* [FFmpeg-devel] [PATCH v3] libavfilter/qsvvpp: Change the alignment to meet the requirement of YUV420P format
@ 2022-12-05 6:32 wenbin.chen-at-intel.com
2022-12-07 1:52 ` Xiang, Haihao
0 siblings, 1 reply; 2+ messages in thread
From: wenbin.chen-at-intel.com @ 2022-12-05 6:32 UTC (permalink / raw)
To: ffmpeg-devel
From: Wenbin Chen <wenbin.chen@intel.com>
When process yuv420 frames, FFmpeg uses same alignment on Y/U/V
planes. VPL and MSDK use Y plane's pitch / 2 as U/V planes's
pitch, which makes U/V planes 16-bytes aligned. We need to set
a separate alignment to meet runtime's behaviour.
Now alignment is changed to 16 so that the linesizes of U/V planes
meet the requirment of VPL/MSDK. Add get_buffer.video callback to
qsv filters to change the default get_buffer behaviour.
Now the commandline works fine:
ffmpeg -f rawvideo -pix_fmt yuv420p -s:v 3082x1884 \
-i ./3082x1884.yuv -vf 'vpp_qsv=w=2466:h=1508' -f rawvideo \
-pix_fmt yuv420p 2466_1508.yuv
Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
---
libavfilter/qsvvpp.c | 13 +++++++++++++
libavfilter/qsvvpp.h | 1 +
libavfilter/vf_deinterlace_qsv.c | 1 +
libavfilter/vf_overlay_qsv.c | 2 ++
libavfilter/vf_scale_qsv.c | 1 +
libavfilter/vf_vpp_qsv.c | 1 +
6 files changed, 19 insertions(+)
diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 8428ee89ab..d5cfeab402 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -1003,3 +1003,16 @@ int ff_qsvvpp_create_mfx_session(void *ctx,
}
#endif
+
+AVFrame *ff_qsvvpp_get_video_buffer(AVFilterLink *inlink, int w, int h)
+{
+ /* When process YUV420 frames, FFmpeg uses same alignment on Y/U/V
+ * planes. VPL and MSDK use Y plane's pitch / 2 as U/V planes's
+ * pitch, which makes U/V planes 16-bytes aligned. We need to set a
+ * separate alignment to meet runtime's behaviour.
+ */
+ return ff_default_get_video_buffer2(inlink,
+ FFALIGN(inlink->w, 32),
+ FFALIGN(inlink->h, 32),
+ 16);
+}
diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h
index a8cfcc565a..6f7c9bfc15 100644
--- a/libavfilter/qsvvpp.h
+++ b/libavfilter/qsvvpp.h
@@ -127,4 +127,5 @@ int ff_qsvvpp_print_warning(void *log_ctx, mfxStatus err,
int ff_qsvvpp_create_mfx_session(void *ctx, void *loader, mfxIMPL implementation,
mfxVersion *pver, mfxSession *psession);
+AVFrame *ff_qsvvpp_get_video_buffer(AVFilterLink *inlink, int w, int h);
#endif /* AVFILTER_QSVVPP_H */
diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c
index 98ed7283ad..6c94923f02 100644
--- a/libavfilter/vf_deinterlace_qsv.c
+++ b/libavfilter/vf_deinterlace_qsv.c
@@ -581,6 +581,7 @@ static const AVFilterPad qsvdeint_inputs[] = {
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
.filter_frame = qsvdeint_filter_frame,
+ .get_buffer.video = ff_qsvvpp_get_video_buffer,
},
};
diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c
index d947a1faa1..1a2c1b1e96 100644
--- a/libavfilter/vf_overlay_qsv.c
+++ b/libavfilter/vf_overlay_qsv.c
@@ -399,11 +399,13 @@ static const AVFilterPad overlay_qsv_inputs[] = {
.name = "main",
.type = AVMEDIA_TYPE_VIDEO,
.config_props = config_main_input,
+ .get_buffer.video = ff_qsvvpp_get_video_buffer,
},
{
.name = "overlay",
.type = AVMEDIA_TYPE_VIDEO,
.config_props = config_overlay_input,
+ .get_buffer.video = ff_qsvvpp_get_video_buffer,
},
};
diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
index 758e730f78..36d5f3a6ec 100644
--- a/libavfilter/vf_scale_qsv.c
+++ b/libavfilter/vf_scale_qsv.c
@@ -641,6 +641,7 @@ static const AVFilterPad qsvscale_inputs[] = {
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
.filter_frame = qsvscale_filter_frame,
+ .get_buffer.video = ff_qsvvpp_get_video_buffer,
},
};
diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 4a053f9145..b26d19c3bc 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -634,6 +634,7 @@ static const AVFilterPad vpp_inputs[] = {
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
.config_props = config_input,
+ .get_buffer.video = ff_qsvvpp_get_video_buffer,
},
};
--
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".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH v3] libavfilter/qsvvpp: Change the alignment to meet the requirement of YUV420P format
2022-12-05 6:32 [FFmpeg-devel] [PATCH v3] libavfilter/qsvvpp: Change the alignment to meet the requirement of YUV420P format wenbin.chen-at-intel.com
@ 2022-12-07 1:52 ` Xiang, Haihao
0 siblings, 0 replies; 2+ messages in thread
From: Xiang, Haihao @ 2022-12-07 1:52 UTC (permalink / raw)
To: ffmpeg-devel
On Ma, 2022-12-05 at 14:32 +0800, wenbin.chen-at-intel.com@ffmpeg.org wrote:
> From: Wenbin Chen <wenbin.chen@intel.com>
>
> When process yuv420 frames, FFmpeg uses same alignment on Y/U/V
> planes. VPL and MSDK use Y plane's pitch / 2 as U/V planes's
> pitch, which makes U/V planes 16-bytes aligned. We need to set
> a separate alignment to meet runtime's behaviour.
>
> Now alignment is changed to 16 so that the linesizes of U/V planes
> meet the requirment of VPL/MSDK. Add get_buffer.video callback to
> qsv filters to change the default get_buffer behaviour.
>
> Now the commandline works fine:
> ffmpeg -f rawvideo -pix_fmt yuv420p -s:v 3082x1884 \
> -i ./3082x1884.yuv -vf 'vpp_qsv=w=2466:h=1508' -f rawvideo \
> -pix_fmt yuv420p 2466_1508.yuv
>
> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
> ---
> libavfilter/qsvvpp.c | 13 +++++++++++++
> libavfilter/qsvvpp.h | 1 +
> libavfilter/vf_deinterlace_qsv.c | 1 +
> libavfilter/vf_overlay_qsv.c | 2 ++
> libavfilter/vf_scale_qsv.c | 1 +
> libavfilter/vf_vpp_qsv.c | 1 +
> 6 files changed, 19 insertions(+)
>
> diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
> index 8428ee89ab..d5cfeab402 100644
> --- a/libavfilter/qsvvpp.c
> +++ b/libavfilter/qsvvpp.c
> @@ -1003,3 +1003,16 @@ int ff_qsvvpp_create_mfx_session(void *ctx,
> }
>
> #endif
> +
> +AVFrame *ff_qsvvpp_get_video_buffer(AVFilterLink *inlink, int w, int h)
> +{
> + /* When process YUV420 frames, FFmpeg uses same alignment on Y/U/V
> + * planes. VPL and MSDK use Y plane's pitch / 2 as U/V planes's
> + * pitch, which makes U/V planes 16-bytes aligned. We need to set a
> + * separate alignment to meet runtime's behaviour.
> + */
> + return ff_default_get_video_buffer2(inlink,
> + FFALIGN(inlink->w, 32),
> + FFALIGN(inlink->h, 32),
> + 16);
> +}
> diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h
> index a8cfcc565a..6f7c9bfc15 100644
> --- a/libavfilter/qsvvpp.h
> +++ b/libavfilter/qsvvpp.h
> @@ -127,4 +127,5 @@ int ff_qsvvpp_print_warning(void *log_ctx, mfxStatus err,
> int ff_qsvvpp_create_mfx_session(void *ctx, void *loader, mfxIMPL
> implementation,
> mfxVersion *pver, mfxSession *psession);
>
> +AVFrame *ff_qsvvpp_get_video_buffer(AVFilterLink *inlink, int w, int h);
> #endif /* AVFILTER_QSVVPP_H */
> diff --git a/libavfilter/vf_deinterlace_qsv.c
> b/libavfilter/vf_deinterlace_qsv.c
> index 98ed7283ad..6c94923f02 100644
> --- a/libavfilter/vf_deinterlace_qsv.c
> +++ b/libavfilter/vf_deinterlace_qsv.c
> @@ -581,6 +581,7 @@ static const AVFilterPad qsvdeint_inputs[] = {
> .name = "default",
> .type = AVMEDIA_TYPE_VIDEO,
> .filter_frame = qsvdeint_filter_frame,
> + .get_buffer.video = ff_qsvvpp_get_video_buffer,
> },
> };
>
> diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c
> index d947a1faa1..1a2c1b1e96 100644
> --- a/libavfilter/vf_overlay_qsv.c
> +++ b/libavfilter/vf_overlay_qsv.c
> @@ -399,11 +399,13 @@ static const AVFilterPad overlay_qsv_inputs[] = {
> .name = "main",
> .type = AVMEDIA_TYPE_VIDEO,
> .config_props = config_main_input,
> + .get_buffer.video = ff_qsvvpp_get_video_buffer,
> },
> {
> .name = "overlay",
> .type = AVMEDIA_TYPE_VIDEO,
> .config_props = config_overlay_input,
> + .get_buffer.video = ff_qsvvpp_get_video_buffer,
> },
> };
>
> diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
> index 758e730f78..36d5f3a6ec 100644
> --- a/libavfilter/vf_scale_qsv.c
> +++ b/libavfilter/vf_scale_qsv.c
> @@ -641,6 +641,7 @@ static const AVFilterPad qsvscale_inputs[] = {
> .name = "default",
> .type = AVMEDIA_TYPE_VIDEO,
> .filter_frame = qsvscale_filter_frame,
> + .get_buffer.video = ff_qsvvpp_get_video_buffer,
> },
> };
>
> diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
> index 4a053f9145..b26d19c3bc 100644
> --- a/libavfilter/vf_vpp_qsv.c
> +++ b/libavfilter/vf_vpp_qsv.c
> @@ -634,6 +634,7 @@ static const AVFilterPad vpp_inputs[] = {
> .name = "default",
> .type = AVMEDIA_TYPE_VIDEO,
> .config_props = config_input,
> + .get_buffer.video = ff_qsvvpp_get_video_buffer,
> },
> };
LGTM, will apply,
Thanks
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".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-07 1:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-05 6:32 [FFmpeg-devel] [PATCH v3] libavfilter/qsvvpp: Change the alignment to meet the requirement of YUV420P format wenbin.chen-at-intel.com
2022-12-07 1:52 ` Xiang, Haihao
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