From patchwork Sat Aug 31 16:31:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 51257 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:4027:b0:48e:c0f8:d0de with SMTP id ky39csp1020782vqb; Sat, 31 Aug 2024 09:40:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWF5G/pQfoIj/YbvgHzGkEbtlaMlAEpDncQbTCCVLpF1KSRIYeIfVzYneMN/EUa3Cqt9ozZ5dCR8CzfatY30VdN@gmail.com X-Google-Smtp-Source: AGHT+IG+zT5B+ttl8IrzDBuzsJ5ZdhcdwqA5UujYQTsBJPNpZtaLCsUAC95xnvb0gNaQq2+hYqot X-Received: by 2002:a2e:a98e:0:b0:2ef:2d71:e23c with SMTP id 38308e7fff4ca-2f61e02592dmr18018421fa.2.1725122414186; Sat, 31 Aug 2024 09:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725122414; cv=none; d=google.com; s=arc-20240605; b=FgUWhgiNmQIPgVe7dKsB2YL5NSr4iJt8M8hS708JvCcNqUEDhv3aVw6vQxa/IFqBjo AdjsUZrwkE9UDS1kpl5N1zede3SjHYOCva3ufZC6CMxGJT8Dsik/1ary2NROFUURkVP+ 97skwt8wmM7GJqY5zp8tkAG/hO14lxo0G7Ad/NMyvz61W29XZoGTA7jbUZdZAFxqkRhw jMg6mN1ISKfxEf/1yO9uIJY4hinZfGiWwRyCqb1MaMwdJjq2QD/xyy5gqYk1AZ/33B6J 4ZeedkySTlersxnJXVLO78f5vszR2vnfpct23Ixyfj0c4JuVVV/nLwa9u61YFGdNk838 D02g== 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=yzE4+Y16g2PwLDgrV/Wb0icRMnQzZuyKENLjYulLJic=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=BhTnS/dNwmw3MnHZCMoJTSNnQMb3dBHkBqN+WsNuto5C6Zwd/1x8//jeD2L9Obonhw rIwA/y1vIiIOLaMJjuF0HCMtu6Qegf4PZ6yqhUiQ3vmtvqsK+B39vA4M+uNEi+5kIwBg fy5DpQdEJCdu/OQcss6ijNHqMX/5ROlRJEV8crMt1cG8RfxUhYUaz9rNJFUttBWh2Eru DiqKEuvfKyxbYfEJPKasHN2uzD1706/pOOMC+U4x4Jq/ah+3cNOsXjss3eE/vG8YDgct Ii/OPr3l+FKkbIGR6ZxbOlbIb3OwkGTBRK6bdVe5CTSVJwflJCoNvwGVSRz2gOicCWwX 23jA==; 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=AhluNThp; 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-2f615171d73si18430541fa.450.2024.08.31.09.40.13; Sat, 31 Aug 2024 09:40: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=@gmail.com header.s=20230601 header.b=AhluNThp; 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 921C668DDD6; Sat, 31 Aug 2024 19:31:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 659BA68DDB0 for ; Sat, 31 Aug 2024 19:30:53 +0300 (EEST) Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2d88690837eso893208a91.2 for ; Sat, 31 Aug 2024 09:30:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725121851; x=1725726651; 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=+Dhsu1aV7u8PaQrpiRufV9h/GwuJeN0UpHAddg4+3H4=; b=AhluNThp2WLHV399AGa+nHuFZBoBeY86lxHlhEPGavaZ/4vpK37ExQQoShBl9krgvk 7lukPaJUFLo0y7IJ21vaZZi0RDRz1qWbETgK6eQGLQi4WTp1CGEoyvaiwm/dBM30mT5T ZKK374a5j6JVVhRspfAibMM1j0izJQoyD3DglbbQgO4ZSDofNg47YsATUCjcW5OWh3Ja Uu1uLYmRegnTbYtWEf9wQ570p+/COGnHiTOhxaYNZOF71mnRdVzZtnRkMRGN4m/DV6NI XlOPNH+j5ct/MAZR3JglzvDGIhVEHFTD3RauAQS6gjIDTt+M0xvn51qXlEhUYoWln787 Qwxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725121851; x=1725726651; 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=+Dhsu1aV7u8PaQrpiRufV9h/GwuJeN0UpHAddg4+3H4=; b=AuL1YEtxFT9XcKmQhD2un/KzViim3iKboSiPVey3pxsI+Rsv3ZR4SXCTD+SA9BmXzo LGj3IJfrcJbITstHpTMRzBIVmZOmOryUjD13YXo1a4NOh723l8FLfA4ksqskE5hwyWy4 nwEMRRjhmyj+mqdbHWEMN8q9F0VpFcJzsDspOdCQRqRHRw137buxYVuas9YGynjQhv5m cXAA01xrWcun99Uc6WvfVI0Vs/EW/7Yq5uiAEgCKpzDxBuTO9Pa3a3DQX7Ps8r67Ch8b U8MKaCkCJe2jhDPtRd0ztHTMEEtGfVjvS93+BVRGEkj4EiBuRw2MtEasCN+4ITEpwJDn U17g== X-Gm-Message-State: AOJu0Yy89S4b50tiWqqOfppskUIR0lToc9KBD5t30W9q6UzzqTuujyhZ O1Lo/EwPcoLm9a7bdSNMWNb6DDM1bDho0DRFw9LHAmMO9/Tbt/TW3ia2Qw== X-Received: by 2002:a17:90b:524a:b0:2c5:10a6:e989 with SMTP id 98e67ed59e1d1-2d8564b9bc5mr9806844a91.35.1725121850504; Sat, 31 Aug 2024 09:30:50 -0700 (PDT) Received: from localhost.localdomain ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d85b3b9522sm5935328a91.50.2024.08.31.09.30.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Aug 2024 09:30:49 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 31 Aug 2024 13:31:05 -0300 Message-ID: <20240831163114.4197-4-jamrial@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240831163114.4197-1-jamrial@gmail.com> References: <20240831163114.4197-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/13] 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: oTEgTmb9DsU0 Signed-off-by: James Almer --- 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 dc868714ac..033c4913c0 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1749,7 +1749,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; @@ -1767,9 +1767,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);