Changeset 147 for libmpc/branches/r2d/libmpcenc
- Timestamp:
- 11/20/06 19:53:36 (18 years ago)
- Location:
- libmpc/branches/r2d/libmpcenc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpc/branches/r2d/libmpcenc/bitstream.c
r142 r147 70 70 } 71 71 72 static void encodeGolomb(mpc_encoder_t * e, mpc_uint32_t nb, mpc_uint_t k) 73 { 74 unsigned int l = (nb >> k) + 1; 75 nb &= (1 << k) - 1; 76 77 while( l > 32 ){ 78 writeBits(e, 0, 32); 79 l -= 32; 80 } 81 writeBits(e, 1, l); 82 writeBits(e, nb, k); 83 } 84 72 85 void writeMagic(mpc_encoder_t * e) 73 86 { … … 121 134 } 122 135 136 void writeSeekTable (mpc_encoder_t * e) 137 { 138 mpc_uint32_t tmp1, tmp2, i, len; 139 mpc_uint32_t * table = e->seek_table; 140 mpc_uint8_t tmp[10]; 141 142 // 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); 151 152 tmp1 = table[0]; 153 tmp2 = table[1]; 154 155 len = encodeSize(tmp1 - e->seek_ref, tmp, MPC_FALSE); 156 for( i = 0; i < len; i++) 157 writeBits ( e, tmp[i], 8 ); 158 len = encodeSize(tmp2 - e->seek_ref, tmp, MPC_FALSE); 159 for( i = 0; i < len; i++) 160 writeBits ( e, tmp[i], 8 ); 161 162 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 } 173 } 174 } 175 123 176 /* end of bitstream.c */ -
libmpc/branches/r2d/libmpcenc/encode_sv7.c
r142 r147 75 75 e->bitsBuff = 0; 76 76 e->Overflows = 0; 77 e->seek_pos = 0; 77 78 } 78 79 … … 415 416 416 417 e->framesInBlock++; 417 if (e->framesInBlock == FRAMES_PER_BLOCK) 418 if (e->framesInBlock == FRAMES_PER_BLOCK) { 419 e->seek_table[e->seek_pos] = ftell(e->outputFile); 420 e->seek_pos++; 418 421 writeBlock(e, "AD", MPC_FALSE); 422 } 419 423 } 420 424 -
libmpc/branches/r2d/libmpcenc/libmpcenc.h
r137 r147 32 32 #define BUFFER_FULL (4352 * FRAMES_PER_BLOCK) // 34490 bit/frame 1320.3 kbps 33 33 34 // FIXME : make this size dependent of the input file 35 #define SEEK_SIZE (1 << 16) // number of seek entries 36 34 37 typedef struct { 35 38 unsigned int L [36]; 36 39 unsigned int R [36]; 37 40 } SubbandQuantTyp; 38 39 // TODO : enc/dec common struct40 // just the same struct as below, dup ?41 41 42 42 typedef struct { … … 53 53 mpc_uint_t framesInBlock; 54 54 55 // seeking 56 mpc_uint32_t seek_table[SEEK_SIZE]; 57 mpc_uint32_t seek_pos; /// current position in the seek table 58 mpc_uint32_t seek_ref; /// reference position for the seek information 59 55 60 FILE * outputFile; // ouput file 56 61
Note: See TracChangeset
for help on using the changeset viewer.