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
Location:
libmpc/branches/r2d/libmpcenc
Files:
3 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
  • libmpc/branches/r2d/libmpcenc/encode_sv7.c

    r203 r204  
    2424#include <mpc/minimax.h>
    2525
    26 // bitstream.c
    27 void writeBits (mpc_encoder_t * e, mpc_uint32_t input, unsigned int bits );
    28 unsigned int encodeSize(mpc_uint64_t, char *, mpc_bool_t);
    29 void encodeEnum(mpc_encoder_t * e, const mpc_uint32_t bits, const mpc_uint_t N);
    30 void encodeLog(mpc_encoder_t * e, mpc_uint32_t value, mpc_uint32_t max);
    31 void writeBlock ( mpc_encoder_t * e, const char * key, const mpc_bool_t addCRC);
    32 
    33 void       Init_Huffman_Encoder_SV7   ( void );
    34 
    35 void   Klemm ( void );
    36 
    37 void   Init_Skalenfaktoren             ( void );
     26void Klemm ( void );
     27void Init_Skalenfaktoren ( void );
    3828
    3929// huffsv7.c
     
    358348                }
    359349                e->block_cnt++;
    360                 writeBlock(e, "AD", MPC_FALSE);
     350                writeBlock(e, "AD", MPC_FALSE, 0);
    361351        }
    362352}
  • libmpc/branches/r2d/libmpcenc/libmpcenc.h

    r203 r204  
    8888                                                 const int version_implement,
    8989                                                 const int version_build );
    90  void writeBlock ( mpc_encoder_t * e, const char * key, const mpc_bool_t addCRC);
     90 mpc_uint32_t writeBlock ( mpc_encoder_t *, const char *, const mpc_bool_t, mpc_uint32_t);
    9191 void writeMagic (mpc_encoder_t * e);
    9292 void writeBits (mpc_encoder_t * e, mpc_uint32_t input, unsigned int bits );
     
    9494 void writeBitstream_SV8 ( mpc_encoder_t*, int);
    9595
     96 unsigned int encodeSize(mpc_uint64_t, char *, mpc_bool_t);
     97 void encodeEnum(mpc_encoder_t * e, const mpc_uint32_t bits, const mpc_uint_t N);
     98 void encodeLog(mpc_encoder_t * e, mpc_uint32_t value, mpc_uint32_t max);
     99
     100
Note: See TracChangeset for help on using the changeset viewer.