changeset 9244:cbf65173eed3 libavcodec

flacdec: allow sample rate to change mid-stream, but log a warning message when it does
author jbr
date Sun, 22 Mar 2009 22:38:06 +0000
parents c09443000c4b
children b5d1395879a0
files flacdec.c
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flacdec.c	Sun Mar 22 22:33:41 2009 +0000
+++ b/flacdec.c	Sun Mar 22 22:38:06 2009 +0000
@@ -563,9 +563,7 @@
     }
 
     /* sample rate */
-    if (sr_code == 0) {
-        samplerate= s->samplerate;
-    } else if (sr_code < 12) {
+    if (sr_code < 12) {
         samplerate = ff_flac_sample_rate_table[sr_code];
     } else if (sr_code == 12) {
         samplerate = get_bits(gb, 8) * 1000;
@@ -578,6 +576,12 @@
                sr_code);
         return -1;
     }
+    if (samplerate == 0) {
+        samplerate = s->samplerate;
+    } else if (samplerate != s->samplerate) {
+        av_log(s->avctx, AV_LOG_WARNING, "sample rate changed from %d to %d\n",
+               s->samplerate, samplerate);
+    }
 
     /* header CRC-8 check */
     skip_bits(gb, 8);
@@ -588,7 +592,7 @@
     }
 
     s->blocksize    = blocksize;
-    s->samplerate   = samplerate;
+    s->samplerate   = s->avctx->sample_rate = samplerate;
     s->bps          = bps;
     s->ch_mode      = ch_mode;