35 #define ZMBV_KEYFRAME 1
36 #define ZMBV_DELTAPAL 2
80 uint8_t *output, *
prev;
83 int d, dx, dy, bw2, bh2;
92 for (i = 0; i < 768; i++)
97 src += ((c->
bx * c->
by * 2 + 3) & ~3);
100 for (y = 0; y < c->
height; y += c->
bh) {
102 for (x = 0; x < c->
width; x += c->
bw) {
103 uint8_t *out, *tprev;
106 dx = mvec[
block] >> 1;
107 dy = mvec[block + 1] >> 1;
114 tprev = prev + x + dx + dy * c->
width;
117 for (j = 0; j < bh2; j++) {
118 if (my + j < 0 || my + j >= c->
height) {
121 for (i = 0; i < bw2; i++) {
122 if (mx + i < 0 || mx + i >= c->
width)
134 for (j = 0; j < bh2; j++) {
135 for (i = 0; i < bw2; i++)
157 uint16_t *output, *
prev;
160 int d, dx, dy, bw2, bh2;
165 output = (uint16_t*)c->
cur;
166 prev = (uint16_t*)c->
prev;
169 src += ((c->
bx * c->
by * 2 + 3) & ~3);
172 for (y = 0; y < c->
height; y += c->
bh) {
174 for (x = 0; x < c->
width; x += c->
bw) {
175 uint16_t *out, *tprev;
178 dx = mvec[
block] >> 1;
179 dy = mvec[block + 1] >> 1;
186 tprev = prev + x + dx + dy * c->
width;
189 for (j = 0; j < bh2; j++) {
190 if (my + j < 0 || my + j >= c->
height) {
191 memset(out, 0, bw2 * 2);
193 for (i = 0; i < bw2; i++) {
194 if (mx + i < 0 || mx + i >= c->
width)
206 for (j = 0; j < bh2; j++){
207 for (i = 0; i < bw2; i++) {
208 out[i] ^= *((uint16_t*)src);
224 #ifdef ZMBV_ENABLE_24BPP
232 uint8_t *output, *
prev;
235 int d, dx, dy, bw2, bh2;
244 stride = c->
width * 3;
246 src += ((c->
bx * c->
by * 2 + 3) & ~3);
249 for (y = 0; y < c->
height; y += c->
bh) {
251 for (x = 0; x < c->
width; x += c->
bw) {
252 uint8_t *out, *tprev;
255 dx = mvec[
block] >> 1;
256 dy = mvec[block + 1] >> 1;
262 out = output + x * 3;
263 tprev = prev + (x + dx) * 3 + dy * stride;
266 for (j = 0; j < bh2; j++) {
267 if (my + j < 0 || my + j >= c->
height) {
268 memset(out, 0, bw2 * 3);
270 for (i = 0; i < bw2; i++){
271 if (mx + i < 0 || mx + i >= c->
width) {
276 out[i * 3 + 0] = tprev[i * 3 + 0];
277 out[i * 3 + 1] = tprev[i * 3 + 1];
278 out[i * 3 + 2] = tprev[i * 3 + 2];
287 out = output + x * 3;
288 for (j = 0; j < bh2; j++) {
289 for (i = 0; i < bw2; i++) {
290 out[i * 3 + 0] ^= *src++;
291 out[i * 3 + 1] ^= *src++;
292 out[i * 3 + 2] ^= *src++;
298 output += stride * c->
bh;
299 prev += stride * c->
bh;
306 #endif //ZMBV_ENABLE_24BPP
315 uint32_t *output, *
prev;
318 int d, dx, dy, bw2, bh2;
323 output = (uint32_t*)c->
cur;
324 prev = (uint32_t*)c->
prev;
327 src += ((c->
bx * c->
by * 2 + 3) & ~3);
330 for (y = 0; y < c->
height; y += c->
bh) {
332 for (x = 0; x < c->
width; x += c->
bw) {
333 uint32_t *out, *tprev;
336 dx = mvec[
block] >> 1;
337 dy = mvec[block + 1] >> 1;
344 tprev = prev + x + dx + dy * c->
width;
347 for (j = 0; j < bh2; j++) {
348 if (my + j < 0 || my + j >= c->
height) {
349 memset(out, 0, bw2 * 4);
351 for (i = 0; i < bw2; i++){
352 if (mx + i < 0 || mx + i >= c->
width)
364 for (j = 0; j < bh2; j++){
365 for (i = 0; i < bw2; i++) {
366 out[i] ^= *((uint32_t *) src);
391 memcpy(c->
pal, src, 768);
401 const uint8_t *buf = avpkt->
data;
402 int buf_size = avpkt->
size;
432 "Flags=%X ver=%i.%i comp=%i fmt=%i blk=%ix%i\n",
434 if (hi_ver != 0 || lo_ver != 1) {
439 if (c->
bw == 0 || c->
bh == 0) {
462 #ifdef ZMBV_ENABLE_24BPP
468 #endif //ZMBV_ENABLE_24BPP
478 "Unsupported (for now) format %i\n", c->
fmt);
482 zret = inflateReset(&c->
zstream);
511 inflate(&c->
zstream, Z_FINISH);
534 for (j = 0; j < c->
height; j++) {
535 for (i = 0; i < c->
width; i++) {
536 out[i * 3 + 0] = c->
pal[(*src) * 3 + 0];
537 out[i * 3 + 1] = c->
pal[(*src) * 3 + 1];
538 out[i * 3 + 2] = c->
pal[(*src) * 3 + 2];
545 for (j = 0; j < c->
height; j++) {
546 for (i = 0; i < c->
width; i++) {
549 out[i * 3 + 0] = (tmp & 0x7C00) >> 7;
550 out[i * 3 + 1] = (tmp & 0x03E0) >> 2;
551 out[i * 3 + 2] = (tmp & 0x001F) << 3;
557 for (j = 0; j < c->
height; j++) {
558 for (i = 0; i < c->
width; i++) {
561 out[i * 3 + 0] = (tmp & 0xF800) >> 8;
562 out[i * 3 + 1] = (tmp & 0x07E0) >> 3;
563 out[i * 3 + 2] = (tmp & 0x001F) << 3;
568 #ifdef ZMBV_ENABLE_24BPP
570 for (j = 0; j < c->
height; j++) {
571 memcpy(out, src, c->
width * 3);
576 #endif //ZMBV_ENABLE_24BPP
578 for (j = 0; j < c->
height; j++) {
579 for (i = 0; i < c->
width; i++) {
619 memset(&c->
zstream, 0,
sizeof(z_stream));
628 "Can't allocate decompression buffer.\n");
636 zret = inflateInit(&c->
zstream);