[FFmpeg-devel] [PATCH] libavfilter/qsvvpp: Use different alignment for YUV420P format

wenbin.chen at intel.com wenbin.chen at intel.com
Tue Nov 29 10:07:02 EET 2022


From: Wenbin Chen <wenbin.chen at 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 at 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



More information about the ffmpeg-devel mailing list