From: "Xiang, Haihao" <haihao.xiang-at-intel.com@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Haihao Xiang <haihao.xiang@intel.com>
Subject: [FFmpeg-devel] [PATCH 1/2] lavc/qsvenc: always allocate the array to store mfxExtBuffer points
Date: Thu, 29 Feb 2024 13:34:33 +0800
Message-ID: <20240229053434.2476820-1-haihao.xiang@intel.com> (raw)
From: Haihao Xiang <haihao.xiang@intel.com>
This allows us to append mfxExtBuffer per user's settings
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
---
libavcodec/qsvenc.c | 44 +++++++++++++++++++++++++-------------------
libavcodec/qsvenc.h | 1 +
2 files changed, 26 insertions(+), 19 deletions(-)
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index c63b72e384..27e0e7ee71 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1608,6 +1608,7 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
int iopattern = 0;
int opaque_alloc = 0;
int ret;
+ void *tmp;
q->param.AsyncDepth = q->async_depth;
@@ -1668,35 +1669,40 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q)
if (ret < 0)
return ret;
+ tmp = av_realloc_array(q->extparam, q->nb_extparam_internal, sizeof(*q->extparam));
+ if (!tmp)
+ return AVERROR(ENOMEM);
+
+ q->extparam = tmp;
+ q->nb_extparam = q->nb_extparam_internal;
+ memcpy(q->extparam, q->extparam_internal, q->nb_extparam * sizeof(*q->extparam));
+
if (avctx->hwaccel_context) {
AVQSVContext *qsv = avctx->hwaccel_context;
int i, j;
- q->extparam = av_calloc(qsv->nb_ext_buffers + q->nb_extparam_internal,
- sizeof(*q->extparam));
- if (!q->extparam)
- return AVERROR(ENOMEM);
-
- q->param.ExtParam = q->extparam;
- for (i = 0; i < qsv->nb_ext_buffers; i++)
- q->param.ExtParam[i] = qsv->ext_buffers[i];
- q->param.NumExtParam = qsv->nb_ext_buffers;
-
- for (i = 0; i < q->nb_extparam_internal; i++) {
- for (j = 0; j < qsv->nb_ext_buffers; j++) {
- if (qsv->ext_buffers[j]->BufferId == q->extparam_internal[i]->BufferId)
+ for (i = 0; i < qsv->nb_ext_buffers; i++) {
+ for (j = 0; j < q->nb_extparam_internal; j++) {
+ if (qsv->ext_buffers[i]->BufferId == q->extparam_internal[j]->BufferId) {
+ q->extparam[j] = qsv->ext_buffers[i];
break;
+ }
}
- if (j < qsv->nb_ext_buffers)
- continue;
- q->param.ExtParam[q->param.NumExtParam++] = q->extparam_internal[i];
+ if (j == q->nb_extparam_internal) {
+ tmp = av_realloc_array(q->extparam, q->nb_extparam + 1, sizeof(*q->extparam));
+ if (!tmp)
+ return AVERROR(ENOMEM);
+
+ q->extparam = tmp;
+ q->extparam[q->nb_extparam++] = qsv->ext_buffers[i];
+ }
}
- } else {
- q->param.ExtParam = q->extparam_internal;
- q->param.NumExtParam = q->nb_extparam_internal;
}
+ q->param.ExtParam = q->extparam;
+ q->param.NumExtParam = q->nb_extparam;
+
ret = MFXVideoENCODE_Query(q->session, &q->param, &q->param);
if (ret == MFX_WRN_PARTIAL_ACCELERATION) {
av_log(avctx, AV_LOG_WARNING, "Encoder will work with partial HW acceleration\n");
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index c71bf2ed50..f2f0687bfe 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -196,6 +196,7 @@ typedef struct QSVEncContext {
int nb_extparam_internal;
mfxExtBuffer **extparam;
+ int nb_extparam;
AVFifo *async_fifo;
--
2.34.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".
next reply other threads:[~2024-02-29 5:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-29 5:34 Xiang, Haihao [this message]
2024-02-29 5:34 ` [FFmpeg-devel] [PATCH 2/2] lavc/qsvenc: add support for oneVPL string API Xiang, Haihao
2024-05-04 5:45 ` Xiang, Haihao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240229053434.2476820-1-haihao.xiang@intel.com \
--to=haihao.xiang-at-intel.com@ffmpeg.org \
--cc=ffmpeg-devel@ffmpeg.org \
--cc=haihao.xiang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git