*/
/**
- * @file zmbvenc.c
+ * @file libavcodec/zmbvenc.c
* Zip Motion Blocks Video encoder
*/
#include <stdio.h>
#include <stdlib.h>
+#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include <zlib.h>
z_stream zstream;
} ZmbvEncContext;
+static int score_tab[256];
+
/** Block comparing function
* XXX should be optimized and moved to DSPContext
* TODO handle out of edge ME
{
int sum = 0;
int i, j;
+ uint8_t histogram[256]={0};
for(j = 0; j < bh; j++){
for(i = 0; i < bw; i++)
- sum += src[i] ^ src2[i];
+ histogram[src[i] ^ src2[i]]++;
src += stride;
src2 += stride2;
}
+
+ for(i=1; i<256; i++)
+ sum+= score_tab[histogram[i]];
+
return sum;
}
AVFrame * const p = &c->pic;
uint8_t *src, *prev;
uint32_t *palptr;
- int zret = Z_OK;
int len = 0;
int keyframe, chpal;
int fl;
c->zstream.next_out = c->comp_buf;
c->zstream.avail_out = c->comp_size;
c->zstream.total_out = 0;
- if((zret = deflate(&c->zstream, Z_SYNC_FLUSH)) != Z_OK){
+ if(deflate(&c->zstream, Z_SYNC_FLUSH) != Z_OK){
av_log(avctx, AV_LOG_ERROR, "Error compressing data\n");
return -1;
}
{
ZmbvEncContext * const c = avctx->priv_data;
int zret; // Zlib return code
+ int i;
int lvl = 9;
+ for(i=1; i<256; i++)
+ score_tab[i]= -i * log(i/(double)(ZMBV_BLOCK*ZMBV_BLOCK)) * (256/M_LN2);
+
c->avctx = avctx;
- c->pic.data[0] = NULL;
c->curfrm = 0;
c->keyint = avctx->keyint_min;
c->range = 8;
return -1;
}
+ avctx->coded_frame = (AVFrame*)&c->pic;
+
return 0;
}
encode_init,
encode_frame,
encode_end,
- .pix_fmts = (enum PixelFormat[]){PIX_FMT_PAL8, -1},
+ .pix_fmts = (enum PixelFormat[]){PIX_FMT_PAL8, PIX_FMT_NONE},
+ .long_name = NULL_IF_CONFIG_SMALL("Zip Motion Blocks Video"),
};