Ignore:
Timestamp:
02/17/07 18:49:10 (17 years ago)
Author:
r2d
Message:
  • updated according to the spec
  • now reads / write beginning / end silences, but decoder does not care.
  • please test !
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libmpc/branches/r2d/libmpcenc/encode_sv7.c

    r212 r220  
    6060
    6161// writes replay gain info
    62 static void writeGainInfo ( mpc_encoder_t * e,
    63                                                         unsigned short t_gain,
    64                                                         unsigned short t_peak,
    65                                                         unsigned short a_gain,
    66                                                         unsigned short a_peak)
     62void writeGainInfo ( mpc_encoder_t * e,
     63                                         unsigned short t_gain,
     64                                         unsigned short t_peak,
     65                                         unsigned short a_gain,
     66                                         unsigned short a_peak)
    6767{
    6868        writeBits ( e, 1,  8 ); // version
     
    8080                  const unsigned int  SamplesCount,
    8181                  const unsigned int  SampleFreq,
    82                                   const unsigned int  ChannelCount,
    83                                   unsigned short t_gain,
    84                                   unsigned short t_peak,
    85                                   unsigned short a_gain,
    86                                   unsigned short a_peak)
     82                                  const unsigned int  ChannelCount)
    8783{
    8884        unsigned char tmp[10];
    89         int i, len = encodeSize(SamplesCount, (char *)tmp, MPC_FALSE);
    90 
    91         len = encodeSize(len + 3, (char *)tmp, MPC_TRUE);
    92         writeBits ( e, tmp[0]  , 8 );
     85        int i, len;
    9386
    9487    writeBits ( e, 8,  8 );    // StreamVersion
     
    9689        len = encodeSize(SamplesCount, (char *)tmp, MPC_FALSE);
    9790        for( i = 0; i < len; i++) // nb of samples
    98                 writeBits ( e, tmp[i]  , 8 );
     91                writeBits ( e, tmp[i], 8 );
     92        writeBits ( e, 0, 8 ); // nb of samples to skip at beginning
     93        writeBits ( e, 0, 8 ); // nb of samples to skip at end
    9994
    10095        switch ( SampleFreq ) {
     
    107102        }
    108103
     104        writeBits ( e, MaxBand - 1  ,  5 );    // Bandwidth
    109105        writeBits ( e, ChannelCount - 1  ,  4 );    // Channels
    110         writeBits ( e, MaxBand - 1  ,  5 );    // Bandwidth
    111106        writeBits ( e, MS_on        ,  1 );    // MS-Coding Flag
    112107        writeBits ( e, FRAMES_PER_BLOCK_PWR >> 1,  3 );    // frames per block (log4 unit)
    113 
    114         writeGainInfo(e, t_gain, t_peak, a_gain, a_peak);
    115108}
    116109
     
    121114                                                const int version_major,
    122115                                                const int version_minor,
    123                                                 const int version_implement,
    124116                                                const int version_build )
    125117{
    126118        writeBits ( e, (mpc_uint32_t)(profile * 8 + .5),  7 );
    127119        writeBits ( e, PNS_on,  1 );
    128         writeBits ( e, version_major,  4 );
     120        writeBits ( e, version_major,  8 );
    129121        writeBits ( e, version_minor,  8 );
    130         writeBits ( e, version_implement,  4 );
    131122        writeBits ( e, version_build,  8 );
    132123}
     
    269260        for ( n = 0; n < MaxBand; n++ ) {
    270261                int Res = e->Res_L[n];
    271                 const unsigned int * q = e->Q[n].L;
     262                const int * q = e->Q[n].L;
    272263                static const unsigned int thres[] = {0, 0, 3, 7, 9, 1, 3, 4, 8};
    273264                static const int HuffQ2_var[5*5*5] =
     
    356347                }
    357348                e->block_cnt++;
    358                 writeBlock(e, "AD", MPC_FALSE, 0);
     349                writeBlock(e, "AP", MPC_FALSE, 0);
    359350        }
    360351}
Note: See TracChangeset for help on using the changeset viewer.