From patchwork Thu Sep 12 00:59:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51544 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:14c:b0:48e:c0f8:d0de with SMTP id h12csp776676vqi; Thu, 12 Sep 2024 01:44:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUmk/dLYooVk1TwcIlYpGQSXE/lJClzHG0JXCUVqJBZul0N1APPa7qZQrvXKvGBH3gmlrgbTewDeLFBYqLZGNTW@gmail.com X-Google-Smtp-Source: AGHT+IEvA+F/RdzkQUOvIll29fE7eUl5qJzAxEjKJRBVNd2GmVKNAUvBF8MyF0XFk/lQttYY28cm X-Received: by 2002:a05:651c:2211:b0:2ef:21b3:cdef with SMTP id 38308e7fff4ca-2f787edd67dmr12073801fa.25.1726130650566; Thu, 12 Sep 2024 01:44:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726130650; cv=none; d=google.com; s=arc-20240605; b=O3eOA0XUTk9Zg53KffXlkoW9jX29TIs3gldp+NPRvdvuSVTaSq4zKlNBMsLBPlq4Vl K8AbiEadQDdZ4aw1C5SGHEcDa6aUli4lqEewHVzbudviAtce+5mujxPvglabPF18aEmo qegW97dzJ5jLcPhdirFPG73ACi75auIwnLo+CpyXdwKNQy4a0T7ouXxE8uJ9KpLyXbUS jOBFS+OYlFyTBeUtOvU0r8JlhCZkKpULOTPEGx+eoXjbUjZNH5oU3YQmKilDloq6Q6sB cfO+RHs64MN6bGQYdtdV4PJ6WrGMjmjS7RwjqgzCEw2MoK6mBVhfUPUucJercClAQSv8 buiA== 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=ihMVOXn34b01TttLBegcMNavMu9waHv3q+f7xshnqHA=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=PZnmJAKsbb6n8OBz3YnXjW/2vIalnkajqT0Wkn5exws2xBCUqsch84L/0xs+o2Uj2n HTKH0BVawg5ZboGifguW389iVki4GFf0HCjV94GZq2Go15nuke9kLLFuX2NSgbcqa8GF z4UwAmE5VqJ6kUjqkleD0HPijuB0PFOxBqz6rwr+7Be17ET11SGCfkXedWKIke74bNsi 1MzSysn8WqKcyCqJA4jkzQ0CC7vxu2gi7g/jd/SEAHdY1C1oFvFKtuDe1QPXaLDsGEzT 9FZvfJFPyTgz4xd2Rfva8bwVu58yEPhtUXHuYHZHBTZQEnsVXv7XaAJRzzdf1hDzCST5 cvmQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=kjvHqDaY; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2f75bfea454si34287481fa.157.2024.09.12.01.44.10; Thu, 12 Sep 2024 01:44:10 -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=@gmail.com header.s=20230601 header.b=kjvHqDaY; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2A8A468D95B; Thu, 12 Sep 2024 03:59:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 075DF68D818 for ; Thu, 12 Sep 2024 03:59:48 +0300 (EEST) Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-718d606726cso218264b3a.3 for ; Wed, 11 Sep 2024 17:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726102786; x=1726707586; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=1+WMg9YO8bBbcnkXJrfpIOscDd1i3n7k3W2YLiv4FDM=; b=kjvHqDaYpnoVZNQIHIffX2CzeD+HnxHKWGBD/MyEjUuyrURPU42a7X7+Gug32umGKN N3etq7CWM/0Xcyy/6ikyhyHqdVt6uxg9/waMevDM6U0QN3EfEbhjqUXi7WQ+rkogML+v hbI45h6FvYZIyQR/SSevVsz+kqUlymBChxSzxpmj47/IT9ZjZz3VqzGN0XMaUfTV2hgo ifbVO20TxiX9/3/o6x/6G19yLGV/5ABVj4aIHPcO08UgMpWr5zF/j/oprdByQplw/nWh bOPDb9BaoUqq5T18jZB/mV8AQ76oxxiz0xHyc+S32YqM1e9ES5zSsErDYLh3icZO2t2J CW+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726102786; x=1726707586; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1+WMg9YO8bBbcnkXJrfpIOscDd1i3n7k3W2YLiv4FDM=; b=Dp22qoFm0mkISXULpc2QssGsCk5uOu4U2mMKsuYMvE70cflkb+2/yoAl3pGYIOMjSU a9bHhh/7leSHpJyLO/Cpddpgt3Di6kGKLbLUht5hPxFbv96vzv4BBdY3VxQHXir92hxq ZX2YdSVcw8+F0TVTPk583aJTZbj6R136An83yYka8sDxI+msxEL432xQo54kjeaMryV5 urnjEadYA/0Ve/nzW8VrhvRVWZA5G1A06NebaKkTqJIG8KG1itDYLr9Q4ej32+bz3t7R CUlZTueHxPCnWBaSr83xZs2FW5hm+7noQxwVwc6DzqOM4HmYA2QR8fWl4OT8aohVWAw6 nKpA== X-Gm-Message-State: AOJu0YwhmMMcUV3euW9BtOGtU7GjtbLPmNRLOQCG6VacA5phv4qFFVC5 1dc6Y3siaBZD9ITpK1GHxewhNFQC/wKTVIvWLQsE88Ac1yauXYwC0G20bg== X-Received: by 2002:a05:6a00:2d17:b0:714:2d05:60df with SMTP id d2e1a72fcca58-71926091d24mr1630972b3a.15.1726102785607; Wed, 11 Sep 2024 17:59:45 -0700 (PDT) Received: from localhost.localdomain ([181.92.233.116]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908fc8210sm3557769b3a.36.2024.09.11.17.59.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 17:59:44 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 Sep 2024 21:59:22 -0300 Message-ID: <20240912005925.10151-8-jamrial@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912005925.10151-1-jamrial@gmail.com> References: <20240912005925.10151-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/10 v2] 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: ec1IhBLR8m2R Signed-off-by: James Almer --- No changes since last version. 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 18ddd28690..e4e92e34e4 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1725,7 +1725,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; @@ -1743,9 +1743,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);