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 D057A4E8D4
	for <ffmpegdev@gitmailbox.com>; Mon, 17 Mar 2025 17:52:31 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 03FA1687C6E;
	Mon, 17 Mar 2025 19:49:50 +0200 (EET)
Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com
 [209.85.221.51])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9DCA7687C1B
 for <ffmpeg-devel@ffmpeg.org>; Mon, 17 Mar 2025 19:49:28 +0200 (EET)
Received: by mail-wr1-f51.google.com with SMTP id
 ffacd0b85a97d-390fdaf2897so4440553f8f.0
 for <ffmpeg-devel@ffmpeg.org>; Mon, 17 Mar 2025 10:49:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742233768; x=1742838568; darn=ffmpeg.org;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=hbKnn1lARlqgTHU98ABIQtjntffEQZjoLo/BjqaQCtQ=;
 b=GtFno7ShGnIyPZ6TL2J7Tr2biUNhJf1DAJQwJmNDU7hZUg+jPyzJfAFxKdeVZ6yR5o
 AUjzmYI+vC4QVHuttt2VhDdpmTapdDn85UZC21tFiUL4Ivz21/6o+70tHEEvI5sbUtXS
 UHV8SvqOBnz2/l8xS7FduPNix9v4uLBnpIF4BjgNBgWUhkDqShS2Nh/xLMCeVGI7vN7S
 bEGWcSDi5+1TijutDJ2UvO3vvVgYZkXSYkvcp3adZfzKegpTsJMx0XlGwnXrYmsz+qKy
 9yqTkskBUv8prb1RiUrxzjmLm6nRx7UuFpB3H5ZQDDMG1cShGq2Xk0fG9RPrK0ChdueC
 tRyg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742233768; x=1742838568;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=hbKnn1lARlqgTHU98ABIQtjntffEQZjoLo/BjqaQCtQ=;
 b=q8ePPdi+m/7/e1Yf62ySv6Mo5E+tO1YZu2Fe8GLj4OLQJtBNYHLR5aiytImzOyseAs
 /uBHcn4Ho/EluHtu2maTTyw5MTCFKHl2nVjSI5YFwOFyooX9PNs0aRZg3tlyE2BkGH/4
 jT8lq+LxMvF+6R7P6TgcqP0YnGVR5zMj+rKt1wD4itA1vtO1s0/0d/olm3mDs9TCb3+r
 JR2DCgBb7BXGuCxcpT92G+x3cekGOZC56fZ8csleSpN8hhUV4xrvUSTLKZrm1iE146pw
 oSU3e5r+97TbyMAp6od8uVjZvLzkTuElS/xxVePLayAVpPoitPmBxEMvg2AtOLSO2j8W
 c5xw==
X-Gm-Message-State: AOJu0YxrOiScXhzALjE2eIIeFwEFjgpJcg3Ptif7LuCqXs20CWZeXXjo
 8XEcbffGNY4mDqeJx9lsKWZZI8JTf/oZWc6+X7gb/b/xLyqHi23Kiln8COYg
X-Gm-Gg: ASbGncseuDcdl2Zevld4sT1JDG5HvZPU51ZXd4ateI7M5R7LCsgd8VFH/d6qMEefJud
 TdgIRwfqPzI4TCTcodamYj95Zj5mEaSk5VMRYshCDtSiSH0tXPrk2yx4pr+mgrC8Wlv5LKDKxMz
 v44jKxVsxzkPwn53H+XZzDbD6Ivl22g6IG1czQfMbR5u4O2g9hWUd3u9AJXocmxGPbaZP5IepOo
 8YnHy4lybvWZ5/sTdqtpIzFIoVrT8jvU1D6++pfrVtik9dw130hAVmcCc5ngf7C4prhzEO48Ldw
 lrQ47TiUZb5ReAoiDN2GWq4WJpdpr6DFYK8VREmZrJkiwdP0Sdt722QWr2avxaHpt+aav65lVPy
 zY/IcMRdqhkg5pwsfl163ohby2AkWMA==
X-Google-Smtp-Source: AGHT+IGt6eAdRt0tAEbvu5u9/uke2TzA5uQb8SCqud3ciqGD1l0rOfzSIMQCuJd2HHxN44dsurJeHQ==
X-Received: by 2002:a05:6000:1f82:b0:391:11b:c7e9 with SMTP id
 ffacd0b85a97d-3971ee43e56mr11525491f8f.28.1742233767906; 
 Mon, 17 Mar 2025 10:49:27 -0700 (PDT)
Received: from flagship3.deu.mlau.at (p54bc8686.dip0.t-ipconnect.de.
 [84.188.134.134]) by smtp.gmail.com with ESMTPSA id
 ffacd0b85a97d-395c7df35ecsm15809347f8f.16.2025.03.17.10.49.27
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 17 Mar 2025 10:49:27 -0700 (PDT)
From: Manuel Lauss <manuel.lauss@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Date: Mon, 17 Mar 2025 18:49:12 +0100
Message-ID: <20250317174917.6872-11-manuel.lauss@gmail.com>
X-Mailer: git-send-email 2.49.0
In-Reply-To: <20250317174917.6872-1-manuel.lauss@gmail.com>
References: <20250317174917.6872-1-manuel.lauss@gmail.com>
MIME-Version: 1.0
Subject: [FFmpeg-devel] [PATCH v3 10/14] avcodec/sanm: codec37: reimplement
 comp4
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>
Cc: Manuel Lauss <manuel.lauss@gmail.com>
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/20250317174917.6872-11-manuel.lauss@gmail.com/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

Compression 4 code 0 means copy from delta buffer without mv,
AND start of a skip run.  This gets rid of the extra case and column
index manipulation and implements this as it is implemented in the
original game exe, i.e. as a special case for after mv copy.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
---
v3: check bytestream size before reading a byte
v2: no changes

 libavcodec/sanm.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c
index 5bb35df9e0..9486e298cf 100644
--- a/libavcodec/sanm.c
+++ b/libavcodec/sanm.c
@@ -1106,16 +1106,17 @@ static int old_codec37(SANMVideoContext *ctx, int width, int height)
                     t = bytestream2_get_byteu(&ctx->gb);
                     for (k = 0; k < 4; k++)
                         memset(dst + i + k * stride, t, 4);
-               } else if ((compr == 4) && (code == 0)) {
-                    if (bytestream2_get_bytes_left(&ctx->gb) < 1)
-                        return AVERROR_INVALIDDATA;
-                    skip_run = bytestream2_get_byteu(&ctx->gb) + 1;
-                    i -= 4;
                } else {
                     mx = c37_mv[(mvoff * 255 + code) * 2];
                     my = c37_mv[(mvoff * 255 + code) * 2 + 1];
                     codec37_mv(dst + i, prev + i + mx + my * stride,
                                ctx->height, stride, i + mx, j + my);
+
+                    if ((compr == 4) && (code == 0)) {
+                        if (bytestream2_get_bytes_left(&ctx->gb) < 1)
+                            return AVERROR_INVALIDDATA;
+                        skip_run = bytestream2_get_byteu(&ctx->gb);
+                    }
                 }
             }
             dst  += stride * 4;
-- 
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".