Ignore:
Timestamp:
02/08/07 21:36:52 (18 years ago)
Author:
r2d
Message:
  • file length should be OK for all files
  • seems there is a bug at end of file
File:
1 edited

Legend:

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

    r194 r204  
    194194}
    195195
    196 void writeBlock ( mpc_encoder_t * e, const char * key, const mpc_bool_t addCRC)
     196mpc_uint32_t writeBlock ( mpc_encoder_t * e, const char * key, const mpc_bool_t addCRC, mpc_uint32_t min_size)
    197197{
    198198        FILE * fp = e->outputFile;
     
    200200        mpc_uint8_t * datas = e->buffer;
    201201        char blockSize[10];
    202         mpc_uint_t len;
     202        mpc_uint32_t len;
    203203
    204204        writeBits(e, 0, (8 - e->bitsCount) % 8);
     
    206206
    207207        // write block header (key / length)
    208         len = encodeSize(e->pos + 2 + (addCRC ? 4 : 0), blockSize, MPC_TRUE);
     208        len = e->pos + 2 + (addCRC > 0) * 4;
     209        if (min_size <= len)
     210                min_size = len;
     211        else {
     212                mpc_uint32_t pad = min_size - len, i;
     213                for(i = 0; i < pad; i++)
     214                        writeBits(e, 0, 8);
     215        }
     216        len = encodeSize(min_size, blockSize, MPC_TRUE);
    209217        fwrite(key, sizeof(char), 2, fp);
    210218        fwrite(blockSize, sizeof(char), len, fp);
    211219        e->outputBits += (len + 2) * 8;
    212 
    213220
    214221        if (addCRC) {
     
    236243        }
    237244        e->framesInBlock = 0;
     245
     246        return min_size;
    238247}
    239248
Note: See TracChangeset for help on using the changeset viewer.