34 #define KMVC_KEYFRAME 0x80
35 #define KMVC_PALETTE 0x40
36 #define KMVC_METHOD 0x0F
37 #define MAX_PALSIZE 256
59 #define BLK(data, x, y) data[(x) + (y) * 320]
61 #define kmvc_init_getbits(bb, g) bb.bits = 7; bb.bitbuf = bytestream2_get_byte(g);
63 #define kmvc_getbit(bb, g, res) {\
65 if (bb.bitbuf & (1 << bb.bits)) res = 1; \
68 bb.bitbuf = bytestream2_get_byte(g); \
79 int l0x, l1x, l0y, l1y;
84 for (by = 0; by < h; by += 8)
85 for (bx = 0; bx < w; bx += 8) {
92 val = bytestream2_get_byte(&ctx->
g);
93 for (i = 0; i < 64; i++)
94 BLK(ctx->
cur, bx + (i & 0x7), by + (i >> 3)) = val;
96 for (i = 0; i < 4; i++) {
97 l0x = bx + (i & 1) * 4;
98 l0y = by + (i & 2) * 2;
103 val = bytestream2_get_byte(&ctx->
g);
104 for (j = 0; j < 16; j++)
105 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) = val;
107 val = bytestream2_get_byte(&ctx->
g);
110 if ((l0x-mx) + 320*(l0y-my) < 0 || (l0x-mx) + 320*(l0y-my) > 316*196) {
114 for (j = 0; j < 16; j++)
115 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) =
116 BLK(ctx->
cur, l0x + (j & 3) - mx, l0y + (j >> 2) - my);
119 for (j = 0; j < 4; j++) {
120 l1x = l0x + (j & 1) * 2;
126 val = bytestream2_get_byte(&ctx->
g);
127 BLK(ctx->
cur, l1x, l1y) = val;
128 BLK(ctx->
cur, l1x + 1, l1y) = val;
129 BLK(ctx->
cur, l1x, l1y + 1) = val;
130 BLK(ctx->
cur, l1x + 1, l1y + 1) = val;
132 val = bytestream2_get_byte(&ctx->
g);
135 if ((l1x-mx) + 320*(l1y-my) < 0 || (l1x-mx) + 320*(l1y-my) > 318*198) {
139 BLK(ctx->
cur, l1x, l1y) =
BLK(ctx->
cur, l1x - mx, l1y - my);
140 BLK(ctx->
cur, l1x + 1, l1y) =
141 BLK(ctx->
cur, l1x + 1 - mx, l1y - my);
142 BLK(ctx->
cur, l1x, l1y + 1) =
143 BLK(ctx->
cur, l1x - mx, l1y + 1 - my);
144 BLK(ctx->
cur, l1x + 1, l1y + 1) =
145 BLK(ctx->
cur, l1x + 1 - mx, l1y + 1 - my);
148 BLK(ctx->
cur, l1x, l1y) = bytestream2_get_byte(&ctx->
g);
149 BLK(ctx->
cur, l1x + 1, l1y) = bytestream2_get_byte(&ctx->
g);
150 BLK(ctx->
cur, l1x, l1y + 1) = bytestream2_get_byte(&ctx->
g);
151 BLK(ctx->
cur, l1x + 1, l1y + 1) = bytestream2_get_byte(&ctx->
g);
168 int l0x, l1x, l0y, l1y;
173 for (by = 0; by < h; by += 8)
174 for (bx = 0; bx < w; bx += 8) {
183 val = bytestream2_get_byte(&ctx->
g);
184 for (i = 0; i < 64; i++)
185 BLK(ctx->
cur, bx + (i & 0x7), by + (i >> 3)) = val;
187 for (i = 0; i < 64; i++)
188 BLK(ctx->
cur, bx + (i & 0x7), by + (i >> 3)) =
189 BLK(ctx->
prev, bx + (i & 0x7), by + (i >> 3));
196 for (i = 0; i < 4; i++) {
197 l0x = bx + (i & 1) * 4;
198 l0y = by + (i & 2) * 2;
203 val = bytestream2_get_byte(&ctx->
g);
204 for (j = 0; j < 16; j++)
205 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) = val;
207 val = bytestream2_get_byte(&ctx->
g);
208 mx = (val & 0xF) - 8;
210 if ((l0x+mx) + 320*(l0y+my) < 0 || (l0x+mx) + 320*(l0y+my) > 318*198) {
214 for (j = 0; j < 16; j++)
215 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) =
216 BLK(ctx->
prev, l0x + (j & 3) + mx, l0y + (j >> 2) + my);
219 for (j = 0; j < 4; j++) {
220 l1x = l0x + (j & 1) * 2;
226 val = bytestream2_get_byte(&ctx->
g);
227 BLK(ctx->
cur, l1x, l1y) = val;
228 BLK(ctx->
cur, l1x + 1, l1y) = val;
229 BLK(ctx->
cur, l1x, l1y + 1) = val;
230 BLK(ctx->
cur, l1x + 1, l1y + 1) = val;
232 val = bytestream2_get_byte(&ctx->
g);
233 mx = (val & 0xF) - 8;
235 if ((l1x+mx) + 320*(l1y+my) < 0 || (l1x+mx) + 320*(l1y+my) > 318*198) {
239 BLK(ctx->
cur, l1x, l1y) =
BLK(ctx->
prev, l1x + mx, l1y + my);
240 BLK(ctx->
cur, l1x + 1, l1y) =
241 BLK(ctx->
prev, l1x + 1 + mx, l1y + my);
242 BLK(ctx->
cur, l1x, l1y + 1) =
243 BLK(ctx->
prev, l1x + mx, l1y + 1 + my);
244 BLK(ctx->
cur, l1x + 1, l1y + 1) =
245 BLK(ctx->
prev, l1x + 1 + mx, l1y + 1 + my);
248 BLK(ctx->
cur, l1x, l1y) = bytestream2_get_byte(&ctx->
g);
249 BLK(ctx->
cur, l1x + 1, l1y) = bytestream2_get_byte(&ctx->
g);
250 BLK(ctx->
cur, l1x, l1y + 1) = bytestream2_get_byte(&ctx->
g);
251 BLK(ctx->
cur, l1x + 1, l1y + 1) = bytestream2_get_byte(&ctx->
g);
283 header = bytestream2_get_byte(&ctx->
g);
286 if (bytestream2_peek_byte(&ctx->
g) == 127) {
288 for (i = 0; i < 127; i++) {
289 ctx->
pal[i + (header & 0x81)] = 0xFFU << 24 | bytestream2_get_be24(&ctx->
g);
306 for (i = 1; i <= ctx->
palsize; i++) {
307 ctx->
pal[i] = 0xFF
U << 24 | bytestream2_get_be24(&ctx->
g);
324 blocksize = bytestream2_get_byte(&ctx->
g);
326 if (blocksize != 8 && blocksize != 127) {
330 memset(ctx->
cur, 0, 320 * 200);
334 memcpy(ctx->
cur, ctx->
prev, 320 * 200);
349 for (i = 0; i < avctx->
height; i++) {
350 memcpy(out, src, avctx->
width);
393 for (i = 0; i < 256; i++) {
394 c->
pal[i] = 0xFF
U << 24 | i * 0x10101;
399 "Extradata missing, decoding may not work properly...\n");
412 for (i = 0; i < 256; i++) {