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 06C5D4E898
	for <ffmpegdev@gitmailbox.com>; Mon, 17 Mar 2025 17:51:17 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 22E1C687C47;
	Mon, 17 Mar 2025 19:49:40 +0200 (EET)
Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com
 [209.85.221.47])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D0E16687C05
 for <ffmpeg-devel@ffmpeg.org>; Mon, 17 Mar 2025 19:49:25 +0200 (EET)
Received: by mail-wr1-f47.google.com with SMTP id
 ffacd0b85a97d-391342fc1f6so4007486f8f.1
 for <ffmpeg-devel@ffmpeg.org>; Mon, 17 Mar 2025 10:49:25 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742233765; x=1742838565; 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=vdcfDfS7winmon7BSCx3+Fs6E5HC/lX2NU3r1ZK/2JE=;
 b=iLTuh0BUxP065jxGag3q5AKU4s3YseeO/sNVB470ZAcFLvnKTNcRUqNNHtvbo+T4UY
 X62qFZfiGHUiDSULnEy/EzEXaLbKkiuZZH8Rc4VQfoJNQEphqhha7yTdKnOT6MYR9XdL
 Ce8mJm1quxLwLiOfvRjULqiLVIsMObEdMAOJNlfE+U/QP630KD+2EpyGJ/fnBi6Qt2jR
 EXnbCbLtE1TCtBRDD0vmVCYv2EcxX4PIr7JLiCxoNaFTfDqzW9tQVIkrEVxIr4u7CSrC
 0CipxzMOOEaTZ25aFsqGyFWINj71sPKPuPQR//0NA7cj6i9hGZX+2Bz/pjmSkOLCPvH+
 kTTQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742233765; x=1742838565;
 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=vdcfDfS7winmon7BSCx3+Fs6E5HC/lX2NU3r1ZK/2JE=;
 b=QwZp+iqxSrfyqAGcmVL5gZCizxUolk8T+exFQnDZ/5/CLr5HqMjbp9F1drmADa/EOP
 eDIsn48cMk1pEnpmdX+grez8EQbnbuA8F0w4eoO0qKsGo4s0WLAa0lHjecDmezUHYsag
 1O/pocuUQ1oT355PIN5QITFlakkDhGQxtql6b/1Nxo2+rurH81DulzpgNZUF0X424Qjg
 T/UPH9LMZ+Gf2Mz05EXpF6yBcunHkCOnGonrrkmhWPzExMwTe07GytkNlEV8w+VfNwTg
 6SJIJQxGCJU7A/zl8zgyhyoItIvgMUC2vqyZF8sbDaXMLqYgN0420wuMRUqkPXofAPOS
 XwtQ==
X-Gm-Message-State: AOJu0Yy7Gy5ZPBKkNouhIUbBH9Ur/oYAVZ1EkWpwhrNushJsJ3vEkdlN
 91ZPopAqv0UfaEFryjYhXoQm1OltS2uH1+x8M13e4N1d4f/Hbj+TcrgctCAV
X-Gm-Gg: ASbGnctrA3B7QsCeL+lEFy4mPUzRn0URJ5HVvuw+j4r7Uwtqt3ujE+1Nf5C3kj0qEVg
 vHM/5wdU9CKeWgKfkpY7ewQLe73vQ6kzrWy6j3o2s07hbxz9VsoAbyJypLqLgUXIa6MJ142fVrJ
 YauIQlTXyI8XT/9I3+I7J/2QRZX+9P7t3x6LJyqOuxnIS4wCykC6TYkF/xdyeLZuJJ+gvCz1yx0
 bHOBZBwcf7FdgXd11d34z7NJM31lBDD4FMNWUA7LBaUYGWc3fjHo9naS6uZ/NmQakk03Ko1nuCN
 jqwxxx3IfNHOrySjUugFJUTF3yscmOUz6W7qtC1wDkUqiKmk7QUYDq20eUu5IEAgTLKII7f2wc+
 rMjo3pqX3Q5fvjJTzOK1KinIbML6w4g==
X-Google-Smtp-Source: AGHT+IFUKgSiKStgl7RTmPRNaN+rd/n6TYEbsj/C0zsrMTA8a08Gjq/9hBw+TL5TlfeLck3fyGTgIQ==
X-Received: by 2002:adf:8bdb:0:b0:391:1923:5a91 with SMTP id
 ffacd0b85a97d-3971fadd9e3mr11169601f8f.55.1742233765056; 
 Mon, 17 Mar 2025 10:49:25 -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.24
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 17 Mar 2025 10:49:24 -0700 (PDT)
From: Manuel Lauss <manuel.lauss@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Date: Mon, 17 Mar 2025 18:49:08 +0100
Message-ID: <20250317174917.6872-7-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 06/14] 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/20250317174917.6872-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>
---
v2, v3: no changes.

 libavcodec/sanm.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c
index e1471211d6..3fa6c334df 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.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".