From patchwork Sat Apr 2 11:59:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, Wenbin" X-Patchwork-Id: 35137 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c05:b0:7a:e998:b410 with SMTP id bw5csp1070085pzb; Sat, 2 Apr 2022 05:00:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweQG17eTqMQ0/PTcGZBxxfYq43IhIDTaO5hb5RwIuAyc/hs4/mUo2ifNLNdjLEZN5JOtH/ X-Received: by 2002:aa7:cc02:0:b0:411:487e:36fe with SMTP id q2-20020aa7cc02000000b00411487e36femr24834436edt.338.1648900818142; Sat, 02 Apr 2022 05:00:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648900818; cv=none; d=google.com; s=arc-20160816; b=ZzwU8Ym7Rgi/y09Y1M3g0uK71nGAy1eQgLA4MsirSC1ezFY6AmA47dp6cLH7CK9fIM mEOkZBpuWaidLAJ5yHWeMUTJ+NcdQ1B3vnzig1zKChD4DZA8/ubkR/6ONFzEq1qVRjJm mYMqYjueHfgB6JAl754+Oge6jUOOCWN8kdgvRyp5tnJAEr3CMWqk8Q7PmRpXd5qCJ6FW IcU3RDYOGOJ6UZ3sLkCqdW7bbl6AYRo7uYkrO+ujynxG6P29oqBzcuzdhhhrQxDETMIv uo9pqwtYSIsteQTJD3pOdgqYJin7HqWX/3qxr+yOZQ+Lg6L56Oo/xeoZ42KYEu1N6Y2R RU5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=WmumTcXFdqSHQ4aphfK742X/fO4EAZKXVCAhwSRXgDE=; b=pscoXl6lSe8PgjhAUd+NC9JmtpnoaRiTcm+dCnRteWbcfidl77PGtpgciN+8j3vnvX q/tdNseyLbGmnD7pUVxgwSd/TyoVBK+VfN7WUI2jHQwLCQoM+sMZNWLk7U6OTmlNmUJR tg64mP5GqxlpPK47FA1s35/Qsd0JvawtkVDsdUIjPDyLLjUPKG0oUQ+8wYGHpoYY7OO4 cb+Zah9HARitvrvKckdYFxIoPxD4SIICddDKjbh5urVsdM0saU2aQEXs/wfhI/n50CME sJ8vRgYD2e+LqS8oZfzVtAJ9tdWXARlNhCg6wHPAePikwh0VwWTe06ZVRtXBbOiZ5TQ4 39Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=Vjz5KqDf; 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 le14-20020a170907170e00b006df76385db4si3083407ejc.596.2022.04.02.05.00.17; Sat, 02 Apr 2022 05:00:18 -0700 (PDT) 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=Vjz5KqDf; 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 3997068B205; Sat, 2 Apr 2022 15:00:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: DE4guIDNbXVH 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);