[FFmpeg-devel] lavc/qsv: skip the packet if decoding failure.

Submitted by Ruiling Song on Jan. 22, 2018, 8:50 a.m.

Details

Message ID 1516611033-14558-1-git-send-email-ruiling.song@intel.com
State Superseded
Headers show

Commit Message

Ruiling Song Jan. 22, 2018, 8:50 a.m.
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>
---
 libavcodec/qsvdec_h2645.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavcodec/qsvdec_h2645.c b/libavcodec/qsvdec_h2645.c
index 5e00673..0d06b21 100644
--- a/libavcodec/qsvdec_h2645.c
+++ b/libavcodec/qsvdec_h2645.c
@@ -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);
-        if (ret < 0)
-            return ret;
+        if (ret < 0){
+             /* force the buffer_pkt's size to 0 when failed to decode the packet,
+                otherwise, the decoder will keep decoding the failure packet. */
+             s->buffer_pkt.size = 0;
+             return ret;
+        }
 
         s->buffer_pkt.size -= ret;
         s->buffer_pkt.data += ret;