From patchwork Thu Dec 1 02:48:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, Wenbin" X-Patchwork-Id: 39546 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp30920pzb; Wed, 30 Nov 2022 18:49:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf5cFtzvCJxqVOZGTjDghQ+4/PhO5zyb51gs24Rm3SSKJ4wRfPSdfzYDJhSt8Ur8YkjSDFjh X-Received: by 2002:a17:906:f1d9:b0:7c0:7a5c:9f3 with SMTP id gx25-20020a170906f1d900b007c07a5c09f3mr13298872ejb.643.1669862955617; Wed, 30 Nov 2022 18:49:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669862955; cv=none; d=google.com; s=arc-20160816; b=MAW5AOjBf03QLa2XXRQrnZh7chrZI69dX1EefAHyhI8DwV6cW/6kX8CZy+txZUmos2 3JoUMR/rNdeZFVQn6yEtzye/SVjrZ6Fg4DJnfjRyZs106tvYuSQYrYzHiVNIF1fwvD/L F05+iV80xkiztSZ9mzvhwIodb4FPtjSQIFKEIGLiYIPxA/2NnRQmI1RxZzQO5Pb5OCMj cUndwWu/MviR8/lJS80OsPProOXvfK5//edwCWFakVfrOmm5TCoaJN1JupoULbG4JN2P EezDfe4dg6N9WyqLxraJvaVFzZ2SJRgsNIFlHpQpWNns9xL/fSxPUCrL6Svr7I+x+/JZ kI+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=gHWufefVc08YC2VjpUTkUScHcZ1o/vL6OvzuJBNpw7g=; b=PXjnEuZVv4Vx3dMtuMyfFtAc7VJw5oxL1Td6vdUx5etg/qyaWkabGd7Z9UpW77kaHW DToFmLBwtcw1rI4lr92k18jU0lKds3LuavaesEDTfn592Pq6sMVEMyaxk3syPLeb8M7H Bz+v8d1U7AY1qWCn3eII1FHO8cJTaNyJnH14lAw2tWLYAn361ntFjD+wFc/YX2sUwUE0 zsxMS7CGs2Ol7EV3v9OgzAvA3n25hpq9oLc//fglcI0k8PBEEedKqTIJmmpI/PNNlHHV +A6NySVU8bPedIZ9p0OfIfc8erzHTLi3GBNguuDbwYrb4XVfCiLi/XhwptYgVXcToGU/ QJOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b="ejeV+Jt/"; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p13-20020a1709065dcd00b007aeff3b0b17si2582034ejv.674.2022.11.30.18.49.09; Wed, 30 Nov 2022 18:49:15 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b="ejeV+Jt/"; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DFDAA689CE2; Thu, 1 Dec 2022 04:49:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4F7E6689CE2 for ; Thu, 1 Dec 2022 04:48:58 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669862943; x=1701398943; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=+vt5lsFPZTTjx3BrvykZ6BsEpTUre4lPQORO55wxuNI=; b=ejeV+Jt/AbgJxqAtX/T2DgIzsvbQu2abo0Hg3FEJQbTPyPBL/5idUQgH 35x/tsScRUfXEdPzLgQMrlYTh8FZmJqzd3XmFHDkf+nfio4YdbCjzEcTA qTc0i7Jn770Y00zcQqLrQWvPJhVSGz1wIQ15GAI1NbgToXi/rdKOPfBbs +8brn6Iq8vUYLwQ0zEf0ks4X007+Qz2PPQzV1mLXb8qhZ8NouYI3NHXjj brZbDnZRMGrflniK212Jn5TH0SpXkOSx8tC+DGRsXeJ1WgnZAYr2sil4t ci/uPIHJvM76HgyyoAI3rq5LSc/OmhjtZHKK1bPuDLcZzqFWV6RlC38PR Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10547"; a="317424006" X-IronPort-AV: E=Sophos;i="5.96,207,1665471600"; d="scan'208";a="317424006" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2022 18:48:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10547"; a="638228666" X-IronPort-AV: E=Sophos;i="5.96,207,1665471600"; d="scan'208";a="638228666" Received: from wenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.4]) by orsmga007.jf.intel.com with ESMTP; 30 Nov 2022 18:48:53 -0800 From: wenbin.chen-at-intel.com@ffmpeg.org To: ffmpeg-devel@ffmpeg.org Date: Thu, 1 Dec 2022 10:48:50 +0800 Message-Id: <20221201024850.425856-1-wenbin.chen@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] libavfilter/qsvvpp: Use different alignment for YUV420P format X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Wenbin Chen Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: mu5PcdeWuvau From: Wenbin Chen 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 --- 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, }, };