aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Lauss <manuel.lauss@gmail.com>2025-03-11 13:32:21 +0100
committerManuel Lauss <manuel.lauss@gmail.com>2025-03-19 20:58:47 +0100
commit968ffbe64a6f8a93a84cb99cedae0fc4ba8c5fb9 (patch)
treed6609c0db47122f979f56a32df0e79c7187d9f0f
parentaa2f2befaa786b4b0970c08b2837c07ff77ebabc (diff)
downloadffmpeg-968ffbe64a6f8a93a84cb99cedae0fc4ba8c5fb9.tar.gz
avcodec/sanm: codec2 decoder
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>
-rw-r--r--libavcodec/sanm.c20
1 files changed, 20 insertions, 0 deletions
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: