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 9DEDF4073F for ; Thu, 31 Mar 2022 07:44:18 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CE55468B1D4; Thu, 31 Mar 2022 10:44:15 +0300 (EEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C2BE568B0BE for ; Thu, 31 Mar 2022 10:44:08 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648712653; x=1680248653; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=zpYRDEhJeBcY00g//vurdFmMz+M5acDGixeybxVo3Hs=; b=bMMP2J6RMsUZ+06BqfogMIoqc57Vp9qHYJvndl1Y743TLOTT8OwdsQuy ZTv+Ux2Q/rVLQI/KuA/DJkd13nvTBrPeByVNJf6IUIFG42LvYrWUKfVbg FRNb1L6F3z0zNkfQJmX7f+eyavw7KkcmF0DD6NXzcmb4E0RG9ezroXVSN r5cm4FQzBSyfAntK5hud6Y98AMT3qDI9DLiSvNI7px+BwyKb6wERK7IFE w9Um+2KiERiLLDHLFqw3ryDjWGM3d2l4dQtEmLtTDTvg9DKTMUK6C5Szx CYCKti6s6sUVWl+Q7In/W1tNKuHcL8SWIKM3zGn32KIGSGuk2jo36/o4c g==; X-IronPort-AV: E=McAfee;i="6200,9189,10302"; a="259929600" X-IronPort-AV: E=Sophos;i="5.90,224,1643702400"; d="scan'208";a="259929600" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2022 00:44:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,224,1643702400"; d="scan'208";a="566240633" Received: from wenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.4]) by orsmga008.jf.intel.com with ESMTP; 31 Mar 2022 00:44:06 -0700 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Thu, 31 Mar 2022 15:43:41 +0800 Message-Id: <20220331074341.896911-1-wenbin.chen@intel.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] libavutil/hwcontext_qsv: Align width and heigh when download qsv frame 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: The width and height for qsv frame to download need to be aligned with 16. Add the alignment operation. Now the following command works: ffmpeg -hwaccel qsv -f rawvideo -s 1920x1080 -pix_fmt yuv420p -i \ input.yuv -vf "hwupload=extra_hw_frames=16,format=qsv,hwdownload, \ format=nv12" -f null - Signed-off-by: Wenbin Chen --- libavutil/hwcontext_qsv.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 95f8071abe..1e7c065902 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -1063,6 +1063,40 @@ static int qsv_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst, if (ret < 0) return ret; + /* According to MSDK spec for mfxframeinfo, "Width must be a multiple of 16. + * Height must be a multiple of 16 for progressive frame sequence and a + * multiple of 32 otherwise.", so allign all frames to 16 before downloading. */ + if (ctx->height & 15 || dst->linesize[0] & 15) { + AVFrame *tmp_frame; + tmp_frame = av_frame_alloc(); + if (!tmp_frame) + return AVERROR(ENOMEM); + ret = av_frame_ref(tmp_frame, dst); + if (ret < 0) { + av_frame_free(&tmp_frame); + return ret; + } + av_frame_unref(dst); + + dst->width = FFALIGN(tmp_frame->width, 16); + dst->height = FFALIGN(ctx->height, 16); + dst->format = tmp_frame->format; + ret = av_frame_get_buffer(dst, 0); + if (ret < 0) { + av_frame_free(&tmp_frame); + return ret; + } + + dst->width = tmp_frame->width; + dst->height = tmp_frame->height; + ret = av_frame_copy_props(dst, tmp_frame); + if (ret < 0) { + av_frame_free(&tmp_frame); + return ret; + } + av_frame_free(&tmp_frame); + } + if (!s->session_download) { if (s->child_frames_ref) return qsv_transfer_data_child(ctx, dst, src); -- 2.32.0 _______________________________________________ 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".