Libav
ffv1dec.c
Go to the documentation of this file.
1 /*
2  * FFV1 decoder
3  *
4  * Copyright (c) 2003-2012 Michael Niedermayer <michaelni@gmx.at>
5  *
6  * This file is part of Libav.
7  *
8  * Libav is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * Libav is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with Libav; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
28 #include "libavutil/avassert.h"
29 #include "libavutil/pixdesc.h"
30 #include "libavutil/crc.h"
31 #include "libavutil/opt.h"
32 #include "libavutil/imgutils.h"
33 #include "libavutil/timer.h"
34 #include "avcodec.h"
35 #include "internal.h"
36 #include "get_bits.h"
37 #include "put_bits.h"
38 #include "rangecoder.h"
39 #include "golomb.h"
40 #include "mathops.h"
41 #include "ffv1.h"
42 
44  int is_signed)
45 {
46  if (get_rac(c, state + 0))
47  return 0;
48  else {
49  int i, e, a;
50  e = 0;
51  while (get_rac(c, state + 1 + FFMIN(e, 9))) // 1..10
52  e++;
53 
54  a = 1;
55  for (i = e - 1; i >= 0; i--)
56  a += a + get_rac(c, state + 22 + FFMIN(i, 9)); // 22..31
57 
58  e = -(is_signed && get_rac(c, state + 11 + FFMIN(e, 10))); // 11..21
59  return (a ^ e) - e;
60  }
61 }
62 
63 static av_noinline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed)
64 {
65  return get_symbol_inline(c, state, is_signed);
66 }
67 
68 static inline int get_vlc_symbol(GetBitContext *gb, VlcState *const state,
69  int bits)
70 {
71  int k, i, v, ret;
72 
73  i = state->count;
74  k = 0;
75  while (i < state->error_sum) { // FIXME: optimize
76  k++;
77  i += i;
78  }
79 
80  assert(k <= 8);
81 
82  v = get_sr_golomb(gb, k, 12, bits);
83  ff_dlog(NULL, "v:%d bias:%d error:%d drift:%d count:%d k:%d",
84  v, state->bias, state->error_sum, state->drift, state->count, k);
85 
86  v ^= ((2 * state->drift + state->count) >> 31);
87 
88  ret = fold(v + state->bias, bits);
89 
90  update_vlc_state(state, v);
91 
92  return ret;
93 }
94 
96  int16_t *sample[2],
97  int plane_index, int bits)
98 {
99  PlaneContext *const p = &s->plane[plane_index];
100  RangeCoder *const c = &s->c;
101  int x;
102  int run_count = 0;
103  int run_mode = 0;
104  int run_index = s->run_index;
105 
106  for (x = 0; x < w; x++) {
107  int diff, context, sign;
108 
109  context = get_context(p, sample[1] + x, sample[0] + x, sample[1] + x);
110  if (context < 0) {
111  context = -context;
112  sign = 1;
113  } else
114  sign = 0;
115 
116  av_assert2(context < p->context_count);
117 
118  if (s->ac != AC_GOLOMB_RICE) {
119  diff = get_symbol_inline(c, p->state[context], 1);
120  } else {
121  if (context == 0 && run_mode == 0)
122  run_mode = 1;
123 
124  if (run_mode) {
125  if (run_count == 0 && run_mode == 1) {
126  if (get_bits1(&s->gb)) {
127  run_count = 1 << ff_log2_run[run_index];
128  if (x + run_count <= w)
129  run_index++;
130  } else {
131  if (ff_log2_run[run_index])
132  run_count = get_bits(&s->gb, ff_log2_run[run_index]);
133  else
134  run_count = 0;
135  if (run_index)
136  run_index--;
137  run_mode = 2;
138  }
139  }
140  run_count--;
141  if (run_count < 0) {
142  run_mode = 0;
143  run_count = 0;
144  diff = get_vlc_symbol(&s->gb, &p->vlc_state[context],
145  bits);
146  if (diff >= 0)
147  diff++;
148  } else
149  diff = 0;
150  } else
151  diff = get_vlc_symbol(&s->gb, &p->vlc_state[context], bits);
152 
153  ff_dlog(s->avctx, "count:%d index:%d, mode:%d, x:%d pos:%d\n",
154  run_count, run_index, run_mode, x, get_bits_count(&s->gb));
155  }
156 
157  if (sign)
158  diff = -diff;
159 
160  sample[1][x] = (predict(sample[1] + x, sample[0] + x) + diff) &
161  ((1 << bits) - 1);
162  }
163  s->run_index = run_index;
164 }
165 
167  int w, int h, int stride, int plane_index)
168 {
169  int x, y;
170  int16_t *sample[2];
171  sample[0] = s->sample_buffer + 3;
172  sample[1] = s->sample_buffer + w + 6 + 3;
173 
174  s->run_index = 0;
175 
176  memset(s->sample_buffer, 0, 2 * (w + 6) * sizeof(*s->sample_buffer));
177 
178  for (y = 0; y < h; y++) {
179  int16_t *temp = sample[0]; // FIXME: try a normal buffer
180 
181  sample[0] = sample[1];
182  sample[1] = temp;
183 
184  sample[1][-1] = sample[0][0];
185  sample[0][w] = sample[0][w - 1];
186 
187 // { START_TIMER
188  if (s->avctx->bits_per_raw_sample <= 8) {
189  decode_line(s, w, sample, plane_index, 8);
190  for (x = 0; x < w; x++)
191  src[x + stride * y] = sample[1][x];
192  } else {
193  decode_line(s, w, sample, plane_index,
195  if (s->packed_at_lsb) {
196  for (x = 0; x < w; x++)
197  ((uint16_t *)(src + stride * y))[x] = sample[1][x];
198  } else {
199  for (x = 0; x < w; x++)
200  ((uint16_t *)(src + stride * y))[x] = sample[1][x] << (16 - s->avctx->bits_per_raw_sample);
201  }
202  }
203 // STOP_TIMER("decode-line") }
204  }
205 }
206 
207 static void decode_rgb_frame(FFV1Context *s, uint8_t *src[3], int w, int h,
208  int stride[3])
209 {
210  int x, y, p;
211  int16_t *sample[4][2];
212  int lbd = s->avctx->bits_per_raw_sample <= 8;
213  int bits = s->avctx->bits_per_raw_sample > 0
215  : 8;
216  int offset = 1 << bits;
217 
218  for (x = 0; x < 4; x++) {
219  sample[x][0] = s->sample_buffer + x * 2 * (w + 6) + 3;
220  sample[x][1] = s->sample_buffer + (x * 2 + 1) * (w + 6) + 3;
221  }
222 
223  s->run_index = 0;
224 
225  memset(s->sample_buffer, 0, 8 * (w + 6) * sizeof(*s->sample_buffer));
226 
227  for (y = 0; y < h; y++) {
228  for (p = 0; p < 3 + s->transparency; p++) {
229  int16_t *temp = sample[p][0]; //FIXME try a normal buffer
230 
231  sample[p][0] = sample[p][1];
232  sample[p][1] = temp;
233 
234  sample[p][1][-1] = sample[p][0][0];
235  sample[p][0][w] = sample[p][0][w - 1];
236  if (lbd)
237  decode_line(s, w, sample[p], (p + 1) / 2, 9);
238  else
239  decode_line(s, w, sample[p], (p + 1) / 2, bits + 1);
240  }
241  for (x = 0; x < w; x++) {
242  int g = sample[0][1][x];
243  int b = sample[1][1][x];
244  int r = sample[2][1][x];
245  int a = sample[3][1][x];
246 
247  b -= offset;
248  r -= offset;
249  g -= (b + r) >> 2;
250  b += g;
251  r += g;
252 
253  if (lbd)
254  *((uint32_t *)(src[0] + x * 4 + stride[0] * y)) = b +
255  (g << 8) + (r << 16) + (a << 24);
256  else {
257  *((uint16_t *)(src[0] + x * 2 + stride[0] * y)) = b;
258  *((uint16_t *)(src[1] + x * 2 + stride[1] * y)) = g;
259  *((uint16_t *)(src[2] + x * 2 + stride[2] * y)) = r;
260  }
261  }
262  }
263 }
264 
266 {
267  RangeCoder *c = &fs->c;
269  unsigned ps, i, context_count;
270  memset(state, 128, sizeof(state));
271 
272  if (fs->ac == AC_RANGE_CUSTOM_TAB) {
273  for (i = 1; i < 256; i++) {
274  fs->c.one_state[i] = f->state_transition[i];
275  fs->c.zero_state[256 - i] = 256 - fs->c.one_state[i];
276  }
277  }
278 
279  fs->slice_x = get_symbol(c, state, 0) * f->width;
280  fs->slice_y = get_symbol(c, state, 0) * f->height;
281  fs->slice_width = (get_symbol(c, state, 0) + 1) * f->width + fs->slice_x;
282  fs->slice_height = (get_symbol(c, state, 0) + 1) * f->height + fs->slice_y;
283 
284  fs->slice_x /= f->num_h_slices;
285  fs->slice_y /= f->num_v_slices;
286  fs->slice_width = fs->slice_width / f->num_h_slices - fs->slice_x;
287  fs->slice_height = fs->slice_height / f->num_v_slices - fs->slice_y;
288  if ((unsigned)fs->slice_width > f->width ||
289  (unsigned)fs->slice_height > f->height)
290  return AVERROR_INVALIDDATA;
291  if ((unsigned)fs->slice_x + (uint64_t)fs->slice_width > f->width ||
292  (unsigned)fs->slice_y + (uint64_t)fs->slice_height > f->height)
293  return AVERROR_INVALIDDATA;
294 
295  for (i = 0; i < f->plane_count; i++) {
296  PlaneContext *const p = &fs->plane[i];
297  int idx = get_symbol(c, state, 0);
298  if (idx > (unsigned)f->quant_table_count) {
299  av_log(f->avctx, AV_LOG_ERROR, "quant_table_index out of range\n");
300  return AVERROR_INVALIDDATA;
301  }
302  p->quant_table_index = idx;
303  memcpy(p->quant_table, f->quant_tables[idx], sizeof(p->quant_table));
304  context_count = f->context_count[idx];
305 
306  if (p->context_count < context_count) {
307  av_freep(&p->state);
308  av_freep(&p->vlc_state);
309  }
311  }
312 
313  ps = get_symbol(c, state, 0);
314  if (ps == 1) {
315  f->cur->interlaced_frame = 1;
316  f->cur->top_field_first = 1;
317  } else if (ps == 2) {
318  f->cur->interlaced_frame = 1;
319  f->cur->top_field_first = 0;
320  } else if (ps == 3) {
321  f->cur->interlaced_frame = 0;
322  }
323  f->cur->sample_aspect_ratio.num = get_symbol(c, state, 0);
324  f->cur->sample_aspect_ratio.den = get_symbol(c, state, 0);
325 
326  if (av_image_check_sar(f->width, f->height,
327  f->cur->sample_aspect_ratio) < 0) {
328  av_log(f->avctx, AV_LOG_WARNING, "ignoring invalid SAR: %u/%u\n",
331  f->cur->sample_aspect_ratio = (AVRational){ 0, 1 };
332  }
333 
334  return 0;
335 }
336 
337 static int decode_slice(AVCodecContext *c, void *arg)
338 {
339  FFV1Context *fs = *(void **)arg;
340  FFV1Context *f = fs->avctx->priv_data;
341  int width, height, x, y, ret;
343  ? (c->bits_per_raw_sample > 8) + 1
344  : 4;
345  AVFrame *const p = f->cur;
346 
347  if (f->version > 2) {
348  if (decode_slice_header(f, fs) < 0) {
349  fs->slice_damaged = 1;
350  return AVERROR_INVALIDDATA;
351  }
352  }
353  if ((ret = ffv1_init_slice_state(f, fs)) < 0)
354  return ret;
355  if (f->cur->key_frame)
356  ffv1_clear_slice_state(f, fs);
357  width = fs->slice_width;
358  height = fs->slice_height;
359  x = fs->slice_x;
360  y = fs->slice_y;
361 
362  if (fs->ac == AC_GOLOMB_RICE) {
363  if (f->version == 3 && f->minor_version > 1 || f->version > 3)
364  get_rac(&fs->c, (uint8_t[]) { 129 });
365  fs->ac_byte_count = f->version > 2 || (!x && !y) ? fs->c.bytestream - fs->c.bytestream_start - 1 : 0;
367  (fs->c.bytestream_end - fs->c.bytestream_start -
368  fs->ac_byte_count) * 8);
369  }
370 
371  av_assert1(width && height);
372  if (f->colorspace == 0) {
373  const int chroma_width = AV_CEIL_RSHIFT(width, f->chroma_h_shift);
374  const int chroma_height = AV_CEIL_RSHIFT(height, f->chroma_v_shift);
375  const int cx = x >> f->chroma_h_shift;
376  const int cy = y >> f->chroma_v_shift;
377  decode_plane(fs, p->data[0] + ps * x + y * p->linesize[0], width,
378  height, p->linesize[0],
379  0);
380 
381  if (f->chroma_planes) {
382  decode_plane(fs, p->data[1] + ps * cx + cy * p->linesize[1],
383  chroma_width, chroma_height, p->linesize[1],
384  1);
385  decode_plane(fs, p->data[2] + ps * cx + cy * p->linesize[2],
386  chroma_width, chroma_height, p->linesize[2],
387  1);
388  }
389  if (fs->transparency)
390  decode_plane(fs, p->data[3] + ps * x + y * p->linesize[3], width,
391  height, p->linesize[3],
392  2);
393  } else {
394  uint8_t *planes[3] = { p->data[0] + ps * x + y * p->linesize[0],
395  p->data[1] + ps * x + y * p->linesize[1],
396  p->data[2] + ps * x + y * p->linesize[2] };
397  decode_rgb_frame(fs, planes, width, height, p->linesize);
398  }
399  if (fs->ac != AC_GOLOMB_RICE && f->version > 2) {
400  int v;
401  get_rac(&fs->c, (uint8_t[]) { 129 });
402  v = fs->c.bytestream_end - fs->c.bytestream - 2 - 5 * f->ec;
403  if (v) {
404  av_log(f->avctx, AV_LOG_ERROR, "bytestream end mismatching by %d\n",
405  v);
406  fs->slice_damaged = 1;
407  }
408  }
409 
410  emms_c();
411 
412  return 0;
413 }
414 
415 static int read_quant_table(RangeCoder *c, int16_t *quant_table, int scale)
416 {
417  int v;
418  int i = 0;
420 
421  memset(state, 128, sizeof(state));
422 
423  for (v = 0; i < 128; v++) {
424  unsigned len = get_symbol(c, state, 0) + 1;
425 
426  if (len > 128 - i)
427  return -1;
428 
429  while (len--) {
430  quant_table[i] = scale * v;
431  i++;
432  }
433  }
434 
435  for (i = 1; i < 128; i++)
436  quant_table[256 - i] = -quant_table[i];
437  quant_table[128] = -quant_table[127];
438 
439  return 2 * v - 1;
440 }
441 
443  int16_t quant_table[MAX_CONTEXT_INPUTS][256])
444 {
445  int i;
446  int context_count = 1;
447 
448  for (i = 0; i < 5; i++) {
449  context_count *= read_quant_table(c, quant_table[i], context_count);
450  if (context_count > 32768U) {
451  return -1;
452  }
453  }
454  return (context_count + 1) / 2;
455 }
456 
458 {
459  RangeCoder *const c = &f->c;
461  int i, j, k, ret;
462  uint8_t state2[32][CONTEXT_SIZE];
463 
464  memset(state2, 128, sizeof(state2));
465  memset(state, 128, sizeof(state));
466 
468  ff_build_rac_states(c, 0.05 * (1LL << 32), 256 - 8);
469 
470  f->version = get_symbol(c, state, 0);
471  if (f->version > 2) {
472  c->bytestream_end -= 4;
473  f->minor_version = get_symbol(c, state, 0);
474  }
475  f->ac = get_symbol(c, state, 0);
476 
477  if (f->ac == AC_RANGE_CUSTOM_TAB) {
478  for (i = 1; i < 256; i++)
479  f->state_transition[i] = get_symbol(c, state, 1) + c->one_state[i];
480  }
481 
482  f->colorspace = get_symbol(c, state, 0); //YUV cs type
483  f->avctx->bits_per_raw_sample = get_symbol(c, state, 0);
484  f->chroma_planes = get_rac(c, state);
485  f->chroma_h_shift = get_symbol(c, state, 0);
486  f->chroma_v_shift = get_symbol(c, state, 0);
487  f->transparency = get_rac(c, state);
488  f->plane_count = 2 + f->transparency;
489  f->num_h_slices = 1 + get_symbol(c, state, 0);
490  f->num_v_slices = 1 + get_symbol(c, state, 0);
491 
492  if (f->num_h_slices > (unsigned)f->width ||
493  f->num_v_slices > (unsigned)f->height) {
494  av_log(f->avctx, AV_LOG_ERROR, "too many slices\n");
495  return AVERROR_INVALIDDATA;
496  }
497 
498  f->quant_table_count = get_symbol(c, state, 0);
499  if (f->quant_table_count > (unsigned)MAX_QUANT_TABLES)
500  return AVERROR_INVALIDDATA;
501  for (i = 0; i < f->quant_table_count; i++) {
502  f->context_count[i] = read_quant_tables(c, f->quant_tables[i]);
503  if (f->context_count[i] < 0) {
504  av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n");
505  return AVERROR_INVALIDDATA;
506  }
507  }
508  if ((ret = ffv1_allocate_initial_states(f)) < 0)
509  return ret;
510 
511  for (i = 0; i < f->quant_table_count; i++)
512  if (get_rac(c, state)) {
513  for (j = 0; j < f->context_count[i]; j++)
514  for (k = 0; k < CONTEXT_SIZE; k++) {
515  int pred = j ? f->initial_states[i][j - 1][k] : 128;
516  f->initial_states[i][j][k] =
517  (pred + get_symbol(c, state2[k], 1)) & 0xFF;
518  }
519  }
520 
521  if (f->version > 2) {
522  f->ec = get_symbol(c, state, 0);
523  }
524 
525  if (f->version > 2) {
526  unsigned v;
529  if (v) {
530  av_log(f->avctx, AV_LOG_ERROR, "CRC mismatch %X!\n", v);
531  return AVERROR_INVALIDDATA;
532  }
533  }
534 
536  "FFV1 version %d.%d colorspace %d - %d bits - %d/%d planes, %s transparent - tile geometry %dx%d - %s\n",
538  f->plane_count, f->chroma_planes, f->transparency ? "" : "not",
539  f->num_h_slices, f->num_v_slices,
540  f->ec ? "per-slice crc" : "no crc");
541 
542  return 0;
543 }
544 
545 
546 static int read_header(FFV1Context *f)
547 {
549  int i, j, context_count = -1;
550  RangeCoder *const c = &f->slice_context[0]->c;
551 
552  memset(state, 128, sizeof(state));
553 
554  if (f->version < 2) {
556  unsigned v = get_symbol(c, state, 0);
557  if (v > 1) {
559  "invalid version %d in version 1 header\n", v);
560  return AVERROR_INVALIDDATA;
561  }
562  f->version = v;
563 
564  f->ac = get_symbol(c, state, 0);
565 
566  if (f->ac == AC_RANGE_CUSTOM_TAB) {
567  for (i = 1; i < 256; i++)
568  f->state_transition[i] =
569  get_symbol(c, state, 1) + c->one_state[i];
570  }
571 
572  colorspace = get_symbol(c, state, 0); //YUV cs type
573  bits_per_raw_sample = f->version > 0 ? get_symbol(c, state, 0) : f->avctx->bits_per_raw_sample;
574  chroma_planes = get_rac(c, state);
575  chroma_h_shift = get_symbol(c, state, 0);
576  chroma_v_shift = get_symbol(c, state, 0);
577  transparency = get_rac(c, state);
578 
579  if (f->plane_count) {
580  if (colorspace != f->colorspace ||
581  bits_per_raw_sample != f->avctx->bits_per_raw_sample ||
582  chroma_planes != f->chroma_planes ||
583  chroma_h_shift != f->chroma_h_shift ||
584  chroma_v_shift != f->chroma_v_shift ||
585  transparency != f->transparency) {
586  av_log(f->avctx, AV_LOG_ERROR, "Invalid change of global parameters\n");
587  return AVERROR_INVALIDDATA;
588  }
589  }
590 
591  f->colorspace = colorspace;
597 
598  f->plane_count = 2 + f->transparency;
599  }
600 
601  if (f->colorspace == 0) {
602  if (f->transparency && f->avctx->bits_per_raw_sample > 8) {
604  "Transparency not supported for bit depth %d\n",
606  return AVERROR(ENOSYS);
607  }
608  if (!f->transparency && !f->chroma_planes) {
609  if (f->avctx->bits_per_raw_sample <= 8)
611  else
613  } else if (f->avctx->bits_per_raw_sample <= 8 && !f->transparency) {
614  switch (16 * f->chroma_h_shift + f->chroma_v_shift) {
615  case 0x00:
617  break;
618  case 0x01:
620  break;
621  case 0x10:
623  break;
624  case 0x11:
626  break;
627  case 0x20:
629  break;
630  case 0x22:
632  break;
633  default:
634  av_log(f->avctx, AV_LOG_ERROR, "format not supported\n");
635  return AVERROR(ENOSYS);
636  }
637  } else if (f->avctx->bits_per_raw_sample <= 8 && f->transparency) {
638  switch (16 * f->chroma_h_shift + f->chroma_v_shift) {
639  case 0x00:
641  break;
642  case 0x10:
644  break;
645  case 0x11:
647  break;
648  default:
649  av_log(f->avctx, AV_LOG_ERROR, "format not supported\n");
650  return AVERROR(ENOSYS);
651  }
652  } else if (f->avctx->bits_per_raw_sample == 9) {
653  f->packed_at_lsb = 1;
654  switch (16 * f->chroma_h_shift + f->chroma_v_shift) {
655  case 0x00:
657  break;
658  case 0x10:
660  break;
661  case 0x11:
663  break;
664  default:
665  av_log(f->avctx, AV_LOG_ERROR, "format not supported\n");
666  return AVERROR(ENOSYS);
667  }
668  } else if (f->avctx->bits_per_raw_sample == 10) {
669  f->packed_at_lsb = 1;
670  switch (16 * f->chroma_h_shift + f->chroma_v_shift) {
671  case 0x00:
673  break;
674  case 0x10:
676  break;
677  case 0x11:
679  break;
680  default:
681  av_log(f->avctx, AV_LOG_ERROR, "format not supported\n");
682  return AVERROR(ENOSYS);
683  }
684  } else {
685  switch (16 * f->chroma_h_shift + f->chroma_v_shift) {
686  case 0x00:
688  break;
689  case 0x10:
691  break;
692  case 0x11:
694  break;
695  default:
696  av_log(f->avctx, AV_LOG_ERROR, "format not supported\n");
697  return AVERROR(ENOSYS);
698  }
699  }
700  } else if (f->colorspace == 1) {
701  if (f->chroma_h_shift || f->chroma_v_shift) {
703  "chroma subsampling not supported in this colorspace\n");
704  return AVERROR(ENOSYS);
705  }
706  if (f->transparency) {
708  "Transparency not supported in this colorspace\n");
709  return AVERROR(ENOSYS);
710  }
711  switch (f->avctx->bits_per_raw_sample) {
712  case 0:
713  case 8:
715  break;
716  case 9:
718  break;
719  case 10:
721  break;
722  default:
724  "bit depth %d not supported\n",
726  return AVERROR(ENOSYS);
727  }
728  } else {
729  av_log(f->avctx, AV_LOG_ERROR, "colorspace not supported\n");
730  return AVERROR(ENOSYS);
731  }
732 
733  ff_dlog(f->avctx, "%d %d %d\n",
735  if (f->version < 2) {
736  context_count = read_quant_tables(c, f->quant_table);
737  if (context_count < 0) {
738  av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n");
739  return AVERROR_INVALIDDATA;
740  }
741  } else if (f->version < 3) {
742  f->slice_count = get_symbol(c, state, 0);
743  } else {
744  const uint8_t *p = c->bytestream_end;
745  for (f->slice_count = 0;
746  f->slice_count < MAX_SLICES && 3 < p - c->bytestream_start;
747  f->slice_count++) {
748  int trailer = 3 + 5 * !!f->ec;
749  int size = AV_RB24(p - trailer);
750  if (size + trailer > p - c->bytestream_start)
751  break;
752  p -= size + trailer;
753  }
754  }
755  if (f->slice_count > (unsigned)MAX_SLICES || f->slice_count <= 0) {
756  av_log(f->avctx, AV_LOG_ERROR, "slice count %d is invalid\n",
757  f->slice_count);
758  return AVERROR_INVALIDDATA;
759  }
760 
761  for (j = 0; j < f->slice_count; j++) {
762  FFV1Context *fs = f->slice_context[j];
763  fs->ac = f->ac;
764  fs->packed_at_lsb = f->packed_at_lsb;
765 
766  fs->slice_damaged = 0;
767 
768  if (f->version == 2) {
769  fs->slice_x = get_symbol(c, state, 0) * f->width;
770  fs->slice_y = get_symbol(c, state, 0) * f->height;
771  fs->slice_width =
772  (get_symbol(c, state, 0) + 1) * f->width + fs->slice_x;
773  fs->slice_height =
774  (get_symbol(c, state, 0) + 1) * f->height + fs->slice_y;
775 
776  fs->slice_x /= f->num_h_slices;
777  fs->slice_y /= f->num_v_slices;
778  fs->slice_width = fs->slice_width / f->num_h_slices - fs->slice_x;
779  fs->slice_height = fs->slice_height / f->num_v_slices - fs->slice_y;
780  if ((unsigned)fs->slice_width > f->width ||
781  (unsigned)fs->slice_height > f->height)
782  return AVERROR_INVALIDDATA;
783  if ((unsigned)fs->slice_x + (uint64_t)fs->slice_width > f->width
784  || (unsigned)fs->slice_y + (uint64_t)fs->slice_height >
785  f->height)
786  return AVERROR_INVALIDDATA;
787  }
788 
789  for (i = 0; i < f->plane_count; i++) {
790  PlaneContext *const p = &fs->plane[i];
791 
792  if (f->version == 2) {
793  int idx = get_symbol(c, state, 0);
794  if (idx > (unsigned)f->quant_table_count) {
796  "quant_table_index out of range\n");
797  return AVERROR_INVALIDDATA;
798  }
799  p->quant_table_index = idx;
800  memcpy(p->quant_table, f->quant_tables[idx],
801  sizeof(p->quant_table));
802  context_count = f->context_count[idx];
803  } else {
804  memcpy(p->quant_table, f->quant_table, sizeof(p->quant_table));
805  }
806 
807  if (f->version <= 2) {
808  av_assert0(context_count >= 0);
809  if (p->context_count < context_count) {
810  av_freep(&p->state);
811  av_freep(&p->vlc_state);
812  }
814  }
815  }
816  }
817  return 0;
818 }
819 
821 {
822  FFV1Context *f = avctx->priv_data;
823  int ret;
824 
825  ffv1_common_init(avctx);
826 
828  if (!f->last_picture)
829  return AVERROR(ENOMEM);
830 
831  if (avctx->extradata && (ret = read_extra_header(f)) < 0)
832  return ret;
833 
834  if ((ret = ffv1_init_slice_contexts(f)) < 0)
835  return ret;
836 
837  return 0;
838 }
839 
841  int *got_frame, AVPacket *avpkt)
842 {
843  uint8_t *buf = avpkt->data;
844  int buf_size = avpkt->size;
845  FFV1Context *f = avctx->priv_data;
846  RangeCoder *const c = &f->slice_context[0]->c;
847  int i, ret;
848  uint8_t keystate = 128;
849  uint8_t *buf_p;
850  AVFrame *const p = data;
851 
852  f->cur = p;
853 
854  ff_init_range_decoder(c, buf, buf_size);
855  ff_build_rac_states(c, 0.05 * (1LL << 32), 256 - 8);
856 
857  p->pict_type = AV_PICTURE_TYPE_I; //FIXME I vs. P
858  if (get_rac(c, &keystate)) {
859  p->key_frame = 1;
860  f->key_frame_ok = 0;
861  if ((ret = read_header(f)) < 0)
862  return ret;
863  f->key_frame_ok = 1;
864  } else {
865  if (!f->key_frame_ok) {
866  av_log(avctx, AV_LOG_ERROR,
867  "Cannot decode non-keyframe without valid keyframe\n");
868  return AVERROR_INVALIDDATA;
869  }
870  p->key_frame = 0;
871  }
872 
873  if ((ret = ff_get_buffer(avctx, p, AV_GET_BUFFER_FLAG_REF)) < 0) {
874  av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
875  return ret;
876  }
877 
878  if (avctx->debug & FF_DEBUG_PICT_INFO)
879  av_log(avctx, AV_LOG_DEBUG,
880  "ver:%d keyframe:%d coder:%d ec:%d slices:%d bps:%d\n",
881  f->version, p->key_frame, f->ac, f->ec, f->slice_count,
883 
884  buf_p = buf + buf_size;
885  for (i = f->slice_count - 1; i >= 0; i--) {
886  FFV1Context *fs = f->slice_context[i];
887  int trailer = 3 + 5 * !!f->ec;
888  int v;
889 
890  if (i || f->version > 2)
891  v = AV_RB24(buf_p - trailer) + trailer;
892  else
893  v = buf_p - c->bytestream_start;
894  if (buf_p - c->bytestream_start < v) {
895  av_log(avctx, AV_LOG_ERROR, "Slice pointer chain broken\n");
896  return AVERROR_INVALIDDATA;
897  }
898  buf_p -= v;
899 
900  if (f->ec) {
901  unsigned crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, buf_p, v);
902  if (crc) {
903  av_log(f->avctx, AV_LOG_ERROR, "CRC mismatch %X!\n", crc);
904  fs->slice_damaged = 1;
905  }
906  }
907 
908  if (i) {
909  ff_init_range_decoder(&fs->c, buf_p, v);
910  } else
911  fs->c.bytestream_end = buf_p + v;
912 
913  fs->cur = p;
914  }
915 
916  avctx->execute(avctx, decode_slice, &f->slice_context[0], NULL,
917  f->slice_count,
918  sizeof(void *));
919 
920  for (i = f->slice_count - 1; i >= 0; i--) {
921  FFV1Context *fs = f->slice_context[i];
922  int j;
923  if (fs->slice_damaged && f->last_picture->data[0]) {
924  const uint8_t *src[4];
925  uint8_t *dst[4];
926  for (j = 0; j < 4; j++) {
927  int sh = (j == 1 || j == 2) ? f->chroma_h_shift : 0;
928  int sv = (j == 1 || j == 2) ? f->chroma_v_shift : 0;
929  dst[j] = p->data[j] + p->linesize[j] *
930  (fs->slice_y >> sv) + (fs->slice_x >> sh);
931  src[j] = f->last_picture->data[j] +
932  f->last_picture->linesize[j] *
933  (fs->slice_y >> sv) + (fs->slice_x >> sh);
934  }
935  av_image_copy(dst, p->linesize, src,
937  avctx->pix_fmt, fs->slice_width,
938  fs->slice_height);
939  }
940  }
941 
942  f->picture_number++;
943 
945  if ((ret = av_frame_ref(f->last_picture, p)) < 0)
946  return ret;
947  f->cur = NULL;
948 
949  *got_frame = 1;
950 
951  return buf_size;
952 }
953 
955 {
956  FFV1Context *s = avctx->priv_data;;
957 
959 
960  ffv1_close(avctx);
961 
962  return 0;
963 }
964 
966  .name = "ffv1",
967  .long_name = NULL_IF_CONFIG_SMALL("FFmpeg video codec #1"),
968  .type = AVMEDIA_TYPE_VIDEO,
969  .id = AV_CODEC_ID_FFV1,
970  .priv_data_size = sizeof(FFV1Context),
972  .close = ffv1_decode_close,
974  .capabilities = AV_CODEC_CAP_DR1 /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/ |
976 };
static av_always_inline int fold(int diff, int bits)
Definition: ffv1.h:124
int ffv1_allocate_initial_states(FFV1Context *f)
Definition: ffv1.c:233
const uint8_t ff_log2_run[41]
Definition: bitstream.c:37
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:54
int size
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:1768
This structure describes decoded (raw) audio or video data.
Definition: frame.h:140
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
Definition: crc.c:312
av_cold int ffv1_common_init(AVCodecContext *avctx)
Definition: ffv1.c:132
Definition: vf_drawbox.c:37
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:64
misc image utilities
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:228
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:130
int16_t quant_table[MAX_CONTEXT_INPUTS][256]
Definition: ffv1.h:59
int quant_table_count
Definition: ffv1.h:112
int ffv1_init_slice_state(FFV1Context *f, FFV1Context *fs)
Definition: ffv1.c:152
static int decode_slice(AVCodecContext *c, void *arg)
Definition: ffv1dec.c:337
int slice_height
Definition: ffv1.h:119
#define MAX_CONTEXT_INPUTS
Definition: ffv1.h:37
int16_t * sample_buffer
Definition: ffv1.h:101
int version
Definition: ffv1.h:77
uint8_t zero_state[256]
Definition: rangecoder.h:40
Range coder.
uint8_t * bytestream_end
Definition: rangecoder.h:44
int num
numerator
Definition: rational.h:44
int size
Definition: avcodec.h:1347
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:271
static int read_quant_table(RangeCoder *c, int16_t *quant_table, int scale)
Definition: ffv1dec.c:415
#define AV_RB24
Definition: intreadwrite.h:64
static av_flatten int get_symbol_inline(RangeCoder *c, uint8_t *state, int is_signed)
Definition: ffv1dec.c:43
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1621
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:2776
static av_always_inline void predict(PredictorState *ps, float *coef, int output_enable)
Definition: aacdec.c:1792
#define sample
int height
Definition: ffv1.h:79
int stride
Definition: mace.c:144
AVCodec.
Definition: avcodec.h:3120
uint8_t one_state[256]
Definition: rangecoder.h:41
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Definition: mem.c:202
int plane_count
Definition: ffv1.h:90
int slice_damaged
Definition: ffv1.h:104
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:98
static int read_quant_tables(RangeCoder *c, int16_t quant_table[MAX_CONTEXT_INPUTS][256])
Definition: ffv1dec.c:442
uint8_t bits
Definition: crc.c:252
uint8_t
#define av_cold
Definition: attributes.h:66
static int get_rac(RangeCoder *c, uint8_t *const state)
Definition: rangecoder.h:115
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:68
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition: avassert.h:63
AVOptions.
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
Definition: crc.c:298
#define FF_DEBUG_PICT_INFO
Definition: avcodec.h:2627
int8_t bias
Definition: ffv1.h:54
#define b
Definition: input.c:52
RangeCoder c
Definition: ffv1.h:72
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
Definition: frame.c:199
#define emms_c()
Definition: internal.h:48
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1523
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:270
int slice_y
Definition: ffv1.h:121
uint8_t(*[MAX_QUANT_TABLES] initial_states)[32]
Definition: ffv1.h:98
const char data[16]
Definition: mxf.c:70
int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar)
Check if the given sample aspect ratio of an image is valid.
Definition: imgutils.c:234
uint8_t * data
Definition: avcodec.h:1346
static av_cold int ffv1_decode_close(AVCodecContext *avctx)
Definition: ffv1dec.c:954
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:182
uint8_t count
Definition: ffv1.h:55
bitstream reader API header.
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:140
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:268
static void decode_rgb_frame(FFV1Context *s, uint8_t *src[3], int w, int h, int stride[3])
Definition: ffv1dec.c:207
int interlaced_frame
The content of the picture is interlaced.
Definition: frame.h:263
VlcState * vlc_state
Definition: ffv1.h:63
high precision timer, useful to profile code
int minor_version
Definition: ffv1.h:78
int bits_per_raw_sample
Definition: ffv1.h:108
int slice_width
Definition: ffv1.h:118
#define r
Definition: input.c:51
GetBitContext gb
Definition: ffv1.h:73
#define src
Definition: vp8dsp.c:254
AVFrame * cur
Definition: ffv1.h:89
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:169
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:124
static int decode_slice_header(FFV1Context *f, FFV1Context *fs)
Definition: ffv1dec.c:265
int16_t quant_tables[MAX_QUANT_TABLES][MAX_CONTEXT_INPUTS][256]
Definition: ffv1.h:95
static int ffv1_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: ffv1dec.c:840
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:80
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:148
static av_cold int ffv1_decode_init(AVCodecContext *avctx)
Definition: ffv1dec.c:820
g
Definition: yuv2rgb.c:546
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:145
int context_count
Definition: ffv1.h:61
simple assert() macros that are a bit more flexible than ISO C assert().
const char * name
Name of the codec implementation.
Definition: avcodec.h:3127
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:265
#define MAX_SLICES
Definition: dxva2_hevc.c:32
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
Definition: imgutils.c:268
static int get_vlc_symbol(GetBitContext *gb, VlcState *const state, int bits)
Definition: ffv1dec.c:68
uint8_t * bytestream
Definition: rangecoder.h:43
static void decode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride, int plane_index)
Definition: ffv1dec.c:166
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:63
int ac
Definition: ffv1.h:91
int16_t quant_table[MAX_CONTEXT_INPUTS][256]
Definition: ffv1.h:94
#define AC_RANGE_CUSTOM_TAB
Definition: ffv1.h:41
int run_index
Definition: ffv1.h:99
Definition: ffv1.h:51
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:105
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:261
#define av_flatten
Definition: attributes.h:72
static av_noinline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed)
Definition: ffv1dec.c:63
uint8_t state_transition[256]
Definition: ffv1.h:97
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:201
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:247
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
#define FFMIN(a, b)
Definition: common.h:66
int num_h_slices
Definition: ffv1.h:117
static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
Definition: avconv.c:1288
#define MAX_QUANT_TABLES
Definition: ffv1.h:36
int colorspace
Definition: ffv1.h:100
static float quant_table[96]
Definition: binkaudio.c:42
static int get_context(PlaneContext *p, int16_t *src, int16_t *last, int16_t *last2)
Definition: ffv1.h:146
static void update_vlc_state(VlcState *const state, const int v)
Definition: ffv1.h:168
int slice_count
Definition: ffv1.h:115
void ff_build_rac_states(RangeCoder *c, int factor, int max_p)
Definition: rangecoder.c:62
int ac_byte_count
Definition: ffv1.h:92
static av_always_inline void decode_line(FFV1Context *s, int w, int16_t *sample[2], int plane_index, int bits)
Definition: ffv1dec.c:95
int16_t drift
Definition: ffv1.h:52
int packed_at_lsb
Definition: ffv1.h:109
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:262
av_cold int ffv1_init_slice_contexts(FFV1Context *f)
Definition: ffv1.c:186
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:546
if(ac->has_optimized_func)
static const float pred[4]
Definition: siprdata.h:259
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:266
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: avcodec.h:897
NULL
Definition: eval.c:55
static int width
Definition: utils.c:156
int context_count[MAX_QUANT_TABLES]
Definition: ffv1.h:96
Libavcodec external API header.
#define ff_dlog(ctx,...)
Definition: internal.h:60
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:158
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:170
int debug
debug
Definition: avcodec.h:2626
main external API structure.
Definition: avcodec.h:1409
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:242
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Definition: frame.h:206
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Definition: utils.c:589
int extradata_size
Definition: avcodec.h:1524
void ffv1_clear_slice_state(FFV1Context *f, FFV1Context *fs)
Definition: ffv1.c:248
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:267
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:263
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:65
rational number numerator/denominator
Definition: rational.h:43
av_cold void ff_init_range_decoder(RangeCoder *c, const uint8_t *buf, int buf_size)
Definition: rangecoder.c:52
#define AC_GOLOMB_RICE
Definition: ffv1.h:39
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition: get_bits.h:362
int picture_number
Definition: ffv1.h:84
uint16_t error_sum
Definition: ffv1.h:53
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:260
int key_frame_ok
Definition: ffv1.h:105
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:302
#define CONTEXT_SIZE
Definition: ffv1.h:34
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:264
int quant_table_index
Definition: ffv1.h:60
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:146
int height
Definition: gxfenc.c:72
static struct @174 state
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:59
Y , 8bpp.
Definition: pixfmt.h:67
common internal api header.
uint8_t(* state)[CONTEXT_SIZE]
Definition: ffv1.h:62
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:66
int den
denominator
Definition: rational.h:45
static av_cold int init(AVCodecParserContext *s)
Definition: h264_parser.c:582
uint8_t * bytestream_start
Definition: rangecoder.h:42
void * priv_data
Definition: avcodec.h:1451
int chroma_h_shift
Definition: ffv1.h:81
PlaneContext plane[MAX_PLANES]
Definition: ffv1.h:93
int transparency
Definition: ffv1.h:82
int chroma_v_shift
Definition: ffv1.h:81
int top_field_first
If the content is interlaced, is top field displayed first.
Definition: frame.h:268
int len
int chroma_planes
Definition: ffv1.h:80
av_cold int ffv1_close(AVCodecContext *avctx)
Definition: ffv1.c:275
int key_frame
1 -> keyframe, 0-> not
Definition: frame.h:196
struct FFV1Context * slice_context[MAX_SLICES]
Definition: ffv1.h:114
#define av_noinline
Definition: attributes.h:48
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:96
#define av_always_inline
Definition: attributes.h:40
int ec
Definition: ffv1.h:103
static int get_sr_golomb(GetBitContext *gb, int k, int limit, int esc_len)
read signed golomb rice code (ffv1).
Definition: golomb.h:361
int num_v_slices
Definition: ffv1.h:116
int(* execute)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size)
The codec may call this to execute several independent things.
Definition: avcodec.h:2846
exp golomb vlc stuff
This structure stores compressed data.
Definition: avcodec.h:1323
static int read_extra_header(FFV1Context *f)
Definition: ffv1dec.c:457
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
Definition: avcodec.h:1183
AVCodecContext * avctx
Definition: ffv1.h:71
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
Definition: pixdesc.h:146
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:838
int slice_x
Definition: ffv1.h:120
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:267
AVFrame * last_picture
Definition: ffv1.h:87
AVCodec ff_ffv1_decoder
Definition: ffv1dec.c:965
int width
Definition: ffv1.h:79
#define AV_CEIL_RSHIFT(a, b)
Fast a / (1 << b) rounded toward +inf, assuming a >= 0 and b >= 0.
Definition: common.h:57
bitstream writer API