diff options
author | Haihao Xiang <haihao.xiang@intel.com> | 2022-10-18 12:59:24 +0800 |
---|---|---|
committer | Haihao Xiang <haihao.xiang@intel.com> | 2022-10-25 08:49:48 +0800 |
commit | dc26bd8e6d01a344df47e8ae9b156d6a97d451cc (patch) | |
tree | 7951f4e479054a9834f5090972b4b6b671ab654e /libavcodec/qsvenc.c | |
parent | 76965fa41177658444c334ebbe0ae11eafd8c796 (diff) | |
download | ffmpeg-dc26bd8e6d01a344df47e8ae9b156d6a97d451cc.tar.gz |
lavc/qsvenc: enlarge the maximum number of ExtParam buffers on mfxEncodeCtrl
The next commit and other commits in future will use more ExtParam
buffers.
And combine 2 free functions into single one
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
Diffstat (limited to 'libavcodec/qsvenc.c')
-rw-r--r-- | libavcodec/qsvenc.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 993139eb33..0db774ea63 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1622,25 +1622,16 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q) return 0; } -static void free_encoder_ctrl_payloads(mfxEncodeCtrl* enc_ctrl) +static void free_encoder_ctrl(mfxEncodeCtrl* enc_ctrl) { if (enc_ctrl) { - int i; - for (i = 0; i < enc_ctrl->NumPayload && i < QSV_MAX_ENC_PAYLOAD; i++) { + for (int i = 0; i < enc_ctrl->NumPayload && i < QSV_MAX_ENC_PAYLOAD; i++) av_freep(&enc_ctrl->Payload[i]); - } - enc_ctrl->NumPayload = 0; - } -} -static void free_encoder_ctrl_extparam(mfxEncodeCtrl* enc_ctrl) -{ - if (enc_ctrl) { - int i; - for (i = 0; i < enc_ctrl->NumExtParam && i < QSV_MAX_ENC_EXTPARAM; i++) { - if (enc_ctrl->ExtParam[i]) - av_freep(&(enc_ctrl->ExtParam[i])); - } + for (int i = 0; i < enc_ctrl->NumExtParam && i < QSV_MAX_ENC_EXTPARAM; i++) + av_freep(&enc_ctrl->ExtParam[i]); + + enc_ctrl->NumPayload = 0; enc_ctrl->NumExtParam = 0; } } @@ -1650,8 +1641,7 @@ static void clear_unused_frames(QSVEncContext *q) QSVFrame *cur = q->work_frames; while (cur) { if (cur->used && !cur->surface.Data.Locked) { - free_encoder_ctrl_payloads(&cur->enc_ctrl); - free_encoder_ctrl_extparam(&cur->enc_ctrl); + free_encoder_ctrl(&cur->enc_ctrl); //do not reuse enc_ctrl from previous frame memset(&cur->enc_ctrl, 0, sizeof(cur->enc_ctrl)); cur->enc_ctrl.Payload = cur->payloads; @@ -2419,8 +2409,7 @@ int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q) while (cur) { q->work_frames = cur->next; av_frame_free(&cur->frame); - free_encoder_ctrl_extparam(&cur->enc_ctrl); - free_encoder_ctrl_payloads(&cur->enc_ctrl); + free_encoder_ctrl(&cur->enc_ctrl); av_freep(&cur); cur = q->work_frames; } |