Ignore:
Timestamp:
11/23/06 19:17:14 (18 years ago)
Author:
r2d
Message:
  • merged SI and RG blocks
  • updated seek table according to the spec in mppenc
Location:
libmpc/branches/r2d/libmpcdec
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libmpc/branches/r2d/libmpcdec/mpc_demux.c

    r148 r149  
    189189                        } else if (memcmp(b.key, "EI", 2) == 0)
    190190                                streaminfo_encoder_info(&d->si, &d->bits_reader);
    191                         else if (memcmp(b.key, "RG", 2) == 0)
    192                                 streaminfo_gain(&d->si, &d->bits_reader);
    193191                        d->bits_reader.buff += b.size;
    194192                        size = mpc_bits_get_block(&d->bits_reader, &b);
  • libmpc/branches/r2d/libmpcdec/streaminfo.c

    r146 r149  
    140140}
    141141
     142/// Reads replay gain datas
     143void  streaminfo_gain(mpc_streaminfo* si, const mpc_bits_reader * r_in)
     144{
     145        mpc_bits_reader r = *r_in;
     146
     147        mpc_bits_read(&r, 8); // gain version
     148        // FIXME : add gain conversion
     149        si->gain_title         = (mpc_uint16_t) mpc_bits_read(&r, 16);
     150        si->peak_title         = (mpc_uint16_t) mpc_bits_read(&r, 16);
     151        si->gain_album         = (mpc_uint16_t) mpc_bits_read(&r, 16);
     152        si->peak_album         = (mpc_uint16_t) mpc_bits_read(&r, 16);
     153}
     154
    142155/// Reads streaminfo from SV8 header.
    143156mpc_status
     
    145158                                                   mpc_size_t block_size)
    146159{
    147         mpc_uint32_t CRC, CRC_tmp;
    148         mpc_bits_reader r = *r_in;
     160        mpc_uint32_t CRC;
     161        mpc_uint64_t info_len;
     162        mpc_bits_reader r = *r_in, r_gain;
    149163
    150164        CRC = mpc_bits_read(&r, 32);
    151         CRC_tmp = crc32(r.buff + 1 - (r.count >> 3), block_size - 4);
    152         if (CRC != CRC_tmp)
     165        if (CRC != crc32(r.buff + 1 - (r.count >> 3), block_size - 4))
    153166                return MPC_STATUS_FILE;
     167
     168        r_gain = r;
     169        mpc_bits_get_size(&r, &info_len);
     170        r_gain.buff += info_len;
    154171
    155172        si->stream_version = mpc_bits_read(&r, 8);
     
    164181        si->bitrate = 0;
    165182
    166         si->average_bitrate = (si->tag_offset - si->header_position) * 8.0
    167                         *  si->sample_freq / si->samples;
     183        if (si->samples != 0)
     184                si->average_bitrate = (si->tag_offset - si->header_position) * 8.0
     185                                *  si->sample_freq / si->samples;
     186
     187        streaminfo_gain(si, &r_gain);
    168188
    169189        return MPC_STATUS_OK;
     
    187207}
    188208
    189 /// Reads replay gain datas
    190 void  streaminfo_gain(mpc_streaminfo* si, const mpc_bits_reader * r_in)
    191 {
    192         mpc_bits_reader r = *r_in;
    193 
    194         mpc_bits_read(&r, 8); // gain version
    195         // FIXME : add gain conversion
    196         si->gain_title         = (mpc_uint16_t) mpc_bits_read(&r, 16);
    197         si->peak_title         = (mpc_uint16_t) mpc_bits_read(&r, 16);
    198         si->gain_album         = (mpc_uint16_t) mpc_bits_read(&r, 16);
    199         si->peak_album         = (mpc_uint16_t) mpc_bits_read(&r, 16);
    200 }
    201 
    202209double
    203210mpc_streaminfo_get_length(mpc_streaminfo * si)
Note: See TracChangeset for help on using the changeset viewer.