* [FFmpeg-devel] [PATCH] libavfilter/qsvvpp: Use different alignment for YUV420P format
@ 2022-11-29 8:07 wenbin.chen-at-intel.com
2022-11-29 12:31 ` James Almer
0 siblings, 1 reply; 3+ messages in thread
From: wenbin.chen-at-intel.com @ 2022-11-29 8:07 UTC (permalink / raw)
To: ffmpeg-devel
From: Wenbin Chen <wenbin.chen@intel.com>
When process yuv420 frames, FFmpeg use same alignment on Y/U/V
planes. VPL and MSDK use Y plane's pitch / 2 as U/V planes's
pitch, which make U/V planes 16-bytes aligned. We need to set
a separate alignment to meet runtime's 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 | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 8428ee89ab..ad09114cb7 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -408,9 +408,15 @@ static QSVFrame *submit_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *p
} else {
/* make a copy if the input is not padded as libmfx requires */
if (picref->height & 31 || picref->linesize[0] & 31) {
- qsv_frame->frame = ff_get_video_buffer(inlink,
- FFALIGN(inlink->w, 32),
- FFALIGN(inlink->h, 32));
+ /* 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.
+ */
+ qsv_frame->frame = ff_default_get_video_buffer2(inlink,
+ FFALIGN(inlink->w, 32),
+ FFALIGN(inlink->h, 32),
+ 16);
if (!qsv_frame->frame)
return NULL;
--
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] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavfilter/qsvvpp: Use different alignment for YUV420P format
2022-11-29 8:07 [FFmpeg-devel] [PATCH] libavfilter/qsvvpp: Use different alignment for YUV420P format wenbin.chen-at-intel.com
@ 2022-11-29 12:31 ` James Almer
2022-11-30 4:08 ` Chen, Wenbin
0 siblings, 1 reply; 3+ messages in thread
From: James Almer @ 2022-11-29 12:31 UTC (permalink / raw)
To: ffmpeg-devel
On 11/29/2022 5:07 AM, wenbin.chen-at-intel.com@ffmpeg.org wrote:
> From: Wenbin Chen <wenbin.chen@intel.com>
>
> When process yuv420 frames, FFmpeg use same alignment on Y/U/V
> planes. VPL and MSDK use Y plane's pitch / 2 as U/V planes's
> pitch, which make U/V planes 16-bytes aligned. We need to set
> a separate alignment to meet runtime's 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 | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
> index 8428ee89ab..ad09114cb7 100644
> --- a/libavfilter/qsvvpp.c
> +++ b/libavfilter/qsvvpp.c
> @@ -408,9 +408,15 @@ static QSVFrame *submit_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *p
> } else {
> /* make a copy if the input is not padded as libmfx requires */
> if (picref->height & 31 || picref->linesize[0] & 31) {
> - qsv_frame->frame = ff_get_video_buffer(inlink,
> - FFALIGN(inlink->w, 32),
> - FFALIGN(inlink->h, 32));
> + /* 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.
> + */
> + qsv_frame->frame = ff_default_get_video_buffer2(inlink,
I think the proper way to do this is by setting a custom AVFilterPad
get_buffer.video() callback, which will be called instead of
ff_default_get_video_buffer() (Which uses an automatically chosen
alignment at runtime) by ff_get_video_buffer().
See other filters like vf_pad, vf_transpose_vaapi, etc.
> + FFALIGN(inlink->w, 32),
> + FFALIGN(inlink->h, 32),
> + 16);
> if (!qsv_frame->frame)
> return NULL;
>
_______________________________________________
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] 3+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavfilter/qsvvpp: Use different alignment for YUV420P format
2022-11-29 12:31 ` James Almer
@ 2022-11-30 4:08 ` Chen, Wenbin
0 siblings, 0 replies; 3+ messages in thread
From: Chen, Wenbin @ 2022-11-30 4:08 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> On 11/29/2022 5:07 AM, wenbin.chen-at-intel.com@ffmpeg.org wrote:
> > From: Wenbin Chen <wenbin.chen@intel.com>
> >
> > When process yuv420 frames, FFmpeg use same alignment on Y/U/V
> > planes. VPL and MSDK use Y plane's pitch / 2 as U/V planes's
> > pitch, which make U/V planes 16-bytes aligned. We need to set
> > a separate alignment to meet runtime's 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 | 12 +++++++++---
> > 1 file changed, 9 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
> > index 8428ee89ab..ad09114cb7 100644
> > --- a/libavfilter/qsvvpp.c
> > +++ b/libavfilter/qsvvpp.c
> > @@ -408,9 +408,15 @@ static QSVFrame *submit_frame(QSVVPPContext
> *s, AVFilterLink *inlink, AVFrame *p
> > } else {
> > /* make a copy if the input is not padded as libmfx requires */
> > if (picref->height & 31 || picref->linesize[0] & 31) {
> > - qsv_frame->frame = ff_get_video_buffer(inlink,
> > - FFALIGN(inlink->w, 32),
> > - FFALIGN(inlink->h, 32));
> > + /* 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.
> > + */
> > + qsv_frame->frame = ff_default_get_video_buffer2(inlink,
>
> I think the proper way to do this is by setting a custom AVFilterPad
> get_buffer.video() callback, which will be called instead of
> ff_default_get_video_buffer() (Which uses an automatically chosen
> alignment at runtime) by ff_get_video_buffer().
>
> See other filters like vf_pad, vf_transpose_vaapi, etc.
Thanks for your advice. I will try it.
>
> > + FFALIGN(inlink->w, 32),
> > + FFALIGN(inlink->h, 32),
> > + 16);
> > if (!qsv_frame->frame)
> > return NULL;
> >
> _______________________________________________
> 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".
_______________________________________________
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] 3+ messages in thread
end of thread, other threads:[~2022-11-30 4:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29 8:07 [FFmpeg-devel] [PATCH] libavfilter/qsvvpp: Use different alignment for YUV420P format wenbin.chen-at-intel.com
2022-11-29 12:31 ` James Almer
2022-11-30 4:08 ` Chen, Wenbin
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