[FFmpeg-devel] [PATCH v1 1/1] lavc/qsvdec: fix dead loop of qsv decoding
Xiang, Haihao
haihao.xiang at intel.com
Mon Aug 21 09:20:03 EEST 2023
On Do, 2023-08-17 at 19:39 +0800, Ting Hu wrote:
> From: tinghu3 <siriushu at hotmail.com>
>
> MFXVideoDECODE_DecodeFrameAsync always return MFX_WRN_DEVICE_BUSY in special
> scenario.
>
> Signed-off-by: tinghu3 <siriushu at hotmail.com>
> ---
> libavcodec/qsvdec.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index da700f25e9..35102fb476 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;
> @@ -730,7 +731,9 @@ static int qsv_decode(AVCodecContext *avctx, QSVContext
> *q,
> insurf, &outsurf, sync);
> if (ret == MFX_WRN_DEVICE_BUSY)
> av_usleep(500);
> -
> + /* Check the max wait time 500ms to avoid dead loop */
> + if (++max_count == 1000)
Check the max wait time only for MFX_WRN_DEVICE_BUSY, and reset max_count to 0
when ret is not MFX_WRN_DEVICE_BUSY.
> + return ret;
Don't return MFX_WRN_xxx from this function.
Thanks
Haihao
> } while (ret == MFX_WRN_DEVICE_BUSY || ret == MFX_ERR_MORE_SURFACE);
>
> if (ret == MFX_ERR_INCOMPATIBLE_VIDEO_PARAM) {
More information about the ffmpeg-devel
mailing list