summaryrefslogtreecommitdiff
path: root/libavcodec/flacdec.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2009-03-22 22:38:06 +0000
committerJustin Ruggles <justin.ruggles@gmail.com>2009-03-22 22:38:06 +0000
commite7e6b068028a90c2702fafa827cc2b2afe9cf669 (patch)
tree0099791ee56fbce175dd1e0def79aaa178b8735a /libavcodec/flacdec.c
parent6708cfc4d3a079527409b2ba2fc75997a7975104 (diff)
flacdec: allow sample rate to change mid-stream, but log a warning
message when it does Originally committed as revision 18162 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/flacdec.c')
-rw-r--r--libavcodec/flacdec.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index 046fe78df1..bcccec5f11 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -563,9 +563,7 @@ static int decode_frame(FLACContext *s)
}
/* 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 @@ static int decode_frame(FLACContext *s)
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 @@ static int decode_frame(FLACContext *s)
}
s->blocksize = blocksize;
- s->samplerate = samplerate;
+ s->samplerate = s->avctx->sample_rate = samplerate;
s->bps = bps;
s->ch_mode = ch_mode;