[V2] lavc/qsv: skip the packet if decoding failure.

Message ID 1516761374-6022-1-git-send-email-ruiling.song@intel.com
State New
Headers show
Series
  • [V2] lavc/qsv: skip the packet if decoding failure.
Related show

Commit Message

Ruiling Song Jan. 24, 2018, 2:36 a.m.
From: "Ruiling, Song" <ruiling.song@intel.com>

MediaSDK may fail to decode some frame, just skip it.
Otherwise, it will keep decoding the failure packet repeatedly
without processing any packet afterwards.

v2:
switch to using av_packet_unref().

Signed-off-by: Ruiling Song <ruiling.song@intel.com>
---
 libavcodec/qsvdec_h2645.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Ruiling Song Jan. 24, 2018, 2:40 a.m. | #1
> -----Original Message-----
> From: Song, Ruiling
> Sent: Wednesday, January 24, 2018 10:36 AM
> To: libav-devel@libav.org
> Cc: Song, Ruiling <ruiling.song@intel.com>
> Subject: [PATCH V2] lavc/qsv: skip the packet if decoding failure.
> 
> From: "Ruiling, Song" <ruiling.song@intel.com>
> 
> MediaSDK may fail to decode some frame, just skip it.
> Otherwise, it will keep decoding the failure packet repeatedly
> without processing any packet afterwards.
> 
> v2:
> switch to using av_packet_unref().

I am sorry to re-send the v2 because I missed to add "v2:" in commit message and fix one code format error.

Ruiling

Patch

diff --git a/libavcodec/qsvdec_h2645.c b/libavcodec/qsvdec_h2645.c
index 83880dc..d5a34ed 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)
+        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;
+        }
 
         s->buffer_pkt.size -= ret;
         s->buffer_pkt.data += ret;