From patchwork Thu Aug 8 18:37:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Llu=C3=ADs_Batlle_i_Rossell?= X-Patchwork-Id: 50946 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d7b2:0:b0:489:2eb3:e4c4 with SMTP id dc18csp1222086vqb; Thu, 8 Aug 2024 11:37:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW4wQmPFE788298VVQeZOz1eZxr6mDUdiOhyOFH+2eeO0eWHH3sjGKf3FpENVrYfuKfpGhx9RaVKP11FJNLhhQwrVDuBjkhpG9jsg== X-Google-Smtp-Source: AGHT+IHBAjpL9zPIHuedGcNlGJZEpxS5AvIUounoDoUQtiuwZztDDLU1fsXiqXIJhIyZuJM1on5Y X-Received: by 2002:a05:6512:ac8:b0:52c:de3a:839f with SMTP id 2adb3069b0e04-530e581fcb6mr2077516e87.20.1723142273590; Thu, 08 Aug 2024 11:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723142273; cv=none; d=google.com; s=arc-20160816; b=ObIeuR3T/ZkrO0ES9j+xuqIzczXchmhV21J39Sd3p5sQvuqWjW5Z6+7GPoqWRJlNa8 nbwARdlVh/1DDSU2mMZIF4qpqMLQg8Pf3XkNH0DVasoQpNTOFG7FTVQovW/PfZMnORBE 9A6UbBfYQdpWQ9WFYJ1GyMtEoLuk8E49oYhIZILdAQRK+rpG1eiWccPE01vgADmptG/o yOtSXZMlx27vRPML3gggyZvm7uFc4BqXWNRod6+A/4Wb2cWZPFSR5f0qRhSJjA1s2sS8 u3LHfUhNCLH+ocQXYpldUP/taIqWvGYYAkDKODSJJy7PP35b5k4GeKOOXeFgOzrgEZTw JCZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :content-disposition:mime-version:message-id:to:from:date :dkim-signature:delivered-to; bh=gUoOXdzyb0qMaFlY7RpKDWQzx5xxrf10/BoTKpMTBuw=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=oC2xp0YxGKDD9/O7oRUBvIQ4nKEyld9JzqsA1+J5mtaWI5FUrx5vBQIDKm8PXpWoPM sHleONKTM6J4SdoTRjhIo3pjDoiAjazZpx3Xpl7cI8LHK08f1doiVOfiK1JJ4dImvvjx 9KrK1awCarKA0SNR5EGoaF2Ex/ARAu+Ag2jWAqW91WmK7HgQ991ildbcUxAu+hvvZatk C/lv8bos3Eqa1hDCkV6gItjfYYoEpVF6bhvHbYQVxisAYGaRmapo0U5OKr0ahK7Ye3q8 Uj724VzOcr/RkOTqbDgIZZnN9h3A73ZhBTqusZKSE5+Z9tV0Fajnyur6+KBFU0gm4bn7 DDKw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@viric.name header.s=dkim1 header.b=oY22emZe; 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=NONE sp=NONE dis=NONE) header.from=viric.name Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 2adb3069b0e04-530de6cf3b0si1157442e87.609.2024.08.08.11.37.53; Thu, 08 Aug 2024 11:37:53 -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=@viric.name header.s=dkim1 header.b=oY22emZe; 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=NONE sp=NONE dis=NONE) header.from=viric.name Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DC0E068DA3A; Thu, 8 Aug 2024 21:37:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.viric.name (mail.viric.name [37.18.133.75]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 687D868D836 for ; Thu, 8 Aug 2024 21:37:42 +0300 (EEST) Received: by mail.viric.name (Postfix, from userid 1000) id A5B5A12BB0B6; Thu, 08 Aug 2024 20:37:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=viric.name; s=dkim1; t=1723142261; bh=soc5BgEQo1h6UIjLpU6/iwquqzXcR1a8qPQ2gbf7jwY=; h=Date:From:To:Subject; b=oY22emZewqFTZkMdKXRxL50hDnCIXcyWyP5vWP9zFa2jmojy9p+XdDZ4DP5zuCSmI JYzQ0EbGGJUiErGUyYzN/wVOp2cgBsGAyKJD4A7ZfptRBfrG6yt5y6vV7TtI5vjGYE u+d2w8hSHgr/HCPYR6YlUDnUMP2h6W9i35w4TJyc= Date: Thu, 8 Aug 2024 20:37:41 +0200 From: =?iso-8859-1?q?Llu=EDs?= Batlle i Rossell To: ffmpeg-devel@ffmpeg.org Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Accept-Language: ca, es, eo, ru, en, jbo, tokipona Subject: [FFmpeg-devel] PATCH: Force vaapi image formats to NV12-only 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: vUQiV73O3RR8 attached From c6439f3a74529db25777029596791a62eb3c77d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Thu, 8 Aug 2024 20:32:03 +0200 Subject: [PATCH] Force vaapi image formats to NV12-only Vaapi drivers often lack proper image converesions and not all situations allow vaGetImage or vaPutImage with the image formats reported by the API. NV12 seems allowed in all circumstances. With this change now one can use the hwaccel directly without explicit conversions to nv12 for frame downloading to work. gstreamer adopted a similar approach: https://bugzilla.gnome.org/show_bug.cgi?id=752958 --- libavutil/hwcontext_vaapi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 12bc95119a..d678e58d07 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -418,7 +418,12 @@ static int vaapi_device_init(AVHWDeviceContext *hwdev) for (i = 0; i < image_count; i++) { fourcc = image_list[i].fourcc; pix_fmt = vaapi_pix_fmt_from_fourcc(fourcc); - if (pix_fmt == AV_PIX_FMT_NONE) { + if (pix_fmt != AV_PIX_FMT_NV12) { + av_log(hwdev, AV_LOG_DEBUG, "Format %#x -> ignored.\n", + fourcc); + continue; + } + else if (pix_fmt == AV_PIX_FMT_NONE) { av_log(hwdev, AV_LOG_DEBUG, "Format %#x -> unknown.\n", fourcc); } else {