Changeset 117


Ignore:
Timestamp:
11/11/06 18:22:26 (17 years ago)
Author:
r2d
Message:
  • read "EI" and "RG" blocks
  • updated "SI" block according to the spec
Location:
libmpcdec/branches/zorg
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libmpcdec/branches/zorg/include/mpcdec/streaminfo.h

    r104 r117  
    6565    mpc_int64_t          pcm_samples;        ///< Approximate number of pcm samples in stream
    6666    mpc_uint32_t         max_band;           ///< Maximum band-index used in stream (0...31)
    67     mpc_uint32_t         is;                 ///< Intensity stereo (0: off, 1: on)
    6867    mpc_uint32_t         ms;                 ///< Mid/side stereo (0: off, 1: on)
    69     mpc_uint32_t         block_size;         ///< Only needed for SV4...SV6 -> not supported
    70     mpc_uint32_t         profile;            ///< Quality profile of stream
    71     const char*          profile_name;       ///< Name of profile used by stream
    72     mpc_uint32_t         fast_seek;          ///< True if stream supports fast-seeking
     68        mpc_uint32_t         fast_seek;          ///< True if stream supports fast-seeking (sv7)
     69        mpc_uint32_t         frames_per_block;   ///< Number of frames in a block (sv8)
    7370    //@}
    7471
     
    8481    //@{
    8582    mpc_uint32_t         is_true_gapless;    ///< True gapless? (0: no, 1: yes)
    86     mpc_uint32_t         last_frame_samples; ///< Number of valid samples within last frame
     83        mpc_uint32_t         last_frame_samples; ///< Number of valid samples within last frame
     84    //@}
    8785
     86        /// @name Encoder informations
     87    //@{
    8888    mpc_uint32_t         encoder_version;    ///< Version of encoder used
    8989    char                 encoder[256];       ///< Encoder name
     90        mpc_bool_t           pns;                ///< pns used
     91        mpc_uint32_t         profile;            ///< Quality profile of stream
     92        const char*          profile_name;       ///< Name of profile used by stream
     93        //@}
    9094
    9195    mpc_streaminfo_off_t tag_offset;         ///< Offset to file tags
    9296    mpc_streaminfo_off_t total_file_length;  ///< Total length of underlying file
    93     //@}
    9497} mpc_streaminfo;
    9598
  • libmpcdec/branches/zorg/src/mpc_demux.c

    r108 r117  
    4545mpc_status streaminfo_read_header_sv8(mpc_streaminfo* si, const mpc_bits_reader * r_in);
    4646mpc_status streaminfo_read_header_sv7(mpc_streaminfo* si, mpc_bits_reader * r_in);
     47void  streaminfo_encoder_info(mpc_streaminfo* si, const mpc_bits_reader * r_in);
     48void  streaminfo_gain(mpc_streaminfo* si, const mpc_bits_reader * r_in);
    4749
    4850#define MAX_FRAME_SIZE 4352
     
    133135                        if (memcmp(b.key, "SI", 2) == 0)
    134136                                streaminfo_read_header_sv8(&d->si, &d->bits_reader);
     137                        else if (memcmp(b.key, "EI", 2) == 0)
     138                                streaminfo_encoder_info(&d->si, &d->bits_reader);
     139                        else if (memcmp(b.key, "RG", 2) == 0)
     140                                streaminfo_gain(&d->si, &d->bits_reader);
    135141                        d->bits_reader.buff += b.size;
    136142                        size = mpc_bits_get_block(&d->bits_reader, &b);
  • libmpcdec/branches/zorg/src/streaminfo.c

    r104 r117  
    6060mpc_get_encoder_string(mpc_streaminfo* si)
    6161{
    62         if (si->encoder_version == 0) {
    63                 sprintf(si->encoder, "Buschmann 1.7.0...9, Klemm 0.90...1.05");
     62        if (si->stream_version < 8) {
     63                if (si->encoder_version == 0) {
     64                        sprintf(si->encoder, "Buschmann 1.7.0...9, Klemm 0.90...1.05");
     65                } else {
     66                        switch (si->encoder_version % 10) {
     67                                case 0:
     68                                        sprintf(si->encoder, "Release %u.%u", si->encoder_version / 100,
     69                                                        si->encoder_version / 10 % 10);
     70                                        break;
     71                                case 2: case 4: case 6: case 8:
     72                                        sprintf(si->encoder, "Beta %u.%02u", si->encoder_version / 100,
     73                                                        si->encoder_version % 100);
     74                                        break;
     75                                default:
     76                                        sprintf(si->encoder, "--Alpha-- %u.%02u",
     77                                                        si->encoder_version / 100, si->encoder_version % 100);
     78                                        break;
     79                        }
     80                }
    6481        } else {
    65                 switch (si->encoder_version % 10) {
    66                         case 0:
    67                                 sprintf(si->encoder, "Release %u.%u", si->encoder_version / 100,
    68                                                 si->encoder_version / 10 % 10);
    69                                 break;
    70                         case 2: case 4: case 6: case 8:
    71                                 sprintf(si->encoder, "Beta %u.%02u", si->encoder_version / 100,
    72                                                 si->encoder_version % 100);
    73                                 break;
    74                         default:
    75                                 sprintf(si->encoder, "--Alpha-- %u.%02u",
    76                                                 si->encoder_version / 100, si->encoder_version % 100);
    77                                 break;
    78                 }
     82                int major = si->encoder_version >> 24;
     83                int minor = (si->encoder_version >> 16) & 0xFF;
     84                int impl = (si->encoder_version >> 8) & 0xFF;
     85                int build = si->encoder_version & 0xFF;
     86                char * tmp = "--Stable--";
     87
     88                if (minor & 1)
     89                        tmp = "--Unstable--";
     90
     91                sprintf(si->encoder, "%s %u.%u.%u build %u", tmp, major, minor, impl,
     92                                build);
    7993        }
    8094}
     
    87101
    88102        si->bitrate            = 0;
    89         si->block_size         = 1;
    90103        si->frames             = mpc_bits_read(r, 32);
    91         si->is                 = mpc_bits_read(r, 1); // should be 0
     104        mpc_bits_read(r, 1); // intensity stereo : should be 0
    92105        si->ms                 = mpc_bits_read(r, 1);
    93106        si->max_band           = mpc_bits_read(r, 6);
     
    138151        si->channels = mpc_bits_read(&r, 4) + 1;
    139152        si->max_band = mpc_bits_read(&r, 5) + 1;
    140         // FIXME : this flag will be removed, must be 0
    141         si->is = mpc_bits_read(&r, 1);
    142153        si->ms = mpc_bits_read(&r, 1);
    143 
    144         si->bitrate            = 0;
    145         si->block_size         = 1;
     154        si->frames_per_block = 1 << mpc_bits_read(&r, 4);
     155
     156        si->bitrate = 0;
    146157
    147158        si->pcm_samples     = sampleCount;
     
    152163
    153164        return MPC_STATUS_OK;
     165}
     166
     167/// Reads encoder informations
     168void  streaminfo_encoder_info(mpc_streaminfo* si, const mpc_bits_reader * r_in)
     169{
     170        mpc_bits_reader r = *r_in;
     171
     172        si->profile            = mpc_bits_read(&r, 4);
     173        si->profile_name       = mpc_get_version_string(si->profile);
     174        si->pns                = mpc_bits_read(&r, 1);
     175        mpc_bits_read(&r, 3); // unused
     176        si->encoder_version = mpc_bits_read(&r, 4) << 24; // major
     177        si->encoder_version |= mpc_bits_read(&r, 8) << 16; // minor
     178        si->encoder_version |= mpc_bits_read(&r, 4) << 8; // implementation
     179        si->encoder_version |= mpc_bits_read(&r, 8); // build
     180
     181        mpc_get_encoder_string(si);
     182}
     183
     184/// Reads replay gain datas
     185void  streaminfo_gain(mpc_streaminfo* si, const mpc_bits_reader * r_in)
     186{
     187        mpc_bits_reader r = *r_in;
     188
     189        mpc_bits_read(&r, 8); // gain version
     190        // FIXME : add gain conversion
     191        si->gain_title         = (mpc_uint16_t) mpc_bits_read(&r, 16);
     192        si->peak_title         = (mpc_uint16_t) mpc_bits_read(&r, 16);
     193        si->gain_album         = (mpc_uint16_t) mpc_bits_read(&r, 16);
     194        si->peak_album         = (mpc_uint16_t) mpc_bits_read(&r, 16);
    154195}
    155196
Note: See TracChangeset for help on using the changeset viewer.