From patchwork Fri Apr 29 10:45:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Tong1" X-Patchwork-Id: 35503 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp212059pzb; Fri, 29 Apr 2022 03:45:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuAkx5z9WztltH7hKzamQ44q6djFFGYm2vP9DcAVbH5lZutRD+U8DpT7GjV9GHz3jLgPN9 X-Received: by 2002:a05:6402:2788:b0:426:18e3:b6f9 with SMTP id b8-20020a056402278800b0042618e3b6f9mr12452533ede.81.1651229132495; Fri, 29 Apr 2022 03:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651229132; cv=none; d=google.com; s=arc-20160816; b=O4UtKc7FMULWdVnS0Mc9vgTr9YBa3Kg7s9q2PGRgHDtO+rx7/Jh6Q7YuNk3uPPZSdf o2ZT0YzgeWb/u2VqzsQ0ccv53m9ULyIphchc8vuNSWDyycCE1zjgLHXCwLjDdItH2vC+ 9Po2vEbCk5WU8YkTBp52PpO6zb5GjyNOOW7wfuC+fSewGaoHJWzW6RUOs1UdIUH2F9SP rDPWFNHI8zgbPycCM/teBE+Z/M/FI2tzby+5uUioKYfzt52+M0FySqwnWiBcdPNa18dr b1Qra8xJajP2xWgpbn7GUOUFVOBvTWSPCmD+7rKiWj2s8xpqXLdGFCR8fL1vfYIJdnpP KPyw== 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=VBrItA7bm0luCHHJzRDsKxFPeomS+KgwTmkp6fBNELU=; b=0gkg9dZFfDuJyfytRB6fSI11m9WY6D2/fXlzAfR5e4jc07HPGudDDHeJdhxgxsjyK2 fxyv9Y576prEA8viMLV2aXGpkDAqwLVUprKCFN9zuD+euR8t6WeyBrcrspwggqqxnVNK DEaEVAYaXNScnZui4i+qWYrue12qS5KYiEek7LF3WjzBk9b9a/+pnuPzupRBe2kFAmLQ 9uwfuTrVRrwFpQhN7GfOEuoHAVjtn8q3/1hBOYs7gziv/AX+h0qvV7moQBCt8s5/jiBU 0g0JzWn/IKncO6rnRrgD1GDqtYMUCpbegVsYNiJYZsG2RAIFWHdwNHVthAGx0D8lLkue rcxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=AafAwWUl; 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 lx15-20020a170906af0f00b006e86ef1545csi5466941ejb.326.2022.04.29.03.45.31; Fri, 29 Apr 2022 03:45:32 -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=AafAwWUl; 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 C931568B29A; Fri, 29 Apr 2022 13:45:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EC05868B1BB for ; Fri, 29 Apr 2022 13:45:20 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651229126; x=1682765126; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=3+E3893/sNEwsEglkpLG7l7ge7lL/7AJFqcoDgZFvYY=; b=AafAwWUl5sYag8/OAEVidvwTai5NL1YrpF2HvR14kzMcTuh9UG0zB0vN 661CaH0r2inaY7SsRcke2GU8bwaRUiSUH6RdKvxrXuQqZplXayuwu37cT 7oyRitDc2FFHZKZ1caoOeaMIBM8cHsCrY7UMMpr67ZeQUxeWGqop+Mn0Z VxJ/N/dwT8SHHEsivUN0PjdPCm0qPW1pXuKPWlrJWYRQV86ZcxZwvZEb6 uqiYoakE8Saw4IhUgB4t9G5D2KY3x4fX5zevSs7REXLj8+esCB4lz0Qkj o+/ut91GCwLz8kMhwAToLY08CdSLh2R7LPyt4tGLzrCRoRwoO46x1Rf/7 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10331"; a="329548320" X-IronPort-AV: E=Sophos;i="5.91,298,1647327600"; d="scan'208";a="329548320" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2022 03:45:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,298,1647327600"; d="scan'208";a="566080472" Received: from gtapc.iind.intel.com (HELO localhost.localdomain) ([10.190.235.42]) by fmsmga007.fm.intel.com with ESMTP; 29 Apr 2022 03:45:16 -0700 From: Tong Wu To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Apr 2022 10:45:01 +0000 Message-Id: <20220429104505.1747-1-tong1.wu@intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/5] avutil/hwcontext_d3d11va: fix the uninitialized texture bindflag 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: Tong Wu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: okKeLg9J2lxD When uploading rawvideos using d3d11va hardware framecontext, the bindflag is not initialized and will cause creating texture failure. Now fix it, assign it the value of D3D11_BIND_RENDER_TARGET. Fixes: $ ffmpeg.exe -init_hw_device d3d11va=d3d11 -f lavfi -i yuvtestsrc -vf \ "format=nv12,hwupload=extra_hw_frames=16" -f null - Signed-off-by: Tong Wu --- libavutil/hwcontext_d3d11va.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c index 8ab96bad25..db529acbb4 100644 --- a/libavutil/hwcontext_d3d11va.c +++ b/libavutil/hwcontext_d3d11va.c @@ -254,6 +254,11 @@ static int d3d11va_frames_init(AVHWFramesContext *ctx) return AVERROR(EINVAL); } + if (!hwctx->BindFlags) { + av_log(ctx, AV_LOG_DEBUG, "Add render target bindflag for texture\n"); + hwctx->BindFlags = D3D11_BIND_RENDER_TARGET; + } + texDesc = (D3D11_TEXTURE2D_DESC){ .Width = ctx->width, .Height = ctx->height, From patchwork Fri Apr 29 10:45:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Tong1" X-Patchwork-Id: 35504 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp212136pzb; Fri, 29 Apr 2022 03:45:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVhZaL5v+cDXpIYMicPT0bLu6tvzchRjWJZJp9Du/INHV5yuQWaZ/U1rarbrN5golhtpMC X-Received: by 2002:a17:907:2d11:b0:6f0:f39:f647 with SMTP id gs17-20020a1709072d1100b006f00f39f647mr34754380ejc.694.1651229142154; Fri, 29 Apr 2022 03:45:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651229142; cv=none; d=google.com; s=arc-20160816; b=UnM6tXvr/LL+oouO6ZrWbwJUBX5Cz+hK5AZwXxSQQdssv3zBM9oPbDT88TMyYIfMb7 l/JaMvBr4z84zpMJXHz7lpoPdJ0VxS18XYekjr2i7RvrYxjzxJmN0H2DvGRvR5nSvz1I ghENqGcXhb6pmtKEyqxjM5ovnNP9K2tQG39lF8hJqW6JQs0qG4oWhFcjxBFZhGWNQizS vaVN3Nyj+Bmkv68Gdk1hyq9aHFR371ZKBQUfa2xKO+ZGuf548ncRdujulA05ii2zV5Ys +e9zKN2GA9hJDkSG2mujSZPYGW6+bh2pIhLrI940UfCGFuhEGt9Cjr8MJnCV/UxKIuYK baeA== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=Le1J5zk2nc8MM7SVCcmnPtkeEXpcGCcTSum8JtTY/2o=; b=mIMs8VpwGI2maRZZPduaNCsuMlSsTpKZxkhQWgdXxpnYweaDa/h3n1aqsVIevhWYqy JdWJo1UmHCk/iskf00nWdOrtn94Z5FLXij23OdHz08tfD2f4jPDckbHOqMKEdMhhiLXY bnYqGTPaGUDWy5ni+wEWMPUJPi0uoQksIw5KrDTnW+01T0IAOh6iEt0ritbBGuEe0Pr3 elDpc430lPBnzZVzX4efX3fu4BelHmSj8vUW1CbQEn7JN07fj0ArwwIku8GdCkgTgHfr MDxtoYLBfLVrTLW2gMGPHJpnyq+gtwwWI9L/3t/7n0RKd6NkA5G5ShAD3yW1i4Ms8ZmU tKWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=jUd6gn68; 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 mz14-20020a1709071b8e00b006f3bf032c05si5265617ejc.793.2022.04.29.03.45.41; Fri, 29 Apr 2022 03:45:42 -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=jUd6gn68; 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 E04C368B2C6; Fri, 29 Apr 2022 13:45:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9547C68B294 for ; Fri, 29 Apr 2022 13:45:22 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651229127; x=1682765127; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CwLgUhv9/5i28NGmEU+boOX9Y1cTIVG6InFgcv7VpRY=; b=jUd6gn68eewKFTsVSNqHDwOMnO69hSDQlqQGjmxnmkZSr6IgbLx21IqZ Wu33iahkyoCTXJDlTtui6d5DI2bpguGgkEawWNbAn/tuHW11EQr5aYIwi QY8Wm8uC+uXR26obE2hhDbFKmEDwHiprv8DqmGrAKAmM2FsuKKW4gX9U3 OVt1Tu35S2vd83qJqOYvifOYyyxL6WsqMN0ytNxJ6kP5rtK1xUccPWddD OM+aPSp7liKOgCUkMin+cXtsgJMFGIaePo5r7euXhb75fMRNyZDYGteW7 D9WMsLDXTGCO4dCb8uQn8LY/xisU6QJRrAAO8LGr6U5QbyXrEGwoc+g4L g==; X-IronPort-AV: E=McAfee;i="6400,9594,10331"; a="329548322" X-IronPort-AV: E=Sophos;i="5.91,298,1647327600"; d="scan'208";a="329548322" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2022 03:45:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,298,1647327600"; d="scan'208";a="566080485" Received: from gtapc.iind.intel.com (HELO localhost.localdomain) ([10.190.235.42]) by fmsmga007.fm.intel.com with ESMTP; 29 Apr 2022 03:45:17 -0700 From: Tong Wu To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Apr 2022 10:45:02 +0000 Message-Id: <20220429104505.1747-2-tong1.wu@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220429104505.1747-1-tong1.wu@intel.com> References: <20220429104505.1747-1-tong1.wu@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/5] avutil/hwcontext_qsv: derive QSV frames to D3D11VA frames 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: Tong Wu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: zVWVw9u02c4A Fixes: $ ffmpeg.exe -y -hwaccel qsv -init_hw_device d3d11va=d3d11 \ -init_hw_device qsv=qsv@d3d11 -c:v h264_qsv -i input.h264 \ -vf "hwmap=derive_device=d3d11va,format=d3d11" -f null - Signed-off-by: Tong Wu --- libavutil/hwcontext_qsv.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 66c0e38955..d9d05e936a 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -808,12 +808,23 @@ static int qsv_frames_derive_from(AVHWFramesContext *dst_ctx, #if CONFIG_D3D11VA case AV_HWDEVICE_TYPE_D3D11VA: { + dst_ctx->initial_pool_size = src_ctx->initial_pool_size; AVD3D11VAFramesContext *dst_hwctx = dst_ctx->hwctx; - mfxHDLPair *pair = (mfxHDLPair*)src_hwctx->surfaces[i].Data.MemId; - dst_hwctx->texture = (ID3D11Texture2D*)pair->first; + dst_hwctx->texture_infos = av_calloc(src_hwctx->nb_surfaces, + sizeof(*dst_hwctx->texture_infos)); if (src_hwctx->frame_type & MFX_MEMTYPE_SHARED_RESOURCE) dst_hwctx->MiscFlags = D3D11_RESOURCE_MISC_SHARED; dst_hwctx->BindFlags = qsv_get_d3d11va_bind_flags(src_hwctx->frame_type); + for (i = 0; i < src_hwctx->nb_surfaces; i++) { + mfxHDLPair* pair = (mfxHDLPair*)src_hwctx->surfaces[i].Data.MemId; + dst_hwctx->texture_infos[i].texture = (ID3D11Texture2D*)pair->first; + if (dst_hwctx->BindFlags & D3D11_BIND_RENDER_TARGET) { + dst_hwctx->texture_infos[i].index = 0; + } + else { + dst_hwctx->texture_infos[i].index = (intptr_t)pair->second; + } + } } break; #endif From patchwork Fri Apr 29 10:45:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Tong1" X-Patchwork-Id: 35505 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp212204pzb; Fri, 29 Apr 2022 03:45:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuGg0EXStqoSfm0dMoiJSyJPwqnD6GplIHPldv2smpyS6VMWYNxNXhPo544cfNRZRX0xO4 X-Received: by 2002:a50:fa94:0:b0:425:e8ac:3fb4 with SMTP id w20-20020a50fa94000000b00425e8ac3fb4mr26401279edr.43.1651229152433; Fri, 29 Apr 2022 03:45:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651229152; cv=none; d=google.com; s=arc-20160816; b=xlPwVueC5WK2PLQ/PKoUCpbACYcMYLzBswPV8aGSUJP/arC2dZycogfk7WR1gDgqv1 oS/5u2HL5jtan0+jRg5680XBm6MKKmrJ6k8Ay2Q3ANOATie6Tr5zUuaag847z+E0SMzK MLvyOzCRX7J/teMlZ0yAuXRLOLjuhWvTK6dB7/8uZoTcGNufPA3Q2D2apXS4v6CPB8UW HU4x6dF+AnAobxIdSxQUiMQT2DYx+dKru9+3ajN/Sqz4Gf+mIGwKAhoOEEc/HMYcB6zV YqmgAWyubnCketi6fQfdxhvamd14G1KT4iaV/vp+A2ha/zm2im2Zc1rHXTq7wxDcWXW+ knKQ== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=aCPxCnxEeF37YteMzEx3V64C6TM+ZT7Ds2NeYosbAxQ=; b=djR1NPclVHvXN8UadsKz8CAcbmoRqfQwjaCPm1H9w0hzQMLaKbWdpYp2zvfu9XPeVK ze7TM76VbYxNZVDL4zNPV6E1OPAzyU5skQpYk/LdlQ4FkZLy4WjHZTqcBQ0f6RIcpinL jF9WxIPfxQM9gCSafjMUKb2yVSW3U0duXUkskUmAEISMD+CS9awrUoYatmt3TV3cBUsV w49yTQCcV2I2GVkyP7DqhhQ8p1t5HwZzeb08dXDpAINVKLmbma9p8nhd/7wHmCVqX056 2eHorBfXfjLQizbyd6xbcE7ogeLzQRCmtR2Tmnwn7U0OhDLlolLHsTDjON9Y7/w9151/ DFXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=aC64jdn5; 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 sa31-20020a1709076d1f00b006f405295484si375321ejc.947.2022.04.29.03.45.51; Fri, 29 Apr 2022 03:45:52 -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=aC64jdn5; 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 06F9A68B2D5; Fri, 29 Apr 2022 13:45:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B5B5368B267 for ; Fri, 29 Apr 2022 13:45:23 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651229128; x=1682765128; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j5J4pwC3Zw42mRsmtyI6LzLhC4Fhi8bZoqCJXGG5Vxk=; b=aC64jdn5Fone+ehltLUib2FfNcXhO8elN9HJ+xLQ50XLYo+Jr6CrvS1W bCUkrXIbGw+H6VQrrhoxZp7Ktoz/xsflpXbLCwqXGqd/dxvtkMDYjut1I xbim5UEyC0ZFgutrAf1FxP4Hm3GgQSy5VPdFUYNJM6JgJPckpRScnbfj6 rNt8UnJlD8DXuoXXq7OsaWWnyLslqUkuNWqbd9AQUupnakqX0yaJhsnZe 719XV5T5RCRo11VyDifajdhHDXXthvyuCUiVZVqRRCJ0umxSzdW4gnjp8 jY0Q8upIMA1bxJ7t6VqFCVJBQsbWZJJfuKPYnpysIRgUHI5+YBqnBKON4 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10331"; a="329548328" X-IronPort-AV: E=Sophos;i="5.91,298,1647327600"; d="scan'208";a="329548328" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2022 03:45:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,298,1647327600"; d="scan'208";a="566080497" Received: from gtapc.iind.intel.com (HELO localhost.localdomain) ([10.190.235.42]) by fmsmga007.fm.intel.com with ESMTP; 29 Apr 2022 03:45:18 -0700 From: Tong Wu To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Apr 2022 10:45:03 +0000 Message-Id: <20220429104505.1747-3-tong1.wu@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220429104505.1747-1-tong1.wu@intel.com> References: <20220429104505.1747-1-tong1.wu@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 3/5] avutil/hwcontext_d3d11va: add a format check for staging texture 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: Tong Wu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 7dAuydJvoigl The texDesc.Format needs to be filled in with a corresponding format. I add a format check to initialize the format in case sometimes the ctx->internal->priv is not initialized, such as during the hwmap process. $ ffmpeg.exe -y -hwaccel qsv -init_hw_device d3d11va=d3d11 \ -init_hw_device qsv=qsv@d3d11 -c:v h264_qsv \ -i input.h264 -vf "hwmap=derive_device=d3d11va,format=d3d11,hwdownload,format=nv12" \ -f null - Signed-off-by: Tong Wu --- libavutil/hwcontext_d3d11va.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c index db529acbb4..0ec0e07d3a 100644 --- a/libavutil/hwcontext_d3d11va.c +++ b/libavutil/hwcontext_d3d11va.c @@ -349,6 +349,8 @@ static int d3d11va_create_staging_texture(AVHWFramesContext *ctx) AVD3D11VADeviceContext *device_hwctx = ctx->device_ctx->hwctx; D3D11VAFramesContext *s = ctx->internal->priv; HRESULT hr; + int i; + D3D11_TEXTURE2D_DESC texDesc = { .Width = ctx->width, .Height = ctx->height, @@ -360,6 +362,20 @@ static int d3d11va_create_staging_texture(AVHWFramesContext *ctx) .CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE, }; + if (!texDesc.Format) { + for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++) { + if (ctx->sw_format == supported_formats[i].pix_fmt) { + texDesc.Format = supported_formats[i].d3d_format; + break; + } + } + if (i == FF_ARRAY_ELEMS(supported_formats)) { + av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format: %s\n", + av_get_pix_fmt_name(ctx->sw_format)); + return AVERROR(EINVAL); + } + } + hr = ID3D11Device_CreateTexture2D(device_hwctx->device, &texDesc, NULL, &s->staging_texture); if (FAILED(hr)) { av_log(ctx, AV_LOG_ERROR, "Could not create the staging texture (%lx)\n", (long)hr); From patchwork Fri Apr 29 10:45:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Tong1" X-Patchwork-Id: 35506 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp212278pzb; Fri, 29 Apr 2022 03:46:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycD86DiX0jKWsmZhe9Yv2jUPdpQjVOsvRXHJKXzAgKQKDbQfunNJ/r7A6eDSfYOfhSBS7/ X-Received: by 2002:a50:9985:0:b0:425:c2dd:4cf7 with SMTP id m5-20020a509985000000b00425c2dd4cf7mr37163637edb.19.1651229161015; Fri, 29 Apr 2022 03:46:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651229161; cv=none; d=google.com; s=arc-20160816; b=zzJdbrrZCLKs0+VMmejj++KGm2yf8MdwtpTBtjWqWonSuZxKIG2SfSdRY8Wdpbtvfb UU2fZIT5tq9A8RsOc5xu1yBUqExiflZQKYgpkuCxLAfg7I2fjFxdOi5FPIZkMl88qWFc SZLU6THZtLkg/9pvp8Br0H5LSaQQZyUk+l6Mh4hqBCVzId+ovmFznJsVTrrMxDcsGPOi obs0jZmGAlw7x+NEwxTNmPChSorr/kkRg7KvPPOT5co5/un7UzNEVYc84B1pkruha0sE 4qYEXXVKVv2xJQc7eN9qnXehIJbCSZOJpMgF86tB0ttsrlhWeOPM5pfhMA8b8rvFslxx NMVw== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=Mu37kVnlq3+Hd0fJMTsWPv7Jn1l2yyv7KtkgJjp6EIk=; b=iVTRF6TNx57tkuhvYtFnUuKtOZWeJLATwJOdEmsrhCWjHWU2p6wJq34HXtCmiOfVGV GNY9gyHTsAqLmexGU/Pue7iz4NWHQXkpZYWSeje+4WQcCWlsg3VNJNMff0AHoTSVs7k/ VISTP37iDflKLSxb/SfL/EMTKJs+zPZy+JGfzwOYEwZ4TvbEjhZQ6Nku8M2m8BElFvRw pBfN9VfPuL3+oZvd93jjbojFrarMv6fJFaw558pySZQNaGXLi/yHtKr4R34hI2klQUOP vCo2kUxoeL/T7t6+uSykELc9B3PmsFWUHZbPZOyX7aqiWB05JIxg53lw5qyhnt28hBmk mHEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=lezDPN2a; 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 s7-20020a056402520700b0042600b03337si6010585edd.469.2022.04.29.03.46.00; Fri, 29 Apr 2022 03:46:01 -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=lezDPN2a; 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 3858A68B272; Fri, 29 Apr 2022 13:45:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D67D368B2BB for ; Fri, 29 Apr 2022 13:45:26 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651229132; x=1682765132; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e9C1vP8NgnnNfZQzDyHeYAxB8Utt9cASHFgTPUHzycs=; b=lezDPN2aVeIUEnFRCX9PeE3PRT4p1V/uKGvD6fcIz0v56HPOgq0YY5aV ydoAtzn/qHfbiNgjq3rO5Uc+/pbcGXL0qt5OUH7L78mjyYZMP6FnWz8rz G3743G3KVYgLkofFZxQxD/8MqsNiCJ2NxHh+wovCL+osQIYAve6tbDU0O OYVciC1/Em6DD4wEn9cq0nShmodZxBt0Ma75BlieA3YWJutsFKOAVy5Ux B7Of/tkDwkqoJVFbb4XobneOBqalvzEQtUejDYCHnzOUq8hRyhXbQ3rTS lzC5VlOQjN2rXpBS7EM1mKGxx5fGt4E52X5LitsXRZptKakS6SqclA6AL g==; X-IronPort-AV: E=McAfee;i="6400,9594,10331"; a="329548332" X-IronPort-AV: E=Sophos;i="5.91,298,1647327600"; d="scan'208";a="329548332" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2022 03:45:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,298,1647327600"; d="scan'208";a="566080510" Received: from gtapc.iind.intel.com (HELO localhost.localdomain) ([10.190.235.42]) by fmsmga007.fm.intel.com with ESMTP; 29 Apr 2022 03:45:19 -0700 From: Tong Wu To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Apr 2022 10:45:04 +0000 Message-Id: <20220429104505.1747-4-tong1.wu@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220429104505.1747-1-tong1.wu@intel.com> References: <20220429104505.1747-1-tong1.wu@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 4/5] avutil/hwcontext_qsv: map QSV frames to D3D11VA frames 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: Tong Wu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: eNqQd0W/YCVz When input is a rawvideo, after mapping QSV frames to D3D11VA frames, the output will have green frames. Now fix it. Fixes: $ ffmpeg.exe -y -init_hw_device d3d11va=d3d11 \ -init_hw_device qsv=qsv@d3d11 -s:v WxH -pix_fmt nv12 -i input.yuv \ -vf "format=nv12,hwupload=extra_hw_frames=16,\ hwmap=derive_device=d3d11va,format=d3d11,hwdownload,format=nv12" \ -f rawvideo output.yuv Signed-off-by: Tong Wu --- libavutil/hwcontext_qsv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index d9d05e936a..6bc920ef59 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -915,7 +915,7 @@ static int qsv_map_from(AVHWFramesContext *ctx, if (child_frames_ctx->device_ctx->type == AV_HWDEVICE_TYPE_D3D11VA) { mfxHDLPair *pair = (mfxHDLPair*)surf->Data.MemId; dst->data[0] = pair->first; - dst->data[1] = pair->second; + dst->data[1] = pair->second == (mfxMemId)MFX_INFINITE ? (uint8_t *)0 : pair->second; } else { dst->data[3] = child_data; } @@ -945,7 +945,7 @@ static int qsv_map_from(AVHWFramesContext *ctx, if (child_frames_ctx->device_ctx->type == AV_HWDEVICE_TYPE_D3D11VA) { mfxHDLPair *pair = (mfxHDLPair*)surf->Data.MemId; dummy->data[0] = pair->first; - dummy->data[1] = pair->second; + dummy->data[1] = pair->second == (mfxMemId)MFX_INFINITE ? (uint8_t *)0 : pair->second; } else { dummy->data[3] = child_data; } From patchwork Fri Apr 29 10:45:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Tong1" X-Patchwork-Id: 35507 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp212342pzb; Fri, 29 Apr 2022 03:46:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWubf5oep1HkEmznCTZid5mThclG1+BfNPDdl0EpTQnQa0oN+qr7hBqyNbb6rhM7OWynxr X-Received: by 2002:a50:9985:0:b0:425:c2dd:4cf7 with SMTP id m5-20020a509985000000b00425c2dd4cf7mr37164263edb.19.1651229171417; Fri, 29 Apr 2022 03:46:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651229171; cv=none; d=google.com; s=arc-20160816; b=UhEcIrFuiNJklx86h6+SDCXJdJPqeGL/1oZJoL8xox6yL5wemeYA8z36KZf5YFmcH6 Wy2bg5dAseakwLt+HcXQuFhx9gFYwi9QsjjeiLgPLX7atp8pCsvCwNBfJ8Me0myAaTYG WOHflIHc66iqLgoY9I1qat2wsCpGa95SRXJBmIshF0ucERQX0PN9ccNuV7yGMMFu20lU TCfgw9iiGug+TIBkUJ4KFgq+h8jWzXKg+wl5IVjxNzTHpJCEz7auWJDDyJytYxXT85ED LsTYyHKEQjR1RXpB2DYWuOlrowZp1inm4bzvVn+nmiEELr6e9sck9+cI7YUcaMUdVRkZ Ls9w== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=cQcCXzDIglX8x/xNDJ27/hwkcX6J1oYtJ3pePER4GeU=; b=gGJI3Z6w3ogDRavn08vwUd3LBN1PfMuXaXc1iE4bDIO5jL5O46wKburzc9ITVYUnpl dxefBryNM8ZDysyisMil9KSS1RA2WkNTE+VhpggxxYkjSzpoyIrbBFmcO+TM2B4wsBBV 7rLJ+afsDV2hfVZrD6l3EiGyA4iaiQwrPkzEmF/Xhbh/3exCxC3Atm76ifxprKukreUI QMy9AJ+vhSp8xzl8XpVBCgc/yX2tm8ox8ENjjvk3CugLEXuFWVyQbCykqEueIr23lvzG /nPkw2do3WLhLg6rz92IC6sgt5thqyoPH6xCs34bQmdvHucqk1ec8O9oEk+tN9RlncPq FUyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=eoMWLTd0; 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 ta23-20020a1709078c1700b006f3aac86a91si5359002ejc.674.2022.04.29.03.46.11; Fri, 29 Apr 2022 03:46:11 -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=eoMWLTd0; 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 39FF968B30C; Fri, 29 Apr 2022 13:45:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7FDE068B272 for ; Fri, 29 Apr 2022 13:45:28 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651229133; x=1682765133; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hPm7cRHyyVal2zjMWPwuMciP5ZtBx/Kb7mLykG7HOgg=; b=eoMWLTd0SzFKmu9y0sbz+Ek4MABrIMW2N/y2DG4IU07MVJW8KJSiur52 S6NHzOdXJ6Twkb9CWZBOlW3JcTnCHZLeRIyN626FTh2iRvtLLFSMRfInH vcrsnen34CSsWh6dNoW56WERuKppGlJPg6vP0Bbc5XTqdI2cCjenXrwLE PA1v75E0qG0oI4SHCuxAe+9TB4cqgQZaGGKTqipXvQIvcnCFaR/VjQdzX 85Rq+0S+8tS6KYXrjIo8vPbwe+ADgBkXlagD16UlUvC2uFHbqPk/p6mEU CVJ3h7q3S39fI2sxUBjzZ9Vt2khc2QVs843/WhaqjL1046WljBiTIKVBS w==; X-IronPort-AV: E=McAfee;i="6400,9594,10331"; a="329548335" X-IronPort-AV: E=Sophos;i="5.91,298,1647327600"; d="scan'208";a="329548335" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2022 03:45:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,298,1647327600"; d="scan'208";a="566080525" Received: from gtapc.iind.intel.com (HELO localhost.localdomain) ([10.190.235.42]) by fmsmga007.fm.intel.com with ESMTP; 29 Apr 2022 03:45:21 -0700 From: Tong Wu To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Apr 2022 10:45:05 +0000 Message-Id: <20220429104505.1747-5-tong1.wu@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220429104505.1747-1-tong1.wu@intel.com> References: <20220429104505.1747-1-tong1.wu@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 5/5] avutil/hwcontext_qsv: map D3D11VA frames to QSV frames 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: Tong Wu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: wY8Dk4n5bXKL Fixes: $ ffmpeg.exe -init_hw_device d3d11va=d3d11 -f lavfi -i yuvtestsrc -vf "format=nv12,hwupload=extra_hw_frames=16,hwmap=derive_device=qsv,format=qsv ,hwdownload,format=nv12" -f null - Signed-off-by: Tong Wu --- libavutil/hwcontext_qsv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 6bc920ef59..1bdffee4a4 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -1363,7 +1363,8 @@ static int qsv_map_to(AVHWFramesContext *dst_ctx, { mfxHDLPair *pair = (mfxHDLPair*)hwctx->surfaces[i].Data.MemId; if (pair->first == src->data[0] - && pair->second == src->data[1]) { + && (pair->second == src->data[1] + || (pair->second == (mfxMemId)MFX_INFINITE && src->data[1] == (uint8_t *)0))) { index = i; break; }