Changeset 302 for libmpc/trunk/libmpcdec
- Timestamp:
- 05/02/07 22:31:31 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpc/trunk/libmpcdec/mpc_demux.c
r301 r302 101 101 } 102 102 103 return 0;103 return (mpc_uint32_t) -1; 104 104 } 105 105 … … 367 367 { 368 368 mpc_bits_reader r; 369 int pos = 0; 369 370 if (d->si.stream_version >= 8) { 370 371 i->is_key_frame = MPC_FALSE; … … 379 380 mpc_demux_fill(d, 11, 0); // max header block size 380 381 mpc_bits_get_block(&d->bits_reader, &b); 382 pos = mpc_demux_pos(d) >> 3; 381 383 while( memcmp(b.key, "AP", 2) != 0 ) { // scan all blocks until audio 384 if (b.key[0] < 65 || b.key[0] > 90 || b.key[1] < 65 || b.key[1] > 90 385 || b.size > (mpc_uint64_t) DEMUX_BUFFER_SIZE - 11) 386 goto error; 382 387 if (memcmp(b.key, "SE", 2) == 0) { // end block 383 388 i->bits = -1; 384 389 return MPC_STATUS_OK; 385 390 } 386 mpc_demux_fill(d, 11 + (mpc_uint32_t) b.size, 0); 391 if (mpc_demux_fill(d, 11 + (mpc_uint32_t) b.size, 0) == 0) 392 goto error; 387 393 d->bits_reader.buff += b.size; 388 394 mpc_bits_get_block(&d->bits_reader, &b); … … 392 398 i->is_key_frame = MPC_TRUE; 393 399 } 394 if (d->buffer + d->bytes_total - d->bits_reader.buff <= MAX_FRAME_SIZE )400 if (d->buffer + d->bytes_total - d->bits_reader.buff <= MAX_FRAME_SIZE * 2) 395 401 mpc_demux_fill(d, (d->block_bits >> 3) + 1, 0); 396 402 r = d->bits_reader; … … 398 404 d->block_bits -= ((d->bits_reader.buff - r.buff) << 3) + r.count - d->bits_reader.count; 399 405 d->block_frames--; 400 if (d->block_bits < 0 || (d->block_frames == 0 && d->block_bits > 7)) { 401 i->bits = -1; // we pretend it's end of file 402 return MPC_STATUS_INVALIDSV; 403 } 406 if (d->block_bits < 0 || (d->block_frames == 0 && d->block_bits > 7)) 407 goto error; 404 408 } else { 405 409 if (d->d->decoded_samples == (d->seek_table_size << d->seek_pwr) * MPC_FRAME_LENGTH) { … … 412 416 r = d->bits_reader; 413 417 mpc_decoder_decode_frame(d->d, &d->bits_reader, i); 414 if (i->bits != -1 && d->block_bits != ((d->bits_reader.buff - r.buff) << 3) + r.count - d->bits_reader.count) { 415 i->bits = -1; // we pretend it's end of file 416 return MPC_STATUS_INVALIDSV; 417 } 418 } 419 if (d->buffer + d->bytes_total < d->bits_reader.buff + ((8 - d->bits_reader.count) >> 3)) { 418 if (i->bits != -1 && d->block_bits != ((d->bits_reader.buff - r.buff) << 3) + r.count - d->bits_reader.count) 419 goto error; 420 } 421 if (d->buffer + d->bytes_total < d->bits_reader.buff + ((8 - d->bits_reader.count) >> 3)) 422 goto error; 423 424 return MPC_STATUS_OK; 425 error: 420 426 i->bits = -1; // we pretend it's end of file 421 return MPC_STATUS_INVALIDSV; 422 } 423 return MPC_STATUS_OK; 427 // return MPC_STATUS_INVALIDSV; 428 return pos; 424 429 } 425 430
Note: See TracChangeset
for help on using the changeset viewer.