]> git.sesse.net Git - ffmpeg/commitdiff
qsvdec: avoid an infinite loop with no consumed data and no output
authorAnton Khirnov <anton@khirnov.net>
Thu, 9 Jul 2015 18:08:13 +0000 (20:08 +0200)
committerAnton Khirnov <anton@khirnov.net>
Sat, 25 Jul 2015 15:23:29 +0000 (17:23 +0200)
This is triggerable with the HEVC decoder. It is unclear yet whether the
bug is in the calling code or the MSDK, but it seems better to check for
this in any case.

libavcodec/qsvdec.c

index da9b082d09b32c9a9eedd83f80a90dc9cc2c2030..489375cf7b08a04d39facd32a88c18ae966bf906 100644 (file)
@@ -245,6 +245,13 @@ int ff_qsv_decode(AVCodecContext *avctx, QSVContext *q,
         return ff_qsv_error(ret);
     }
 
+    /* make sure we do not enter an infinite loop if the SDK
+     * did not consume any data and did not return anything */
+    if (!sync && !bs.DataOffset) {
+        av_log(avctx, AV_LOG_WARNING, "A decode call did not consume any data\n");
+        bs.DataOffset = avpkt->size;
+    }
+
     if (sync) {
         QSVFrame *out_frame = find_frame(q, outsurf);