From 7b966566da24598a636a433a75a7842e272b18f6 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sun, 30 Oct 2011 00:46:16 -0400 Subject: vqf/twinvq: pass vqf COMM chunk info in extradata This is needed because the twinvq decoder cannot rely on bit_rate to be set. The API documentation says that bit_rate is set by libavcodec, not by the user. --- libavcodec/twinvq.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'libavcodec/twinvq.c') diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c index 174cee7424..73eb7c1499 100644 --- a/libavcodec/twinvq.c +++ b/libavcodec/twinvq.c @@ -1104,17 +1104,31 @@ static av_cold int twin_decode_init(AVCodecContext *avctx) { int ret; TwinContext *tctx = avctx->priv_data; - int isampf = avctx->sample_rate/1000; - int ibps = avctx->bit_rate/(1000 * avctx->channels); + int isampf, ibps; tctx->avctx = avctx; avctx->sample_fmt = AV_SAMPLE_FMT_FLT; + if (!avctx->extradata || avctx->extradata_size < 12) { + av_log(avctx, AV_LOG_ERROR, "Missing or incomplete extradata\n"); + return AVERROR_INVALIDDATA; + } + avctx->channels = AV_RB32(avctx->extradata ) + 1; + avctx->bit_rate = AV_RB32(avctx->extradata + 4) * 1000; + isampf = AV_RB32(avctx->extradata + 8); + switch (isampf) { + case 44: avctx->sample_rate = 44100; break; + case 22: avctx->sample_rate = 22050; break; + case 11: avctx->sample_rate = 11025; break; + default: avctx->sample_rate = isampf * 1000; break; + } + if (avctx->channels > CHANNELS_MAX) { av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %i\n", avctx->channels); return -1; } + ibps = avctx->bit_rate / (1000 * avctx->channels); switch ((isampf << 8) + ibps) { case (8 <<8) + 8: tctx->mtab = &mode_08_08; break; -- cgit v1.2.3