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 5A5834084D for ; Sat, 2 Apr 2022 12:00:15 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 050CA68B1FA; Sat, 2 Apr 2022 15:00:13 +0300 (EEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EC74268B11B for ; Sat, 2 Apr 2022 15:00:06 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648900812; x=1680436812; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=0M+kYuL9jRTXbQ+cTTFkqtEhjPc/6p9/hukNX4T48Yw=; b=Vjz5KqDfonB35mZaEo+F8WI+kM8OElL6nE3DOzuN1EHQoMdcLrF5TKL8 5mIfa27BAx+4RMp0zrikGtIVemjABLZteZ0BSkIzl7xVhmXvcMW7Gkk0K 8kF+kzm15cdkN/Z7wzkTL2zyRjktadhBvJI1elSKzRCTUUQ2GvhKio1hH EuamqIDzvjo5Sqr2pBixh31qyxCi2dNjbRh2nfdIrQjhVTbbj0ZmGIklE aB8L0mbMM7/UdXWlgF0lNZnN9DIGQmJcopqsEUcjpKl1yoP9/80o9NNLl wB3zLsdJ76j6Nn/i7elSnWZPp2qPS/0jwDIk0fJOUNFnrGu8zNvMGCDOS w==; X-IronPort-AV: E=McAfee;i="6200,9189,10304"; a="242439621" X-IronPort-AV: E=Sophos;i="5.90,230,1643702400"; d="scan'208";a="242439621" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2022 05:00:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,230,1643702400"; d="scan'208";a="789067486" Received: from wenbin-z390-aorus-ultra.sh.intel.com ([10.239.35.4]) by fmsmga006.fm.intel.com with ESMTP; 02 Apr 2022 05:00:03 -0700 From: Wenbin Chen To: ffmpeg-devel@ffmpeg.org Date: Sat, 2 Apr 2022 19:59:39 +0800 Message-Id: <20220402115939.993541-1-wenbin.chen@intel.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] 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 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 95f8071abe..fe11e215a8 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -1063,6 +1063,38 @@ 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 (dst->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->linesize[0], 16); + dst->height = FFALIGN(tmp_frame->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); + av_frame_free(&tmp_frame); + if (ret < 0) + return ret; + } + 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".