From: Manuel Lauss <manuel.lauss@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Manuel Lauss <manuel.lauss@gmail.com> Subject: [FFmpeg-devel] [PATCH v2 2/3] avcodec/sanm: recognize common FOBJ sizes Date: Tue, 6 May 2025 17:40:55 +0200 Message-ID: <20250506154056.920553-3-manuel.lauss@gmail.com> (raw) In-Reply-To: <20250506154056.920553-1-manuel.lauss@gmail.com> Change the size detection a bit to recognize common video sizes, as the FOBJ codecs>=37 cannot always be trusted, since they can be embedded in a larger frame. Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com> --- v2: reworded description. libavcodec/sanm.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c index e436b5ab8e..63f5c2cc7f 100644 --- a/libavcodec/sanm.c +++ b/libavcodec/sanm.c @@ -1603,6 +1603,7 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb) uint16_t w, h, parm2; uint8_t codec, param; int16_t left, top; + int fsc, sote; codec = bytestream2_get_byteu(gb); param = bytestream2_get_byteu(gb); @@ -1620,6 +1621,14 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb) return 0; } + /* codecs with their own buffers */ + fsc = (codec == 37 || codec == 47 || codec == 48); + + /* special case for "Shadows of the Empire" videos */ + sote = ((w == 640) && (h == 272) && (codec == 47)); + if (sote) + left = top = 0; + if (!ctx->have_dimensions) { int xres, yres; if (ctx->subversion < 2) { @@ -1633,12 +1642,24 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb) yres = h; ctx->have_dimensions = 1; } else { - /* Rebel Assault 2: 424x260 internal size */ - if (((left + w) == 424) && ((top + h) == 260)) + /* detect common sizes */ + xres = w + left; + yres = h + top; + if (sote) { + /* SotE: has top=60 at all times to center video + * inside the 640x480 game window + */ + xres = w; + yres = h; ctx->have_dimensions = 1; + } else if (((xres == 424) && (yres == 260)) || /* RA1 */ + ((xres == 320) && (yres == 200)) || /* ft/dig/... */ + ((xres == 640) && (yres == 480))) { /* ol/comi/mots... */ + ctx->have_dimensions = 1; + } - xres = FFMAX(left + w, ctx->width); - yres = FFMAX(top + h, ctx->height); + xres = FFMAX(xres, ctx->width); + yres = FFMAX(yres, ctx->height); } if (ctx->width < xres || ctx->height < yres) { @@ -1652,8 +1673,7 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb) } } } else { - if (((left + w > ctx->width) || (top + h > ctx->height)) - && (codec >= 37)) { + if (((left + w > ctx->width) || (top + h > ctx->height)) && fsc) { /* correct unexpected overly large frames: this happens * for instance with The Dig's sq1.san video: it has a few * (all black) 640x480 frames halfway in, while the rest is @@ -1671,7 +1691,7 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb) */ if (ctx->first_fob) { ctx->first_fob = 0; - if (codec < 37) + if (!fsc) memset(ctx->frm0, 0, ctx->frm0_size); } -- 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".
next prev parent reply other threads:[~2025-05-06 15:41 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-05-06 15:40 [FFmpeg-devel] [PATCH v2 0/3] avcodec/sanm: Fixes for "StarWars - Making Magic" Manuel Lauss 2025-05-06 15:40 ` [FFmpeg-devel] [PATCH v1 1/3] avcodec/sanm: ignore codec48 compression type 6 Manuel Lauss 2025-05-06 15:40 ` Manuel Lauss [this message] 2025-05-06 15:40 ` [FFmpeg-devel] [PATCH v2 3/3] avcodec/sanm: support "StarWars - Making Magic" video Manuel Lauss 2025-05-07 7:00 ` [FFmpeg-devel] [PATCH v2 0/3] avcodec/sanm: Fixes for "StarWars - Making Magic" Manuel Lauss
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250506154056.920553-3-manuel.lauss@gmail.com \ --to=manuel.lauss@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git