FFmpeg
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
proresdec.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2011 Maxim Poliakovski
3  * Copyright (c) 2010-2011 Elvis Presley
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * Known FOURCCs: 'apch' (HQ), 'apcn' (SD), 'apcs' (LT), 'apco' (Proxy), 'ap4h' (4444), 'ap4x' (4444 XQ)
25  */
26 
27 //#define DEBUG
28 
29 #include "config_components.h"
30 
31 #include "libavutil/internal.h"
32 #include "libavutil/mem.h"
33 #include "libavutil/mem_internal.h"
34 
35 #include "avcodec.h"
36 #include "codec_internal.h"
37 #include "decode.h"
38 #include "get_bits.h"
39 #include "hwaccel_internal.h"
40 #include "hwconfig.h"
41 #include "idctdsp.h"
42 #include "profiles.h"
43 #include "proresdec.h"
44 #include "proresdata.h"
45 #include "thread.h"
46 
47 #define ALPHA_SHIFT_16_TO_10(alpha_val) (alpha_val >> 6)
48 #define ALPHA_SHIFT_8_TO_10(alpha_val) ((alpha_val << 2) | (alpha_val >> 6))
49 #define ALPHA_SHIFT_16_TO_12(alpha_val) (alpha_val >> 4)
50 #define ALPHA_SHIFT_8_TO_12(alpha_val) ((alpha_val << 4) | (alpha_val >> 4))
51 
52 static void inline unpack_alpha(GetBitContext *gb, uint16_t *dst, int num_coeffs,
53  const int num_bits, const int decode_precision) {
54  const int mask = (1 << num_bits) - 1;
55  int i, idx, val, alpha_val;
56 
57  idx = 0;
58  alpha_val = mask;
59  do {
60  do {
61  if (get_bits1(gb)) {
62  val = get_bits(gb, num_bits);
63  } else {
64  int sign;
65  val = get_bits(gb, num_bits == 16 ? 7 : 4);
66  sign = val & 1;
67  val = (val + 2) >> 1;
68  if (sign)
69  val = -val;
70  }
71  alpha_val = (alpha_val + val) & mask;
72  if (num_bits == 16) {
73  if (decode_precision == 10) {
74  dst[idx++] = ALPHA_SHIFT_16_TO_10(alpha_val);
75  } else { /* 12b */
76  dst[idx++] = ALPHA_SHIFT_16_TO_12(alpha_val);
77  }
78  } else {
79  if (decode_precision == 10) {
80  dst[idx++] = ALPHA_SHIFT_8_TO_10(alpha_val);
81  } else { /* 12b */
82  dst[idx++] = ALPHA_SHIFT_8_TO_12(alpha_val);
83  }
84  }
85  if (idx >= num_coeffs)
86  break;
87  } while (get_bits_left(gb)>0 && get_bits1(gb));
88  val = get_bits(gb, 4);
89  if (!val)
90  val = get_bits(gb, 11);
91  if (idx + val > num_coeffs)
92  val = num_coeffs - idx;
93  if (num_bits == 16) {
94  for (i = 0; i < val; i++) {
95  if (decode_precision == 10) {
96  dst[idx++] = ALPHA_SHIFT_16_TO_10(alpha_val);
97  } else { /* 12b */
98  dst[idx++] = ALPHA_SHIFT_16_TO_12(alpha_val);
99  }
100  }
101  } else {
102  for (i = 0; i < val; i++) {
103  if (decode_precision == 10) {
104  dst[idx++] = ALPHA_SHIFT_8_TO_10(alpha_val);
105  } else { /* 12b */
106  dst[idx++] = ALPHA_SHIFT_8_TO_12(alpha_val);
107  }
108  }
109  }
110  } while (idx < num_coeffs);
111 }
112 
113 static void unpack_alpha_10(GetBitContext *gb, uint16_t *dst, int num_coeffs,
114  const int num_bits)
115 {
116  if (num_bits == 16) {
117  unpack_alpha(gb, dst, num_coeffs, 16, 10);
118  } else { /* 8 bits alpha */
119  unpack_alpha(gb, dst, num_coeffs, 8, 10);
120  }
121 }
122 
123 static void unpack_alpha_12(GetBitContext *gb, uint16_t *dst, int num_coeffs,
124  const int num_bits)
125 {
126  if (num_bits == 16) {
127  unpack_alpha(gb, dst, num_coeffs, 16, 12);
128  } else { /* 8 bits alpha */
129  unpack_alpha(gb, dst, num_coeffs, 8, 12);
130  }
131 }
132 
134 {
135  ProresContext *ctx = avctx->priv_data;
136 
137  avctx->bits_per_raw_sample = 10;
138 
139  switch (avctx->codec_tag) {
140  case MKTAG('a','p','c','o'):
142  break;
143  case MKTAG('a','p','c','s'):
144  avctx->profile = AV_PROFILE_PRORES_LT;
145  break;
146  case MKTAG('a','p','c','n'):
148  break;
149  case MKTAG('a','p','c','h'):
150  avctx->profile = AV_PROFILE_PRORES_HQ;
151  break;
152  case MKTAG('a','p','4','h'):
154  avctx->bits_per_raw_sample = 12;
155  break;
156  case MKTAG('a','p','4','x'):
157  avctx->profile = AV_PROFILE_PRORES_XQ;
158  avctx->bits_per_raw_sample = 12;
159  break;
160  default:
161  avctx->profile = AV_PROFILE_UNKNOWN;
162  av_log(avctx, AV_LOG_WARNING, "Unknown prores profile %d\n", avctx->codec_tag);
163  }
164 
165  ctx->unpack_alpha = avctx->bits_per_raw_sample == 10 ?
167 
168  av_log(avctx, AV_LOG_DEBUG,
169  "Auto bitdepth precision. Use %db decoding based on codec tag.\n",
170  avctx->bits_per_raw_sample);
171 
172  ff_blockdsp_init(&ctx->bdsp);
173  ff_proresdsp_init(&ctx->prodsp, avctx->bits_per_raw_sample);
174 
176  ctx->prodsp.idct_permutation);
178  ctx->prodsp.idct_permutation);
179 
180  ctx->pix_fmt = AV_PIX_FMT_NONE;
181 
182  return 0;
183 }
184 
185 static int decode_frame_header(ProresContext *ctx, const uint8_t *buf,
186  const int data_size, AVCodecContext *avctx)
187 {
188  int hdr_size, width, height, flags;
189  int version;
190  const uint8_t *ptr;
191  enum AVPixelFormat pix_fmt;
192 
193  hdr_size = AV_RB16(buf);
194  ff_dlog(avctx, "header size %d\n", hdr_size);
195  if (hdr_size > data_size) {
196  av_log(avctx, AV_LOG_ERROR, "error, wrong header size\n");
197  return AVERROR_INVALIDDATA;
198  }
199 
200  version = AV_RB16(buf + 2);
201  ff_dlog(avctx, "%.4s version %d\n", buf+4, version);
202  if (version > 1) {
203  av_log(avctx, AV_LOG_ERROR, "unsupported version: %d\n", version);
204  return AVERROR_PATCHWELCOME;
205  }
206 
207  width = AV_RB16(buf + 8);
208  height = AV_RB16(buf + 10);
209 
210  if (width != avctx->width || height != avctx->height) {
211  int ret;
212 
213  av_log(avctx, AV_LOG_WARNING, "picture resolution change: %dx%d -> %dx%d\n",
214  avctx->width, avctx->height, width, height);
215  if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
216  return ret;
217  }
218 
219  ctx->frame_type = (buf[12] >> 2) & 3;
220  ctx->alpha_info = buf[17] & 0xf;
221 
222  if (ctx->alpha_info > 2) {
223  av_log(avctx, AV_LOG_ERROR, "Invalid alpha mode %d\n", ctx->alpha_info);
224  return AVERROR_INVALIDDATA;
225  }
226  if (avctx->skip_alpha) ctx->alpha_info = 0;
227 
228  ff_dlog(avctx, "frame type %d\n", ctx->frame_type);
229 
230  if (ctx->frame_type == 0) {
231  ctx->scan = ctx->progressive_scan; // permuted
232  } else {
233  ctx->scan = ctx->interlaced_scan; // permuted
235  if (ctx->frame_type == 1)
237  }
238 
239  if (ctx->alpha_info) {
240  if (avctx->bits_per_raw_sample == 10) {
241  pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUVA444P10 : AV_PIX_FMT_YUVA422P10;
242  } else { /* 12b */
243  pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUVA444P12 : AV_PIX_FMT_YUVA422P12;
244  }
245  } else {
246  if (avctx->bits_per_raw_sample == 10) {
247  pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUV444P10 : AV_PIX_FMT_YUV422P10;
248  } else { /* 12b */
249  pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUV444P12 : AV_PIX_FMT_YUV422P12;
250  }
251  }
252 
253  if (pix_fmt != ctx->pix_fmt) {
254 #define HWACCEL_MAX (CONFIG_PRORES_VIDEOTOOLBOX_HWACCEL)
255 #if HWACCEL_MAX
256  enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts;
257  int ret;
258 
259  ctx->pix_fmt = pix_fmt;
260 
261 #if CONFIG_PRORES_VIDEOTOOLBOX_HWACCEL
262  *fmtp++ = AV_PIX_FMT_VIDEOTOOLBOX;
263 #endif
264  *fmtp++ = ctx->pix_fmt;
265  *fmtp = AV_PIX_FMT_NONE;
266 
267  if ((ret = ff_get_format(avctx, pix_fmts)) < 0)
268  return ret;
269 
270  avctx->pix_fmt = ret;
271 #else
272  avctx->pix_fmt = ctx->pix_fmt = pix_fmt;
273 #endif
274  }
275 
276  ctx->frame->color_primaries = buf[14];
277  ctx->frame->color_trc = buf[15];
278  ctx->frame->colorspace = buf[16];
279  ctx->frame->color_range = AVCOL_RANGE_MPEG;
280 
281  ptr = buf + 20;
282  flags = buf[19];
283  ff_dlog(avctx, "flags %x\n", flags);
284 
285  if (flags & 2) {
286  if(buf + data_size - ptr < 64) {
287  av_log(avctx, AV_LOG_ERROR, "Header truncated\n");
288  return AVERROR_INVALIDDATA;
289  }
290  ff_permute_scantable(ctx->qmat_luma, ctx->prodsp.idct_permutation, ptr);
291  ptr += 64;
292  } else {
293  memset(ctx->qmat_luma, 4, 64);
294  }
295 
296  if (flags & 1) {
297  if(buf + data_size - ptr < 64) {
298  av_log(avctx, AV_LOG_ERROR, "Header truncated\n");
299  return AVERROR_INVALIDDATA;
300  }
301  ff_permute_scantable(ctx->qmat_chroma, ctx->prodsp.idct_permutation, ptr);
302  } else {
303  memcpy(ctx->qmat_chroma, ctx->qmat_luma, 64);
304  }
305 
306  return hdr_size;
307 }
308 
309 static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, const int buf_size)
310 {
311  ProresContext *ctx = avctx->priv_data;
312  int i, hdr_size, slice_count;
313  unsigned pic_data_size;
314  int log2_slice_mb_width, log2_slice_mb_height;
315  int slice_mb_count, mb_x, mb_y;
316  const uint8_t *data_ptr, *index_ptr;
317 
318  hdr_size = buf[0] >> 3;
319  if (hdr_size < 8 || hdr_size > buf_size) {
320  av_log(avctx, AV_LOG_ERROR, "error, wrong picture header size\n");
321  return AVERROR_INVALIDDATA;
322  }
323 
324  pic_data_size = AV_RB32(buf + 1);
325  if (pic_data_size > buf_size) {
326  av_log(avctx, AV_LOG_ERROR, "error, wrong picture data size\n");
327  return AVERROR_INVALIDDATA;
328  }
329 
330  log2_slice_mb_width = buf[7] >> 4;
331  log2_slice_mb_height = buf[7] & 0xF;
332  if (log2_slice_mb_width > 3 || log2_slice_mb_height) {
333  av_log(avctx, AV_LOG_ERROR, "unsupported slice resolution: %dx%d\n",
334  1 << log2_slice_mb_width, 1 << log2_slice_mb_height);
335  return AVERROR_INVALIDDATA;
336  }
337 
338  ctx->mb_width = (avctx->width + 15) >> 4;
339  if (ctx->frame_type)
340  ctx->mb_height = (avctx->height + 31) >> 5;
341  else
342  ctx->mb_height = (avctx->height + 15) >> 4;
343 
344  // QT ignores the written value
345  // slice_count = AV_RB16(buf + 5);
346  slice_count = ctx->mb_height * ((ctx->mb_width >> log2_slice_mb_width) +
347  av_popcount(ctx->mb_width & (1 << log2_slice_mb_width) - 1));
348 
349  if (ctx->slice_count != slice_count || !ctx->slices) {
350  av_freep(&ctx->slices);
351  ctx->slice_count = 0;
352  ctx->slices = av_calloc(slice_count, sizeof(*ctx->slices));
353  if (!ctx->slices)
354  return AVERROR(ENOMEM);
355  ctx->slice_count = slice_count;
356  }
357 
358  if (!slice_count)
359  return AVERROR(EINVAL);
360 
361  if (hdr_size + slice_count*2 > buf_size) {
362  av_log(avctx, AV_LOG_ERROR, "error, wrong slice count\n");
363  return AVERROR_INVALIDDATA;
364  }
365 
366  // parse slice information
367  index_ptr = buf + hdr_size;
368  data_ptr = index_ptr + slice_count*2;
369 
370  slice_mb_count = 1 << log2_slice_mb_width;
371  mb_x = 0;
372  mb_y = 0;
373 
374  for (i = 0; i < slice_count; i++) {
375  SliceContext *slice = &ctx->slices[i];
376 
377  slice->data = data_ptr;
378  data_ptr += AV_RB16(index_ptr + i*2);
379 
380  while (ctx->mb_width - mb_x < slice_mb_count)
381  slice_mb_count >>= 1;
382 
383  slice->mb_x = mb_x;
384  slice->mb_y = mb_y;
385  slice->mb_count = slice_mb_count;
386  slice->data_size = data_ptr - slice->data;
387 
388  if (slice->data_size < 6) {
389  av_log(avctx, AV_LOG_ERROR, "error, wrong slice data size\n");
390  return AVERROR_INVALIDDATA;
391  }
392 
393  mb_x += slice_mb_count;
394  if (mb_x == ctx->mb_width) {
395  slice_mb_count = 1 << log2_slice_mb_width;
396  mb_x = 0;
397  mb_y++;
398  }
399  if (data_ptr > buf + buf_size) {
400  av_log(avctx, AV_LOG_ERROR, "error, slice out of bounds\n");
401  return AVERROR_INVALIDDATA;
402  }
403  }
404 
405  if (mb_x || mb_y != ctx->mb_height) {
406  av_log(avctx, AV_LOG_ERROR, "error wrong mb count y %d h %d\n",
407  mb_y, ctx->mb_height);
408  return AVERROR_INVALIDDATA;
409  }
410 
411  return pic_data_size;
412 }
413 
414 #define DECODE_CODEWORD(val, codebook, SKIP) \
415  do { \
416  unsigned int rice_order, exp_order, switch_bits; \
417  unsigned int q, buf, bits; \
418  \
419  UPDATE_CACHE_32(re, gb); /* We really need 32 bits */ \
420  buf = GET_CACHE(re, gb); \
421  \
422  /* number of bits to switch between rice and exp golomb */ \
423  switch_bits = codebook & 3; \
424  rice_order = codebook >> 5; \
425  exp_order = (codebook >> 2) & 7; \
426  \
427  q = 31 - av_log2(buf); \
428  \
429  if (q > switch_bits) { /* exp golomb */ \
430  bits = exp_order - switch_bits + (q<<1); \
431  if (bits > 31) \
432  return AVERROR_INVALIDDATA; \
433  val = SHOW_UBITS(re, gb, bits) - (1 << exp_order) + \
434  ((switch_bits + 1) << rice_order); \
435  SKIP(re, gb, bits); \
436  } else if (rice_order) { \
437  SKIP_BITS(re, gb, q+1); \
438  val = (q << rice_order) + SHOW_UBITS(re, gb, rice_order); \
439  SKIP(re, gb, rice_order); \
440  } else { \
441  val = q; \
442  SKIP(re, gb, q+1); \
443  } \
444  } while (0)
445 
446 #define TOSIGNED(x) (((x) >> 1) ^ (-((x) & 1)))
447 
448 #define FIRST_DC_CB 0xB8
449 
450 static const uint8_t dc_codebook[7] = { 0x04, 0x28, 0x28, 0x4D, 0x4D, 0x70, 0x70};
451 
453  int blocks_per_slice)
454 {
455  int16_t prev_dc;
456  int code, i, sign;
457 
458  OPEN_READER(re, gb);
459 
461  prev_dc = TOSIGNED(code);
462  out[0] = prev_dc;
463 
464  out += 64; // dc coeff for the next block
465 
466  code = 5;
467  sign = 0;
468  for (i = 1; i < blocks_per_slice; i++, out += 64) {
470  if(code) sign ^= -(code & 1);
471  else sign = 0;
472  prev_dc += (((code + 1) >> 1) ^ sign) - sign;
473  out[0] = prev_dc;
474  }
475  CLOSE_READER(re, gb);
476  return 0;
477 }
478 
479 // adaptive codebook switching lut according to previous run/level values
480 static const uint8_t run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29, 0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C };
481 static const uint8_t lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28, 0x28, 0x28, 0x28, 0x4C };
482 
484  int16_t *out, int blocks_per_slice)
485 {
486  const ProresContext *ctx = avctx->priv_data;
487  int block_mask, sign;
488  unsigned pos, run, level;
489  int max_coeffs, i, bits_left;
490  int log2_block_count = av_log2(blocks_per_slice);
491 
492  OPEN_READER(re, gb);
493  UPDATE_CACHE_32(re, gb);
494  run = 4;
495  level = 2;
496 
497  max_coeffs = 64 << log2_block_count;
498  block_mask = blocks_per_slice - 1;
499 
500  for (pos = block_mask;;) {
501  bits_left = gb->size_in_bits - re_index;
502  if (bits_left <= 0 || (bits_left < 32 && !SHOW_UBITS(re, gb, bits_left)))
503  break;
504 
506  pos += run + 1;
507  if (pos >= max_coeffs) {
508  av_log(avctx, AV_LOG_ERROR, "ac tex damaged %d, %d\n", pos, max_coeffs);
509  return AVERROR_INVALIDDATA;
510  }
511 
513  level += 1;
514 
515  i = pos >> log2_block_count;
516 
517  sign = SHOW_SBITS(re, gb, 1);
518  SKIP_BITS(re, gb, 1);
519  out[((pos & block_mask) << 6) + ctx->scan[i]] = ((level ^ sign) - sign);
520  }
521 
522  CLOSE_READER(re, gb);
523  return 0;
524 }
525 
527  uint16_t *dst, int dst_stride,
528  const uint8_t *buf, unsigned buf_size,
529  const int16_t *qmat)
530 {
531  const ProresContext *ctx = avctx->priv_data;
532  LOCAL_ALIGNED_32(int16_t, blocks, [8*4*64]);
533  int16_t *block;
534  GetBitContext gb;
535  int i, blocks_per_slice = slice->mb_count<<2;
536  int ret;
537 
538  for (i = 0; i < blocks_per_slice; i++)
539  ctx->bdsp.clear_block(blocks+(i<<6));
540 
541  init_get_bits(&gb, buf, buf_size << 3);
542 
543  if ((ret = decode_dc_coeffs(&gb, blocks, blocks_per_slice)) < 0)
544  return ret;
545  if ((ret = decode_ac_coeffs(avctx, &gb, blocks, blocks_per_slice)) < 0)
546  return ret;
547 
548  block = blocks;
549  for (i = 0; i < slice->mb_count; i++) {
550  ctx->prodsp.idct_put(dst, dst_stride, block+(0<<6), qmat);
551  ctx->prodsp.idct_put(dst +8, dst_stride, block+(1<<6), qmat);
552  ctx->prodsp.idct_put(dst+4*dst_stride , dst_stride, block+(2<<6), qmat);
553  ctx->prodsp.idct_put(dst+4*dst_stride+8, dst_stride, block+(3<<6), qmat);
554  block += 4*64;
555  dst += 16;
556  }
557  return 0;
558 }
559 
561  uint16_t *dst, int dst_stride,
562  const uint8_t *buf, unsigned buf_size,
563  const int16_t *qmat, int log2_blocks_per_mb)
564 {
565  ProresContext *ctx = avctx->priv_data;
566  LOCAL_ALIGNED_32(int16_t, blocks, [8*4*64]);
567  int16_t *block;
568  GetBitContext gb;
569  int i, j, blocks_per_slice = slice->mb_count << log2_blocks_per_mb;
570  int ret;
571 
572  for (i = 0; i < blocks_per_slice; i++)
573  ctx->bdsp.clear_block(blocks+(i<<6));
574 
575  init_get_bits(&gb, buf, buf_size << 3);
576 
577  if ((ret = decode_dc_coeffs(&gb, blocks, blocks_per_slice)) < 0)
578  return ret;
579  if ((ret = decode_ac_coeffs(avctx, &gb, blocks, blocks_per_slice)) < 0)
580  return ret;
581 
582  block = blocks;
583  for (i = 0; i < slice->mb_count; i++) {
584  for (j = 0; j < log2_blocks_per_mb; j++) {
585  ctx->prodsp.idct_put(dst, dst_stride, block+(0<<6), qmat);
586  ctx->prodsp.idct_put(dst+4*dst_stride, dst_stride, block+(1<<6), qmat);
587  block += 2*64;
588  dst += 8;
589  }
590  }
591  return 0;
592 }
593 
594 /**
595  * Decode alpha slice plane.
596  */
598  uint16_t *dst, int dst_stride,
599  const uint8_t *buf, int buf_size,
600  int blocks_per_slice)
601 {
602  GetBitContext gb;
603  int i;
604  LOCAL_ALIGNED_32(int16_t, blocks, [8*4*64]);
605  int16_t *block;
606 
607  for (i = 0; i < blocks_per_slice<<2; i++)
608  ctx->bdsp.clear_block(blocks+(i<<6));
609 
610  init_get_bits(&gb, buf, buf_size << 3);
611 
612  if (ctx->alpha_info == 2) {
613  ctx->unpack_alpha(&gb, blocks, blocks_per_slice * 4 * 64, 16);
614  } else {
615  ctx->unpack_alpha(&gb, blocks, blocks_per_slice * 4 * 64, 8);
616  }
617 
618  block = blocks;
619 
620  for (i = 0; i < 16; i++) {
621  memcpy(dst, block, 16 * blocks_per_slice * sizeof(*dst));
622  dst += dst_stride >> 1;
623  block += 16 * blocks_per_slice;
624  }
625 }
626 
627 static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
628 {
629  const ProresContext *ctx = avctx->priv_data;
630  SliceContext *slice = &ctx->slices[jobnr];
631  const uint8_t *buf = slice->data;
632  AVFrame *pic = ctx->frame;
633  int i, hdr_size, qscale, log2_chroma_blocks_per_mb;
634  int luma_stride, chroma_stride;
635  int y_data_size, u_data_size, v_data_size, a_data_size, offset;
636  uint8_t *dest_y, *dest_u, *dest_v;
637  LOCAL_ALIGNED_16(int16_t, qmat_luma_scaled, [64]);
638  LOCAL_ALIGNED_16(int16_t, qmat_chroma_scaled,[64]);
639  int mb_x_shift;
640  int ret;
641  uint16_t val_no_chroma;
642 
643  slice->ret = -1;
644  //av_log(avctx, AV_LOG_INFO, "slice %d mb width %d mb x %d y %d\n",
645  // jobnr, slice->mb_count, slice->mb_x, slice->mb_y);
646 
647  // slice header
648  hdr_size = buf[0] >> 3;
649  qscale = av_clip(buf[1], 1, 224);
650  qscale = qscale > 128 ? qscale - 96 << 2: qscale;
651  y_data_size = AV_RB16(buf + 2);
652  u_data_size = AV_RB16(buf + 4);
653  v_data_size = slice->data_size - y_data_size - u_data_size - hdr_size;
654  if (hdr_size > 7) v_data_size = AV_RB16(buf + 6);
655  a_data_size = slice->data_size - y_data_size - u_data_size -
656  v_data_size - hdr_size;
657 
658  if (y_data_size < 0 || u_data_size < 0 || v_data_size < 0
659  || hdr_size+y_data_size+u_data_size+v_data_size > slice->data_size){
660  av_log(avctx, AV_LOG_ERROR, "invalid plane data size\n");
661  return AVERROR_INVALIDDATA;
662  }
663 
664  buf += hdr_size;
665 
666  for (i = 0; i < 64; i++) {
667  qmat_luma_scaled [i] = ctx->qmat_luma [i] * qscale;
668  qmat_chroma_scaled[i] = ctx->qmat_chroma[i] * qscale;
669  }
670 
671  if (ctx->frame_type == 0) {
672  luma_stride = pic->linesize[0];
673  chroma_stride = pic->linesize[1];
674  } else {
675  luma_stride = pic->linesize[0] << 1;
676  chroma_stride = pic->linesize[1] << 1;
677  }
678 
679  if (avctx->pix_fmt == AV_PIX_FMT_YUV444P10 || avctx->pix_fmt == AV_PIX_FMT_YUVA444P10 ||
681  mb_x_shift = 5;
682  log2_chroma_blocks_per_mb = 2;
683  } else {
684  mb_x_shift = 4;
685  log2_chroma_blocks_per_mb = 1;
686  }
687 
688  offset = (slice->mb_y << 4) * luma_stride + (slice->mb_x << 5);
689  dest_y = pic->data[0] + offset;
690  dest_u = pic->data[1] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift);
691  dest_v = pic->data[2] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift);
692 
693  if (ctx->frame_type && ctx->first_field ^ !!(ctx->frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST)) {
694  dest_y += pic->linesize[0];
695  dest_u += pic->linesize[1];
696  dest_v += pic->linesize[2];
697  offset += pic->linesize[3];
698  }
699 
700  ret = decode_slice_luma(avctx, slice, (uint16_t*)dest_y, luma_stride,
701  buf, y_data_size, qmat_luma_scaled);
702  if (ret < 0)
703  return ret;
704 
705  if (!(avctx->flags & AV_CODEC_FLAG_GRAY) && (u_data_size + v_data_size) > 0) {
706  ret = decode_slice_chroma(avctx, slice, (uint16_t*)dest_u, chroma_stride,
707  buf + y_data_size, u_data_size,
708  qmat_chroma_scaled, log2_chroma_blocks_per_mb);
709  if (ret < 0)
710  return ret;
711 
712  ret = decode_slice_chroma(avctx, slice, (uint16_t*)dest_v, chroma_stride,
713  buf + y_data_size + u_data_size, v_data_size,
714  qmat_chroma_scaled, log2_chroma_blocks_per_mb);
715  if (ret < 0)
716  return ret;
717  }
718  else {
719  size_t mb_max_x = slice->mb_count << (mb_x_shift - 1);
720  size_t i, j;
721  if (avctx->bits_per_raw_sample == 10) {
722  val_no_chroma = 511;
723  } else { /* 12b */
724  val_no_chroma = 511 * 4;
725  }
726  for (i = 0; i < 16; ++i)
727  for (j = 0; j < mb_max_x; ++j) {
728  *(uint16_t*)(dest_u + (i * chroma_stride) + (j << 1)) = val_no_chroma;
729  *(uint16_t*)(dest_v + (i * chroma_stride) + (j << 1)) = val_no_chroma;
730  }
731  }
732 
733  /* decode alpha plane if available */
734  if (ctx->alpha_info && pic->data[3] && a_data_size) {
735  uint8_t *dest_a = pic->data[3] + offset;
736  decode_slice_alpha(ctx, (uint16_t*)dest_a, luma_stride,
737  buf + y_data_size + u_data_size + v_data_size,
738  a_data_size, slice->mb_count);
739  }
740 
741  slice->ret = 0;
742  return 0;
743 }
744 
745 static int decode_picture(AVCodecContext *avctx)
746 {
747  ProresContext *ctx = avctx->priv_data;
748  int i;
749  int error = 0;
750 
751  avctx->execute2(avctx, decode_slice_thread, NULL, NULL, ctx->slice_count);
752 
753  for (i = 0; i < ctx->slice_count; i++)
754  error += ctx->slices[i].ret < 0;
755 
756  if (error)
757  ctx->frame->decode_error_flags = FF_DECODE_ERROR_INVALID_BITSTREAM;
758  if (error < ctx->slice_count)
759  return 0;
760 
761  return ctx->slices[0].ret;
762 }
763 
765  int *got_frame, AVPacket *avpkt)
766 {
767  ProresContext *ctx = avctx->priv_data;
768  const uint8_t *buf = avpkt->data;
769  int buf_size = avpkt->size;
770  int frame_hdr_size, pic_size, ret;
771 
772  if (buf_size < 28 || AV_RL32(buf + 4) != AV_RL32("icpf")) {
773  av_log(avctx, AV_LOG_ERROR, "invalid frame header\n");
774  return AVERROR_INVALIDDATA;
775  }
776 
777  ctx->frame = frame;
778  ctx->first_field = 1;
779 
780  buf += 8;
781  buf_size -= 8;
782 
783  frame_hdr_size = decode_frame_header(ctx, buf, buf_size, avctx);
784  if (frame_hdr_size < 0)
785  return frame_hdr_size;
786 
787  buf += frame_hdr_size;
788  buf_size -= frame_hdr_size;
789 
790  if ((ret = ff_thread_get_buffer(avctx, frame, 0)) < 0)
791  return ret;
792  ff_thread_finish_setup(avctx);
793 
794  if (HWACCEL_MAX && avctx->hwaccel) {
795  const FFHWAccel *hwaccel = ffhwaccel(avctx->hwaccel);
796  ret = hwaccel->start_frame(avctx, NULL, 0);
797  if (ret < 0)
798  return ret;
799  ret = hwaccel->decode_slice(avctx, avpkt->data, avpkt->size);
800  if (ret < 0)
801  return ret;
802  ret = hwaccel->end_frame(avctx);
803  if (ret < 0)
804  return ret;
805  goto finish;
806  }
807 
809  pic_size = decode_picture_header(avctx, buf, buf_size);
810  if (pic_size < 0) {
811  av_log(avctx, AV_LOG_ERROR, "error decoding picture header\n");
812  return pic_size;
813  }
814 
815  if ((ret = decode_picture(avctx)) < 0) {
816  av_log(avctx, AV_LOG_ERROR, "error decoding picture\n");
817  return ret;
818  }
819 
820  buf += pic_size;
821  buf_size -= pic_size;
822 
823  if (ctx->frame_type && buf_size > 0 && ctx->first_field) {
824  ctx->first_field = 0;
825  goto decode_picture;
826  }
827 
828 finish:
829  *got_frame = 1;
830 
831  return avpkt->size;
832 }
833 
835 {
836  ProresContext *ctx = avctx->priv_data;
837 
838  av_freep(&ctx->slices);
839 
840  return 0;
841 }
842 
843 #if HAVE_THREADS
845 {
846  ProresContext *csrc = src->priv_data;
847  ProresContext *cdst = dst->priv_data;
848 
849  cdst->pix_fmt = csrc->pix_fmt;
850 
851  return 0;
852 }
853 #endif
854 
856  .p.name = "prores",
857  CODEC_LONG_NAME("Apple ProRes (iCodec Pro)"),
858  .p.type = AVMEDIA_TYPE_VIDEO,
859  .p.id = AV_CODEC_ID_PRORES,
860  .priv_data_size = sizeof(ProresContext),
861  .init = decode_init,
862  .close = decode_close,
867 #if HWACCEL_MAX
868  .hw_configs = (const AVCodecHWConfigInternal *const []) {
869 #if CONFIG_PRORES_VIDEOTOOLBOX_HWACCEL
870  HWACCEL_VIDEOTOOLBOX(prores),
871 #endif
872  NULL
873  },
874 #endif
875 };
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:32
hwconfig.h
AVCodecContext::hwaccel
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
Definition: avcodec.h:1445
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:215
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
level
uint8_t level
Definition: svq3.c:205
av_clip
#define av_clip
Definition: common.h:100
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:678
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
mem_internal.h
ff_get_format
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
Definition: decode.c:1274
out
FILE * out
Definition: movenc.c:55
ff_prores_profiles
const AVProfile ff_prores_profiles[]
Definition: profiles.c:175
decode_frame_header
static int decode_frame_header(ProresContext *ctx, const uint8_t *buf, const int data_size, AVCodecContext *avctx)
Definition: proresdec.c:185
unpack_alpha_10
static void unpack_alpha_10(GetBitContext *gb, uint16_t *dst, int num_coeffs, const int num_bits)
Definition: proresdec.c:113
mask
int mask
Definition: mediacodecdec_common.c:154
GetBitContext::size_in_bits
int size_in_bits
Definition: get_bits.h:111
HWACCEL_MAX
#define HWACCEL_MAX
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:410
decode_frame
static int decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
Definition: proresdec.c:764
AVPacket::data
uint8_t * data
Definition: packet.h:539
decode_picture_header
static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, const int buf_size)
Definition: proresdec.c:309
ProresContext
Definition: proresdec.h:43
SliceContext::mb_x
unsigned mb_x
Definition: proresdec.h:36
FFCodec
Definition: codec_internal.h:127
av_popcount
#define av_popcount
Definition: common.h:154
ff_set_dimensions
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
Definition: utils.c:91
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:570
ff_prores_progressive_scan
const uint8_t ff_prores_progressive_scan[64]
Definition: proresdata.c:25
init_get_bits
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition: get_bits.h:497
thread.h
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:431
AV_PROFILE_PRORES_STANDARD
#define AV_PROFILE_PRORES_STANDARD
Definition: defs.h:183
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:674
ff_permute_scantable
av_cold void ff_permute_scantable(uint8_t dst[64], const uint8_t src[64], const uint8_t permutation[64])
Definition: idctdsp.c:30
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:318
AV_PROFILE_PRORES_HQ
#define AV_PROFILE_PRORES_HQ
Definition: defs.h:184
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
finish
static void finish(void)
Definition: movenc.c:374
FFHWAccel
Definition: hwaccel_internal.h:34
ProresContext::pix_fmt
enum AVPixelFormat pix_fmt
Definition: proresdec.h:60
GetBitContext
Definition: get_bits.h:108
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:508
proresdec.h
val
static double val(void *priv, double ch)
Definition: aeval.c:77
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:528
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
decode_slice_alpha
static void decode_slice_alpha(const ProresContext *ctx, uint16_t *dst, int dst_stride, const uint8_t *buf, int buf_size, int blocks_per_slice)
Decode alpha slice plane.
Definition: proresdec.c:597
AV_PROFILE_UNKNOWN
#define AV_PROFILE_UNKNOWN
Definition: defs.h:65
CLOSE_READER
#define CLOSE_READER(name, gb)
Definition: get_bits.h:184
dc_codebook
static const uint8_t dc_codebook[7]
Definition: proresdec.c:450
unpack_alpha_12
static void unpack_alpha_12(GetBitContext *gb, uint16_t *dst, int num_coeffs, const int num_bits)
Definition: proresdec.c:123
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:341
ff_blockdsp_init
av_cold void ff_blockdsp_init(BlockDSPContext *c)
Definition: blockdsp.c:58
SliceContext::data_size
unsigned data_size
Definition: proresdec.h:39
decode_close
static av_cold int decode_close(AVCodecContext *avctx)
Definition: proresdec.c:834
AVFormatContext::flags
int flags
Flags modifying the (de)muxer behaviour.
Definition: avformat.h:1451
pix_fmt
static enum AVPixelFormat pix_fmt
Definition: demux_decode.c:41
ff_thread_get_buffer
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
Definition: pthread_frame.c:1053
SHOW_SBITS
#define SHOW_SBITS(name, gb, num)
Definition: get_bits.h:243
decode_dc_coeffs
static av_always_inline int decode_dc_coeffs(GetBitContext *gb, int16_t *out, int blocks_per_slice)
Definition: proresdec.c:452
LOCAL_ALIGNED_16
#define LOCAL_ALIGNED_16(t, v,...)
Definition: mem_internal.h:130
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:304
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:573
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1593
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
decode.h
get_bits.h
SKIP_BITS
#define SKIP_BITS(name, gb, num)
Definition: get_bits.h:224
decode_slice_thread
static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
Definition: proresdec.c:627
ff_prores_interlaced_scan
const uint8_t ff_prores_interlaced_scan[64]
Definition: proresdata.c:36
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:326
arg
const char * arg
Definition: jacosubdec.c:67
if
if(ret)
Definition: filter_design.txt:179
decode_ac_coeffs
static av_always_inline int decode_ac_coeffs(AVCodecContext *avctx, GetBitContext *gb, int16_t *out, int blocks_per_slice)
Definition: proresdec.c:483
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:110
ALPHA_SHIFT_8_TO_10
#define ALPHA_SHIFT_8_TO_10(alpha_val)
Definition: proresdec.c:48
NULL
#define NULL
Definition: coverity.c:32
FF_DECODE_ERROR_INVALID_BITSTREAM
#define FF_DECODE_ERROR_INVALID_BITSTREAM
Definition: frame.h:746
bits_left
#define bits_left
Definition: bitstream.h:114
DECODE_CODEWORD
#define DECODE_CODEWORD(val, codebook, SKIP)
Definition: proresdec.c:414
LOCAL_ALIGNED_32
#define LOCAL_ALIGNED_32(t, v,...)
Definition: mem_internal.h:132
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
run
uint8_t run
Definition: svq3.c:204
hwaccel_internal.h
SliceContext::ret
int ret
Definition: proresdec.h:40
ALPHA_SHIFT_16_TO_10
#define ALPHA_SHIFT_16_TO_10(alpha_val)
Definition: proresdec.c:47
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:371
profiles.h
SliceContext::mb_y
unsigned mb_y
Definition: proresdec.h:37
LAST_SKIP_BITS
#define LAST_SKIP_BITS(name, gb, num)
Definition: get_bits.h:230
UPDATE_THREAD_CONTEXT
#define UPDATE_THREAD_CONTEXT(func)
Definition: codec_internal.h:335
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:526
AV_PROFILE_PRORES_LT
#define AV_PROFILE_PRORES_LT
Definition: defs.h:182
lev_to_cb
static const uint8_t lev_to_cb[10]
Definition: proresdec.c:481
SliceContext
Definition: mss12.h:70
ff_dlog
#define ff_dlog(a,...)
Definition: tableprint_vlc.h:28
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
decode_slice_luma
static int decode_slice_luma(AVCodecContext *avctx, SliceContext *slice, uint16_t *dst, int dst_stride, const uint8_t *buf, unsigned buf_size, const int16_t *qmat)
Definition: proresdec.c:526
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
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
height
#define height
Definition: dsp.h:85
codec_internal.h
ff_proresdsp_init
av_cold void ff_proresdsp_init(ProresDSPContext *dsp, int bits_per_raw_sample)
Definition: proresdsp.c:124
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:530
SliceContext::mb_count
unsigned mb_count
Definition: proresdec.h:38
AV_RB32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
Definition: bytestream.h:96
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:532
proresdata.h
AVCodecContext::skip_alpha
int skip_alpha
Skip processing alpha if supported by codec.
Definition: avcodec.h:1855
AVCodecHWConfigInternal
Definition: hwconfig.h:25
OPEN_READER
#define OPEN_READER(name, gb)
Definition: get_bits.h:173
AV_PROFILE_PRORES_4444
#define AV_PROFILE_PRORES_4444
Definition: defs.h:185
AV_CODEC_CAP_SLICE_THREADS
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: codec.h:114
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:571
offset
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Definition: writing_filters.txt:86
version
version
Definition: libkvazaar.c:321
AV_PROFILE_PRORES_PROXY
#define AV_PROFILE_PRORES_PROXY
Definition: defs.h:181
AV_PIX_FMT_VIDEOTOOLBOX
@ AV_PIX_FMT_VIDEOTOOLBOX
hardware decoding through Videotoolbox
Definition: pixfmt.h:305
TOSIGNED
#define TOSIGNED(x)
Definition: proresdec.c:446
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
internal.h
SliceContext::data
const uint8_t * data
Definition: proresdec.h:35
decode_slice_chroma
static int decode_slice_chroma(AVCodecContext *avctx, SliceContext *slice, uint16_t *dst, int dst_stride, const uint8_t *buf, unsigned buf_size, const int16_t *qmat, int log2_blocks_per_mb)
Definition: proresdec.c:560
FIRST_DC_CB
#define FIRST_DC_CB
Definition: proresdec.c:448
av_always_inline
#define av_always_inline
Definition: attributes.h:49
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
AVCodecContext::height
int height
Definition: avcodec.h:632
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:671
AV_FRAME_FLAG_INTERLACED
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
Definition: frame.h:669
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:729
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:264
HWACCEL_VIDEOTOOLBOX
#define HWACCEL_VIDEOTOOLBOX(codec)
Definition: hwconfig.h:74
idctdsp.h
avcodec.h
ff_prores_decoder
const FFCodec ff_prores_decoder
Definition: proresdec.c:855
ALPHA_SHIFT_16_TO_12
#define ALPHA_SHIFT_16_TO_12(alpha_val)
Definition: proresdec.c:49
ret
ret
Definition: filter_design.txt:187
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
run_to_cb
static const uint8_t run_to_cb[16]
Definition: proresdec.c:480
hwaccel
static const char * hwaccel
Definition: ffplay.c:353
pos
unsigned int pos
Definition: spdifenc.c:414
ff_thread_finish_setup
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call ff_thread_finish_setup() afterwards. If some code can 't be moved
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
U
#define U(x)
Definition: vpx_arith.h:37
AVCodecContext
main external API structure.
Definition: avcodec.h:451
SHOW_UBITS
#define SHOW_UBITS(name, gb, num)
Definition: get_bits.h:242
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:572
AVCodecContext::profile
int profile
profile
Definition: avcodec.h:1658
ffhwaccel
static const FFHWAccel * ffhwaccel(const AVHWAccel *codec)
Definition: hwaccel_internal.h:166
update_thread_context
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have update_thread_context() run it in the next thread. Add AV_CODEC_CAP_FRAME_THREADS to the codec capabilities. There will be very little speed gain at this point but it should work. Use ff_thread_get_buffer()(or ff_progress_frame_get_buffer() in case you have inter-frame dependencies and use the ProgressFrame API) to allocate frame buffers. Call ff_progress_frame_report() after some part of the current picture has decoded. A good place to put this is where draw_horiz_band() is called - add this if it isn 't called anywhere
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
UPDATE_CACHE_32
#define UPDATE_CACHE_32(name, gb)
Definition: get_bits.h:209
mem.h
AVCodecContext::codec_tag
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition: avcodec.h:476
ALPHA_SHIFT_8_TO_12
#define ALPHA_SHIFT_8_TO_12(alpha_val)
Definition: proresdec.c:50
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
unpack_alpha
static void unpack_alpha(GetBitContext *gb, uint16_t *dst, int num_coeffs, const int num_bits, const int decode_precision)
Definition: proresdec.c:52
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:632
AV_PROFILE_PRORES_XQ
#define AV_PROFILE_PRORES_XQ
Definition: defs.h:186
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
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:455
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
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
decode_picture
static int decode_picture(AVCodecContext *avctx)
Definition: proresdec.c:745
MKTAG
#define MKTAG(a, b, c, d)
Definition: macros.h:55
width
#define width
Definition: dsp.h:85
AVCodecContext::execute2
int(* execute2)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count)
The codec may call this to execute several independent things.
Definition: avcodec.h:1650
av_log2
int av_log2(unsigned v)
Definition: intmath.c:26
src
#define src
Definition: vp8dsp.c:248
AV_CODEC_ID_PRORES
@ AV_CODEC_ID_PRORES
Definition: codec_id.h:200
AV_RB16
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
Definition: bytestream.h:98
decode_init
static av_cold int decode_init(AVCodecContext *avctx)
Definition: proresdec.c:133