FFmpeg
proresenc_anatoliy.c
Go to the documentation of this file.
1 /*
2  * Apple ProRes encoder
3  *
4  * Copyright (c) 2011 Anatoliy Wasserman
5  * Copyright (c) 2012 Konstantin Shishkov
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 /**
25  * @file
26  * Apple ProRes encoder (Anatoliy Wasserman version)
27  * Known FOURCCs: 'ap4h' (444), 'apch' (HQ), 'apcn' (422), 'apcs' (LT), 'acpo' (Proxy)
28  */
29 
30 #include "libavutil/mem.h"
31 #include "libavutil/mem_internal.h"
32 #include "libavutil/opt.h"
33 #include "avcodec.h"
34 #include "codec_internal.h"
35 #include "encode.h"
36 #include "profiles.h"
37 #include "proresdata.h"
38 #include "put_bits.h"
39 #include "bytestream.h"
40 #include "fdctdsp.h"
41 
42 #define DEFAULT_SLICE_MB_WIDTH 8
43 
44 static const AVProfile profiles[] = {
45  { AV_PROFILE_PRORES_PROXY, "apco"},
46  { AV_PROFILE_PRORES_LT, "apcs"},
47  { AV_PROFILE_PRORES_STANDARD, "apcn"},
48  { AV_PROFILE_PRORES_HQ, "apch"},
49  { AV_PROFILE_PRORES_4444, "ap4h"},
50  { AV_PROFILE_PRORES_XQ, "ap4x"},
52 };
53 
54 static const int qp_start_table[] = { 8, 3, 2, 1, 1, 1};
55 static const int qp_end_table[] = { 13, 9, 6, 6, 5, 4};
56 static const int bitrate_table[] = { 1000, 2100, 3500, 5400, 7000, 10000};
57 
61  AVCOL_TRC_ARIB_STD_B67, INT_MAX };
63  AVCOL_SPC_BT2020_NCL, INT_MAX };
64 
65 static const uint8_t QMAT_LUMA[6][64] = {
66  {
67  4, 7, 9, 11, 13, 14, 15, 63,
68  7, 7, 11, 12, 14, 15, 63, 63,
69  9, 11, 13, 14, 15, 63, 63, 63,
70  11, 11, 13, 14, 63, 63, 63, 63,
71  11, 13, 14, 63, 63, 63, 63, 63,
72  13, 14, 63, 63, 63, 63, 63, 63,
73  13, 63, 63, 63, 63, 63, 63, 63,
74  63, 63, 63, 63, 63, 63, 63, 63
75  }, {
76  4, 5, 6, 7, 9, 11, 13, 15,
77  5, 5, 7, 8, 11, 13, 15, 17,
78  6, 7, 9, 11, 13, 15, 15, 17,
79  7, 7, 9, 11, 13, 15, 17, 19,
80  7, 9, 11, 13, 14, 16, 19, 23,
81  9, 11, 13, 14, 16, 19, 23, 29,
82  9, 11, 13, 15, 17, 21, 28, 35,
83  11, 13, 16, 17, 21, 28, 35, 41
84  }, {
85  4, 4, 5, 5, 6, 7, 7, 9,
86  4, 4, 5, 6, 7, 7, 9, 9,
87  5, 5, 6, 7, 7, 9, 9, 10,
88  5, 5, 6, 7, 7, 9, 9, 10,
89  5, 6, 7, 7, 8, 9, 10, 12,
90  6, 7, 7, 8, 9, 10, 12, 15,
91  6, 7, 7, 9, 10, 11, 14, 17,
92  7, 7, 9, 10, 11, 14, 17, 21
93  }, {
94  4, 4, 4, 4, 4, 4, 4, 4,
95  4, 4, 4, 4, 4, 4, 4, 4,
96  4, 4, 4, 4, 4, 4, 4, 4,
97  4, 4, 4, 4, 4, 4, 4, 5,
98  4, 4, 4, 4, 4, 4, 5, 5,
99  4, 4, 4, 4, 4, 5, 5, 6,
100  4, 4, 4, 4, 5, 5, 6, 7,
101  4, 4, 4, 4, 5, 6, 7, 7
102  }, { /* 444 */
103  4, 4, 4, 4, 4, 4, 4, 4,
104  4, 4, 4, 4, 4, 4, 4, 4,
105  4, 4, 4, 4, 4, 4, 4, 4,
106  4, 4, 4, 4, 4, 4, 4, 5,
107  4, 4, 4, 4, 4, 4, 5, 5,
108  4, 4, 4, 4, 4, 5, 5, 6,
109  4, 4, 4, 4, 5, 5, 6, 7,
110  4, 4, 4, 4, 5, 6, 7, 7
111  }, { /* 444 XQ */
112  2, 2, 2, 2, 2, 2, 2, 2,
113  2, 2, 2, 2, 2, 2, 2, 2,
114  2, 2, 2, 2, 2, 2, 2, 2,
115  2, 2, 2, 2, 2, 2, 2, 3,
116  2, 2, 2, 2, 2, 2, 3, 3,
117  2, 2, 2, 2, 2, 3, 3, 3,
118  2, 2, 2, 2, 3, 3, 3, 4,
119  2, 2, 2, 2, 3, 3, 4, 4,
120  }
121 };
122 
123 static const uint8_t QMAT_CHROMA[6][64] = {
124  {
125  4, 7, 9, 11, 13, 14, 63, 63,
126  7, 7, 11, 12, 14, 63, 63, 63,
127  9, 11, 13, 14, 63, 63, 63, 63,
128  11, 11, 13, 14, 63, 63, 63, 63,
129  11, 13, 14, 63, 63, 63, 63, 63,
130  13, 14, 63, 63, 63, 63, 63, 63,
131  13, 63, 63, 63, 63, 63, 63, 63,
132  63, 63, 63, 63, 63, 63, 63, 63
133  }, {
134  4, 5, 6, 7, 9, 11, 13, 15,
135  5, 5, 7, 8, 11, 13, 15, 17,
136  6, 7, 9, 11, 13, 15, 15, 17,
137  7, 7, 9, 11, 13, 15, 17, 19,
138  7, 9, 11, 13, 14, 16, 19, 23,
139  9, 11, 13, 14, 16, 19, 23, 29,
140  9, 11, 13, 15, 17, 21, 28, 35,
141  11, 13, 16, 17, 21, 28, 35, 41
142  }, {
143  4, 4, 5, 5, 6, 7, 7, 9,
144  4, 4, 5, 6, 7, 7, 9, 9,
145  5, 5, 6, 7, 7, 9, 9, 10,
146  5, 5, 6, 7, 7, 9, 9, 10,
147  5, 6, 7, 7, 8, 9, 10, 12,
148  6, 7, 7, 8, 9, 10, 12, 15,
149  6, 7, 7, 9, 10, 11, 14, 17,
150  7, 7, 9, 10, 11, 14, 17, 21
151  }, {
152  4, 4, 4, 4, 4, 4, 4, 4,
153  4, 4, 4, 4, 4, 4, 4, 4,
154  4, 4, 4, 4, 4, 4, 4, 4,
155  4, 4, 4, 4, 4, 4, 4, 5,
156  4, 4, 4, 4, 4, 4, 5, 5,
157  4, 4, 4, 4, 4, 5, 5, 6,
158  4, 4, 4, 4, 5, 5, 6, 7,
159  4, 4, 4, 4, 5, 6, 7, 7
160  }, { /* 444 */
161  4, 4, 4, 4, 4, 4, 4, 4,
162  4, 4, 4, 4, 4, 4, 4, 4,
163  4, 4, 4, 4, 4, 4, 4, 4,
164  4, 4, 4, 4, 4, 4, 4, 5,
165  4, 4, 4, 4, 4, 4, 5, 5,
166  4, 4, 4, 4, 4, 5, 5, 6,
167  4, 4, 4, 4, 5, 5, 6, 7,
168  4, 4, 4, 4, 5, 6, 7, 7
169  }, { /* 444 xq */
170  4, 4, 4, 4, 4, 4, 4, 4,
171  4, 4, 4, 4, 4, 4, 4, 4,
172  4, 4, 4, 4, 4, 4, 4, 4,
173  4, 4, 4, 4, 4, 4, 4, 5,
174  4, 4, 4, 4, 4, 4, 5, 5,
175  4, 4, 4, 4, 4, 5, 5, 6,
176  4, 4, 4, 4, 5, 5, 6, 7,
177  4, 4, 4, 4, 5, 6, 7, 7
178  }
179 };
180 
181 
182 typedef struct {
183  AVClass *class;
185  uint8_t* fill_y;
186  uint8_t* fill_u;
187  uint8_t* fill_v;
188  uint8_t* fill_a;
189 
190  int qmat_luma[16][64];
191  int qmat_chroma[16][64];
192  const uint8_t *scantable;
193 
194  int is_422;
197 
198  char *vendor;
199 } ProresContext;
200 
201 /**
202  * Check if a value is in the list. If not, return the default value
203  *
204  * @param ctx Context for the log msg
205  * @param val_name Name of the checked value, for log msg
206  * @param array_valid_values Array of valid int, ended with INT_MAX
207  * @param default_value Value return if checked value is not in the array
208  * @return Value or default_value.
209  */
210 static int int_from_list_or_default(void *ctx, const char *val_name, int val,
211  const int *array_valid_values, int default_value)
212 {
213  int i = 0;
214 
215  while (1) {
216  int ref_val = array_valid_values[i];
217  if (ref_val == INT_MAX)
218  break;
219  if (val == ref_val)
220  return val;
221  i++;
222  }
223  /* val is not a valid value */
225  "%s %d are not supported. Set to default value : %d\n",
226  val_name, val, default_value);
227  return default_value;
228 }
229 
230 static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val)
231 {
232  unsigned int rice_order, exp_order, switch_bits, switch_val;
233  int exponent;
234 
235  /* number of prefix bits to switch between Rice and expGolomb */
236  switch_bits = (codebook & 3) + 1;
237  rice_order = codebook >> 5; /* rice code order */
238  exp_order = (codebook >> 2) & 7; /* exp golomb code order */
239 
240  switch_val = switch_bits << rice_order;
241 
242  if (val >= switch_val) {
243  val -= switch_val - (1 << exp_order);
244  exponent = av_log2(val);
245 
246  put_bits(pb, exponent - exp_order + switch_bits, 0);
247  put_bits(pb, exponent + 1, val);
248  } else {
249  exponent = val >> rice_order;
250 
251  if (exponent)
252  put_bits(pb, exponent, 0);
253  put_bits(pb, 1, 1);
254  if (rice_order)
255  put_sbits(pb, rice_order, val);
256  }
257 }
258 
259 #define GET_SIGN(x) ((x) >> 31)
260 #define MAKE_CODE(x) (((x) * 2) ^ GET_SIGN(x))
261 
262 static void encode_dcs(PutBitContext *pb, int16_t *blocks,
263  int blocks_per_slice, int scale)
264 {
265  int i;
266  int codebook = 5, code, dc, prev_dc, delta, sign, new_sign;
267 
268  prev_dc = (blocks[0] - 0x4000) / scale;
270  sign = 0;
271  blocks += 64;
272 
273  for (i = 1; i < blocks_per_slice; i++, blocks += 64) {
274  dc = (blocks[0] - 0x4000) / scale;
275  delta = dc - prev_dc;
276  new_sign = GET_SIGN(delta);
277  delta = (delta ^ sign) - sign;
278  code = MAKE_CODE(delta);
280  codebook = FFMIN(code, 6);
281  sign = new_sign;
282  prev_dc = dc;
283  }
284 }
285 
286 static void encode_acs(PutBitContext *pb, int16_t *blocks,
287  int blocks_per_slice,
288  int *qmat, const uint8_t *scan)
289 {
290  int idx, i;
291  int prev_run = 4;
292  int prev_level = 2;
293  int run = 0, level;
294  int max_coeffs, abs_level;
295 
296  max_coeffs = blocks_per_slice << 6;
297 
298  for (i = 1; i < 64; i++) {
299  for (idx = scan[i]; idx < max_coeffs; idx += 64) {
300  level = blocks[idx] / qmat[scan[i]];
301  if (level) {
302  abs_level = FFABS(level);
304  encode_vlc_codeword(pb, ff_prores_level_to_cb[prev_level], abs_level - 1);
305  put_sbits(pb, 1, GET_SIGN(level));
306 
307  prev_run = FFMIN(run, 15);
308  prev_level = FFMIN(abs_level, 9);
309  run = 0;
310  } else {
311  run++;
312  }
313  }
314  }
315 }
316 
317 static void get(const uint8_t *pixels, int stride, int16_t* block)
318 {
319  int i;
320 
321  for (i = 0; i < 8; i++) {
322  AV_WN64(block, AV_RN64(pixels));
323  AV_WN64(block+4, AV_RN64(pixels+8));
324  pixels += stride;
325  block += 8;
326  }
327 }
328 
329 static void fdct_get(FDCTDSPContext *fdsp, const uint8_t *pixels, int stride, int16_t* block)
330 {
331  get(pixels, stride, block);
332  fdsp->fdct(block);
333 }
334 
335 static void calc_plane_dct(FDCTDSPContext *fdsp, const uint8_t *src, int16_t * blocks, int src_stride, int mb_count, int chroma, int is_422)
336 {
337  int16_t *block;
338  int i;
339 
340  block = blocks;
341 
342  if (!chroma) { /* Luma plane */
343  for (i = 0; i < mb_count; i++) {
344  fdct_get(fdsp, src, src_stride, block + (0 << 6));
345  fdct_get(fdsp, src + 16, src_stride, block + (1 << 6));
346  fdct_get(fdsp, src + 8 * src_stride, src_stride, block + (2 << 6));
347  fdct_get(fdsp, src + 16 + 8 * src_stride, src_stride, block + (3 << 6));
348 
349  block += 256;
350  src += 32;
351  }
352  } else if (chroma && is_422){ /* chroma plane 422 */
353  for (i = 0; i < mb_count; i++) {
354  fdct_get(fdsp, src, src_stride, block + (0 << 6));
355  fdct_get(fdsp, src + 8 * src_stride, src_stride, block + (1 << 6));
356  block += (256 >> 1);
357  src += (32 >> 1);
358  }
359  } else { /* chroma plane 444 */
360  for (i = 0; i < mb_count; i++) {
361  fdct_get(fdsp, src, src_stride, block + (0 << 6));
362  fdct_get(fdsp, src + 8 * src_stride, src_stride, block + (1 << 6));
363  fdct_get(fdsp, src + 16, src_stride, block + (2 << 6));
364  fdct_get(fdsp, src + 16 + 8 * src_stride, src_stride, block + (3 << 6));
365 
366  block += 256;
367  src += 32;
368  }
369  }
370 }
371 
372 static int encode_slice_plane(int16_t *blocks, int mb_count, uint8_t *buf, unsigned buf_size, int *qmat, int sub_sample_chroma,
373  const uint8_t *scan)
374 {
375  int blocks_per_slice;
376  PutBitContext pb;
377 
378  blocks_per_slice = mb_count << (2 - sub_sample_chroma);
379  init_put_bits(&pb, buf, buf_size);
380 
381  encode_dcs(&pb, blocks, blocks_per_slice, qmat[0]);
382  encode_acs(&pb, blocks, blocks_per_slice, qmat, scan);
383 
384  flush_put_bits(&pb);
385  return put_bits_ptr(&pb) - pb.buf;
386 }
387 
389  int16_t * blocks_y, int16_t * blocks_u, int16_t * blocks_v,
390  unsigned mb_count, uint8_t *buf, unsigned data_size,
391  unsigned* y_data_size, unsigned* u_data_size, unsigned* v_data_size,
392  int qp)
393 {
394  ProresContext* ctx = avctx->priv_data;
395 
396  *y_data_size = encode_slice_plane(blocks_y, mb_count,
397  buf, data_size, ctx->qmat_luma[qp - 1], 0, ctx->scantable);
398 
399  if (!(avctx->flags & AV_CODEC_FLAG_GRAY)) {
400  *u_data_size = encode_slice_plane(blocks_u, mb_count, buf + *y_data_size, data_size - *y_data_size,
401  ctx->qmat_chroma[qp - 1], ctx->is_422, ctx->scantable);
402 
403  *v_data_size = encode_slice_plane(blocks_v, mb_count, buf + *y_data_size + *u_data_size,
404  data_size - *y_data_size - *u_data_size,
405  ctx->qmat_chroma[qp - 1], ctx->is_422, ctx->scantable);
406  }
407 
408  return *y_data_size + *u_data_size + *v_data_size;
409 }
410 
411 static void put_alpha_diff(PutBitContext *pb, int cur, int prev)
412 {
413  const int abits = 16;
414  const int dbits = 7;
415  const int dsize = 1 << dbits - 1;
416  int diff = cur - prev;
417 
418  diff = av_zero_extend(diff, abits);
419  if (diff >= (1 << abits) - dsize)
420  diff -= 1 << abits;
421  if (diff < -dsize || diff > dsize || !diff) {
422  put_bits(pb, 1, 1);
423  put_bits(pb, abits, diff);
424  } else {
425  put_bits(pb, 1, 0);
426  put_bits(pb, dbits - 1, FFABS(diff) - 1);
427  put_bits(pb, 1, diff < 0);
428  }
429 }
430 
431 static inline void put_alpha_run(PutBitContext *pb, int run)
432 {
433  if (run) {
434  put_bits(pb, 1, 0);
435  if (run < 0x10)
436  put_bits(pb, 4, run);
437  else
438  put_bits(pb, 15, run);
439  } else {
440  put_bits(pb, 1, 1);
441  }
442 }
443 
444 static av_always_inline int encode_alpha_slice_data(AVCodecContext *avctx, int8_t * src_a,
445  unsigned mb_count, uint8_t *buf, unsigned data_size, unsigned* a_data_size)
446 {
447  const int abits = 16;
448  const int mask = (1 << abits) - 1;
449  const int num_coeffs = mb_count * 256;
450  int prev = mask, cur;
451  int idx = 0;
452  int run = 0;
453  int16_t * blocks = (int16_t *)src_a;
454  PutBitContext pb;
455  init_put_bits(&pb, buf, data_size);
456 
457  cur = blocks[idx++];
458  put_alpha_diff(&pb, cur, prev);
459  prev = cur;
460  do {
461  cur = blocks[idx++];
462  if (cur != prev) {
463  put_alpha_run (&pb, run);
464  put_alpha_diff(&pb, cur, prev);
465  prev = cur;
466  run = 0;
467  } else {
468  run++;
469  }
470  } while (idx < num_coeffs);
471  put_alpha_run(&pb, run);
472  flush_put_bits(&pb);
473  *a_data_size = put_bytes_output(&pb);
474 
475  if (put_bits_left(&pb) < 0) {
476  av_log(avctx, AV_LOG_ERROR,
477  "Underestimated required buffer size.\n");
478  return AVERROR_BUG;
479  } else {
480  return 0;
481  }
482 }
483 
484 static inline void subimage_with_fill_template(const uint16_t *src, unsigned x, unsigned y,
485  unsigned stride, unsigned width, unsigned height, uint16_t *dst,
486  unsigned dst_width, unsigned dst_height, int is_alpha_plane,
487  int is_interlaced, int is_top_field)
488 {
489  int box_width = FFMIN(width - x, dst_width);
490  int i, j, src_stride, box_height;
491  uint16_t last_pix, *last_line;
492 
493  if (!is_interlaced) {
494  src_stride = stride >> 1;
495  src += y * src_stride + x;
496  box_height = FFMIN(height - y, dst_height);
497  } else {
498  src_stride = stride; /* 2 lines stride */
499  src += y * src_stride + x;
500  box_height = FFMIN(height/2 - y, dst_height);
501  if (!is_top_field)
502  src += stride >> 1;
503  }
504 
505  for (i = 0; i < box_height; ++i) {
506  for (j = 0; j < box_width; ++j) {
507  if (!is_alpha_plane) {
508  dst[j] = src[j];
509  } else {
510  dst[j] = src[j] << 6; /* alpha 10b to 16b */
511  }
512  }
513  if (!is_alpha_plane) {
514  last_pix = dst[j - 1];
515  } else {
516  last_pix = dst[j - 1] << 6; /* alpha 10b to 16b */
517  }
518  for (; j < dst_width; j++)
519  dst[j] = last_pix;
520  src += src_stride;
521  dst += dst_width;
522  }
523  last_line = dst - dst_width;
524  for (; i < dst_height; i++) {
525  for (j = 0; j < dst_width; ++j) {
526  dst[j] = last_line[j];
527  }
528  dst += dst_width;
529  }
530 }
531 
532 static void subimage_with_fill(const uint16_t *src, unsigned x, unsigned y,
533  unsigned stride, unsigned width, unsigned height, uint16_t *dst,
534  unsigned dst_width, unsigned dst_height, int is_interlaced, int is_top_field)
535 {
536  subimage_with_fill_template(src, x, y, stride, width, height, dst, dst_width, dst_height, 0, is_interlaced, is_top_field);
537 }
538 
539 /* reorganize alpha data and convert 10b -> 16b */
540 static void subimage_alpha_with_fill(const uint16_t *src, unsigned x, unsigned y,
541  unsigned stride, unsigned width, unsigned height, uint16_t *dst,
542  unsigned dst_width, unsigned dst_height, int is_interlaced, int is_top_field)
543 {
544  subimage_with_fill_template(src, x, y, stride, width, height, dst, dst_width, dst_height, 1, is_interlaced, is_top_field);
545 }
546 
547 static int encode_slice(AVCodecContext *avctx, const AVFrame *pic, int mb_x,
548  int mb_y, unsigned mb_count, uint8_t *buf, unsigned data_size,
549  int unsafe, int *qp, int is_interlaced, int is_top_field)
550 {
551  int luma_stride, chroma_stride, alpha_stride = 0;
552  ProresContext* ctx = avctx->priv_data;
553  int hdr_size = 6 + (ctx->need_alpha * 2); /* v data size is write when there is alpha */
554  int ret = 0, slice_size;
555  const uint8_t *dest_y, *dest_u, *dest_v;
556  unsigned y_data_size = 0, u_data_size = 0, v_data_size = 0, a_data_size = 0;
557  FDCTDSPContext *fdsp = &ctx->fdsp;
558  int tgt_bits = (mb_count * bitrate_table[avctx->profile]) >> 2;
559  int low_bytes = (tgt_bits - (tgt_bits >> 3)) >> 3; // 12% bitrate fluctuation
560  int high_bytes = (tgt_bits + (tgt_bits >> 3)) >> 3;
561 
562  LOCAL_ALIGNED(16, int16_t, blocks_y, [DEFAULT_SLICE_MB_WIDTH << 8]);
563  LOCAL_ALIGNED(16, int16_t, blocks_u, [DEFAULT_SLICE_MB_WIDTH << 8]);
564  LOCAL_ALIGNED(16, int16_t, blocks_v, [DEFAULT_SLICE_MB_WIDTH << 8]);
565 
566  luma_stride = pic->linesize[0];
567  chroma_stride = pic->linesize[1];
568 
569  if (ctx->need_alpha)
570  alpha_stride = pic->linesize[3];
571 
572  if (!is_interlaced) {
573  dest_y = pic->data[0] + (mb_y << 4) * luma_stride + (mb_x << 5);
574  dest_u = pic->data[1] + (mb_y << 4) * chroma_stride + (mb_x << (5 - ctx->is_422));
575  dest_v = pic->data[2] + (mb_y << 4) * chroma_stride + (mb_x << (5 - ctx->is_422));
576  } else {
577  dest_y = pic->data[0] + (mb_y << 4) * luma_stride * 2 + (mb_x << 5);
578  dest_u = pic->data[1] + (mb_y << 4) * chroma_stride * 2 + (mb_x << (5 - ctx->is_422));
579  dest_v = pic->data[2] + (mb_y << 4) * chroma_stride * 2 + (mb_x << (5 - ctx->is_422));
580  if (!is_top_field){ /* bottom field, offset dest */
581  dest_y += luma_stride;
582  dest_u += chroma_stride;
583  dest_v += chroma_stride;
584  }
585  }
586 
587  if (unsafe) {
588  subimage_with_fill((const uint16_t *) pic->data[0], mb_x << 4, mb_y << 4,
589  luma_stride, avctx->width, avctx->height,
590  (uint16_t *) ctx->fill_y, mb_count << 4, 16, is_interlaced, is_top_field);
591  subimage_with_fill((const uint16_t *) pic->data[1], mb_x << (4 - ctx->is_422), mb_y << 4,
592  chroma_stride, avctx->width >> ctx->is_422, avctx->height,
593  (uint16_t *) ctx->fill_u, mb_count << (4 - ctx->is_422), 16, is_interlaced, is_top_field);
594  subimage_with_fill((const uint16_t *) pic->data[2], mb_x << (4 - ctx->is_422), mb_y << 4,
595  chroma_stride, avctx->width >> ctx->is_422, avctx->height,
596  (uint16_t *) ctx->fill_v, mb_count << (4 - ctx->is_422), 16, is_interlaced, is_top_field);
597 
598  /* no need for interlaced special case, data already reorganized in subimage_with_fill */
599  calc_plane_dct(fdsp, ctx->fill_y, blocks_y, mb_count << 5, mb_count, 0, 0);
600  calc_plane_dct(fdsp, ctx->fill_u, blocks_u, mb_count << (5 - ctx->is_422), mb_count, 1, ctx->is_422);
601  calc_plane_dct(fdsp, ctx->fill_v, blocks_v, mb_count << (5 - ctx->is_422), mb_count, 1, ctx->is_422);
602 
603  slice_size = encode_slice_data(avctx, blocks_y, blocks_u, blocks_v,
604  mb_count, buf + hdr_size, data_size - hdr_size,
605  &y_data_size, &u_data_size, &v_data_size,
606  *qp);
607  } else {
608  if (!is_interlaced) {
609  calc_plane_dct(fdsp, dest_y, blocks_y, luma_stride, mb_count, 0, 0);
610  calc_plane_dct(fdsp, dest_u, blocks_u, chroma_stride, mb_count, 1, ctx->is_422);
611  calc_plane_dct(fdsp, dest_v, blocks_v, chroma_stride, mb_count, 1, ctx->is_422);
612  } else {
613  calc_plane_dct(fdsp, dest_y, blocks_y, luma_stride * 2, mb_count, 0, 0);
614  calc_plane_dct(fdsp, dest_u, blocks_u, chroma_stride * 2, mb_count, 1, ctx->is_422);
615  calc_plane_dct(fdsp, dest_v, blocks_v, chroma_stride * 2, mb_count, 1, ctx->is_422);
616  }
617 
618  slice_size = encode_slice_data(avctx, blocks_y, blocks_u, blocks_v,
619  mb_count, buf + hdr_size, data_size - hdr_size,
620  &y_data_size, &u_data_size, &v_data_size,
621  *qp);
622 
623  if (slice_size > high_bytes && *qp < qp_end_table[avctx->profile]) {
624  do {
625  *qp += 1;
626  slice_size = encode_slice_data(avctx, blocks_y, blocks_u, blocks_v,
627  mb_count, buf + hdr_size, data_size - hdr_size,
628  &y_data_size, &u_data_size, &v_data_size,
629  *qp);
630  } while (slice_size > high_bytes && *qp < qp_end_table[avctx->profile]);
631  } else if (slice_size < low_bytes && *qp
632  > qp_start_table[avctx->profile]) {
633  do {
634  *qp -= 1;
635  slice_size = encode_slice_data(avctx, blocks_y, blocks_u, blocks_v,
636  mb_count, buf + hdr_size, data_size - hdr_size,
637  &y_data_size, &u_data_size, &v_data_size,
638  *qp);
639  } while (slice_size < low_bytes && *qp > qp_start_table[avctx->profile]);
640  }
641  }
642 
643  buf[0] = hdr_size << 3;
644  buf[1] = *qp;
645  AV_WB16(buf + 2, y_data_size);
646  AV_WB16(buf + 4, u_data_size);
647 
648  if (ctx->need_alpha) {
649  AV_WB16(buf + 6, v_data_size); /* write v data size only if there is alpha */
650 
651  subimage_alpha_with_fill((const uint16_t *) pic->data[3], mb_x << 4, mb_y << 4,
652  alpha_stride, avctx->width, avctx->height,
653  (uint16_t *) ctx->fill_a, mb_count << 4, 16, is_interlaced, is_top_field);
654  ret = encode_alpha_slice_data(avctx, ctx->fill_a, mb_count,
655  buf + hdr_size + slice_size,
656  data_size - hdr_size - slice_size, &a_data_size);
657  }
658 
659  if (ret != 0) {
660  return ret;
661  }
662  return hdr_size + y_data_size + u_data_size + v_data_size + a_data_size;
663 }
664 
665 static int prores_encode_picture(AVCodecContext *avctx, const AVFrame *pic,
666  uint8_t *buf, const int buf_size, const int picture_index, const int is_top_field)
667 {
668  ProresContext *ctx = avctx->priv_data;
669  int mb_width = (avctx->width + 15) >> 4;
670  int hdr_size, sl_size, i;
671  int mb_y, sl_data_size, qp, mb_height, picture_height, unsafe_mb_height_limit;
672  int unsafe_bot, unsafe_right;
673  uint8_t *sl_data, *sl_data_sizes;
674  int slice_per_line = 0, rem = mb_width;
675 
676  if (!ctx->is_interlaced) { /* progressive encoding */
677  mb_height = (avctx->height + 15) >> 4;
678  unsafe_mb_height_limit = mb_height;
679  } else {
680  if (is_top_field) {
681  picture_height = (avctx->height + 1) / 2;
682  } else {
683  picture_height = avctx->height / 2;
684  }
685  mb_height = (picture_height + 15) >> 4;
686  unsafe_mb_height_limit = mb_height;
687  }
688 
689  for (i = av_log2(DEFAULT_SLICE_MB_WIDTH); i >= 0; --i) {
690  slice_per_line += rem >> i;
691  rem &= (1 << i) - 1;
692  }
693 
694  qp = qp_start_table[avctx->profile];
695  hdr_size = 8; sl_data_size = buf_size - hdr_size;
696  sl_data_sizes = buf + hdr_size;
697  sl_data = sl_data_sizes + (slice_per_line * mb_height * 2);
698  for (mb_y = 0; mb_y < mb_height; mb_y++) {
699  int mb_x = 0;
700  int slice_mb_count = DEFAULT_SLICE_MB_WIDTH;
701  while (mb_x < mb_width) {
702  while (mb_width - mb_x < slice_mb_count)
703  slice_mb_count >>= 1;
704 
705  unsafe_bot = (avctx->height & 0xf) && (mb_y == unsafe_mb_height_limit - 1);
706  unsafe_right = (avctx->width & 0xf) && (mb_x + slice_mb_count == mb_width);
707 
708  sl_size = encode_slice(avctx, pic, mb_x, mb_y, slice_mb_count,
709  sl_data, sl_data_size, unsafe_bot || unsafe_right, &qp, ctx->is_interlaced, is_top_field);
710  if (sl_size < 0){
711  return sl_size;
712  }
713 
714  bytestream_put_be16(&sl_data_sizes, sl_size);
715  sl_data += sl_size;
716  sl_data_size -= sl_size;
717  mb_x += slice_mb_count;
718  }
719  }
720 
721  buf[0] = hdr_size << 3;
722  AV_WB32(buf + 1, sl_data - buf);
723  AV_WB16(buf + 5, slice_per_line * mb_height); /* picture size */
724  buf[7] = av_log2(DEFAULT_SLICE_MB_WIDTH) << 4; /* number of slices */
725 
726  return sl_data - buf;
727 }
728 
730  const AVFrame *pict, int *got_packet)
731 {
732  ProresContext *ctx = avctx->priv_data;
733  int header_size = 148;
734  uint8_t *buf;
735  int compress_frame_size, pic_size, ret, is_top_field_first = 0;
736  uint8_t frame_flags;
737  int frame_size = FFALIGN(avctx->width, 16) * FFALIGN(avctx->height, 16)*16 + 500 + FF_INPUT_BUFFER_MIN_SIZE; //FIXME choose tighter limit
738 
739 
741  return ret;
742 
743  buf = pkt->data;
744  compress_frame_size = 8 + header_size;
745 
746  bytestream_put_be32(&buf, compress_frame_size);/* frame size will be update after picture(s) encoding */
747  bytestream_put_be32(&buf, FRAME_ID);
748 
749  bytestream_put_be16(&buf, header_size);
750  bytestream_put_be16(&buf, avctx->pix_fmt != AV_PIX_FMT_YUV422P10 || ctx->need_alpha ? 1 : 0); /* version */
751  bytestream_put_buffer(&buf, ctx->vendor, 4);
752  bytestream_put_be16(&buf, avctx->width);
753  bytestream_put_be16(&buf, avctx->height);
754  frame_flags = 0x80; /* 422 not interlaced */
755  if (avctx->profile >= AV_PROFILE_PRORES_4444) /* 4444 or 4444 Xq */
756  frame_flags |= 0x40; /* 444 chroma */
757  if (ctx->is_interlaced) {
759  /* tff frame or progressive frame interpret as tff */
760  av_log(avctx, AV_LOG_DEBUG, "use interlaced encoding, top field first\n");
761  frame_flags |= 0x04; /* interlaced tff */
762  is_top_field_first = 1;
763  } else {
764  av_log(avctx, AV_LOG_DEBUG, "use interlaced encoding, bottom field first\n");
765  frame_flags |= 0x08; /* interlaced bff */
766  }
767  } else {
768  av_log(avctx, AV_LOG_DEBUG, "use progressive encoding\n");
769  }
770  *buf++ = frame_flags;
771  *buf++ = 0; /* reserved */
772  /* only write color properties, if valid value. set to unspecified otherwise */
773  *buf++ = int_from_list_or_default(avctx, "frame color primaries",
774  pict->color_primaries, valid_primaries, 0);
775  *buf++ = int_from_list_or_default(avctx, "frame color trc",
776  pict->color_trc, valid_trc, 0);
777  *buf++ = int_from_list_or_default(avctx, "frame colorspace",
778  pict->colorspace, valid_colorspace, 0);
779  *buf++ = ctx->need_alpha ? 0x2 /* 16-bit alpha */ : 0;
780  *buf++ = 0; /* reserved */
781  *buf++ = 3; /* luma and chroma matrix present */
782 
783  bytestream_put_buffer(&buf, QMAT_LUMA[avctx->profile], 64);
784  bytestream_put_buffer(&buf, QMAT_CHROMA[avctx->profile], 64);
785 
786  pic_size = prores_encode_picture(avctx, pict, buf,
787  pkt->size - compress_frame_size, 0, is_top_field_first);/* encode progressive or first field */
788  if (pic_size < 0) {
789  return pic_size;
790  }
791  compress_frame_size += pic_size;
792 
793  if (ctx->is_interlaced) { /* encode second field */
794  pic_size = prores_encode_picture(avctx, pict, pkt->data + compress_frame_size,
795  pkt->size - compress_frame_size, 1, !is_top_field_first);
796  if (pic_size < 0) {
797  return pic_size;
798  }
799  compress_frame_size += pic_size;
800  }
801 
802  AV_WB32(pkt->data, compress_frame_size);/* update frame size */
803  pkt->size = compress_frame_size;
804  *got_packet = 1;
805 
806  return 0;
807 }
808 
809 static void scale_mat(const uint8_t* src, int* dst, int scale)
810 {
811  int i;
812  for (i = 0; i < 64; i++)
813  dst[i] = src[i] * scale;
814 }
815 
817 {
818  int i;
819  ProresContext* ctx = avctx->priv_data;
820 
821  avctx->bits_per_raw_sample = 10;
822  ctx->need_alpha = 0;
823  ctx->is_interlaced = !!(avctx->flags & AV_CODEC_FLAG_INTERLACED_DCT);
824  if (ctx->is_interlaced) {
825  ctx->scantable = ff_prores_interlaced_scan;
826  } else {
827  ctx->scantable = ff_prores_progressive_scan;
828  }
829 
830  if (avctx->width & 0x1) {
831  av_log(avctx, AV_LOG_ERROR,
832  "frame width needs to be multiple of 2\n");
833  return AVERROR(EINVAL);
834  }
835 
836  if (avctx->width > 65534 || avctx->height > 65535) {
837  av_log(avctx, AV_LOG_ERROR,
838  "The maximum dimensions are 65534x65535\n");
839  return AVERROR(EINVAL);
840  }
841 
842  if (strlen(ctx->vendor) != 4) {
843  av_log(avctx, AV_LOG_ERROR, "vendor ID should be 4 bytes\n");
844  return AVERROR(EINVAL);
845  }
846 
847  if (avctx->profile == AV_PROFILE_UNKNOWN) {
848  if (avctx->pix_fmt == AV_PIX_FMT_YUV422P10) {
850  av_log(avctx, AV_LOG_INFO,
851  "encoding with ProRes standard (apcn) profile\n");
852  } else if (avctx->pix_fmt == AV_PIX_FMT_YUV444P10) {
854  av_log(avctx, AV_LOG_INFO,
855  "encoding with ProRes 4444 (ap4h) profile\n");
856  } else if (avctx->pix_fmt == AV_PIX_FMT_YUVA444P10) {
858  av_log(avctx, AV_LOG_INFO,
859  "encoding with ProRes 4444+ (ap4h) profile\n");
860  } else
861  av_assert0(0);
862  } else if (avctx->profile < AV_PROFILE_PRORES_PROXY
863  || avctx->profile > AV_PROFILE_PRORES_XQ) {
864  av_log(
865  avctx,
866  AV_LOG_ERROR,
867  "unknown profile %d, use [0 - apco, 1 - apcs, 2 - apcn (default), 3 - apch, 4 - ap4h, 5 - ap4x]\n",
868  avctx->profile);
869  return AVERROR(EINVAL);
870  } else if ((avctx->pix_fmt == AV_PIX_FMT_YUV422P10) && (avctx->profile > AV_PROFILE_PRORES_HQ)){
871  av_log(avctx, AV_LOG_ERROR,
872  "encoding with ProRes 444/Xq (ap4h/ap4x) profile, need YUV444P10 input\n");
873  return AVERROR(EINVAL);
874  } else if ((avctx->pix_fmt == AV_PIX_FMT_YUV444P10 || avctx->pix_fmt == AV_PIX_FMT_YUVA444P10)
875  && (avctx->profile < AV_PROFILE_PRORES_4444)){
876  av_log(avctx, AV_LOG_ERROR,
877  "encoding with ProRes Proxy/LT/422/422 HQ (apco, apcs, apcn, ap4h) profile, need YUV422P10 input\n");
878  return AVERROR(EINVAL);
879  }
880 
881  if (avctx->profile < AV_PROFILE_PRORES_4444) { /* 422 versions */
882  ctx->is_422 = 1;
883  if ((avctx->height & 0xf) || (avctx->width & 0xf)) {
884  ctx->fill_y = av_malloc(4 * (DEFAULT_SLICE_MB_WIDTH << 8));
885  if (!ctx->fill_y)
886  return AVERROR(ENOMEM);
887  ctx->fill_u = ctx->fill_y + (DEFAULT_SLICE_MB_WIDTH << 9);
888  ctx->fill_v = ctx->fill_u + (DEFAULT_SLICE_MB_WIDTH << 8);
889  }
890  } else { /* 444 */
891  ctx->is_422 = 0;
892  if ((avctx->height & 0xf) || (avctx->width & 0xf)) {
893  ctx->fill_y = av_malloc(3 * (DEFAULT_SLICE_MB_WIDTH << 9));
894  if (!ctx->fill_y)
895  return AVERROR(ENOMEM);
896  ctx->fill_u = ctx->fill_y + (DEFAULT_SLICE_MB_WIDTH << 9);
897  ctx->fill_v = ctx->fill_u + (DEFAULT_SLICE_MB_WIDTH << 9);
898  }
899  if (avctx->pix_fmt == AV_PIX_FMT_YUVA444P10) {
900  ctx->need_alpha = 1;
901  ctx->fill_a = av_malloc(DEFAULT_SLICE_MB_WIDTH << 9); /* 8 blocks x 16px x 16px x sizeof (uint16) */
902  if (!ctx->fill_a)
903  return AVERROR(ENOMEM);
904  }
905  }
906 
907  if (ctx->need_alpha)
908  avctx->bits_per_coded_sample = 32;
909 
910  ff_fdctdsp_init(&ctx->fdsp, avctx);
911 
912  avctx->codec_tag = AV_RL32((const uint8_t*)profiles[avctx->profile].name);
913 
914  for (i = 1; i <= 16; i++) {
915  scale_mat(QMAT_LUMA[avctx->profile] , ctx->qmat_luma[i - 1] , i);
916  scale_mat(QMAT_CHROMA[avctx->profile], ctx->qmat_chroma[i - 1], i);
917  }
918 
919  return 0;
920 }
921 
923 {
924  ProresContext* ctx = avctx->priv_data;
925  av_freep(&ctx->fill_y);
926  av_freep(&ctx->fill_a);
927 
928  return 0;
929 }
930 
931 #define OFFSET(x) offsetof(ProresContext, x)
932 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
933 
934 static const AVOption options[] = {
935  { "vendor", "vendor ID", OFFSET(vendor), AV_OPT_TYPE_STRING, { .str = "fmpg" }, 0, 0, VE },
936  { NULL }
937 };
938 
939 static const AVClass prores_enc_class = {
940  .class_name = "ProRes encoder",
941  .item_name = av_default_item_name,
942  .option = options,
943  .version = LIBAVUTIL_VERSION_INT,
944 };
945 
946 static const enum AVPixelFormat pix_fmts[] = {
949 };
950 
952  .p.name = "prores_aw",
953  CODEC_LONG_NAME("Apple ProRes"),
954  .p.type = AVMEDIA_TYPE_VIDEO,
955  .p.id = AV_CODEC_ID_PRORES,
956  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS |
958  .p.pix_fmts = pix_fmts,
959  .color_ranges = AVCOL_RANGE_MPEG,
960  .priv_data_size = sizeof(ProresContext),
962  .close = prores_encode_close,
964  .p.priv_class = &prores_enc_class,
966  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
967 };
968 
970  .p.name = "prores",
971  CODEC_LONG_NAME("Apple ProRes"),
972  .p.type = AVMEDIA_TYPE_VIDEO,
973  .p.id = AV_CODEC_ID_PRORES,
974  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS |
976  .p.pix_fmts = pix_fmts,
977  .color_ranges = AVCOL_RANGE_MPEG,
978  .priv_data_size = sizeof(ProresContext),
980  .close = prores_encode_close,
982  .p.priv_class = &prores_enc_class,
984  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
985 };
int_from_list_or_default
static int int_from_list_or_default(void *ctx, const char *val_name, int val, const int *array_valid_values, int default_value)
Check if a value is in the list.
Definition: proresenc_anatoliy.c:210
AVFrame::color_trc
enum AVColorTransferCharacteristic color_trc
Definition: frame.h:672
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
level
uint8_t level
Definition: svq3.c:205
subimage_with_fill_template
static void subimage_with_fill_template(const uint16_t *src, unsigned x, unsigned y, unsigned stride, unsigned width, unsigned height, uint16_t *dst, unsigned dst_width, unsigned dst_height, int is_alpha_plane, int is_interlaced, int is_top_field)
Definition: proresenc_anatoliy.c:484
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: codec_internal.h:43
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
opt.h
ProresContext::fdsp
FDCTDSPContext fdsp
Definition: proresenc_anatoliy.c:184
mem_internal.h
put_bytes_output
static int put_bytes_output(const PutBitContext *s)
Definition: put_bits.h:89
ff_prores_profiles
const AVProfile ff_prores_profiles[]
Definition: profiles.c:175
AVProfile::name
const char * name
short name for the profile
Definition: codec.h:181
GET_SIGN
#define GET_SIGN(x)
Definition: proresenc_anatoliy.c:259
options
static const AVOption options[]
Definition: proresenc_anatoliy.c:934
prores_encode_picture
static int prores_encode_picture(AVCodecContext *avctx, const AVFrame *pic, uint8_t *buf, const int buf_size, const int picture_index, const int is_top_field)
Definition: proresenc_anatoliy.c:665
put_sbits
static void put_sbits(PutBitContext *pb, int n, int32_t value)
Definition: put_bits.h:281
init_put_bits
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
Definition: put_bits.h:62
prores_enc_class
static const AVClass prores_enc_class
Definition: proresenc_anatoliy.c:939
AVFrame::color_primaries
enum AVColorPrimaries color_primaries
Definition: frame.h:670
mask
int mask
Definition: mediacodecdec_common.c:154
ProresContext::vendor
char * vendor
Definition: proresenc_anatoliy.c:198
encode_slice
static int encode_slice(AVCodecContext *avctx, const AVFrame *pic, int mb_x, int mb_y, unsigned mb_count, uint8_t *buf, unsigned data_size, int unsafe, int *qp, int is_interlaced, int is_top_field)
Definition: proresenc_anatoliy.c:547
AVFrame::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: frame.h:679
AV_RN64
#define AV_RN64(p)
Definition: intreadwrite.h:364
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
put_bits
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:223
AVPacket::data
uint8_t * data
Definition: packet.h:539
AVOption
AVOption.
Definition: opt.h:429
encode.h
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:614
FIRST_DC_CB
#define FIRST_DC_CB
Definition: proresdata.h:36
chroma
static av_always_inline void chroma(WaveformContext *s, AVFrame *in, AVFrame *out, int component, int intensity, int offset_y, int offset_x, int column, int mirror, int jobnr, int nb_jobs)
Definition: vf_waveform.c:1639
ProresContext
Definition: proresdec.h:43
FFCodec
Definition: codec_internal.h:127
encode_alpha_slice_data
static av_always_inline int encode_alpha_slice_data(AVCodecContext *avctx, int8_t *src_a, unsigned mb_count, uint8_t *buf, unsigned data_size, unsigned *a_data_size)
Definition: proresenc_anatoliy.c:444
AVFrame::flags
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
Definition: frame.h:661
VE
#define VE
Definition: proresenc_anatoliy.c:932
prores_encode_init
static av_cold int prores_encode_init(AVCodecContext *avctx)
Definition: proresenc_anatoliy.c:816
ff_prores_progressive_scan
const uint8_t ff_prores_progressive_scan[64]
Definition: proresdata.c:25
ff_prores_level_to_cb
const uint8_t ff_prores_level_to_cb[10]
Definition: proresdata.c:52
FF_INPUT_BUFFER_MIN_SIZE
#define FF_INPUT_BUFFER_MIN_SIZE
Used by some encoders as upper bound for the length of headers.
Definition: encode.h:33
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:410
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
AV_PROFILE_PRORES_STANDARD
#define AV_PROFILE_PRORES_STANDARD
Definition: defs.h:183
encode_vlc_codeword
static void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int val)
Definition: proresenc_anatoliy.c:230
AV_FRAME_FLAG_TOP_FIELD_FIRST
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
Definition: frame.h:653
AVProfile
AVProfile.
Definition: codec.h:179
QMAT_CHROMA
static const uint8_t QMAT_CHROMA[6][64]
Definition: proresenc_anatoliy.c:123
AV_PROFILE_PRORES_HQ
#define AV_PROFILE_PRORES_HQ
Definition: defs.h:184
FDCTDSPContext
Definition: fdctdsp.h:28
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
ff_prores_aw_encoder
const FFCodec ff_prores_aw_encoder
Definition: proresenc_anatoliy.c:951
put_bits_left
static int put_bits_left(PutBitContext *s)
Definition: put_bits.h:125
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:508
val
static double val(void *priv, double ch)
Definition: aeval.c:77
qp_start_table
static const int qp_start_table[]
Definition: proresenc_anatoliy.c:54
FF_CODEC_ENCODE_CB
#define FF_CODEC_ENCODE_CB(func)
Definition: codec_internal.h:320
AV_CODEC_FLAG_INTERLACED_DCT
#define AV_CODEC_FLAG_INTERLACED_DCT
Use interlaced DCT.
Definition: avcodec.h:330
bitrate_table
static const int bitrate_table[]
Definition: proresenc_anatoliy.c:56
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:505
pkt
AVPacket * pkt
Definition: movenc.c:60
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
av_cold
#define av_cold
Definition: attributes.h:90
AV_PROFILE_UNKNOWN
#define AV_PROFILE_UNKNOWN
Definition: defs.h:65
AVCOL_PRI_RESERVED0
@ AVCOL_PRI_RESERVED0
Definition: pixfmt.h:587
LOCAL_ALIGNED
#define LOCAL_ALIGNED(a, t, v,...)
Definition: mem_internal.h:133
prores_encode_frame
static int prores_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
Definition: proresenc_anatoliy.c:729
ProresContext::fill_v
uint8_t * fill_v
Definition: proresenc_anatoliy.c:187
prores_encode_close
static av_cold int prores_encode_close(AVCodecContext *avctx)
Definition: proresenc_anatoliy.c:922
put_alpha_run
static void put_alpha_run(PutBitContext *pb, int run)
Definition: proresenc_anatoliy.c:431
AVCOL_SPC_SMPTE170M
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
Definition: pixfmt.h:647
frame_size
int frame_size
Definition: mxfenc.c:2429
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition: codec.h:159
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1585
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:230
ctx
AVFormatContext * ctx
Definition: movenc.c:49
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: proresenc_anatoliy.c:946
ff_prores_interlaced_scan
const uint8_t ff_prores_interlaced_scan[64]
Definition: proresdata.c:36
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:589
PutBitContext
Definition: put_bits.h:50
valid_primaries
static const int valid_primaries[]
Definition: proresenc_anatoliy.c:58
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
AVCOL_PRI_BT470BG
@ AVCOL_PRI_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
Definition: pixfmt.h:593
AVCOL_PRI_SMPTE170M
@ AVCOL_PRI_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: pixfmt.h:594
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:74
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:110
scale_mat
static void scale_mat(const uint8_t *src, int *dst, int scale)
Definition: proresenc_anatoliy.c:809
AVCOL_TRC_RESERVED0
@ AVCOL_TRC_RESERVED0
Definition: pixfmt.h:612
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
PutBitContext::buf
uint8_t * buf
Definition: put_bits.h:53
ff_prores_run_to_cb
const uint8_t ff_prores_run_to_cb[16]
Definition: proresdata.c:49
NULL
#define NULL
Definition: coverity.c:32
run
uint8_t run
Definition: svq3.c:204
AV_WB16
#define AV_WB16(p, v)
Definition: intreadwrite.h:401
ff_prores_encoder
const FFCodec ff_prores_encoder
Definition: proresenc_anatoliy.c:969
AVCOL_PRI_BT709
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
Definition: pixfmt.h:588
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
profiles.h
valid_trc
static const int valid_trc[]
Definition: proresenc_anatoliy.c:60
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:503
get
static void get(const uint8_t *pixels, int stride, int16_t *block)
Definition: proresenc_anatoliy.c:317
DEFAULT_SLICE_MB_WIDTH
#define DEFAULT_SLICE_MB_WIDTH
Definition: proresenc_anatoliy.c:42
AV_PROFILE_PRORES_LT
#define AV_PROFILE_PRORES_LT
Definition: defs.h:182
AVCOL_PRI_BT2020
@ AVCOL_PRI_BT2020
ITU-R BT2020.
Definition: pixfmt.h:597
AV_WB32
#define AV_WB32(p, v)
Definition: intreadwrite.h:415
AVCOL_TRC_SMPTE2084
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition: pixfmt.h:628
ProresContext::fill_y
uint8_t * fill_y
Definition: proresenc_anatoliy.c:185
AVCOL_PRI_SMPTE431
@ AVCOL_PRI_SMPTE431
SMPTE ST 431-2 (2011) / DCI P3.
Definition: pixfmt.h:600
profiles
static const AVProfile profiles[]
Definition: proresenc_anatoliy.c:44
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
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
put_alpha_diff
static void put_alpha_diff(PutBitContext *pb, int cur, int prev)
Definition: proresenc_anatoliy.c:411
ProresContext::fill_a
uint8_t * fill_a
Definition: proresenc_anatoliy.c:188
AV_CODEC_FLAG_GRAY
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
Definition: avcodec.h:322
AVPacket::size
int size
Definition: packet.h:540
dc
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2] ... the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so ...,+,-,+,-,+,+,-,+,-,+,... hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32 - hcoeff[1] - hcoeff[2] - ... a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2} an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||......... intra?||||:Block01 :yes no||||:Block02 :....... ..........||||:Block03 ::y DC ::ref index:||||:Block04 ::cb DC ::motion x :||||......... :cr DC ::motion y :||||....... ..........|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------ ------------ ------------|||Y subbands||Cb subbands||Cr subbands||||--- ---||--- ---||--- ---|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------ ------------ ------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction ------------|\ Dequantization ------------------- \||Reference frames|\ IDWT|------- -------|Motion \|||Frame 0||Frame 1||Compensation . OBMC v -------|------- -------|--------------. \------> Frame n output Frame Frame<----------------------------------/|...|------------------- Range Coder:============Binary Range Coder:------------------- The implemented range coder is an adapted version based upon "Range encoding: an algorithm for removing redundancy from a digitised message." by G. N. N. Martin. The symbols encoded by the Snow range coder are bits(0|1). The associated probabilities are not fix but change depending on the symbol mix seen so far. bit seen|new state ---------+----------------------------------------------- 0|256 - state_transition_table[256 - old_state];1|state_transition_table[old_state];state_transition_table={ 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:------------------------- FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1. the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled top and top right vectors is used as motion vector prediction the used motion vector is the sum of the predictor and(mvx_diff, mvy_diff) *mv_scale Intra DC Prediction block[y][x] dc[1]
Definition: snow.txt:400
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:94
ProresContext::scantable
const uint8_t * scantable
Definition: proresenc_anatoliy.c:192
height
#define height
Definition: dsp.h:85
codec_internal.h
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
calc_plane_dct
static void calc_plane_dct(FDCTDSPContext *fdsp, const uint8_t *src, int16_t *blocks, int src_stride, int mb_count, int chroma, int is_422)
Definition: proresenc_anatoliy.c:335
ProresContext::is_interlaced
int is_interlaced
Definition: proresenc_anatoliy.c:196
proresdata.h
ProresContext::is_422
int is_422
Definition: proresenc_anatoliy.c:194
diff
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
Definition: vf_paletteuse.c:166
AV_PROFILE_PRORES_4444
#define AV_PROFILE_PRORES_4444
Definition: defs.h:185
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:542
ff_prores_dc_codebook
const uint8_t ff_prores_dc_codebook[7]
Definition: proresdata.c:47
av_zero_extend
#define av_zero_extend
Definition: common.h:151
AV_PROFILE_PRORES_PROXY
#define AV_PROFILE_PRORES_PROXY
Definition: defs.h:181
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:220
AVCOL_TRC_BT709
@ AVCOL_TRC_BT709
also ITU-R BT1361
Definition: pixfmt.h:613
encode_acs
static void encode_acs(PutBitContext *pb, int16_t *blocks, int blocks_per_slice, int *qmat, const uint8_t *scan)
Definition: proresenc_anatoliy.c:286
encode_slice_plane
static int encode_slice_plane(int16_t *blocks, int mb_count, uint8_t *buf, unsigned buf_size, int *qmat, int sub_sample_chroma, const uint8_t *scan)
Definition: proresenc_anatoliy.c:372
AVCodecContext::bits_per_coded_sample
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:1578
bytestream_put_buffer
static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
Definition: bytestream.h:372
subimage_with_fill
static void subimage_with_fill(const uint16_t *src, unsigned x, unsigned y, unsigned stride, unsigned width, unsigned height, uint16_t *dst, unsigned dst_width, unsigned dst_height, int is_interlaced, int is_top_field)
Definition: proresenc_anatoliy.c:532
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
code
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
Definition: filter_design.txt:178
AVCOL_SPC_BT2020_NCL
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:651
ff_fdctdsp_init
av_cold void ff_fdctdsp_init(FDCTDSPContext *c, AVCodecContext *avctx)
Definition: fdctdsp.c:25
delta
float delta
Definition: vorbis_enc_data.h:430
xf
#define xf(width, name, var, range_min, range_max, subs,...)
Definition: cbs_av1.c:598
av_always_inline
#define av_always_inline
Definition: attributes.h:49
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
fdctdsp.h
encode_dcs
static void encode_dcs(PutBitContext *pb, int16_t *blocks, int blocks_per_slice, int scale)
Definition: proresenc_anatoliy.c:262
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
OFFSET
#define OFFSET(x)
Definition: proresenc_anatoliy.c:931
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:643
fdct_get
static void fdct_get(FDCTDSPContext *fdsp, const uint8_t *pixels, int stride, int16_t *block)
Definition: proresenc_anatoliy.c:329
AVCodecContext::height
int height
Definition: avcodec.h:624
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:663
qp_end_table
static const int qp_end_table[]
Definition: proresenc_anatoliy.c:55
AV_FRAME_FLAG_INTERLACED
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
Definition: frame.h:648
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:700
avcodec.h
stride
#define stride
Definition: h264pred_template.c:537
ProresContext::need_alpha
int need_alpha
Definition: proresenc_anatoliy.c:195
ret
ret
Definition: filter_design.txt:187
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:80
subimage_alpha_with_fill
static void subimage_alpha_with_fill(const uint16_t *src, unsigned x, unsigned y, unsigned stride, unsigned width, unsigned height, uint16_t *dst, unsigned dst_width, unsigned dst_height, int is_interlaced, int is_top_field)
Definition: proresenc_anatoliy.c:540
encode_slice_data
static av_always_inline unsigned encode_slice_data(AVCodecContext *avctx, int16_t *blocks_y, int16_t *blocks_u, int16_t *blocks_v, unsigned mb_count, uint8_t *buf, unsigned data_size, unsigned *y_data_size, unsigned *u_data_size, unsigned *v_data_size, int qp)
Definition: proresenc_anatoliy.c:388
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
ProresContext::fill_u
uint8_t * fill_u
Definition: proresenc_anatoliy.c:186
AVCodecContext
main external API structure.
Definition: avcodec.h:451
AVCOL_TRC_ARIB_STD_B67
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
Definition: pixfmt.h:632
put_bits_ptr
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
Definition: put_bits.h:377
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AVCodecContext::profile
int profile
profile
Definition: avcodec.h:1650
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
mem.h
FRAME_ID
#define FRAME_ID
Definition: proresdata.h:28
QMAT_LUMA
static const uint8_t QMAT_LUMA[6][64]
Definition: proresenc_anatoliy.c:65
valid_colorspace
static const int valid_colorspace[]
Definition: proresenc_anatoliy.c:62
FDCTDSPContext::fdct
void(* fdct)(int16_t *block)
Definition: fdctdsp.h:29
MAKE_CODE
#define MAKE_CODE(x)
Definition: proresenc_anatoliy.c:260
flush_put_bits
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Definition: put_bits.h:143
AVCOL_PRI_SMPTE432
@ AVCOL_PRI_SMPTE432
SMPTE ST 432-1 (2010) / P3 D65 / Display P3.
Definition: pixfmt.h:601
AVCodecContext::codec_tag
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition: avcodec.h:476
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: intra.c:291
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
AVPacket
This structure stores compressed data.
Definition: packet.h:516
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:478
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:624
bytestream.h
AV_PROFILE_PRORES_XQ
#define AV_PROFILE_PRORES_XQ
Definition: defs.h:186
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:52
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:434
block
The exact code depends on how similar the blocks are and how related they are to the block
Definition: filter_design.txt:207
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AV_WN64
#define AV_WN64(p, v)
Definition: intreadwrite.h:376
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276
width
#define width
Definition: dsp.h:85
AVCOL_SPC_BT709
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
Definition: pixfmt.h:642
put_bits.h
av_log2
int av_log2(unsigned v)
Definition: intmath.c:26
ff_alloc_packet
int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.
Definition: encode.c:62
src
#define src
Definition: vp8dsp.c:248
codebook
static const unsigned codebook[256][2]
Definition: cfhdenc.c:41
AV_CODEC_ID_PRORES
@ AV_CODEC_ID_PRORES
Definition: codec_id.h:200