From 12218984045065dd6730d023dc0b0f20e3da52af Mon Sep 17 00:00:00 2001 From: Haihao Xiang Date: Wed, 8 May 2019 16:05:07 +0800 Subject: [PATCH] msdkenc: allow encode element requires extra frames The call of MFXVideoENCODE_EncodeFrameAsync may not generate output and the function returns MFX_ERR_MORE_DATA with NULL sync point, the input frame is cached in this case, so it is possible that all allocated frames go into the surfaces_used list after calling MFXVideoENCODE_EncodeFrameAsync a few times, then the encoder will fail to get an available surface before releasing used frames This patch adds a new field of num_extra_frames to GstMsdkEnc and allows encode element requires extra frames, the default value is 0. This patch is the preparation for msdkvp9enc element. --- sys/msdk/gstmsdkenc.c | 2 ++ sys/msdk/gstmsdkenc.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/sys/msdk/gstmsdkenc.c b/sys/msdk/gstmsdkenc.c index 1afec086bf..c5359d8d3f 100644 --- a/sys/msdk/gstmsdkenc.c +++ b/sys/msdk/gstmsdkenc.c @@ -454,6 +454,8 @@ gst_msdkenc_init_encoder (GstMsdkEnc * thiz) msdk_status_to_string (status)); } + request[0].NumFrameSuggested += thiz->num_extra_frames; + if (thiz->has_vpp) request[0].NumFrameSuggested += thiz->num_vpp_surfaces + 1 - 4; diff --git a/sys/msdk/gstmsdkenc.h b/sys/msdk/gstmsdkenc.h index 1cfaf50aed..90ba88766b 100644 --- a/sys/msdk/gstmsdkenc.h +++ b/sys/msdk/gstmsdkenc.h @@ -104,6 +104,9 @@ struct _GstMsdkEnc guint num_tasks; MsdkEncTask *tasks; guint next_task; + /* Extra frames for encoding, set by each element, + * the default value is 0 */ + guint num_extra_frames; gboolean has_vpp; mfxVideoParam vpp_param;