qsv: Skip the packet if decoding failure
authorRuiling, Song <ruiling.song@intel.com>
Wed, 24 Jan 2018 02:14:51 +0000 (10:14 +0800)
committerLuca Barbato <lu_zero@gentoo.org>
Thu, 25 Jan 2018 10:13:34 +0000 (11:13 +0100)
MediaSDK may fail to decode some frame, just skip it.
Otherwise, it will keep decoding the failure packet repeatedly
without processing any packet afterwards.

Signed-off-by: Ruiling Song <ruiling.song@intel.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
libavcodec/qsvdec_h2645.c

index 83880dc..78a7b61 100644 (file)
@@ -153,8 +153,12 @@ static int qsv_decode_frame(AVCodecContext *avctx, void *data,
         }
 
         ret = ff_qsv_process_data(avctx, &s->qsv, frame, got_frame, &s->buffer_pkt);
         }
 
         ret = ff_qsv_process_data(avctx, &s->qsv, frame, got_frame, &s->buffer_pkt);
-        if (ret < 0)
+        if (ret < 0){
+            /* Drop buffer_pkt when failed to decode the packet. Otherwise,
+               the decoder will keep decoding the failure packet. */
+            av_packet_unref(&s->buffer_pkt);
             return ret;
             return ret;
+        }
 
         s->buffer_pkt.size -= ret;
         s->buffer_pkt.data += ret;
 
         s->buffer_pkt.size -= ret;
         s->buffer_pkt.data += ret;