FFmpeg
av1dec.c
Go to the documentation of this file.
1 /*
2  * AV1 video decoder
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "config_components.h"
22 
26 #include "libavutil/pixdesc.h"
27 #include "libavutil/opt.h"
28 #include "avcodec.h"
29 #include "av1dec.h"
30 #include "atsc_a53.h"
31 #include "bytestream.h"
32 #include "codec_internal.h"
33 #include "decode.h"
34 #include "hwconfig.h"
35 #include "profiles.h"
36 #include "thread.h"
37 
38 /**< same with Div_Lut defined in spec 7.11.3.7 */
39 static const uint16_t div_lut[AV1_DIV_LUT_NUM] = {
40  16384, 16320, 16257, 16194, 16132, 16070, 16009, 15948, 15888, 15828, 15768,
41  15709, 15650, 15592, 15534, 15477, 15420, 15364, 15308, 15252, 15197, 15142,
42  15087, 15033, 14980, 14926, 14873, 14821, 14769, 14717, 14665, 14614, 14564,
43  14513, 14463, 14413, 14364, 14315, 14266, 14218, 14170, 14122, 14075, 14028,
44  13981, 13935, 13888, 13843, 13797, 13752, 13707, 13662, 13618, 13574, 13530,
45  13487, 13443, 13400, 13358, 13315, 13273, 13231, 13190, 13148, 13107, 13066,
46  13026, 12985, 12945, 12906, 12866, 12827, 12788, 12749, 12710, 12672, 12633,
47  12596, 12558, 12520, 12483, 12446, 12409, 12373, 12336, 12300, 12264, 12228,
48  12193, 12157, 12122, 12087, 12053, 12018, 11984, 11950, 11916, 11882, 11848,
49  11815, 11782, 11749, 11716, 11683, 11651, 11619, 11586, 11555, 11523, 11491,
50  11460, 11429, 11398, 11367, 11336, 11305, 11275, 11245, 11215, 11185, 11155,
51  11125, 11096, 11067, 11038, 11009, 10980, 10951, 10923, 10894, 10866, 10838,
52  10810, 10782, 10755, 10727, 10700, 10673, 10645, 10618, 10592, 10565, 10538,
53  10512, 10486, 10460, 10434, 10408, 10382, 10356, 10331, 10305, 10280, 10255,
54  10230, 10205, 10180, 10156, 10131, 10107, 10082, 10058, 10034, 10010, 9986,
55  9963, 9939, 9916, 9892, 9869, 9846, 9823, 9800, 9777, 9754, 9732,
56  9709, 9687, 9664, 9642, 9620, 9598, 9576, 9554, 9533, 9511, 9489,
57  9468, 9447, 9425, 9404, 9383, 9362, 9341, 9321, 9300, 9279, 9259,
58  9239, 9218, 9198, 9178, 9158, 9138, 9118, 9098, 9079, 9059, 9039,
59  9020, 9001, 8981, 8962, 8943, 8924, 8905, 8886, 8867, 8849, 8830,
60  8812, 8793, 8775, 8756, 8738, 8720, 8702, 8684, 8666, 8648, 8630,
61  8613, 8595, 8577, 8560, 8542, 8525, 8508, 8490, 8473, 8456, 8439,
62  8422, 8405, 8389, 8372, 8355, 8339, 8322, 8306, 8289, 8273, 8257,
63  8240, 8224, 8208, 8192
64 };
65 
66 static uint32_t inverse_recenter(int r, uint32_t v)
67 {
68  if (v > 2 * r)
69  return v;
70  else if (v & 1)
71  return r - ((v + 1) >> 1);
72  else
73  return r + (v >> 1);
74 }
75 
76 static uint32_t decode_unsigned_subexp_with_ref(uint32_t sub_exp,
77  int mx, int r)
78 {
79  if ((r << 1) <= mx) {
80  return inverse_recenter(r, sub_exp);
81  } else {
82  return mx - 1 - inverse_recenter(mx - 1 - r, sub_exp);
83  }
84 }
85 
86 static int32_t decode_signed_subexp_with_ref(uint32_t sub_exp, int low,
87  int high, int r)
88 {
89  int32_t x = decode_unsigned_subexp_with_ref(sub_exp, high - low, r - low);
90  return x + low;
91 }
92 
93 static void read_global_param(AV1DecContext *s, int type, int ref, int idx)
94 {
95  uint8_t primary_frame, prev_frame;
96  uint32_t abs_bits, prec_bits, round, prec_diff, sub, mx;
97  int32_t r, prev_gm_param;
98 
99  primary_frame = s->raw_frame_header->primary_ref_frame;
100  prev_frame = s->raw_frame_header->ref_frame_idx[primary_frame];
101  abs_bits = AV1_GM_ABS_ALPHA_BITS;
102  prec_bits = AV1_GM_ALPHA_PREC_BITS;
103 
104  /* setup_past_independence() sets PrevGmParams to default values. We can
105  * simply point to the current's frame gm_params as they will be initialized
106  * with defaults at this point.
107  */
108  if (s->raw_frame_header->primary_ref_frame == AV1_PRIMARY_REF_NONE)
109  prev_gm_param = s->cur_frame.gm_params[ref][idx];
110  else
111  prev_gm_param = s->ref[prev_frame].gm_params[ref][idx];
112 
113  if (idx < 2) {
115  abs_bits = AV1_GM_ABS_TRANS_ONLY_BITS -
116  !s->raw_frame_header->allow_high_precision_mv;
117  prec_bits = AV1_GM_TRANS_ONLY_PREC_BITS -
118  !s->raw_frame_header->allow_high_precision_mv;
119  } else {
120  abs_bits = AV1_GM_ABS_TRANS_BITS;
121  prec_bits = AV1_GM_TRANS_PREC_BITS;
122  }
123  }
124  round = (idx % 3) == 2 ? (1 << AV1_WARPEDMODEL_PREC_BITS) : 0;
125  prec_diff = AV1_WARPEDMODEL_PREC_BITS - prec_bits;
126  sub = (idx % 3) == 2 ? (1 << prec_bits) : 0;
127  mx = 1 << abs_bits;
128  r = (prev_gm_param >> prec_diff) - sub;
129 
130  s->cur_frame.gm_params[ref][idx] =
131  (decode_signed_subexp_with_ref(s->raw_frame_header->gm_params[ref][idx],
132  -mx, mx + 1, r) << prec_diff) + round;
133 }
134 
135 static uint64_t round_two(uint64_t x, uint16_t n)
136 {
137  if (n == 0)
138  return x;
139  return ((x + ((uint64_t)1 << (n - 1))) >> n);
140 }
141 
142 static int64_t round_two_signed(int64_t x, uint16_t n)
143 {
144  return ((x<0) ? -((int64_t)round_two(-x, n)) : (int64_t)round_two(x, n));
145 }
146 
147 /**
148  * Resolve divisor process.
149  * see spec 7.11.3.7
150  */
151 static int16_t resolve_divisor(uint32_t d, uint16_t *shift)
152 {
153  int32_t e, f;
154 
155  *shift = av_log2(d);
156  e = d - (1 << (*shift));
157  if (*shift > AV1_DIV_LUT_BITS)
159  else
160  f = e << (AV1_DIV_LUT_BITS - (*shift));
161 
163 
164  return div_lut[f];
165 }
166 
167 /**
168  * check if global motion params is valid.
169  * see spec 7.11.3.6
170  */
171 static uint8_t get_shear_params_valid(AV1DecContext *s, int idx)
172 {
173  int16_t alpha, beta, gamma, delta, divf, divs;
174  int64_t v, w;
175  int32_t *param = &s->cur_frame.gm_params[idx][0];
176  if (param[2] < 0)
177  return 0;
178 
179  alpha = av_clip_int16(param[2] - (1 << AV1_WARPEDMODEL_PREC_BITS));
180  beta = av_clip_int16(param[3]);
181  divf = resolve_divisor(abs(param[2]), &divs);
182  v = (int64_t)param[4] * (1 << AV1_WARPEDMODEL_PREC_BITS);
183  w = (int64_t)param[3] * param[4];
184  gamma = av_clip_int16((int)round_two_signed((v * divf), divs));
185  delta = av_clip_int16(param[5] - (int)round_two_signed((w * divf), divs) - (1 << AV1_WARPEDMODEL_PREC_BITS));
186 
191 
192  if ((4 * abs(alpha) + 7 * abs(beta)) >= (1 << AV1_WARPEDMODEL_PREC_BITS) ||
193  (4 * abs(gamma) + 4 * abs(delta)) >= (1 << AV1_WARPEDMODEL_PREC_BITS))
194  return 0;
195 
196  return 1;
197 }
198 
199 /**
200 * update gm type/params, since cbs already implemented part of this function,
201 * so we don't need to full implement spec.
202 */
204 {
205  const AV1RawFrameHeader *header = s->raw_frame_header;
206  int type, ref;
207 
209  s->cur_frame.gm_type[ref] = AV1_WARP_MODEL_IDENTITY;
210  for (int i = 0; i < 6; i++)
211  s->cur_frame.gm_params[ref][i] = (i % 3 == 2) ?
212  1 << AV1_WARPEDMODEL_PREC_BITS : 0;
213  }
214  if (header->frame_type == AV1_FRAME_KEY ||
215  header->frame_type == AV1_FRAME_INTRA_ONLY)
216  return;
217 
219  if (header->is_global[ref]) {
220  if (header->is_rot_zoom[ref]) {
222  } else {
223  type = header->is_translation[ref] ? AV1_WARP_MODEL_TRANSLATION
225  }
226  } else {
228  }
229  s->cur_frame.gm_type[ref] = type;
230 
231  if (type >= AV1_WARP_MODEL_ROTZOOM) {
232  read_global_param(s, type, ref, 2);
233  read_global_param(s, type, ref, 3);
234  if (type == AV1_WARP_MODEL_AFFINE) {
235  read_global_param(s, type, ref, 4);
236  read_global_param(s, type, ref, 5);
237  } else {
238  s->cur_frame.gm_params[ref][4] = -s->cur_frame.gm_params[ref][3];
239  s->cur_frame.gm_params[ref][5] = s->cur_frame.gm_params[ref][2];
240  }
241  }
243  read_global_param(s, type, ref, 0);
244  read_global_param(s, type, ref, 1);
245  }
246  if (type <= AV1_WARP_MODEL_AFFINE) {
247  s->cur_frame.gm_invalid[ref] = !get_shear_params_valid(s, ref);
248  }
249  }
250 }
251 
253  unsigned int a, unsigned int b)
254 {
255  unsigned int diff = a - b;
256  unsigned int m = 1 << seq->order_hint_bits_minus_1;
257  return (diff & (m - 1)) - (diff & m);
258 }
259 
261 {
262  const AV1RawFrameHeader *header = s->raw_frame_header;
263  const AV1RawSequenceHeader *seq = s->raw_seq;
264 
265  int forward_idx, backward_idx;
266  int forward_hint, backward_hint;
267  int second_forward_idx, second_forward_hint;
268  int ref_hint, dist, i;
269 
270  if (!header->skip_mode_present)
271  return;
272 
273  forward_idx = -1;
274  backward_idx = -1;
275  for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
276  ref_hint = s->ref[header->ref_frame_idx[i]].raw_frame_header->order_hint;
277  dist = get_relative_dist(seq, ref_hint, header->order_hint);
278  if (dist < 0) {
279  if (forward_idx < 0 ||
280  get_relative_dist(seq, ref_hint, forward_hint) > 0) {
281  forward_idx = i;
282  forward_hint = ref_hint;
283  }
284  } else if (dist > 0) {
285  if (backward_idx < 0 ||
286  get_relative_dist(seq, ref_hint, backward_hint) < 0) {
287  backward_idx = i;
288  backward_hint = ref_hint;
289  }
290  }
291  }
292 
293  if (forward_idx < 0) {
294  return;
295  } else if (backward_idx >= 0) {
296  s->cur_frame.skip_mode_frame_idx[0] =
297  AV1_REF_FRAME_LAST + FFMIN(forward_idx, backward_idx);
298  s->cur_frame.skip_mode_frame_idx[1] =
299  AV1_REF_FRAME_LAST + FFMAX(forward_idx, backward_idx);
300  return;
301  }
302 
303  second_forward_idx = -1;
304  for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
305  ref_hint = s->ref[header->ref_frame_idx[i]].raw_frame_header->order_hint;
306  if (get_relative_dist(seq, ref_hint, forward_hint) < 0) {
307  if (second_forward_idx < 0 ||
308  get_relative_dist(seq, ref_hint, second_forward_hint) > 0) {
309  second_forward_idx = i;
310  second_forward_hint = ref_hint;
311  }
312  }
313  }
314 
315  if (second_forward_idx < 0)
316  return;
317 
318  s->cur_frame.skip_mode_frame_idx[0] =
319  AV1_REF_FRAME_LAST + FFMIN(forward_idx, second_forward_idx);
320  s->cur_frame.skip_mode_frame_idx[1] =
321  AV1_REF_FRAME_LAST + FFMAX(forward_idx, second_forward_idx);
322 }
323 
325 {
326  const AV1RawFrameHeader *header = s->raw_frame_header;
327  int i;
328 
329  if (header->delta_q_y_dc || header->delta_q_u_ac ||
330  header->delta_q_u_dc || header->delta_q_v_ac ||
331  header->delta_q_v_dc) {
332  s->cur_frame.coded_lossless = 0;
333  return;
334  }
335 
336  s->cur_frame.coded_lossless = 1;
337  for (i = 0; i < AV1_MAX_SEGMENTS; i++) {
338  int qindex;
339  if (header->feature_enabled[i][AV1_SEG_LVL_ALT_Q]) {
340  qindex = (header->base_q_idx +
341  header->feature_value[i][AV1_SEG_LVL_ALT_Q]);
342  } else {
343  qindex = header->base_q_idx;
344  }
345  qindex = av_clip_uintp2(qindex, 8);
346 
347  if (qindex) {
348  s->cur_frame.coded_lossless = 0;
349  return;
350  }
351  }
352 }
353 
355 {
356  const AV1RawFrameHeader *header = s->raw_frame_header;
357  const AV1RawFilmGrainParams *film_grain = &header->film_grain, *src;
358  AV1RawFilmGrainParams *dst = &s->cur_frame.film_grain;
359 
360  if (!film_grain->apply_grain)
361  return;
362 
363  if (film_grain->update_grain) {
364  memcpy(dst, film_grain, sizeof(*dst));
365  return;
366  }
367 
368  src = &s->ref[film_grain->film_grain_params_ref_idx].film_grain;
369 
370  memcpy(dst, src, sizeof(*dst));
371  dst->grain_seed = film_grain->grain_seed;
372 }
373 
375 
376 {
377  int cur_tile_num =
378  s->raw_frame_header->tile_cols * s->raw_frame_header->tile_rows;
379  if (s->tile_num < cur_tile_num) {
380  int ret = av_reallocp_array(&s->tile_group_info, cur_tile_num,
381  sizeof(TileGroupInfo));
382  if (ret < 0) {
383  s->tile_num = 0;
384  return ret;
385  }
386  }
387  s->tile_num = cur_tile_num;
388 
389  return 0;
390 }
391 
392 static int get_tiles_info(AVCodecContext *avctx, const AV1RawTileGroup *tile_group)
393 {
394  AV1DecContext *s = avctx->priv_data;
395  GetByteContext gb;
396  uint16_t tile_num, tile_row, tile_col;
397  uint32_t size = 0, size_bytes = 0;
398 
399  bytestream2_init(&gb, tile_group->tile_data.data,
400  tile_group->tile_data.data_size);
401  s->tg_start = tile_group->tg_start;
402  s->tg_end = tile_group->tg_end;
403 
404  for (tile_num = tile_group->tg_start; tile_num <= tile_group->tg_end; tile_num++) {
405  tile_row = tile_num / s->raw_frame_header->tile_cols;
406  tile_col = tile_num % s->raw_frame_header->tile_cols;
407 
408  if (tile_num == tile_group->tg_end) {
409  s->tile_group_info[tile_num].tile_size = bytestream2_get_bytes_left(&gb);
410  s->tile_group_info[tile_num].tile_offset = bytestream2_tell(&gb);
411  s->tile_group_info[tile_num].tile_row = tile_row;
412  s->tile_group_info[tile_num].tile_column = tile_col;
413  return 0;
414  }
415  size_bytes = s->raw_frame_header->tile_size_bytes_minus1 + 1;
416  if (bytestream2_get_bytes_left(&gb) < size_bytes)
417  return AVERROR_INVALIDDATA;
418  size = 0;
419  for (int i = 0; i < size_bytes; i++)
420  size |= bytestream2_get_byteu(&gb) << 8 * i;
421  if (bytestream2_get_bytes_left(&gb) <= size)
422  return AVERROR_INVALIDDATA;
423  size++;
424 
425  s->tile_group_info[tile_num].tile_size = size;
426  s->tile_group_info[tile_num].tile_offset = bytestream2_tell(&gb);
427  s->tile_group_info[tile_num].tile_row = tile_row;
428  s->tile_group_info[tile_num].tile_column = tile_col;
429 
430  bytestream2_skipu(&gb, size);
431  }
432 
433  return 0;
434 
435 }
436 
438 {
439  AV1DecContext *s = avctx->priv_data;
440  const AV1RawSequenceHeader *seq = s->raw_seq;
441  uint8_t bit_depth;
442  int ret;
444 #define HWACCEL_MAX (CONFIG_AV1_DXVA2_HWACCEL + \
445  CONFIG_AV1_D3D11VA_HWACCEL * 2 + \
446  CONFIG_AV1_NVDEC_HWACCEL + \
447  CONFIG_AV1_VAAPI_HWACCEL + \
448  CONFIG_AV1_VDPAU_HWACCEL)
449  enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts;
450 
451  if (seq->seq_profile == 2 && seq->color_config.high_bitdepth)
452  bit_depth = seq->color_config.twelve_bit ? 12 : 10;
453  else if (seq->seq_profile <= 2)
454  bit_depth = seq->color_config.high_bitdepth ? 10 : 8;
455  else {
456  av_log(avctx, AV_LOG_ERROR,
457  "Unknown AV1 profile %d.\n", seq->seq_profile);
458  return -1;
459  }
460 
461  if (!seq->color_config.mono_chrome) {
462  // 4:4:4 x:0 y:0, 4:2:2 x:1 y:0, 4:2:0 x:1 y:1
463  if (seq->color_config.subsampling_x == 0 &&
464  seq->color_config.subsampling_y == 0) {
465  if (bit_depth == 8)
467  else if (bit_depth == 10)
469  else if (bit_depth == 12)
471  else
472  av_log(avctx, AV_LOG_WARNING, "Unknown AV1 pixel format.\n");
473  } else if (seq->color_config.subsampling_x == 1 &&
474  seq->color_config.subsampling_y == 0) {
475  if (bit_depth == 8)
477  else if (bit_depth == 10)
479  else if (bit_depth == 12)
481  else
482  av_log(avctx, AV_LOG_WARNING, "Unknown AV1 pixel format.\n");
483  } else if (seq->color_config.subsampling_x == 1 &&
484  seq->color_config.subsampling_y == 1) {
485  if (bit_depth == 8)
487  else if (bit_depth == 10)
489  else if (bit_depth == 12)
491  else
492  av_log(avctx, AV_LOG_WARNING, "Unknown AV1 pixel format.\n");
493  }
494  } else {
495  if (bit_depth == 8)
497  else if (bit_depth == 10)
499  else if (bit_depth == 12)
501  else
502  av_log(avctx, AV_LOG_WARNING, "Unknown AV1 pixel format.\n");
503  }
504 
505  av_log(avctx, AV_LOG_DEBUG, "AV1 decode get format: %s.\n",
507 
508  if (pix_fmt == AV_PIX_FMT_NONE)
509  return -1;
510 
511  switch (pix_fmt) {
512  case AV_PIX_FMT_YUV420P:
513 #if CONFIG_AV1_DXVA2_HWACCEL
514  *fmtp++ = AV_PIX_FMT_DXVA2_VLD;
515 #endif
516 #if CONFIG_AV1_D3D11VA_HWACCEL
517  *fmtp++ = AV_PIX_FMT_D3D11VA_VLD;
518  *fmtp++ = AV_PIX_FMT_D3D11;
519 #endif
520 #if CONFIG_AV1_NVDEC_HWACCEL
521  *fmtp++ = AV_PIX_FMT_CUDA;
522 #endif
523 #if CONFIG_AV1_VAAPI_HWACCEL
524  *fmtp++ = AV_PIX_FMT_VAAPI;
525 #endif
526 #if CONFIG_AV1_VDPAU_HWACCEL
527  *fmtp++ = AV_PIX_FMT_VDPAU;
528 #endif
529  break;
531 #if CONFIG_AV1_DXVA2_HWACCEL
532  *fmtp++ = AV_PIX_FMT_DXVA2_VLD;
533 #endif
534 #if CONFIG_AV1_D3D11VA_HWACCEL
535  *fmtp++ = AV_PIX_FMT_D3D11VA_VLD;
536  *fmtp++ = AV_PIX_FMT_D3D11;
537 #endif
538 #if CONFIG_AV1_NVDEC_HWACCEL
539  *fmtp++ = AV_PIX_FMT_CUDA;
540 #endif
541 #if CONFIG_AV1_VAAPI_HWACCEL
542  *fmtp++ = AV_PIX_FMT_VAAPI;
543 #endif
544 #if CONFIG_AV1_VDPAU_HWACCEL
545  *fmtp++ = AV_PIX_FMT_VDPAU;
546 #endif
547  break;
548  case AV_PIX_FMT_GRAY8:
549 #if CONFIG_AV1_NVDEC_HWACCEL
550  *fmtp++ = AV_PIX_FMT_CUDA;
551 #endif
552  break;
553  case AV_PIX_FMT_GRAY10:
554 #if CONFIG_AV1_NVDEC_HWACCEL
555  *fmtp++ = AV_PIX_FMT_CUDA;
556 #endif
557  break;
558  }
559 
560  *fmtp++ = pix_fmt;
561  *fmtp = AV_PIX_FMT_NONE;
562 
564  if (ret < 0)
565  return ret;
566 
567  /**
568  * check if the HW accel is inited correctly. If not, return un-implemented.
569  * Since now the av1 decoder doesn't support native decode, if it will be
570  * implemented in the future, need remove this check.
571  */
572  if (!avctx->hwaccel) {
573  av_log(avctx, AV_LOG_ERROR, "Your platform doesn't support"
574  " hardware accelerated AV1 decoding.\n");
575  return AVERROR(ENOSYS);
576  }
577 
578  s->pix_fmt = pix_fmt;
579  avctx->pix_fmt = ret;
580 
581  return 0;
582 }
583 
585 {
586  ff_thread_release_buffer(avctx, f->f);
587  av_buffer_unref(&f->hwaccel_priv_buf);
588  f->hwaccel_picture_private = NULL;
589  av_buffer_unref(&f->header_ref);
590  f->raw_frame_header = NULL;
591  f->spatial_id = f->temporal_id = 0;
592  memset(f->skip_mode_frame_idx, 0,
593  2 * sizeof(uint8_t));
594  memset(&f->film_grain, 0, sizeof(f->film_grain));
595  f->coded_lossless = 0;
596 }
597 
598 static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *src)
599 {
600  int ret;
601 
602  ret = av_buffer_replace(&dst->header_ref, src->header_ref);
603  if (ret < 0)
604  return ret;
605 
606  dst->raw_frame_header = src->raw_frame_header;
607 
608  if (!src->f->buf[0])
609  return 0;
610 
611  ret = av_frame_ref(dst->f, src->f);
612  if (ret < 0)
613  goto fail;
614 
615  if (src->hwaccel_picture_private) {
616  dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf);
617  if (!dst->hwaccel_priv_buf)
618  goto fail;
620  }
621 
622  dst->spatial_id = src->spatial_id;
623  dst->temporal_id = src->temporal_id;
624  memcpy(dst->gm_invalid,
625  src->gm_invalid,
626  AV1_NUM_REF_FRAMES * sizeof(uint8_t));
627  memcpy(dst->gm_type,
628  src->gm_type,
629  AV1_NUM_REF_FRAMES * sizeof(uint8_t));
630  memcpy(dst->gm_params,
631  src->gm_params,
632  AV1_NUM_REF_FRAMES * 6 * sizeof(int32_t));
633  memcpy(dst->skip_mode_frame_idx,
634  src->skip_mode_frame_idx,
635  2 * sizeof(uint8_t));
636  memcpy(&dst->film_grain,
637  &src->film_grain,
638  sizeof(dst->film_grain));
639  dst->coded_lossless = src->coded_lossless;
640 
641  return 0;
642 
643 fail:
644  av1_frame_unref(avctx, dst);
645  return AVERROR(ENOMEM);
646 }
647 
649 {
650  AV1DecContext *s = avctx->priv_data;
651  AV1RawMetadataITUTT35 itut_t35;
652 
653  for (int i = 0; i < FF_ARRAY_ELEMS(s->ref); i++) {
654  av1_frame_unref(avctx, &s->ref[i]);
655  av_frame_free(&s->ref[i].f);
656  }
657  av1_frame_unref(avctx, &s->cur_frame);
658  av_frame_free(&s->cur_frame.f);
659 
660  av_buffer_unref(&s->seq_ref);
661  av_buffer_unref(&s->header_ref);
662  av_buffer_unref(&s->cll_ref);
663  av_buffer_unref(&s->mdcv_ref);
664  av_freep(&s->tile_group_info);
665 
666  while (s->itut_t35_fifo && av_fifo_read(s->itut_t35_fifo, &itut_t35, 1) >= 0)
667  av_buffer_unref(&itut_t35.payload_ref);
668  av_fifo_freep2(&s->itut_t35_fifo);
669 
670  ff_cbs_fragment_free(&s->current_obu);
671  ff_cbs_close(&s->cbc);
672 
673  return 0;
674 }
675 
677  const AV1RawSequenceHeader *seq)
678 {
679  int width = seq->max_frame_width_minus_1 + 1;
680  int height = seq->max_frame_height_minus_1 + 1;
681 
682  avctx->profile = seq->seq_profile;
683  avctx->level = seq->seq_level_idx[0];
684 
685  avctx->color_range =
690 
691  switch (seq->color_config.chroma_sample_position) {
692  case AV1_CSP_VERTICAL:
694  break;
695  case AV1_CSP_COLOCATED:
697  break;
698  }
699 
700  if (seq->film_grain_params_present)
702  else
704 
705  if (avctx->width != width || avctx->height != height) {
706  int ret = ff_set_dimensions(avctx, width, height);
707  if (ret < 0)
708  return ret;
709  }
710  avctx->sample_aspect_ratio = (AVRational) { 1, 1 };
711 
713  seq->timing_info.time_scale) {
714  av_reduce(&avctx->framerate.den, &avctx->framerate.num,
716  seq->timing_info.time_scale,
717  INT_MAX);
720  }
721 
722  return 0;
723 }
724 
726  const AV1RawFrameHeader *header)
727 {
728  AVRational aspect_ratio;
729  int width = header->frame_width_minus_1 + 1;
730  int height = header->frame_height_minus_1 + 1;
731  int r_width = header->render_width_minus_1 + 1;
732  int r_height = header->render_height_minus_1 + 1;
733  int ret;
734 
735  if (avctx->width != width || avctx->height != height) {
736  ret = ff_set_dimensions(avctx, width, height);
737  if (ret < 0)
738  return ret;
739  }
740 
741  av_reduce(&aspect_ratio.num, &aspect_ratio.den,
742  (int64_t)height * r_width,
743  (int64_t)width * r_height,
744  INT_MAX);
745 
746  if (av_cmp_q(avctx->sample_aspect_ratio, aspect_ratio)) {
747  ret = ff_set_sar(avctx, aspect_ratio);
748  if (ret < 0)
749  return ret;
750  }
751 
752  return 0;
753 }
754 
763 };
764 
766 {
767  AV1DecContext *s = avctx->priv_data;
769  int ret;
770 
771  s->avctx = avctx;
772  s->pix_fmt = AV_PIX_FMT_NONE;
773 
774  for (int i = 0; i < FF_ARRAY_ELEMS(s->ref); i++) {
775  s->ref[i].f = av_frame_alloc();
776  if (!s->ref[i].f) {
777  av_log(avctx, AV_LOG_ERROR,
778  "Failed to allocate reference frame buffer %d.\n", i);
779  return AVERROR(ENOMEM);
780  }
781  }
782 
783  s->cur_frame.f = av_frame_alloc();
784  if (!s->cur_frame.f) {
785  av_log(avctx, AV_LOG_ERROR,
786  "Failed to allocate current frame buffer.\n");
787  return AVERROR(ENOMEM);
788  }
789 
790  ret = ff_cbs_init(&s->cbc, AV_CODEC_ID_AV1, avctx);
791  if (ret < 0)
792  return ret;
793 
794  s->cbc->decompose_unit_types = decompose_unit_types;
795  s->cbc->nb_decompose_unit_types = FF_ARRAY_ELEMS(decompose_unit_types);
796 
797  s->itut_t35_fifo = av_fifo_alloc2(1, sizeof(AV1RawMetadataITUTT35),
799  if (!s->itut_t35_fifo)
800  return AVERROR(ENOMEM);
801 
802  av_opt_set_int(s->cbc->priv_data, "operating_point", s->operating_point, 0);
803 
804  if (avctx->extradata && avctx->extradata_size) {
806  &s->current_obu,
807  avctx);
808  if (ret < 0) {
809  av_log(avctx, AV_LOG_WARNING, "Failed to read extradata.\n");
810  return ret;
811  }
812 
813  seq = ((CodedBitstreamAV1Context *)(s->cbc->priv_data))->sequence_header;
814  if (!seq) {
815  av_log(avctx, AV_LOG_WARNING, "No sequence header available.\n");
816  goto end;
817  }
818 
819  ret = set_context_with_sequence(avctx, seq);
820  if (ret < 0) {
821  av_log(avctx, AV_LOG_WARNING, "Failed to set decoder context.\n");
822  goto end;
823  }
824 
825  end:
826  ff_cbs_fragment_reset(&s->current_obu);
827  }
828 
829  return ret;
830 }
831 
833 {
834  AV1DecContext *s = avctx->priv_data;
835  AV1RawFrameHeader *header= s->raw_frame_header;
836  AVFrame *frame;
837  int ret;
838 
840  if (ret < 0) {
841  av_log(avctx, AV_LOG_ERROR, "Failed to update context with frame header\n");
842  return ret;
843  }
844 
845  if ((ret = ff_thread_get_buffer(avctx, f->f, AV_GET_BUFFER_FLAG_REF)) < 0)
846  goto fail;
847 
848  frame = f->f;
849  frame->key_frame = header->frame_type == AV1_FRAME_KEY;
850 
851  switch (header->frame_type) {
852  case AV1_FRAME_KEY:
854  frame->pict_type = AV_PICTURE_TYPE_I;
855  break;
856  case AV1_FRAME_INTER:
857  frame->pict_type = AV_PICTURE_TYPE_P;
858  break;
859  case AV1_FRAME_SWITCH:
860  frame->pict_type = AV_PICTURE_TYPE_SP;
861  break;
862  }
863 
864  if (avctx->hwaccel) {
865  const AVHWAccel *hwaccel = avctx->hwaccel;
866  if (hwaccel->frame_priv_data_size) {
867  f->hwaccel_priv_buf =
869  if (!f->hwaccel_priv_buf) {
870  ret = AVERROR(ENOMEM);
871  goto fail;
872  }
873  f->hwaccel_picture_private = f->hwaccel_priv_buf->data;
874  }
875  }
876  return 0;
877 
878 fail:
879  av1_frame_unref(avctx, f);
880  return ret;
881 }
882 
884  const AV1RawMetadataITUTT35 *itut_t35)
885 {
886  GetByteContext gb;
887  int ret, provider_code;
888 
889  bytestream2_init(&gb, itut_t35->payload, itut_t35->payload_size);
890 
891  provider_code = bytestream2_get_be16(&gb);
892  switch (provider_code) {
893  case 0x31: { // atsc_provider_code
894  uint32_t user_identifier = bytestream2_get_be32(&gb);
895  switch (user_identifier) {
896  case MKBETAG('G', 'A', '9', '4'): { // closed captions
897  AVBufferRef *buf = NULL;
898 
900  if (ret < 0)
901  return ret;
902  if (!ret)
903  break;
904 
906  av_buffer_unref(&buf);
907 
909  break;
910  }
911  default: // ignore unsupported identifiers
912  break;
913  }
914  break;
915  }
916  case 0x3C: { // smpte_provider_code
917  AVDynamicHDRPlus *hdrplus;
918  int provider_oriented_code = bytestream2_get_be16(&gb);
919  int application_identifier = bytestream2_get_byte(&gb);
920 
921  if (itut_t35->itu_t_t35_country_code != 0xB5 ||
922  provider_oriented_code != 1 || application_identifier != 4)
923  break;
924 
926  if (!hdrplus)
927  return AVERROR(ENOMEM);
928 
931  if (ret < 0)
932  return ret;
933  break;
934  }
935  default: // ignore unsupported provider codes
936  break;
937  }
938 
939  return 0;
940 }
941 
943 {
944  AV1DecContext *s = avctx->priv_data;
945  AV1RawMetadataITUTT35 itut_t35;
946  int ret = 0;
947 
948  if (s->mdcv) {
950  if (!mastering)
951  return AVERROR(ENOMEM);
952 
953  for (int i = 0; i < 3; i++) {
954  mastering->display_primaries[i][0] = av_make_q(s->mdcv->primary_chromaticity_x[i], 1 << 16);
955  mastering->display_primaries[i][1] = av_make_q(s->mdcv->primary_chromaticity_y[i], 1 << 16);
956  }
957  mastering->white_point[0] = av_make_q(s->mdcv->white_point_chromaticity_x, 1 << 16);
958  mastering->white_point[1] = av_make_q(s->mdcv->white_point_chromaticity_y, 1 << 16);
959 
960  mastering->max_luminance = av_make_q(s->mdcv->luminance_max, 1 << 8);
961  mastering->min_luminance = av_make_q(s->mdcv->luminance_min, 1 << 14);
962 
963  mastering->has_primaries = 1;
964  mastering->has_luminance = 1;
965  }
966 
967  if (s->cll) {
969  if (!light)
970  return AVERROR(ENOMEM);
971 
972  light->MaxCLL = s->cll->max_cll;
973  light->MaxFALL = s->cll->max_fall;
974  }
975 
976  while (av_fifo_read(s->itut_t35_fifo, &itut_t35, 1) >= 0) {
977  if (ret >= 0)
978  ret = export_itut_t35(avctx, frame, &itut_t35);
979  av_buffer_unref(&itut_t35.payload_ref);
980  }
981 
982  return ret;
983 }
984 
986 {
987  AV1DecContext *s = avctx->priv_data;
988  const AV1RawFilmGrainParams *film_grain = &s->cur_frame.film_grain;
989  AVFilmGrainParams *fgp;
991 
992  if (!film_grain->apply_grain)
993  return 0;
994 
996  if (!fgp)
997  return AVERROR(ENOMEM);
998 
1000  fgp->seed = film_grain->grain_seed;
1001 
1002  aom = &fgp->codec.aom;
1004  aom->scaling_shift = film_grain->grain_scaling_minus_8 + 8;
1005  aom->ar_coeff_lag = film_grain->ar_coeff_lag;
1006  aom->ar_coeff_shift = film_grain->ar_coeff_shift_minus_6 + 6;
1007  aom->grain_scale_shift = film_grain->grain_scale_shift;
1008  aom->overlap_flag = film_grain->overlap_flag;
1009  aom->limit_output_range = film_grain->clip_to_restricted_range;
1010 
1011  aom->num_y_points = film_grain->num_y_points;
1012  for (int i = 0; i < film_grain->num_y_points; i++) {
1013  aom->y_points[i][0] = film_grain->point_y_value[i];
1014  aom->y_points[i][1] = film_grain->point_y_scaling[i];
1015  }
1016  aom->num_uv_points[0] = film_grain->num_cb_points;
1017  for (int i = 0; i < film_grain->num_cb_points; i++) {
1018  aom->uv_points[0][i][0] = film_grain->point_cb_value[i];
1019  aom->uv_points[0][i][1] = film_grain->point_cb_scaling[i];
1020  }
1021  aom->num_uv_points[1] = film_grain->num_cr_points;
1022  for (int i = 0; i < film_grain->num_cr_points; i++) {
1023  aom->uv_points[1][i][0] = film_grain->point_cr_value[i];
1024  aom->uv_points[1][i][1] = film_grain->point_cr_scaling[i];
1025  }
1026 
1027  for (int i = 0; i < 24; i++) {
1028  aom->ar_coeffs_y[i] = film_grain->ar_coeffs_y_plus_128[i] - 128;
1029  }
1030  for (int i = 0; i < 25; i++) {
1031  aom->ar_coeffs_uv[0][i] = film_grain->ar_coeffs_cb_plus_128[i] - 128;
1032  aom->ar_coeffs_uv[1][i] = film_grain->ar_coeffs_cr_plus_128[i] - 128;
1033  }
1034 
1035  aom->uv_mult[0] = film_grain->cb_mult;
1036  aom->uv_mult[1] = film_grain->cr_mult;
1037  aom->uv_mult_luma[0] = film_grain->cb_luma_mult;
1038  aom->uv_mult_luma[1] = film_grain->cr_luma_mult;
1039  aom->uv_offset[0] = film_grain->cb_offset;
1040  aom->uv_offset[1] = film_grain->cr_offset;
1041 
1042  return 0;
1043 }
1044 
1046  const AVPacket *pkt, int *got_frame)
1047 {
1048  AV1DecContext *s = avctx->priv_data;
1049  const AVFrame *srcframe = s->cur_frame.f;
1050  int ret;
1051 
1052  // TODO: all layers
1053  if (s->operating_point_idc &&
1054  av_log2(s->operating_point_idc >> 8) > s->cur_frame.spatial_id)
1055  return 0;
1056 
1057  ret = av_frame_ref(frame, srcframe);
1058  if (ret < 0)
1059  return ret;
1060 
1061  ret = export_metadata(avctx, frame);
1062  if (ret < 0) {
1064  return ret;
1065  }
1066 
1068  ret = export_film_grain(avctx, frame);
1069  if (ret < 0) {
1071  return ret;
1072  }
1073  }
1074 
1075  frame->pts = pkt->pts;
1076  frame->pkt_dts = pkt->dts;
1077 #if FF_API_FRAME_PKT
1079  frame->pkt_size = pkt->size;
1081 #endif
1082 
1083  *got_frame = 1;
1084 
1085  return 0;
1086 }
1087 
1089 {
1090  AV1DecContext *s = avctx->priv_data;
1091  const AV1RawFrameHeader *header = s->raw_frame_header;
1092  int ret;
1093 
1094  for (int i = 0; i < AV1_NUM_REF_FRAMES; i++) {
1095  if (header->refresh_frame_flags & (1 << i)) {
1096  av1_frame_unref(avctx, &s->ref[i]);
1097  if ((ret = av1_frame_ref(avctx, &s->ref[i], &s->cur_frame)) < 0) {
1098  av_log(avctx, AV_LOG_ERROR,
1099  "Failed to update frame %d in reference list\n", i);
1100  return ret;
1101  }
1102  }
1103  }
1104  return 0;
1105 }
1106 
1108 {
1109  AV1DecContext *s = avctx->priv_data;
1110  int ret;
1111 
1112  av1_frame_unref(avctx, &s->cur_frame);
1113 
1114  s->cur_frame.header_ref = av_buffer_ref(s->header_ref);
1115  if (!s->cur_frame.header_ref)
1116  return AVERROR(ENOMEM);
1117 
1118  s->cur_frame.raw_frame_header = s->raw_frame_header;
1119 
1120  ret = init_tile_data(s);
1121  if (ret < 0) {
1122  av_log(avctx, AV_LOG_ERROR, "Failed to init tile data.\n");
1123  return ret;
1124  }
1125 
1126  if ((avctx->skip_frame >= AVDISCARD_NONINTRA &&
1127  (s->raw_frame_header->frame_type != AV1_FRAME_KEY &&
1128  s->raw_frame_header->frame_type != AV1_FRAME_INTRA_ONLY)) ||
1129  (avctx->skip_frame >= AVDISCARD_NONKEY &&
1130  s->raw_frame_header->frame_type != AV1_FRAME_KEY) ||
1131  avctx->skip_frame >= AVDISCARD_ALL)
1132  return 0;
1133 
1134  ret = av1_frame_alloc(avctx, &s->cur_frame);
1135  if (ret < 0) {
1136  av_log(avctx, AV_LOG_ERROR,
1137  "Failed to allocate space for current frame.\n");
1138  return ret;
1139  }
1140 
1145 
1146  return ret;
1147 }
1148 
1150  int *got_frame, AVPacket *pkt)
1151 {
1152  AV1DecContext *s = avctx->priv_data;
1153  AV1RawTileGroup *raw_tile_group = NULL;
1154  int ret;
1155 
1156  ret = ff_cbs_read_packet(s->cbc, &s->current_obu, pkt);
1157  if (ret < 0) {
1158  av_log(avctx, AV_LOG_ERROR, "Failed to read packet.\n");
1159  goto end;
1160  }
1161  av_log(avctx, AV_LOG_DEBUG, "Total obu for this frame:%d.\n",
1162  s->current_obu.nb_units);
1163 
1164  for (int i = 0; i < s->current_obu.nb_units; i++) {
1165  CodedBitstreamUnit *unit = &s->current_obu.units[i];
1166  AV1RawOBU *obu = unit->content;
1167  const AV1RawOBUHeader *header;
1168 
1169  if (!obu)
1170  continue;
1171 
1172  header = &obu->header;
1173  av_log(avctx, AV_LOG_DEBUG, "Obu idx:%d, obu type:%d.\n", i, unit->type);
1174 
1175  switch (unit->type) {
1177  av_buffer_unref(&s->seq_ref);
1178  s->seq_ref = av_buffer_ref(unit->content_ref);
1179  if (!s->seq_ref) {
1180  ret = AVERROR(ENOMEM);
1181  goto end;
1182  }
1183 
1184  s->raw_seq = &obu->obu.sequence_header;
1185 
1186  ret = set_context_with_sequence(avctx, s->raw_seq);
1187  if (ret < 0) {
1188  av_log(avctx, AV_LOG_ERROR, "Failed to set context.\n");
1189  s->raw_seq = NULL;
1190  goto end;
1191  }
1192 
1193  s->operating_point_idc = s->raw_seq->operating_point_idc[s->operating_point];
1194 
1195  if (s->pix_fmt == AV_PIX_FMT_NONE) {
1196  ret = get_pixel_format(avctx);
1197  if (ret < 0) {
1198  av_log(avctx, AV_LOG_ERROR,
1199  "Failed to get pixel format.\n");
1200  s->raw_seq = NULL;
1201  goto end;
1202  }
1203  }
1204 
1205  if (avctx->hwaccel && avctx->hwaccel->decode_params) {
1206  ret = avctx->hwaccel->decode_params(avctx, unit->type, unit->data,
1207  unit->data_size);
1208  if (ret < 0) {
1209  av_log(avctx, AV_LOG_ERROR, "HW accel decode params fail.\n");
1210  s->raw_seq = NULL;
1211  goto end;
1212  }
1213  }
1214  break;
1216  if (s->raw_frame_header)
1217  break;
1218  // fall-through
1219  case AV1_OBU_FRAME:
1220  case AV1_OBU_FRAME_HEADER:
1221  if (!s->raw_seq) {
1222  av_log(avctx, AV_LOG_ERROR, "Missing Sequence Header.\n");
1224  goto end;
1225  }
1226 
1227  av_buffer_unref(&s->header_ref);
1228  s->header_ref = av_buffer_ref(unit->content_ref);
1229  if (!s->header_ref) {
1230  ret = AVERROR(ENOMEM);
1231  goto end;
1232  }
1233 
1234  if (unit->type == AV1_OBU_FRAME)
1235  s->raw_frame_header = &obu->obu.frame.header;
1236  else
1237  s->raw_frame_header = &obu->obu.frame_header;
1238 
1239  if (s->raw_frame_header->show_existing_frame) {
1240  av1_frame_unref(avctx, &s->cur_frame);
1241 
1242  ret = av1_frame_ref(avctx, &s->cur_frame,
1243  &s->ref[s->raw_frame_header->frame_to_show_map_idx]);
1244  if (ret < 0) {
1245  av_log(avctx, AV_LOG_ERROR, "Failed to get reference frame.\n");
1246  goto end;
1247  }
1248 
1249  ret = update_reference_list(avctx);
1250  if (ret < 0) {
1251  av_log(avctx, AV_LOG_ERROR, "Failed to update reference list.\n");
1252  goto end;
1253  }
1254 
1255  if (s->cur_frame.f->buf[0]) {
1256  ret = set_output_frame(avctx, frame, pkt, got_frame);
1257  if (ret < 0)
1258  av_log(avctx, AV_LOG_ERROR, "Set output frame error.\n");
1259  }
1260 
1261  s->raw_frame_header = NULL;
1262 
1263  goto end;
1264  }
1265 
1266  ret = get_current_frame(avctx);
1267  if (ret < 0) {
1268  av_log(avctx, AV_LOG_ERROR, "Get current frame error\n");
1269  goto end;
1270  }
1271 
1272  s->cur_frame.spatial_id = header->spatial_id;
1273  s->cur_frame.temporal_id = header->temporal_id;
1274 
1275  if (avctx->hwaccel && s->cur_frame.f->buf[0]) {
1276  ret = avctx->hwaccel->start_frame(avctx, unit->data,
1277  unit->data_size);
1278  if (ret < 0) {
1279  av_log(avctx, AV_LOG_ERROR, "HW accel start frame fail.\n");
1280  goto end;
1281  }
1282  }
1283  if (unit->type != AV1_OBU_FRAME)
1284  break;
1285  // fall-through
1286  case AV1_OBU_TILE_GROUP:
1287  if (!s->raw_frame_header) {
1288  av_log(avctx, AV_LOG_ERROR, "Missing Frame Header.\n");
1290  goto end;
1291  }
1292 
1293  if (unit->type == AV1_OBU_FRAME)
1294  raw_tile_group = &obu->obu.frame.tile_group;
1295  else
1296  raw_tile_group = &obu->obu.tile_group;
1297 
1298  ret = get_tiles_info(avctx, raw_tile_group);
1299  if (ret < 0)
1300  goto end;
1301 
1302  if (avctx->hwaccel && s->cur_frame.f->buf[0]) {
1303  ret = avctx->hwaccel->decode_slice(avctx,
1304  raw_tile_group->tile_data.data,
1305  raw_tile_group->tile_data.data_size);
1306  if (ret < 0) {
1307  av_log(avctx, AV_LOG_ERROR,
1308  "HW accel decode slice fail.\n");
1309  goto end;
1310  }
1311  }
1312  break;
1313  case AV1_OBU_TILE_LIST:
1315  case AV1_OBU_PADDING:
1316  break;
1317  case AV1_OBU_METADATA:
1318  switch (obu->obu.metadata.metadata_type) {
1320  av_buffer_unref(&s->cll_ref);
1321  s->cll_ref = av_buffer_ref(unit->content_ref);
1322  if (!s->cll_ref) {
1323  s->cll = NULL;
1324  ret = AVERROR(ENOMEM);
1325  goto end;
1326  }
1327  s->cll = &obu->obu.metadata.metadata.hdr_cll;
1328  break;
1330  av_buffer_unref(&s->mdcv_ref);
1331  s->mdcv_ref = av_buffer_ref(unit->content_ref);
1332  if (!s->mdcv_ref) {
1333  s->mdcv = NULL;
1334  ret = AVERROR(ENOMEM);
1335  goto end;
1336  }
1337  s->mdcv = &obu->obu.metadata.metadata.hdr_mdcv;
1338  break;
1340  AV1RawMetadataITUTT35 itut_t35;
1341  memcpy(&itut_t35, &obu->obu.metadata.metadata.itut_t35, sizeof(itut_t35));
1343  if (!itut_t35.payload_ref) {
1344  ret = AVERROR(ENOMEM);
1345  goto end;
1346  }
1347  ret = av_fifo_write(s->itut_t35_fifo, &itut_t35, 1);
1348  if (ret < 0) {
1349  av_buffer_unref(&itut_t35.payload_ref);
1350  goto end;
1351  }
1352  break;
1353  }
1354  default:
1355  break;
1356  }
1357  break;
1358  default:
1359  av_log(avctx, AV_LOG_DEBUG,
1360  "Unknown obu type: %d (%"SIZE_SPECIFIER" bits).\n",
1361  unit->type, unit->data_size);
1362  }
1363 
1364  if (raw_tile_group && (s->tile_num == raw_tile_group->tg_end + 1)) {
1365  if (avctx->hwaccel && s->cur_frame.f->buf[0]) {
1366  ret = avctx->hwaccel->end_frame(avctx);
1367  if (ret < 0) {
1368  av_log(avctx, AV_LOG_ERROR, "HW accel end frame fail.\n");
1369  goto end;
1370  }
1371  }
1372 
1373  ret = update_reference_list(avctx);
1374  if (ret < 0) {
1375  av_log(avctx, AV_LOG_ERROR, "Failed to update reference list.\n");
1376  goto end;
1377  }
1378 
1379  if (s->raw_frame_header->show_frame && s->cur_frame.f->buf[0]) {
1380  ret = set_output_frame(avctx, frame, pkt, got_frame);
1381  if (ret < 0) {
1382  av_log(avctx, AV_LOG_ERROR, "Set output frame error\n");
1383  goto end;
1384  }
1385  }
1386  raw_tile_group = NULL;
1387  s->raw_frame_header = NULL;
1388  }
1389  }
1390 
1391 end:
1392  ff_cbs_fragment_reset(&s->current_obu);
1393  if (ret < 0)
1394  s->raw_frame_header = NULL;
1395  return ret;
1396 }
1397 
1399 {
1400  AV1DecContext *s = avctx->priv_data;
1401  AV1RawMetadataITUTT35 itut_t35;
1402 
1403  for (int i = 0; i < FF_ARRAY_ELEMS(s->ref); i++)
1404  av1_frame_unref(avctx, &s->ref[i]);
1405 
1406  av1_frame_unref(avctx, &s->cur_frame);
1407  s->operating_point_idc = 0;
1408  s->raw_frame_header = NULL;
1409  s->raw_seq = NULL;
1410  s->cll = NULL;
1411  s->mdcv = NULL;
1412  while (av_fifo_read(s->itut_t35_fifo, &itut_t35, 1) >= 0)
1413  av_buffer_unref(&itut_t35.payload_ref);
1414 
1415  ff_cbs_flush(s->cbc);
1416 }
1417 
1418 #define OFFSET(x) offsetof(AV1DecContext, x)
1419 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
1420 static const AVOption av1_options[] = {
1421  { "operating_point", "Select an operating point of the scalable bitstream",
1422  OFFSET(operating_point), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, AV1_MAX_OPERATING_POINTS - 1, VD },
1423  { NULL }
1424 };
1425 
1426 static const AVClass av1_class = {
1427  .class_name = "AV1 decoder",
1428  .item_name = av_default_item_name,
1429  .option = av1_options,
1430  .version = LIBAVUTIL_VERSION_INT,
1431 };
1432 
1434  .p.name = "av1",
1435  CODEC_LONG_NAME("Alliance for Open Media AV1"),
1436  .p.type = AVMEDIA_TYPE_VIDEO,
1437  .p.id = AV_CODEC_ID_AV1,
1438  .priv_data_size = sizeof(AV1DecContext),
1439  .init = av1_decode_init,
1440  .close = av1_decode_free,
1442  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_AVOID_PROBING,
1443  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP |
1445  .flush = av1_decode_flush,
1446  .p.profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles),
1447  .p.priv_class = &av1_class,
1448  .bsfs = "av1_frame_split",
1449  .hw_configs = (const AVCodecHWConfigInternal *const []) {
1450 #if CONFIG_AV1_DXVA2_HWACCEL
1451  HWACCEL_DXVA2(av1),
1452 #endif
1453 #if CONFIG_AV1_D3D11VA_HWACCEL
1454  HWACCEL_D3D11VA(av1),
1455 #endif
1456 #if CONFIG_AV1_D3D11VA2_HWACCEL
1457  HWACCEL_D3D11VA2(av1),
1458 #endif
1459 #if CONFIG_AV1_NVDEC_HWACCEL
1460  HWACCEL_NVDEC(av1),
1461 #endif
1462 #if CONFIG_AV1_VAAPI_HWACCEL
1463  HWACCEL_VAAPI(av1),
1464 #endif
1465 #if CONFIG_AV1_VDPAU_HWACCEL
1466  HWACCEL_VDPAU(av1),
1467 #endif
1468 
1469  NULL
1470  },
1471 };
hwconfig.h
AVMasteringDisplayMetadata::has_primaries
int has_primaries
Flag indicating whether the display primaries (and white point) are set.
Definition: mastering_display_metadata.h:62
AV1RawTimingInfo::num_units_in_display_tick
uint32_t num_units_in_display_tick
Definition: cbs_av1.h:59
AV1RawTimingInfo::time_scale
uint32_t time_scale
Definition: cbs_av1.h:60
AV1_REF_FRAME_ALTREF
@ AV1_REF_FRAME_ALTREF
Definition: av1.h:68
AVCodecContext::hwaccel
const struct AVHWAccel * hwaccel
Hardware accelerator in use.
Definition: avcodec.h:1418
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:82
bit_depth
static void bit_depth(AudioStatsContext *s, uint64_t mask, uint64_t imask, AVRational *depth)
Definition: af_astats.c:227
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AV_PIX_FMT_CUDA
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
Definition: pixfmt.h:253
AVMasteringDisplayMetadata::max_luminance
AVRational max_luminance
Max luminance of mastering display (cd/m^2).
Definition: mastering_display_metadata.h:57
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
AV1_METADATA_TYPE_HDR_MDCV
@ AV1_METADATA_TYPE_HDR_MDCV
Definition: av1.h:45
AV1RawColorConfig::color_primaries
uint8_t color_primaries
Definition: cbs_av1.h:47
av1_decode_init
static av_cold int av1_decode_init(AVCodecContext *avctx)
Definition: av1dec.c:765
AV1_OBU_REDUNDANT_FRAME_HEADER
@ AV1_OBU_REDUNDANT_FRAME_HEADER
Definition: av1.h:36
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:42
AV1_GM_ABS_TRANS_BITS
@ AV1_GM_ABS_TRANS_BITS
Definition: av1.h:109
AV1RawSequenceHeader::seq_level_idx
uint8_t seq_level_idx[AV1_MAX_OPERATING_POINTS]
Definition: cbs_av1.h:87
r
const char * r
Definition: vf_curves.c:126
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
AV1RawFilmGrainParams::clip_to_restricted_range
uint8_t clip_to_restricted_range
Definition: cbs_av1.h:162
opt.h
AV1RawFilmGrainParams::grain_seed
uint16_t grain_seed
Definition: cbs_av1.h:135
AVCodecContext::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:1015
AV1RawSequenceHeader
Definition: cbs_av1.h:73
ff_thread_get_format
#define ff_thread_get_format
Definition: thread.h:65
AV1_FRAME_INTRA_ONLY
@ AV1_FRAME_INTRA_ONLY
Definition: av1.h:55
AV1RawColorConfig::color_range
uint8_t color_range
Definition: cbs_av1.h:51
coded_lossless_param
static void coded_lossless_param(AV1DecContext *s)
Definition: av1dec.c:324
GetByteContext
Definition: bytestream.h:33
sub
static float sub(float src0, float src1)
Definition: dnn_backend_native_layer_mathbinary.c:31
ff_cbs_fragment_free
av_cold void ff_cbs_fragment_free(CodedBitstreamFragment *frag)
Free the units array of a fragment in addition to what ff_cbs_fragment_reset does.
Definition: cbs.c:171
av1_frame_alloc
static int av1_frame_alloc(AVCodecContext *avctx, AV1Frame *f)
Definition: av1dec.c:832
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
AV_FRAME_DATA_A53_CC
@ AV_FRAME_DATA_A53_CC
ATSC A53 Part 4 Closed Captions.
Definition: frame.h:59
av_clip_uintp2
#define av_clip_uintp2
Definition: common.h:119
AVMasteringDisplayMetadata::display_primaries
AVRational display_primaries[3][2]
CIE 1931 xy chromaticity coords of color primaries (r, g, b order).
Definition: mastering_display_metadata.h:42
AVMasteringDisplayMetadata::has_luminance
int has_luminance
Flag indicating whether the luminance (min_ and max_) have been set.
Definition: mastering_display_metadata.h:67
AV1RawFilmGrainParams::point_cb_value
uint8_t point_cb_value[10]
Definition: cbs_av1.h:143
CodedBitstreamUnit::content
void * content
Pointer to the decomposed form of this unit.
Definition: cbs.h:106
AV1RawFilmGrainParams::apply_grain
uint8_t apply_grain
Definition: cbs_av1.h:134
bytestream2_skipu
static av_always_inline void bytestream2_skipu(GetByteContext *g, unsigned int size)
Definition: bytestream.h:174
AVFilmGrainAOMParams::uv_points
uint8_t uv_points[2][10][2]
Definition: film_grain_params.h:63
get_current_frame
static int get_current_frame(AVCodecContext *avctx)
Definition: av1dec.c:1107
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:101
AVContentLightMetadata::MaxCLL
unsigned MaxCLL
Max content light level (cd/m^2).
Definition: mastering_display_metadata.h:102
AVFilmGrainParams::aom
AVFilmGrainAOMParams aom
Definition: film_grain_params.h:236
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:330
pixdesc.h
AVCodecContext::color_trc
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:1008
AV1_GM_ABS_TRANS_ONLY_BITS
@ AV1_GM_ABS_TRANS_ONLY_BITS
Definition: av1.h:107
set_context_with_sequence
static int set_context_with_sequence(AVCodecContext *avctx, const AV1RawSequenceHeader *seq)
Definition: av1dec.c:676
w
uint8_t w
Definition: llviddspenc.c:38
HWACCEL_DXVA2
#define HWACCEL_DXVA2(codec)
Definition: hwconfig.h:67
AV1RawFilmGrainParams::point_y_value
uint8_t point_y_value[14]
Definition: cbs_av1.h:139
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:661
AV1_METADATA_TYPE_ITUT_T35
@ AV1_METADATA_TYPE_ITUT_T35
Definition: av1.h:47
ff_cbs_fragment_reset
void ff_cbs_fragment_reset(CodedBitstreamFragment *frag)
Free the units contained in a fragment as well as the fragment's own data buffer, but not the units a...
Definition: cbs.c:157
AV1Frame::raw_frame_header
AV1RawFrameHeader * raw_frame_header
Definition: av1dec.h:41
AVOption
AVOption.
Definition: opt.h:251
HWACCEL_D3D11VA2
#define HWACCEL_D3D11VA2(codec)
Definition: hwconfig.h:69
b
#define b
Definition: input.c:41
AV1RawSequenceHeader::timing_info
AV1RawTimingInfo timing_info
Definition: cbs_av1.h:83
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:459
AV1RawTileGroup::tg_end
uint16_t tg_end
Definition: cbs_av1.h:298
AV_PIX_FMT_D3D11VA_VLD
@ AV_PIX_FMT_D3D11VA_VLD
HW decoding through Direct3D11 via old API, Picture.data[3] contains a ID3D11VideoDecoderOutputView p...
Definition: pixfmt.h:247
AV1_WARP_PARAM_REDUCE_BITS
@ AV1_WARP_PARAM_REDUCE_BITS
Definition: av1.h:117
FFCodec
Definition: codec_internal.h:127
CodedBitstreamUnit::type
CodedBitstreamUnitType type
Codec-specific type of this unit.
Definition: cbs.h:73
decompose_unit_types
static const CodedBitstreamUnitType decompose_unit_types[]
Definition: av1dec.c:755
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
AV1_OBU_TEMPORAL_DELIMITER
@ AV1_OBU_TEMPORAL_DELIMITER
Definition: av1.h:31
AV1RawTileData::data
uint8_t * data
Definition: cbs_av1.h:290
AV1_DIV_LUT_PREC_BITS
@ AV1_DIV_LUT_PREC_BITS
Definition: av1.h:120
get_relative_dist
static int get_relative_dist(const AV1RawSequenceHeader *seq, unsigned int a, unsigned int b)
Definition: av1dec.c:252
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
AV1RawOBU::header
AV1RawOBUHeader header
Definition: cbs_av1.h:392
AV1_GM_TRANS_ONLY_PREC_BITS
@ AV1_GM_TRANS_ONLY_PREC_BITS
Definition: av1.h:108
thread.h
AVFilmGrainParams::seed
uint64_t seed
Seed to use for the synthesis process, if the codec allows for it.
Definition: film_grain_params.h:228
AV1RawSequenceHeader::seq_profile
uint8_t seq_profile
Definition: cbs_av1.h:74
AV1RawMetadata::itut_t35
AV1RawMetadataITUTT35 itut_t35
Definition: cbs_av1.h:379
CodedBitstreamUnit
Coded bitstream unit structure.
Definition: cbs.h:69
ff_cbs_close
av_cold void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
Definition: cbs.c:127
AV1RawColorConfig::subsampling_y
uint8_t subsampling_y
Definition: cbs_av1.h:53
round_two
static uint64_t round_two(uint64_t x, uint16_t n)
Definition: av1dec.c:135
AV1RawFrame::header
AV1RawFrameHeader header
Definition: cbs_av1.h:304
AV1RawFilmGrainParams::cr_mult
uint8_t cr_mult
Definition: cbs_av1.h:158
AVContentLightMetadata
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
Definition: mastering_display_metadata.h:98
AV1RawFilmGrainParams::chroma_scaling_from_luma
uint8_t chroma_scaling_from_luma
Definition: cbs_av1.h:141
AVCodecContext::framerate
AVRational framerate
Definition: avcodec.h:1771
AV1RawFilmGrainParams::ar_coeffs_cr_plus_128
uint8_t ar_coeffs_cr_plus_128[25]
Definition: cbs_av1.h:152
AV1RawSequenceHeader::film_grain_params_present
uint8_t film_grain_params_present
Definition: cbs_av1.h:130
AVHWAccel
Definition: avcodec.h:2097
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
av1_options
static const AVOption av1_options[]
Definition: av1dec.c:1420
AV1_DIV_LUT_NUM
@ AV1_DIV_LUT_NUM
Definition: av1.h:121
av1_frame_ref
static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *src)
Definition: av1dec.c:598
AVCodecContext::skip_frame
enum AVDiscard skip_frame
Skip decoding for selected frames.
Definition: avcodec.h:1734
fail
#define fail()
Definition: checkasm.h:135
AV1_OBU_FRAME_HEADER
@ AV1_OBU_FRAME_HEADER
Definition: av1.h:32
av_fifo_write
int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems)
Write data into a FIFO.
Definition: fifo.c:188
AVFilmGrainAOMParams::grain_scale_shift
int grain_scale_shift
Signals the down shift applied to the generated gaussian numbers during synthesis.
Definition: film_grain_params.h:99
AV1RawFilmGrainParams::point_cr_scaling
uint8_t point_cr_scaling[10]
Definition: cbs_av1.h:147
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
AV1RawMetadataITUTT35::payload_size
size_t payload_size
Definition: cbs_av1.h:354
inverse_recenter
static uint32_t inverse_recenter(int r, uint32_t v)
Definition: av1dec.c:66
HWACCEL_VDPAU
#define HWACCEL_VDPAU(codec)
Definition: hwconfig.h:75
type
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 type
Definition: writing_filters.txt:86
AV1RawFilmGrainParams::ar_coeff_shift_minus_6
uint8_t ar_coeff_shift_minus_6
Definition: cbs_av1.h:153
CodedBitstreamUnit::data
uint8_t * data
Pointer to the directly-parsable bitstream form of this unit.
Definition: cbs.h:80
AV1RawFilmGrainParams::num_y_points
uint8_t num_y_points
Definition: cbs_av1.h:138
av1_decode_frame
static int av1_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
Definition: av1dec.c:1149
AVFilmGrainAOMParams::limit_output_range
int limit_output_range
Signals to clip to limited color levels after film grain application.
Definition: film_grain_params.h:122
AVFilmGrainAOMParams::num_y_points
int num_y_points
Number of points, and the scale and value for each point of the piecewise linear scaling function for...
Definition: film_grain_params.h:49
av_reduce
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
round_two_signed
static int64_t round_two_signed(int64_t x, uint16_t n)
Definition: av1dec.c:142
AVRational::num
int num
Numerator.
Definition: rational.h:59
AVFilmGrainAOMParams
This structure describes how to handle film grain synthesis for AOM codecs.
Definition: film_grain_params.h:44
AV1RawFilmGrainParams::num_cb_points
uint8_t num_cb_points
Definition: cbs_av1.h:142
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:89
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:462
AV1RawFilmGrainParams::cb_luma_mult
uint8_t cb_luma_mult
Definition: cbs_av1.h:156
AV1Frame
Definition: av1dec.h:34
AV1RawFilmGrainParams::overlap_flag
uint8_t overlap_flag
Definition: cbs_av1.h:161
AVCodecContext::color_primaries
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:1001
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
film_grain_params.h
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
AV1_METADATA_TYPE_HDR_CLL
@ AV1_METADATA_TYPE_HDR_CLL
Definition: av1.h:44
av_fifo_read
int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems)
Read data from a FIFO.
Definition: fifo.c:240
AV1RawFilmGrainParams::grain_scaling_minus_8
uint8_t grain_scaling_minus_8
Definition: cbs_av1.h:148
AV1_GM_TRANS_PREC_BITS
@ AV1_GM_TRANS_PREC_BITS
Definition: av1.h:110
set_output_frame
static int set_output_frame(AVCodecContext *avctx, AVFrame *frame, const AVPacket *pkt, int *got_frame)
Definition: av1dec.c:1045
global_motion_params
static void global_motion_params(AV1DecContext *s)
update gm type/params, since cbs already implemented part of this function, so we don't need to full ...
Definition: av1dec.c:203
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:537
AV1Frame::spatial_id
int spatial_id
Definition: av1dec.h:44
width
#define width
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:306
AVMasteringDisplayMetadata::white_point
AVRational white_point[2]
CIE 1931 xy chromaticity coords of white point.
Definition: mastering_display_metadata.h:47
AV_PIX_FMT_DXVA2_VLD
@ AV_PIX_FMT_DXVA2_VLD
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer.
Definition: pixfmt.h:127
s
#define s(width, name)
Definition: cbs_vp9.c:256
AV1_CSP_COLOCATED
@ AV1_CSP_COLOCATED
Definition: av1.h:134
AV1Frame::hwaccel_priv_buf
AVBufferRef * hwaccel_priv_buf
Definition: av1dec.h:37
AV_GET_BUFFER_FLAG_REF
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
Definition: avcodec.h:413
pix_fmt
static enum AVPixelFormat pix_fmt
Definition: demux_decode.c:41
AVCodecContext::ticks_per_frame
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
Definition: avcodec.h:566
av_film_grain_params_create_side_data
AVFilmGrainParams * av_film_grain_params_create_side_data(AVFrame *frame)
Allocate a complete AVFilmGrainParams and add it to the frame.
Definition: film_grain_params.c:31
GetByteContext::buffer
const uint8_t * buffer
Definition: bytestream.h:34
AV1Frame::film_grain
AV1RawFilmGrainParams film_grain
Definition: av1dec.h:52
av1_decode_free
static av_cold int av1_decode_free(AVCodecContext *avctx)
Definition: av1dec.c:648
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
AV1RawMetadata::hdr_cll
AV1RawMetadataHDRCLL hdr_cll
Definition: cbs_av1.h:376
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:296
init_tile_data
static int init_tile_data(AV1DecContext *s)
Definition: av1dec.c:374
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
update_reference_list
static int update_reference_list(AVCodecContext *avctx)
Definition: av1dec.c:1088
decode.h
ff_av1_profiles
const AVProfile ff_av1_profiles[]
Definition: profiles.c:160
av1_frame_unref
static void av1_frame_unref(AVCodecContext *avctx, AV1Frame *f)
Definition: av1dec.c:584
AV1RawColorConfig::transfer_characteristics
uint8_t transfer_characteristics
Definition: cbs_av1.h:48
AVHWAccel::decode_params
int(* decode_params)(AVCodecContext *avctx, int type, const uint8_t *buf, uint32_t buf_size)
Callback for parameter data (SPS/PPS/VPS etc).
Definition: avcodec.h:2173
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
av1dec.h
get_tiles_info
static int get_tiles_info(AVCodecContext *avctx, const AV1RawTileGroup *tile_group)
Definition: av1dec.c:392
export_itut_t35
static int export_itut_t35(AVCodecContext *avctx, AVFrame *frame, const AV1RawMetadataITUTT35 *itut_t35)
Definition: av1dec.c:883
AVFilmGrainParams::codec
union AVFilmGrainParams::@320 codec
Additional fields may be added both here and in any structure included.
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
FF_CODEC_PROPERTY_FILM_GRAIN
#define FF_CODEC_PROPERTY_FILM_GRAIN
Definition: avcodec.h:1875
load_grain_params
static void load_grain_params(AV1DecContext *s)
Definition: av1dec.c:354
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:440
AV1RawOBU::obu
union AV1RawOBU::@27 obu
ff_av1_decoder
const FFCodec ff_av1_decoder
Definition: av1dec.c:1433
AV1_WARP_MODEL_TRANSLATION
@ AV1_WARP_MODEL_TRANSLATION
Definition: av1.h:114
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: defs.h:76
AVFilmGrainAOMParams::uv_mult_luma
int uv_mult_luma[2]
Definition: film_grain_params.h:106
ff_parse_a53_cc
int ff_parse_a53_cc(AVBufferRef **pbuf, const uint8_t *data, int size)
Parse a data array for ATSC A53 Part 4 Closed Captions and store them in an AVBufferRef.
Definition: atsc_a53.c:68
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AV1RawOBU
Definition: cbs_av1.h:391
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
av_clip_int16
#define av_clip_int16
Definition: common.h:110
HWACCEL_MAX
#define HWACCEL_MAX
NULL
#define NULL
Definition: coverity.c:32
AV1Frame::gm_params
int32_t gm_params[AV1_NUM_REF_FRAMES][6]
Definition: av1dec.h:48
AV1RawFilmGrainParams::cb_mult
uint8_t cb_mult
Definition: cbs_av1.h:155
AVCodecContext::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:1022
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:139
AV_CODEC_ID_AV1
@ AV_CODEC_ID_AV1
Definition: codec_id.h:283
AV1RawFrameHeader
Definition: cbs_av1.h:165
AVCHROMA_LOC_LEFT
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
Definition: pixfmt.h:682
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVCHROMA_LOC_TOPLEFT
@ AVCHROMA_LOC_TOPLEFT
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
Definition: pixfmt.h:684
AV1_NUM_REF_FRAMES
@ AV1_NUM_REF_FRAMES
Definition: av1.h:83
AV1RawTileData::data_size
size_t data_size
Definition: cbs_av1.h:292
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AVHWAccel::end_frame
int(* end_frame)(AVCodecContext *avctx)
Called at the end of each frame or field picture.
Definition: avcodec.h:2197
AV_PICTURE_TYPE_I
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
AV1RawColorConfig::chroma_sample_position
uint8_t chroma_sample_position
Definition: cbs_av1.h:54
profiles.h
CodedBitstreamUnit::data_size
size_t data_size
The number of bytes in the bitstream (including any padding bits in the final byte).
Definition: cbs.h:85
ff_set_sar
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
Definition: utils.c:106
AV1_OBU_TILE_GROUP
@ AV1_OBU_TILE_GROUP
Definition: av1.h:33
AV1_FRAME_SWITCH
@ AV1_FRAME_SWITCH
Definition: av1.h:56
av_frame_new_side_data_from_buf
AVFrameSideData * av_frame_new_side_data_from_buf(AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef *buf)
Add a new side data to a frame from an existing AVBufferRef.
Definition: frame.c:642
update_context_with_frame_header
static int update_context_with_frame_header(AVCodecContext *avctx, const AV1RawFrameHeader *header)
Definition: av1dec.c:725
abs
#define abs(x)
Definition: cuda_runtime.h:35
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:460
skip_mode_params
static void skip_mode_params(AV1DecContext *s)
Definition: av1dec.c:260
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
AVCodecContext::level
int level
level
Definition: avcodec.h:1712
AV_PICTURE_TYPE_SP
@ AV_PICTURE_TYPE_SP
Switching Predicted.
Definition: avutil.h:279
av_opt_set_int
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
Definition: opt.c:624
bytestream2_get_bytes_left
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
Definition: bytestream.h:158
bytestream2_tell
static av_always_inline int bytestream2_tell(GetByteContext *g)
Definition: bytestream.h:192
AV1RawSequenceHeader::max_frame_height_minus_1
uint16_t max_frame_height_minus_1
Definition: cbs_av1.h:99
resolve_divisor
static int16_t resolve_divisor(uint32_t d, uint16_t *shift)
Resolve divisor process.
Definition: av1dec.c:151
AV1_OBU_FRAME
@ AV1_OBU_FRAME
Definition: av1.h:35
AVFilmGrainAOMParams::num_uv_points
int num_uv_points[2]
If chroma_scaling_from_luma is set to 0, signals the chroma scaling function parameters.
Definition: film_grain_params.h:62
AV1RawFilmGrainParams::point_cr_value
uint8_t point_cr_value[10]
Definition: cbs_av1.h:146
AVDISCARD_NONKEY
@ AVDISCARD_NONKEY
discard all frames except keyframes
Definition: defs.h:75
AV1_FRAME_INTER
@ AV1_FRAME_INTER
Definition: av1.h:54
f
f
Definition: af_crystalizer.c:122
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
AVPacket::size
int size
Definition: packet.h:375
AV1RawFilmGrainParams::cb_offset
uint16_t cb_offset
Definition: cbs_av1.h:157
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:115
av_frame_ref
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
Definition: frame.c:350
decode_unsigned_subexp_with_ref
static uint32_t decode_unsigned_subexp_with_ref(uint32_t sub_exp, int mx, int r)
Definition: av1dec.c:76
codec_internal.h
AV1RawTimingInfo::num_ticks_per_picture_minus_1
uint32_t num_ticks_per_picture_minus_1
Definition: cbs_av1.h:63
shift
static int shift(int a, int b)
Definition: bonk.c:257
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:464
size
int size
Definition: twinvq_data.h:10344
AV1DecContext
Definition: av1dec.h:64
AV1RawOBU::sequence_header
AV1RawSequenceHeader sequence_header
Definition: cbs_av1.h:397
av_make_q
static AVRational av_make_q(int num, int den)
Create an AVRational.
Definition: rational.h:71
AV1Frame::skip_mode_frame_idx
uint8_t skip_mode_frame_idx[2]
Definition: av1dec.h:50
MKBETAG
#define MKBETAG(a, b, c, d)
Definition: macros.h:56
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:466
AVFilmGrainParams
This structure describes how to handle film grain synthesis in video for specific codecs.
Definition: film_grain_params.h:216
AV1_OBU_SEQUENCE_HEADER
@ AV1_OBU_SEQUENCE_HEADER
Definition: av1.h:30
AVCodecHWConfigInternal
Definition: hwconfig.h:29
header
static const uint8_t header[24]
Definition: sdr2.c:67
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:162
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:373
height
#define height
AV1Frame::f
AVFrame * f
Definition: av1dec.h:35
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
av_reallocp_array
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate an array through a pointer to a pointer.
Definition: mem.c:223
VD
#define VD
Definition: av1dec.c:1419
AV1_REFS_PER_FRAME
@ AV1_REFS_PER_FRAME
Definition: av1.h:84
HWACCEL_D3D11VA
#define HWACCEL_D3D11VA(codec)
Definition: hwconfig.h:79
av_content_light_metadata_create_side_data
AVContentLightMetadata * av_content_light_metadata_create_side_data(AVFrame *frame)
Allocate a complete AVContentLightMetadata and add it to the frame.
Definition: mastering_display_metadata.c:55
AV_PIX_FMT_D3D11
@ AV_PIX_FMT_D3D11
Hardware surfaces for Direct3D11.
Definition: pixfmt.h:333
AV1RawFilmGrainParams::grain_scale_shift
uint8_t grain_scale_shift
Definition: cbs_av1.h:154
HWACCEL_NVDEC
#define HWACCEL_NVDEC(codec)
Definition: hwconfig.h:71
AV1_WARP_MODEL_IDENTITY
@ AV1_WARP_MODEL_IDENTITY
Definition: av1.h:113
AVFilmGrainAOMParams::ar_coeffs_y
int8_t ar_coeffs_y[24]
Luma auto-regression coefficients.
Definition: film_grain_params.h:80
AV_PIX_FMT_VAAPI
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
Definition: pixfmt.h:119
AV1RawOBU::frame_header
AV1RawFrameHeader frame_header
Definition: cbs_av1.h:398
ff_cbs_read_extradata_from_codec
int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const AVCodecContext *avctx)
Definition: cbs.c:280
ff_thread_release_buffer
void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
Definition: pthread_frame.c:967
av1_decode_flush
static void av1_decode_flush(AVCodecContext *avctx)
Definition: av1dec.c:1398
AV_PIX_FMT_VDPAU
@ AV_PIX_FMT_VDPAU
HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface.
Definition: pixfmt.h:187
AV1RawOBU::metadata
AV1RawMetadata metadata
Definition: cbs_av1.h:402
AV1_FRAME_KEY
@ AV1_FRAME_KEY
Definition: av1.h:53
AV1RawMetadata::metadata_type
uint64_t metadata_type
Definition: cbs_av1.h:374
export_film_grain
static int export_film_grain(AVCodecContext *avctx, AVFrame *frame)
Definition: av1dec.c:985
AV1_WARP_MODEL_ROTZOOM
@ AV1_WARP_MODEL_ROTZOOM
Definition: av1.h:115
AV1_SEG_LVL_ALT_Q
@ AV1_SEG_LVL_ALT_Q
Definition: av1.h:91
AV1_OBU_PADDING
@ AV1_OBU_PADDING
Definition: av1.h:39
AVDISCARD_NONINTRA
@ AVDISCARD_NONINTRA
discard all non intra frames
Definition: defs.h:74
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:367
AVCodecContext::properties
unsigned properties
Properties of the stream that gets decoded.
Definition: avcodec.h:1872
round
static av_always_inline av_const double round(double x)
Definition: libm.h:444
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:536
AVHWAccel::decode_slice
int(* decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Callback for each slice.
Definition: avcodec.h:2186
div_lut
static const uint16_t div_lut[AV1_DIV_LUT_NUM]
< same with Div_Lut defined in spec 7.11.3.7
Definition: av1dec.c:39
AV1Frame::hwaccel_picture_private
void * hwaccel_picture_private
Definition: av1dec.h:38
AV1RawMetadata::hdr_mdcv
AV1RawMetadataHDRMDCV hdr_mdcv
Definition: cbs_av1.h:377
AV1RawTimingInfo::equal_picture_interval
uint8_t equal_picture_interval
Definition: cbs_av1.h:62
delta
float delta
Definition: vorbis_enc_data.h:430
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:484
AV1RawSequenceHeader::max_frame_width_minus_1
uint16_t max_frame_width_minus_1
Definition: cbs_av1.h:98
AV1RawSequenceHeader::color_config
AV1RawColorConfig color_config
Definition: cbs_av1.h:128
AV1RawMetadataITUTT35::payload
uint8_t * payload
Definition: cbs_av1.h:352
AVFilmGrainAOMParams::scaling_shift
int scaling_shift
Specifies the shift applied to the chroma components.
Definition: film_grain_params.h:69
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:191
av_buffer_replace
int av_buffer_replace(AVBufferRef **pdst, const AVBufferRef *src)
Ensure dst refers to the same data as src.
Definition: buffer.c:233
AVCodecContext::chroma_sample_location
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
Definition: avcodec.h:1029
AV1RawTileGroup::tg_start
uint16_t tg_start
Definition: cbs_av1.h:297
AVMasteringDisplayMetadata
Mastering display metadata capable of representing the color volume of the display used to master the...
Definition: mastering_display_metadata.h:38
FF_CODEC_CAP_SETS_PKT_DTS
#define FF_CODEC_CAP_SETS_PKT_DTS
Decoders marked with FF_CODEC_CAP_SETS_PKT_DTS want to set AVFrame.pkt_dts manually.
Definition: codec_internal.h:49
AVCodecContext::height
int height
Definition: avcodec.h:607
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:644
AV1_GM_ALPHA_PREC_BITS
@ AV1_GM_ALPHA_PREC_BITS
Definition: av1.h:106
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:644
AV1RawMetadataITUTT35::payload_ref
AVBufferRef * payload_ref
Definition: cbs_av1.h:353
AV1RawOBU::tile_group
AV1RawTileGroup tile_group
Definition: cbs_av1.h:400
AVDynamicHDRPlus
This struct represents dynamic metadata for color volume transform - application 4 of SMPTE 2094-40:2...
Definition: hdr_dynamic_metadata.h:243
AV1RawFilmGrainParams::update_grain
uint8_t update_grain
Definition: cbs_av1.h:136
avcodec.h
AV1RawTileGroup::tile_data
AV1RawTileData tile_data
Definition: cbs_av1.h:300
av_cmp_q
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
Definition: rational.h:89
av1_class
static const AVClass av1_class
Definition: av1dec.c:1426
av_dynamic_hdr_plus_create_side_data
AVDynamicHDRPlus * av_dynamic_hdr_plus_create_side_data(AVFrame *frame)
Allocate a complete AVDynamicHDRPlus and add it to the frame.
Definition: hdr_dynamic_metadata.c:49
CodedBitstreamUnit::content_ref
AVBufferRef * content_ref
If content is reference counted, a reference to the buffer containing content.
Definition: cbs.h:111
av_buffer_allocz
AVBufferRef * av_buffer_allocz(size_t size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
Definition: buffer.c:93
ret
ret
Definition: filter_design.txt:187
AV1RawColorConfig::subsampling_x
uint8_t subsampling_x
Definition: cbs_av1.h:52
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:71
AV1_OBU_TILE_LIST
@ AV1_OBU_TILE_LIST
Definition: av1.h:37
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
AV1Frame::gm_invalid
uint8_t gm_invalid[AV1_NUM_REF_FRAMES]
Definition: av1dec.h:46
AV1_PRIMARY_REF_NONE
@ AV1_PRIMARY_REF_NONE
Definition: av1.h:86
atsc_a53.h
AV1RawColorConfig::high_bitdepth
uint8_t high_bitdepth
Definition: cbs_av1.h:42
AV1RawFilmGrainParams::cr_luma_mult
uint8_t cr_luma_mult
Definition: cbs_av1.h:159
AV1RawFilmGrainParams::film_grain_params_ref_idx
uint8_t film_grain_params_ref_idx
Definition: cbs_av1.h:137
read_global_param
static void read_global_param(AV1DecContext *s, int type, int ref, int idx)
Definition: av1dec.c:93
av_fifo_alloc2
AVFifo * av_fifo_alloc2(size_t nb_elems, size_t elem_size, unsigned int flags)
Allocate and initialize an AVFifo with a given element size.
Definition: fifo.c:47
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:463
AV1_WARPEDMODEL_PREC_BITS
@ AV1_WARPEDMODEL_PREC_BITS
Definition: av1.h:111
SIZE_SPECIFIER
#define SIZE_SPECIFIER
Definition: internal.h:150
AV1_WARP_MODEL_AFFINE
@ AV1_WARP_MODEL_AFFINE
Definition: av1.h:116
AV1RawMetadataITUTT35
Definition: cbs_av1.h:348
AVCodecContext
main external API structure.
Definition: avcodec.h:435
get_shear_params_valid
static uint8_t get_shear_params_valid(AV1DecContext *s, int idx)
check if global motion params is valid.
Definition: av1dec.c:171
AVFilmGrainAOMParams::ar_coeff_lag
int ar_coeff_lag
Specifies the auto-regression lag.
Definition: film_grain_params.h:74
AV1_MAX_SEGMENTS
@ AV1_MAX_SEGMENTS
Definition: av1.h:88
av_mastering_display_metadata_create_side_data
AVMasteringDisplayMetadata * av_mastering_display_metadata_create_side_data(AVFrame *frame)
Allocate a complete AVMasteringDisplayMetadata and add it to the frame.
Definition: mastering_display_metadata.c:32
AVFilmGrainAOMParams::y_points
uint8_t y_points[14][2]
Definition: film_grain_params.h:50
CodedBitstreamUnitType
uint32_t CodedBitstreamUnitType
The codec-specific type of a bitstream unit.
Definition: cbs.h:46
AVFilmGrainAOMParams::uv_offset
int uv_offset[2]
Offset used for component scaling function.
Definition: film_grain_params.h:112
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AVHWAccel::frame_priv_data_size
int frame_priv_data_size
Size of per-frame hardware accelerator private data.
Definition: avcodec.h:2206
AV1_MAX_OPERATING_POINTS
@ AV1_MAX_OPERATING_POINTS
Definition: av1.h:73
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AV1RawFilmGrainParams::ar_coeff_lag
uint8_t ar_coeff_lag
Definition: cbs_av1.h:149
AVCodecContext::profile
int profile
profile
Definition: avcodec.h:1578
AV1RawColorConfig::mono_chrome
uint8_t mono_chrome
Definition: cbs_av1.h:44
export_metadata
static int export_metadata(AVCodecContext *avctx, AVFrame *frame)
Definition: av1dec.c:942
AVFilmGrainAOMParams::uv_mult
int uv_mult[2]
Specifies the luma/chroma multipliers for the index to the component scaling function.
Definition: film_grain_params.h:105
AV1_GM_ABS_ALPHA_BITS
@ AV1_GM_ABS_ALPHA_BITS
Definition: av1.h:105
hdr_dynamic_metadata.h
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:112
AVCodecContext::export_side_data
int export_side_data
Bit set of AV_CODEC_EXPORT_DATA_* flags, which affects the kind of metadata exported in frame,...
Definition: avcodec.h:2025
AV1RawFilmGrainParams::ar_coeffs_cb_plus_128
uint8_t ar_coeffs_cb_plus_128[25]
Definition: cbs_av1.h:151
AV1RawFilmGrainParams::ar_coeffs_y_plus_128
uint8_t ar_coeffs_y_plus_128[24]
Definition: cbs_av1.h:150
AVMasteringDisplayMetadata::min_luminance
AVRational min_luminance
Min luminance of mastering display (cd/m^2).
Definition: mastering_display_metadata.h:52
FF_CODEC_PROPERTY_CLOSED_CAPTIONS
#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS
Definition: avcodec.h:1874
ff_cbs_read_packet
int ff_cbs_read_packet(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const AVPacket *pkt)
Read the data bitstream from a packet into a fragment, then split into units and decompose.
Definition: cbs.c:289
AV1RawSequenceHeader::order_hint_bits_minus_1
uint8_t order_hint_bits_minus_1
Definition: cbs_av1.h:122
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
AV1RawTileGroup
Definition: cbs_av1.h:295
AV1RawFilmGrainParams::cr_offset
uint16_t cr_offset
Definition: cbs_av1.h:160
AV1RawFilmGrainParams::point_y_scaling
uint8_t point_y_scaling[14]
Definition: cbs_av1.h:140
AVHWAccel::start_frame
int(* start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Called at the beginning of each frame or field picture.
Definition: avcodec.h:2159
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:81
AVFilmGrainAOMParams::overlap_flag
int overlap_flag
Signals whether to overlap film grain blocks.
Definition: film_grain_params.h:117
AV1_CSP_VERTICAL
@ AV1_CSP_VERTICAL
Definition: av1.h:133
AV_PICTURE_TYPE_P
@ AV_PICTURE_TYPE_P
Predicted.
Definition: avutil.h:275
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV1RawOBU::frame
AV1RawFrame frame
Definition: cbs_av1.h:399
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
AV1RawFilmGrainParams::point_cb_scaling
uint8_t point_cb_scaling[10]
Definition: cbs_av1.h:144
AV1RawMetadataITUTT35::itu_t_t35_country_code
uint8_t itu_t_t35_country_code
Definition: cbs_av1.h:349
mastering_display_metadata.h
AV1RawFrame::tile_group
AV1RawTileGroup tile_group
Definition: cbs_av1.h:305
decode_signed_subexp_with_ref
static int32_t decode_signed_subexp_with_ref(uint32_t sub_exp, int low, int high, int r)
Definition: av1dec.c:86
AV1Frame::temporal_id
int temporal_id
Definition: av1dec.h:43
ff_cbs_init
av_cold int ff_cbs_init(CodedBitstreamContext **ctx_ptr, enum AVCodecID codec_id, void *log_ctx)
Create and initialise a new context for the given codec.
Definition: cbs.c:76
AV1RawColorConfig::twelve_bit
uint8_t twelve_bit
Definition: cbs_av1.h:43
get_pixel_format
static int get_pixel_format(AVCodecContext *avctx)
Definition: av1dec.c:437
alpha
static const int16_t alpha[]
Definition: ilbcdata.h:55
AVPacket
This structure stores compressed data.
Definition: packet.h:351
AVContentLightMetadata::MaxFALL
unsigned MaxFALL
Max average light level per frame (cd/m^2).
Definition: mastering_display_metadata.h:107
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:462
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
OFFSET
#define OFFSET(x)
Definition: av1dec.c:1418
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
av_dynamic_hdr_plus_from_t35
int av_dynamic_hdr_plus_from_t35(AVDynamicHDRPlus *s, const uint8_t *data, size_t size)
Parse the user data registered ITU-T T.35 to AVbuffer (AVDynamicHDRPlus).
Definition: hdr_dynamic_metadata.c:62
HWACCEL_VAAPI
#define HWACCEL_VAAPI(codec)
Definition: hwconfig.h:73
AV1Frame::header_ref
AVBufferRef * header_ref
Definition: av1dec.h:40
d
d
Definition: ffmpeg_filter.c:156
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:607
TileGroupInfo
Definition: av1dec.h:57
int32_t
int32_t
Definition: audioconvert.c:56
bytestream.h
bytestream2_init
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition: bytestream.h:137
AV1RawFilmGrainParams
Definition: cbs_av1.h:133
sequence_header
static int FUNC() sequence_header(CodedBitstreamContext *ctx, RWContext *rw, MPEG2RawSequenceHeader *current)
Definition: cbs_mpeg2_syntax_template.c:19
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
av_fifo_freep2
void av_fifo_freep2(AVFifo **f)
Free an AVFifo and reset pointer to NULL.
Definition: fifo.c:286
AV_CODEC_CAP_AVOID_PROBING
#define AV_CODEC_CAP_AVOID_PROBING
Decoder is not a preferred choice for probing.
Definition: codec.h:135
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
AV1Frame::coded_lossless
uint8_t coded_lossless
Definition: av1dec.h:54
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:441
AVFilmGrainAOMParams::chroma_scaling_from_luma
int chroma_scaling_from_luma
Signals whether to derive the chroma scaling function from the luma.
Definition: film_grain_params.h:56
ff_cbs_flush
av_cold void ff_cbs_flush(CodedBitstreamContext *ctx)
Reset all internal state in a context.
Definition: cbs.c:121
AV1Frame::gm_type
uint8_t gm_type[AV1_NUM_REF_FRAMES]
Definition: av1dec.h:47
AV1_DIV_LUT_BITS
@ AV1_DIV_LUT_BITS
Definition: av1.h:119
AV_FILM_GRAIN_PARAMS_AV1
@ AV_FILM_GRAIN_PARAMS_AV1
The union is valid when interpreted as AVFilmGrainAOMParams (codec.aom)
Definition: film_grain_params.h:30
AV1RawOBUHeader
Definition: cbs_av1.h:29
AVFilmGrainParams::type
enum AVFilmGrainParamsType type
Specifies the codec for which this structure is valid.
Definition: film_grain_params.h:220
av_log2
int av_log2(unsigned v)
Definition: intmath.c:26
AV1_OBU_METADATA
@ AV1_OBU_METADATA
Definition: av1.h:34
AV1RawFilmGrainParams::num_cr_points
uint8_t num_cr_points
Definition: cbs_av1.h:145
AVCodecContext::sample_aspect_ratio
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
Definition: avcodec.h:808
AV1RawMetadata::metadata
union AV1RawMetadata::@26 metadata
AV_CODEC_EXPORT_DATA_FILM_GRAIN
#define AV_CODEC_EXPORT_DATA_FILM_GRAIN
Decoding only.
Definition: avcodec.h:408
AV_FIFO_FLAG_AUTO_GROW
#define AV_FIFO_FLAG_AUTO_GROW
Automatically resize the FIFO on writes, so that the data fits.
Definition: fifo.h:67
AVFilmGrainAOMParams::ar_coeff_shift
int ar_coeff_shift
Specifies the range of the auto-regressive coefficients.
Definition: film_grain_params.h:93
AV1_REF_FRAME_LAST
@ AV1_REF_FRAME_LAST
Definition: av1.h:62
av_get_pix_fmt_name
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:2808
AVFilmGrainAOMParams::ar_coeffs_uv
int8_t ar_coeffs_uv[2][25]
Chroma auto-regression coefficients.
Definition: film_grain_params.h:86
CodedBitstreamAV1Context
Definition: cbs_av1.h:427