34 #define KMVC_KEYFRAME 0x80
35 #define KMVC_PALETTE 0x40
36 #define KMVC_METHOD 0x0F
37 #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 if ((l0x-mx) + 320*(l0y-my) < 0 || (l0x-mx) + 320*(l0y-my) > 316*196) {
113 for (j = 0; j < 16; j++)
114 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) =
115 BLK(ctx->
cur, l0x + (j & 3) - mx, l0y + (j >> 2) - my);
118 for (j = 0; j < 4; j++) {
119 l1x = l0x + (j & 1) * 2;
125 val = bytestream2_get_byte(&ctx->
g);
131 val = bytestream2_get_byte(&ctx->
g);
134 if ((l1x-mx) + 320*(l1y-my) < 0 || (l1x-mx) + 320*(l1y-my) > 318*198) {
138 BLK(ctx->
cur, l1x, l1y) =
BLK(ctx->
cur, l1x - mx, l1y - my);
139 BLK(ctx->
cur, l1x + 1, l1y) =
140 BLK(ctx->
cur, l1x + 1 - mx, l1y - my);
141 BLK(ctx->
cur, l1x, l1y + 1) =
142 BLK(ctx->
cur, l1x - mx, l1y + 1 - my);
143 BLK(ctx->
cur, l1x + 1, l1y + 1) =
144 BLK(ctx->
cur, l1x + 1 - mx, l1y + 1 - my);
147 BLK(ctx->
cur, l1x, l1y) = bytestream2_get_byte(&ctx->
g);
148 BLK(ctx->
cur, l1x + 1, l1y) = bytestream2_get_byte(&ctx->
g);
149 BLK(ctx->
cur, l1x, l1y + 1) = bytestream2_get_byte(&ctx->
g);
150 BLK(ctx->
cur, l1x + 1, l1y + 1) = bytestream2_get_byte(&ctx->
g);
167 int l0x, l1x, l0y, l1y;
172 for (by = 0; by < h; by += 8)
173 for (bx = 0; bx < w; bx += 8) {
182 val = bytestream2_get_byte(&ctx->
g);
183 for (i = 0; i < 64; i++)
184 BLK(ctx->
cur, bx + (i & 0x7), by + (i >> 3)) =
val;
186 for (i = 0; i < 64; i++)
187 BLK(ctx->
cur, bx + (i & 0x7), by + (i >> 3)) =
188 BLK(ctx->
prev, bx + (i & 0x7), by + (i >> 3));
195 for (i = 0; i < 4; i++) {
196 l0x = bx + (i & 1) * 4;
197 l0y = by + (i & 2) * 2;
202 val = bytestream2_get_byte(&ctx->
g);
203 for (j = 0; j < 16; j++)
204 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) =
val;
206 val = bytestream2_get_byte(&ctx->
g);
207 mx = (val & 0xF) - 8;
209 if ((l0x+mx) + 320*(l0y+my) < 0 || (l0x+mx) + 320*(l0y+my) > 318*198) {
213 for (j = 0; j < 16; j++)
214 BLK(ctx->
cur, l0x + (j & 3), l0y + (j >> 2)) =
215 BLK(ctx->
prev, l0x + (j & 3) + mx, l0y + (j >> 2) + my);
218 for (j = 0; j < 4; j++) {
219 l1x = l0x + (j & 1) * 2;
225 val = bytestream2_get_byte(&ctx->
g);
231 val = bytestream2_get_byte(&ctx->
g);
232 mx = (val & 0xF) - 8;
234 if ((l1x+mx) + 320*(l1y+my) < 0 || (l1x+mx) + 320*(l1y+my) > 318*198) {
238 BLK(ctx->
cur, l1x, l1y) =
BLK(ctx->
prev, l1x + mx, l1y + my);
239 BLK(ctx->
cur, l1x + 1, l1y) =
240 BLK(ctx->
prev, l1x + 1 + mx, l1y + my);
241 BLK(ctx->
cur, l1x, l1y + 1) =
242 BLK(ctx->
prev, l1x + mx, l1y + 1 + my);
243 BLK(ctx->
cur, l1x + 1, l1y + 1) =
244 BLK(ctx->
prev, l1x + 1 + mx, l1y + 1 + my);
247 BLK(ctx->
cur, l1x, l1y) = bytestream2_get_byte(&ctx->
g);
248 BLK(ctx->
cur, l1x + 1, l1y) = bytestream2_get_byte(&ctx->
g);
249 BLK(ctx->
cur, l1x, l1y + 1) = bytestream2_get_byte(&ctx->
g);
250 BLK(ctx->
cur, l1x + 1, l1y + 1) = bytestream2_get_byte(&ctx->
g);
277 header = bytestream2_get_byte(&ctx->
g);
280 if (bytestream2_peek_byte(&ctx->
g) == 127) {
282 for (i = 0; i < 127; i++) {
283 ctx->
pal[i + (header & 0x81)] = 0xFFU << 24 | bytestream2_get_be24(&ctx->
g);
300 for (i = 1; i <= ctx->
palsize; i++) {
301 ctx->
pal[i] = 0xFF
U << 24 | bytestream2_get_be24(&ctx->
g);
316 memcpy(frame->
data[1], ctx->
pal, 1024);
318 blocksize = bytestream2_get_byte(&ctx->
g);
320 if (blocksize != 8 && blocksize != 127) {
324 memset(ctx->
cur, 0, 320 * 200);
328 memcpy(ctx->
cur, ctx->
prev, 320 * 200);
341 out = frame->
data[0];
343 for (i = 0; i < avctx->
height; i++) {
344 memcpy(out, src, avctx->
width);
386 for (i = 0; i < 256; i++) {
387 c->
pal[i] = 0xFF
U << 24 | i * 0x10101;
392 "Extradata missing, decoding may not work properly...\n");
405 for (i = 0; i < 256; i++) {