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 256AF4E89F
	for <ffmpegdev@gitmailbox.com>; Mon, 17 Mar 2025 17:52:06 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5E0B4687C5A;
	Mon, 17 Mar 2025 19:49:46 +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 651FD687C11
 for <ffmpeg-devel@ffmpeg.org>; Mon, 17 Mar 2025 19:49:27 +0200 (EET)
Received: by mail-wm1-f45.google.com with SMTP id
 5b1f17b1804b1-43cfa7e7f54so14175775e9.1
 for <ffmpeg-devel@ffmpeg.org>; Mon, 17 Mar 2025 10:49:27 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1742233767; x=1742838567; 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=WYFeZpt6qe23sxaQrQ/MgJIne/9divyxkRdlFisnryw=;
 b=fTLrtfrvBciqH1WgfzGofpfxBkjiX5iRJPdc+LC4VEQMay+d2MNmTs4hCOpZvEvvn7
 Dmbrr5GFRFL0WwYPHTf5iZwX9TAZbZoqzrzBjEzr+/b5yOsaRIIkaJUjs9MQcxAlw2bf
 1cvBknkrdoV2stCq+jJ+o+N/PJp6NIx+JRIkexWs4Ju298ydd/386Zgtw127gezmBC08
 3gn+xJMbh8MGM0cNtdlvKY0XJc/P1X5rI6UBpshQWgRnWR2DT7cK5U2CDhZqely+L3YX
 gmSjYLkEsyjlA7gitvI/ZhwV5KZpATuZYsfR5GY2KxAaJA3SX/d+QdCQySh82Fd51Jrw
 bDbg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1742233767; x=1742838567;
 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=WYFeZpt6qe23sxaQrQ/MgJIne/9divyxkRdlFisnryw=;
 b=TL/LlJXbdatqESF8d8xGOs5TLAI6s2XOW/PXZdDItt0DYocOi7QrLhwyrIR/uWAJJG
 iU00xVtStbw7+TjYbK5w569B5O79H3MTqRCwr5qHLNB8PUw/XkJl9LSk714yv1x5e7jK
 IvVXdXuItVMNco7SaerG+S1Rwnr0dOOFvBkOuJ6SzWCsHN59OMq8YU1r0zNhpxbyHAIi
 aYhR0fWn8jENzTD+gipVl4c4FeQ2FqzB64abIxUAriugTZcdLsHL/DzabmKDOv7u3BLk
 MQQ4/c0yVwFoYwAqFqAyh3KqTuRh9vDhevpyHWUX/oKKVh6TcWf8bQTbDUv+FttuVzfj
 Q+vQ==
X-Gm-Message-State: AOJu0YyiPstDWh53deNlbjoN0FIU0y4I2NfX2aoOqwrYMksQ2TP7SHpj
 kfsArHXxdrwbQfbode8968baPS2tuNdwrIiQA549lmfHa7dfAor9jJ5ddW0Y
X-Gm-Gg: ASbGnct3ZcYhyiRdvxZlt06vS58IApWsr4pa0ETjvaA0f2rPANOJW0dDgAGHe98T0Td
 5/sVMyLtVpnu8hlk0czayNf2f4ceWpB3Xr52JpXYCeWZQDtVS8qAEK1kizGL3eZWQlj91aUNcRT
 jMfx0MbZaGM/bjfsCuBJQgM6vLET1A48YGp5jXyL8d1awYzAMaK80POOW4aPN7Rb/39z2cgU01L
 GJsg0HbZ0cgdyGTRBaPXVfj/URO/zI5m+V/P78ro+dXP8q5iv7P/uI6Pc6Z7gb+1hDFiOUFnJ9h
 RaxZw3HlUEeRKJS3saeXGsFwiPxwyJq3td9arETDAsM1Ue0myRKTC29N9/cU36e8zWrCQSCjqKm
 VtDe6unJlvLTqcHB9VL95cEUC+m/rLw==
X-Google-Smtp-Source: AGHT+IEMhlvVlQJCD9L/p302lEYBEkYf9Izl9ROJA58Gjt8+/Oe6r+1iUf4yg8bwWqHhKfH8jJOHZQ==
X-Received: by 2002:a05:600c:4fc4:b0:439:5f04:4f8d with SMTP id
 5b1f17b1804b1-43d3908ac65mr3028735e9.12.1742233766394; 
 Mon, 17 Mar 2025 10:49:26 -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.25
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Mon, 17 Mar 2025 10:49:26 -0700 (PDT)
From: Manuel Lauss <manuel.lauss@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Date: Mon, 17 Mar 2025 18:49:10 +0100
Message-ID: <20250317174917.6872-9-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 08/14] avcodec/sanm: codec21 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-9-manuel.lauss@gmail.com/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

similar to codec23, this one alternatingly skips and writes bytes.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
---
v2,v3: no changes

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

diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c
index 6302c62f43..95ff8596ab 100644
--- a/libavcodec/sanm.c
+++ b/libavcodec/sanm.c
@@ -614,6 +614,49 @@ static int old_codec23(SANMVideoContext *ctx, int top, int left, int width,
     return 0;
 }
 
+static int old_codec21(SANMVideoContext *ctx, int top, int left, int width,
+                       int height)
+{
+    const uint32_t maxpxo = ctx->height * ctx->pitch;
+    uint8_t *dst = (uint8_t *)ctx->frm0, c;
+    int i, j, k, pc, sk, pxoff;
+
+    dst = (uint8_t *)ctx->frm0;
+    for (i = 0; i < height; i++) {
+        if (bytestream2_get_bytes_left(&ctx->gb) < 2)
+            return 0;
+        pxoff = left + ((top + i) * ctx->pitch);
+        k = bytestream2_get_le16u(&ctx->gb);
+        sk = 1;
+        pc = 0;
+        while (k > 0 && pc <= width) {
+            if (bytestream2_get_bytes_left(&ctx->gb) < 2)
+                return AVERROR_INVALIDDATA;
+            j = bytestream2_get_le16u(&ctx->gb);
+            k -= 2;
+            if (sk) {
+                pxoff += j;
+                pc += j;
+            } else {
+                if (bytestream2_get_bytes_left(&ctx->gb) < (j + 1))
+                    return AVERROR_INVALIDDATA;
+                do {
+                    c = bytestream2_get_byteu(&ctx->gb);
+                    if (pxoff >=0 && pxoff < maxpxo) {
+                        *(dst + pxoff) = c;
+                    }
+                    pxoff++;
+                    pc++;
+                    j--;
+                    k--;
+                } while (j > -1);
+            }
+            sk ^= 1;
+        }
+    }
+    return 0;
+}
+
 static int old_codec1(SANMVideoContext *ctx, int top,
                       int left, int width, int height, int opaque)
 {
@@ -1393,6 +1436,8 @@ static int process_frame_obj(SANMVideoContext *ctx)
         return old_codec1(ctx, top, left, w, h, codec == 3);
     case 2:
         return old_codec2(ctx, top, left, w, h);
+    case 21:
+        return old_codec21(ctx, top, left, w, h);
     case 23:
         return old_codec23(ctx, top, left, w, h, param, parm2);
     case 37:
-- 
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".