37 #define ZMBV_KEYFRAME 1
38 #define ZMBV_DELTAPAL 2
66 int bw,
int bh,
int *xored)
73 for(j = 0; j < bh; j++){
74 for(i = 0; i < bw; i++){
75 int t = src[i] ^ src2[i];
83 for(i = 1; i < 256; i++)
93 int pstride,
int x,
int y,
int *mx,
int *my,
int *xored)
95 int dx, dy, tx, ty, tv, bv, bw, bh;
100 bv =
block_cmp(src, sstride, prev, pstride, bw, bh, xored);
104 if(tx == x && ty == y)
continue;
107 tv =
block_cmp(src, sstride, prev + dx + dy*pstride, pstride, bw, bh, xored);
120 const AVFrame *pict,
int *got_packet)
123 const AVFrame *
const p = pict;
128 int work_size = 0, pkt_size;
138 chpal = !keyframe && memcmp(p->
data[1], c->
pal2, 1024);
140 palptr = (uint32_t*)p->
data[1];
145 for(i = 0; i < 256; i++){
147 c->
work_buf[work_size++] = tpal[0] ^ c->
pal[i * 3 + 0];
148 c->
work_buf[work_size++] = tpal[1] ^ c->
pal[i * 3 + 1];
149 c->
work_buf[work_size++] = tpal[2] ^ c->
pal[i * 3 + 2];
150 c->
pal[i * 3 + 0] = tpal[0];
151 c->
pal[i * 3 + 1] = tpal[1];
152 c->
pal[i * 3 + 2] = tpal[2];
157 for(i = 0; i < 256; i++){
163 for(i = 0; i < avctx->
height; i++){
166 work_size += avctx->
width;
169 int x,
y, bh2, bw2, xored;
177 memset(c->
work_buf + work_size, 0, (bw * bh * 2 + 3) & ~3);
178 work_size += (bw * bh * 2 + 3) & ~3;
189 mv[0] = (mx << 1) | !!xored;
193 for(j = 0; j < bh2; j++){
194 for(i = 0; i < bw2; i++)
195 c->
work_buf[work_size++] = tsrc[i] ^ tprev[i];
208 for(i = 0; i < avctx->
height; i++){
209 memcpy(prev, src, avctx->
width);
218 c->
zstream.avail_in = work_size;
224 if(deflate(&c->
zstream, Z_SYNC_FLUSH) != Z_OK){
229 pkt_size = c->
zstream.total_out + 1 + 6*keyframe;
290 if(lvl < 0 || lvl > 9){
296 memset(&c->
zstream, 0,
sizeof(z_stream));
298 ((avctx->
width + ZMBV_BLOCK - 1) / ZMBV_BLOCK) * ((avctx->
height + ZMBV_BLOCK - 1) / ZMBV_BLOCK) * 2 + 4;
321 zret = deflateInit(&c->
zstream, lvl);