From patchwork Sun Sep 1 00:03:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 51277 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:4027:b0:48e:c0f8:d0de with SMTP id ky39csp1138628vqb; Sat, 31 Aug 2024 17:20:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW2tmdcy9WO22Sy2yfZpFWrhCkgNMq1or1+Uz9Tp03++UqX0ni45v5hGVl3NZ9vuHeaIe0Ld7cCHHdr3edP87FZ@gmail.com X-Google-Smtp-Source: AGHT+IFYlagYwHsWPrXrdR1UucKFH5SopBwqqe/Bjo5ZUw2blgh4C92ySFQIXgKtpsrAOqjFFie2 X-Received: by 2002:a2e:6109:0:b0:2f3:c82d:9e7d with SMTP id 38308e7fff4ca-2f61052c6b9mr57972321fa.47.1725150012094; Sat, 31 Aug 2024 17:20:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725150012; cv=none; d=google.com; s=arc-20240605; b=f6GTUnoTbrZOAM83MZXmzt7HCM9XXUPIuVtSkSn47Ii0C0REovqL/S2YuckYcmHcc3 PPRM0xnX49vdLkW6SmkNUGQaV+mbV3YBWqKyIokKeXYnxyKklhHJz2xbQhWd59Zc+m0c zWo3HRi/NFl20+QbHU9uTzRwpQWfqk+AIR4balq1NFDSeJ7VghV4++jCy9vSLiMAaDHV nMfB7/CmmzHjNhijerj/zALqz2SqleashIYaiwBOXKwynPVQLnx7Qmcu4aqHcTIdSE6x h6ARcnfnyz9rQEU4jzs/thiKw0lxDuV7VaGtWsFH7LzU16HD5S7WDNt3b7mITwTZ3mHB 8wnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:cc:reply-to:from :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:delivered-to; bh=AadiAKOh7rAbveUK2a2j51cS8dz3Hyjb4uzoam34XA0=; fh=nenT92/WZoU6unXd3J6UhGUdod4piddKfVtctNBOh6k=; b=Z6aFgeDPTXZS3GbByfUNnp8zHQdKhzxDJlgshP2OI95wag4Jg5Z4Kumn9472TQ/C4E Nz3vuKUKu8kV5rTgVQn4tzNjtUZxa0Al8sqHh+HY49Sy1hd1wg1EiOfEMCR5Ydi7mki9 frjDxNQJXtfPhLIqokBHCIyIx/wVO9MI4Ji5QgH4qiKxLrpxnDi+vqGKZXmsZpiS3I9N qnXbWK3pYvR+sEZYBi1IHnIibn8pfaXjgKl5ZB1UFaA2kPIyWLURHnE6ihbBuEosn73m +DHLKXuz9AUcu5rqHlNUGqsbwKr1ZvR/fhG4ehXOWwELMkcORNxuOfQp73n0SzSBNnLW uohg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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 38308e7fff4ca-2f615161f52si18625041fa.371.2024.08.31.17.20.11; Sat, 31 Aug 2024 17:20:12 -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; 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 B189968DF57; Sun, 1 Sep 2024 03:03:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vidala.lynne.ee (vidala.pars.ee [116.203.72.101]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 96B4168DF0C for ; Sun, 1 Sep 2024 03:03:30 +0300 (EEST) To: ffmpeg-devel@ffmpeg.org Date: Sun, 1 Sep 2024 02:03:01 +0200 Message-ID: <20240901000314.379276-3-dev@lynne.ee> X-Mailer: git-send-email 2.45.2.753.g447d99e1c3b In-Reply-To: <20240901000314.379276-1-dev@lynne.ee> References: <20240901000314.379276-1-dev@lynne.ee> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/10] hw_base_encode: make recon_frames_ref optional 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: , X-Patchwork-Original-From: Lynne via ffmpeg-devel From: Lynne Reply-To: FFmpeg development discussions and patches Cc: Lynne Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: RbatJmATOdaw Vulkan supports some stupidly odd hardware, that unfortunately, most modern GPUs happen to be. The DPB images for encoders may be required to be preallocated all at once, and rather than be individual frames, be layers of a single frame. As the hw_base_encode code is written with the thought that either the driver or the device itself supports sane image allocation, Vulkan does not leave us with this option. So, in the case that the hardware does not support individual frames to be used as DPBs, make the DBP frames context optional, and let the subsystem manage this. --- libavcodec/hw_base_encode.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/libavcodec/hw_base_encode.c b/libavcodec/hw_base_encode.c index 8411cc7582..7b6ec97d3b 100644 --- a/libavcodec/hw_base_encode.c +++ b/libavcodec/hw_base_encode.c @@ -440,16 +440,18 @@ static int hw_base_encode_send_frame(AVCodecContext *avctx, FFHWBaseEncodeContex goto fail; } - pic->recon_image = av_frame_alloc(); - if (!pic->recon_image) { - err = AVERROR(ENOMEM); - goto fail; - } + if (ctx->recon_frames_ref) { + pic->recon_image = av_frame_alloc(); + if (!pic->recon_image) { + err = AVERROR(ENOMEM); + goto fail; + } - err = av_hwframe_get_buffer(ctx->recon_frames_ref, pic->recon_image, 0); - if (err < 0) { - err = AVERROR(ENOMEM); - goto fail; + err = av_hwframe_get_buffer(ctx->recon_frames_ref, pic->recon_image, 0); + if (err < 0) { + err = AVERROR(ENOMEM); + goto fail; + } } pic->priv = av_mallocz(ctx->op->priv_size);