From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 9F4854BFA3 for ; Fri, 23 May 2025 03:11:02 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 868AC68D025; Fri, 23 May 2025 06:10:49 +0300 (EEST) Received: from mail-vk1-f172.google.com (mail-vk1-f172.google.com [209.85.221.172]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id D5E2068D01E for ; Fri, 23 May 2025 06:10:41 +0300 (EEST) Received: by mail-vk1-f172.google.com with SMTP id 71dfb90a1353d-52eff44a661so959793e0c.3 for ; Thu, 22 May 2025 20:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747969840; x=1748574640; 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=mYMyTgpais+7ektIJnX9RxajTTYpcjcQJUTJOtE50pE=; b=M1A+Q+xPrj0ZPF2e+Gl6Wpeid9YHR00/znEH9z0UoWzdwAufndQle0iKAEMIhvoBeG 2cVWYhHoIzLiao8mjS9PaTgxw26vIciCJmhB+CvON+daG25MBgX7MWACS+wwuptm8gSX fCOkk65tky6/JnL59LVltcU5Lvz7x3IAbyTuEGroM9X5ln/AQDtaFwfdUlI3AcsSugQu ovmEtgVfArx/u/c+93qNP2yq70RiSNCiOmeDF3v0ZID0CF66qKM1XhKTHo2SPg4xlwHN mP189z37I66gtuJ86TQgs0pAJuqzZnno2Tzq1vADr9X4+bjHLaCBB0U7e83LXGUBHXVo B4Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747969840; x=1748574640; 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=mYMyTgpais+7ektIJnX9RxajTTYpcjcQJUTJOtE50pE=; b=dg5g6lTTR8CPWfN2409odMjUS8NaxVG6fhw1ff2srrIDzyhdWPE44vcBpcPMBcqRps HtLhP9hrWZ36Vm+MwrPAZvrkR5SjJ4nY2Mja3jSNAqozCZXWRODkm6YkwpREuCLGKHgI Ru96d+sP3JE6f8/izIGdYUT/O1//SafdroMkHgHPoOtRi2p0/uy+ifm/cH4Fj1hr5mUy bzRdNGXUkd1QbpBmXHEAKGwp0utL0UbyVYhit+g3G2Yt/2RSBCu2c5Yw6jC3aGkDavmS ljns7tmuNTl6ADzjR41fcmLxsEIXDj150jPiXewBGHJgggsI+5KgGWF3EFZsmN4w8DII xAZQ== X-Gm-Message-State: AOJu0YyMNI8dGW/xCqZvQvbaF/nU9nIh9vJW0qzprgdHHoJsBHwVnJaG oJ6mdgOJDVtr9NMTCnaA+ZR/AvhU6cVs7rQprrz41iqN+S/vojl5IVzZz4sZ7Q== X-Gm-Gg: ASbGnctud1vWRE66QFRyoo+RTvnGcZQF5IUmaDhdIHt4C1p7pb0EQn/YIwIfGz6fAkF A5eTzOtjJN+CH6mObz0ETlFCIUcgIg6env7SAcU5ticK31+2lNCDzIL7Ea4nb3TFLP4oZfX4xW8 dyslOj6ad6PVk8CNjdY3GQa9b3BTSu2E49W4ZKr5Q9MOhmyN1sXVRjVrosELI2bZFM74cNJZevS OWbXTI/Q5F6rSOU9U1p3HL9pM02RPH7DQMIEmtXtrZ28Jz8C/zL7INbhQMq0NT42GLDQDMKkWqp nqeXI1fdJKj47LYoIM3s6QoAgEVNBxBF+B3z0XdeGSrPeWpOXqVyAwLhHdzqV1gXqkHY8QIOQBn Fj42P X-Google-Smtp-Source: AGHT+IEQkX5M3arvOCNuLX6ycr+NAPuKA8z/On1sgRi75iH5pfnsLtfvrsnJBiM/jLf74JKtr1CTJw== X-Received: by 2002:a05:6122:caa:b0:520:61ee:c815 with SMTP id 71dfb90a1353d-52dbce4a585mr23624722e0c.10.1747969840078; Thu, 22 May 2025 20:10:40 -0700 (PDT) Received: from localhost.localdomain ([2800:2121:b000:82e:78e2:53a8:f2f1:b249]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-52dba9408f5sm12812913e0c.15.2025.05.22.20.10.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 May 2025 20:10:39 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Fri, 23 May 2025 00:10:20 -0300 Message-ID: <20250523031021.15983-2-jamrial@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250523031021.15983-1-jamrial@gmail.com> References: <20250523031021.15983-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/cbs_av1: don't store a reference to the unit data if it's not needed 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: If a module using CBS-AV1 doesn't bother to decompose redundant frame header OBUs, then there's no need to keep a reference to the previous frame header around. Signed-off-by: James Almer --- libavcodec/cbs_av1.c | 23 +++++++++++++++++++++++ libavcodec/cbs_av1.h | 3 +++ libavcodec/cbs_av1_syntax_template.c | 2 ++ 3 files changed, 28 insertions(+) diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c index 4edb6ecd50..1938c5acff 100644 --- a/libavcodec/cbs_av1.c +++ b/libavcodec/cbs_av1.c @@ -1104,6 +1104,7 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx, { err = cbs_av1_write_frame_header_obu(ctx, pbc, &obu->obu.frame_header, + priv->redundant && obu->header.obu_type == AV1_OBU_REDUNDANT_FRAME_HEADER, NULL); @@ -1265,6 +1266,27 @@ static int cbs_av1_assemble_fragment(CodedBitstreamContext *ctx, #endif } +static int cbs_av1_init(CodedBitstreamContext *ctx) +{ + CodedBitstreamAV1Context *priv = ctx->priv_data; + + if (ctx->decompose_unit_types) { + for (int i = 0; i < ctx->nb_decompose_unit_types; i++) { + switch (ctx->decompose_unit_types[i]) { + case AV1_OBU_REDUNDANT_FRAME_HEADER: + priv->redundant = 1; + break; + default: + break; + } + } + } else { + priv->redundant = 1; + } + + return 0; +} + static void cbs_av1_flush(CodedBitstreamContext *ctx) { CodedBitstreamAV1Context *priv = ctx->priv_data; @@ -1385,6 +1407,7 @@ const CodedBitstreamType CBS_FUNC(type_av1) = { .write_unit = &cbs_av1_write_obu, .assemble_fragment = &cbs_av1_assemble_fragment, + .init = &cbs_av1_init, .flush = &cbs_av1_flush, .close = &cbs_av1_close, }; diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h index 874f64561f..e79e90c6eb 100644 --- a/libavcodec/cbs_av1.h +++ b/libavcodec/cbs_av1.h @@ -490,6 +490,9 @@ typedef struct CodedBitstreamAV1Context { AV1ReferenceFrameState ref[AV1_NUM_REF_FRAMES]; + // Init values + int redundant; + // AVOptions int operating_point; // When writing, fix the length in bytes of the obu_size field. diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c index 5518544a4d..701f474ce4 100644 --- a/libavcodec/cbs_av1_syntax_template.c +++ b/libavcodec/cbs_av1_syntax_template.c @@ -1795,6 +1795,7 @@ static int FUNC(frame_header_obu)(CodedBitstreamContext *ctx, RWContext *rw, #endif fh_bytes = (fh_bits + 7) / 8; + if (priv->redundant) { priv->frame_header_size = fh_bits; if (rw_buffer_ref) { @@ -1810,6 +1811,7 @@ static int FUNC(frame_header_obu)(CodedBitstreamContext *ctx, RWContext *rw, priv->frame_header = priv->frame_header_ref->data; memcpy(priv->frame_header, fh_start, fh_bytes); } + } } } -- 2.49.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".