-static inline int block_cmp(uint8_t *src, int stride, uint8_t *src2, int stride2, int bw, int bh)
+static inline int block_cmp(uint8_t *src, int stride, uint8_t *src2, int stride2,
+ int bw, int bh, int *xored)
-static int zmbv_me(ZmbvEncContext *c, uint8_t *src, int sstride, uint8_t *prev, int pstride,
- int x, int y, int *mx, int *my)
+static int zmbv_me(ZmbvEncContext *c, uint8_t *src, int sstride, uint8_t *prev,
+ int pstride, int x, int y, int *mx, int *my, int *xored)
{
int dx, dy, tx, ty, tv, bv, bw, bh;
*mx = *my = 0;
bw = FFMIN(ZMBV_BLOCK, c->avctx->width - x);
bh = FFMIN(ZMBV_BLOCK, c->avctx->height - y);
{
int dx, dy, tx, ty, tv, bv, bw, bh;
*mx = *my = 0;
bw = FFMIN(ZMBV_BLOCK, c->avctx->width - x);
bh = FFMIN(ZMBV_BLOCK, c->avctx->height - y);
- bv = block_cmp(src, sstride, prev, pstride, bw, bh);
+ bv = block_cmp(src, sstride, prev, pstride, bw, bh, xored);
if(!bv) return 0;
for(ty = FFMAX(y - c->range, 0); ty < FFMIN(y + c->range, c->avctx->height - bh); ty++){
for(tx = FFMAX(x - c->range, 0); tx < FFMIN(x + c->range, c->avctx->width - bw); tx++){
if(tx == x && ty == y) continue; // we already tested this block
dx = tx - x;
dy = ty - y;
if(!bv) return 0;
for(ty = FFMAX(y - c->range, 0); ty < FFMIN(y + c->range, c->avctx->height - bh); ty++){
for(tx = FFMAX(x - c->range, 0); tx < FFMIN(x + c->range, c->avctx->width - bw); tx++){
if(tx == x && ty == y) continue; // we already tested this block
dx = tx - x;
dy = ty - y;
- tv = block_cmp(src, sstride, prev + dx + dy*pstride, pstride, bw, bh);
+ tv = block_cmp(src, sstride, prev + dx + dy*pstride, pstride, bw, bh, xored);
- bv = zmbv_me(c, tsrc, p->linesize[0], tprev, c->pstride, x, y, &mx, &my);
- mv[0] = (mx << 1) | !!bv;
+ bv = zmbv_me(c, tsrc, p->linesize[0], tprev, c->pstride, x, y, &mx, &my, &xored);
+ mv[0] = (mx << 1) | !!xored;
c->zstream.next_out = c->comp_buf;
c->zstream.avail_out = c->comp_size;
c->zstream.total_out = 0;
c->zstream.next_out = c->comp_buf;
c->zstream.avail_out = c->comp_size;
c->zstream.total_out = 0;
// Needed if zlib unused or init aborted before deflateInit
memset(&(c->zstream), 0, sizeof(z_stream));
c->comp_size = avctx->width * avctx->height + 1024 +
// Needed if zlib unused or init aborted before deflateInit
memset(&(c->zstream), 0, sizeof(z_stream));
c->comp_size = avctx->width * avctx->height + 1024 +
if ((c->prev = av_malloc(c->pstride * avctx->height)) == NULL) {
av_log(avctx, AV_LOG_ERROR, "Can't allocate picture.\n");
return -1;
if ((c->prev = av_malloc(c->pstride * avctx->height)) == NULL) {
av_log(avctx, AV_LOG_ERROR, "Can't allocate picture.\n");
return -1;
- .pix_fmts = (enum PixelFormat[]){PIX_FMT_PAL8, PIX_FMT_NONE},
- .long_name = "Zip Motion Blocks Video",
+ .pix_fmts = (const enum PixelFormat[]){PIX_FMT_PAL8, PIX_FMT_NONE},
+ .long_name = NULL_IF_CONFIG_SMALL("Zip Motion Blocks Video"),