35 #define ZMBV_KEYFRAME 1
36 #define ZMBV_DELTAPAL 2
65 int bw,
int bh,
int *xored)
69 uint8_t histogram[256] = {0};
72 for(j = 0; j < bh; j++){
73 for(i = 0; i < bw; i++){
74 int t = src[i] ^ src2[i];
82 for(i = 1; i < 256; i++)
92 int pstride,
int x,
int y,
int *mx,
int *my,
int *xored)
94 int dx, dy, tx, ty, tv, bv, bw, bh;
99 bv =
block_cmp(src, sstride, prev, pstride, bw, bh, xored);
103 if(tx == x && ty == y)
continue;
106 tv =
block_cmp(src, sstride, prev + dx + dy*pstride, pstride, bw, bh, xored);
139 chpal = !keyframe && memcmp(p->
data[1], c->
pal2, 1024);
152 palptr = (uint32_t*)p->
data[1];
157 for(i = 0; i < 256; i++){
159 c->
work_buf[work_size++] = tpal[0] ^ c->
pal[i * 3 + 0];
160 c->
work_buf[work_size++] = tpal[1] ^ c->
pal[i * 3 + 1];
161 c->
work_buf[work_size++] = tpal[2] ^ c->
pal[i * 3 + 2];
162 c->
pal[i * 3 + 0] = tpal[0];
163 c->
pal[i * 3 + 1] = tpal[1];
164 c->
pal[i * 3 + 2] = tpal[2];
169 for(i = 0; i < 256; i++){
175 for(i = 0; i < avctx->
height; i++){
178 work_size += avctx->
width;
181 int x, y, bh2, bw2, xored;
182 uint8_t *tsrc, *tprev;
189 memset(c->
work_buf + work_size, 0, (bw * bh * 2 + 3) & ~3);
190 work_size += (bw * bh * 2 + 3) & ~3;
201 mv[0] = (mx << 1) | !!xored;
205 for(j = 0; j < bh2; j++){
206 for(i = 0; i < bw2; i++)
207 c->
work_buf[work_size++] = tsrc[i] ^ tprev[i];
220 for(i = 0; i < avctx->
height; i++){
221 memcpy(prev, src, avctx->
width);
227 c->
zstream.avail_in = work_size;
233 if(deflate(&c->
zstream, Z_SYNC_FLUSH) != Z_OK){
239 return len + c->
zstream.total_out;
266 if(lvl < 0 || lvl > 9){
272 memset(&c->
zstream, 0,
sizeof(z_stream));
274 ((avctx->
width + ZMBV_BLOCK - 1) / ZMBV_BLOCK) * ((avctx->
height + ZMBV_BLOCK - 1) / ZMBV_BLOCK) * 2 + 4;
297 zret = deflateInit(&c->
zstream, lvl);
AVFrame * coded_frame
the picture in the bitstream
static av_cold int encode_end(AVCodecContext *avctx)
Uninit zmbv encoder.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
int me_range
maximum motion estimation search range in subpel units If 0 then no limit.
static int init(AVCodecParserContext *s)
static av_cold int encode_init(AVCodecContext *avctx)
Init zmbv encoder.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static int encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size, void *data)
struct ZmbvEncContext ZmbvEncContext
Encoder context.
enum AVPictureType pict_type
Picture type of the frame, see ?_TYPE below.
int width
picture width / height.
static const int8_t mv[256][2]
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
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)
Motion estimation function TODO make better ME decisions.
main external API structure.
static void close(AVCodecParserContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int score_tab[256]
8 bit with PIX_FMT_RGB32 palette
int key_frame
1 -> keyframe, 0-> not
static int block_cmp(uint8_t *src, int stride, uint8_t *src2, int stride2, int bw, int bh, int *xored)
Block comparing function XXX should be optimized and moved to DSPContext TODO handle out of edge ME...
int keyint_min
minimum GOP size