diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2009-03-22 22:10:33 +0000 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2009-03-22 22:10:33 +0000 |
commit | e2a38af96eb1c1ee80e9f967d26f61d1e29eabdb (patch) | |
tree | da6bae9f0f9e3285b02e5c5a572321a7130f7002 /libavcodec | |
parent | f91eaf5deb3c02f1d1a439b9fa4e3608a0d6a08b (diff) | |
download | ffmpeg-e2a38af96eb1c1ee80e9f967d26f61d1e29eabdb.tar.gz |
flacdec: change frame bps validation to return an error value if bps
changes since this is not currently supported by the decoder.
Originally committed as revision 18157 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/flacdec.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index d33dc27760..da578f3112 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -512,25 +512,26 @@ static int decode_frame(FLACContext *s) /* bits per sample */ bps_code = get_bits(gb, 3); - if (bps_code == 0) { - bps= s->bps; - } else if ((bps_code != 3) && (bps_code != 7)) { - bps = sample_size_table[bps_code]; - } else { + if (bps_code == 3 || bps_code == 7) { av_log(s->avctx, AV_LOG_ERROR, "invalid sample size code (%d)\n", bps_code); return -1; } - if (bps > 16) { + bps = sample_size_table[bps_code]; + if (bps && bps != s->bps) { + av_log(s->avctx, AV_LOG_ERROR, "switching bps mid-stream is not " + "supported\n"); + return -1; + } + if (s->bps > 16) { s->avctx->sample_fmt = SAMPLE_FMT_S32; - s->sample_shift = 32 - bps; + s->sample_shift = 32 - s->bps; s->is32 = 1; } else { s->avctx->sample_fmt = SAMPLE_FMT_S16; - s->sample_shift = 16 - bps; + s->sample_shift = 16 - s->bps; s->is32 = 0; } - s->bps = s->avctx->bits_per_raw_sample = bps; /* reserved bit */ if (get_bits1(gb)) { |