FFmpeg
zmbvenc.c
Go to the documentation of this file.
1 /*
2  * Zip Motion Blocks Video (ZMBV) encoder
3  * Copyright (c) 2006 Konstantin Shishkov
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * Zip Motion Blocks Video encoder
25  */
26 
27 #include <stdio.h>
28 #include <stdlib.h>
29 
30 #include "libavutil/common.h"
31 #include "libavutil/intreadwrite.h"
32 #include "avcodec.h"
33 #include "encode.h"
34 #include "internal.h"
35 
36 #include <zlib.h>
37 
38 /* Frame header flags */
39 #define ZMBV_KEYFRAME 1
40 #define ZMBV_DELTAPAL 2
41 
42 /* Motion block width/height (maximum allowed value is 255)
43  * Note: histogram datatype in block_cmp() must be big enough to hold values
44  * up to (4 * ZMBV_BLOCK * ZMBV_BLOCK)
45  */
46 #define ZMBV_BLOCK 16
47 
48 /* Keyframe header format values */
49 enum ZmbvFormat {
59 };
60 
61 /**
62  * Encoder context
63  */
64 typedef struct ZmbvEncContext {
66 
67  int lrange, urange;
68  uint8_t *comp_buf, *work_buf;
69  uint8_t pal[768];
70  uint32_t pal2[256]; //for quick comparisons
71  uint8_t *prev, *prev_buf;
72  int pstride;
73  int comp_size;
74  int keyint, curfrm;
75  int bypp;
78  z_stream zstream;
79 
82 
83 
84 /** Block comparing function
85  * XXX should be optimized and moved to DSPContext
86  */
87 static inline int block_cmp(ZmbvEncContext *c, uint8_t *src, int stride,
88  uint8_t *src2, int stride2, int bw, int bh,
89  int *xored)
90 {
91  int sum = 0;
92  int i, j;
93  uint16_t histogram[256] = {0};
94  int bw_bytes = bw * c->bypp;
95 
96  /* Build frequency histogram of byte values for src[] ^ src2[] */
97  for(j = 0; j < bh; j++){
98  for(i = 0; i < bw_bytes; i++){
99  int t = src[i] ^ src2[i];
100  histogram[t]++;
101  }
102  src += stride;
103  src2 += stride2;
104  }
105 
106  /* If not all the xored values were 0, then the blocks are different */
107  *xored = (histogram[0] < bw_bytes * bh);
108 
109  /* Exit early if blocks are equal */
110  if (!*xored) return 0;
111 
112  /* Sum the entropy of all values */
113  for(i = 0; i < 256; i++)
114  sum += c->score_tab[histogram[i]];
115 
116  return sum;
117 }
118 
119 /** Motion estimation function
120  * TODO make better ME decisions
121  */
122 static int zmbv_me(ZmbvEncContext *c, uint8_t *src, int sstride, uint8_t *prev,
123  int pstride, int x, int y, int *mx, int *my, int *xored)
124 {
125  int dx, dy, txored, tv, bv, bw, bh;
126  int mx0, my0;
127 
128  mx0 = *mx;
129  my0 = *my;
130  bw = FFMIN(ZMBV_BLOCK, c->avctx->width - x);
131  bh = FFMIN(ZMBV_BLOCK, c->avctx->height - y);
132 
133  /* Try (0,0) */
134  bv = block_cmp(c, src, sstride, prev, pstride, bw, bh, xored);
135  *mx = *my = 0;
136  if(!bv) return 0;
137 
138  /* Try previous block's MV (if not 0,0) */
139  if (mx0 || my0){
140  tv = block_cmp(c, src, sstride, prev + mx0 * c->bypp + my0 * pstride, pstride, bw, bh, &txored);
141  if(tv < bv){
142  bv = tv;
143  *mx = mx0;
144  *my = my0;
145  *xored = txored;
146  if(!bv) return 0;
147  }
148  }
149 
150  /* Try other MVs from top-to-bottom, left-to-right */
151  for(dy = -c->lrange; dy <= c->urange; dy++){
152  for(dx = -c->lrange; dx <= c->urange; dx++){
153  if(!dx && !dy) continue; // we already tested this block
154  if(dx == mx0 && dy == my0) continue; // this one too
155  tv = block_cmp(c, src, sstride, prev + dx * c->bypp + dy * pstride, pstride, bw, bh, &txored);
156  if(tv < bv){
157  bv = tv;
158  *mx = dx;
159  *my = dy;
160  *xored = txored;
161  if(!bv) return 0;
162  }
163  }
164  }
165  return bv;
166 }
167 
169  const AVFrame *pict, int *got_packet)
170 {
171  ZmbvEncContext * const c = avctx->priv_data;
172  const AVFrame * const p = pict;
173  uint8_t *src, *prev, *buf;
174  uint32_t *palptr;
175  int keyframe, chpal;
176  int fl;
177  int work_size = 0, pkt_size;
178  int bw, bh;
179  int i, j, ret;
180 
181  keyframe = !c->curfrm;
182  c->curfrm++;
183  if(c->curfrm == c->keyint)
184  c->curfrm = 0;
185 
186  palptr = (avctx->pix_fmt == AV_PIX_FMT_PAL8) ? (uint32_t *)p->data[1] : NULL;
187  chpal = !keyframe && palptr && memcmp(palptr, c->pal2, 1024);
188 
189  src = p->data[0];
190  prev = c->prev;
191  if(chpal){
192  uint8_t tpal[3];
193  for(i = 0; i < 256; i++){
194  AV_WB24(tpal, palptr[i]);
195  c->work_buf[work_size++] = tpal[0] ^ c->pal[i * 3 + 0];
196  c->work_buf[work_size++] = tpal[1] ^ c->pal[i * 3 + 1];
197  c->work_buf[work_size++] = tpal[2] ^ c->pal[i * 3 + 2];
198  c->pal[i * 3 + 0] = tpal[0];
199  c->pal[i * 3 + 1] = tpal[1];
200  c->pal[i * 3 + 2] = tpal[2];
201  }
202  memcpy(c->pal2, palptr, 1024);
203  }
204  if(keyframe){
205  if (palptr){
206  for(i = 0; i < 256; i++){
207  AV_WB24(c->pal+(i*3), palptr[i]);
208  }
209  memcpy(c->work_buf, c->pal, 768);
210  memcpy(c->pal2, palptr, 1024);
211  work_size = 768;
212  }
213  for(i = 0; i < avctx->height; i++){
214  memcpy(c->work_buf + work_size, src, avctx->width * c->bypp);
215  src += p->linesize[0];
216  work_size += avctx->width * c->bypp;
217  }
218  }else{
219  int x, y, bh2, bw2, xored;
220  uint8_t *tsrc, *tprev;
221  uint8_t *mv;
222  int mx = 0, my = 0;
223 
224  bw = (avctx->width + ZMBV_BLOCK - 1) / ZMBV_BLOCK;
225  bh = (avctx->height + ZMBV_BLOCK - 1) / ZMBV_BLOCK;
226  mv = c->work_buf + work_size;
227  memset(c->work_buf + work_size, 0, (bw * bh * 2 + 3) & ~3);
228  work_size += (bw * bh * 2 + 3) & ~3;
229  /* for now just XOR'ing */
230  for(y = 0; y < avctx->height; y += ZMBV_BLOCK) {
231  bh2 = FFMIN(avctx->height - y, ZMBV_BLOCK);
232  for(x = 0; x < avctx->width; x += ZMBV_BLOCK, mv += 2) {
233  bw2 = FFMIN(avctx->width - x, ZMBV_BLOCK);
234 
235  tsrc = src + x * c->bypp;
236  tprev = prev + x * c->bypp;
237 
238  zmbv_me(c, tsrc, p->linesize[0], tprev, c->pstride, x, y, &mx, &my, &xored);
239  mv[0] = (mx * 2) | !!xored;
240  mv[1] = my * 2;
241  tprev += mx * c->bypp + my * c->pstride;
242  if(xored){
243  for(j = 0; j < bh2; j++){
244  for(i = 0; i < bw2 * c->bypp; i++)
245  c->work_buf[work_size++] = tsrc[i] ^ tprev[i];
246  tsrc += p->linesize[0];
247  tprev += c->pstride;
248  }
249  }
250  }
251  src += p->linesize[0] * ZMBV_BLOCK;
252  prev += c->pstride * ZMBV_BLOCK;
253  }
254  }
255  /* save the previous frame */
256  src = p->data[0];
257  prev = c->prev;
258  for(i = 0; i < avctx->height; i++){
259  memcpy(prev, src, avctx->width * c->bypp);
260  prev += c->pstride;
261  src += p->linesize[0];
262  }
263 
264  if (keyframe)
265  deflateReset(&c->zstream);
266 
267  c->zstream.next_in = c->work_buf;
268  c->zstream.avail_in = work_size;
269  c->zstream.total_in = 0;
270 
271  c->zstream.next_out = c->comp_buf;
272  c->zstream.avail_out = c->comp_size;
273  c->zstream.total_out = 0;
274  if(deflate(&c->zstream, Z_SYNC_FLUSH) != Z_OK){
275  av_log(avctx, AV_LOG_ERROR, "Error compressing data\n");
276  return -1;
277  }
278 
279  pkt_size = c->zstream.total_out + 1 + 6*keyframe;
280  if ((ret = ff_get_encode_buffer(avctx, pkt, pkt_size, 0)) < 0)
281  return ret;
282  buf = pkt->data;
283 
284  fl = (keyframe ? ZMBV_KEYFRAME : 0) | (chpal ? ZMBV_DELTAPAL : 0);
285  *buf++ = fl;
286  if (keyframe) {
287  *buf++ = 0; // hi ver
288  *buf++ = 1; // lo ver
289  *buf++ = 1; // comp
290  *buf++ = c->fmt; // format
291  *buf++ = ZMBV_BLOCK; // block width
292  *buf++ = ZMBV_BLOCK; // block height
294  }
295  memcpy(buf, c->comp_buf, c->zstream.total_out);
296 
297  *got_packet = 1;
298 
299  return 0;
300 }
301 
303 {
304  ZmbvEncContext * const c = avctx->priv_data;
305 
306  av_freep(&c->comp_buf);
307  av_freep(&c->work_buf);
308 
309  av_freep(&c->prev_buf);
310  if (c->zlib_init_ok)
311  deflateEnd(&c->zstream);
312 
313  return 0;
314 }
315 
316 /**
317  * Init zmbv encoder
318  */
320 {
321  ZmbvEncContext * const c = avctx->priv_data;
322  int zret; // Zlib return code
323  int i;
324  int lvl = 9;
325  int prev_size, prev_offset;
326 
327  switch (avctx->pix_fmt) {
328  case AV_PIX_FMT_PAL8:
329  c->fmt = ZMBV_FMT_8BPP;
330  c->bypp = 1;
331  break;
332  case AV_PIX_FMT_RGB555LE:
333  c->fmt = ZMBV_FMT_15BPP;
334  c->bypp = 2;
335  break;
336  case AV_PIX_FMT_RGB565LE:
337  c->fmt = ZMBV_FMT_16BPP;
338  c->bypp = 2;
339  break;
340 #ifdef ZMBV_ENABLE_24BPP
341  case AV_PIX_FMT_BGR24:
342  c->fmt = ZMBV_FMT_24BPP;
343  c->bypp = 3;
344  break;
345 #endif //ZMBV_ENABLE_24BPP
346  case AV_PIX_FMT_BGR0:
347  c->fmt = ZMBV_FMT_32BPP;
348  c->bypp = 4;
349  break;
350  }
351 
352  /* Entropy-based score tables for comparing blocks.
353  * Suitable for blocks up to (ZMBV_BLOCK * ZMBV_BLOCK) bytes.
354  * Scores are nonnegative, lower is better.
355  */
356  for(i = 1; i <= ZMBV_BLOCK * ZMBV_BLOCK * c->bypp; i++)
357  c->score_tab[i] = -i * log2(i / (double)(ZMBV_BLOCK * ZMBV_BLOCK * c->bypp)) * 256;
358 
359  c->avctx = avctx;
360 
361  c->curfrm = 0;
362  c->keyint = avctx->keyint_min;
363 
364  /* Motion estimation range: maximum distance is -64..63 */
365  c->lrange = c->urange = 8;
366  if(avctx->me_range > 0){
367  c->lrange = FFMIN(avctx->me_range, 64);
368  c->urange = FFMIN(avctx->me_range, 63);
369  }
370 
371  if(avctx->compression_level >= 0)
372  lvl = avctx->compression_level;
373  if(lvl < 0 || lvl > 9){
374  av_log(avctx, AV_LOG_ERROR, "Compression level should be 0-9, not %i\n", lvl);
375  return AVERROR(EINVAL);
376  }
377 
378  c->comp_size = avctx->width * c->bypp * avctx->height + 1024 +
379  ((avctx->width + ZMBV_BLOCK - 1) / ZMBV_BLOCK) * ((avctx->height + ZMBV_BLOCK - 1) / ZMBV_BLOCK) * 2 + 4;
380  if (!(c->work_buf = av_malloc(c->comp_size))) {
381  av_log(avctx, AV_LOG_ERROR, "Can't allocate work buffer.\n");
382  return AVERROR(ENOMEM);
383  }
384  /* Conservative upper bound taken from zlib v1.2.1 source via lcl.c */
385  c->comp_size = c->comp_size + ((c->comp_size + 7) >> 3) +
386  ((c->comp_size + 63) >> 6) + 11;
387 
388  /* Allocate compression buffer */
389  if (!(c->comp_buf = av_malloc(c->comp_size))) {
390  av_log(avctx, AV_LOG_ERROR, "Can't allocate compression buffer.\n");
391  return AVERROR(ENOMEM);
392  }
393 
394  /* Allocate prev buffer - pad around the image to allow out-of-edge ME:
395  * - The image should be padded with `lrange` rows before and `urange` rows
396  * after.
397  * - The stride should be padded with `lrange` pixels, then rounded up to a
398  * multiple of 16 bytes.
399  * - The first row should also be padded with `lrange` pixels before, then
400  * aligned up to a multiple of 16 bytes.
401  */
402  c->pstride = FFALIGN((avctx->width + c->lrange) * c->bypp, 16);
403  prev_size = FFALIGN(c->lrange * c->bypp, 16) + c->pstride * (c->lrange + avctx->height + c->urange);
404  prev_offset = FFALIGN(c->lrange * c->bypp, 16) + c->pstride * c->lrange;
405  if (!(c->prev_buf = av_mallocz(prev_size))) {
406  av_log(avctx, AV_LOG_ERROR, "Can't allocate picture.\n");
407  return AVERROR(ENOMEM);
408  }
409  c->prev = c->prev_buf + prev_offset;
410 
411  c->zstream.zalloc = Z_NULL;
412  c->zstream.zfree = Z_NULL;
413  c->zstream.opaque = Z_NULL;
414  zret = deflateInit(&c->zstream, lvl);
415  if (zret != Z_OK) {
416  av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
417  return -1;
418  }
419  c->zlib_init_ok = 1;
420 
421  return 0;
422 }
423 
425  .name = "zmbv",
426  .long_name = NULL_IF_CONFIG_SMALL("Zip Motion Blocks Video"),
427  .type = AVMEDIA_TYPE_VIDEO,
428  .id = AV_CODEC_ID_ZMBV,
429  .capabilities = AV_CODEC_CAP_DR1,
430  .priv_data_size = sizeof(ZmbvEncContext),
431  .init = encode_init,
432  .encode2 = encode_frame,
433  .close = encode_end,
434  .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_PAL8,
437 #ifdef ZMBV_ENABLE_24BPP
439 #endif //ZMBV_ENABLE_24BPP
441  AV_PIX_FMT_NONE },
443 };
ZmbvEncContext::work_buf
uint8_t * work_buf
Definition: zmbvenc.c:68
AVCodec
AVCodec.
Definition: codec.h:202
ZmbvEncContext::comp_buf
uint8_t * comp_buf
Definition: zmbvenc.c:68
stride
int stride
Definition: mace.c:144
FF_CODEC_CAP_INIT_THREADSAFE
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:42
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
ff_zmbv_encoder
const AVCodec ff_zmbv_encoder
Definition: zmbvenc.c:424
AVCodecContext::keyint_min
int keyint_min
minimum GOP size
Definition: avcodec.h:925
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AV_CODEC_ID_ZMBV
@ AV_CODEC_ID_ZMBV
Definition: codec_id.h:131
mv
static const int8_t mv[256][2]
Definition: 4xm.c:79
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:373
ZmbvEncContext::prev_buf
uint8_t * prev_buf
Definition: zmbvenc.c:71
encode.h
ZMBV_FMT_15BPP
@ ZMBV_FMT_15BPP
Definition: zmbvenc.c:55
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
ZMBV_FMT_NONE
@ ZMBV_FMT_NONE
Definition: zmbvenc.c:50
ZmbvEncContext::keyint
int keyint
Definition: zmbvenc.c:74
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:428
encode_end
static av_cold int encode_end(AVCodecContext *avctx)
Definition: zmbvenc.c:302
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:338
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
init
static int init
Definition: av_tx.c:47
ZmbvEncContext::prev
uint8_t * prev
Definition: zmbvenc.c:71
ZmbvEncContext::pal2
uint32_t pal2[256]
Definition: zmbvenc.c:70
ZMBV_KEYFRAME
#define ZMBV_KEYFRAME
Definition: zmbvenc.c:39
ZMBV_FMT_8BPP
@ ZMBV_FMT_8BPP
Definition: zmbvenc.c:54
ZmbvEncContext::zlib_init_ok
int zlib_init_ok
Definition: zmbvenc.c:77
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
encode_init
static av_cold int encode_init(AVCodecContext *avctx)
Init zmbv encoder.
Definition: zmbvenc.c:319
intreadwrite.h
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:296
ZmbvEncContext::comp_size
int comp_size
Definition: zmbvenc.c:73
AV_PIX_FMT_RGB565LE
@ AV_PIX_FMT_RGB565LE
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
Definition: pixfmt.h:106
NULL
#define NULL
Definition: coverity.c:32
ZmbvEncContext
Encoder context.
Definition: zmbvenc.c:64
src
#define src
Definition: vp8dsp.c:255
ZmbvEncContext::fmt
enum ZmbvFormat fmt
Definition: zmbvenc.c:76
deflate
static void deflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)
Definition: vf_neighbor.c:160
ZmbvEncContext::pal
uint8_t pal[768]
Definition: zmbvenc.c:69
AV_PIX_FMT_BGR0
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:230
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
ZmbvFormat
ZmbvFormat
Definition: zmbv.c:41
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
AVCodecContext::me_range
int me_range
maximum motion estimation search range in subpel units If 0 then no limit.
Definition: avcodec.h:839
zmbv_me
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.
Definition: zmbvenc.c:122
ZmbvEncContext::avctx
AVCodecContext * avctx
Definition: zmbvenc.c:65
AV_WB24
#define AV_WB24(p, d)
Definition: intreadwrite.h:450
ZMBV_FMT_24BPP
@ ZMBV_FMT_24BPP
Definition: zmbvenc.c:57
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:379
ZmbvEncContext::pstride
int pstride
Definition: zmbvenc.c:72
ZMBV_BLOCK
#define ZMBV_BLOCK
Definition: zmbvenc.c:46
ZMBV_FMT_1BPP
@ ZMBV_FMT_1BPP
Definition: zmbvenc.c:51
AV_PIX_FMT_RGB555LE
@ AV_PIX_FMT_RGB555LE
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined
Definition: pixfmt.h:108
ZMBV_DELTAPAL
#define ZMBV_DELTAPAL
Definition: zmbvenc.c:40
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:271
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: internal.h:50
encode_frame
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
Definition: zmbvenc.c:168
common.h
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:263
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:209
ZMBV_FMT_4BPP
@ ZMBV_FMT_4BPP
Definition: zmbvenc.c:53
ZMBV_FMT_2BPP
@ ZMBV_FMT_2BPP
Definition: zmbvenc.c:52
AVCodecContext::height
int height
Definition: avcodec.h:556
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:593
ZmbvEncContext::lrange
int lrange
Definition: zmbvenc.c:67
log2
#define log2(x)
Definition: libm.h:404
avcodec.h
AV_PIX_FMT_PAL8
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:77
ret
ret
Definition: filter_design.txt:187
ZMBV_FMT_16BPP
@ ZMBV_FMT_16BPP
Definition: zmbvenc.c:56
AVCodecContext
main external API structure.
Definition: avcodec.h:383
ff_get_encode_buffer
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
Definition: encode.c:78
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
ZmbvEncContext::urange
int urange
Definition: zmbvenc.c:67
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
ZmbvEncContext::zstream
z_stream zstream
Definition: zmbvenc.c:78
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:410
AVPacket
This structure stores compressed data.
Definition: packet.h:350
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:556
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:362
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
ZmbvEncContext::bypp
int bypp
Definition: zmbvenc.c:75
block_cmp
static int block_cmp(ZmbvEncContext *c, 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.
Definition: zmbvenc.c:87
ZmbvEncContext::curfrm
int curfrm
Definition: zmbvenc.c:74
ZmbvEncContext::score_tab
int score_tab[ZMBV_BLOCK *ZMBV_BLOCK *4+1]
Definition: zmbvenc.c:80
AVCodecContext::compression_level
int compression_level
Definition: avcodec.h:455
ZMBV_FMT_32BPP
@ ZMBV_FMT_32BPP
Definition: zmbvenc.c:58