37 #define ZMBV_KEYFRAME 1
38 #define ZMBV_DELTAPAL 2
67 int bw,
int bh,
int *xored)
74 for(j = 0; j < bh; j++){
75 for(i = 0; i < bw; i++){
76 int t = src[i] ^ src2[i];
84 for(i = 1; i < 256; i++)
94 int pstride,
int x,
int y,
int *mx,
int *my,
int *xored)
96 int dx, dy, tx, ty, tv, bv, bw, bh;
101 bv =
block_cmp(src, sstride, prev, pstride, bw, bh, xored);
105 if(tx == x && ty == y)
continue;
108 tv =
block_cmp(src, sstride, prev + dx + dy*pstride, pstride, bw, bh, xored);
121 const AVFrame *pict,
int *got_packet)
129 int work_size = 0, pkt_size;
140 chpal = !keyframe && memcmp(p->
data[1], c->
pal2, 1024);
142 palptr = (uint32_t*)p->
data[1];
147 for(i = 0; i < 256; i++){
149 c->
work_buf[work_size++] = tpal[0] ^ c->
pal[i * 3 + 0];
150 c->
work_buf[work_size++] = tpal[1] ^ c->
pal[i * 3 + 1];
151 c->
work_buf[work_size++] = tpal[2] ^ c->
pal[i * 3 + 2];
152 c->
pal[i * 3 + 0] = tpal[0];
153 c->
pal[i * 3 + 1] = tpal[1];
154 c->
pal[i * 3 + 2] = tpal[2];
159 for(i = 0; i < 256; i++){
165 for(i = 0; i < avctx->
height; i++){
168 work_size += avctx->
width;
171 int x, y, bh2, bw2, xored;
179 memset(c->
work_buf + work_size, 0, (bw * bh * 2 + 3) & ~3);
180 work_size += (bw * bh * 2 + 3) & ~3;
191 mv[0] = (mx << 1) | !!xored;
195 for(j = 0; j < bh2; j++){
196 for(i = 0; i < bw2; i++)
197 c->
work_buf[work_size++] = tsrc[i] ^ tprev[i];
210 for(i = 0; i < avctx->
height; i++){
211 memcpy(prev, src, avctx->
width);
220 c->
zstream.avail_in = work_size;
226 if(deflate(&c->
zstream, Z_SYNC_FLUSH) != Z_OK){
231 pkt_size = c->
zstream.total_out + 1 + 6*keyframe;
278 if(lvl < 0 || lvl > 9){
284 memset(&c->
zstream, 0,
sizeof(z_stream));
286 ((avctx->
width + ZMBV_BLOCK - 1) / ZMBV_BLOCK) * ((avctx->
height + ZMBV_BLOCK - 1) / ZMBV_BLOCK) * 2 + 4;
309 zret = deflateInit(&c->
zstream, lvl);