| 2015 | } |
| 2016 | |
| 2017 | static int process_frame_obj(SANMVideoContext *ctx, GetByteContext *gb, |
| 2018 | int xoff, int yoff) |
| 2019 | { |
| 2020 | uint16_t w, h, parm2; |
| 2021 | uint8_t codec, param; |
| 2022 | int16_t left, top; |
| 2023 | int fsc; |
| 2024 | |
| 2025 | codec = bytestream2_get_byteu(gb); |
| 2026 | param = bytestream2_get_byteu(gb); |
| 2027 | left = bytestream2_get_le16u(gb) + xoff; |
| 2028 | top = bytestream2_get_le16u(gb) + yoff; |
| 2029 | w = bytestream2_get_le16u(gb); |
| 2030 | h = bytestream2_get_le16u(gb); |
| 2031 | bytestream2_skip(gb, 2); |
| 2032 | parm2 = bytestream2_get_le16u(gb); |
| 2033 | |
| 2034 | if (w < 1 || h < 1 || w > 640 || h > 480 || left > 640 || top > 480 || left + w <= 0 || top + h <= 0) { |
| 2035 | /* codec45 frames with data for the 2 tables have nonsensical dimensions */ |
| 2036 | if (codec == 45) { |
| 2037 | old_codec45(ctx, gb, 0, 0, 1); |
| 2038 | return 0; |
| 2039 | } |
| 2040 | |
| 2041 | av_log(ctx->avctx, AV_LOG_WARNING, |
| 2042 | "ignoring invalid fobj dimensions: c%d %d %d @ %d %d\n", |
| 2043 | codec, w, h, left, top); |
| 2044 | return 0; |
| 2045 | } |
| 2046 | |
| 2047 | /* codecs with their own buffers */ |
| 2048 | fsc = (codec == 37 || codec == 47 || codec == 48); |
| 2049 | |
| 2050 | /* special case for "Shadows of the Empire" videos: they have top=60 |
| 2051 | * at all frames to vertically center the video in the 640x480 game |
| 2052 | * window, but we don't need that. |
| 2053 | */ |
| 2054 | if ((w == 640) && (h == 272) && (top == 60) && (codec == 47)) |
| 2055 | left = top = 0; |
| 2056 | |
| 2057 | if (!ctx->have_dimensions && (codec != 45)) { |
| 2058 | int xres, yres; |
| 2059 | if (ctx->subversion < 2) { |
| 2060 | /* Rebel Assault 1: 384x242 internal size */ |
| 2061 | xres = 384; |
| 2062 | yres = 242; |
| 2063 | if (w > xres || h > yres) |
| 2064 | return AVERROR_INVALIDDATA; |
| 2065 | ctx->have_dimensions = 1; |
| 2066 | } else if (fsc) { |
| 2067 | /* these codecs work on full frames, trust their dimensions */ |
| 2068 | xres = w; |
| 2069 | yres = h; |
| 2070 | ctx->have_dimensions = 1; |
| 2071 | } else { |
| 2072 | /* detect common sizes */ |
| 2073 | xres = w + left; |
| 2074 | yres = h + top; |
no test coverage detected