Changeset 266 for libmpc/branches/r2d/libmpcdec
- Timestamp:
- 04/15/07 23:40:45 (18 years ago)
- Location:
- libmpc/branches/r2d/libmpcdec
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpc/branches/r2d/libmpcdec/internal.h
r206 r266 62 62 unsigned int count; /// unread bits in current byte 63 63 }; 64 65 #define DEMUX_BUFFER_SIZE 65536 64 65 #define MAX_FRAME_SIZE 4352 66 #define DEMUX_BUFFER_SIZE (65536 - MAX_FRAME_SIZE) // need some space as sand box 66 67 67 68 struct mpc_demux_t { … … 71 72 72 73 // buffer 73 mpc_uint8_t buffer[DEMUX_BUFFER_SIZE ];74 mpc_uint8_t buffer[DEMUX_BUFFER_SIZE + MAX_FRAME_SIZE]; 74 75 mpc_size_t bytes_total; 75 76 mpc_bits_reader bits_reader; -
libmpc/branches/r2d/libmpcdec/mpc_demux.c
r262 r266 50 50 void streaminfo_gain(mpc_streaminfo* si, const mpc_bits_reader * r_in); 51 51 52 #define MAX_FRAME_SIZE 435253 52 54 53 enum { … … 300 299 mpc_demux_fill(d, 11, 0); // max header block size 301 300 size = mpc_bits_get_block(&d->bits_reader, &b); 301 // FIXME : stop scan if invalid key 302 302 while( memcmp(b.key, "AP", 2) != 0 ){ // scan all blocks until audio 303 303 mpc_demux_fill(d, 11 + (mpc_uint32_t) b.size, 0); … … 317 317 } 318 318 d->bits_reader.buff -= size; 319 if (d->si.stream_version == 0) // si no initialized !!! 320 return MPC_STATUS_INVALIDSV; 319 321 } else 320 322 return MPC_STATUS_INVALIDSV; … … 335 337 p_tmp->d = mpc_decoder_init(&p_tmp->si); 336 338 } else { 339 if (p_tmp->seek_table) 340 free(p_tmp->seek_table); 337 341 free(p_tmp); 338 342 p_tmp = 0; … … 357 361 void mpc_demux_decode(mpc_demux * d, mpc_frame_info * i) 358 362 { 363 mpc_bits_reader r; 359 364 if (d->si.stream_version >= 8) { 360 mpc_bits_reader r;361 365 i->is_key_frame = MPC_FALSE; 362 366 … … 389 393 d->block_bits -= ((d->bits_reader.buff - r.buff) << 3) + r.count - d->bits_reader.count; 390 394 d->block_frames--; 391 if (d->block_bits < 0) i->bits = -1; 395 if (d->block_bits < 0 || (d->block_frames == 0 && d->block_bits > 7)) { 396 // an error occured, stop decoding 397 // FIXME : return an error code. 398 i->bits = -1; // we pretend it's end of file 399 } 392 400 } else { 393 mpc_bits_reader r;394 401 if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) { 395 402 d->seek_table[d->seek_table_size] = (mpc_uint32_t) mpc_demux_pos(d); … … 397 404 } 398 405 mpc_demux_fill(d, MAX_FRAME_SIZE, MPC_BUFFER_FULL | MPC_BUFFER_SWAP); 399 mpc_bits_read(&d->bits_reader, 20); // read frame size406 d->block_bits = (mpc_int_t) mpc_bits_read(&d->bits_reader, 20); // read frame size 400 407 r = d->bits_reader; 401 408 mpc_decoder_decode_frame(d->d, &d->bits_reader, i); 409 if (d->block_bits != ((d->bits_reader.buff - r.buff) << 3) + r.count - d->bits_reader.count) { 410 // an error occured, stop decoding 411 // FIXME : return an error code. 412 i->bits = -1; // we pretend it's end of file 413 } 414 } 415 if (d->buffer + d->bytes_total < d->bits_reader.buff + ((8 - d->bits_reader.count) >> 3)) { 416 // we're reading outside the buffer bytes, this is an error ! 417 // FIXME : return an error code. 418 i->bits = -1; // we pretend it's end of file 402 419 } 403 420 }
Note: See TracChangeset
for help on using the changeset viewer.