From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id AA8A044272 for ; Mon, 5 Dec 2022 06:32:26 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 14C7568BC1C; Mon, 5 Dec 2022 08:32:24 +0200 (EET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 16E7568BAFB for ; Mon, 5 Dec 2022 08:32:16 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670221942; x=1701757942; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=+vt5lsFPZTTjx3BrvykZ6BsEpTUre4lPQORO55wxuNI=; b=FnlhHcYW8UlXvI0dGVGrBvrtLLEzqR5F84zRW5ZeAmMz8DR/3sA5ENd2 3gVc5G5Vi/bNYAUONdZUcpMXy4+jwsyclSzyOP9HYQIYWRZC+Fk9DB0lm k2/zmP6zax5x3DtdKeYedMGZCJuhhwb4Gw2iGZ6jZZGHmShNuk05dKVCb yyWf4MGt2fkbtSQGBXUVvU882V9okEZU3NFJg5DzSKsat6h2Ke0toHmSn n33H5ic1ISJtJ9xfqjZzjJivpSAXBkR49QHufUaiCPhmW9ihfVRbQyeDt H8BrqydzU6eO3t2+czy9iDGnoFRgz7pr48dR86M9NVydokaod4r0ai2P3 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10551"; a="316301231" X-IronPort-AV: E=Sophos;i="5.96,218,1665471600"; d="scan'208";a="316301231" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2022 22:32:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10551"; a="770242531" X-IronPort-AV: E=Sophos;i="5.96,218,1665471600"; d="scan'208";a="770242531" Received: from wenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.4]) by orsmga004.jf.intel.com with ESMTP; 04 Dec 2022 22:32:14 -0800 From: wenbin.chen-at-intel.com@ffmpeg.org To: ffmpeg-devel@ffmpeg.org Date: Mon, 5 Dec 2022 14:32:13 +0800 Message-Id: <20221205063213.315082-1-wenbin.chen@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3] libavfilter/qsvvpp: Change the alignment to meet the requirement of 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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, }, }; -- 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".