From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTPS id 718584B1D4
	for <ffmpegdev@gitmailbox.com>; Tue, 25 Mar 2025 13:09:49 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 03070687B95;
	Tue, 25 Mar 2025 15:09:46 +0200 (EET)
Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net
 [217.70.183.195])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D6D28687A16
 for <ffmpeg-devel@ffmpeg.org>; Tue, 25 Mar 2025 15:09:39 +0200 (EET)
Received: by mail.gandi.net (Postfix) with ESMTPSA id 3BD5420489
 for <ffmpeg-devel@ffmpeg.org>; Tue, 25 Mar 2025 13:09:39 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc;
 s=gm1; t=1742908179;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:
 content-transfer-encoding:content-transfer-encoding;
 bh=rMYN3evN6I3wYQ6B0BHtZo4Xz2WhQ7hG7o+fLoFMiRQ=;
 b=KwtCEXHeGvv2nPmSnr6N8eo5/m8hukandPZ5Vj5OeVl5Ru0PQFuzl/ygQyPh0fnl3WWD27
 BuUUgSFim0OJ3fNsuKUM7K8BGKVE5CfEXQ668IC/r1qDD+A33ulpbiUkYxoaVE6GxTnqfl
 S5Me2veeI1RZkoaR2Jvampt95Ef8ZU/OVX+RHplrbOmtX5jpYkRRDUZBuYKzSvZDHIyna6
 4yl18ARBcn+685OvW4bGg9ZJ0FBs3+yo03Dmd6klvvxG0Q7K6sTtw7DeE9OtcmP61m17c5
 qDZOVr2v+JhR7du37y9kvIvhHtitofC1kQtJLE4sm0KRWS9JeN1MpRUcPugtHQ==
From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Date: Tue, 25 Mar 2025 14:09:37 +0100
Message-ID: <20250325130938.598361-1-michael@niedermayer.cc>
X-Mailer: git-send-email 2.48.1
MIME-Version: 1.0
X-GND-State: clean
X-GND-Score: -70
X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduiedvjeefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlhcuvffnffculdeftddmnecujfgurhephffvufffkffoggfgsedtkeertdertddtnecuhfhrohhmpefoihgthhgrvghlucfpihgvuggvrhhmrgihvghruceomhhitghhrggvlhesnhhivgguvghrmhgrhigvrhdrtggtqeenucggtffrrghtthgvrhhnpefhledvvdehgfettdefueevtdeifffhkeeljeetjeeugfelgfffieduheevvefgvdenucfkphepgedurdeiiedrieejrdduudefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepgedurdeiiedrieejrdduudefpdhhvghloheplhhotggrlhhhohhsthdpmhgrihhlfhhrohhmpehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgdpnhgspghrtghpthhtohepuddprhgtphhtthhopehffhhmphgvghdquggvvhgvlhesfhhfmhhpvghgrdhorhhg
X-GND-Sasl: michael@niedermayer.cc
Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/ffv1enc: split updating bitmap
 out of remap write loop
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/20250325130938.598361-1-michael@niedermayer.cc/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

Maybe easier to understand

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/ffv1enc.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index bc59f96746c..0c879fe5ce5 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -1310,6 +1310,19 @@ static int encode_float32_remap_segment(FFV1SliceContext *sc,
         s.run1final = 0;
     }
 
+    if (final) {
+        int64_t last_val = s.last_val;
+        for (int i = s.i; i<s.pixel_num; i++) {
+            int val = sc->unit[s.p][i].val;
+
+            if (last_val != val) {
+                s.compact_index ++;
+                last_val = val;
+            }
+            sc->bitmap[s.p][sc->unit[s.p][i].ndx] = s.compact_index;
+        }
+    }
+
     for (; s.i < s.pixel_num+1; s.i++) {
         int current_mul = s.current_mul_index < 0 ? 1 : FFABS(s.mul[s.current_mul_index]);
         int64_t val;
@@ -1386,12 +1399,8 @@ static int encode_float32_remap_segment(FFV1SliceContext *sc,
                     s.mul[ s.current_mul_index ] *= -1;
                     put_symbol_inline(&s.rc, s.state[0][2], s.mul[ s.current_mul_index ], 0, NULL, NULL);
                 }
-                s.compact_index ++;
             }
         }
-        if (!s.run || s.run1final)
-            if (final && s.i < s.pixel_num)
-                sc->bitmap[s.p][sc->unit[s.p][s.i].ndx] = s.compact_index;
     }
 
     if (update) {
-- 
2.48.1

_______________________________________________
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".