Discussion:
[PATCH V2] lavc/qsv: skip the packet if decoding failure.
(too old to reply)
Ruiling Song
2018-01-24 02:14:51 UTC
Permalink
From: "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.

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

diff --git a/libavcodec/qsvdec_h2645.c b/libavcodec/qsvdec_h2645.c
index 83880dc..78a7b61 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;
--
2.7.4
Ruiling Song
2018-01-24 02:36:14 UTC
Permalink
From: "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 <***@intel.com>
---
libavcodec/qsvdec_h2645.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

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;
--
2.7.4
Song, Ruiling
2018-01-24 02:40:05 UTC
Permalink
-----Original Message-----
From: Song, Ruiling
Sent: Wednesday, January 24, 2018 10:36 AM
Subject: [PATCH V2] lavc/qsv: skip the packet if decoding failure.
MediaSDK may fail to decode some frame, just skip it.
Otherwise, it will keep decoding the failure packet repeatedly
without processing any packet afterwards.
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
Luca Barbato
2018-01-24 10:36:26 UTC
Permalink
Post by Ruiling Song
MediaSDK may fail to decode some frame, just skip it.
Otherwise, it will keep decoding the failure packet repeatedly
without processing any packet afterwards.
---
libavcodec/qsvdec_h2645.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libavcodec/qsvdec_h2645.c b/libavcodec/qsvdec_h2645.c
index 83880dc..78a7b61 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;
Looks better, do you have a specific test sample?

lu
Song, Ruiling
2018-01-25 01:21:24 UTC
Permalink
-----Original Message-----
Barbato
Sent: Wednesday, January 24, 2018 6:36 PM
Subject: Re: [libav-devel] [PATCH V2] lavc/qsv: skip the packet if decoding failure.
Post by Ruiling Song
MediaSDK may fail to decode some frame, just skip it.
Otherwise, it will keep decoding the failure packet repeatedly
without processing any packet afterwards.
---
libavcodec/qsvdec_h2645.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libavcodec/qsvdec_h2645.c b/libavcodec/qsvdec_h2645.c
index 83880dc..78a7b61 100644
--- a/libavcodec/qsvdec_h2645.c
+++ b/libavcodec/qsvdec_h2645.c
@@ -153,8 +153,12 @@ static int qsv_decode_frame(AVCodecContext *avctx,
void *data,
Post by Ruiling Song
}
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;
Looks better, do you have a specific test sample?
Sorry I don't have the original clip to hit the issue.
But I tried to decode fate-suite/h264/attachment631-small.mp4 (The video stream has some broken frames)
QSV keeps trying to decode one broken frame. With this patch, qsv could move on to process all the frames.
Even with this patch, MediaSDK still fails to decode out any frame in that stream, which I think the issue comes from MediaSDK itself.

Thanks!
Ruiling
lu
_______________________________________________
libav-devel mailing list
https://lists.libav.org/mailman/listinfo/libav-devel
Luca Barbato
2018-01-25 07:59:07 UTC
Permalink
-----Original Message----- From: libav-devel
lavc/qsv: skip the packet if decoding failure.
MediaSDK may fail to decode some frame, just skip it. Otherwise,
it will keep decoding the failure packet repeatedly without
processing any packet afterwards.
libavcodec/qsvdec_h2645.c | 6 +++++- 1 file changed, 5
insertions(+), 1 deletion(-)
diff --git a/libavcodec/qsvdec_h2645.c
b/libavcodec/qsvdec_h2645.c index 83880dc..78a7b61 100644 ---
*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;
Looks better, do you have a specific test sample?
Sorry I don't have the original clip to hit the issue. But I tried to
decode fate-suite/h264/attachment631-small.mp4 (The video stream has
some broken frames) QSV keeps trying to decode one broken frame. With
this patch, qsv could move on to process all the frames. Even with
this patch, MediaSDK still fails to decode out any frame in that
stream, which I think the issue comes from MediaSDK itself.
Ok, I'd merge this if nobody is against then.

lu
Maxym Dmytrychenko
2018-01-25 08:32:12 UTC
Permalink
just fine, thanks
Post by Luca Barbato
-----Original Message----- From: libav-devel
lavc/qsv: skip the packet if decoding failure.
MediaSDK may fail to decode some frame, just skip it. Otherwise,
it will keep decoding the failure packet repeatedly without
processing any packet afterwards.
libavcodec/qsvdec_h2645.c | 6 +++++- 1 file changed, 5
insertions(+), 1 deletion(-)
diff --git a/libavcodec/qsvdec_h2645.c
b/libavcodec/qsvdec_h2645.c index 83880dc..78a7b61 100644 ---
*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;
Looks better, do you have a specific test sample?
Sorry I don't have the original clip to hit the issue. But I tried to
decode fate-suite/h264/attachment631-small.mp4 (The video stream has
some broken frames) QSV keeps trying to decode one broken frame. With
this patch, qsv could move on to process all the frames. Even with
this patch, MediaSDK still fails to decode out any frame in that
stream, which I think the issue comes from MediaSDK itself.
Ok, I'd merge this if nobody is against then.
lu
_______________________________________________
libav-devel mailing list
https://lists.libav.org/mailman/listinfo/libav-devel
Song, Ruiling
2018-01-25 06:28:32 UTC
Permalink
Post by Song, Ruiling
Post by Luca Barbato
Looks better, do you have a specific test sample?
Sorry I don't have the original clip to hit the issue.
But I tried to decode fate-suite/h264/attachment631-small.mp4 (The video
stream has some broken frames)
Sorry that the video stream I mentioned is inside FFmpeg fate instead of Libav fate.

Ruiling
Post by Song, Ruiling
QSV keeps trying to decode one broken frame. With this patch, qsv could move
on to process all the frames.
Even with this patch, MediaSDK still fails to decode out any frame in that stream,
which I think the issue comes from MediaSDK itself.
Thanks!
Ruiling
Post by Luca Barbato
lu
_______________________________________________
libav-devel mailing list
https://lists.libav.org/mailman/listinfo/libav-devel
Loading...