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

avcodec/sanm: fix codec3

codec3 is codec1 which writes zero values instead of skipping them.
This fixes a lot of RA1 videos.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
This commit is contained in:
Manuel Lauss
2025-03-11 13:02:14 +01:00
parent fd9b92b216
commit aa2f2befaa

View File

@ -558,7 +558,7 @@ static int rle_decode(SANMVideoContext *ctx, uint8_t *dst, const int out_size)
} }
static int old_codec1(SANMVideoContext *ctx, int top, static int old_codec1(SANMVideoContext *ctx, int top,
int left, int width, int height) int left, int width, int height, int opaque)
{ {
int i, j, len, flag, code, val, end, pxoff; int i, j, len, flag, code, val, end, pxoff;
const int maxpxo = ctx->height * ctx->pitch; const int maxpxo = ctx->height * ctx->pitch;
@ -581,7 +581,7 @@ static int old_codec1(SANMVideoContext *ctx, int top,
code = (code >> 1) + 1; code = (code >> 1) + 1;
if (flag) { if (flag) {
val = bytestream2_get_byteu(&ctx->gb); val = bytestream2_get_byteu(&ctx->gb);
if (val) { if (val || opaque) {
for (j = 0; j < code; j++) { for (j = 0; j < code; j++) {
if (pxoff >= 0 && pxoff < maxpxo) if (pxoff >= 0 && pxoff < maxpxo)
*(dst + pxoff) = val; *(dst + pxoff) = val;
@ -595,7 +595,7 @@ static int old_codec1(SANMVideoContext *ctx, int top,
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
for (j = 0; j < code; j++) { for (j = 0; j < code; j++) {
val = bytestream2_get_byteu(&ctx->gb); val = bytestream2_get_byteu(&ctx->gb);
if ((pxoff >= 0) && (pxoff < maxpxo) && val) if ((pxoff >= 0) && (pxoff < maxpxo) && (val || opaque))
*(dst + pxoff) = val; *(dst + pxoff) = val;
pxoff++; pxoff++;
} }
@ -1312,7 +1312,7 @@ static int process_frame_obj(SANMVideoContext *ctx)
switch (codec) { switch (codec) {
case 1: case 1:
case 3: case 3:
return old_codec1(ctx, top, left, w, h); return old_codec1(ctx, top, left, w, h, codec == 3);
case 37: case 37:
return old_codec37(ctx, w, h); return old_codec37(ctx, w, h);
case 47: case 47: