]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/takdec.c
qsvdec: only access hwaccel_context is the pixel format is QSV
[ffmpeg] / libavcodec / takdec.c
index c84cca448d3074e20bfb8cb64db159c99a8bc993..c9db928c5c0a0f462376b34db2e71b9176c4c666 100644 (file)
 
 #include "libavutil/internal.h"
 #include "libavutil/samplefmt.h"
-#include "tak.h"
+
+#define BITSTREAM_READER_LE
 #include "audiodsp.h"
 #include "avcodec.h"
 #include "internal.h"
 #include "unary.h"
+#include "tak.h"
 
 #define MAX_SUBFRAMES     8                         // max number of subframes per channel
 #define MAX_PREDICTORS  256
@@ -806,6 +808,12 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
                     if (s->mcdparams[i].present) {
                         s->mcdparams[i].index = get_bits(gb, 2);
                         s->mcdparams[i].chan2 = get_bits(gb, 4);
+                        if (s->mcdparams[i].chan2 >= avctx->channels) {
+                            av_log(avctx, AV_LOG_ERROR,
+                                   "invalid channel 2 (%d) for %d channel(s)\n",
+                                   s->mcdparams[i].chan2, avctx->channels);
+                            return AVERROR_INVALIDDATA;
+                        }
                         if (s->mcdparams[i].index == 1) {
                             if ((nbit == s->mcdparams[i].chan2) ||
                                 (ch_mask & 1 << s->mcdparams[i].chan2))