From patchwork Sat Aug 6 03:27:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 37153 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:92a9:b0:8d:7f3b:94fc with SMTP id q41csp711147pzg; Sat, 6 Aug 2022 03:35:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR6C8J40zyKPylTGyE6+45TVBxG99q5g4rmgMwaHXbBQPOZSvuLdas/PMUq2idzFmjHaFU3Q X-Received: by 2002:a50:d0da:0:b0:43d:5f5f:32c3 with SMTP id g26-20020a50d0da000000b0043d5f5f32c3mr10311318edf.192.1659782114280; Sat, 06 Aug 2022 03:35:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659782114; cv=none; d=google.com; s=arc-20160816; b=bkluQ9uhyjh2cWG0C0BMh43Rao0ziyrBSidOTezOj1fHpGO/lsdFTXpdC6mmgThlq4 +LkE67CiCMi2/I59IzgEEUcnKi7KENrCq/Eke4cciBinyQ9JVPHZQxXHGwCGhRdBBYTT DGw3Z7CxC6mr6gyVL9g033BNnIFwHtVqY5N9GZF25QDwXJ0hCuhvgFB+UCt8+LzgEA4C aHdbVSmrSi/VrbqitNZvNvq61UvgeRNZvsDiyFacC+WSLHhW5UOmOYt2lGf/WiEM/OCo pyHJja/zITw7nYIlpAi9qUGF2cv9PbVcBGYha7729n4UxSUb4XpUlFbT2KrvzIibWgPS RQCA== 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=jovy09hif07TnSdl2nDZHDWa7336/vR0J8/V8uLJrFI=; b=SEnYZoo6i19PVeSLAkeQ4FIaycdmIvJz4JhhQ8GgseGraTmUgYoUlrPB4Z0mpNuhCA 7UHbtZfD84X4PpQUICVOiGlW+c+Xa+S2/mNOwNGq7tyLqUv0Aw9zDE+LjFZJf7RfK7Ue c9qsiTEQcD1CCT75OKY/SsAvx89jjf7kwiOPkKCFknTNnLtflBUnNQsD9V6IJDVjfPgL GVoaDxfzgZk7LAk297c0+yMzEkUV1PJjl9Eud2hJkQvcLbo+nvQ4xaLn78YBVxWmoO6y csHIik6BMniqp4gIPDvHGRqvxIZcLDDpIR559mNtDlr0sE3PLjBhThFI/c0JGgIHkBYp n5bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.s=mail header.b=fgFNmjj6; 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 r12-20020a05640251cc00b0044052e86694si1803348edd.377.2022.08.06.03.35.13; Sat, 06 Aug 2022 03:35:14 -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=fgFNmjj6; 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 78DEE68B70E; Sat, 6 Aug 2022 13:35:11 +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 0AAE868B2BC for ; Sat, 6 Aug 2022 13:35: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 4F7EA3F54C; Fri, 5 Aug 2022 22:28:02 -0500 (CDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1659756482; bh=tnuabNVpWtr3ILPPAbjlNkW1JfC8fmDw6jAjtJi15OQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fgFNmjj6+YTHzgX75M7AqjZ+KFvEoLoRpMM+SmYkmCf6mhEKa29bUN5EUlXmzDuGt uV/3JBayFqrt+xGY5kW4EDE6S+gm2HCTi44ApuN7otLAimRGxww+YeNnYY/se9lJ9R Svkwq9vWD8TPWYQw5/c4FzNUwbfGm8Wo2Zb+0wbXTMlxTveeohQXKFj+S+rTqjWG+S BaJq/qOlUd4hYv+OaBpaCIlnvDQR2mDQLecvBWmtef8FQan7Qlw3jkLDrlSvoAFoow PuMKG2gaT/3BQcLFBu8vddfxzzANbXVMSgbJw/eTUbHL5HhWjH8x14OCEAMi5Twz08 MwCvRg9OD4d+g== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Aug 2022 20:27:52 -0700 Message-Id: <20220806032754.71419-2-philipl@overt.org> In-Reply-To: <20220806032754.71419-1-philipl@overt.org> References: <20220806032754.71419-1-philipl@overt.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] lavc/vaapi_decode: add missing flag when picking best pixel format 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: gkAjBJTVDduE vaapi_decode_find_best_format currently does not set the VA_SURFACE_ATTRIB_SETTABLE flag on the pixel format attribute that it returns. Without this flag, the attribute will be ignored by vaCreateSurfaces, meaning that the driver's default logic for picking a pixel format will kick in. So far, this hasn't produced visible problems, but when trying to decode 4:4:4 content, at least on Intel, the driver will pick the 444P planar format, even though the decoder can only return the AYUV packed format. The hwcontext_vaapi code that sets surface attributes when picking formats does not have this bug. Applications may use their own logic for finding the best format, and so may not hit this bug. eg: mpv is unaffected. Signed-off-by: Philip Langdale --- libavcodec/vaapi_decode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c index db48efc3ed..bc2d3ed803 100644 --- a/libavcodec/vaapi_decode.c +++ b/libavcodec/vaapi_decode.c @@ -358,6 +358,8 @@ static int vaapi_decode_find_best_format(AVCodecContext *avctx, ctx->pixel_format_attribute = (VASurfaceAttrib) { .type = VASurfaceAttribPixelFormat, + .flags = VA_SURFACE_ATTRIB_SETTABLE, + .value.type = VAGenericValueTypeInteger, .value.value.i = best_fourcc, }; From patchwork Sat Aug 6 03:27:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 37154 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:92a9:b0:8d:7f3b:94fc with SMTP id q41csp711191pzg; Sat, 6 Aug 2022 03:35:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR4VC9Boj103x+ft0Q7edvgc77CtdmyeXODjYfk/WyxKXNcn+8zyj9gtFZPzUnlSUR3kYBrw X-Received: by 2002:a17:906:8461:b0:730:a43a:9981 with SMTP id hx1-20020a170906846100b00730a43a9981mr7932122ejc.552.1659782121349; Sat, 06 Aug 2022 03:35:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659782121; cv=none; d=google.com; s=arc-20160816; b=w69xUu2qYdwpWbVTwNO6yR8gQyjuVV7JrLAMbu+EPHv9mTH/WZwLr57bLvAHIbc9xw wUgWV5DCLPNlsiNIlGAFhUniGZtELZbi1Nu0GrJ6WWqyAZP0T3vKZHRDuHzXD3qa+dSo fQdcPASkWvv4oHz0CEnEKkfJhNlTfWWb22upg85WAjWPXoaIqUbcAVopiSKNoQ75urBd msDVW0vkwubfzhdIMLKDHkiqomxsY05bRpZFDCof/TrcBRNmtL97o2Le9CCyry3dfRML UNYN3OVUNzIYm8CZcKTyC/SLWT/h+4rrELqDstSGXbL9xW9CovQxNrovoh/5xYlj3YIK L2xA== 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=uZ2xOLhsCCpS4mWzla1O9ajYDPrilGsdb6O5lZXJCgk=; b=PdbG0ljG9+GRHGrFobwE8YmNoabK1+hmD6+T+iztHczf2McNbr1CWfLRY///QlrNMf 2yFXzuVhia7FQmo+FXrpgrHYYx/h1g3uBUFj6T90runnHNWcxG1sG+axtaIDuAZjzOez KkY3iZfj1OtD1TE/907VTRimuCCZykbaKZY5v2oZmcwSY24ecP9EgNhUONWaSxO5zjqJ p4gNZ/5+uONNm9muQYD8wqDkPwh4MOBtcNBVuTGphwUUHk6xMWSEn67RHu0iyYaFrGs4 TJD6zjK8/SMgxdzBAJrEu3qlAp6XPYbp47pGtRClggl2gKFuGs2gHlp35tI3LvH4ZKHJ z3Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@overt.org header.s=mail header.b=c6CMaCdT; 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 v21-20020aa7cd55000000b0043ba23f56a6si1671720edw.200.2022.08.06.03.35.21; Sat, 06 Aug 2022 03:35: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=c6CMaCdT; 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 A896468B710; Sat, 6 Aug 2022 13:35:12 +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 1972668B6B0 for ; Sat, 6 Aug 2022 13:35: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 D2D3D3F552; Fri, 5 Aug 2022 22:28:02 -0500 (CDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1659756483; bh=Gmxiiu07DsyQZ9ha2g7udR9C4MRkPDkKJqu12cC5OuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c6CMaCdTTK+8kB18v15/aB2tAa/w5JBDvYPNsbKHesPMEAQ94M1zP4KZHYVMlsd71 +eDCDwQYLXYUSFRi78oCjv3C2B+rhLAYam4Ej01Gpf5ecnIZSlpq43CLwj6q74+zti Vh1+tV7ZGZcS75z0AzLTyLFO18+5QFcunC90ySaew3YoWtfaER0jjcYecKtKBQ0Nx5 FVoIXwot/a1+CW6WnhT6bbIUPJkwz7fKKo/+qleTGlqUo9x6UCTJPIUbstY+yiGKyi 2TXFPh8Cxi3ftF6tRfTbZm6nKzuLKbkxBR6FOUT2I8DxI/EW/Tb+gKjP//mWgrxjt/ HE25PHAexR8mQ== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 Aug 2022 20:27:53 -0700 Message-Id: <20220806032754.71419-3-philipl@overt.org> In-Reply-To: <20220806032754.71419-1-philipl@overt.org> References: <20220806032754.71419-1-philipl@overt.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] lavc/vaapi_encode: enable 8bit 4:4:4 encoding for HEVC and VP9 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: DcERS92xwJ4K Sufficiently recent Intel hardware is able to do encoding of 8bit 4:4:4 content in HEVC and VP9. The main requirement here is that the frames must be provided in the AYUV format. Enabling support is done by adding the appropriate encoding profiles and noting that AYUV is officially a four channel format with alpha so we must state that we expect all four channels. Also, there are currently very limited ways to get data into the right format. While our VUYA format exists, the swscale code that can convert to VUYA is pending, but I've tested it and it works as expected. Signed-off-by: Philip Langdale --- libavcodec/vaapi_encode.c | 1 + libavcodec/vaapi_encode_h265.c | 2 ++ libavcodec/vaapi_encode_vp9.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 284ce29888..f13daa5cff 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1308,6 +1308,7 @@ static const VAAPIEncodeRTFormat vaapi_encode_rt_formats[] = { { "YUV422_10", VA_RT_FORMAT_YUV422_10, 10, 3, 1, 0 }, #endif { "YUV444", VA_RT_FORMAT_YUV444, 8, 3, 0, 0 }, + { "AYUV", VA_RT_FORMAT_YUV444, 8, 4, 0, 0 }, { "YUV411", VA_RT_FORMAT_YUV411, 8, 3, 2, 0 }, #if VA_CHECK_VERSION(0, 38, 1) { "YUV420_10", VA_RT_FORMAT_YUV420_10BPP, 10, 3, 1, 1 }, diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index d5375add22..1de323af78 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -1278,6 +1278,8 @@ static const VAAPIEncodeProfile vaapi_encode_h265_profiles[] = { #if VA_CHECK_VERSION(1, 2, 0) { 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, 8, 4, 0, 0, VAProfileHEVCMain444 }, #endif { FF_PROFILE_UNKNOWN } }; diff --git a/libavcodec/vaapi_encode_vp9.c b/libavcodec/vaapi_encode_vp9.c index 892ad770c6..9b455e10c9 100644 --- a/libavcodec/vaapi_encode_vp9.c +++ b/libavcodec/vaapi_encode_vp9.c @@ -228,6 +228,8 @@ 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 + { FF_PROFILE_VP9_1, 8, 4, 0, 0, VAProfileVP9Profile1 }, { FF_PROFILE_VP9_2, 10, 3, 1, 1, VAProfileVP9Profile2 }, { FF_PROFILE_UNKNOWN } };