[FFmpeg-devel] [PATCH v3 13/14] avcodec/sanm: codec20 decoder

Manuel Lauss manuel.lauss at gmail.com
Mon Mar 17 19:49:15 EET 2025


codec20 is raw uncompressed image data.

It is used internally in Rebel Assault 1 as a special format for STOR
(when parameter for STOR is set to 3), and is used again in
the "Full Throttle Remaster" from 2017.

Signed-off-by: Manuel Lauss <manuel.lauss at gmail.com>
---
v3: newly added

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

diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c
index 730ec14b98..d8276f9d85 100644
--- a/libavcodec/sanm.c
+++ b/libavcodec/sanm.c
@@ -950,6 +950,24 @@ static int old_codec2(SANMVideoContext *ctx, GetByteContext *gb, int top,
     return 0;
 }
 
+static int old_codec20(SANMVideoContext *ctx, int w, int h)
+{
+    uint8_t *dst = (uint8_t *)ctx->frm0;
+
+    if (bytestream2_get_bytes_left(&ctx->gb) < w * h)
+        return AVERROR_INVALIDDATA;
+
+    if (w == ctx->pitch) {
+        bytestream2_get_bufferu(&ctx->gb, dst, w * h);
+    } else {
+        for (int i = 0; i < h; i++) {
+            bytestream2_get_bufferu(&ctx->gb, dst, w);
+            dst += ctx->pitch;
+        }
+    }
+    return 0;
+}
+
 static inline void codec37_mv(uint8_t *dst, const uint8_t *src,
                               int height, int stride, int x, int y)
 {
@@ -1673,6 +1691,8 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb)
     case 33:
     case 34:
         return old_codec4(ctx, gb, top, left, w, h, param, parm2, codec);
+    case 20:
+        return old_codec20(ctx, w, h);
     case 21:
         return old_codec21(ctx, gb, top, left, w, h);
     case 23:
-- 
2.49.0



More information about the ffmpeg-devel mailing list