From patchwork Sat Sep 14 10:45:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51586 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:9fc3:0:b0:48e:c0f8:d0de with SMTP id k3csp303514vqy; Sat, 14 Sep 2024 04:19:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVpt9A+OdxkNknQczz12fMKh3+IHVjWiXfn9eZUdAgsg4L5Cnybo8n8nj88sZj8D59h/wF6kIeAfoxC3tfhHIGC@gmail.com X-Google-Smtp-Source: AGHT+IG/9iUKKJPqe0Mz1EQnrI7DV1+7T4PAxheVZigaQG9Zng698TA7UoDdeoVrK9F20K7VDO5C X-Received: by 2002:a17:907:f75a:b0:a86:a90f:3025 with SMTP id a640c23a62f3a-a90480ce2a2mr536865366b.59.1726312764378; Sat, 14 Sep 2024 04:19:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726312764; cv=none; d=google.com; s=arc-20240605; b=fI7dEmBTZXqrw9WKODUR+zRbEgMLuYkLIVunSI4pRI/FB4JLqWCsH2CIivRlIQcPbQ urQ/APst9RmRWoDQbpJ3bD+8cQIsYbg57xSAAh3g5jZDmBvvivgy9MQ7H/FAvVh4W016 ffYyf73NJEr01Ids/3z2/XJFN2vZQmZGDduBDhEm5Zd3QNSX0k2tH0fdJeBTWWiItzFt VOkqiHHH72klrlDAh+rEhP9zgRBOY8jM8daSAnL+DjIctxeXUagQoik3YKCS5FrsYv87 3UZf6neu2Z6LbRzcW0m2rFNoogmUmooMAy2UU3Xx0ELvUnfod+tezwU+eiDmaZjRAJ6N gXvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding: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=Y+8oL9hrgcQanRpjbBjiIm8TRbrIt6uuq/1aOTmrWyk=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=KbuR5OZDJg+/kPBwpqdCDNanZwRfF12O2zuRQH+nsPp0GmqIVSuNnAwIxLEUJITwCX JbHZoGIoNi6Rcm2llJ5Fe+cx+LXZ5fOSDC4h7aqWdomDSxZyMfbviPtnPpAnd3lZrkwd 9OMlutu9ZX3pm9wtMyInNLSSQN+rhVIBUMelEzH7bgyivHTJRQ/7z5dqmku4Cidryg1Z UQyQhxj0Hjd9r2Yt7oM2WTnmKjuEzN/7bHHXOOZFTwSuJno6mLJCuWNQed8OrCedk3Ca V0RsZaaan5whm4mqAG0ICqmcZ9sN+c6GB+693nWTdB0JGV2P//ZjX0jm0WvZDjDLfMI+ yuag==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=XBB9Sj5v; 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 a640c23a62f3a-a906133aa9dsi85705866b.862.2024.09.14.04.19.24; Sat, 14 Sep 2024 04:19:24 -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=@khirnov.net header.s=mail header.b=XBB9Sj5v; 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 6091168DDFF; Sat, 14 Sep 2024 14:11:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BE99568DBA3 for ; Sat, 14 Sep 2024 14:10:53 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=XBB9Sj5v; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id AB5534E11 for ; Sat, 14 Sep 2024 13:10:49 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id AocUpMwCAm9E for ; Sat, 14 Sep 2024 13:10:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1726312246; bh=eF4yBVIFT6kfIUwdv7m7k/98WRLnrlrV3yxU3Uqm56M=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XBB9Sj5vjQXsouAOGRCXZeEpsqnRPykPWInKqPmXoEYNmQ0Wl+K9DBctqzpJ1Dq/X ++38bdDhN6/E7aoHBChhOLZm9qsAwvOeh2NH+FM/GfcCBz1/ITqPSnsL5i0h/M7lfh GxsRRzY5fmuWZwzz1sfPNR6B00OpsU/I13Qw7qLJGX8DcXdKXO3GXr8Z+8BzGBAmkv /TvGNSvBomevHx85gfkWA99toCQ0fKpgKLXeFTkdVwj6YNay80v85fC7PbxCmBRZfn vBAL612JiiwBrpU+Y8GVehDNpkmmC1uA4zKHqYIn+8AkADEy/e309626G5w94ETrbk YkhMsucMR7ssQ== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 7E2C64E14 for ; Sat, 14 Sep 2024 13:10:46 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 7D9393A1E08 for ; Sat, 14 Sep 2024 13:10:41 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 14 Sep 2024 12:45:39 +0200 Message-ID: <20240914111036.17164-15-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240914111036.17164-1-anton@khirnov.net> References: <20240914111036.17164-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 14/23] avcodec/decode: split ProgressFrame allocator into two functions 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: E6hAz96cEX/E From: James Almer Signed-off-by: James Almer Signed-off-by: Anton Khirnov --- libavcodec/decode.c | 11 +++++++---- libavcodec/progressframe.h | 16 ++++++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 27dba8a1f3..5f6646ea4d 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1724,7 +1724,7 @@ static void check_progress_consistency(const ProgressFrame *f) av_assert1(!f->progress || f->progress->f == f->f); } -static int progress_frame_get(AVCodecContext *avctx, ProgressFrame *f) +int ff_progress_frame_alloc(AVCodecContext *avctx, ProgressFrame *f) { FFRefStructPool *pool = avctx->internal->progress_frame_pool; @@ -1742,9 +1742,12 @@ int ff_progress_frame_get_buffer(AVCodecContext *avctx, ProgressFrame *f, int fl { int ret; - ret = progress_frame_get(avctx, f); - if (ret < 0) - return ret; + check_progress_consistency(f); + if (!f->f) { + ret = ff_progress_frame_alloc(avctx, f); + if (ret < 0) + return ret; + } ret = ff_thread_get_buffer(avctx, f->progress->f, flags); if (ret < 0) { diff --git a/libavcodec/progressframe.h b/libavcodec/progressframe.h index 428a461659..32a345beec 100644 --- a/libavcodec/progressframe.h +++ b/libavcodec/progressframe.h @@ -102,12 +102,24 @@ void ff_progress_frame_report(ProgressFrame *f, int progress); void ff_progress_frame_await(const ProgressFrame *f, int progress); /** - * This function sets up the ProgressFrame, i.e. gets ProgressFrame.f - * and also calls ff_thread_get_buffer() on the frame. + * This function allocates ProgressFrame.f + * May be called before ff_progress_frame_get_buffer() in the cases where the + * AVFrame needs to be accessed before the ff_thread_get_buffer() call in + * ff_progress_frame_alloc(). * * @note: This must only be called by codecs with the * FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap. */ +int ff_progress_frame_alloc(struct AVCodecContext *avctx, ProgressFrame *f); + +/** + * This function sets up the ProgressFrame, i.e. allocates ProgressFrame.f + * if needed, and also calls ff_thread_get_buffer() on the frame. + * + * @note: This must only be called by codecs with the + * FF_CODEC_CAP_USES_PROGRESSFRAMES internal cap. + * @see ff_progress_frame_alloc + */ int ff_progress_frame_get_buffer(struct AVCodecContext *avctx, ProgressFrame *f, int flags);