Ignore:
Timestamp:
11/23/06 19:17:14 (17 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/bitstream.c

    r147 r149  
    136136void writeSeekTable (mpc_encoder_t * e)
    137137{
    138         mpc_uint32_t tmp1, tmp2, i, len;
     138        mpc_uint32_t i, len;
    139139        mpc_uint32_t * table = e->seek_table;
    140140        mpc_uint8_t tmp[10];
    141141
    142142        // write the position to header
    143         tmp1 = ftell(e->outputFile); // get the seek table position
    144         tmp[0] = (mpc_uint8_t) (tmp1 >> 24);
    145         tmp[1] = (mpc_uint8_t) (tmp1 >> 16);
    146         tmp[2] = (mpc_uint8_t) (tmp1 >> 8);
    147         tmp[3] = (mpc_uint8_t) tmp1;
    148         fseek(e->outputFile, e->seek_ref + 3, SEEK_SET);
    149         fwrite(tmp, sizeof(mpc_uint8_t), 4, e->outputFile);
    150         fseek(e->outputFile, tmp1, SEEK_SET);
     143        i = ftell(e->outputFile); // get the seek table position
     144        len = encodeSize(i - e->seek_ptr, (char*)tmp, MPC_FALSE);
     145        fseek(e->outputFile, e->seek_ptr + 3, SEEK_SET);
     146        fwrite(tmp, sizeof(mpc_uint8_t), len, e->outputFile);
     147        fseek(e->outputFile, i, SEEK_SET);
    151148
    152         tmp1 = table[0];
    153         tmp2 = table[1];
    154 
    155         len = encodeSize(tmp1 - e->seek_ref, tmp, MPC_FALSE);
     149        // write the seek table datas
     150        len = encodeSize(e->seek_pos, (char*)tmp, MPC_FALSE);
    156151        for( i = 0; i < len; i++)
    157152                writeBits ( e, tmp[i], 8 );
    158         len = encodeSize(tmp2 - e->seek_ref, tmp, MPC_FALSE);
     153        writeBits ( e, e->seek_pwr, 4 );
     154
     155        len = encodeSize(table[0] - e->seek_ref, (char*)tmp, MPC_FALSE);
    159156        for( i = 0; i < len; i++)
    160157                writeBits ( e, tmp[i], 8 );
     158        if (e->seek_pos > 1) {
     159                len = encodeSize(table[1] - e->seek_ref, (char*)tmp, MPC_FALSE);
     160                for( i = 0; i < len; i++)
     161                        writeBits ( e, tmp[i], 8 );
     162        }
    161163
    162164        for( i = 2; i < e->seek_pos; i++){
    163                 int code = table[i] - 2 * tmp2 + tmp1;
    164                 tmp1 = tmp2;
    165                 tmp2 = table[i];
    166                 if (code >= 0) {
    167                         writeBits(e, 0, 1);
    168                         encodeGolomb(e, code, 10);
    169                 } else {
    170                         writeBits(e, 1, 1);
    171                         encodeGolomb(e, -code, 10);
    172                 }
     165                int code = (table[i] - 2 * table[i-1] + table[i-2]) << 1;
     166                if (code < 0)
     167                        code = -code | 1;
     168                encodeGolomb(e, code, 12);
    173169        }
    174170}
Note: See TracChangeset for help on using the changeset viewer.