changeset 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 4b74d02db3df
files flacdec.c
diffstat 1 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/flacdec.c	Sun Mar 22 21:53:28 2009 +0000
+++ b/flacdec.c	Sun Mar 22 22:10:33 2009 +0000
@@ -512,25 +512,26 @@
 
     /* 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)) {