1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

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>
This commit is contained in:
Manuel Lauss
2025-03-11 13:32:21 +01:00
parent aa2f2befaa
commit 968ffbe64a

View File

@ -607,6 +607,24 @@ static int old_codec1(SANMVideoContext *ctx, int top,
return 0; 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, static inline void codec37_mv(uint8_t *dst, const uint8_t *src,
int height, int stride, int x, int y) int height, int stride, int x, int y)
{ {
@ -1313,6 +1331,8 @@ static int process_frame_obj(SANMVideoContext *ctx)
case 1: case 1:
case 3: case 3:
return old_codec1(ctx, top, left, w, h, codec == 3); return old_codec1(ctx, top, left, w, h, codec == 3);
case 2:
return old_codec2(ctx, top, left, w, h);
case 37: case 37:
return old_codec37(ctx, w, h); return old_codec37(ctx, w, h);
case 47: case 47: