From: "Xiang, Haihao" <haihao.xiang-at-intel.com@ffmpeg.org>
To: "ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH 1/4] lavfi/qsvvpp: add set_frame_ext_params callback
Date: Mon, 31 Jul 2023 07:00:23 +0000
Message-ID: <afda54139b2fad6536a8b6616b1524d01448b5f3.camel@intel.com> (raw)
In-Reply-To: <20230726071522.38149-1-haihao.xiang@intel.com>
On Wo, 2023-07-26 at 15:15 +0800, Xiang, Haihao wrote:
> From: Haihao Xiang <haihao.xiang@intel.com>
>
> This allows we add mfxExtBuffer per frame later.
>
> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
> ---
> libavfilter/qsvvpp.c | 67 +++++++++++++++++++++++++++++++++-----------
> libavfilter/qsvvpp.h | 10 +++++++
> 2 files changed, 61 insertions(+), 16 deletions(-)
>
> diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
> index a03de05d9c..3c8dfea16a 100644
> --- a/libavfilter/qsvvpp.c
> +++ b/libavfilter/qsvvpp.c
> @@ -731,6 +731,11 @@ static int init_vpp_session(AVFilterContext *avctx,
> QSVVPPContext *s)
> return 0;
> }
>
> +static int set_frame_ext_params_null(AVFilterContext *ctx, const AVFrame *in,
> AVFrame *out, QSVVPPFrameParam *fp)
> +{
> + return 0;
> +}
> +
> int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param)
> {
> int i;
> @@ -742,6 +747,10 @@ int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam
> *param)
> s->filter_frame = ff_filter_frame;
> s->out_sw_format = param->out_sw_format;
>
> + s->set_frame_ext_params = param->set_frame_ext_params;
> + if (!s->set_frame_ext_params)
> + s->set_frame_ext_params = set_frame_ext_params_null;
> +
> /* create the vpp session */
> ret = init_vpp_session(avctx, s);
> if (ret < 0)
> @@ -868,27 +877,53 @@ failed:
> static int qsvvpp_init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s,
> const QSVFrame *in, QSVFrame *out)
> {
> int ret;
> + mfxExtBuffer *ext_param[QSVVPP_MAX_FRAME_EXTBUFS];
> + QSVVPPFrameParam fp = { 0, ext_param };
>
> - if (s->vpp_initted)
> - return 0;
> + ret = s->set_frame_ext_params(avctx, in->frame, out->frame, &fp);
> + if (ret)
> + return ret;
>
> - s->vpp_param.vpp.In.PicStruct = in->surface.Info.PicStruct;
> - s->vpp_param.vpp.Out.PicStruct = out->surface.Info.PicStruct;
> + if (fp.num_ext_buf) {
> + av_freep(&s->ext_buffers);
> + s->nb_ext_buffers = s->nb_seq_buffers + fp.num_ext_buf;
>
> - /* Query VPP params again, including params for frame */
> - ret = MFXVideoVPP_Query(s->session, &s->vpp_param, &s->vpp_param);
> - if (ret < 0)
> - return ff_qsvvpp_print_error(avctx, ret, "Error querying VPP
> params");
> - else if (ret > 0)
> - ff_qsvvpp_print_warning(avctx, ret, "Warning When querying VPP
> params");
> + s->ext_buffers = av_calloc(s->nb_ext_buffers, sizeof(*s-
> >ext_buffers));
> + if (!s->ext_buffers)
> + return AVERROR(ENOMEM);
>
> - ret = MFXVideoVPP_Init(s->session, &s->vpp_param);
> - if (ret < 0)
> - return ff_qsvvpp_print_error(avctx, ret, "Failed to create a
> qsvvpp");
> - else if (ret > 0)
> - ff_qsvvpp_print_warning(avctx, ret, "Warning When creating qsvvpp");
> + memcpy(&s->ext_buffers[0], s->seq_buffers, s->nb_seq_buffers *
> sizeof(*s->seq_buffers));
> + memcpy(&s->ext_buffers[s->nb_seq_buffers], fp.ext_buf, fp.num_ext_buf
> * sizeof(*fp.ext_buf));
> + s->vpp_param.ExtParam = s->ext_buffers;
> + s->vpp_param.NumExtParam = s->nb_ext_buffers;
> + }
> +
> + if (!s->vpp_initted) {
> + s->vpp_param.vpp.In.PicStruct = in->surface.Info.PicStruct;
> + s->vpp_param.vpp.Out.PicStruct = out->surface.Info.PicStruct;
> +
> + /* Query VPP params again, including params for frame */
> + ret = MFXVideoVPP_Query(s->session, &s->vpp_param, &s->vpp_param);
> + if (ret < 0)
> + return ff_qsvvpp_print_error(avctx, ret, "Error querying VPP
> params");
> + else if (ret > 0)
> + ff_qsvvpp_print_warning(avctx, ret, "Warning When querying VPP
> params");
> +
> + ret = MFXVideoVPP_Init(s->session, &s->vpp_param);
> + if (ret < 0)
> + return ff_qsvvpp_print_error(avctx, ret, "Failed to create a
> qsvvpp");
> + else if (ret > 0)
> + ff_qsvvpp_print_warning(avctx, ret, "Warning When creating
> qsvvpp");
>
> - s->vpp_initted = 1;
> + s->vpp_initted = 1;
> + } else if (fp.num_ext_buf) {
> + ret = MFXVideoVPP_Reset(s->session, &s->vpp_param);
> + if (ret < 0) {
> + ret = ff_qsvvpp_print_error(avctx, ret, "Failed to reset session
> for qsvvpp");
> + return ret;
> + } else if (ret > 0)
> + ff_qsvvpp_print_warning(avctx, ret, "Warning When resetting
> session for qsvvpp");
> + }
>
> return 0;
> }
> diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h
> index fba5f037d4..4eea7a46c7 100644
> --- a/libavfilter/qsvvpp.h
> +++ b/libavfilter/qsvvpp.h
> @@ -52,11 +52,20 @@ typedef struct QSVFrame {
> int queued;
> } QSVFrame;
>
> +#define QSVVPP_MAX_FRAME_EXTBUFS 8
> +
> +typedef struct QSVVPPFrameParam {
> + /* To fill with MFX enhanced filter configurations */
> + int num_ext_buf;
> + mfxExtBuffer **ext_buf;
> +} QSVVPPFrameParam;
> +
> typedef struct QSVVPPContext {
> const AVClass *class;
>
> mfxSession session;
> int (*filter_frame) (AVFilterLink *outlink, AVFrame *frame); /**<
> callback */
> + int (*set_frame_ext_params)(AVFilterContext *ctx, const AVFrame *in,
> AVFrame *out, QSVVPPFrameParam *fp); /**< callbak */
> enum AVPixelFormat out_sw_format; /**< Real output format */
> mfxVideoParam vpp_param;
> mfxFrameInfo *frame_infos; /**< frame info for each input */
> @@ -101,6 +110,7 @@ typedef struct QSVVPPCrop {
> typedef struct QSVVPPParam {
> /* default is ff_filter_frame */
> int (*filter_frame)(AVFilterLink *outlink, AVFrame *frame);
> + int (*set_frame_ext_params)(AVFilterContext *ctx, const AVFrame *in,
> AVFrame *out, QSVVPPFrameParam *fp); /**< callbak */
>
> /* To fill with MFX enhanced filter configurations */
> int num_ext_buf;
Will apply
- Haihao
_______________________________________________
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".
prev parent reply other threads:[~2023-07-31 7:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-26 7:15 Xiang, Haihao
2023-07-26 7:15 ` [FFmpeg-devel] [PATCH 2/4] lavfi/vf_vpp_qsv: take input color properties into account Xiang, Haihao
2023-07-26 7:15 ` [FFmpeg-devel] [PATCH 3/4] lavfi/vf_vpp_qsv: set color properties for output Xiang, Haihao
2023-07-26 7:15 ` [FFmpeg-devel] [PATCH 4/4] lavfi/vf_vpp_qsv: perform conversion from HDR to SDR Xiang, Haihao
2023-07-31 7:00 ` Xiang, Haihao [this message]
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=afda54139b2fad6536a8b6616b1524d01448b5f3.camel@intel.com \
--to=haihao.xiang-at-intel.com@ffmpeg.org \
--cc=ffmpeg-devel@ffmpeg.org \
/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