* [FFmpeg-devel] [PATCH v3 1/1] lavc/qsvdec: fix dead loop of qsv decoding
[not found] <20230829074906.9345-1-siriushu@hotmail.com>
@ 2023-09-18 7:59 ` Ting Hu
0 siblings, 0 replies; only message in thread
From: Ting Hu @ 2023-09-18 7:59 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: tinghu3
From: tinghu3 <siriushu@hotmail.com>
MFXVideoDECODE_DecodeFrameAsync always returns MFX_WRN_DEVICE_BUSY in special scenario.
Client side received and decoded more than 9 video streams
with different resolution in video conference call.
Related to bug: https://github.com/oneapi-src/oneVPL-intel-gpu/issues/299
Signed-off-by: tinghu3 <siriushu@hotmail.com>
---
libavcodec/qsvdec.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index da700f25e9..6286612ce6 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -703,6 +703,7 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
mfxSyncPoint *sync;
mfxBitstream bs = { { { 0 } } };
int ret;
+ int max_count = 0;
if (avpkt->size) {
bs.Data = avpkt->data;
@@ -728,9 +729,18 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext *q,
ret = MFXVideoDECODE_DecodeFrameAsync(q->session, avpkt->size ? &bs : NULL,
insurf, &outsurf, sync);
- if (ret == MFX_WRN_DEVICE_BUSY)
+ if (ret == MFX_WRN_DEVICE_BUSY) {
+ /* Check the max wait time 500ms to avoid dead loop */
+ if (++max_count == 1000) {
+ av_log(avctx, AV_LOG_ERROR,
+ "MFX decoder returns device busy that reachs timeout 500ms \n");
+ av_freep(&sync);
+ return AVERROR(EBUSY);
+ }
av_usleep(500);
-
+ } else if (ret == MFX_ERR_MORE_SURFACE) {
+ max_count = 0;
+ }
} while (ret == MFX_WRN_DEVICE_BUSY || ret == MFX_ERR_MORE_SURFACE);
if (ret == MFX_ERR_INCOMPATIBLE_VIDEO_PARAM) {
--
2.38.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] only message in thread