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
File:
1 edited

Legend:

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

    r147 r149  
    7676        e->Overflows = 0;
    7777        e->seek_pos = 0;
    78 }
    79 
     78        e->block_cnt = 0;
     79        e->seek_pwr = 1;
     80}
     81
     82// writes replay gain info
     83static void writeGainInfo ( mpc_encoder_t * e )
     84{
     85        writeBits ( e, 1,  8 ); // version
     86        writeBits ( e, 0,  16 ); // Title gain
     87        writeBits ( e, 0,  16 ); // Title peak
     88        writeBits ( e, 0,  16 ); // Album gain
     89        writeBits ( e, 0,  16 ); // Album peak
     90}
    8091
    8192// writes SV8-header
     
    8899                                  const unsigned int  ChannelCount)
    89100{
    90         unsigned char samplesCount[10];
    91         int samplesCountLen = encodeSize(SamplesCount, (char *)samplesCount, MPC_FALSE);
    92         int i;
     101        unsigned char tmp[10];
     102        int i, len = encodeSize(SamplesCount, (char *)tmp, MPC_FALSE);
     103
     104        len = encodeSize(len + 4, (char *)tmp, MPC_TRUE);
     105        writeBits ( e, tmp[0]  , 8 );
    93106
    94107    writeBits ( e, 0x08,  8 );    // StreamVersion
    95108
    96         for( i = 0; i < samplesCountLen; i++) // nb of samples
    97                 writeBits ( e, samplesCount[i]  , 8 );
     109        len = encodeSize(SamplesCount, (char *)tmp, MPC_FALSE);
     110        for( i = 0; i < len; i++) // nb of samples
     111                writeBits ( e, tmp[i]  , 8 );
    98112
    99113        switch ( SampleFreq ) {
     
    110124        writeBits ( e, MS_on        ,  1 );    // MS-Coding Flag
    111125        writeBits ( e, FRAMES_PER_BLOCK_PWR,  4 );    // frames per block (log2 unit)
     126        writeBits ( e, 0, 6 );    // unused
     127
     128        writeGainInfo(e);
    112129}
    113130
     
    128145        writeBits ( e, version_implement,  4 );
    129146        writeBits ( e, version_build,  8 );
    130 }
    131 
    132 // writes replay gain info
    133 void writeGainInfo ( mpc_encoder_t * e )
    134 {
    135         writeBits ( e, 1,  8 ); // version
    136         writeBits ( e, 0,  16 ); // Title gain
    137         writeBits ( e, 0,  16 ); // Title peak
    138         writeBits ( e, 0,  16 ); // Album gain
    139         writeBits ( e, 0,  16 ); // Album peak
    140147}
    141148
     
    417424        e->framesInBlock++;
    418425        if (e->framesInBlock == FRAMES_PER_BLOCK) {
    419                 e->seek_table[e->seek_pos] = ftell(e->outputFile);
    420                 e->seek_pos++;
     426                if ((e->block_cnt & ((1 << e->seek_pwr) - 1)) == 0) {
     427                        e->seek_table[e->seek_pos] = ftell(e->outputFile);
     428                        e->seek_pos++;
     429                }
     430                e->block_cnt++;
    421431                writeBlock(e, "AD", MPC_FALSE);
    422432        }
Note: See TracChangeset for help on using the changeset viewer.