35 #define KMVC_KEYFRAME 0x80
36 #define KMVC_PALETTE 0x40
37 #define KMVC_METHOD 0x0F
38 #define MAX_PALSIZE 256
60 #define BLK(data, x, y) data[av_clip((x) + (y) * 320, 0, 320 * 200 -1)]
62 #define kmvc_init_getbits(bb, g) bb.bits = 7; bb.bitbuf = bytestream2_get_byte(g);
64 #define kmvc_getbit(bb, g, res) {\
66 if (bb.bitbuf & (1 << bb.bits)) res = 1; \
69 bb.bitbuf = bytestream2_get_byte(g); \
80 int l0x, l1x, l0y, l1y;
85 for (by = 0; by < h; by += 8)
86 for (bx = 0; bx < w; bx += 8) {
93 val = bytestream2_get_byte(&ctx->
g);
94 for (i = 0; i < 64; i++)
95 BLK(ctx->
cur, bx + (i & 0x7), by + (i >> 3)) = val;
97 for (i = 0; i < 4; i++) {
98 l0x = bx + (i & 1) * 4;
99 l0y = by + (i & 2) * 2;
104 val = bytestream2_get_byte(&ctx->
g);
105 for (j = 0; j < 16; j++)
106 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) = val;
108 val = bytestream2_get_byte(&ctx->
g);
111 for (j = 0; j < 16; j++)
112 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) =
113 BLK(ctx->
cur, l0x + (j & 3) - mx, l0y + (j >> 2) - my);
116 for (j = 0; j < 4; j++) {
117 l1x = l0x + (j & 1) * 2;
123 val = bytestream2_get_byte(&ctx->
g);
124 BLK(ctx->
cur, l1x, l1y) = val;
125 BLK(ctx->
cur, l1x + 1, l1y) = val;
126 BLK(ctx->
cur, l1x, l1y + 1) = val;
127 BLK(ctx->
cur, l1x + 1, l1y + 1) = val;
129 val = bytestream2_get_byte(&ctx->
g);
132 BLK(ctx->
cur, l1x, l1y) =
BLK(ctx->
cur, l1x - mx, l1y - my);
133 BLK(ctx->
cur, l1x + 1, l1y) =
134 BLK(ctx->
cur, l1x + 1 - mx, l1y - my);
135 BLK(ctx->
cur, l1x, l1y + 1) =
136 BLK(ctx->
cur, l1x - mx, l1y + 1 - my);
137 BLK(ctx->
cur, l1x + 1, l1y + 1) =
138 BLK(ctx->
cur, l1x + 1 - mx, l1y + 1 - my);
141 BLK(ctx->
cur, l1x, l1y) = bytestream2_get_byte(&ctx->
g);
142 BLK(ctx->
cur, l1x + 1, l1y) = bytestream2_get_byte(&ctx->
g);
143 BLK(ctx->
cur, l1x, l1y + 1) = bytestream2_get_byte(&ctx->
g);
144 BLK(ctx->
cur, l1x + 1, l1y + 1) = bytestream2_get_byte(&ctx->
g);
161 int l0x, l1x, l0y, l1y;
166 for (by = 0; by < h; by += 8)
167 for (bx = 0; bx < w; bx += 8) {
176 val = bytestream2_get_byte(&ctx->
g);
177 for (i = 0; i < 64; i++)
178 BLK(ctx->
cur, bx + (i & 0x7), by + (i >> 3)) = val;
180 for (i = 0; i < 64; i++)
181 BLK(ctx->
cur, bx + (i & 0x7), by + (i >> 3)) =
182 BLK(ctx->
prev, bx + (i & 0x7), by + (i >> 3));
189 for (i = 0; i < 4; i++) {
190 l0x = bx + (i & 1) * 4;
191 l0y = by + (i & 2) * 2;
196 val = bytestream2_get_byte(&ctx->
g);
197 for (j = 0; j < 16; j++)
198 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) = val;
200 val = bytestream2_get_byte(&ctx->
g);
201 mx = (val & 0xF) - 8;
203 for (j = 0; j < 16; j++)
204 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) =
205 BLK(ctx->
prev, l0x + (j & 3) + mx, l0y + (j >> 2) + my);
208 for (j = 0; j < 4; j++) {
209 l1x = l0x + (j & 1) * 2;
215 val = bytestream2_get_byte(&ctx->
g);
216 BLK(ctx->
cur, l1x, l1y) = val;
217 BLK(ctx->
cur, l1x + 1, l1y) = val;
218 BLK(ctx->
cur, l1x, l1y + 1) = val;
219 BLK(ctx->
cur, l1x + 1, l1y + 1) = val;
221 val = bytestream2_get_byte(&ctx->
g);
222 mx = (val & 0xF) - 8;
224 BLK(ctx->
cur, l1x, l1y) =
BLK(ctx->
prev, l1x + mx, l1y + my);
225 BLK(ctx->
cur, l1x + 1, l1y) =
226 BLK(ctx->
prev, l1x + 1 + mx, l1y + my);
227 BLK(ctx->
cur, l1x, l1y + 1) =
228 BLK(ctx->
prev, l1x + mx, l1y + 1 + my);
229 BLK(ctx->
cur, l1x + 1, l1y + 1) =
230 BLK(ctx->
prev, l1x + 1 + mx, l1y + 1 + my);
233 BLK(ctx->
cur, l1x, l1y) = bytestream2_get_byte(&ctx->
g);
234 BLK(ctx->
cur, l1x + 1, l1y) = bytestream2_get_byte(&ctx->
g);
235 BLK(ctx->
cur, l1x, l1y + 1) = bytestream2_get_byte(&ctx->
g);
236 BLK(ctx->
cur, l1x + 1, l1y + 1) = bytestream2_get_byte(&ctx->
g);
267 header = bytestream2_get_byte(&ctx->
g);
270 if (bytestream2_peek_byte(&ctx->
g) == 127) {
272 for (i = 0; i < 127; i++) {
273 ctx->
pal[i + (header & 0x81)] = bytestream2_get_be24(&ctx->
g);
290 for (i = 1; i <= ctx->
palsize; i++) {
291 ctx->
pal[i] = bytestream2_get_be24(&ctx->
g);
308 blocksize = bytestream2_get_byte(&ctx->
g);
310 if (blocksize != 8 && blocksize != 127) {
314 memset(ctx->
cur, 0, 320 * 200);
318 memcpy(ctx->
cur, ctx->
prev, 320 * 200);
333 for (i = 0; i < avctx->
height; i++) {
334 memcpy(out, src, avctx->
width);
375 for (i = 0; i < 256; i++) {
376 c->
pal[i] = i * 0x10101;
380 av_log(
NULL, 0,
"Extradata missing, decoding may not work properly...\n");
392 for (i = 0; i < 256; i++) {