From: "Xiang, Haihao" <haihao.xiang-at-intel.com@ffmpeg.org>
To: "ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] lavfi/vf_vpp_qsv: use macros for extra mfx parameter
Date: Wed, 7 Dec 2022 01:52:37 +0000
Message-ID: <703631df0ea03559e4efc0f2708e53cf20889dec.camel@intel.com> (raw)
In-Reply-To: <20221205062508.2922-1-haihao.xiang@intel.com>
On Ma, 2022-12-05 at 14:25 +0800, Xiang, Haihao wrote:
> From: Haihao Xiang <haihao.xiang@intel.com>
>
> Make it easy to add new extra mfx parameter buffer. No functional
> change.
>
> Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
> ---
> libavfilter/vf_vpp_qsv.c | 86 ++++++++++++++++------------------------
> 1 file changed, 34 insertions(+), 52 deletions(-)
>
> diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
> index a14b3de7b5..61ea0c4256 100644
> --- a/libavfilter/vf_vpp_qsv.c
> +++ b/libavfilter/vf_vpp_qsv.c
> @@ -365,53 +365,44 @@ static int config_output(AVFilterLink *outlink)
> param.crop = &crop;
> }
>
> - if (vpp->deinterlace) {
> - memset(&vpp->deinterlace_conf, 0, sizeof(mfxExtVPPDeinterlacing));
> - vpp->deinterlace_conf.Header.BufferId =
> MFX_EXTBUFF_VPP_DEINTERLACING;
> - vpp->deinterlace_conf.Header.BufferSz =
> sizeof(mfxExtVPPDeinterlacing);
> - vpp->deinterlace_conf.Mode = vpp->deinterlace == 1 ?
> - MFX_DEINTERLACING_BOB :
> MFX_DEINTERLACING_ADVANCED;
> +#define INIT_MFX_EXTBUF(extbuf, id) do { \
> + memset(&vpp->extbuf, 0, sizeof(vpp->extbuf)); \
> + vpp->extbuf.Header.BufferId = id; \
> + vpp->extbuf.Header.BufferSz = sizeof(vpp->extbuf); \
> + param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp->extbuf; \
> + } while (0)
> +
> +#define SET_MFX_PARAM_FIELD(extbuf, field, value) do { \
> + vpp->extbuf.field = value; \
> + } while (0)
>
> - param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp-
> >deinterlace_conf;
> + if (vpp->deinterlace) {
> + INIT_MFX_EXTBUF(deinterlace_conf, MFX_EXTBUFF_VPP_DEINTERLACING);
> + SET_MFX_PARAM_FIELD(deinterlace_conf, Mode, (vpp->deinterlace == 1 ?
> + MFX_DEINTERLACING_BOB :
> MFX_DEINTERLACING_ADVANCED));
> }
>
> if (vpp->use_frc) {
> - memset(&vpp->frc_conf, 0, sizeof(mfxExtVPPFrameRateConversion));
> - vpp->frc_conf.Header.BufferId =
> MFX_EXTBUFF_VPP_FRAME_RATE_CONVERSION;
> - vpp->frc_conf.Header.BufferSz = sizeof(mfxExtVPPFrameRateConversion);
> - vpp->frc_conf.Algorithm = MFX_FRCALGM_DISTRIBUTED_TIMESTAMP;
> -
> - param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp->frc_conf;
> + INIT_MFX_EXTBUF(frc_conf, MFX_EXTBUFF_VPP_FRAME_RATE_CONVERSION);
> + SET_MFX_PARAM_FIELD(frc_conf, Algorithm,
> MFX_FRCALGM_DISTRIBUTED_TIMESTAMP);
> }
>
> if (vpp->denoise) {
> - memset(&vpp->denoise_conf, 0, sizeof(mfxExtVPPDenoise));
> - vpp->denoise_conf.Header.BufferId = MFX_EXTBUFF_VPP_DENOISE;
> - vpp->denoise_conf.Header.BufferSz = sizeof(mfxExtVPPDenoise);
> - vpp->denoise_conf.DenoiseFactor = vpp->denoise;
> -
> - param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp-
> >denoise_conf;
> + INIT_MFX_EXTBUF(denoise_conf, MFX_EXTBUFF_VPP_DENOISE);
> + SET_MFX_PARAM_FIELD(denoise_conf, DenoiseFactor, vpp->denoise);
> }
>
> if (vpp->detail) {
> - memset(&vpp->detail_conf, 0, sizeof(mfxExtVPPDetail));
> - vpp->detail_conf.Header.BufferId = MFX_EXTBUFF_VPP_DETAIL;
> - vpp->detail_conf.Header.BufferSz = sizeof(mfxExtVPPDetail);
> - vpp->detail_conf.DetailFactor = vpp->detail;
> -
> - param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp-
> >detail_conf;
> + INIT_MFX_EXTBUF(detail_conf, MFX_EXTBUFF_VPP_DETAIL);
> + SET_MFX_PARAM_FIELD(detail_conf, DetailFactor, vpp->detail);
> }
>
> if (vpp->procamp) {
> - memset(&vpp->procamp_conf, 0, sizeof(mfxExtVPPProcAmp));
> - vpp->procamp_conf.Header.BufferId = MFX_EXTBUFF_VPP_PROCAMP;
> - vpp->procamp_conf.Header.BufferSz = sizeof(mfxExtVPPProcAmp);
> - vpp->procamp_conf.Hue = vpp->hue;
> - vpp->procamp_conf.Saturation = vpp->saturation;
> - vpp->procamp_conf.Contrast = vpp->contrast;
> - vpp->procamp_conf.Brightness = vpp->brightness;
> -
> - param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp-
> >procamp_conf;
> + INIT_MFX_EXTBUF(procamp_conf, MFX_EXTBUFF_VPP_PROCAMP);
> + SET_MFX_PARAM_FIELD(procamp_conf, Hue, vpp->hue);
> + SET_MFX_PARAM_FIELD(procamp_conf, Saturation, vpp->saturation);
> + SET_MFX_PARAM_FIELD(procamp_conf, Contrast, vpp->contrast);
> + SET_MFX_PARAM_FIELD(procamp_conf, Brightness, vpp->brightness);
> }
>
> if (vpp->transpose >= 0) {
> @@ -458,18 +449,14 @@ static int config_output(AVFilterLink *outlink)
>
> if (vpp->rotate) {
> if (QSV_RUNTIME_VERSION_ATLEAST(mfx_version, 1, 17)) {
> - memset(&vpp->rotation_conf, 0, sizeof(mfxExtVPPRotation));
> - vpp->rotation_conf.Header.BufferId = MFX_EXTBUFF_VPP_ROTATION;
> - vpp->rotation_conf.Header.BufferSz = sizeof(mfxExtVPPRotation);
> - vpp->rotation_conf.Angle = vpp->rotate;
> + INIT_MFX_EXTBUF(rotation_conf, MFX_EXTBUFF_VPP_ROTATION);
> + SET_MFX_PARAM_FIELD(rotation_conf, Angle, vpp->rotate);
>
> if (MFX_ANGLE_90 == vpp->rotate || MFX_ANGLE_270 == vpp->rotate)
> {
> FFSWAP(int, vpp->out_width, vpp->out_height);
> FFSWAP(int, outlink->w, outlink->h);
> av_log(ctx, AV_LOG_DEBUG, "Swap width and height for
> clock/cclock rotation.\n");
> }
> -
> - param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp-
> >rotation_conf;
> } else {
> av_log(ctx, AV_LOG_WARNING, "The QSV VPP rotate option is "
> "not supported with this MSDK version.\n");
> @@ -479,12 +466,8 @@ static int config_output(AVFilterLink *outlink)
>
> if (vpp->hflip) {
> if (QSV_RUNTIME_VERSION_ATLEAST(mfx_version, 1, 19)) {
> - memset(&vpp->mirroring_conf, 0, sizeof(mfxExtVPPMirroring));
> - vpp->mirroring_conf.Header.BufferId = MFX_EXTBUFF_VPP_MIRRORING;
> - vpp->mirroring_conf.Header.BufferSz = sizeof(mfxExtVPPMirroring);
> - vpp->mirroring_conf.Type = vpp->hflip;
> -
> - param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp-
> >mirroring_conf;
> + INIT_MFX_EXTBUF(mirroring_conf, MFX_EXTBUFF_VPP_MIRRORING);
> + SET_MFX_PARAM_FIELD(mirroring_conf, Type, vpp->hflip);
> } else {
> av_log(ctx, AV_LOG_WARNING, "The QSV VPP hflip option is "
> "not supported with this MSDK version.\n");
> @@ -494,17 +477,16 @@ static int config_output(AVFilterLink *outlink)
>
> if (inlink->w != outlink->w || inlink->h != outlink->h || in_format !=
> vpp->out_format) {
> if (QSV_RUNTIME_VERSION_ATLEAST(mfx_version, 1, 19)) {
> - memset(&vpp->scale_conf, 0, sizeof(mfxExtVPPScaling));
> - vpp->scale_conf.Header.BufferId = MFX_EXTBUFF_VPP_SCALING;
> - vpp->scale_conf.Header.BufferSz = sizeof(mfxExtVPPScaling);
> - vpp->scale_conf.ScalingMode = vpp->scale_mode;
> -
> - param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp-
> >scale_conf;
> + INIT_MFX_EXTBUF(scale_conf, MFX_EXTBUFF_VPP_SCALING);
> + SET_MFX_PARAM_FIELD(scale_conf, ScalingMode, vpp->scale_mode);
> } else
> av_log(ctx, AV_LOG_WARNING, "The QSV VPP Scale & format
> conversion "
> "option is not supported with this MSDK version.\n");
> }
>
> +#undef INIT_MFX_EXTBUF
> +#undef SET_MFX_PARAM_FIELD
> +
> if (vpp->use_frc || vpp->use_crop || vpp->deinterlace || vpp->denoise ||
> vpp->detail || vpp->procamp || vpp->rotate || vpp->hflip ||
> inlink->w != outlink->w || inlink->h != outlink->h || in_format !=
> vpp->out_format)
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:[~2022-12-07 1:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-05 6:25 Xiang, Haihao
2022-12-07 1:52 ` 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=703631df0ea03559e4efc0f2708e53cf20889dec.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