FFmpeg
proresdec2.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), 'acpo' (Proxy), 'ap4h' (4444)
25  */
26 
27 //#define DEBUG
28 
29 #define LONG_BITSTREAM_READER
30 
31 #include "libavutil/internal.h"
32 #include "libavutil/mem_internal.h"
33 
34 #include "avcodec.h"
35 #include "get_bits.h"
36 #include "idctdsp.h"
37 #include "internal.h"
38 #include "profiles.h"
39 #include "simple_idct.h"
40 #include "proresdec.h"
41 #include "proresdata.h"
42 #include "thread.h"
43 
44 static void permute(uint8_t *dst, const uint8_t *src, const uint8_t permutation[64])
45 {
46  int i;
47  for (i = 0; i < 64; i++)
48  dst[i] = permutation[src[i]];
49 }
50 
51 #define ALPHA_SHIFT_16_TO_10(alpha_val) (alpha_val >> 6)
52 #define ALPHA_SHIFT_8_TO_10(alpha_val) ((alpha_val << 2) | (alpha_val >> 6))
53 #define ALPHA_SHIFT_16_TO_12(alpha_val) (alpha_val >> 4)
54 #define ALPHA_SHIFT_8_TO_12(alpha_val) ((alpha_val << 4) | (alpha_val >> 4))
55 
56 static void inline unpack_alpha(GetBitContext *gb, uint16_t *dst, int num_coeffs,
57  const int num_bits, const int decode_precision) {
58  const int mask = (1 << num_bits) - 1;
59  int i, idx, val, alpha_val;
60 
61  idx = 0;
62  alpha_val = mask;
63  do {
64  do {
65  if (get_bits1(gb)) {
66  val = get_bits(gb, num_bits);
67  } else {
68  int sign;
69  val = get_bits(gb, num_bits == 16 ? 7 : 4);
70  sign = val & 1;
71  val = (val + 2) >> 1;
72  if (sign)
73  val = -val;
74  }
75  alpha_val = (alpha_val + val) & mask;
76  if (num_bits == 16) {
77  if (decode_precision == 10) {
78  dst[idx++] = ALPHA_SHIFT_16_TO_10(alpha_val);
79  } else { /* 12b */
80  dst[idx++] = ALPHA_SHIFT_16_TO_12(alpha_val);
81  }
82  } else {
83  if (decode_precision == 10) {
84  dst[idx++] = ALPHA_SHIFT_8_TO_10(alpha_val);
85  } else { /* 12b */
86  dst[idx++] = ALPHA_SHIFT_8_TO_12(alpha_val);
87  }
88  }
89  if (idx >= num_coeffs)
90  break;
91  } while (get_bits_left(gb)>0 && get_bits1(gb));
92  val = get_bits(gb, 4);
93  if (!val)
94  val = get_bits(gb, 11);
95  if (idx + val > num_coeffs)
96  val = num_coeffs - idx;
97  if (num_bits == 16) {
98  for (i = 0; i < val; i++) {
99  if (decode_precision == 10) {
100  dst[idx++] = ALPHA_SHIFT_16_TO_10(alpha_val);
101  } else { /* 12b */
102  dst[idx++] = ALPHA_SHIFT_16_TO_12(alpha_val);
103  }
104  }
105  } else {
106  for (i = 0; i < val; i++) {
107  if (decode_precision == 10) {
108  dst[idx++] = ALPHA_SHIFT_8_TO_10(alpha_val);
109  } else { /* 12b */
110  dst[idx++] = ALPHA_SHIFT_8_TO_12(alpha_val);
111  }
112  }
113  }
114  } while (idx < num_coeffs);
115 }
116 
117 static void unpack_alpha_10(GetBitContext *gb, uint16_t *dst, int num_coeffs,
118  const int num_bits)
119 {
120  if (num_bits == 16) {
121  unpack_alpha(gb, dst, num_coeffs, 16, 10);
122  } else { /* 8 bits alpha */
123  unpack_alpha(gb, dst, num_coeffs, 8, 10);
124  }
125 }
126 
127 static void unpack_alpha_12(GetBitContext *gb, uint16_t *dst, int num_coeffs,
128  const int num_bits)
129 {
130  if (num_bits == 16) {
131  unpack_alpha(gb, dst, num_coeffs, 16, 12);
132  } else { /* 8 bits alpha */
133  unpack_alpha(gb, dst, num_coeffs, 8, 12);
134  }
135 }
136 
138 {
139  int ret = 0;
140  ProresContext *ctx = avctx->priv_data;
141  uint8_t idct_permutation[64];
142 
143  avctx->bits_per_raw_sample = 10;
144 
145  switch (avctx->codec_tag) {
146  case MKTAG('a','p','c','o'):
148  break;
149  case MKTAG('a','p','c','s'):
150  avctx->profile = FF_PROFILE_PRORES_LT;
151  break;
152  case MKTAG('a','p','c','n'):
154  break;
155  case MKTAG('a','p','c','h'):
156  avctx->profile = FF_PROFILE_PRORES_HQ;
157  break;
158  case MKTAG('a','p','4','h'):
160  avctx->bits_per_raw_sample = 12;
161  break;
162  case MKTAG('a','p','4','x'):
163  avctx->profile = FF_PROFILE_PRORES_XQ;
164  avctx->bits_per_raw_sample = 12;
165  break;
166  default:
167  avctx->profile = FF_PROFILE_UNKNOWN;
168  av_log(avctx, AV_LOG_WARNING, "Unknown prores profile %d\n", avctx->codec_tag);
169  }
170 
171  if (avctx->bits_per_raw_sample == 10) {
172  av_log(avctx, AV_LOG_DEBUG, "Auto bitdepth precision. Use 10b decoding based on codec tag.\n");
173  } else { /* 12b */
174  av_log(avctx, AV_LOG_DEBUG, "Auto bitdepth precision. Use 12b decoding based on codec tag.\n");
175  }
176 
177  ff_blockdsp_init(&ctx->bdsp, avctx);
178  ret = ff_proresdsp_init(&ctx->prodsp, avctx);
179  if (ret < 0) {
180  av_log(avctx, AV_LOG_ERROR, "Fail to init proresdsp for bits per raw sample %d\n", avctx->bits_per_raw_sample);
181  return ret;
182  }
183 
184  ff_init_scantable_permutation(idct_permutation,
185  ctx->prodsp.idct_permutation_type);
186 
187  permute(ctx->progressive_scan, ff_prores_progressive_scan, idct_permutation);
188  permute(ctx->interlaced_scan, ff_prores_interlaced_scan, idct_permutation);
189 
190  if (avctx->bits_per_raw_sample == 10){
191  ctx->unpack_alpha = unpack_alpha_10;
192  } else if (avctx->bits_per_raw_sample == 12){
193  ctx->unpack_alpha = unpack_alpha_12;
194  } else {
195  av_log(avctx, AV_LOG_ERROR, "Fail to set unpack_alpha for bits per raw sample %d\n", avctx->bits_per_raw_sample);
196  return AVERROR_BUG;
197  }
198  return ret;
199 }
200 
202  const int data_size, AVCodecContext *avctx)
203 {
204  int hdr_size, width, height, flags;
205  int version;
206  const uint8_t *ptr;
207 
208  hdr_size = AV_RB16(buf);
209  ff_dlog(avctx, "header size %d\n", hdr_size);
210  if (hdr_size > data_size) {
211  av_log(avctx, AV_LOG_ERROR, "error, wrong header size\n");
212  return AVERROR_INVALIDDATA;
213  }
214 
215  version = AV_RB16(buf + 2);
216  ff_dlog(avctx, "%.4s version %d\n", buf+4, version);
217  if (version > 1) {
218  av_log(avctx, AV_LOG_ERROR, "unsupported version: %d\n", version);
219  return AVERROR_PATCHWELCOME;
220  }
221 
222  width = AV_RB16(buf + 8);
223  height = AV_RB16(buf + 10);
224 
225  if (width != avctx->width || height != avctx->height) {
226  int ret;
227 
228  av_log(avctx, AV_LOG_WARNING, "picture resolution change: %dx%d -> %dx%d\n",
229  avctx->width, avctx->height, width, height);
230  if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
231  return ret;
232  }
233 
234  ctx->frame_type = (buf[12] >> 2) & 3;
235  ctx->alpha_info = buf[17] & 0xf;
236 
237  if (ctx->alpha_info > 2) {
238  av_log(avctx, AV_LOG_ERROR, "Invalid alpha mode %d\n", ctx->alpha_info);
239  return AVERROR_INVALIDDATA;
240  }
241  if (avctx->skip_alpha) ctx->alpha_info = 0;
242 
243  ff_dlog(avctx, "frame type %d\n", ctx->frame_type);
244 
245  if (ctx->frame_type == 0) {
246  ctx->scan = ctx->progressive_scan; // permuted
247  } else {
248  ctx->scan = ctx->interlaced_scan; // permuted
249  ctx->frame->interlaced_frame = 1;
250  ctx->frame->top_field_first = ctx->frame_type == 1;
251  }
252 
253  if (ctx->alpha_info) {
254  if (avctx->bits_per_raw_sample == 10) {
255  avctx->pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUVA444P10 : AV_PIX_FMT_YUVA422P10;
256  } else { /* 12b */
257  avctx->pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUVA444P12 : AV_PIX_FMT_YUVA422P12;
258  }
259  } else {
260  if (avctx->bits_per_raw_sample == 10) {
261  avctx->pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUV444P10 : AV_PIX_FMT_YUV422P10;
262  } else { /* 12b */
263  avctx->pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUV444P12 : AV_PIX_FMT_YUV422P12;
264  }
265  }
266 
267  avctx->color_primaries = buf[14];
268  avctx->color_trc = buf[15];
269  avctx->colorspace = buf[16];
270  avctx->color_range = AVCOL_RANGE_MPEG;
271 
272  ptr = buf + 20;
273  flags = buf[19];
274  ff_dlog(avctx, "flags %x\n", flags);
275 
276  if (flags & 2) {
277  if(buf + data_size - ptr < 64) {
278  av_log(avctx, AV_LOG_ERROR, "Header truncated\n");
279  return AVERROR_INVALIDDATA;
280  }
281  permute(ctx->qmat_luma, ctx->prodsp.idct_permutation, ptr);
282  ptr += 64;
283  } else {
284  memset(ctx->qmat_luma, 4, 64);
285  }
286 
287  if (flags & 1) {
288  if(buf + data_size - ptr < 64) {
289  av_log(avctx, AV_LOG_ERROR, "Header truncated\n");
290  return AVERROR_INVALIDDATA;
291  }
292  permute(ctx->qmat_chroma, ctx->prodsp.idct_permutation, ptr);
293  } else {
294  memcpy(ctx->qmat_chroma, ctx->qmat_luma, 64);
295  }
296 
297  return hdr_size;
298 }
299 
300 static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, const int buf_size)
301 {
302  ProresContext *ctx = avctx->priv_data;
303  int i, hdr_size, slice_count;
304  unsigned pic_data_size;
305  int log2_slice_mb_width, log2_slice_mb_height;
306  int slice_mb_count, mb_x, mb_y;
307  const uint8_t *data_ptr, *index_ptr;
308 
309  hdr_size = buf[0] >> 3;
310  if (hdr_size < 8 || hdr_size > buf_size) {
311  av_log(avctx, AV_LOG_ERROR, "error, wrong picture header size\n");
312  return AVERROR_INVALIDDATA;
313  }
314 
315  pic_data_size = AV_RB32(buf + 1);
316  if (pic_data_size > buf_size) {
317  av_log(avctx, AV_LOG_ERROR, "error, wrong picture data size\n");
318  return AVERROR_INVALIDDATA;
319  }
320 
321  log2_slice_mb_width = buf[7] >> 4;
322  log2_slice_mb_height = buf[7] & 0xF;
323  if (log2_slice_mb_width > 3 || log2_slice_mb_height) {
324  av_log(avctx, AV_LOG_ERROR, "unsupported slice resolution: %dx%d\n",
325  1 << log2_slice_mb_width, 1 << log2_slice_mb_height);
326  return AVERROR_INVALIDDATA;
327  }
328 
329  ctx->mb_width = (avctx->width + 15) >> 4;
330  if (ctx->frame_type)
331  ctx->mb_height = (avctx->height + 31) >> 5;
332  else
333  ctx->mb_height = (avctx->height + 15) >> 4;
334 
335  // QT ignores the written value
336  // slice_count = AV_RB16(buf + 5);
337  slice_count = ctx->mb_height * ((ctx->mb_width >> log2_slice_mb_width) +
338  av_popcount(ctx->mb_width & (1 << log2_slice_mb_width) - 1));
339 
340  if (ctx->slice_count != slice_count || !ctx->slices) {
341  av_freep(&ctx->slices);
342  ctx->slice_count = 0;
343  ctx->slices = av_mallocz_array(slice_count, sizeof(*ctx->slices));
344  if (!ctx->slices)
345  return AVERROR(ENOMEM);
346  ctx->slice_count = slice_count;
347  }
348 
349  if (!slice_count)
350  return AVERROR(EINVAL);
351 
352  if (hdr_size + slice_count*2 > buf_size) {
353  av_log(avctx, AV_LOG_ERROR, "error, wrong slice count\n");
354  return AVERROR_INVALIDDATA;
355  }
356 
357  // parse slice information
358  index_ptr = buf + hdr_size;
359  data_ptr = index_ptr + slice_count*2;
360 
361  slice_mb_count = 1 << log2_slice_mb_width;
362  mb_x = 0;
363  mb_y = 0;
364 
365  for (i = 0; i < slice_count; i++) {
366  SliceContext *slice = &ctx->slices[i];
367 
368  slice->data = data_ptr;
369  data_ptr += AV_RB16(index_ptr + i*2);
370 
371  while (ctx->mb_width - mb_x < slice_mb_count)
372  slice_mb_count >>= 1;
373 
374  slice->mb_x = mb_x;
375  slice->mb_y = mb_y;
376  slice->mb_count = slice_mb_count;
377  slice->data_size = data_ptr - slice->data;
378 
379  if (slice->data_size < 6) {
380  av_log(avctx, AV_LOG_ERROR, "error, wrong slice data size\n");
381  return AVERROR_INVALIDDATA;
382  }
383 
384  mb_x += slice_mb_count;
385  if (mb_x == ctx->mb_width) {
386  slice_mb_count = 1 << log2_slice_mb_width;
387  mb_x = 0;
388  mb_y++;
389  }
390  if (data_ptr > buf + buf_size) {
391  av_log(avctx, AV_LOG_ERROR, "error, slice out of bounds\n");
392  return AVERROR_INVALIDDATA;
393  }
394  }
395 
396  if (mb_x || mb_y != ctx->mb_height) {
397  av_log(avctx, AV_LOG_ERROR, "error wrong mb count y %d h %d\n",
398  mb_y, ctx->mb_height);
399  return AVERROR_INVALIDDATA;
400  }
401 
402  return pic_data_size;
403 }
404 
405 #define DECODE_CODEWORD(val, codebook, SKIP) \
406  do { \
407  unsigned int rice_order, exp_order, switch_bits; \
408  unsigned int q, buf, bits; \
409  \
410  UPDATE_CACHE(re, gb); \
411  buf = GET_CACHE(re, gb); \
412  \
413  /* number of bits to switch between rice and exp golomb */ \
414  switch_bits = codebook & 3; \
415  rice_order = codebook >> 5; \
416  exp_order = (codebook >> 2) & 7; \
417  \
418  q = 31 - av_log2(buf); \
419  \
420  if (q > switch_bits) { /* exp golomb */ \
421  bits = exp_order - switch_bits + (q<<1); \
422  if (bits > FFMIN(MIN_CACHE_BITS, 31)) \
423  return AVERROR_INVALIDDATA; \
424  val = SHOW_UBITS(re, gb, bits) - (1 << exp_order) + \
425  ((switch_bits + 1) << rice_order); \
426  SKIP(re, gb, bits); \
427  } else if (rice_order) { \
428  SKIP_BITS(re, gb, q+1); \
429  val = (q << rice_order) + SHOW_UBITS(re, gb, rice_order); \
430  SKIP(re, gb, rice_order); \
431  } else { \
432  val = q; \
433  SKIP(re, gb, q+1); \
434  } \
435  } while (0)
436 
437 #define TOSIGNED(x) (((x) >> 1) ^ (-((x) & 1)))
438 
439 #define FIRST_DC_CB 0xB8
440 
441 static const uint8_t dc_codebook[7] = { 0x04, 0x28, 0x28, 0x4D, 0x4D, 0x70, 0x70};
442 
444  int blocks_per_slice)
445 {
446  int16_t prev_dc;
447  int code, i, sign;
448 
449  OPEN_READER(re, gb);
450 
452  prev_dc = TOSIGNED(code);
453  out[0] = prev_dc;
454 
455  out += 64; // dc coeff for the next block
456 
457  code = 5;
458  sign = 0;
459  for (i = 1; i < blocks_per_slice; i++, out += 64) {
461  if(code) sign ^= -(code & 1);
462  else sign = 0;
463  prev_dc += (((code + 1) >> 1) ^ sign) - sign;
464  out[0] = prev_dc;
465  }
466  CLOSE_READER(re, gb);
467  return 0;
468 }
469 
470 // adaptive codebook switching lut according to previous run/level values
471 static const uint8_t run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29, 0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C };
472 static const uint8_t lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28, 0x28, 0x28, 0x28, 0x4C };
473 
475  int16_t *out, int blocks_per_slice)
476 {
477  ProresContext *ctx = avctx->priv_data;
478  int block_mask, sign;
479  unsigned pos, run, level;
480  int max_coeffs, i, bits_left;
481  int log2_block_count = av_log2(blocks_per_slice);
482 
483  OPEN_READER(re, gb);
484  UPDATE_CACHE(re, gb); \
485  run = 4;
486  level = 2;
487 
488  max_coeffs = 64 << log2_block_count;
489  block_mask = blocks_per_slice - 1;
490 
491  for (pos = block_mask;;) {
492  bits_left = gb->size_in_bits - re_index;
493  if (!bits_left || (bits_left < 32 && !SHOW_UBITS(re, gb, bits_left)))
494  break;
495 
497  pos += run + 1;
498  if (pos >= max_coeffs) {
499  av_log(avctx, AV_LOG_ERROR, "ac tex damaged %d, %d\n", pos, max_coeffs);
500  return AVERROR_INVALIDDATA;
501  }
502 
504  level += 1;
505 
506  i = pos >> log2_block_count;
507 
508  sign = SHOW_SBITS(re, gb, 1);
509  SKIP_BITS(re, gb, 1);
510  out[((pos & block_mask) << 6) + ctx->scan[i]] = ((level ^ sign) - sign);
511  }
512 
513  CLOSE_READER(re, gb);
514  return 0;
515 }
516 
518  uint16_t *dst, int dst_stride,
519  const uint8_t *buf, unsigned buf_size,
520  const int16_t *qmat)
521 {
522  ProresContext *ctx = avctx->priv_data;
523  LOCAL_ALIGNED_32(int16_t, blocks, [8*4*64]);
524  int16_t *block;
525  GetBitContext gb;
526  int i, blocks_per_slice = slice->mb_count<<2;
527  int ret;
528 
529  for (i = 0; i < blocks_per_slice; i++)
530  ctx->bdsp.clear_block(blocks+(i<<6));
531 
532  init_get_bits(&gb, buf, buf_size << 3);
533 
534  if ((ret = decode_dc_coeffs(&gb, blocks, blocks_per_slice)) < 0)
535  return ret;
536  if ((ret = decode_ac_coeffs(avctx, &gb, blocks, blocks_per_slice)) < 0)
537  return ret;
538 
539  block = blocks;
540  for (i = 0; i < slice->mb_count; i++) {
541  ctx->prodsp.idct_put(dst, dst_stride, block+(0<<6), qmat);
542  ctx->prodsp.idct_put(dst +8, dst_stride, block+(1<<6), qmat);
543  ctx->prodsp.idct_put(dst+4*dst_stride , dst_stride, block+(2<<6), qmat);
544  ctx->prodsp.idct_put(dst+4*dst_stride+8, dst_stride, block+(3<<6), qmat);
545  block += 4*64;
546  dst += 16;
547  }
548  return 0;
549 }
550 
552  uint16_t *dst, int dst_stride,
553  const uint8_t *buf, unsigned buf_size,
554  const int16_t *qmat, int log2_blocks_per_mb)
555 {
556  ProresContext *ctx = avctx->priv_data;
557  LOCAL_ALIGNED_32(int16_t, blocks, [8*4*64]);
558  int16_t *block;
559  GetBitContext gb;
560  int i, j, blocks_per_slice = slice->mb_count << log2_blocks_per_mb;
561  int ret;
562 
563  for (i = 0; i < blocks_per_slice; i++)
564  ctx->bdsp.clear_block(blocks+(i<<6));
565 
566  init_get_bits(&gb, buf, buf_size << 3);
567 
568  if ((ret = decode_dc_coeffs(&gb, blocks, blocks_per_slice)) < 0)
569  return ret;
570  if ((ret = decode_ac_coeffs(avctx, &gb, blocks, blocks_per_slice)) < 0)
571  return ret;
572 
573  block = blocks;
574  for (i = 0; i < slice->mb_count; i++) {
575  for (j = 0; j < log2_blocks_per_mb; j++) {
576  ctx->prodsp.idct_put(dst, dst_stride, block+(0<<6), qmat);
577  ctx->prodsp.idct_put(dst+4*dst_stride, dst_stride, block+(1<<6), qmat);
578  block += 2*64;
579  dst += 8;
580  }
581  }
582  return 0;
583 }
584 
585 /**
586  * Decode alpha slice plane.
587  */
589  uint16_t *dst, int dst_stride,
590  const uint8_t *buf, int buf_size,
591  int blocks_per_slice)
592 {
593  GetBitContext gb;
594  int i;
595  LOCAL_ALIGNED_32(int16_t, blocks, [8*4*64]);
596  int16_t *block;
597 
598  for (i = 0; i < blocks_per_slice<<2; i++)
599  ctx->bdsp.clear_block(blocks+(i<<6));
600 
601  init_get_bits(&gb, buf, buf_size << 3);
602 
603  if (ctx->alpha_info == 2) {
604  ctx->unpack_alpha(&gb, blocks, blocks_per_slice * 4 * 64, 16);
605  } else {
606  ctx->unpack_alpha(&gb, blocks, blocks_per_slice * 4 * 64, 8);
607  }
608 
609  block = blocks;
610 
611  for (i = 0; i < 16; i++) {
612  memcpy(dst, block, 16 * blocks_per_slice * sizeof(*dst));
613  dst += dst_stride >> 1;
614  block += 16 * blocks_per_slice;
615  }
616 }
617 
618 static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
619 {
620  ProresContext *ctx = avctx->priv_data;
621  SliceContext *slice = &ctx->slices[jobnr];
622  const uint8_t *buf = slice->data;
623  AVFrame *pic = ctx->frame;
624  int i, hdr_size, qscale, log2_chroma_blocks_per_mb;
625  int luma_stride, chroma_stride;
626  int y_data_size, u_data_size, v_data_size, a_data_size, offset;
627  uint8_t *dest_y, *dest_u, *dest_v;
628  LOCAL_ALIGNED_16(int16_t, qmat_luma_scaled, [64]);
629  LOCAL_ALIGNED_16(int16_t, qmat_chroma_scaled,[64]);
630  int mb_x_shift;
631  int ret;
632  uint16_t val_no_chroma;
633 
634  slice->ret = -1;
635  //av_log(avctx, AV_LOG_INFO, "slice %d mb width %d mb x %d y %d\n",
636  // jobnr, slice->mb_count, slice->mb_x, slice->mb_y);
637 
638  // slice header
639  hdr_size = buf[0] >> 3;
640  qscale = av_clip(buf[1], 1, 224);
641  qscale = qscale > 128 ? qscale - 96 << 2: qscale;
642  y_data_size = AV_RB16(buf + 2);
643  u_data_size = AV_RB16(buf + 4);
644  v_data_size = slice->data_size - y_data_size - u_data_size - hdr_size;
645  if (hdr_size > 7) v_data_size = AV_RB16(buf + 6);
646  a_data_size = slice->data_size - y_data_size - u_data_size -
647  v_data_size - hdr_size;
648 
649  if (y_data_size < 0 || u_data_size < 0 || v_data_size < 0
650  || hdr_size+y_data_size+u_data_size+v_data_size > slice->data_size){
651  av_log(avctx, AV_LOG_ERROR, "invalid plane data size\n");
652  return AVERROR_INVALIDDATA;
653  }
654 
655  buf += hdr_size;
656 
657  for (i = 0; i < 64; i++) {
658  qmat_luma_scaled [i] = ctx->qmat_luma [i] * qscale;
659  qmat_chroma_scaled[i] = ctx->qmat_chroma[i] * qscale;
660  }
661 
662  if (ctx->frame_type == 0) {
663  luma_stride = pic->linesize[0];
664  chroma_stride = pic->linesize[1];
665  } else {
666  luma_stride = pic->linesize[0] << 1;
667  chroma_stride = pic->linesize[1] << 1;
668  }
669 
670  if (avctx->pix_fmt == AV_PIX_FMT_YUV444P10 || avctx->pix_fmt == AV_PIX_FMT_YUVA444P10 ||
672  mb_x_shift = 5;
673  log2_chroma_blocks_per_mb = 2;
674  } else {
675  mb_x_shift = 4;
676  log2_chroma_blocks_per_mb = 1;
677  }
678 
679  offset = (slice->mb_y << 4) * luma_stride + (slice->mb_x << 5);
680  dest_y = pic->data[0] + offset;
681  dest_u = pic->data[1] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift);
682  dest_v = pic->data[2] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift);
683 
684  if (ctx->frame_type && ctx->first_field ^ ctx->frame->top_field_first) {
685  dest_y += pic->linesize[0];
686  dest_u += pic->linesize[1];
687  dest_v += pic->linesize[2];
688  offset += pic->linesize[3];
689  }
690 
691  ret = decode_slice_luma(avctx, slice, (uint16_t*)dest_y, luma_stride,
692  buf, y_data_size, qmat_luma_scaled);
693  if (ret < 0)
694  return ret;
695 
696  if (!(avctx->flags & AV_CODEC_FLAG_GRAY) && (u_data_size + v_data_size) > 0) {
697  ret = decode_slice_chroma(avctx, slice, (uint16_t*)dest_u, chroma_stride,
698  buf + y_data_size, u_data_size,
699  qmat_chroma_scaled, log2_chroma_blocks_per_mb);
700  if (ret < 0)
701  return ret;
702 
703  ret = decode_slice_chroma(avctx, slice, (uint16_t*)dest_v, chroma_stride,
704  buf + y_data_size + u_data_size, v_data_size,
705  qmat_chroma_scaled, log2_chroma_blocks_per_mb);
706  if (ret < 0)
707  return ret;
708  }
709  else {
710  size_t mb_max_x = slice->mb_count << (mb_x_shift - 1);
711  size_t i, j;
712  if (avctx->bits_per_raw_sample == 10) {
713  val_no_chroma = 511;
714  } else { /* 12b */
715  val_no_chroma = 511 * 4;
716  }
717  for (i = 0; i < 16; ++i)
718  for (j = 0; j < mb_max_x; ++j) {
719  *(uint16_t*)(dest_u + (i * chroma_stride) + (j << 1)) = val_no_chroma;
720  *(uint16_t*)(dest_v + (i * chroma_stride) + (j << 1)) = val_no_chroma;
721  }
722  }
723 
724  /* decode alpha plane if available */
725  if (ctx->alpha_info && pic->data[3] && a_data_size) {
726  uint8_t *dest_a = pic->data[3] + offset;
727  decode_slice_alpha(ctx, (uint16_t*)dest_a, luma_stride,
728  buf + y_data_size + u_data_size + v_data_size,
729  a_data_size, slice->mb_count);
730  }
731 
732  slice->ret = 0;
733  return 0;
734 }
735 
736 static int decode_picture(AVCodecContext *avctx)
737 {
738  ProresContext *ctx = avctx->priv_data;
739  int i;
740  int error = 0;
741 
742  avctx->execute2(avctx, decode_slice_thread, NULL, NULL, ctx->slice_count);
743 
744  for (i = 0; i < ctx->slice_count; i++)
745  error += ctx->slices[i].ret < 0;
746 
747  if (error)
748  ctx->frame->decode_error_flags = FF_DECODE_ERROR_INVALID_BITSTREAM;
749  if (error < ctx->slice_count)
750  return 0;
751 
752  return ctx->slices[0].ret;
753 }
754 
755 static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
756  AVPacket *avpkt)
757 {
758  ProresContext *ctx = avctx->priv_data;
759  ThreadFrame tframe = { .f = data };
760  AVFrame *frame = data;
761  const uint8_t *buf = avpkt->data;
762  int buf_size = avpkt->size;
763  int frame_hdr_size, pic_size, ret;
764 
765  if (buf_size < 28 || AV_RL32(buf + 4) != AV_RL32("icpf")) {
766  av_log(avctx, AV_LOG_ERROR, "invalid frame header\n");
767  return AVERROR_INVALIDDATA;
768  }
769 
770  ctx->frame = frame;
771  ctx->frame->pict_type = AV_PICTURE_TYPE_I;
772  ctx->frame->key_frame = 1;
773  ctx->first_field = 1;
774 
775  buf += 8;
776  buf_size -= 8;
777 
778  frame_hdr_size = decode_frame_header(ctx, buf, buf_size, avctx);
779  if (frame_hdr_size < 0)
780  return frame_hdr_size;
781 
782  buf += frame_hdr_size;
783  buf_size -= frame_hdr_size;
784 
786  pic_size = decode_picture_header(avctx, buf, buf_size);
787  if (pic_size < 0) {
788  av_log(avctx, AV_LOG_ERROR, "error decoding picture header\n");
789  return pic_size;
790  }
791 
792  if (ctx->first_field)
793  if ((ret = ff_thread_get_buffer(avctx, &tframe, 0)) < 0)
794  return ret;
795 
796  if ((ret = decode_picture(avctx)) < 0) {
797  av_log(avctx, AV_LOG_ERROR, "error decoding picture\n");
798  return ret;
799  }
800 
801  buf += pic_size;
802  buf_size -= pic_size;
803 
804  if (ctx->frame_type && buf_size > 0 && ctx->first_field) {
805  ctx->first_field = 0;
806  goto decode_picture;
807  }
808 
809  *got_frame = 1;
810 
811  return avpkt->size;
812 }
813 
815 {
816  ProresContext *ctx = avctx->priv_data;
817 
818  av_freep(&ctx->slices);
819 
820  return 0;
821 }
822 
824  .name = "prores",
825  .long_name = NULL_IF_CONFIG_SMALL("Apple ProRes (iCodec Pro)"),
826  .type = AVMEDIA_TYPE_VIDEO,
827  .id = AV_CODEC_ID_PRORES,
828  .priv_data_size = sizeof(ProresContext),
829  .init = decode_init,
830  .close = decode_close,
831  .decode = decode_frame,
834 };
error
static void error(const char *err)
Definition: target_bsf_fuzzer.c:30
AVCodec
AVCodec.
Definition: codec.h:197
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:200
DECODE_CODEWORD
#define DECODE_CODEWORD(val, codebook, SKIP)
Definition: proresdec2.c:405
FF_PROFILE_PRORES_XQ
#define FF_PROFILE_PRORES_XQ
Definition: avcodec.h:1971
level
uint8_t level
Definition: svq3.c:206
av_clip
#define av_clip
Definition: common.h:122
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:849
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
AVCodecContext::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:1164
mem_internal.h
out
FILE * out
Definition: movenc.c:54
ff_prores_profiles
const AVProfile ff_prores_profiles[]
Definition: profiles.c:159
MKTAG
#define MKTAG(a, b, c, d)
Definition: common.h:478
ff_proresdsp_init
av_cold int ff_proresdsp_init(ProresDSPContext *dsp, AVCodecContext *avctx)
Definition: proresdsp.c:79
GetBitContext::size_in_bits
int size_in_bits
Definition: get_bits.h:68
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
AVCodecContext::color_trc
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:1157
internal.h
AVPacket::data
uint8_t * data
Definition: packet.h:369
data
const char data[16]
Definition: mxf.c:142
ProresContext
Definition: proresdec.h:38
TOSIGNED
#define TOSIGNED(x)
Definition: proresdec2.c:437
SliceContext::mb_x
unsigned mb_x
Definition: proresdec.h:31
av_mallocz_array
void * av_mallocz_array(size_t nmemb, size_t size)
Definition: mem.c:190
UPDATE_CACHE
#define UPDATE_CACHE(name, gb)
Definition: get_bits.h:178
av_popcount
#define av_popcount
Definition: common.h:176
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:437
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:659
thread.h
ThreadFrame::f
AVFrame * f
Definition: thread.h:35
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:332
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:379
U
#define U(x)
Definition: vp56_arith.h:37
GetBitContext
Definition: get_bits.h:61
ff_thread_get_buffer
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 so the codec calls ff_thread_report set FF_CODEC_CAP_ALLOCATE_PROGRESS in AVCodec caps_internal and use ff_thread_get_buffer() to allocate frames. The frames must then be freed with ff_thread_release_buffer(). Otherwise decode directly into the user-supplied frames. Call ff_thread_report_progress() 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
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:616
proresdec.h
val
static double val(void *priv, double ch)
Definition: aeval.c:76
FF_PROFILE_PRORES_LT
#define FF_PROFILE_PRORES_LT
Definition: avcodec.h:1967
ALPHA_SHIFT_8_TO_10
#define ALPHA_SHIFT_8_TO_10(alpha_val)
Definition: proresdec2.c:52
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:402
unpack_alpha
static void unpack_alpha(GetBitContext *gb, uint16_t *dst, int num_coeffs, const int num_bits, const int decode_precision)
Definition: proresdec2.c:56
AVCodecContext::color_primaries
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:1150
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
av_cold
#define av_cold
Definition: attributes.h:90
FIRST_DC_CB
#define FIRST_DC_CB
Definition: proresdec2.c:439
mask
static const uint16_t mask[17]
Definition: lzw.c:38
CLOSE_READER
#define CLOSE_READER(name, gb)
Definition: get_bits.h:149
decode
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:71
decode_picture_header
static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, const int buf_size)
Definition: proresdec2.c:300
width
#define width
SliceContext::data_size
unsigned data_size
Definition: proresdec.h:34
decode_picture
static int decode_picture(AVCodecContext *avctx)
Definition: proresdec2.c:736
SHOW_SBITS
#define SHOW_SBITS(name, gb, num)
Definition: get_bits.h:212
permute
static void permute(uint8_t *dst, const uint8_t *src, const uint8_t permutation[64])
Definition: proresdec2.c:44
LOCAL_ALIGNED_16
#define LOCAL_ALIGNED_16(t, v,...)
Definition: mem_internal.h:130
FF_PROFILE_UNKNOWN
#define FF_PROFILE_UNKNOWN
Definition: avcodec.h:1859
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:440
AVCodecContext::bits_per_raw_sample
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:1747
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:215
ctx
AVFormatContext * ctx
Definition: movenc.c:48
get_bits.h
simple_idct.h
SKIP_BITS
#define SKIP_BITS(name, gb, num)
Definition: get_bits.h:193
ff_prores_interlaced_scan
const uint8_t ff_prores_interlaced_scan[64]
Definition: proresdata.c:36
arg
const char * arg
Definition: jacosubdec.c:66
if
if(ret)
Definition: filter_design.txt:179
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:108
NULL
#define NULL
Definition: coverity.c:32
FF_DECODE_ERROR_INVALID_BITSTREAM
#define FF_DECODE_ERROR_INVALID_BITSTREAM
Definition: frame.h:614
LOCAL_ALIGNED_32
#define LOCAL_ALIGNED_32(t, v,...)
Definition: mem_internal.h:136
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
run
uint8_t run
Definition: svq3.c:205
AVCodecContext::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:1171
decode_ac_coeffs
static av_always_inline int decode_ac_coeffs(AVCodecContext *avctx, GetBitContext *gb, int16_t *out, int blocks_per_slice)
Definition: proresdec2.c:474
SliceContext::ret
int ret
Definition: proresdec.h:35
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:498
run_to_cb
static const uint8_t run_to_cb[16]
Definition: proresdec2.c:471
profiles.h
src
#define src
Definition: vp8dsp.c:255
SliceContext::mb_y
unsigned mb_y
Definition: proresdec.h:32
LAST_SKIP_BITS
#define LAST_SKIP_BITS(name, gb, num)
Definition: get_bits.h:199
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:400
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: proresdec2.c:551
SliceContext
Definition: mss12.h:70
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: proresdec2.c:517
dc_codebook
static const uint8_t dc_codebook[7]
Definition: proresdec2.c:441
ff_dlog
#define ff_dlog(a,...)
Definition: tableprint_vlc.h:29
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
AV_CODEC_FLAG_GRAY
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
Definition: avcodec.h:308
AVPacket::size
int size
Definition: packet.h:370
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
FF_PROFILE_PRORES_HQ
#define FF_PROFILE_PRORES_HQ
Definition: avcodec.h:1969
FF_PROFILE_PRORES_STANDARD
#define FF_PROFILE_PRORES_STANDARD
Definition: avcodec.h:1968
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:404
SliceContext::mb_count
unsigned mb_count
Definition: proresdec.h:33
ALPHA_SHIFT_16_TO_12
#define ALPHA_SHIFT_16_TO_12(alpha_val)
Definition: proresdec2.c:53
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:406
proresdata.h
ALPHA_SHIFT_8_TO_12
#define ALPHA_SHIFT_8_TO_12(alpha_val)
Definition: proresdec2.c:54
AVCodecContext::skip_alpha
int skip_alpha
Skip processing alpha if supported by codec.
Definition: avcodec.h:2135
decode_close
static av_cold int decode_close(AVCodecContext *avctx)
Definition: proresdec2.c:814
decode_frame_header
static int decode_frame_header(ProresContext *ctx, const uint8_t *buf, const int data_size, AVCodecContext *avctx)
Definition: proresdec2.c:201
OPEN_READER
#define OPEN_READER(name, gb)
Definition: get_bits.h:138
height
#define height
FFMIN
#define FFMIN(a, b)
Definition: common.h:105
AV_CODEC_CAP_SLICE_THREADS
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: codec.h:112
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:438
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:326
ff_init_scantable_permutation
av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation, enum idct_permutation_type perm_type)
Definition: idctdsp.c:50
decode_slice_alpha
static void decode_slice_alpha(ProresContext *ctx, uint16_t *dst, int dst_stride, const uint8_t *buf, int buf_size, int blocks_per_slice)
Decode alpha slice plane.
Definition: proresdec2.c:588
i
int i
Definition: input.c:407
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:30
av_always_inline
#define av_always_inline
Definition: attributes.h:49
uint8_t
uint8_t
Definition: audio_convert.c:194
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:204
AVCodecContext::height
int height
Definition: avcodec.h:709
lev_to_cb
static const uint8_t lev_to_cb[10]
Definition: proresdec2.c:472
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:746
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:569
idctdsp.h
avcodec.h
ret
ret
Definition: filter_design.txt:187
ff_prores_decoder
AVCodec ff_prores_decoder
Definition: proresdec2.c:823
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
FF_PROFILE_PRORES_4444
#define FF_PROFILE_PRORES_4444
Definition: avcodec.h:1970
FF_PROFILE_PRORES_PROXY
#define FF_PROFILE_PRORES_PROXY
Definition: avcodec.h:1966
unpack_alpha_10
static void unpack_alpha_10(GetBitContext *gb, uint16_t *dst, int num_coeffs, const int num_bits)
Definition: proresdec2.c:117
pos
unsigned int pos
Definition: spdifenc.c:412
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
AVCodecContext
main external API structure.
Definition: avcodec.h:536
ALPHA_SHIFT_16_TO_10
#define ALPHA_SHIFT_16_TO_10(alpha_val)
Definition: proresdec2.c:51
decode_frame
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: proresdec2.c:755
ThreadFrame
Definition: thread.h:34
SHOW_UBITS
#define SHOW_UBITS(name, gb, num)
Definition: get_bits.h:211
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:439
AVCodecContext::profile
int profile
profile
Definition: avcodec.h:1858
decode_dc_coeffs
static av_always_inline int decode_dc_coeffs(GetBitContext *gb, int16_t *out, int blocks_per_slice)
Definition: proresdec2.c:443
profiles
static const AVProfile profiles[]
Definition: libfdk-aacenc.c:428
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
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:84
decode_slice_thread
static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
Definition: proresdec2.c:618
decode_init
static av_cold int decode_init(AVCodecContext *avctx)
Definition: proresdec2.c:137
AVCodecContext::codec_tag
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition: avcodec.h:561
AVPacket
This structure stores compressed data.
Definition: packet.h:346
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:563
unpack_alpha_12
static void unpack_alpha_12(GetBitContext *gb, uint16_t *dst, int num_coeffs, const int num_bits)
Definition: proresdec2.c:127
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:709
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:50
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:349
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:28
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
ff_blockdsp_init
av_cold void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx)
Definition: blockdsp.c:60
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:1844
av_log2
int av_log2(unsigned v)
Definition: intmath.c:26
AV_CODEC_ID_PRORES
@ AV_CODEC_ID_PRORES
Definition: codec_id.h:197
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
re
float re
Definition: fft.c:82