From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 2D35D46571 for ; Tue, 16 Jul 2024 17:18:39 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A964468DB12; Tue, 16 Jul 2024 20:16:53 +0300 (EEST) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 50AE968DA9D for ; Tue, 16 Jul 2024 20:16:37 +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=rp5cHEX6; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 5AC594DF8 for ; Tue, 16 Jul 2024 19:16:34 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id T-AxqgqkHtAK for ; Tue, 16 Jul 2024 19:16:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1721150188; bh=FjCDxywa/rWdGdlSn05RjKsHMcc1zM5Ukx/npbCHbsA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rp5cHEX6v8PAPOqawxqlyDxJMaIy8Wi3e83g18goFaiHeRu0h69O0FYS5mtcMN4PS K+PCeB4+rIkA4crnojciQ18v1Ab9VMUcpr372OOKrhNobT0+PmppI/38WW5LhaFeaF 2rjraqsb8jwJNbr/On4K2enAJjozDW9ljA3VOZeJ9UuFwms4a4C+h2iMI/rNMziwGd 5zoCGuXkyI3PgHeN2d5W5QgTowvJkwcRrThU/VP3ZGP8mmtqQUWQEQUfZkeMCmjCpZ b0j16sx8WzERQV2xDOElE6qWzljZyESA8hcnj8i8Fz8CnRt2z8endk7/9qm1BqMpdj /YesQOoKuch+Q== 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 925064E06 for ; Tue, 16 Jul 2024 19:16:28 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 1BDA13A2CFD for ; Tue, 16 Jul 2024 19:16:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 16 Jul 2024 19:11:35 +0200 Message-ID: <20240716171155.31838-20-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716171155.31838-1-anton@khirnov.net> References: <20240716171155.31838-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 20/39] lavc/ffv1enc: store per-slice rc_stat(2?) in FFV1SliceContext 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: Instead of the per-slice FFV1Context, which will be removed in future commits. --- libavcodec/ffv1.c | 6 ++---- libavcodec/ffv1.h | 3 +++ libavcodec/ffv1enc.c | 20 ++++++++++---------- libavcodec/ffv1enc_template.c | 4 ++-- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 490baac233..4ef04f6b9b 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -127,7 +127,6 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f) f->slice_context[i++] = fs; memcpy(fs, f, sizeof(*fs)); - memset(fs->rc_stat2, 0, sizeof(fs->rc_stat2)); sc->slice_width = sxe - sxs; sc->slice_height = sye - sys; @@ -208,9 +207,8 @@ av_cold int ff_ffv1_close(AVCodecContext *avctx) for (j = 0; j < s->quant_table_count; j++) { av_freep(&s->initial_states[j]); for (i = 0; i < s->max_slice_count; i++) { - FFV1Context *sf = s->slice_context[i]; - if (sf) - av_freep(&sf->rc_stat2[j]); + FFV1SliceContext *sc = &s->slices[i]; + av_freep(&sc->rc_stat2[j]); } av_freep(&s->rc_stat2[j]); } diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index 01c35dc942..bee7b75614 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -84,6 +84,9 @@ typedef struct FFV1SliceContext { PlaneContext plane[MAX_PLANES]; PutBitContext pb; RangeCoder c; + + uint64_t rc_stat[256][2]; + uint64_t (*rc_stat2[MAX_QUANT_TABLES])[32][2]; } FFV1SliceContext; typedef struct FFV1Context { diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index d615d3da87..e3d094141c 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -896,11 +896,11 @@ slices_ok: return AVERROR(ENOMEM); for (i = 0; i < s->quant_table_count; i++) for (j = 0; j < s->max_slice_count; j++) { - FFV1Context *sf = s->slice_context[j]; - av_assert0(!sf->rc_stat2[i]); - sf->rc_stat2[i] = av_mallocz(s->context_count[i] * - sizeof(*sf->rc_stat2[i])); - if (!sf->rc_stat2[i]) + FFV1SliceContext *sc = &s->slices[j]; + av_assert0(!sc->rc_stat2[i]); + sc->rc_stat2[i] = av_mallocz(s->context_count[i] * + sizeof(*sc->rc_stat2[i])); + if (!sc->rc_stat2[i]) return AVERROR(ENOMEM); } } @@ -1126,16 +1126,16 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, av_assert0(f->slice_count == f->max_slice_count); for (j = 0; j < f->slice_count; j++) { - FFV1Context *fs = f->slice_context[j]; + const FFV1SliceContext *sc = &f->slices[j]; for (i = 0; i < 256; i++) { - f->rc_stat[i][0] += fs->rc_stat[i][0]; - f->rc_stat[i][1] += fs->rc_stat[i][1]; + f->rc_stat[i][0] += sc->rc_stat[i][0]; + f->rc_stat[i][1] += sc->rc_stat[i][1]; } for (i = 0; i < f->quant_table_count; i++) { for (k = 0; k < f->context_count[i]; k++) for (m = 0; m < 32; m++) { - f->rc_stat2[i][k][m][0] += fs->rc_stat2[i][k][m][0]; - f->rc_stat2[i][k][m][1] += fs->rc_stat2[i][k][m][1]; + f->rc_stat2[i][k][m][0] += sc->rc_stat2[i][k][m][0]; + f->rc_stat2[i][k][m][1] += sc->rc_stat2[i][k][m][1]; } } } diff --git a/libavcodec/ffv1enc_template.c b/libavcodec/ffv1enc_template.c index c27a2e3a39..c79146d619 100644 --- a/libavcodec/ffv1enc_template.c +++ b/libavcodec/ffv1enc_template.c @@ -74,8 +74,8 @@ RENAME(encode_line)(FFV1Context *f, if (f->ac != AC_GOLOMB_RICE) { if (s->flags & AV_CODEC_FLAG_PASS1) { - put_symbol_inline(c, p->state[context], diff, 1, s->rc_stat, - s->rc_stat2[p->quant_table_index][context]); + put_symbol_inline(c, p->state[context], diff, 1, sc->rc_stat, + sc->rc_stat2[p->quant_table_index][context]); } else { put_symbol_inline(c, p->state[context], diff, 1, NULL, NULL); } -- 2.43.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".