From patchwork Fri Jul 8 21:51:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dpeeters@MRU.MEDICAL.CANON X-Patchwork-Id: 36708 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1916:b0:8b:804:ebe9 with SMTP id bv22csp296596pzb; Fri, 8 Jul 2022 14:51:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uLaoj6J/8EY+hZh/A2oQhzwH4+vEQp95cl0J1WxIRtTgyZOjR9icuLIyjQOWzZY6n/zhcg X-Received: by 2002:a05:6402:2804:b0:439:83c2:8be2 with SMTP id h4-20020a056402280400b0043983c28be2mr7477276ede.292.1657317087616; Fri, 08 Jul 2022 14:51:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657317087; cv=none; d=google.com; s=arc-20160816; b=0WdTa0rde24/6hK1fapZ71j/W5cAF7Yu25h7dY7Z3ww7KmT9W4dcv1dMgqeaYAonSp 1ezTJ78J/k7r8/5e4iSFLdCXs2F/VPWybJP74VRVEd+He5W7+dwTXFm1JtVWZxX48bS6 A73LkxIacC1pCbLEhKEWW1NBxa7Nc+11j+q2yUx1x20oq8lyUJ6Ie10p54dNfjYZvfvC bsAOd1pBVTPumRMJn7ZStQrnAMeVaO+oF/tjYHhWJjZavur1pxVl+KCfvQRBZviW2B/F JD1fJElTEi0jWd1vhOGkzhDFYslLOq8uXciieoYd9gxiD0fkmgVFGbP+iGtsrorLUOo7 g0Ng== 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:content-language:accept-language :message-id:date:thread-index:thread-topic:to:from:dkim-signature :delivered-to; bh=bc256vOggNLRqsgfHpz1LUxI4rU2h6Q9Euri1wysmhE=; b=KlNjDxqbQPgHRuABCHeG7yhRAzbERjzAHuuGr9UGTdMNe5p48Way4mVtlbZhrFbI52 1vkGo+QXI1fN8d0M9aChrWn3qKnNc5ooT3clIXUEu3LGQtcr8Oi90GjRAZq+zKgDrM2f PDTRMl/sPiWHBOm79WH61cPPdtsaWoNs+m5uo/8hsW39p4ibAjUrEFAX8d8SuUgvuwdM RxBatiX2ezXJx/094dyzWsMogahcgnZzMmx47XlFSVyHzZvKdFhAIidsxkVTtsja0Mhk MARVcgcJIsuj9Z4qRMmKCgKK9f12v5gtf77xc6usesR93D7Bq13asqsXQ3rf97q2gVbW jmyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mru.medical.canon header.s=mru.medical.canon.01.04.2021 header.b="QvCTi8/j"; 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 u18-20020a1709067d1200b007121245807esi36327364ejo.708.2022.07.08.14.51.26; Fri, 08 Jul 2022 14:51:27 -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=@mru.medical.canon header.s=mru.medical.canon.01.04.2021 header.b="QvCTi8/j"; 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 E53D168B908; Sat, 9 Jul 2022 00:51:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mx0a-0060ff01.pphosted.com (mx0a-0060ff01.pphosted.com [205.220.162.71]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F0A4468B7DC for ; Sat, 9 Jul 2022 00:51:16 +0300 (EEST) Received: from pps.filterd (m0240442.ppops.net [127.0.0.1]) by mx0b-0060ff01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 268LleNS007350 for ; Fri, 8 Jul 2022 16:51:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mru.medical.canon; h=from : to : subject : date : message-id : content-type : content-transfer-encoding : mime-version; s=mru.medical.canon.01.04.2021; bh=C8WRtKdohkCrT15FW2OaHrXbmRc/bcdEvA4Vh1H800s=; b=QvCTi8/jHngrQqrdWKlGHTwqwV7AzoPkquve0wAQUBXrzBLuxRud0+PUgTAbXdnojKHE BagmakXGuh+e3or2tyjhKlJPLOzu0QkY7FcDxKj8VczcKHPh1o2MJNFpzFBhnCF/v8lg LHwV8z9ZmezPoq9L3gz0a1IEX5Y73M5yqCjd5yboV8zNmwzYvJGq+rVUIl4MY424TMXW diFLIAqcXwQXlZTW1yGeD79WC+l5AYoPKrj05vgiGMKi7n3cl/AeyNmAUUaTPbGWHBkF 62OzeiGwKahe5oUWALqZKCLDUFAqx8pPA1dxo+NAZTHBdZqambHBGL2DRGziog4v9pdx ow== Received: from chiexc3.tmriusa.com (dns1.vancepublishing.com [199.48.74.5] (may be forged)) by mx0b-0060ff01.pphosted.com (PPS) with ESMTPS id 3h4ubn8w9n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 08 Jul 2022 16:51:12 -0500 Received: from CHIEXC3.TMRIUSA.COM (172.16.2.234) by CHIEXC3.TMRIUSA.COM (172.16.2.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.9; Fri, 8 Jul 2022 16:51:08 -0500 Received: from CHIEXC3.TMRIUSA.COM ([172.16.2.234]) by CHIEXC3.TMRIUSA.COM ([172.16.2.234]) with mapi id 15.02.1118.009; Fri, 8 Jul 2022 16:51:08 -0500 From: To: Thread-Topic: [PATCH] Allow exporting of RGB and BGR images to CUDA. Thread-Index: AdiTDPLP8QxaiQmES6622Aqz0u0eDA== Date: Fri, 8 Jul 2022 21:51:08 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.30.32.109] MIME-Version: 1.0 X-CrossPremisesHeadersFilteredBySendConnector: CHIEXC3.TMRIUSA.COM X-OrganizationHeadersPreserved: CHIEXC3.TMRIUSA.COM X-Proofpoint-ORIG-GUID: azgkPXY1paRgUOe97VjMEfEJY1xv8YgI X-Proofpoint-GUID: azgkPXY1paRgUOe97VjMEfEJY1xv8YgI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-08_18,2022-07-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 adultscore=0 suspectscore=0 clxscore=1011 phishscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 mlxlogscore=829 mlxscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207080086 Subject: [FFmpeg-devel] [PATCH] Allow exporting of RGB and BGR images to CUDA. 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: ePvWKJj+Nx4U Use the step size when calculating the number of channels to allow for more than two channels per plane. This allows the use of AV_PIX_FMT_0BGR32 when using av_hwframe_transfer_data to transfer data from a Vulkan frame to a CUDA frame. Signed-off-by: David Peeters --- libavutil/hwcontext_vulkan.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index 237caa4bc0..05e8fc5268 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -2992,6 +2992,8 @@ static int vulkan_export_to_cuda(AVHWFramesContext *hwfc, const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(hwfc->sw_format); VulkanDevicePriv *p = ctx->internal->priv; FFVulkanFunctions *vk = &p->vkfn; + int max_pixsteps[4]; + int max_pixstep_comps[4]; AVHWFramesContext *cuda_fc = (AVHWFramesContext*)cuda_hwfc->data; AVHWDeviceContext *cuda_cu = cuda_fc->device_ctx; @@ -3001,6 +3003,8 @@ static int vulkan_export_to_cuda(AVHWFramesContext *hwfc, CUarray_format cufmt = desc->comp[0].depth > 8 ? CU_AD_FORMAT_UNSIGNED_INT16 : CU_AD_FORMAT_UNSIGNED_INT8; + av_image_fill_max_pixsteps(max_pixsteps, max_pixstep_comps, desc); + dst_f = (AVVkFrame *)frame->data[0]; dst_int = dst_f->internal; @@ -3023,7 +3027,9 @@ static int vulkan_export_to_cuda(AVHWFramesContext *hwfc, .arrayDesc = { .Depth = 0, .Format = cufmt, - .NumChannels = 1 + ((planes == 2) && i), + .NumChannels = desc->comp[max_pixstep_comps[i]].depth > 8 + ? max_pixsteps[i] / 2 + : max_pixsteps[i], .Flags = 0, }, .numLevels = 1,