Changeset 151 for libmpc/branches/r2d/libmpcdec
- Timestamp:
- 11/25/06 15:19:25 (18 years ago)
- Location:
- libmpc/branches/r2d/libmpcdec
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpc/branches/r2d/libmpcdec/decoder.h
r126 r151 65 65 //@{ 66 66 mpc_uint32_t stream_version; ///< Streamversion of stream 67 mpc_ uint32_t max_band; ///< Maximum band-index used in stream (0...31)67 mpc_int32_t max_band; ///< Maximum band-index used in stream (0...31) 68 68 mpc_uint32_t ms; ///< Mid/side stereo (0: off, 1: on) 69 69 mpc_uint32_t channels; ///< Number of channels in stream -
libmpc/branches/r2d/libmpcdec/mpc_decoder.c
r143 r151 158 158 159 159 samples_left = d->samples - d->decoded_samples + MPC_DECODER_SYNTH_DELAY; 160 i->samples = samples_left > MPC_FRAME_LENGTH ? MPC_FRAME_LENGTH : samples_left < 0 ? 0 : samples_left;161 i->bits = ( (r->buff - r_sav.buff) << 3) + r_sav.count - r->count;160 i->samples = samples_left > MPC_FRAME_LENGTH ? MPC_FRAME_LENGTH : samples_left < 0 ? 0 : (mpc_uint32_t) samples_left; 161 i->bits = (mpc_uint32_t) (((r->buff - r_sav.buff) << 3) + r_sav.count - r->count); 162 162 163 163 if (d->samples_to_skip) { -
libmpc/branches/r2d/libmpcdec/mpc_demux.c
r150 r151 33 33 */ 34 34 35 #include <string.h> 35 36 #include <mpcdec/streaminfo.h> 36 37 #include <mpcdec/mpcdec.h> … … 114 115 */ 115 116 static void 116 mpc_demux_seek(mpc_demux * d, mpc_ uint32_t fpos, mpc_uint32_t min_bytes) {117 mpc_demux_seek(mpc_demux * d, mpc_size_t fpos, mpc_uint32_t min_bytes) { 117 118 // mpc_uint32_t cur_pos = d->r->tell(d->r); 118 mpc_ uint32_t next_pos;119 mpc_size_t next_pos; 119 120 mpc_int_t bit_offset; 120 121 … … 123 124 next_pos = fpos >> 3; 124 125 if (d->si.stream_version == 7) 125 next_pos &= (-1 u<< 2);126 bit_offset = fpos - (next_pos << 3);126 next_pos &= (-1 << 2); 127 bit_offset = (int) (fpos - (next_pos << 3)); 127 128 next_pos += d->si.header_position; // add id3 offset 128 129 129 d->r->seek(d->r, next_pos);130 d->r->seek(d->r, (mpc_int32_t) next_pos); 130 131 mpc_demux_clear_buff(d); 131 132 if (d->si.stream_version == 7) … … 155 156 if (d->si.block_pwr > d->seek_pwr) 156 157 d->seek_pwr = d->si.block_pwr; 157 d->seek_table = malloc(( 1 + d->si.samples / (MPC_FRAME_LENGTH << d->seek_pwr)) * sizeof(mpc_uint32_t));158 d->seek_table = malloc((size_t)(1 + d->si.samples / (MPC_FRAME_LENGTH << d->seek_pwr)) * sizeof(mpc_uint32_t)); 158 159 if (d->seek_table == 0) 159 160 return MPC_STATUS_FILE; 160 d->seek_table[0] = mpc_demux_pos(d);161 d->seek_table[0] = (mpc_uint32_t)mpc_demux_pos(d); 161 162 d->seek_table_size = 1; 162 163 … … 175 176 176 177 mpc_bits_get_size(&r, &tmp); 177 d->seek_table_size = tmp;178 d->seek_table_size = (mpc_uint32_t) tmp; 178 179 d->seek_pwr = d->si.block_pwr + mpc_bits_read(&r, 4); 179 d->seek_table = malloc(( 1 + d->si.samples / (MPC_FRAME_LENGTH << d->seek_pwr)) * sizeof(mpc_uint32_t));180 d->seek_table = malloc((size_t)(1 + d->si.samples / (MPC_FRAME_LENGTH << d->seek_pwr)) * sizeof(mpc_uint32_t)); 180 181 181 182 table = d->seek_table; 182 183 mpc_bits_get_size(&r, &tmp); 183 table[0] = ( tmp + d->si.header_position) * 8;184 table[0] = (mpc_uint32_t) (tmp + d->si.header_position) * 8; 184 185 185 186 if (d->seek_table_size == 1) … … 187 188 188 189 mpc_bits_get_size(&r, &tmp); 189 table[1] = ( tmp + d->si.header_position) * 8;190 table[1] = (mpc_uint32_t) (tmp + d->si.header_position) * 8; 190 191 191 192 for (i = 2; i < d->seek_table_size; i++) { 192 193 int code = mpc_bits_golomb_dec(&r, 12); 193 194 if (code & 1) 194 code = -(code & (-1 u<< 1));195 code = -(code & (-1 << 1)); 195 196 code <<= 2; 196 197 table[i] = code + 2 * table[i-1] - table[i-2]; … … 209 210 mpc_bits_get_block(&d->bits_reader, &b); 210 211 if (memcmp(b.key, "ST", 2) == 0) { 211 mpc_demux_fill(d, b.size, 0);212 mpc_demux_fill(d, (mpc_uint32_t) b.size, 0); 212 213 mpc_demux_ST(d); 213 214 } … … 253 254 size = mpc_bits_get_block(&d->bits_reader, &b); 254 255 while( memcmp(b.key, "AD", 2) != 0 ){ // scan all blocks until audio 255 mpc_demux_fill(d, 11 + b.size, 0);256 mpc_demux_fill(d, 11 + (mpc_uint32_t) b.size, 0); 256 257 if (memcmp(b.key, "SI", 2) == 0){ 257 int ret = streaminfo_read_header_sv8(&d->si, &d->bits_reader, b.size);258 int ret = streaminfo_read_header_sv8(&d->si, &d->bits_reader, (mpc_uint32_t) b.size); 258 259 if (ret != MPC_STATUS_OK) return ret; 259 260 } else if (memcmp(b.key, "EI", 2) == 0) 260 261 streaminfo_encoder_info(&d->si, &d->bits_reader); 261 262 else if (memcmp(b.key, "SP", 2) == 0) 262 mpc_demux_SP(d, size, b.size);263 mpc_demux_SP(d, size, (mpc_uint32_t) b.size); 263 264 else if (memcmp(b.key, "ST", 2) == 0) 264 265 mpc_demux_ST(d); … … 315 316 d->bits_reader.count &= -8; 316 317 if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) { 317 d->seek_table[d->seek_table_size] = mpc_demux_pos(d);318 d->seek_table[d->seek_table_size] = (mpc_uint32_t) mpc_demux_pos(d); 318 319 d->seek_table_size ++; 319 320 } … … 325 326 break; 326 327 } 327 mpc_demux_fill(d, 11 + b.size, 0);328 mpc_demux_fill(d, 11 + (mpc_uint32_t) b.size, 0); 328 329 d->bits_reader.buff += b.size; 329 330 mpc_bits_get_block(&d->bits_reader, &b); 330 331 } 331 d->block_bits = b.size * 8;332 d->block_bits = (mpc_uint32_t) b.size * 8; 332 333 } 333 334 // FIXME : this is not good if block size > buffer size … … 337 338 d->block_bits -= ((d->bits_reader.buff - r.buff) << 3) + r.count - d->bits_reader.count; 338 339 } else { 340 mpc_bits_reader r; 339 341 if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) { 340 d->seek_table[d->seek_table_size] = mpc_demux_pos(d);342 d->seek_table[d->seek_table_size] = (mpc_uint32_t) mpc_demux_pos(d); 341 343 d->seek_table_size ++; 342 344 } 343 mpc_bits_reader r;344 345 mpc_demux_fill(d, MAX_FRAME_SIZE, MPC_BUFFER_FULL | MPC_BUFFER_SWAP); 345 346 mpc_bits_read(&d->bits_reader, 20); // read frame size … … 354 355 } 355 356 356 mpc_status mpc_demux_seek_sample(mpc_demux * d, mpc_ int64_t destsample)357 mpc_status mpc_demux_seek_sample(mpc_demux * d, mpc_uint64_t destsample) 357 358 { 358 359 mpc_uint32_t fwd, samples_to_skip, fpos, i; … … 388 389 if (memcmp(b.key, "AD", 2) == 0) { 389 390 if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) { 390 d->seek_table[d->seek_table_size] = mpc_demux_pos(d) - 8 * size;391 d->seek_table[d->seek_table_size] = (mpc_uint32_t) mpc_demux_pos(d) - 8 * size; 391 392 d->seek_table_size ++; 392 393 } … … 394 395 i++; 395 396 } 396 fpos += ( b.size + size) * 8;397 fpos += ((mpc_uint32_t)b.size + size) * 8; 397 398 mpc_demux_seek(d, fpos, 11); 398 399 size = mpc_bits_get_block(&d->bits_reader, &b); … … 404 405 for( ; i < fwd; i++){ 405 406 if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) { 406 d->seek_table[d->seek_table_size] = mpc_demux_pos(d);407 d->seek_table[d->seek_table_size] = (mpc_uint32_t) mpc_demux_pos(d); 407 408 d->seek_table_size ++; 408 409 } -
libmpc/branches/r2d/libmpcdec/streaminfo.c
r150 r151 163 163 164 164 CRC = mpc_bits_read(&r, 32); 165 if (CRC != crc32(r.buff + 1 - (r.count >> 3), block_size - 4))165 if (CRC != crc32(r.buff + 1 - (r.count >> 3), (int)block_size - 4)) 166 166 return MPC_STATUS_FILE; 167 167
Note: See TracChangeset
for help on using the changeset viewer.