From patchwork Tue Aug 16 05:02:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 37304 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3d0d:b0:8d:a68e:8a0e with SMTP id y13csp1659895pzi; Mon, 15 Aug 2022 22:03:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR7oQPKaVckXlSM3TnfnQTEzSnT9Mnf3VK1oOM2Y1OWVonaybj+zkmMgOhOYwcSEDMrdXUQJ X-Received: by 2002:a17:906:8445:b0:730:ba5a:ef59 with SMTP id e5-20020a170906844500b00730ba5aef59mr12829156ejy.182.1660626201717; Mon, 15 Aug 2022 22:03:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660626201; cv=none; d=google.com; s=arc-20160816; b=f27f2lkFZqHhJIlccsCbklojU5Gf56sbFgWF18wuK+N4Llld8BJzPx8jAPl1HmvmPr xdnmvxt/BArqGoi3lwTy1WUV50SEyCeWuioTW23+khH6rm1nshK24KSQCsrUFJwHNDCn ggVQZwakWToUDxndLkUm/c+GmHdHTE92c5wpeha1EUgAv6ECJT43TxFurlKBm07RO8v5 2fRJycdwngx7VoXwY3pxecLYXhwoL6EzFwesidXWPauerz+yekv8oyagXIHW1RGvd5KZ WbTuEJgCqEzrGl6G1TtaiTBBeVgkMWQTdqlwS1JaMaisPLUo3hNhE9obGNM2L3ekYI/c 7UeA== 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=qKNoaDoBY/zEay5JkoGVzBoSPKKzUGK/6Vx6zLC4G9U=; b=hDjBLi3MPYHucGmVA9Wo1lhAqGNg4qS5mDZ8iTxAyRPjG8wcMcZvz88SIdLv51zGBN Clb4/4fDCxDahe5uwTjq3ERAIXN/Yr0MVogb2tujyuauljK/C8bjz+DxF1uAbt9ffC5x 6Fgx4/Nj1VnERTbmg89k+bds9M9j38zC+Z6cuXVKJB/nTq9GIcAPz2/J12Z4orrTRQw0 l5hyIiDAnScMGeEYahGA2MmkpnAJfeNSvfOcqouA/mQJCisd/ypn3a991HpQqcMVwE68 GqTkItNGXGNFpuZJwl4XP+ZFYakx5DPl3IkXaaQaCTnxz3I+4+Jq4rMUIEphUKFYp0oY sJvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.s=mail header.b=J7kj9+Sd; 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 i14-20020a05640242ce00b0043d646c3ef9si10994414edc.259.2022.08.15.22.03.21; Mon, 15 Aug 2022 22:03:21 -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=J7kj9+Sd; 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 37B1468B956; Tue, 16 Aug 2022 08:03:13 +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 50F1568B43B for ; Tue, 16 Aug 2022 08:03:05 +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 039DE3F739; Tue, 16 Aug 2022 00:03:03 -0500 (CDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1660626184; bh=N72hgCTuHFvx4OJ0Fjic3RGn88YHpycrHhD+AW3PdVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J7kj9+SdqweAOD1WNPchXpvKX5xS4h4NFF2LpXuO27Wc0WeqD5A/s7r2tQshqXmbZ UFPokb3Q/6C1PPu+Hv7kbtHv1pQMx50d9KUHcYiQs6JSWwqsBym1Tc+au18NY/VoI+ 85tpMzb99Xwglsmm7fV50LdmifUZU1FlYOloKSCk2RZRmOH/yhH7E+3B/sXzX4Yv6i yd9cMXb3BGwwmzKFls6cK2/Ki6aEmSh4j1/2Z56DqI5ZRVWoEVhj8L5faUFnsMiqLV oX0ldeJyAOoxCnoRLk5Q7B493T4g7ZgBkmZUalfQQyKu9lxz9H8kCS4RWFSi4f4ZWI Dtou0yROiY8lg== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Aug 2022 22:02:54 -0700 Message-Id: <20220816050256.32149-2-philipl@overt.org> In-Reply-To: <20220816050256.32149-1-philipl@overt.org> References: <20220816050256.32149-1-philipl@overt.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] lavu/pixfmt: Add P012, Y212, Y410, and Y412 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: OTp4vjyBWpan These are the formats returned by 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 YUVA (AVUY) 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, and Y412 is a normal looking packed 4 channel format where the 12 most significant bits are used. Y410 is an annoying format that packs three 10bit channels into 32bits with 2bits of alpha. As a result, I had to define Y410 as a bitstream format, even though each pixel is byte-aligned. If it is in-fact possible to define as a normal byte-aligned format, please let me know how. As with VUYA, I have kept the formal definition of Y410 and Y412 as formats with alpha channels to maintain fidelity. The Intel folks say they prefer this and they would rather explicitly use a format defined as not having alpha than to silently drop it. The hardware decoder does at least ensure the alpha channel is set to full opacity. Signed-off-by: Philip Langdale --- libavutil/pixdesc.c | 101 ++++++++++++++++++++++++++++++- libavutil/pixfmt.h | 16 +++++ tests/ref/fate/imgutils | 8 +++ tests/ref/fate/sws-pixdesc-query | 42 +++++++++++++ 4 files changed, 166 insertions(+), 1 deletion(-) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index f7558ff8b9..0801927838 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, @@ -2532,6 +2556,81 @@ 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_Y410LE] = { + .name = "y410le", + .nb_components= 4, + .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 */ + { 0, 32, 30, 0, 2 }, /* A */ + }, + .flags = AV_PIX_FMT_FLAG_ALPHA | AV_PIX_FMT_FLAG_BITSTREAM, + }, + [AV_PIX_FMT_Y410BE] = { + .name = "y410be", + .nb_components= 4, + .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 */ + { 0, 32, 30, 0, 2 }, /* A */ + }, + .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_ALPHA | AV_PIX_FMT_FLAG_BITSTREAM, + }, + [AV_PIX_FMT_Y412LE] = { + .name = "y412le", + .nb_components= 4, + .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 */ + { 0, 8, 6, 4, 12 }, /* A */ + }, + .flags = AV_PIX_FMT_FLAG_ALPHA, + }, + [AV_PIX_FMT_Y412BE] = { + .name = "y412be", + .nb_components= 4, + .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 */ + { 0, 8, 6, 4, 12 }, /* A */ + }, + .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_ALPHA, + }, }; static const char * const color_range_names[] = { @@ -2767,7 +2866,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 86c9bdefeb..effaac29d3 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -372,6 +372,18 @@ enum AVPixelFormat { AV_PIX_FMT_RGBAF16BE, ///< IEEE-754 half precision packed RGBA 16:16:16:16, 64bpp, RGBARGBA..., big-endian AV_PIX_FMT_RGBAF16LE, ///< IEEE-754 half precision packed RGBA 16:16:16:16, 64bpp, RGBARGBA..., little-endian + 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_Y410BE, ///< packed AVYU 4:4:4:4, 32bpp, (msb)2A 10V 10Y 10U(lsb), big-endian + AV_PIX_FMT_Y410LE, ///< packed AVYU 4:4:4:4, 32bpp, (msb)2A 10V 10Y 10U(lsb), little-endian + + AV_PIX_FMT_Y412BE, ///< packed AVYU 4:4:4:4, 48bpp, data in the high bits, zeros in the low bits, big-endian + AV_PIX_FMT_Y412LE, ///< packed AVYU 4:4:4:4, 48bpp, data in the high bits, zeros in the low bits, little-endian + 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 }; @@ -458,9 +470,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_Y410 AV_PIX_FMT_NE(Y410BE, Y410LE) +#define AV_PIX_FMT_Y412 AV_PIX_FMT_NE(Y412BE, Y412LE) #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 01c9877de5..bc12d8dad4 100644 --- a/tests/ref/fate/imgutils +++ b/tests/ref/fate/imgutils @@ -249,3 +249,11 @@ p416le planes: 2, linesizes: 128 256 0 0, plane_sizes: 6144 12288 vuya planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 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 +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 +y410be planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 +y410le planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 +y412be planes: 1, linesizes: 512 0 0 0, plane_sizes: 24576 0 0 0, plane_offsets: 0 0 0, total_size: 24576 +y412le 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 f79d99e513..04baf6a3fa 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 @@ -75,6 +77,12 @@ isNBPS: xyz12le y210be y210le + y212be + y212le + y410be + y410le + y412be + y412le yuv420p10be yuv420p10le yuv420p12be @@ -149,6 +157,7 @@ isBE: grayf32be nv20be p010be + p012be p016be p210be p216be @@ -164,6 +173,9 @@ isBE: x2rgb10be xyz12be y210be + y212be + y410be + y412be ya16be yuv420p10be yuv420p12be @@ -206,6 +218,8 @@ isYUV: nv42 p010be p010le + p012be + p012le p016be p016le p210be @@ -223,6 +237,12 @@ isYUV: xyz12le y210be y210le + y212be + y212le + y410be + y410le + y412be + y412le ya16be ya16le ya8 @@ -309,6 +329,8 @@ isPlanarYUV: nv42 p010be p010le + p012be + p012le p016be p016le p210be @@ -400,6 +422,8 @@ isSemiPlanarYUV: nv42 p010be p010le + p012be + p012le p016be p016le p210be @@ -665,6 +689,10 @@ ALPHA: rgbaf16be rgbaf16le vuya + y410be + y410le + y412be + y412le ya16be ya16le ya8 @@ -761,6 +789,12 @@ Packed: xyz12le y210be y210le + y212be + y212le + y410be + y410le + y412be + y412le ya16be ya16le ya8 @@ -799,6 +833,8 @@ Planar: nv42 p010be p010le + p012be + p012le p016be p016le p210be @@ -971,6 +1007,8 @@ usePal: DataInHighBits: p010be p010le + p012be + p012le p210be p210le p410be @@ -979,6 +1017,10 @@ DataInHighBits: xyz12le y210be y210le + y212be + y212le + y412be + y412le SwappedChroma: nv21 From patchwork Tue Aug 16 05:02:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 37305 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3d0d:b0:8d:a68e:8a0e with SMTP id y13csp1659958pzi; Mon, 15 Aug 2022 22:03:30 -0700 (PDT) X-Google-Smtp-Source: AA6agR4dripyKNJow+9Jz/S4WD6a2MMX0V37gFsN4oz58C+iEXs8Y0cFShXJGoZBz6+YryjamWbJ X-Received: by 2002:aa7:c7da:0:b0:440:d482:36b5 with SMTP id o26-20020aa7c7da000000b00440d48236b5mr17526057eds.21.1660626210066; Mon, 15 Aug 2022 22:03:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660626210; cv=none; d=google.com; s=arc-20160816; b=Kng6g0xH+1MRZIGD5d1n82ubyxuUPsEkbTBjDhhbOfTWRFWeVNyowdKGPFzUF6CAdn PtEPd+WKmVlYoZCLcV0KXnT7a5XieonVaEWy6X3k0JG9AWh6n4M4x8klRWUWWLsLVFSU audNmJ3Ly2FXxBn7dGW/B0mNwqpyDFgdvli4L/zW9HFoL3sHO+e3g0+dmC4evRqTh1H+ oy8yA/CO3obsJna4dmYLH+lTo6qNlVvaGGg6+YiNKhlhPjqJ1BXIQI0saRuj1Wen+6rQ 91BCBOK10mkE5HIgnM1JNIWS+MswW6Qcz7Redi75vK2d1xWCovkh2BztpRlwQDpljd5p Nlmg== 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=UbO4G3uTge6NjaMIf8yzs7rmobGdSjIlrS3uIm3U2D8=; b=dpLSI9TBnWS2O8Fd5UQY1TR90fXJJ41sh4RY17s3Sj0CYol8fAtVCEKv5hmFEmLCak X5elkR8nbgOF1kcwjiFWy/9MZeMN3Wh35k0Vhj/WQf2Soc1sS1+ova179FYpHVkPgKmQ UR+sUNEj46/8I8bQo2EXlw0CWl+ucLteByEeoaQNnMS7KEX5Swuxb9Fz11v8mrc/4nBr 96+AiPHGg/2i7X3F3HBn5L7Zd9jHniXAg9ec5ZtIYDFZqz/yk+3LehOTpHV35oClnIpP ZURBhw9BfU228k1JMWBPL60YBu5ufnVJv5cQfDpWqN1JAzobpdFaPUJKb00E6RkhzOim A6LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.s=mail header.b=XiAXIQBc; 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 b7-20020a056402084700b0043a6e795a19si12137435edz.517.2022.08.15.22.03.29; Mon, 15 Aug 2022 22:03:30 -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=XiAXIQBc; 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 39A6668B964; Tue, 16 Aug 2022 08:03:14 +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 D45AD68B6B9 for ; Tue, 16 Aug 2022 08:03:05 +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 889BA3F86B; Tue, 16 Aug 2022 00:03:04 -0500 (CDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1660626184; bh=8RIBlraH146rLsfSq3rhXWyQt79So97K0anry6678lM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XiAXIQBcP2OlLbDn4UPRPwrUojp8CkJoru3CXxLv2uOWaob7GetP9ft7/1INQs1/j nXhMw5SfsUSmdMzxflJDFOqdJ5wptTwp2jPpMTcyGdr8jt+fBP9LOvWs6Dh0n8wT6j J0XOoX0k59/jAHTQ0aKMyW6xewoUkwKdLPox2bDUWEa56yMnH1hILqD3hWexlPYR98 58Hf5pbvexen3rpxy22ds3xQNT7KiRzIKiIOBBTBK0HncGxxjC4DpyI3wOsnWVYt4X mT1TzkvdcVwjtMRfqGSFubXikRZ+6wju9HqAt4z5XD8DqRoLiar6FEcEa34UWW8fi0 UaqhLsyh9bdUA== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Aug 2022 22:02:55 -0700 Message-Id: <20220816050256.32149-3-philipl@overt.org> In-Reply-To: <20220816050256.32149-1-philipl@overt.org> References: <20220816050256.32149-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: mHl4YTY1yhNy 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. I had to tweak the format matching logic slightly to account for the reduced size alpha channel in Y410, as we can't assume all channels are the same depth as the first channel. Signed-off-by: Philip Langdale --- libavcodec/hevcdec.c | 8 ++++++++ libavcodec/vaapi_decode.c | 13 +++++++++++++ libavcodec/vaapi_encode.c | 8 +++++++- libavcodec/vaapi_encode_h265.c | 6 +++++- libavcodec/vaapi_encode_vp9.c | 4 +++- libavcodec/vaapi_hevc.c | 11 ++++++++++- libavcodec/vp9.c | 2 ++ libavutil/hwcontext_vaapi.c | 12 ++++++++++++ 8 files changed, 60 insertions(+), 4 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index f1be8af2cd..1a895800a6 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 bc2d3ed803..8c6fd45f3d 100644 --- a/libavcodec/vaapi_decode.c +++ b/libavcodec/vaapi_decode.c @@ -262,16 +262,28 @@ 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), // 4:4:4 MAP(444P, YUV444P), MAP(AYUV, VUYA), +#ifdef VA_FOURCC_Y410 + MAP(Y410, Y410), +#endif +#ifdef VA_FOURCC_Y412 + MAP(Y412, Y412), +#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 @@ -415,6 +427,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 f13daa5cff..e45ba1938a 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, 4, 0, 0 }, + { "YUV444_12", VA_RT_FORMAT_YUV444_12, 12, 4, 0, 0 }, #endif { "YUV444", VA_RT_FORMAT_YUV444, 8, 3, 0, 0 }, { "AYUV", VA_RT_FORMAT_YUV444, 8, 4, 0, 0 }, @@ -1365,7 +1369,9 @@ static av_cold int vaapi_encode_profile_entrypoint(AVCodecContext *avctx) } depth = desc->comp[0].depth; for (i = 1; i < desc->nb_components; i++) { - if (desc->comp[i].depth != depth) { + // We do not apply this depth requirement to the fourth component as + // that will be the alpha channel when present, which can be smaller. + if (i < 3 && desc->comp[i].depth != depth) { av_log(avctx, AV_LOG_ERROR, "Invalid input pixfmt (%s).\n", desc->name); return AVERROR(EINVAL); diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 1de323af78..c2e91a8449 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -1276,10 +1276,14 @@ 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 }, - // Four channels because this uses the AYUV format which has Alpha + { FF_PROFILE_HEVC_REXT, 12, 3, 1, 0, VAProfileHEVCMain422_12 }, + // Four channels because these use formats which have Alpha { FF_PROFILE_HEVC_REXT, 8, 4, 0, 0, VAProfileHEVCMain444 }, + { FF_PROFILE_HEVC_REXT, 10, 4, 0, 0, VAProfileHEVCMain444_10 }, + { FF_PROFILE_HEVC_REXT, 12, 4, 0, 0, VAProfileHEVCMain444_12 }, #endif { FF_PROFILE_UNKNOWN } }; diff --git a/libavcodec/vaapi_encode_vp9.c b/libavcodec/vaapi_encode_vp9.c index 9b455e10c9..e6c7f01f11 100644 --- a/libavcodec/vaapi_encode_vp9.c +++ b/libavcodec/vaapi_encode_vp9.c @@ -228,9 +228,11 @@ static av_cold int vaapi_encode_vp9_configure(AVCodecContext *avctx) static const VAAPIEncodeProfile vaapi_encode_vp9_profiles[] = { { FF_PROFILE_VP9_0, 8, 3, 1, 1, VAProfileVP9Profile0 }, - // Four channels because this uses the AYUV format which has Alpha + // Four channels because this uses a format which has Alpha { FF_PROFILE_VP9_1, 8, 4, 0, 0, VAProfileVP9Profile1 }, { FF_PROFILE_VP9_2, 10, 3, 1, 1, VAProfileVP9Profile2 }, + // Four channels because this uses a format which has Alpha + { FF_PROFILE_VP9_3, 10, 4, 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 2ee5145727..6c057aa5fd 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), @@ -129,6 +132,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), @@ -143,6 +149,12 @@ static const VAAPIFormatDescriptor vaapi_format_map[] = { #ifdef VA_FOURCC_X2R10G10B10 MAP(X2R10G10B10, RGB32_10, X2RGB10, 0), #endif +#ifdef VA_FOURCC_Y410 + MAP(Y410, YUV444_10, Y410, 0), +#endif +#ifdef VA_FOURCC_Y412 + MAP(Y412, YUV444_12, Y412, 0), +#endif }; #undef MAP From patchwork Tue Aug 16 05:02:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 37306 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3d0d:b0:8d:a68e:8a0e with SMTP id y13csp1660003pzi; Mon, 15 Aug 2022 22:03:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR5hTqrE0NMfmxqZNYz1NBGBRHOnfmamAgq3Yof5K3pBT7GCK1oLCDYp3vq8Kchh4ga45Rba X-Received: by 2002:a17:906:5a5a:b0:730:ba28:292c with SMTP id my26-20020a1709065a5a00b00730ba28292cmr12142889ejc.312.1660626218273; Mon, 15 Aug 2022 22:03:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660626218; cv=none; d=google.com; s=arc-20160816; b=kGZgGMoCOR2CxCx/xWwk4SUSohITBWrvMn6urgkal8fXbt6C/r5rAKUYiTj1crl9dB S25Lh4yEzZhS170bO/1BhOVFPwZ6MKB/ytkXj3DTdbPvMZVryHd32Ye0o0eciNA904ed 8T4TAN9SFyw7pioqoGmffuDcZwLhpmDe9msKkz+wo8QsHu1vD5l0Ds2aPd/gglCVRmx/ aj0AgIh+KcJmkIJ3/+aq1AJY1VePOnz5xPSNQowroj3do3/H/acyL926gVylWGRK2Pod GdHmb272g/R83VH+2dQnu9MLn36TYTgez2czyywTaQbW12dRCcLAL8MwxCrLE7SDjDJ5 FRUg== 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=n5whyEliXPEZ6jsQDRYdH6wylOvrAVG/SgYFc9sa7T0=; b=FIPxjNzCscaevqbVPvme/T2qwm7R3SHwg27yaw6pEovFuLajR3lEiFdTmVMgETz5f5 pJburEiRQdkBr2M0lh8rWDxcNS0no6ETOjCZnuKlEfXL5nILGnuKPRXx90A5wEAt6FGT MT+iX6Aj97vhT4jrun+qvHs/UKFSAo0uqt4njPEMrcIGxH1UTeXQirw28iAT32JgxTXt 5T8JTp6Q+oUY/oDjGLNT2xbl6aljFfKWRMcD+8ldT50F40fvizhFchjeAL9eJE4lhmXv UZVDDZLe5Zvhprj5svMZ+t+2wdhTFiKn5bROFLjoe0E3yG1PFQyUbGnBFmGr2jJ9LZCJ khhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.s=mail header.b=jNY4NKY+; 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 j8-20020aa7c408000000b0043defd3bd70si8445751edq.329.2022.08.15.22.03.37; Mon, 15 Aug 2022 22:03:38 -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=jNY4NKY+; 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 32A4E68B96C; Tue, 16 Aug 2022 08:03:15 +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 6242668B6B9 for ; Tue, 16 Aug 2022 08:03:06 +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 150373F89A; Tue, 16 Aug 2022 00:03:05 -0500 (CDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1660626185; bh=9VDyuZdBvWCQgru0tFwo5FjKCYaie53OVhhgkOoV0pg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jNY4NKY+z9rxClvuS+C7V5hEQHAZ2smt0SA4KfdwQDgHuX/wunLcsS6PGJb0xArx0 OZujzOE5jru7NYpY436hX1phxpZlaSz0R+RwzaGFEfW9E8fDB4LeJnUz2SlsSi4ObS fylDCUZuTZ6ifQ41h966SrDowfPsX0EtjfLlL5GvFarT39ot8P1uUVTmwQ0ucl/UVj ruO8Yw5q2Q+YTym1PSut1m7EaHlPoSJhdEB8epML0NiJHbDNERdyERt7SqwePOh7RG uTEG7wtwwxgXmSdGbr3q3c4Stvv89COuWf/jiQxf8UbU8mXrvCRe5D05aWN+i3uZLK ddciyZG1nR5JQ== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Mon, 15 Aug 2022 22:02:56 -0700 Message-Id: <20220816050256.32149-4-philipl@overt.org> In-Reply-To: <20220816050256.32149-1-philipl@overt.org> References: <20220816050256.32149-1-philipl@overt.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] lavu/hwcontext_[vaapi|vulkan]: support mapping VUYA, P012, and Y412 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: GLn+Qbmy5eai These two of the Microsoft formats used by Intel VAAPI are sufficiently conventional that we can add simple mappings for them in the hwcontexts to enable back and forth mapping so that Vulkan filters can be used with vaapi decoding/encoding of these formats. Note that as with P010, we have to map to full 16bit Vulkan formats and so technically lose some information with P012 and Y412. The most significant consequence of this is that when mapping form Vulkan back to VAAPI, the underlying DRM format will actually be Y416 and so we need a mapping entry for it, even though we haven't added that as a pixel format. Signed-off-by: Philip Langdale --- libavutil/hwcontext_vaapi.c | 9 +++++++++ libavutil/hwcontext_vulkan.c | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 6c057aa5fd..15fea62a34 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -1010,6 +1010,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), @@ -1021,6 +1024,12 @@ static const struct { #endif DRM_MAP(ARGB, 1, DRM_FORMAT_BGRA8888), DRM_MAP(XRGB, 1, DRM_FORMAT_BGRX8888), +#ifdef VA_FOURCC_AYUV + DRM_MAP(AYUV, 1, DRM_FORMAT_AYUV), +#endif +#ifdef VA_FOURCC_Y412 + DRM_MAP(Y412, 1, DRM_FORMAT_Y412), +#endif }; #undef DRM_MAP diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index 237caa4bc0..62db2633fa 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_VUYA, { VK_FORMAT_R8G8B8A8_UNORM } }, + { AV_PIX_FMT_Y412, { 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_AYUV, VK_FORMAT_R8G8B8A8_UNORM }, + { DRM_FORMAT_Y412, VK_FORMAT_R16G16B16A16_UNORM }, + // As we had to map Y412 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)