Changeset 147 for libmpc/branches/r2d/libmpcenc/bitstream.c
- Timestamp:
- 11/20/06 19:53:36 (18 years ago)
- File:
-
- 1 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 */
Note: See TracChangeset
for help on using the changeset viewer.