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 55CF24CEAF
	for <ffmpegdev@gitmailbox.com>; Sat, 15 Mar 2025 09:34:01 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5BA7368E27F;
	Sat, 15 Mar 2025 11:32:47 +0200 (EET)
Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com
 [209.85.128.45])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 80ED068E26C
 for <ffmpeg-devel@ffmpeg.org>; Sat, 15 Mar 2025 11:32:40 +0200 (EET)
Received: by mail-wm1-f45.google.com with SMTP id
 5b1f17b1804b1-43cf034d4abso5621045e9.3
 for <ffmpeg-devel@ffmpeg.org>; Sat, 15 Mar 2025 02:32:40 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742031160; x=1742635960; 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=44mtEe1EDd3YjFxxIrB8UZUzsFrq1EP77VpW8GUxA0s=;
 b=GmRWFdXjzN/PL+f4qnPsKm5PaWlMzV0Ct7e6vw3lqbunmeNbHdeDvGZB5A5uGcZHJ7
 W9UdXLgLTR2Po32w2bduFPVExUdDPn1YeeICIW7nMO9MVvVP39XbYuUWoUaprlMofJp/
 grjpZny24WwQq/Z/a2OT4CS2sw5vI04MzJVx172Ize7JWpRom4ZJlakWxrmWy/YHfJZi
 fwIZCuMtybhu2VeaSodvcmF/pL+EWE1OGMG1jwB+02u92jSwZmRIJ+KttN1C2qimrk0r
 zZTXCorqZH5aDSDjRp+MUwENREmReGWM6Zlre7BkzEPLvbS/c/P5naEYiMg8qgOMinjm
 UZvw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742031160; x=1742635960;
 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=44mtEe1EDd3YjFxxIrB8UZUzsFrq1EP77VpW8GUxA0s=;
 b=w+y1Gvh1o0WDDpy/Qm/HObLq5AeHyDIrOes2KZVuQEiZT/BgOBoZOqTG+dEKPLSZ+i
 vwIe+KrAD/y0xAvt5G+sc8zb4h0gnEoDZMz5LpOweqh129v5Jp63dAgR2yq3NoGjefm3
 6Ds3eWO3fx3ZlErfNwCVgUgK1B58QWAgG/XcEbBKxC6sBcOaXJKy4d1DotEMwR0vhILN
 zbgigFZ8np01tyyLJBOS30IYN9mO/uXk49pms1KRPcKyILlLdautUWF2qrwnKhSHyTHN
 uOwIKTB5Bji2ciZ3vCWCpuqKd8l2+8DedmBIH+SOHlcTzNYJw7XVEeh8lEzgpZHndHsK
 i/Lg==
X-Gm-Message-State: AOJu0YwD+dU/japbGcNn3ErsjMvNHGtIGaFxC8pOAnlb4tCsg0/wYzua
 otyr6RJz8MVr3ejhWcRszwj5m6bHe7E3a0dcTT4HK71eOLZ4+QZmtc2rFw==
X-Gm-Gg: ASbGncuIaRljh/vyhnSMTiVF2zJSCdbrjyS/OPD9UCD6h4lo5EB4yVKXJD13rzE50TF
 gjCluK1Y6wgf2djFEZ1Zgntgk+aDrtsUKIFkykGe78aOkF40Nd6rzVhIkvBCiaDeJoh7fYkE1Nf
 hCafkUE3gAyLQAU3tV/IGRF0pjYqznNTcbrmENhgs+G+bag7BKG9Ex/ugpG+cp0bq0mwupj/WcM
 ecPoXyROfp/o3ud5+/YDSkx+gD+BgVEA+e/vVxEKKGn4YaNKqYsVMqgXDBmt3lJc0IV5iXVd1cO
 6XgU5xFItUMyphPgvsCzLMqd0VMzvCjWX1Q63AFabZH/pWUdaZEdPZpDUmuAbEXnLodNS+7xSoK
 +4kungksIspEWVGMGSqRfzVKktTucG0HECXCxjs897XTE8kf8LZ/lkJQ=
X-Google-Smtp-Source: AGHT+IGh0lseGnOgjjr9GGBLOnDQb+ysAbdTpnosW2VUgY/5LEynKiHtHTeebiW6rvEjBD+col8Sfw==
X-Received: by 2002:a05:600c:3146:b0:43c:fa24:873e with SMTP id
 5b1f17b1804b1-43d1ec8c391mr73473285e9.13.1742031159718; 
 Sat, 15 Mar 2025 02:32:39 -0700 (PDT)
Received: from flagship3.deu.mlau.at
 (p200300c0271f29004c5623f045c27bca.dip0.t-ipconnect.de.
 [2003:c0:271f:2900:4c56:23f0:45c2:7bca])
 by smtp.gmail.com with ESMTPSA id
 5b1f17b1804b1-43d1fe659b3sm43302905e9.34.2025.03.15.02.32.39
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 15 Mar 2025 02:32:39 -0700 (PDT)
From: Manuel Lauss <manuel.lauss@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Date: Sat, 15 Mar 2025 10:32:13 +0100
Message-ID: <20250315093220.2565-7-manuel.lauss@gmail.com>
X-Mailer: git-send-email 2.48.1
In-Reply-To: <20250315093220.2565-1-manuel.lauss@gmail.com>
References: <20250315093220.2565-1-manuel.lauss@gmail.com>
MIME-Version: 1.0
Subject: [FFmpeg-devel] [PATCH v2 06/13] avcodec/sanm: codec2 decoder
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/20250315093220.2565-7-manuel.lauss@gmail.com/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

this codec consists of 4 byte packets: 2bytes delta-x, 1 byte delta-y
and 1 byte color to put at that spot.
Used in Rebel Assault 1 only.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
---
 libavcodec/sanm.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c
index 0c8ca73508..c5099dc999 100644
--- a/libavcodec/sanm.c
+++ b/libavcodec/sanm.c
@@ -607,6 +607,24 @@ static int old_codec1(SANMVideoContext *ctx, int top,
     return 0;
 }
 
+static int old_codec2(SANMVideoContext *ctx, int top,
+                      int left, int width, int height)
+{
+    uint8_t *dst = (uint8_t *)ctx->frm0, col;
+    int16_t xpos = left, ypos = top;
+
+    while (bytestream2_get_bytes_left(&ctx->gb) > 3) {
+        xpos += bytestream2_get_le16u(&ctx->gb);
+        ypos += bytestream2_get_byteu(&ctx->gb);
+        col = bytestream2_get_byteu(&ctx->gb);
+        if (xpos >= 0 && ypos >= 0 &&
+            xpos < ctx->width && ypos < ctx->height) {
+                *(dst + xpos + ypos * ctx->pitch) = col;
+        }
+    }
+    return 0;
+}
+
 static inline void codec37_mv(uint8_t *dst, const uint8_t *src,
                               int height, int stride, int x, int y)
 {
@@ -1313,6 +1331,8 @@ static int process_frame_obj(SANMVideoContext *ctx)
     case 1:
     case 3:
         return old_codec1(ctx, top, left, w, h, codec == 3);
+    case 2:
+        return old_codec2(ctx, top, left, w, h);
     case 37:
         return old_codec37(ctx, w, h);
     case 47:
-- 
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".