History

avcodec/sanm: recognize common FOBJ sizes

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.

Manuel Lauss committed 1 year ago

Commit 9369ebf1 parent 7f0b7b01 file · +27 −7Browse files

Unified · Split

libavcodec/sanm.c+27−7
@@ -1603,6 +1603,7 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb) · 1602 unmodified lines
16031603 uint16_t w, h, parm2;
16041604 uint8_t codec, param;
16051605 int16_t left, top;
1606+ int fsc, sote;
16061607
16071608 codec = bytestream2_get_byteu(gb);
16081609 param = bytestream2_get_byteu(gb);
@@ -1620,6 +1621,14 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb) · 11 unmodified lines
16201621 return 0;
16211622 }
16221623
1624+ /* codecs with their own buffers */
1625+ fsc = (codec == 37 || codec == 47 || codec == 48);
1626+
1627+ /* special case for "Shadows of the Empire" videos */
1628+ sote = ((w == 640) && (h == 272) && (codec == 47));
1629+ if (sote)
1630+ left = top = 0;
1631+
16231632 if (!ctx->have_dimensions) {
16241633 int xres, yres;
16251634 if (ctx->subversion < 2) {
@@ -1633,12 +1642,24 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb) · 7 unmodified lines
16331642 yres = h;
16341643 ctx->have_dimensions = 1;
16351644 } else {
1636− /* Rebel Assault 2: 424x260 internal size */
1637− if (((left + w) == 424) && ((top + h) == 260))
1645+ /* detect common sizes */
1646+ xres = w + left;
1647+ yres = h + top;
1648+ if (sote) {
1649+ /* SotE: has top=60 at all times to center video
1650+ * inside the 640x480 game window
1651+ */
1652+ xres = w;
1653+ yres = h;
16381654 ctx->have_dimensions = 1;
1655+ } else if (((xres == 424) && (yres == 260)) || /* RA1 */
1656+ ((xres == 320) && (yres == 200)) || /* ft/dig/... */
1657+ ((xres == 640) && (yres == 480))) { /* ol/comi/mots... */
1658+ ctx->have_dimensions = 1;
1659+ }
16391660
1640− xres = FFMAX(left + w, ctx->width);
1641− yres = FFMAX(top + h, ctx->height);
1661+ xres = FFMAX(xres, ctx->width);
1662+ yres = FFMAX(yres, ctx->height);
16421663 }
16431664
16441665 if (ctx->width < xres || ctx->height < yres) {
@@ -1652,8 +1673,7 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb) · 7 unmodified lines
16521673 }
16531674 }
16541675 } else {
1655− if (((left + w > ctx->width) || (top + h > ctx->height))
1656− && (codec >= 37)) {
1676+ if (((left + w > ctx->width) || (top + h > ctx->height)) && fsc) {
16571677 /* correct unexpected overly large frames: this happens
16581678 * for instance with The Dig's sq1.san video: it has a few
16591679 * (all black) 640x480 frames halfway in, while the rest is
@@ -1671,7 +1691,7 @@ static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb) · 11 unmodified lines
16711691 */
16721692 if (ctx->first_fob) {
16731693 ctx->first_fob = 0;
1674− if (codec < 37)
1694+ if (!fsc)
16751695 memset(ctx->frm0, 0, ctx->frm0_size);
16761696 }
16771697

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t