Compression 4 code 0 means copy from delta buffer without mv, AND start of a skip run. This gets rid of the extra case and column index manipulation and implements this as it is implemented in the original game exe, i.e. as a special case for after mv copy.
Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -1106,16 +1106,17 @@ static int old_codec37(SANMVideoContext *ctx, int width, int height) · 1105 unmodified lines | |||
| 1106 | t = bytestream2_get_byteu(&ctx->gb); | 1106 | t = bytestream2_get_byteu(&ctx->gb); |
| 1107 | for (k = 0; k < 4; k++) | 1107 | for (k = 0; k < 4; k++) |
| 1108 | memset(dst + i + k * stride, t, 4); | 1108 | memset(dst + i + k * stride, t, 4); |
| 1109 | } else if ((compr == 4) && (code == 0)) { | ||
| 1110 | if (bytestream2_get_bytes_left(&ctx->gb) < 1) | ||
| 1111 | return AVERROR_INVALIDDATA; | ||
| 1112 | skip_run = bytestream2_get_byteu(&ctx->gb) + 1; | ||
| 1113 | i -= 4; | ||
| 1114 | } else { | 1109 | } else { |
| 1115 | mx = c37_mv[(mvoff * 255 + code) * 2]; | 1110 | mx = c37_mv[(mvoff * 255 + code) * 2]; |
| 1116 | my = c37_mv[(mvoff * 255 + code) * 2 + 1]; | 1111 | my = c37_mv[(mvoff * 255 + code) * 2 + 1]; |
| 1117 | codec37_mv(dst + i, prev + i + mx + my * stride, | 1112 | codec37_mv(dst + i, prev + i + mx + my * stride, |
| 1118 | ctx->height, stride, i + mx, j + my); | 1113 | ctx->height, stride, i + mx, j + my); |
| 1114 | |||
| 1115 | if ((compr == 4) && (code == 0)) { | ||
| 1116 | if (bytestream2_get_bytes_left(&ctx->gb) < 1) | ||
| 1117 | return AVERROR_INVALIDDATA; | ||
| 1118 | skip_run = bytestream2_get_byteu(&ctx->gb); | ||
| 1119 | } | ||
| 1119 | } | 1120 | } |
| 1120 | } | 1121 | } |
| 1121 | dst += stride * 4; | 1122 | dst += stride * 4; |