summaryrefslogtreecommitdiff
path: root/libavcodec/twinvq.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-11-02 14:15:28 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-11-02 14:20:33 +0100
commit6788350281c418f0f395a8279eee82f7abe7c63b (patch)
tree69cd76f699eff929f5b13f76b42eabc7f25f9355 /libavcodec/twinvq.c
parent00aa7fa786e41b5fc8404732453869aa3c14e33a (diff)
parent50a65e7a540ce6747f81d6dbf6a602ad35be77ff (diff)
Merge commit '50a65e7a540ce6747f81d6dbf6a602ad35be77ff'
* commit '50a65e7a540ce6747f81d6dbf6a602ad35be77ff': (24 commits) vmdaudio: set channel layout twinvq: validate sample rate code twinvq: set channel layout twinvq: validate that channels is not <= 0 truespeech: set channel layout sipr: set channel layout shorten: validate that the channel count in the header is not <= 0 ra288dec: set channel layout ra144dec: set channel layout qdm2: remove unneeded checks for channel count qdm2: make sure channels is not <= 0 and set channel layout qcelpdec: set channel layout nellymoserdec: set channels to 1 libopencore-amr: set channel layout for amr-nb or if not set by the user libilbc: set channel layout dpcm: use AVCodecContext.channels instead of keeping a private copy imc: set channels to 1 instead of validating it gsmdec: always set channel layout and sample rate at initialization libgsmdec: always set channel layout and sample rate at initialization g726dec: do not validate sample rate ... Conflicts: libavcodec/dpcm.c libavcodec/qdm2.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/twinvq.c')
-rw-r--r--libavcodec/twinvq.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c
index f47f4c30f1..f4eba4d906 100644
--- a/libavcodec/twinvq.c
+++ b/libavcodec/twinvq.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/audioconvert.h"
#include "libavutil/float_dsp.h"
#include "avcodec.h"
#include "get_bits.h"
@@ -1119,6 +1120,11 @@ static av_cold int twin_decode_init(AVCodecContext *avctx)
avctx->channels = AV_RB32(avctx->extradata ) + 1;
avctx->bit_rate = AV_RB32(avctx->extradata + 4) * 1000;
isampf = AV_RB32(avctx->extradata + 8);
+
+ if (isampf < 8 || isampf > 44) {
+ av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate\n");
+ return AVERROR_INVALIDDATA;
+ }
switch (isampf) {
case 44: avctx->sample_rate = 44100; break;
case 22: avctx->sample_rate = 22050; break;
@@ -1126,11 +1132,14 @@ static av_cold int twin_decode_init(AVCodecContext *avctx)
default: avctx->sample_rate = isampf * 1000; break;
}
- if (avctx->channels > CHANNELS_MAX) {
+ if (avctx->channels <= 0 || avctx->channels > CHANNELS_MAX) {
av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %i\n",
avctx->channels);
return -1;
}
+ avctx->channel_layout = avctx->channels == 1 ? AV_CH_LAYOUT_MONO :
+ AV_CH_LAYOUT_STEREO;
+
ibps = avctx->bit_rate / (1000 * avctx->channels);
switch ((isampf << 8) + ibps) {