comparison flacdec.c @ 9239:af76987c8d53 libavcodec

flacdec: change frame bps validation to return an error value if bps changes since this is not currently supported by the decoder.
author jbr
date Sun, 22 Mar 2009 22:10:33 +0000
parents 11a79ab2279d
children 4f827ca90571
comparison
equal deleted inserted replaced
9238:11a79ab2279d 9239:af76987c8d53
510 return -1; 510 return -1;
511 } 511 }
512 512
513 /* bits per sample */ 513 /* bits per sample */
514 bps_code = get_bits(gb, 3); 514 bps_code = get_bits(gb, 3);
515 if (bps_code == 0) { 515 if (bps_code == 3 || bps_code == 7) {
516 bps= s->bps;
517 } else if ((bps_code != 3) && (bps_code != 7)) {
518 bps = sample_size_table[bps_code];
519 } else {
520 av_log(s->avctx, AV_LOG_ERROR, "invalid sample size code (%d)\n", 516 av_log(s->avctx, AV_LOG_ERROR, "invalid sample size code (%d)\n",
521 bps_code); 517 bps_code);
522 return -1; 518 return -1;
523 } 519 }
524 if (bps > 16) { 520 bps = sample_size_table[bps_code];
521 if (bps && bps != s->bps) {
522 av_log(s->avctx, AV_LOG_ERROR, "switching bps mid-stream is not "
523 "supported\n");
524 return -1;
525 }
526 if (s->bps > 16) {
525 s->avctx->sample_fmt = SAMPLE_FMT_S32; 527 s->avctx->sample_fmt = SAMPLE_FMT_S32;
526 s->sample_shift = 32 - bps; 528 s->sample_shift = 32 - s->bps;
527 s->is32 = 1; 529 s->is32 = 1;
528 } else { 530 } else {
529 s->avctx->sample_fmt = SAMPLE_FMT_S16; 531 s->avctx->sample_fmt = SAMPLE_FMT_S16;
530 s->sample_shift = 16 - bps; 532 s->sample_shift = 16 - s->bps;
531 s->is32 = 0; 533 s->is32 = 0;
532 } 534 }
533 s->bps = s->avctx->bits_per_raw_sample = bps;
534 535
535 /* reserved bit */ 536 /* reserved bit */
536 if (get_bits1(gb)) { 537 if (get_bits1(gb)) {
537 av_log(s->avctx, AV_LOG_ERROR, "broken stream, invalid padding\n"); 538 av_log(s->avctx, AV_LOG_ERROR, "broken stream, invalid padding\n");
538 return -1; 539 return -1;