From patchwork Fri Aug 26 02:17:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 37497 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp67954pzh; Thu, 25 Aug 2022 19:18:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR4FhHmx/9LWhvldSIZK5KW93V2MhADDOEELwQNE3B+gpj+sjinuhRv456vw+minxOxz49/h X-Received: by 2002:aa7:d993:0:b0:447:ed34:14a2 with SMTP id u19-20020aa7d993000000b00447ed3414a2mr543723eds.260.1661480289613; Thu, 25 Aug 2022 19:18:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661480289; cv=none; d=google.com; s=arc-20160816; b=XMww0Y/rJZHu7Tu7NvXJu76CJHfhpPcQ+wdF6Yz0wwLQUE7EFSzao89+4YECVytoBz OJcdq+dH/Z9nMHsMPLFZff925FMR0dbpnsj8hh1GPHwJUmKZo9C5lKadXcV9PaE/3y42 zWpJcAp3eRXfyBLPbpwAW+b8/54vXedulPncFO6+VYF1eiJ5TXv83zTLFYDvVC7DPkUS n93vc5NGoL45P7oQvnWwnkNfhddJu07W98eJ5X9UlkG6BxHdamjVOL1QyxYYoXMSYj55 uc036BH2qI0Df42J3N0IrC1Y4YwrKvfxQVXwqyd+vG1YsznWrw/ljypUQFy1bgsB5IbX 31Vg== 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=yMFCmzSVDMMN/Ff7BjaO5zuv/qyqTwTgj8o8S0YONoI=; b=jCHqdiB3k/lE8xply1iUMBNaWEuHgxVYehH9PpUp1vbP1xDW/76H6U5KNy1uxOnAxR rXr3iRnlJDz3tPUR1Cms/5OH6e+XnwGaBWeDHYblOWTyHHcuCvbgNvOTdWGIJYUbbBci TOYPIH3FMVH60H6p/Vu2Xl/sWJK3syfll1agJbWhdpCC6dslohj0b1YH0Rbz3ItrmwM+ vN6DlGU1roCMhSDw16lb81yyj/vy2UTxYWCOijDLCXS9E+yJU50gHR19Ba/2dyNgPZ1u j3Isfmm1y9jIu8ByDC/t6e25aclfsxWMx9ABgU33PW0M9mYgrjaD2SLbgPj3tp1iQvCt VGpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.s=mail header.b=V0UmNQsc; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=overt.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z5-20020a05640235c500b0043b6a4c1f1bsi666916edc.143.2022.08.25.19.18.09; Thu, 25 Aug 2022 19:18:09 -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=@overt.org header.s=mail header.b=V0UmNQsc; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=overt.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 47B6668B9BA; Fri, 26 Aug 2022 05:17:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.overt.org (mail.overt.org [157.230.92.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C067268B99E for ; Fri, 26 Aug 2022 05:17:51 +0300 (EEST) Received: from authenticated-user (mail.overt.org [157.230.92.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by mail.overt.org (Postfix) with ESMTPSA id 7ECB53F71E; Thu, 25 Aug 2022 21:17:50 -0500 (CDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1661480270; bh=PBaIUXvYuL7GBSQZXl1ly3zvdcpooeoGLFaiP8Zo6aA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V0UmNQscvGhCb8RZxC8Hghs3h+si9s60nApEJA6Aqi3RCKqGaG5Oz53DNyZClvyJ9 EcqNPNlPv5dGPgj2cwjqrihZr9GB8++pMfLTUSzfkdJyL6M8KH/KHKV5xK9Dw0lGOI pDhA09mWVDVpdw0/v06QFCY5uXOGUuFKvbHnCftNYAxudWkOUcDSYbl5ZIbgYrQGy8 bzYBQA69vG+S1hCqkXThfPyEq7YEM0yJXbjScr6WDierJ+5otMa7ij1OOopR+geG+B 6VYA2tFqF+cGsmX3m+eUI8x6kfJUbcyWFJ0K8pAo9v7FBsWYz8tjqDweFCstZStJcV CSQfHrF8IoP5g== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Aug 2022 19:17:34 -0700 Message-Id: <20220826021736.355903-2-philipl@overt.org> In-Reply-To: <20220826021736.355903-1-philipl@overt.org> References: <20220826021736.355903-1-philipl@overt.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] lavu/pixfmt: Add P012, Y212, XV30, and XV36 formats 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: Philip Langdale Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: mmhNOU2BHXcs These are the formats we want/need to use when dealing with the Intel VAAPI decoder for 12bit 4:2:0, 12bit 4:2:2, 10bit 4:4:4 and 12bit 4:4:4 respectively. As with the already supported Y210 and YUVX (XVUY) formats, they are based on formats Microsoft picked as their preferred 4:2:2 and 4:4:4 video formats, and Intel ran with it. P12 and Y212 are simply an extension of 10 bit formats to say 12 bits will be used, with 4 unused bits instead of 6. XV30, and XV36, as exotic as they sound, are variants of Y410 and Y412 where the alpha channel is left formally undefined. We prefer these over the alpha versions because the hardware cannot actually do anything with the alpha channel and respecting it is just overhead. Y412/XV46 is a normal looking packed 4 channel format where each channel is 16bits wide but only the 12msb are used (like P012). Y410/XV30 packs three 10bit channels in 32bits with 2bits of alpha, like A/X2RGB10 style formats. This annoying layout forced me to define the BE version as a bitstream format. It seems like our pixdesc infrastructure can handle the LE version being byte-defined, but not when it's reversed. If there's a better way to handle this, please let me know. Our existing X2 formats all have the 2 bits at the MSB end, but this format places them at the LSB end and that seems to be the root of the problem. Signed-off-by: Philip Langdale --- libavutil/pixdesc.c | 95 +++++++++++++++++++++++++++++++- libavutil/pixfmt.h | 16 ++++++ tests/ref/fate/imgutils | 8 +++ tests/ref/fate/sws-pixdesc-query | 38 +++++++++++++ 4 files changed, 156 insertions(+), 1 deletion(-) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 79ebfd3f16..d7c6ebfdc4 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2147,6 +2147,30 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE, }, + [AV_PIX_FMT_P012LE] = { + .name = "p012le", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 1, + .comp = { + { 0, 2, 0, 4, 12 }, /* Y */ + { 1, 4, 0, 4, 12 }, /* U */ + { 1, 4, 2, 4, 12 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR, + }, + [AV_PIX_FMT_P012BE] = { + .name = "p012be", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 1, + .comp = { + { 0, 2, 0, 4, 12 }, /* Y */ + { 1, 4, 0, 4, 12 }, /* U */ + { 1, 4, 2, 4, 12 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE, + }, [AV_PIX_FMT_P016LE] = { .name = "p016le", .nb_components = 3, @@ -2543,6 +2567,75 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA | AV_PIX_FMT_FLAG_FLOAT, }, + [AV_PIX_FMT_Y212LE] = { + .name = "y212le", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 4, 0, 4, 12 }, /* Y */ + { 0, 8, 2, 4, 12 }, /* U */ + { 0, 8, 6, 4, 12 }, /* V */ + }, + }, + [AV_PIX_FMT_Y212BE] = { + .name = "y212be", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 4, 0, 4, 12 }, /* Y */ + { 0, 8, 2, 4, 12 }, /* U */ + { 0, 8, 6, 4, 12 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_BE, + }, + [AV_PIX_FMT_XV30LE] = { + .name = "xv30le", + .nb_components= 3, + .log2_chroma_w= 0, + .log2_chroma_h= 0, + .comp = { + { 0, 4, 1, 2, 10 }, /* Y */ + { 0, 4, 0, 0, 10 }, /* U */ + { 0, 4, 2, 4, 10 }, /* V */ + }, + }, + [AV_PIX_FMT_XV30BE] = { + .name = "xv30be", + .nb_components= 3, + .log2_chroma_w= 0, + .log2_chroma_h= 0, + .comp = { + { 0, 32, 10, 0, 10 }, /* Y */ + { 0, 32, 0, 0, 10 }, /* U */ + { 0, 32, 20, 0, 10 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_BITSTREAM, + }, + [AV_PIX_FMT_XV36LE] = { + .name = "xv36le", + .nb_components= 3, + .log2_chroma_w= 0, + .log2_chroma_h= 0, + .comp = { + { 0, 8, 2, 4, 12 }, /* Y */ + { 0, 8, 0, 4, 12 }, /* U */ + { 0, 8, 4, 4, 12 }, /* V */ + }, + }, + [AV_PIX_FMT_XV36BE] = { + .name = "xv36be", + .nb_components= 3, + .log2_chroma_w= 0, + .log2_chroma_h= 0, + .comp = { + { 0, 8, 2, 4, 12 }, /* Y */ + { 0, 8, 0, 4, 12 }, /* U */ + { 0, 8, 4, 4, 12 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_BE, + }, }; static const char * const color_range_names[] = { @@ -2778,7 +2871,7 @@ void ff_check_pixfmt_descriptors(void){ if (!d->name && !d->nb_components && !d->log2_chroma_w && !d->log2_chroma_h && !d->flags) continue; -// av_log(NULL, AV_LOG_DEBUG, "Checking: %s\n", d->name); + av_log(NULL, AV_LOG_INFO, "Checking: %s\n", d->name); av_assert0(d->log2_chroma_w <= 3); av_assert0(d->log2_chroma_h <= 3); av_assert0(d->nb_components <= 4); diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 7d45561395..a1c4c9fb75 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -374,6 +374,18 @@ enum AVPixelFormat { AV_PIX_FMT_VUYX, ///< packed VUYX 4:4:4, 32bpp, Variant of VUYA where alpha channel is left undefined + AV_PIX_FMT_P012LE, ///< like NV12, with 12bpp per component, data in the high bits, zeros in the low bits, little-endian + AV_PIX_FMT_P012BE, ///< like NV12, with 12bpp per component, data in the high bits, zeros in the low bits, big-endian + + AV_PIX_FMT_Y212BE, ///< packed YUV 4:2:2 like YUYV422, 24bpp, data in the high bits, zeros in the low bits, big-endian + AV_PIX_FMT_Y212LE, ///< packed YUV 4:2:2 like YUYV422, 24bpp, data in the high bits, zeros in the low bits, little-endian + + AV_PIX_FMT_XV30BE, ///< packed XVYU 4:4:4, 32bpp, (msb)2X 10V 10Y 10U(lsb), big-endian, variant of Y410 where alpha channel is left undefined + AV_PIX_FMT_XV30LE, ///< packed XVYU 4:4:4, 32bpp, (msb)2X 10V 10Y 10U(lsb), little-endian, variant of Y410 where alpha channel is left undefined + + AV_PIX_FMT_XV36BE, ///< packed XVYU 4:4:4, 48bpp, data in the high bits, zeros in the low bits, big-endian, variant of Y412 where alpha channel is left undefined + AV_PIX_FMT_XV36LE, ///< packed XVYU 4:4:4, 48bpp, data in the high bits, zeros in the low bits, little-endian, variant of Y412 where alpha channel is left undefined + AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; @@ -460,9 +472,13 @@ enum AVPixelFormat { #define AV_PIX_FMT_NV20 AV_PIX_FMT_NE(NV20BE, NV20LE) #define AV_PIX_FMT_AYUV64 AV_PIX_FMT_NE(AYUV64BE, AYUV64LE) #define AV_PIX_FMT_P010 AV_PIX_FMT_NE(P010BE, P010LE) +#define AV_PIX_FMT_P012 AV_PIX_FMT_NE(P012BE, P012LE) #define AV_PIX_FMT_P016 AV_PIX_FMT_NE(P016BE, P016LE) #define AV_PIX_FMT_Y210 AV_PIX_FMT_NE(Y210BE, Y210LE) +#define AV_PIX_FMT_Y212 AV_PIX_FMT_NE(Y212BE, Y212LE) +#define AV_PIX_FMT_XV30 AV_PIX_FMT_NE(XV30BE, XV30LE) +#define AV_PIX_FMT_XV36 AV_PIX_FMT_NE(XV36BE, XV36LE) #define AV_PIX_FMT_X2RGB10 AV_PIX_FMT_NE(X2RGB10BE, X2RGB10LE) #define AV_PIX_FMT_X2BGR10 AV_PIX_FMT_NE(X2BGR10BE, X2BGR10LE) diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils index 47b73b1b64..de73513e7c 100644 --- a/tests/ref/fate/imgutils +++ b/tests/ref/fate/imgutils @@ -250,3 +250,11 @@ vuya planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 rgbaf16be planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 0 0, plane_offsets: 0 0 0, total_size: 24576 rgbaf16le planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 0 0, plane_offsets: 0 0 0, total_size: 24576 vuyx planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 +p012le planes: 2, linesizes: 128 128 0 0, plane_sizes: 6144 3072 0 0, plane_offsets: 6144 0 0, total_size: 9216 +p012be planes: 2, linesizes: 128 128 0 0, plane_sizes: 6144 3072 0 0, plane_offsets: 6144 0 0, total_size: 9216 +y212be planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 +y212le planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 +xv30be planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 +xv30le planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 +xv36be planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 0 0, plane_offsets: 0 0 0, total_size: 24576 +xv36le planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 0 0, plane_offsets: 0 0 0, total_size: 24576 diff --git a/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query index f54372d364..20fc596ce9 100644 --- a/tests/ref/fate/sws-pixdesc-query +++ b/tests/ref/fate/sws-pixdesc-query @@ -63,6 +63,8 @@ isNBPS: nv20le p010be p010le + p012be + p012le p210be p210le p410be @@ -71,10 +73,16 @@ isNBPS: x2bgr10le x2rgb10be x2rgb10le + xv30be + xv30le + xv36be + xv36le xyz12be xyz12le y210be y210le + y212be + y212le yuv420p10be yuv420p10le yuv420p12be @@ -149,6 +157,7 @@ isBE: grayf32be nv20be p010be + p012be p016be p210be p216be @@ -162,8 +171,11 @@ isBE: rgbaf16be x2bgr10be x2rgb10be + xv30be + xv36be xyz12be y210be + y212be ya16be yuv420p10be yuv420p12be @@ -206,6 +218,8 @@ isYUV: nv42 p010be p010le + p012be + p012le p016be p016le p210be @@ -220,10 +234,16 @@ isYUV: uyyvyy411 vuya vuyx + xv30be + xv30le + xv36be + xv36le xyz12be xyz12le y210be y210le + y212be + y212le ya16be ya16le ya8 @@ -310,6 +330,8 @@ isPlanarYUV: nv42 p010be p010le + p012be + p012le p016be p016le p210be @@ -401,6 +423,8 @@ isSemiPlanarYUV: nv42 p010be p010le + p012be + p012le p016be p016le p210be @@ -759,10 +783,16 @@ Packed: x2bgr10le x2rgb10be x2rgb10le + xv30be + xv30le + xv36be + xv36le xyz12be xyz12le y210be y210le + y212be + y212le ya16be ya16le ya8 @@ -801,6 +831,8 @@ Planar: nv42 p010be p010le + p012be + p012le p016be p016le p210be @@ -973,14 +1005,20 @@ usePal: DataInHighBits: p010be p010le + p012be + p012le p210be p210le p410be p410le + xv36be + xv36le xyz12be xyz12le y210be y210le + y212be + y212le SwappedChroma: nv21 From patchwork Fri Aug 26 02:17:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 37498 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp67996pzh; Thu, 25 Aug 2022 19:18:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR635f24StUz/u6rTnKl22oraBC9bmllScrp+S0o2ULvXsz/Iy7H7UAKKOve2rm/tpB0u3RW X-Received: by 2002:a05:6402:4449:b0:445:cdb6:2de9 with SMTP id o9-20020a056402444900b00445cdb62de9mr5189886edb.59.1661480298211; Thu, 25 Aug 2022 19:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661480298; cv=none; d=google.com; s=arc-20160816; b=Dbd8Lxz7E+AubK90I0oBmW+aZnhgEfKseh0dLGj3tfbE787QYcO+ITqE6fJsjE4/ju Z/sNl8XPXc4qZnmP1c9lJM86cXrpRGHeBRBmBgO075Y6wMuUqwSbgs1NzUp5JxWfTtRz lRrRNhOkUSrQZoP2UlwZcWAv9NMkD/p2HoyGY3GIERbz+yHp6huuzfKYwJj/8+mE5JzW /Gq9jGBZemHr9HQr6tslTZVgWBglfN4BWQXWhU+pWxG4QCrxYreIMWps8dd/fT/2aGmY Xv3OzaPeRJ6dRDMcKz5CCuPhXaGWaHXODM21vE0utPjooOOy4Lx+a+CnJLMt3y/tSfEl Tw+A== 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=+Eh2C2CcahDAuNXQpYonDCi6YTeaGWzIwH6kWpaJ4so=; b=0EiolbkP1OTzd5cLU/bjtEfAf1SmL5hZ0IyS2XvTmkLA+B7l1orX3KR8y3GKG+Iw7M +6E2vrq2jz4x6VwjWIayVKhT6jjEN08JSG8FbKVr9u+4fI0wpXvuZdSL7oSPe+y8hwQa rkRt4uaNg36XH1YH2axtY2WrZMQTo8F125MS3x2ko4XFJd/+Hd3zO4C1MhSkNZH0elK+ phslBwpPs1xkDPro7u41Kx1a6943j1Rm/zFgglosRGrb2GiQM7kPWHrLA1i7zT8FTKFn mYxjPeHZC05Hl46Py/3tElh15kHGLlHfzFSXscy9hXnoV7y0SK+00hP4KzOmOTsG0B8e YtHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.s=mail header.b=KhIKoIbb; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=overt.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t1-20020a170906178100b0073d5dd95a2csi417169eje.429.2022.08.25.19.18.17; Thu, 25 Aug 2022 19:18: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=@overt.org header.s=mail header.b=KhIKoIbb; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=overt.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 25EFF68BA02; Fri, 26 Aug 2022 05:18:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.overt.org (mail.overt.org [157.230.92.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 55D6F68B99E for ; Fri, 26 Aug 2022 05:17:52 +0300 (EEST) Received: from authenticated-user (mail.overt.org [157.230.92.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by mail.overt.org (Postfix) with ESMTPSA id 0BF9C3F89B; Thu, 25 Aug 2022 21:17:50 -0500 (CDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1661480271; bh=+TvYtscNbK80W9htWYIKJuZVTnmGla0N4KvO0QlmSyk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KhIKoIbbDATnDudh1qZ8ou00aSeFATrJCYCKWsYcwMSg1J8SliXpSMQUXQ/lraGtJ ypobV+VuFVd6pUzLDOwKIuC0IBMGWqXvzO1oLiYUiV+FOK35czrpqpYUafvvi2xv9x lSl/NsPg+2Oj3z1qngqwkm6aJCaIUY9+iABqo9GhoO27ETv9Gbd1b56Q6e0zZUf/Qo PFH2QI+obeqT1CUvZwhm3Orb35Oq6CcV7UjcPMrB1MCe4CqMEHl20EPrMMTYLJTHS8 H3/AhUTd7lI8P/r/H4Sr9n1dN69Xctl7jB/dCzL9jLdc0EgTitXNm2HKawqIm5buHj Q3u8H9xc3s6xg== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Aug 2022 19:17:35 -0700 Message-Id: <20220826021736.355903-3-philipl@overt.org> In-Reply-To: <20220826021736.355903-1-philipl@overt.org> References: <20220826021736.355903-1-philipl@overt.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] lavc/vaapi: Add support for remaining 10/12bit profiles 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: Philip Langdale Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: lCL9HHJ1fV+Q With the necessary pixel formats defined, we can now expose support for the remaining 10/12bit combinations that VAAPI can handle. Specifically, we are adding support for: * HEVC ** 12bit 420 ** 10bit 422 ** 12bit 422 ** 10bit 444 ** 12bit 444 * VP9 ** 10bit 444 ** 12bit 444 These obviously require actual hardware support to be usable, but where that exists, it is now enabled. Note that unlike YUVA/YUVX, the Intel driver does not formally expose support for the alphaless formats XV30 and XV360, and so we are implicitly discarding the alpha from the decoder and passing undefined values for the alpha to the encoder. If a future encoder iteration was to actually do something with the alpha bits, we would need to use a formal alpha capable format or the encoder would need to explicitly accept the alphaless format. Signed-off-by: Philip Langdale --- libavcodec/hevcdec.c | 8 ++++++++ libavcodec/vaapi_decode.c | 13 +++++++++++++ libavcodec/vaapi_encode.c | 4 ++++ libavcodec/vaapi_encode_h265.c | 4 ++++ libavcodec/vaapi_encode_vp9.c | 1 + libavcodec/vaapi_hevc.c | 11 ++++++++++- libavcodec/vp9.c | 2 ++ libavutil/hwcontext_vaapi.c | 25 +++++++++++++++++++++++++ 8 files changed, 67 insertions(+), 1 deletion(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 477d6d9d36..fd23e791a4 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -481,11 +481,19 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #endif case AV_PIX_FMT_YUV420P12: case AV_PIX_FMT_YUV444P12: +#if CONFIG_HEVC_VAAPI_HWACCEL + *fmt++ = AV_PIX_FMT_VAAPI; +#endif #if CONFIG_HEVC_VDPAU_HWACCEL *fmt++ = AV_PIX_FMT_VDPAU; #endif #if CONFIG_HEVC_NVDEC_HWACCEL *fmt++ = AV_PIX_FMT_CUDA; +#endif + break; + case AV_PIX_FMT_YUV422P12: +#if CONFIG_HEVC_VAAPI_HWACCEL + *fmt++ = AV_PIX_FMT_VAAPI; #endif break; } diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c index 8c13a4f098..134f10eca5 100644 --- a/libavcodec/vaapi_decode.c +++ b/libavcodec/vaapi_decode.c @@ -262,6 +262,9 @@ static const struct { MAP(YUY2, YUYV422), #ifdef VA_FOURCC_Y210 MAP(Y210, Y210), +#endif +#ifdef VA_FOURCC_Y212 + MAP(Y212, Y212), #endif // 4:4:0 MAP(422V, YUV440P), @@ -269,11 +272,20 @@ static const struct { MAP(444P, YUV444P), #ifdef VA_FOURCC_XYUV MAP(XYUV, VUYX), +#endif +#ifdef VA_FOURCC_Y410 + MAP(Y410, XV30), +#endif +#ifdef VA_FOURCC_Y412 + MAP(Y412, XV36), #endif // 4:2:0 10-bit #ifdef VA_FOURCC_P010 MAP(P010, P010), #endif +#ifdef VA_FOURCC_P012 + MAP(P012, P012), +#endif #ifdef VA_FOURCC_I010 MAP(I010, YUV420P10), #endif @@ -417,6 +429,7 @@ static const struct { #if VA_CHECK_VERSION(0, 39, 0) MAP(VP9, VP9_1, VP9Profile1 ), MAP(VP9, VP9_2, VP9Profile2 ), + MAP(VP9, VP9_3, VP9Profile3 ), #endif #if VA_CHECK_VERSION(1, 8, 0) MAP(AV1, AV1_MAIN, AV1Profile0), diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 2dc5c96f7b..9a58661b51 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1305,7 +1305,11 @@ static const VAAPIEncodeRTFormat vaapi_encode_rt_formats[] = { { "YUV420", VA_RT_FORMAT_YUV420, 8, 3, 1, 1 }, { "YUV422", VA_RT_FORMAT_YUV422, 8, 3, 1, 0 }, #if VA_CHECK_VERSION(1, 2, 0) + { "YUV420_12", VA_RT_FORMAT_YUV420_12, 12, 3, 1, 1 }, { "YUV422_10", VA_RT_FORMAT_YUV422_10, 10, 3, 1, 0 }, + { "YUV422_12", VA_RT_FORMAT_YUV422_12, 12, 3, 1, 0 }, + { "YUV444_10", VA_RT_FORMAT_YUV444_10, 10, 3, 0, 0 }, + { "YUV444_12", VA_RT_FORMAT_YUV444_12, 12, 3, 0, 0 }, #endif { "YUV444", VA_RT_FORMAT_YUV444, 8, 3, 0, 0 }, { "XYUV", VA_RT_FORMAT_YUV444, 8, 3, 0, 0 }, diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 967d71e998..90f44acff1 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -1276,9 +1276,13 @@ static const VAAPIEncodeProfile vaapi_encode_h265_profiles[] = { { FF_PROFILE_HEVC_REXT, 10, 3, 1, 1, VAProfileHEVCMain10 }, #endif #if VA_CHECK_VERSION(1, 2, 0) + { FF_PROFILE_HEVC_REXT, 12, 3, 1, 1, VAProfileHEVCMain12 }, { FF_PROFILE_HEVC_REXT, 8, 3, 1, 0, VAProfileHEVCMain422_10 }, { FF_PROFILE_HEVC_REXT, 10, 3, 1, 0, VAProfileHEVCMain422_10 }, + { FF_PROFILE_HEVC_REXT, 12, 3, 1, 0, VAProfileHEVCMain422_12 }, { FF_PROFILE_HEVC_REXT, 8, 3, 0, 0, VAProfileHEVCMain444 }, + { FF_PROFILE_HEVC_REXT, 10, 3, 0, 0, VAProfileHEVCMain444_10 }, + { FF_PROFILE_HEVC_REXT, 12, 3, 0, 0, VAProfileHEVCMain444_12 }, #endif { FF_PROFILE_UNKNOWN } }; diff --git a/libavcodec/vaapi_encode_vp9.c b/libavcodec/vaapi_encode_vp9.c index 9530b2f462..38c167d2b6 100644 --- a/libavcodec/vaapi_encode_vp9.c +++ b/libavcodec/vaapi_encode_vp9.c @@ -230,6 +230,7 @@ static const VAAPIEncodeProfile vaapi_encode_vp9_profiles[] = { { FF_PROFILE_VP9_0, 8, 3, 1, 1, VAProfileVP9Profile0 }, { FF_PROFILE_VP9_1, 8, 3, 0, 0, VAProfileVP9Profile1 }, { FF_PROFILE_VP9_2, 10, 3, 1, 1, VAProfileVP9Profile2 }, + { FF_PROFILE_VP9_3, 10, 3, 0, 0, VAProfileVP9Profile3 }, { FF_PROFILE_UNKNOWN } }; diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c index d82975979a..20fb36adfa 100644 --- a/libavcodec/vaapi_hevc.c +++ b/libavcodec/vaapi_hevc.c @@ -567,15 +567,24 @@ VAProfile ff_vaapi_parse_hevc_rext_profile(AVCodecContext *avctx) } #if VA_CHECK_VERSION(1, 2, 0) - if (!strcmp(profile->name, "Main 4:2:2 10") || + if (!strcmp(profile->name, "Main 12") || + !strcmp(profile->name, "Main 12 Intra")) + return VAProfileHEVCMain12; + else if (!strcmp(profile->name, "Main 4:2:2 10") || !strcmp(profile->name, "Main 4:2:2 10 Intra")) return VAProfileHEVCMain422_10; + else if (!strcmp(profile->name, "Main 4:2:2 12") || + !strcmp(profile->name, "Main 4:2:2 12 Intra")) + return VAProfileHEVCMain422_12; else if (!strcmp(profile->name, "Main 4:4:4") || !strcmp(profile->name, "Main 4:4:4 Intra")) return VAProfileHEVCMain444; else if (!strcmp(profile->name, "Main 4:4:4 10") || !strcmp(profile->name, "Main 4:4:4 10 Intra")) return VAProfileHEVCMain444_10; + else if (!strcmp(profile->name, "Main 4:4:4 12") || + !strcmp(profile->name, "Main 4:4:4 12 Intra")) + return VAProfileHEVCMain444_12; #else av_log(avctx, AV_LOG_WARNING, "HEVC profile %s is " "not supported with this VA version.\n", profile->name); diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index 621627ddc5..8105956775 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -235,6 +235,8 @@ static int update_size(AVCodecContext *avctx, int w, int h) #endif break; case AV_PIX_FMT_YUV444P: + case AV_PIX_FMT_YUV444P10: + case AV_PIX_FMT_YUV444P12: #if CONFIG_VP9_VAAPI_HWACCEL *fmtp++ = AV_PIX_FMT_VAAPI; #endif diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 78205425ee..9ba5225ad2 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -121,6 +121,9 @@ static const VAAPIFormatDescriptor vaapi_format_map[] = { MAP(YUY2, YUV422, YUYV422, 0), #ifdef VA_FOURCC_Y210 MAP(Y210, YUV422_10, Y210, 0), +#endif +#ifdef VA_FOURCC_Y212 + MAP(Y212, YUV422_12, Y212, 0), #endif MAP(411P, YUV411, YUV411P, 0), MAP(422V, YUV422, YUV440P, 0), @@ -131,6 +134,9 @@ static const VAAPIFormatDescriptor vaapi_format_map[] = { MAP(Y800, YUV400, GRAY8, 0), #ifdef VA_FOURCC_P010 MAP(P010, YUV420_10BPP, P010, 0), +#endif +#ifdef VA_FOURCC_P012 + MAP(P012, YUV420_12, P012, 0), #endif MAP(BGRA, RGB32, BGRA, 0), MAP(BGRX, RGB32, BGR0, 0), @@ -145,6 +151,16 @@ static const VAAPIFormatDescriptor vaapi_format_map[] = { #ifdef VA_FOURCC_X2R10G10B10 MAP(X2R10G10B10, RGB32_10, X2RGB10, 0), #endif +#ifdef VA_FOURCC_Y410 + // libva doesn't include a fourcc for XV30 and the driver only declares + // support for Y410, so we must fudge the mapping here. + MAP(Y410, YUV444_10, XV30, 0), +#endif +#ifdef VA_FOURCC_Y412 + // libva doesn't include a fourcc for XV36 and the driver only declares + // support for Y412, so we must fudge the mapping here. + MAP(Y412, YUV444_12, XV36, 0), +#endif }; #undef MAP @@ -1000,6 +1016,9 @@ static const struct { DRM_MAP(NV12, 1, DRM_FORMAT_NV12), #if defined(VA_FOURCC_P010) && defined(DRM_FORMAT_R16) DRM_MAP(P010, 2, DRM_FORMAT_R16, DRM_FORMAT_RG1616), +#endif +#if defined(VA_FOURCC_P012) && defined(DRM_FORMAT_R16) + DRM_MAP(P012, 2, DRM_FORMAT_R16, DRM_FORMAT_RG1616), #endif DRM_MAP(BGRA, 1, DRM_FORMAT_ARGB8888), DRM_MAP(BGRX, 1, DRM_FORMAT_XRGB8888), @@ -1014,6 +1033,12 @@ static const struct { #if defined(VA_FOURCC_XYUV) && defined(DRM_FORMAT_XYUV8888) DRM_MAP(XYUV, 1, DRM_FORMAT_XYUV8888), #endif +#if defined(VA_FOURCC_Y412) && defined(DRM_FORMAT_XVYU2101010) + DRM_MAP(Y410, 1, DRM_FORMAT_XVYU2101010), +#endif +#if defined(VA_FOURCC_Y412) && defined(DRM_FORMAT_XVYU12_16161616) + DRM_MAP(Y412, 1, DRM_FORMAT_XVYU12_16161616), +#endif }; #undef DRM_MAP From patchwork Fri Aug 26 02:17:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 37499 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp68027pzh; Thu, 25 Aug 2022 19:18:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR7hL7o5fjV4MNwFMf7RFdlz2UmEXCCc8Y7W8Fo6vd6kStzQxFHOZXM+xi2s63KzA7Mzkhm3 X-Received: by 2002:a05:6402:540c:b0:434:d965:f8a with SMTP id ev12-20020a056402540c00b00434d9650f8amr5152274edb.30.1661480307061; Thu, 25 Aug 2022 19:18:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661480307; cv=none; d=google.com; s=arc-20160816; b=qeo0R9c1ZmgIByXW/ps3JIEeYA8GoGq5nAFu1SKgfoV5jFnkGyqmUAzysnsivx1YOF rcV99L7CynlVrEW3OLGXuQbxjZatXYCpZ30wfZ1TFJV2MBIblRh2hWrmcTkJ7tArKGxf OT2PP+6GEAz/4Yyu4q9PxYNnlVYlgCIq+r6A2NzlNWTBMK90MjOTsVNefv2g1sO54kKO dD0fvZfPa/yhyPuoR4dr02GzhvBtBuCfo0/gdAd7JnKeSnOenEVh6QIGQadzcMigsqHk E/IlEK0UGTd18sX0XJPgrMRHXmJZoarBH/pgsBNcPAYsmaTg27uQmLNvyme3RHP3SQJp tgsg== 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=OmTOeQVCQaKQtvfYS6emHPPtnMfUxySHq4PHD1PEOu8=; b=cpORKLJOeQGKuudxbhRp0fxoIpF+NReB+YYFtS2VTg7LhLlLqCbWpqRMXFrbo2J6Bx 4JNO6m3KJpiEASnhIyaTk4N+8/dyqfmTATW9qY/dzwfQ6ZA8opmi5aCRitNX5ETj3O9u kHHGZYE2EHiUN24jC+SKduv4tJ8sKeebie3R5yW6vscpIfUlkqrBGMeOenfx7SFZWeOG ds2Ez+oRC8vlU/XJxgNtextH9ZGCcS+t9nKyfiXu5lUGkrTU0Cbuy9RDnmY3CYz1mTGq TonUBycpyG0MRFJghZHw0dTa3ohgfeAwIIFhF1ZD7ure+qllAPzOx5/ikJvJaR++oLvU in7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.s=mail header.b=kArkf4bu; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=overt.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dy16-20020a05640231f000b0044756d7defdsi528709edb.613.2022.08.25.19.18.26; Thu, 25 Aug 2022 19:18: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=@overt.org header.s=mail header.b=kArkf4bu; 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=overt.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 272FC68BA0C; Fri, 26 Aug 2022 05:18:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.overt.org (mail.overt.org [157.230.92.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D1EE568B99E for ; Fri, 26 Aug 2022 05:17:52 +0300 (EEST) Received: from authenticated-user (mail.overt.org [157.230.92.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by mail.overt.org (Postfix) with ESMTPSA id 8F3C73F89D; Thu, 25 Aug 2022 21:17:51 -0500 (CDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1661480271; bh=goSZYLXhsxy0afTx/eBLoKIx6WoZcZ+oIGtARAFORNQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kArkf4buZ14Jx85bTK1bLMl1t7uZ8mTpGuNZQcKEV3A18uoiDG5LFz887sf42RqKj ExfIsQyTfRqRfwAFgQIRHMv0djY8/BKZY6gsGVKHgQbz7BWtb/EIOCuoPbIXWIvLmY wiMs0H7RZcUPXHiyPAQ9u0osXYKNYLVnU25U223tWUi7nSFzxUizORfWr03AyqOxft /qRSbFAd2coBwkJ3QuNhoLgVf2VTnrMmHx1F8t5HvMnx+X+qvnQt/a9Avd/SF2dbDg aZUeQGp/zQY4rTUvOrgxAA/ih8fq07X9WVjEcA+KJCjUNYrUWXgpUnYFtsH9TH/L0X zrD2HgS5eLnPA== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Aug 2022 19:17:36 -0700 Message-Id: <20220826021736.355903-4-philipl@overt.org> In-Reply-To: <20220826021736.355903-1-philipl@overt.org> References: <20220826021736.355903-1-philipl@overt.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] lavu/hwcontext_vulkan: support mapping VUYX, P012, and XV36 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: Philip Langdale Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: KtqqMmtwyytc If we want to be able to map between VAAPI and Vulkan (to do Vulkan filtering), we need to have matching formats on each side. The mappings here are not exact. In the same way that P010 is still mapped to full 16 bit formats, P012 has to be mapped that way as well. Similarly, VUYX has to be mapped to an alpha-equipped format, and XV36 has to be mapped to a fully 16bit alpha-equipped format. While Vulkan seems to fundamentally lack formats with an undefined, but physically present, alpha channel, it has have 10X6 and 12X4 formats that you could imagine using for P010, P012 and XV36, but these formats don't support the STORAGE usage flag. Today, hwcontext_vulkan requires all formats to be storable because it wants to be able to use them to create writable images. Until that changes, which might happen, we have to restrict the set of formats we use. Finally, when mapping a Vulkan image back to vaapi, I observed that the VK_FORMAT_R16G16B16A16_UNORM format we have to use for XV36 going to Vulkan is mapped to Y416 when going to vaapi (which makes sense as it's the exact matching format) so I had to add an entry for it even though we don't use it directly. Signed-off-by: Philip Langdale --- libavutil/hwcontext_vulkan.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index 237caa4bc0..cabf77db95 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -173,6 +173,7 @@ static const struct { { AV_PIX_FMT_NV12, { VK_FORMAT_R8_UNORM, VK_FORMAT_R8G8_UNORM } }, { AV_PIX_FMT_NV21, { VK_FORMAT_R8_UNORM, VK_FORMAT_R8G8_UNORM } }, { AV_PIX_FMT_P010, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16G16_UNORM } }, + { AV_PIX_FMT_P012, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16G16_UNORM } }, { AV_PIX_FMT_P016, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16G16_UNORM } }, { AV_PIX_FMT_NV16, { VK_FORMAT_R8_UNORM, VK_FORMAT_R8G8_UNORM } }, @@ -210,6 +211,9 @@ static const struct { { AV_PIX_FMT_YUVA444P12, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM } }, { AV_PIX_FMT_YUVA444P16, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM } }, + { AV_PIX_FMT_VUYX, { VK_FORMAT_R8G8B8A8_UNORM } }, + { AV_PIX_FMT_XV36, { VK_FORMAT_R16G16B16A16_UNORM } }, + { AV_PIX_FMT_BGRA, { VK_FORMAT_B8G8R8A8_UNORM } }, { AV_PIX_FMT_RGBA, { VK_FORMAT_R8G8B8A8_UNORM } }, { AV_PIX_FMT_RGB24, { VK_FORMAT_R8G8B8_UNORM } }, @@ -2629,6 +2633,12 @@ static const struct { { DRM_FORMAT_XRGB8888, VK_FORMAT_B8G8R8A8_UNORM }, { DRM_FORMAT_ABGR8888, VK_FORMAT_R8G8B8A8_UNORM }, { DRM_FORMAT_XBGR8888, VK_FORMAT_R8G8B8A8_UNORM }, + + { DRM_FORMAT_XYUV8888, VK_FORMAT_R8G8B8A8_UNORM }, + { DRM_FORMAT_XVYU12_16161616, VK_FORMAT_R16G16B16A16_UNORM} , + // As we had to map XV36 to a 16bit Vulkan format, reverse mapping will + // end up yielding Y416 as the DRM format, so we need to recognise it. + { DRM_FORMAT_Y416, VK_FORMAT_R16G16B16A16_UNORM }, }; static inline VkFormat drm_to_vulkan_fmt(uint32_t drm_fourcc)