33 #define KMVC_KEYFRAME 0x80
34 #define KMVC_PALETTE 0x40
35 #define KMVC_METHOD 0x0F
36 #define MAX_PALSIZE 256
58 #define BLK(data, x, y) data[(x) + (y) * 320]
60 #define kmvc_init_getbits(bb, g) bb.bits = 7; bb.bitbuf = bytestream2_get_byte(g);
62 #define kmvc_getbit(bb, g, res) {\
64 if (bb.bitbuf & (1 << bb.bits)) res = 1; \
67 bb.bitbuf = bytestream2_get_byte(g); \
78 int l0x, l1x, l0y, l1y;
83 for (by = 0; by < h; by += 8)
84 for (bx = 0; bx < w; bx += 8) {
91 val = bytestream2_get_byte(&ctx->
g);
92 for (i = 0; i < 64; i++)
93 BLK(ctx->
cur, bx + (i & 0x7), by + (i >> 3)) = val;
95 for (i = 0; i < 4; i++) {
96 l0x = bx + (i & 1) * 4;
97 l0y = by + (i & 2) * 2;
102 val = bytestream2_get_byte(&ctx->
g);
103 for (j = 0; j < 16; j++)
104 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) = val;
106 val = bytestream2_get_byte(&ctx->
g);
109 for (j = 0; j < 16; j++)
110 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) =
111 BLK(ctx->
cur, l0x + (j & 3) - mx, l0y + (j >> 2) - my);
114 for (j = 0; j < 4; j++) {
115 l1x = l0x + (j & 1) * 2;
121 val = bytestream2_get_byte(&ctx->
g);
122 BLK(ctx->
cur, l1x, l1y) = val;
123 BLK(ctx->
cur, l1x + 1, l1y) = val;
124 BLK(ctx->
cur, l1x, l1y + 1) = val;
125 BLK(ctx->
cur, l1x + 1, l1y + 1) = val;
127 val = bytestream2_get_byte(&ctx->
g);
130 BLK(ctx->
cur, l1x, l1y) =
BLK(ctx->
cur, l1x - mx, l1y - my);
131 BLK(ctx->
cur, l1x + 1, l1y) =
132 BLK(ctx->
cur, l1x + 1 - mx, l1y - my);
133 BLK(ctx->
cur, l1x, l1y + 1) =
134 BLK(ctx->
cur, l1x - mx, l1y + 1 - my);
135 BLK(ctx->
cur, l1x + 1, l1y + 1) =
136 BLK(ctx->
cur, l1x + 1 - mx, l1y + 1 - my);
139 BLK(ctx->
cur, l1x, l1y) = bytestream2_get_byte(&ctx->
g);
140 BLK(ctx->
cur, l1x + 1, l1y) = bytestream2_get_byte(&ctx->
g);
141 BLK(ctx->
cur, l1x, l1y + 1) = bytestream2_get_byte(&ctx->
g);
142 BLK(ctx->
cur, l1x + 1, l1y + 1) = bytestream2_get_byte(&ctx->
g);
159 int l0x, l1x, l0y, l1y;
164 for (by = 0; by < h; by += 8)
165 for (bx = 0; bx < w; bx += 8) {
174 val = bytestream2_get_byte(&ctx->
g);
175 for (i = 0; i < 64; i++)
176 BLK(ctx->
cur, bx + (i & 0x7), by + (i >> 3)) = val;
178 for (i = 0; i < 64; i++)
179 BLK(ctx->
cur, bx + (i & 0x7), by + (i >> 3)) =
180 BLK(ctx->
prev, bx + (i & 0x7), by + (i >> 3));
187 for (i = 0; i < 4; i++) {
188 l0x = bx + (i & 1) * 4;
189 l0y = by + (i & 2) * 2;
194 val = bytestream2_get_byte(&ctx->
g);
195 for (j = 0; j < 16; j++)
196 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) = val;
198 val = bytestream2_get_byte(&ctx->
g);
199 mx = (val & 0xF) - 8;
201 for (j = 0; j < 16; j++)
202 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) =
203 BLK(ctx->
prev, l0x + (j & 3) + mx, l0y + (j >> 2) + my);
206 for (j = 0; j < 4; j++) {
207 l1x = l0x + (j & 1) * 2;
213 val = bytestream2_get_byte(&ctx->
g);
214 BLK(ctx->
cur, l1x, l1y) = val;
215 BLK(ctx->
cur, l1x + 1, l1y) = val;
216 BLK(ctx->
cur, l1x, l1y + 1) = val;
217 BLK(ctx->
cur, l1x + 1, l1y + 1) = val;
219 val = bytestream2_get_byte(&ctx->
g);
220 mx = (val & 0xF) - 8;
222 BLK(ctx->
cur, l1x, l1y) =
BLK(ctx->
prev, l1x + mx, l1y + my);
223 BLK(ctx->
cur, l1x + 1, l1y) =
224 BLK(ctx->
prev, l1x + 1 + mx, l1y + my);
225 BLK(ctx->
cur, l1x, l1y + 1) =
226 BLK(ctx->
prev, l1x + mx, l1y + 1 + my);
227 BLK(ctx->
cur, l1x + 1, l1y + 1) =
228 BLK(ctx->
prev, l1x + 1 + mx, l1y + 1 + my);
231 BLK(ctx->
cur, l1x, l1y) = bytestream2_get_byte(&ctx->
g);
232 BLK(ctx->
cur, l1x + 1, l1y) = bytestream2_get_byte(&ctx->
g);
233 BLK(ctx->
cur, l1x, l1y + 1) = bytestream2_get_byte(&ctx->
g);
234 BLK(ctx->
cur, l1x + 1, l1y + 1) = bytestream2_get_byte(&ctx->
g);
265 header = bytestream2_get_byte(&ctx->
g);
268 if (bytestream2_peek_byte(&ctx->
g) == 127) {
270 for (i = 0; i < 127; i++) {
271 ctx->
pal[i + (header & 0x81)] = bytestream2_get_be24(&ctx->
g);
288 for (i = 1; i <= ctx->
palsize; i++) {
289 ctx->
pal[i] = bytestream2_get_be24(&ctx->
g);
306 blocksize = bytestream2_get_byte(&ctx->
g);
308 if (blocksize != 8 && blocksize != 127) {
312 memset(ctx->
cur, 0, 320 * 200);
316 memcpy(ctx->
cur, ctx->
prev, 320 * 200);
331 for (i = 0; i < avctx->
height; i++) {
332 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++) {