37 #define ZMBV_KEYFRAME 1
38 #define ZMBV_DELTAPAL 2
85 int d, dx, dy, bw2, bh2;
94 for (i = 0; i < 768; i++)
99 src += ((c->
bx * c->
by * 2 + 3) & ~3);
102 for (y = 0; y < c->
height; y += c->
bh) {
104 for (x = 0; x < c->
width; x += c->
bw) {
108 dx = mvec[
block] >> 1;
109 dy = mvec[block + 1] >> 1;
116 tprev = prev + x + dx + dy * c->
width;
119 for (j = 0; j < bh2; j++) {
120 if (my + j < 0 || my + j >= c->
height) {
123 for (i = 0; i < bw2; i++) {
124 if (mx + i < 0 || mx + i >= c->
width)
136 for (j = 0; j < bh2; j++) {
137 for (i = 0; i < bw2; i++)
159 uint16_t *output, *
prev;
162 int d, dx, dy, bw2, bh2;
167 output = (uint16_t*)c->
cur;
168 prev = (uint16_t*)c->
prev;
171 src += ((c->
bx * c->
by * 2 + 3) & ~3);
174 for (y = 0; y < c->
height; y += c->
bh) {
176 for (x = 0; x < c->
width; x += c->
bw) {
177 uint16_t *out, *tprev;
180 dx = mvec[
block] >> 1;
181 dy = mvec[block + 1] >> 1;
188 tprev = prev + x + dx + dy * c->
width;
191 for (j = 0; j < bh2; j++) {
192 if (my + j < 0 || my + j >= c->
height) {
193 memset(out, 0, bw2 * 2);
195 for (i = 0; i < bw2; i++) {
196 if (mx + i < 0 || mx + i >= c->
width)
208 for (j = 0; j < bh2; j++){
209 for (i = 0; i < bw2; i++) {
210 out[i] ^= *((uint16_t*)src);
226 #ifdef ZMBV_ENABLE_24BPP
237 int d, dx, dy, bw2, bh2;
246 stride = c->
width * 3;
248 src += ((c->
bx * c->
by * 2 + 3) & ~3);
251 for (y = 0; y < c->
height; y += c->
bh) {
253 for (x = 0; x < c->
width; x += c->
bw) {
257 dx = mvec[
block] >> 1;
258 dy = mvec[block + 1] >> 1;
264 out = output + x * 3;
265 tprev = prev + (x + dx) * 3 + dy * stride;
268 for (j = 0; j < bh2; j++) {
269 if (my + j < 0 || my + j >= c->
height) {
270 memset(out, 0, bw2 * 3);
272 for (i = 0; i < bw2; i++){
273 if (mx + i < 0 || mx + i >= c->
width) {
278 out[i * 3 + 0] = tprev[i * 3 + 0];
279 out[i * 3 + 1] = tprev[i * 3 + 1];
280 out[i * 3 + 2] = tprev[i * 3 + 2];
289 out = output + x * 3;
290 for (j = 0; j < bh2; j++) {
291 for (i = 0; i < bw2; i++) {
292 out[i * 3 + 0] ^= *src++;
293 out[i * 3 + 1] ^= *src++;
294 out[i * 3 + 2] ^= *src++;
300 output += stride * c->
bh;
301 prev += stride * c->
bh;
308 #endif //ZMBV_ENABLE_24BPP
317 uint32_t *output, *
prev;
320 int d, dx, dy, bw2, bh2;
325 output = (uint32_t*)c->
cur;
326 prev = (uint32_t*)c->
prev;
329 src += ((c->
bx * c->
by * 2 + 3) & ~3);
332 for (y = 0; y < c->
height; y += c->
bh) {
334 for (x = 0; x < c->
width; x += c->
bw) {
335 uint32_t *out, *tprev;
338 dx = mvec[
block] >> 1;
339 dy = mvec[block + 1] >> 1;
346 tprev = prev + x + dx + dy * c->
width;
349 for (j = 0; j < bh2; j++) {
350 if (my + j < 0 || my + j >= c->
height) {
351 memset(out, 0, bw2 * 4);
353 for (i = 0; i < bw2; i++){
354 if (mx + i < 0 || mx + i >= c->
width)
366 for (j = 0; j < bh2; j++){
367 for (i = 0; i < bw2; i++) {
368 out[i] ^= *((uint32_t *) src);
393 memcpy(c->
pal, src, 768);
404 int buf_size = avpkt->
size;
408 int hi_ver, lo_ver, ret;
438 "Flags=%X ver=%i.%i comp=%i fmt=%i blk=%ix%i\n",
440 if (hi_ver != 0 || lo_ver != 1) {
445 if (c->
bw == 0 || c->
bh == 0) {
468 #ifdef ZMBV_ENABLE_24BPP
474 #endif //ZMBV_ENABLE_24BPP
487 zret = inflateReset(&c->
zstream);
521 zret = inflate(&c->
zstream, Z_SYNC_FLUSH);
522 if (zret != Z_OK && zret != Z_STREAM_END) {
548 for (j = 0; j < c->
height; j++) {
549 for (i = 0; i < c->
width; i++) {
550 out[i * 3 + 0] = c->
pal[(*src) * 3 + 0];
551 out[i * 3 + 1] = c->
pal[(*src) * 3 + 1];
552 out[i * 3 + 2] = c->
pal[(*src) * 3 + 2];
559 for (j = 0; j < c->
height; j++) {
560 for (i = 0; i < c->
width; i++) {
563 out[i * 3 + 0] = (tmp & 0x7C00) >> 7;
564 out[i * 3 + 1] = (tmp & 0x03E0) >> 2;
565 out[i * 3 + 2] = (tmp & 0x001F) << 3;
571 for (j = 0; j < c->
height; j++) {
572 for (i = 0; i < c->
width; i++) {
575 out[i * 3 + 0] = (tmp & 0xF800) >> 8;
576 out[i * 3 + 1] = (tmp & 0x07E0) >> 3;
577 out[i * 3 + 2] = (tmp & 0x001F) << 3;
582 #ifdef ZMBV_ENABLE_24BPP
584 for (j = 0; j < c->
height; j++) {
585 memcpy(out, src, c->
width * 3);
590 #endif //ZMBV_ENABLE_24BPP
592 for (j = 0; j < c->
height; j++) {
593 for (i = 0; i < c->
width; i++) {
627 memset(&c->
zstream, 0,
sizeof(z_stream));
636 "Can't allocate decompression buffer.\n");
644 zret = inflateInit(&c->
zstream);