FFmpeg
dec.c
Go to the documentation of this file.
1 /*
2  * VVC video decoder
3  *
4  * Copyright (C) 2021 Nuo Mi
5  * Copyright (C) 2022 Xu Mu
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
24 #include "libavcodec/decode.h"
26 #include "libavcodec/hwconfig.h"
27 #include "libavcodec/profiles.h"
28 #include "libavcodec/refstruct.h"
29 #include "libavutil/cpu.h"
30 #include "libavutil/mem.h"
31 #include "libavutil/thread.h"
32 
33 #include "dec.h"
34 #include "ctu.h"
35 #include "data.h"
36 #include "refs.h"
37 #include "thread.h"
38 #include "config_components.h"
39 
40 #define TAB_MAX 32
41 
42 typedef struct Tab {
43  void **tab;
44  size_t size;
45 } Tab;
46 
47 typedef struct TabList {
49  int nb_tabs;
50 
51  int zero;
52  int realloc;
53 } TabList;
54 
55 #define TL_ADD(t, s) do { \
56  av_assert0(l->nb_tabs < TAB_MAX); \
57  l->tabs[l->nb_tabs].tab = (void**)&fc->tab.t; \
58  l->tabs[l->nb_tabs].size = sizeof(*fc->tab.t) * (s); \
59  l->nb_tabs++; \
60 } while (0)
61 
62 static void tl_init(TabList *l, const int zero, const int realloc)
63 {
64  l->nb_tabs = 0;
65  l->zero = zero;
66  l->realloc = realloc;
67 }
68 
69 static int tl_free(TabList *l)
70 {
71  for (int i = 0; i < l->nb_tabs; i++)
72  av_freep(l->tabs[i].tab);
73 
74  return 0;
75 }
76 
77 static int tl_create(TabList *l)
78 {
79  if (l->realloc) {
80  tl_free(l);
81 
82  for (int i = 0; i < l->nb_tabs; i++) {
83  Tab *t = l->tabs + i;
84  *t->tab = l->zero ? av_mallocz(t->size) : av_malloc(t->size);
85  if (!*t->tab)
86  return AVERROR(ENOMEM);
87  }
88  }
89  return 0;
90 }
91 
92 static int tl_zero(TabList *l)
93 {
94  if (l->zero) {
95  for (int i = 0; i < l->nb_tabs; i++) {
96  Tab *t = l->tabs + i;
97  memset(*t->tab, 0, t->size);
98  }
99  }
100  return 0;
101 }
102 
104 {
105  const VVCSPS *sps = fc->ps.sps;
106  const VVCPPS *pps = fc->ps.pps;
107  const int ctu_size = sps ? (1 << sps->ctb_log2_size_y << sps->ctb_log2_size_y) : 0;
108  const int ctu_count = pps ? pps->ctb_count : 0;
109  const int changed = fc->tab.sz.ctu_count != ctu_count || fc->tab.sz.ctu_size != ctu_size;
110 
111  tl_init(l, 0, changed);
112 
113  TL_ADD(cus, ctu_count);
114  TL_ADD(ctus, ctu_count);
115  TL_ADD(deblock, ctu_count);
116  TL_ADD(sao, ctu_count);
117  TL_ADD(alf, ctu_count);
118  TL_ADD(slice_idx, ctu_count);
119  TL_ADD(coeffs, ctu_count * ctu_size * VVC_MAX_SAMPLE_ARRAYS);
120 }
121 
123 {
124  const VVCPPS *pps = fc->ps.pps;
125  const int pic_size_in_min_cb = pps ? pps->min_cb_width * pps->min_cb_height : 0;
126  const int changed = fc->tab.sz.pic_size_in_min_cb != pic_size_in_min_cb;
127 
128  tl_init(l, 1, changed);
129 
130  TL_ADD(imf, pic_size_in_min_cb);
131 
132  for (int i = LUMA; i <= CHROMA; i++)
133  TL_ADD(cb_width[i], pic_size_in_min_cb); //is_a0_available requires this
134 }
135 
137 {
138  const VVCPPS *pps = fc->ps.pps;
139  const int pic_size_in_min_cb = pps ? pps->min_cb_width * pps->min_cb_height : 0;
140  const int changed = fc->tab.sz.pic_size_in_min_cb != pic_size_in_min_cb;
141 
142  tl_init(l, 0, changed);
143 
144  TL_ADD(skip, pic_size_in_min_cb);
145  TL_ADD(ipm, pic_size_in_min_cb);
146 
147  for (int i = LUMA; i <= CHROMA; i++) {
148  TL_ADD(cqt_depth[i], pic_size_in_min_cb);
149  TL_ADD(cb_pos_x[i], pic_size_in_min_cb);
150  TL_ADD(cb_pos_y[i], pic_size_in_min_cb);
151  TL_ADD(cb_height[i], pic_size_in_min_cb);
152  TL_ADD(cp_mv[i], pic_size_in_min_cb * MAX_CONTROL_POINTS);
153  TL_ADD(cpm[i], pic_size_in_min_cb);
154  TL_ADD(pcmf[i], pic_size_in_min_cb);
155  }
156  // For luma, qp can only change at the CU level, so the qp tab size is related to the CU.
157  TL_ADD(qp[LUMA], pic_size_in_min_cb);
158 }
159 
161 {
162  const VVCPPS *pps = fc->ps.pps;
163  const int pic_size_in_min_pu = pps ? pps->min_pu_width * pps->min_pu_height : 0;
164  const int changed = fc->tab.sz.pic_size_in_min_pu != pic_size_in_min_pu;
165 
166  tl_init(l, 1, changed);
167 
168  TL_ADD(iaf, pic_size_in_min_pu);
169 }
170 
172 {
173  const VVCPPS *pps = fc->ps.pps;
174  const int pic_size_in_min_pu = pps ? pps->min_pu_width * pps->min_pu_height : 0;
175  const int changed = fc->tab.sz.pic_size_in_min_pu != pic_size_in_min_pu;
176 
177  tl_init(l, 0, changed);
178 
179  TL_ADD(msf, pic_size_in_min_pu);
180  TL_ADD(mmi, pic_size_in_min_pu);
181  TL_ADD(mvf, pic_size_in_min_pu);
182 }
183 
185 {
186  const VVCPPS *pps = fc->ps.pps;
187  const int pic_size_in_min_tu = pps ? pps->min_tu_width * pps->min_tu_height : 0;
188  const int changed = fc->tab.sz.pic_size_in_min_tu != pic_size_in_min_tu;
189 
190  tl_init(l, 1, changed);
191 
192  TL_ADD(tu_joint_cbcr_residual_flag, pic_size_in_min_tu);
193 
194  for (int i = 0; i < VVC_MAX_SAMPLE_ARRAYS; i++) {
195  TL_ADD(tu_coded_flag[i], pic_size_in_min_tu);
196 
197  for (int vertical = 0; vertical < 2; vertical++)
198  TL_ADD(bs[vertical][i], pic_size_in_min_tu);
199  }
200 }
201 
203 {
204  const VVCPPS *pps = fc->ps.pps;
205  const int pic_size_in_min_tu = pps ? pps->min_tu_width * pps->min_tu_height : 0;
206  const int changed = fc->tab.sz.pic_size_in_min_tu != pic_size_in_min_tu;
207 
208  tl_init(l, 0, changed);
209 
210  for (int i = LUMA; i <= CHROMA; i++) {
211  TL_ADD(tb_width[i], pic_size_in_min_tu);
212  TL_ADD(tb_height[i], pic_size_in_min_tu);
213  }
214 
215  for (int vertical = 0; vertical < 2; vertical++) {
216  TL_ADD(max_len_p[vertical], pic_size_in_min_tu);
217  TL_ADD(max_len_q[vertical], pic_size_in_min_tu);
218  }
219 
220  // For chroma, considering the joint CbCr, the QP tab size is related to the TU.
221  for (int i = CB; i < VVC_MAX_SAMPLE_ARRAYS; i++)
222  TL_ADD(qp[i], pic_size_in_min_tu);
223 }
224 
226 {
227  const VVCSPS *sps = fc->ps.sps;
228  const VVCPPS *pps = fc->ps.pps;
229  const int width = pps ? pps->width : 0;
230  const int height = pps ? pps->height : 0;
231  const int ctu_width = pps ? pps->ctb_width : 0;
232  const int ctu_height = pps ? pps->ctb_height : 0;
233  const int chroma_idc = sps ? sps->r->sps_chroma_format_idc : 0;
234  const int ps = sps ? sps->pixel_shift : 0;
235  const int c_end = chroma_idc ? VVC_MAX_SAMPLE_ARRAYS : 1;
236  const int changed = fc->tab.sz.chroma_format_idc != chroma_idc ||
237  fc->tab.sz.width != width || fc->tab.sz.height != height ||
238  fc->tab.sz.ctu_width != ctu_width || fc->tab.sz.ctu_height != ctu_height ||
239  fc->tab.sz.pixel_shift != ps;
240 
241  tl_init(l, 0, changed);
242 
243  for (int c_idx = 0; c_idx < c_end; c_idx++) {
244  const int w = width >> (sps ? sps->hshift[c_idx] : 0);
245  const int h = height >> (sps ? sps->vshift[c_idx] : 0);
246  TL_ADD(sao_pixel_buffer_h[c_idx], (w * 2 * ctu_height) << ps);
247  TL_ADD(sao_pixel_buffer_v[c_idx], (h * 2 * ctu_width) << ps);
248  }
249 
250  for (int c_idx = 0; c_idx < c_end; c_idx++) {
251  const int w = width >> (sps ? sps->hshift[c_idx] : 0);
252  const int h = height >> (sps ? sps->vshift[c_idx] : 0);
253  const int border_pixels = c_idx ? ALF_BORDER_CHROMA : ALF_BORDER_LUMA;
254  for (int i = 0; i < 2; i++) {
255  TL_ADD(alf_pixel_buffer_h[c_idx][i], (w * border_pixels * ctu_height) << ps);
256  TL_ADD(alf_pixel_buffer_v[c_idx][i], h * ALF_PADDING_SIZE * ctu_width);
257  }
258  }
259 }
260 
262 {
263  const VVCPPS *pps = fc->ps.pps;
264  const int w32 = pps ? AV_CEIL_RSHIFT(pps->width, 5) : 0;
265  const int h32 = pps ? AV_CEIL_RSHIFT(pps->height, 5) : 0;
266  const int changed = AV_CEIL_RSHIFT(fc->tab.sz.width, 5) != w32 ||
267  AV_CEIL_RSHIFT(fc->tab.sz.height, 5) != h32;
268 
269  tl_init(l, 1, changed);
270 
271  for (int i = LUMA; i <= CHROMA; i++)
272  TL_ADD(msm[i], w32 * h32);
273 }
274 
276 {
277  const VVCPPS *pps = fc->ps.pps;
278  const int w64 = pps ? AV_CEIL_RSHIFT(pps->width, 6) : 0;
279  const int h64 = pps ? AV_CEIL_RSHIFT(pps->height, 6) : 0;
280  const int changed = AV_CEIL_RSHIFT(fc->tab.sz.width, 6) != w64 ||
281  AV_CEIL_RSHIFT(fc->tab.sz.height, 6) != h64;
282 
283  tl_init(l, 1, changed);
284 
285  TL_ADD(ispmf, w64 * h64);
286 }
287 
289 {
290  const VVCSPS *sps = fc->ps.sps;
291  const VVCPPS *pps = fc->ps.pps;
292  const int ctu_height = pps ? pps->ctb_height : 0;
293  const int ctu_size = sps ? sps->ctb_size_y : 0;
294  const int ps = sps ? sps->pixel_shift : 0;
295  const int chroma_idc = sps ? sps->r->sps_chroma_format_idc : 0;
296  const int has_ibc = sps ? sps->r->sps_ibc_enabled_flag : 0;
297  const int changed = fc->tab.sz.chroma_format_idc != chroma_idc ||
298  fc->tab.sz.ctu_height != ctu_height ||
299  fc->tab.sz.ctu_size != ctu_size ||
300  fc->tab.sz.pixel_shift != ps;
301 
302  fc->tab.sz.ibc_buffer_width = ctu_size ? 2 * MAX_CTU_SIZE * MAX_CTU_SIZE / ctu_size : 0;
303 
304  tl_init(l, has_ibc, changed);
305 
306  for (int i = LUMA; i < VVC_MAX_SAMPLE_ARRAYS; i++) {
307  const int hs = sps ? sps->hshift[i] : 0;
308  const int vs = sps ? sps->vshift[i] : 0;
309  TL_ADD(ibc_vir_buf[i], fc->tab.sz.ibc_buffer_width * ctu_size * ctu_height << ps >> hs >> vs);
310  }
311 }
312 
313 typedef void (*tl_init_fn)(TabList *l, VVCFrameContext *fc);
314 
315 static int frame_context_for_each_tl(VVCFrameContext *fc, int (*unary_fn)(TabList *l))
316 {
317  const tl_init_fn init[] = {
326  msm_tl_init,
328  ibc_tl_init,
329  };
330 
331  for (int i = 0; i < FF_ARRAY_ELEMS(init); i++) {
332  TabList l;
333  int ret;
334 
335  init[i](&l, fc);
336  ret = unary_fn(&l);
337  if (ret < 0)
338  return ret;
339  }
340  return 0;
341 }
342 
344 {
345  if (fc->tab.cus) {
346  for (int i = 0; i < fc->tab.sz.ctu_count; i++)
347  ff_vvc_ctu_free_cus(fc->tab.cus + i);
348  }
349 }
350 
352 {
353  free_cus(fc);
355  ff_refstruct_pool_uninit(&fc->rpl_tab_pool);
356  ff_refstruct_pool_uninit(&fc->tab_dmvr_mvf_pool);
357 
358  memset(&fc->tab.sz, 0, sizeof(fc->tab.sz));
359 }
360 
362 {
363  const VVCSPS *sps = fc->ps.sps;
364  const VVCPPS *pps = fc->ps.pps;
365  const int ctu_count = pps->ctb_count;
366  const int pic_size_in_min_pu = pps->min_pu_width * pps->min_pu_height;
367  int ret;
368 
369  free_cus(fc);
370 
372  if (ret < 0)
373  return ret;
374 
375  // for error handling case, we may call free_cus before VVC_TASK_STAGE_INIT, so we need to set cus to 0 here
376  memset(fc->tab.cus, 0, sizeof(*fc->tab.cus) * ctu_count);
377 
378  memset(fc->tab.slice_idx, -1, sizeof(*fc->tab.slice_idx) * ctu_count);
379 
380  if (fc->tab.sz.ctu_count != ctu_count) {
381  ff_refstruct_pool_uninit(&fc->rpl_tab_pool);
382  fc->rpl_tab_pool = ff_refstruct_pool_alloc(ctu_count * sizeof(RefPicListTab), 0);
383  if (!fc->rpl_tab_pool)
384  return AVERROR(ENOMEM);
385  }
386 
387  if (fc->tab.sz.pic_size_in_min_pu != pic_size_in_min_pu) {
388  ff_refstruct_pool_uninit(&fc->tab_dmvr_mvf_pool);
389  fc->tab_dmvr_mvf_pool = ff_refstruct_pool_alloc(
390  pic_size_in_min_pu * sizeof(MvField), FF_REFSTRUCT_POOL_FLAG_ZERO_EVERY_TIME);
391  if (!fc->tab_dmvr_mvf_pool)
392  return AVERROR(ENOMEM);
393  }
394 
395  fc->tab.sz.ctu_count = pps->ctb_count;
396  fc->tab.sz.ctu_size = 1 << sps->ctb_log2_size_y << sps->ctb_log2_size_y;
397  fc->tab.sz.pic_size_in_min_cb = pps->min_cb_width * pps->min_cb_height;
398  fc->tab.sz.pic_size_in_min_pu = pic_size_in_min_pu;
399  fc->tab.sz.pic_size_in_min_tu = pps->min_tu_width * pps->min_tu_height;
400  fc->tab.sz.width = pps->width;
401  fc->tab.sz.height = pps->height;
402  fc->tab.sz.ctu_width = pps->ctb_width;
403  fc->tab.sz.ctu_height = pps->ctb_height;
404  fc->tab.sz.chroma_format_idc = sps->r->sps_chroma_format_idc;
405  fc->tab.sz.pixel_shift = sps->pixel_shift;
406 
407  return 0;
408 }
409 
411 {
413 }
414 
415 static int min_positive(const int idx, const int diff, const int min_diff)
416 {
417  return diff > 0 && (idx < 0 || diff < min_diff);
418 }
419 
420 static int max_negtive(const int idx, const int diff, const int max_diff)
421 {
422  return diff < 0 && (idx < 0 || diff > max_diff);
423 }
424 
425 typedef int (*smvd_find_fxn)(const int idx, const int diff, const int old_diff);
426 
427 static int8_t smvd_find(const VVCFrameContext *fc, const SliceContext *sc, int lx, smvd_find_fxn find)
428 {
429  const H266RawSliceHeader *rsh = sc->sh.r;
430  const RefPicList *rpl = sc->rpl + lx;
431  const int poc = fc->ref->poc;
432  int8_t idx = -1;
433  int old_diff = -1;
434  for (int i = 0; i < rsh->num_ref_idx_active[lx]; i++) {
435  if (!rpl->refs[i].is_lt) {
436  int diff = poc - rpl->refs[i].poc;
437  if (find(idx, diff, old_diff)) {
438  idx = i;
439  old_diff = diff;
440  }
441  }
442  }
443  return idx;
444 }
445 
446 static void smvd_ref_idx(const VVCFrameContext *fc, SliceContext *sc)
447 {
448  VVCSH *sh = &sc->sh;
449  if (IS_B(sh->r)) {
450  sh->ref_idx_sym[0] = smvd_find(fc, sc, 0, min_positive);
451  sh->ref_idx_sym[1] = smvd_find(fc, sc, 1, max_negtive);
452  if (sh->ref_idx_sym[0] == -1 || sh->ref_idx_sym[1] == -1) {
453  sh->ref_idx_sym[0] = smvd_find(fc, sc, 0, max_negtive);
454  sh->ref_idx_sym[1] = smvd_find(fc, sc, 1, min_positive);
455  }
456  }
457 }
458 
459 static void eps_free(SliceContext *slice)
460 {
461  av_freep(&slice->eps);
462  slice->nb_eps = 0;
463 }
464 
466 {
467  if (fc->slices) {
468  for (int i = 0; i < fc->nb_slices_allocated; i++) {
469  SliceContext *slice = fc->slices[i];
470  if (slice) {
471  ff_refstruct_unref(&slice->ref);
472  ff_refstruct_unref(&slice->sh.r);
473  eps_free(slice);
474  av_free(slice);
475  }
476  }
477  av_freep(&fc->slices);
478  }
479  fc->nb_slices_allocated = 0;
480  fc->nb_slices = 0;
481 }
482 
484 {
485  void *p;
486  const int size = (fc->nb_slices_allocated + 1) * 3 / 2;
487 
488  if (fc->nb_slices < fc->nb_slices_allocated)
489  return 0;
490 
491  p = av_realloc_array(fc->slices, size, sizeof(*fc->slices));
492  if (!p)
493  return AVERROR(ENOMEM);
494 
495  fc->slices = p;
496  for (int i = fc->nb_slices_allocated; i < size; i++) {
497  fc->slices[i] = av_mallocz(sizeof(*fc->slices[0]));
498  if (!fc->slices[i]) {
499  fc->nb_slices_allocated = i;
500  return AVERROR(ENOMEM);
501  }
502  fc->slices[i]->slice_idx = i;
503  }
504  fc->nb_slices_allocated = size;
505 
506  return 0;
507 }
508 
509 static int ep_init_cabac_decoder(SliceContext *sc, const int index,
510  const H2645NAL *nal, GetBitContext *gb, const CodedBitstreamUnit *unit)
511 {
512  const H266RawSlice *slice = unit->content_ref;
513  const H266RawSliceHeader *rsh = sc->sh.r;
514  EntryPoint *ep = sc->eps + index;
515  int size;
516  int ret;
517 
518  if (index < rsh->num_entry_points) {
519  int skipped = 0;
520  int64_t start = (gb->index >> 3);
521  int64_t end = start + rsh->sh_entry_point_offset_minus1[index] + 1;
522  while (skipped < nal->skipped_bytes && nal->skipped_bytes_pos[skipped] <= start + slice->header_size) {
523  skipped++;
524  }
525  while (skipped < nal->skipped_bytes && nal->skipped_bytes_pos[skipped] <= end + slice->header_size) {
526  end--;
527  skipped++;
528  }
529  size = end - start;
530  size = av_clip(size, 0, get_bits_left(gb) / 8);
531  } else {
532  size = get_bits_left(gb) / 8;
533  }
534  av_assert0(gb->buffer + get_bits_count(gb) / 8 + size <= gb->buffer_end);
535  ret = ff_init_cabac_decoder (&ep->cc, gb->buffer + get_bits_count(gb) / 8, size);
536  if (ret < 0)
537  return ret;
538  skip_bits(gb, size * 8);
539  return 0;
540 }
541 
543  VVCFrameContext *fc, const H2645NAL *nal, const CodedBitstreamUnit *unit)
544 {
545  const VVCSH *sh = &sc->sh;
546  const H266RawSlice *slice = unit->content_ref;
547  int nb_eps = sh->r->num_entry_points + 1;
548  int ctu_addr = 0;
549  GetBitContext gb;
550  int ret;
551 
552  if (sc->nb_eps != nb_eps) {
553  eps_free(sc);
554  sc->eps = av_calloc(nb_eps, sizeof(*sc->eps));
555  if (!sc->eps)
556  return AVERROR(ENOMEM);
557  sc->nb_eps = nb_eps;
558  }
559 
560  ret = init_get_bits8(&gb, slice->data, slice->data_size);
561  if (ret < 0)
562  return ret;
563  for (int i = 0; i < sc->nb_eps; i++)
564  {
565  EntryPoint *ep = sc->eps + i;
566 
567  ep->ctu_start = ctu_addr;
568  ep->ctu_end = (i + 1 == sc->nb_eps ? sh->num_ctus_in_curr_slice : sh->entry_point_start_ctu[i]);
569 
570  for (int j = ep->ctu_start; j < ep->ctu_end; j++) {
571  const int rs = sc->sh.ctb_addr_in_curr_slice[j];
572  fc->tab.slice_idx[rs] = sc->slice_idx;
573  }
574 
575  ret = ep_init_cabac_decoder(sc, i, nal, &gb, unit);
576  if (ret < 0)
577  return ret;
578 
579  if (i + 1 < sc->nb_eps)
580  ctu_addr = sh->entry_point_start_ctu[i];
581  }
582 
583  return 0;
584 }
585 
587 {
588  const int size = s->nb_fcs;
589  const int idx = (fc - s->fcs + delta + size) % size;
590  return s->fcs + idx;
591 }
592 
593 static int ref_frame(VVCFrame *dst, const VVCFrame *src)
594 {
595  int ret;
596 
597  ret = av_frame_ref(dst->frame, src->frame);
598  if (ret < 0)
599  return ret;
600 
601  ff_refstruct_replace(&dst->sps, src->sps);
602  ff_refstruct_replace(&dst->pps, src->pps);
603 
604  ff_refstruct_replace(&dst->progress, src->progress);
605 
606  ff_refstruct_replace(&dst->tab_dmvr_mvf, src->tab_dmvr_mvf);
607 
608  ff_refstruct_replace(&dst->rpl_tab, src->rpl_tab);
609  ff_refstruct_replace(&dst->rpl, src->rpl);
610  ff_refstruct_replace(&dst->hwaccel_picture_private,
611  src->hwaccel_picture_private);
612  dst->nb_rpl_elems = src->nb_rpl_elems;
613 
614  dst->poc = src->poc;
615  dst->ctb_count = src->ctb_count;
616 
617  dst->scaling_win = src->scaling_win;
618  dst->ref_width = src->ref_width;
619  dst->ref_height = src->ref_height;
620 
621  dst->flags = src->flags;
622  dst->sequence = src->sequence;
623 
624  return 0;
625 }
626 
628 {
629  slices_free(fc);
630 
631  ff_refstruct_pool_uninit(&fc->tu_pool);
632  ff_refstruct_pool_uninit(&fc->cu_pool);
633 
634  for (int i = 0; i < FF_ARRAY_ELEMS(fc->DPB); i++) {
635  ff_vvc_unref_frame(fc, &fc->DPB[i], ~0);
636  av_frame_free(&fc->DPB[i].frame);
637  }
638 
641  av_frame_free(&fc->output_frame);
642  ff_vvc_frame_ps_free(&fc->ps);
643 }
644 
646 {
647 
648  fc->log_ctx = avctx;
649 
650  fc->output_frame = av_frame_alloc();
651  if (!fc->output_frame)
652  return AVERROR(ENOMEM);
653 
654  for (int j = 0; j < FF_ARRAY_ELEMS(fc->DPB); j++) {
655  fc->DPB[j].frame = av_frame_alloc();
656  if (!fc->DPB[j].frame)
657  return AVERROR(ENOMEM);
658  }
659  fc->cu_pool = ff_refstruct_pool_alloc(sizeof(CodingUnit), 0);
660  if (!fc->cu_pool)
661  return AVERROR(ENOMEM);
662 
663  fc->tu_pool = ff_refstruct_pool_alloc(sizeof(TransformUnit), 0);
664  if (!fc->tu_pool)
665  return AVERROR(ENOMEM);
666 
667  return 0;
668 }
669 
671 {
672  int ret;
673 
674  fc->ref = NULL;
675 
676  // copy refs from the last frame
677  if (s->nb_frames && s->nb_fcs > 1) {
678  VVCFrameContext *prev = get_frame_context(s, fc, -1);
679  for (int i = 0; i < FF_ARRAY_ELEMS(fc->DPB); i++) {
680  ff_vvc_unref_frame(fc, &fc->DPB[i], ~0);
681  if (prev->DPB[i].frame->buf[0]) {
682  ret = ref_frame(&fc->DPB[i], &prev->DPB[i]);
683  if (ret < 0)
684  return ret;
685  }
686  }
687  }
688 
689  if (IS_IDR(s)) {
690  s->seq_decode = (s->seq_decode + 1) & 0xff;
692  }
693 
694  ret = pic_arrays_init(s, fc);
695  if (ret < 0)
696  return ret;
697  ff_vvc_dsp_init(&fc->vvcdsp, fc->ps.sps->bit_depth);
698  ff_videodsp_init(&fc->vdsp, fc->ps.sps->bit_depth);
699  return 0;
700 }
701 
703 {
704  const VVCPH *ph = &fc->ps.ph;
705  const H266RawSliceHeader *rsh = sc->sh.r;
706  int ret;
707 
708  // 8.3.1 Decoding process for picture order count
709  if (!s->temporal_id && !ph->r->ph_non_ref_pic_flag && !(IS_RASL(s) || IS_RADL(s)))
710  s->poc_tid0 = ph->poc;
711 
712  if ((ret = ff_vvc_set_new_ref(s, fc, &fc->frame)) < 0)
713  goto fail;
714 
715  if (!IS_IDR(s))
717 
718  av_frame_unref(fc->output_frame);
719 
720  if ((ret = ff_vvc_output_frame(s, fc, fc->output_frame,rsh->sh_no_output_of_prior_pics_flag, 0)) < 0)
721  goto fail;
722 
723  if ((ret = ff_vvc_frame_rpl(s, fc, sc)) < 0)
724  goto fail;
725 
726  if ((ret = ff_vvc_frame_thread_init(fc)) < 0)
727  goto fail;
728  return 0;
729 fail:
730  if (fc->ref)
731  ff_vvc_unref_frame(fc, fc->ref, ~0);
732  fc->ref = NULL;
733  return ret;
734 }
735 
737  const CodedBitstreamUnit *unit, const int is_first_slice)
738 {
739  VVCSH *sh = &sc->sh;
740  int ret;
741 
742  ret = ff_vvc_decode_sh(sh, &fc->ps, unit);
743  if (ret < 0)
744  return ret;
745 
746  ff_refstruct_replace(&sc->ref, unit->content_ref);
747 
748  if (is_first_slice) {
749  ret = frame_start(s, fc, sc);
750  if (ret < 0)
751  return ret;
752  } else if (fc->ref) {
753  if (!IS_I(sh->r)) {
754  ret = ff_vvc_slice_rpl(s, fc, sc);
755  if (ret < 0) {
756  av_log(fc->log_ctx, AV_LOG_WARNING,
757  "Error constructing the reference lists for the current slice.\n");
758  return ret;
759  }
760  }
761  } else {
762  av_log(fc->log_ctx, AV_LOG_ERROR, "First slice in a frame missing.\n");
763  return ret;
764  }
765 
766  if (!IS_I(sh->r))
767  smvd_ref_idx(fc, sc);
768 
769  return 0;
770 }
771 
772 static enum AVPixelFormat get_format(AVCodecContext *avctx, const VVCSPS *sps)
773 {
774 #define HWACCEL_MAX CONFIG_VVC_VAAPI_HWACCEL
775 
776  enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts;
777 
778  switch (sps->pix_fmt) {
779  case AV_PIX_FMT_YUV420P:
780 #if CONFIG_VVC_VAAPI_HWACCEL
781  *fmt++ = AV_PIX_FMT_VAAPI;
782 #endif
783  break;
785 #if CONFIG_VVC_VAAPI_HWACCEL
786  *fmt++ = AV_PIX_FMT_VAAPI;
787 #endif
788  break;
789  }
790 
791  *fmt++ = sps->pix_fmt;
792  *fmt = AV_PIX_FMT_NONE;
793 
794  return ff_get_format(avctx, pix_fmts);
795 }
796 
798 {
799  AVCodecContext *c = s->avctx;
800  const VVCSPS *sps = fc->ps.sps;
801  const VVCPPS *pps = fc->ps.pps;
802  int ret;
803 
804  // Reset HW config if pix_fmt/w/h change.
805  if (s->pix_fmt != sps->pix_fmt || c->coded_width != pps->width || c->coded_height != pps->height) {
806  c->coded_width = pps->width;
807  c->coded_height = pps->height;
808  ret = get_format(c, sps);
809  if (ret < 0)
810  return ret;
811 
812  c->pix_fmt = ret;
813  s->pix_fmt = sps->pix_fmt;
814  }
815 
816  c->width = pps->width - ((pps->r->pps_conf_win_left_offset + pps->r->pps_conf_win_right_offset) << sps->hshift[CHROMA]);
817  c->height = pps->height - ((pps->r->pps_conf_win_top_offset + pps->r->pps_conf_win_bottom_offset) << sps->vshift[CHROMA]);
818  c->has_b_frames = sps->r->sps_dpb_params.dpb_max_num_reorder_pics[sps->r->sps_max_sublayers_minus1];
819 
820  return 0;
821 }
822 
824 {
825  int ret = ff_vvc_decode_frame_ps(&fc->ps, s);
826  if (ret < 0)
827  return ret;
828 
830  if (ret < 0)
831  return ret;
832 
834  if (ret < 0)
835  return ret;
836 
837  return 0;
838 }
839 
840 static int decode_slice(VVCContext *s, VVCFrameContext *fc, const H2645NAL *nal, const CodedBitstreamUnit *unit)
841 {
842  int ret;
843  SliceContext *sc;
844  const int is_first_slice = !fc->nb_slices;
845 
846  ret = slices_realloc(fc);
847  if (ret < 0)
848  return ret;
849 
850  sc = fc->slices[fc->nb_slices];
851 
852  s->vcl_unit_type = nal->type;
853  if (is_first_slice) {
854  ret = frame_setup(fc, s);
855  if (ret < 0)
856  return ret;
857  }
858 
859  ret = slice_start(sc, s, fc, unit, is_first_slice);
860  if (ret < 0)
861  return ret;
862 
863  ret = slice_init_entry_points(sc, fc, nal, unit);
864  if (ret < 0)
865  return ret;
866 
867  if (s->avctx->hwaccel) {
868  if (is_first_slice) {
869  ret = FF_HW_CALL(s->avctx, start_frame, NULL, 0);
870  if (ret < 0)
871  return ret;
872  }
873 
874  ret = FF_HW_CALL(s->avctx, decode_slice,
875  nal->raw_data, nal->raw_size);
876  if (ret < 0)
877  return ret;
878  }
879 
880  fc->nb_slices++;
881 
882  return 0;
883 }
884 
886 {
887  int ret;
888 
889  s->temporal_id = nal->temporal_id;
890 
891  if (nal->nuh_layer_id > 0) {
893  "Decoding of multilayer bitstreams");
894  return AVERROR_PATCHWELCOME;
895  }
896 
897  switch (unit->type) {
898  case VVC_VPS_NUT:
899  case VVC_SPS_NUT:
900  case VVC_PPS_NUT:
901  /* vps, sps, sps cached by s->cbc */
902  break;
903  case VVC_TRAIL_NUT:
904  case VVC_STSA_NUT:
905  case VVC_RADL_NUT:
906  case VVC_RASL_NUT:
907  case VVC_IDR_W_RADL:
908  case VVC_IDR_N_LP:
909  case VVC_CRA_NUT:
910  case VVC_GDR_NUT:
911  ret = decode_slice(s, fc, nal, unit);
912  if (ret < 0)
913  return ret;
914  break;
915  case VVC_PREFIX_APS_NUT:
916  case VVC_SUFFIX_APS_NUT:
917  ret = ff_vvc_decode_aps(&s->ps, unit);
918  if (ret < 0)
919  return ret;
920  break;
921  }
922 
923  return 0;
924 }
925 
927 {
928  const CodedBitstreamH266Context *h266 = s->cbc->priv_data;
929  CodedBitstreamFragment *frame = &s->current_frame;
930  int ret = 0;
931  s->last_eos = s->eos;
932  s->eos = 0;
933 
935  ret = ff_cbs_read_packet(s->cbc, frame, avpkt);
936  if (ret < 0) {
937  av_log(s->avctx, AV_LOG_ERROR, "Failed to read packet.\n");
938  return ret;
939  }
940  /* decode the NAL units */
941  for (int i = 0; i < frame->nb_units; i++) {
942  const H2645NAL *nal = h266->common.read_packet.nals + i;
943  const CodedBitstreamUnit *unit = frame->units + i;
944 
945  if (unit->type == VVC_EOB_NUT || unit->type == VVC_EOS_NUT) {
946  s->last_eos = 1;
947  } else {
948  ret = decode_nal_unit(s, fc, nal, unit);
949  if (ret < 0) {
950  av_log(s->avctx, AV_LOG_WARNING,
951  "Error parsing NAL unit #%d.\n", i);
952  goto fail;
953  }
954  }
955  }
956  return 0;
957 
958 fail:
959  if (fc->ref)
961  return ret;
962 }
963 
964 static int set_output_format(const VVCContext *s, const AVFrame *output)
965 {
966  AVCodecContext *c = s->avctx;
967  int ret;
968 
969  if (output->width != c->width || output->height != c->height) {
970  if ((ret = ff_set_dimensions(c, output->width, output->height)) < 0)
971  return ret;
972  }
973  c->pix_fmt = output->format;
974  return 0;
975 }
976 
977 static int wait_delayed_frame(VVCContext *s, AVFrame *output, int *got_output)
978 {
979  VVCFrameContext *delayed = get_frame_context(s, s->fcs, s->nb_frames - s->nb_delayed);
980  int ret = ff_vvc_frame_wait(s, delayed);
981 
982  if (!ret && delayed->output_frame->buf[0] && output) {
985  if (!ret)
986  *got_output = 1;
987  }
988  s->nb_delayed--;
989 
990  return ret;
991 }
992 
993 static int submit_frame(VVCContext *s, VVCFrameContext *fc, AVFrame *output, int *got_output)
994 {
995  int ret;
996 
997  if (s->avctx->hwaccel) {
998  if (ret = FF_HW_SIMPLE_CALL(s->avctx, end_frame) < 0) {
999  av_log(s->avctx, AV_LOG_ERROR,
1000  "Hardware accelerator failed to decode picture\n");
1001  ff_vvc_unref_frame(fc, fc->ref, ~0);
1002  return ret;
1003  }
1004  } else {
1005  if (ret = ff_vvc_frame_submit(s, fc) < 0) {
1007  return ret;
1008  }
1009  }
1010 
1011  s->nb_frames++;
1012  s->nb_delayed++;
1013 
1014  if (s->nb_delayed >= s->nb_fcs || s->avctx->hwaccel) {
1015  if ((ret = wait_delayed_frame(s, output, got_output)) < 0)
1016  return ret;
1017  }
1018  return 0;
1019 }
1020 
1021 static int get_decoded_frame(VVCContext *s, AVFrame *output, int *got_output)
1022 {
1023  int ret;
1024  while (s->nb_delayed) {
1025  if ((ret = wait_delayed_frame(s, output, got_output)) < 0)
1026  return ret;
1027  if (*got_output)
1028  return 0;
1029  }
1030  if (s->nb_frames) {
1031  //we still have frames cached in dpb.
1032  VVCFrameContext *last = get_frame_context(s, s->fcs, s->nb_frames - 1);
1033 
1034  ret = ff_vvc_output_frame(s, last, output, 0, 1);
1035  if (ret < 0)
1036  return ret;
1037  if (ret) {
1038  *got_output = ret;
1039  if ((ret = set_output_format(s, output)) < 0)
1040  return ret;
1041  }
1042  }
1043  return 0;
1044 }
1045 
1047  int *got_output, AVPacket *avpkt)
1048 {
1049  VVCContext *s = avctx->priv_data;
1051  int ret;
1052 
1053  if (!avpkt->size)
1054  return get_decoded_frame(s, output, got_output);
1055 
1056  fc = get_frame_context(s, s->fcs, s->nb_frames);
1057 
1058  fc->nb_slices = 0;
1059  fc->decode_order = s->nb_frames;
1060 
1061  ret = decode_nal_units(s, fc, avpkt);
1062  if (ret < 0)
1063  return ret;
1064 
1065  if (!fc->ft || !fc->ref)
1066  return avpkt->size;
1067 
1068  ret = submit_frame(s, fc, output, got_output);
1069  if (ret < 0)
1070  return ret;
1071 
1072  return avpkt->size;
1073 }
1074 
1076 {
1077  VVCContext *s = avctx->priv_data;
1078  int got_output = 0;
1079 
1080  while (s->nb_delayed)
1081  wait_delayed_frame(s, NULL, &got_output);
1082 
1083  if (s->fcs) {
1084  VVCFrameContext *last = get_frame_context(s, s->fcs, s->nb_frames - 1);
1085  ff_vvc_flush_dpb(last);
1086  }
1087 
1088  s->ps.sps_id_used = 0;
1089 
1090  s->eos = 1;
1091 }
1092 
1094 {
1095  VVCContext *s = avctx->priv_data;
1096 
1097  ff_cbs_fragment_free(&s->current_frame);
1098  vvc_decode_flush(avctx);
1099  ff_vvc_executor_free(&s->executor);
1100  if (s->fcs) {
1101  for (int i = 0; i < s->nb_fcs; i++)
1102  frame_context_free(s->fcs + i);
1103  av_free(s->fcs);
1104  }
1105  ff_vvc_ps_uninit(&s->ps);
1106  ff_cbs_close(&s->cbc);
1107 
1108  return 0;
1109 }
1110 
1112 {
1113  memset(&ff_vvc_default_scale_m, 16, sizeof(ff_vvc_default_scale_m));
1114 }
1115 
1116 #define VVC_MAX_DELAYED_FRAMES 16
1118 {
1119  VVCContext *s = avctx->priv_data;
1120  static AVOnce init_static_once = AV_ONCE_INIT;
1121  const int cpu_count = av_cpu_count();
1122  const int delayed = FFMIN(cpu_count, VVC_MAX_DELAYED_FRAMES);
1123  int thread_count = avctx->thread_count ? avctx->thread_count : delayed;
1124  int ret;
1125 
1126  s->avctx = avctx;
1127 
1128  ret = ff_cbs_init(&s->cbc, AV_CODEC_ID_VVC, avctx);
1129  if (ret)
1130  return ret;
1131 
1132  if (avctx->extradata_size > 0 && avctx->extradata) {
1133  ret = ff_cbs_read_extradata_from_codec(s->cbc, &s->current_frame, avctx);
1134  if (ret < 0)
1135  return ret;
1136  }
1137 
1138  s->nb_fcs = (avctx->flags & AV_CODEC_FLAG_LOW_DELAY) ? 1 : delayed;
1139  s->fcs = av_calloc(s->nb_fcs, sizeof(*s->fcs));
1140  if (!s->fcs)
1141  return AVERROR(ENOMEM);
1142 
1143  for (int i = 0; i < s->nb_fcs; i++) {
1144  VVCFrameContext *fc = s->fcs + i;
1145  ret = frame_context_init(fc, avctx);
1146  if (ret < 0)
1147  return ret;
1148  }
1149 
1150  if (thread_count == 1)
1151  thread_count = 0;
1152  s->executor = ff_vvc_executor_alloc(s, thread_count);
1153  if (!s->executor)
1154  return AVERROR(ENOMEM);
1155 
1156  s->eos = 1;
1158  ff_thread_once(&init_static_once, init_default_scale_m);
1159 
1160  s->pix_fmt = AV_PIX_FMT_NONE;
1161 
1162  return 0;
1163 }
1164 
1166  .p.name = "vvc",
1167  .p.long_name = NULL_IF_CONFIG_SMALL("VVC (Versatile Video Coding)"),
1168  .p.type = AVMEDIA_TYPE_VIDEO,
1169  .p.id = AV_CODEC_ID_VVC,
1170  .priv_data_size = sizeof(VVCContext),
1171  .init = vvc_decode_init,
1172  .close = vvc_decode_free,
1174  .flush = vvc_decode_flush,
1178  .p.profiles = NULL_IF_CONFIG_SMALL(ff_vvc_profiles),
1179  .hw_configs = (const AVCodecHWConfigInternal *const []) {
1180 #if CONFIG_VVC_VAAPI_HWACCEL
1181  HWACCEL_VAAPI(vvc),
1182 #endif
1183  NULL
1184  },
1185 };
VVC_RADL_NUT
@ VVC_RADL_NUT
Definition: vvc.h:31
VVC_RASL_NUT
@ VVC_RASL_NUT
Definition: vvc.h:32
VVC_GDR_NUT
@ VVC_GDR_NUT
Definition: vvc.h:39
VVC_STSA_NUT
@ VVC_STSA_NUT
Definition: vvc.h:30
hwconfig.h
VVCSPS
Definition: ps.h:58
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:215
ALF_BORDER_LUMA
#define ALF_BORDER_LUMA
Definition: ctu.h:78
CodedBitstreamUnit::content_ref
void * content_ref
If content is reference counted, a RefStruct reference backing content.
Definition: cbs.h:112
VVCSH::num_ctus_in_curr_slice
uint32_t num_ctus_in_curr_slice
NumCtusInCurrSlice.
Definition: ps.h:243
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
VVCPH
Definition: ps.h:147
VVCFrameContext::output_frame
struct AVFrame * output_frame
Definition: dec.h:124
VVCPPS
Definition: ps.h:92
av_clip
#define av_clip
Definition: common.h:100
VVC_MAX_DELAYED_FRAMES
#define VVC_MAX_DELAYED_FRAMES
Definition: dec.c:1116
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:43
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:695
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
LUMA
#define LUMA
Definition: filter.c:31
cpu_count
static atomic_int cpu_count
Definition: cpu.c:57
min_cb_tl_init
static void min_cb_tl_init(TabList *l, VVCFrameContext *fc)
Definition: dec.c:122
ff_vvc_decode_frame_ps
int ff_vvc_decode_frame_ps(VVCFrameParamSets *fps, struct VVCContext *s)
Definition: ps.c:933
smvd_ref_idx
static void smvd_ref_idx(const VVCFrameContext *fc, SliceContext *sc)
Definition: dec.c:446
VVCSH::entry_point_start_ctu
uint32_t entry_point_start_ctu[VVC_MAX_ENTRY_POINTS]
entry point start in ctu_addr
Definition: ps.h:265
ff_get_format
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
Definition: decode.c:1277
ff_refstruct_pool_alloc
FFRefStructPool * ff_refstruct_pool_alloc(size_t size, unsigned flags)
Equivalent to ff_refstruct_pool_alloc(size, flags, NULL, NULL, NULL, NULL, NULL)
Definition: refstruct.c:335
tl_create
static int tl_create(TabList *l)
Definition: dec.c:77
slices_realloc
static int slices_realloc(VVCFrameContext *fc)
Definition: dec.c:483
deblock
static void deblock(const RV60Context *s, AVFrame *frame, int xpos, int ypos, int size, int dpos)
Definition: rv60dec.c:2141
CB
#define CB
Definition: filter.c:32
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:186
thread.h
ff_vvc_report_frame_finished
void ff_vvc_report_frame_finished(VVCFrame *frame)
Definition: refs.c:547
CodingUnit
Definition: hevcdec.h:288
int64_t
long long int64_t
Definition: coverity.c:34
output
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
Definition: filter_design.txt:225
H266RawSliceHeader::sh_no_output_of_prior_pics_flag
uint8_t sh_no_output_of_prior_pics_flag
Definition: cbs_h266.h:781
VVCFrameContext::DPB
VVCFrame DPB[VVC_MAX_DPB_SIZE+1]
Definition: dec.h:121
get_bits_count
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:266
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:162
data.h
ph
static int FUNC() ph(CodedBitstreamContext *ctx, RWContext *rw, H266RawPH *current)
Definition: cbs_h266_syntax_template.c:3043
H2645NAL::nuh_layer_id
int nuh_layer_id
Definition: h2645_parse.h:67
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
w
uint8_t w
Definition: llviddspenc.c:38
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:172
ff_vvc_executor_alloc
FFExecutor * ff_vvc_executor_alloc(VVCContext *s, const int thread_count)
Definition: thread.c:687
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:502
free_cus
static void free_cus(VVCFrameContext *fc)
Definition: dec.c:343
tl_init_fn
void(* tl_init_fn)(TabList *l, VVCFrameContext *fc)
Definition: dec.c:313
VVCSH::r
const H266RawSliceHeader * r
RefStruct reference.
Definition: ps.h:239
FFCodec
Definition: codec_internal.h:127
IS_RADL
#define IS_RADL(s)
Definition: ps.h:36
msm_tl_init
static void msm_tl_init(TabList *l, VVCFrameContext *fc)
Definition: dec.c:261
CodedBitstreamUnit::type
CodedBitstreamUnitType type
Codec-specific type of this unit.
Definition: cbs.h:74
fc
#define fc(width, name, range_min, range_max)
Definition: cbs_av1.c:472
FF_HW_SIMPLE_CALL
#define FF_HW_SIMPLE_CALL(avctx, function)
Definition: hwaccel_internal.h:174
ctu_nz_tl_init
static void ctu_nz_tl_init(TabList *l, VVCFrameContext *fc)
Definition: dec.c:103
ff_vvc_slice_rpl
int ff_vvc_slice_rpl(VVCContext *s, VVCFrameContext *fc, SliceContext *sc)
Definition: refs.c:464
AVFrame::buf
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
Definition: frame.h:602
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:94
H2645NAL::temporal_id
int temporal_id
HEVC only, nuh_temporal_id_plus_1 - 1.
Definition: h2645_parse.h:62
RefPicList
Definition: hevcdec.h:192
min_pu_tl_init
static void min_pu_tl_init(TabList *l, VVCFrameContext *fc)
Definition: dec.c:160
CodedBitstreamUnit
Coded bitstream unit structure.
Definition: cbs.h:70
ff_cbs_close
av_cold void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
Definition: cbs.c:142
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
skip_bits
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:381
pixel_buffer_nz_tl_init
static void pixel_buffer_nz_tl_init(TabList *l, VVCFrameContext *fc)
Definition: dec.c:225
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
decode_nal_units
static int decode_nal_units(VVCContext *s, VVCFrameContext *fc, AVPacket *avpkt)
Definition: dec.c:926
fail
#define fail()
Definition: checkasm.h:193
AVCodecContext::thread_count
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
Definition: avcodec.h:1593
ff_refstruct_pool_uninit
static void ff_refstruct_pool_uninit(FFRefStructPool **poolp)
Mark the pool as being available for freeing.
Definition: refstruct.h:292
IS_B
#define IS_B(rsh)
Definition: ps.h:40
GetBitContext
Definition: get_bits.h:108
ff_vvc_decode_sh
int ff_vvc_decode_sh(VVCSH *sh, const VVCFrameParamSets *fps, const CodedBitstreamUnit *unit)
Definition: ps.c:1348
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:508
ff_videodsp_init
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
Definition: videodsp.c:39
AV_CODEC_FLAG_LOW_DELAY
#define AV_CODEC_FLAG_LOW_DELAY
Force low delay.
Definition: avcodec.h:334
SliceContext::rpl
RefPicList * rpl
Definition: dec.h:113
tl_zero
static int tl_zero(TabList *l)
Definition: dec.c:92
VVC_IDR_W_RADL
@ VVC_IDR_W_RADL
Definition: vvc.h:36
refstruct.h
ff_vvc_executor_free
void ff_vvc_executor_free(FFExecutor **e)
Definition: thread.c:698
ff_vvc_frame_ps_free
void ff_vvc_frame_ps_free(VVCFrameParamSets *fps)
Definition: ps.c:952
VVC_EOS_NUT
@ VVC_EOS_NUT
Definition: vvc.h:50
ff_vvc_frame_submit
int ff_vvc_frame_submit(VVCContext *s, VVCFrameContext *fc)
Definition: thread.c:808
GDR_SET_RECOVERED
#define GDR_SET_RECOVERED(s)
Definition: ps.h:44
frame_context_setup
static int frame_context_setup(VVCFrameContext *fc, VVCContext *s)
Definition: dec.c:670
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:150
vvc_decode_frame
static int vvc_decode_frame(AVCodecContext *avctx, AVFrame *output, int *got_output, AVPacket *avpkt)
Definition: dec.c:1046
H266RawSliceHeader::num_ref_idx_active
uint8_t num_ref_idx_active[2]
NumRefIdxActive[].
Definition: cbs_h266.h:839
ff_thread_once
static int ff_thread_once(char *control, void(*routine)(void))
Definition: thread.h:205
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
H266RawSlice::data
uint8_t * data
Definition: cbs_h266.h:846
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
vvc_decode_init
static av_cold int vvc_decode_init(AVCodecContext *avctx)
Definition: dec.c:1117
init_get_bits8
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:545
RefPicList::refs
VVCRefPic refs[VVC_MAX_REF_ENTRIES]
Definition: dec.h:56
smvd_find_fxn
int(* smvd_find_fxn)(const int idx, const int diff, const int old_diff)
Definition: dec.c:425
ff_vvc_unref_frame
void ff_vvc_unref_frame(VVCFrameContext *fc, VVCFrame *frame, int flags)
Definition: refs.c:43
AVCodecContext::extradata_size
int extradata_size
Definition: avcodec.h:530
ff_vvc_frame_wait
int ff_vvc_frame_wait(VVCContext *s, VVCFrameContext *fc)
Definition: thread.c:837
CodedBitstreamFragment
Coded bitstream fragment structure, combining one or more units.
Definition: cbs.h:122
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:311
s
#define s(width, name)
Definition: cbs_vp9.c:198
ff_vvc_decoder
const FFCodec ff_vvc_decoder
Definition: dec.c:1165
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:60
SliceContext::slice_idx
int slice_idx
Definition: dec.h:109
av_realloc_array
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:217
frame_context_for_each_tl
static int frame_context_for_each_tl(VVCFrameContext *fc, int(*unary_fn)(TabList *l))
Definition: dec.c:315
AV_CODEC_CAP_OTHER_THREADS
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
Definition: codec.h:124
pic_arrays_init
static int pic_arrays_init(VVCContext *s, VVCFrameContext *fc)
Definition: dec.c:361
vvc_decode_free
static av_cold int vvc_decode_free(AVCodecContext *avctx)
Definition: dec.c:1093
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:304
pic_arrays_free
static void pic_arrays_free(VVCFrameContext *fc)
Definition: dec.c:351
VVCSH
Definition: ps.h:238
slice_init_entry_points
static int slice_init_entry_points(SliceContext *sc, VVCFrameContext *fc, const H2645NAL *nal, const CodedBitstreamUnit *unit)
Definition: dec.c:542
ff_vvc_clear_refs
void ff_vvc_clear_refs(VVCFrameContext *fc)
Definition: refs.c:77
decode.h
IS_IDR
#define IS_IDR(s)
Definition: hevcdec.h:76
H2645NAL::skipped_bytes_pos
int * skipped_bytes_pos
Definition: h2645_parse.h:71
TabList::tabs
Tab tabs[TAB_MAX]
Definition: dec.c:48
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:73
ff_vvc_default_scale_m
uint8_t ff_vvc_default_scale_m[64 *64]
Definition: data.c:1641
H2645NAL::type
int type
NAL unit type.
Definition: h2645_parse.h:52
min_tu_tl_init
static void min_tu_tl_init(TabList *l, VVCFrameContext *fc)
Definition: dec.c:184
get_frame_context
static VVCFrameContext * get_frame_context(const VVCContext *s, const VVCFrameContext *fc, const int delta)
Definition: dec.c:586
frame_context_free
static av_cold void frame_context_free(VVCFrameContext *fc)
Definition: dec.c:627
GetBitContext::buffer
const uint8_t * buffer
Definition: get_bits.h:109
H2645NAL::raw_size
int raw_size
Definition: h2645_parse.h:44
AV_ONCE_INIT
#define AV_ONCE_INIT
Definition: thread.h:203
NULL
#define NULL
Definition: coverity.c:32
ff_vvc_frame_thread_init
int ff_vvc_frame_thread_init(VVCFrameContext *fc)
Definition: thread.c:743
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
VVC_MAX_SAMPLE_ARRAYS
@ VVC_MAX_SAMPLE_ARRAYS
Definition: vvc.h:77
TabList
Definition: dec.c:47
hwaccel_internal.h
VVCSH::ref_idx_sym
int8_t ref_idx_sym[2]
RefIdxSymL0, RefIdxSymL1.
Definition: ps.h:248
decode_nal_unit
static int decode_nal_unit(VVCContext *s, VVCFrameContext *fc, const H2645NAL *nal, const CodedBitstreamUnit *unit)
Definition: dec.c:885
HWACCEL_MAX
#define HWACCEL_MAX
frame_setup
static int frame_setup(VVCFrameContext *fc, VVCContext *s)
Definition: dec.c:823
SliceContext::eps
struct EntryPoint * eps
Definition: dec.h:111
profiles.h
CodedBitstreamH266Context::common
CodedBitstreamH2645Context common
Definition: cbs_h266.h:860
CodedBitstreamH2645Context::read_packet
H2645Packet read_packet
Definition: cbs_h2645.h:32
RefPicListTab
Definition: hevcdec.h:199
MAX_CTU_SIZE
#define MAX_CTU_SIZE
Definition: ctu.h:33
VVCRefPic::is_lt
int is_lt
Definition: dec.h:48
TL_ADD
#define TL_ADD(t, s)
Definition: dec.c:55
AVOnce
#define AVOnce
Definition: thread.h:202
index
int index
Definition: gxfenc.c:90
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
IS_RASL
#define IS_RASL(s)
Definition: ps.h:35
TransformUnit
Definition: hevcdec.h:331
TAB_MAX
#define TAB_MAX
Definition: dec.c:40
SliceContext
Definition: mss12.h:70
av_cpu_count
int av_cpu_count(void)
Definition: cpu.c:221
decode_slice
static int decode_slice(VVCContext *s, VVCFrameContext *fc, const H2645NAL *nal, const CodedBitstreamUnit *unit)
Definition: dec.c:840
ff_vvc_flush_dpb
void ff_vvc_flush_dpb(VVCFrameContext *fc)
Definition: refs.c:84
export_frame_params
static int export_frame_params(VVCContext *s, const VVCFrameContext *fc)
Definition: dec.c:797
H266RawSliceHeader::sh_entry_point_offset_minus1
uint32_t sh_entry_point_offset_minus1[VVC_MAX_ENTRY_POINTS]
Definition: cbs_h266.h:834
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
TabList::nb_tabs
int nb_tabs
Definition: dec.c:49
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:540
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
min_cb_nz_tl_init
static void min_cb_nz_tl_init(TabList *l, VVCFrameContext *fc)
Definition: dec.c:136
height
#define height
Definition: dsp.h:85
Tab
Definition: dec.c:42
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:400
codec_internal.h
VVC_VPS_NUT
@ VVC_VPS_NUT
Definition: vvc.h:43
ALF_PADDING_SIZE
#define ALF_PADDING_SIZE
Definition: ctu.h:75
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
cpu.h
ep_init_cabac_decoder
static int ep_init_cabac_decoder(SliceContext *sc, const int index, const H2645NAL *nal, GetBitContext *gb, const CodedBitstreamUnit *unit)
Definition: dec.c:509
vvc_decode_flush
static av_cold void vvc_decode_flush(AVCodecContext *avctx)
Definition: dec.c:1075
FF_CODEC_CAP_EXPORTS_CROPPING
#define FF_CODEC_CAP_EXPORTS_CROPPING
The decoder sets the cropping fields in the output frames manually.
Definition: codec_internal.h:61
ff_vvc_frame_thread_free
void ff_vvc_frame_thread_free(VVCFrameContext *fc)
Definition: thread.c:703
size
int size
Definition: twinvq_data.h:10344
EntryPoint::cc
CABACContext cc
Definition: ctu.h:360
EntryPoint::ctu_end
int ctu_end
Definition: ctu.h:363
max_negtive
static int max_negtive(const int idx, const int diff, const int max_diff)
Definition: dec.c:420
ref_frame
static int ref_frame(VVCFrame *dst, const VVCFrame *src)
Definition: dec.c:593
get_decoded_frame
static int get_decoded_frame(VVCContext *s, AVFrame *output, int *got_output)
Definition: dec.c:1021
min_tu_nz_tl_init
static void min_tu_nz_tl_init(TabList *l, VVCFrameContext *fc)
Definition: dec.c:202
avpriv_report_missing_feature
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
H2645NAL
Definition: h2645_parse.h:34
VVCRefPic::poc
int poc
Definition: dec.h:47
GetBitContext::index
int index
Definition: get_bits.h:110
SliceContext::ref
void * ref
RefStruct reference, backing slice data.
Definition: dec.h:114
AVCodecHWConfigInternal
Definition: hwconfig.h:25
MvField
Definition: hevcdec.h:306
refs.h
diff
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
Definition: vf_paletteuse.c:166
VVCFrame
Definition: dec.h:71
ff_vvc_dsp_init
void ff_vvc_dsp_init(VVCDSPContext *vvcdsp, int bit_depth)
Definition: dsp.c:86
CodedBitstreamH266Context
Definition: cbs_h266.h:858
AV_CODEC_ID_VVC
@ AV_CODEC_ID_VVC
Definition: codec_id.h:252
MAX_CONTROL_POINTS
#define MAX_CONTROL_POINTS
Definition: ctu.h:66
VVCSH::ctb_addr_in_curr_slice
const uint32_t * ctb_addr_in_curr_slice
CtbAddrInCurrSlice.
Definition: ps.h:244
frame_start
static int frame_start(VVCContext *s, VVCFrameContext *fc, SliceContext *sc)
Definition: dec.c:702
VVC_TRAIL_NUT
@ VVC_TRAIL_NUT
Definition: vvc.h:29
VVC_SPS_NUT
@ VVC_SPS_NUT
Definition: vvc.h:44
AV_PIX_FMT_VAAPI
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
Definition: pixfmt.h:126
zero
static int zero(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:121
ff_cbs_read_extradata_from_codec
int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const AVCodecContext *avctx)
Definition: cbs.c:295
ff_vvc_output_frame
int ff_vvc_output_frame(VVCContext *s, VVCFrameContext *fc, AVFrame *out, const int no_output_of_prior_pics_flag, int flush)
Definition: refs.c:213
ff_init_cabac_decoder
int ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size)
Definition: cabac.c:162
H2645Packet::nals
H2645NAL * nals
Definition: h2645_parse.h:83
H266RawSliceHeader
Definition: cbs_h266.h:771
H266RawSliceHeader::num_entry_points
uint32_t num_entry_points
NumEntryPoints.
Definition: cbs_h266.h:838
FF_REFSTRUCT_POOL_FLAG_ZERO_EVERY_TIME
#define FF_REFSTRUCT_POOL_FLAG_ZERO_EVERY_TIME
If this flag is set, the entries will be zeroed before being returned to the user (after the init or ...
Definition: refstruct.h:221
TabList::realloc
int realloc
Definition: dec.c:52
SliceContext::nb_eps
int nb_eps
Definition: dec.h:112
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:529
delta
float delta
Definition: vorbis_enc_data.h:430
ff_vvc_decode_aps
int ff_vvc_decode_aps(VVCParamSets *ps, const CodedBitstreamUnit *unit)
Definition: ps.c:1159
H266RawSlice::header_size
size_t header_size
Definition: cbs_h266.h:848
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
av_frame_move_ref
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
Definition: frame.c:649
VVC_IDR_N_LP
@ VVC_IDR_N_LP
Definition: vvc.h:37
H266RawSlice::data_size
size_t data_size
Definition: cbs_h266.h:849
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:622
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:256
EntryPoint
Definition: ctu.h:354
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
set_output_format
static int set_output_format(const VVCContext *s, const AVFrame *output)
Definition: dec.c:964
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:264
slice_start
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
Definition: dec.c:736
ff_vvc_ps_uninit
void ff_vvc_ps_uninit(VVCParamSets *ps)
Definition: ps.c:962
ret
ret
Definition: filter_design.txt:187
H2645NAL::raw_data
const uint8_t * raw_data
Definition: h2645_parse.h:45
VVCFrame::frame
struct AVFrame * frame
Definition: dec.h:72
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
ibc_tl_init
static void ibc_tl_init(TabList *l, VVCFrameContext *fc)
Definition: dec.c:288
CHROMA
@ CHROMA
Definition: vf_waveform.c:49
sps
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
Definition: cbs_h264_syntax_template.c:260
ff_refstruct_replace
void ff_refstruct_replace(void *dstp, const void *src)
Ensure *dstp refers to the same object as src.
Definition: refstruct.c:160
VVC_PPS_NUT
@ VVC_PPS_NUT
Definition: vvc.h:45
ispmf_tl_init
static void ispmf_tl_init(TabList *l, VVCFrameContext *fc)
Definition: dec.c:275
slices_free
static void slices_free(VVCFrameContext *fc)
Definition: dec.c:465
AVCodecContext
main external API structure.
Definition: avcodec.h:451
eps_free
static void eps_free(SliceContext *slice)
Definition: dec.c:459
VVC_PREFIX_APS_NUT
@ VVC_PREFIX_APS_NUT
Definition: vvc.h:46
TabList::zero
int zero
Definition: dec.c:51
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
FF_HW_CALL
#define FF_HW_CALL(avctx, function,...)
Definition: hwaccel_internal.h:171
VVC_SUFFIX_APS_NUT
@ VVC_SUFFIX_APS_NUT
Definition: vvc.h:47
Tab::size
size_t size
Definition: dec.c:44
pps
uint64_t pps
Definition: dovi_rpuenc.c:35
imf
#define imf
Definition: vf_colormatrix.c:113
AV_CODEC_CAP_DELAY
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:76
get_format
static enum AVPixelFormat get_format(AVCodecContext *avctx, const VVCSPS *sps)
Definition: dec.c:772
VVC_CRA_NUT
@ VVC_CRA_NUT
Definition: vvc.h:38
ff_vvc_set_new_ref
int ff_vvc_set_new_ref(VVCContext *s, VVCFrameContext *fc, AVFrame **frame)
Definition: refs.c:171
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:304
wait_delayed_frame
static int wait_delayed_frame(VVCContext *s, AVFrame *output, int *got_output)
Definition: dec.c:977
frame_context_init
static av_cold int frame_context_init(VVCFrameContext *fc, AVCodecContext *avctx)
Definition: dec.c:645
ALF_BORDER_CHROMA
#define ALF_BORDER_CHROMA
Definition: ctu.h:79
ff_vvc_frame_rpl
int ff_vvc_frame_rpl(VVCContext *s, VVCFrameContext *fc, SliceContext *sc)
Definition: refs.c:523
ff_vvc_profiles
const AVProfile ff_vvc_profiles[]
Definition: profiles.c:91
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
mem.h
init_default_scale_m
static av_cold void init_default_scale_m(void)
Definition: dec.c:1111
FF_CODEC_CAP_AUTO_THREADS
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
Definition: codec_internal.h:73
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:90
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
min_pu_nz_tl_init
static void min_pu_nz_tl_init(TabList *l, VVCFrameContext *fc)
Definition: dec.c:171
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:478
AVPacket
This structure stores compressed data.
Definition: packet.h:516
SliceContext::sh
VVCSH sh
Definition: dec.h:110
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
HWACCEL_VAAPI
#define HWACCEL_VAAPI(codec)
Definition: hwconfig.h:70
submit_frame
static int submit_frame(VVCContext *s, VVCFrameContext *fc, AVFrame *output, int *got_output)
Definition: dec.c:993
VVCFrameContext
Definition: dec.h:117
EntryPoint::ctu_start
int ctu_start
Definition: ctu.h:362
IS_I
#define IS_I(rsh)
Definition: ps.h:38
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
thread.h
tl_free
static int tl_free(TabList *l)
Definition: dec.c:69
tl_init
static void tl_init(TabList *l, const int zero, const int realloc)
Definition: dec.c:62
VVC_EOB_NUT
@ VVC_EOB_NUT
Definition: vvc.h:51
h
h
Definition: vp9dsp_template.c:2070
ctu.h
ff_vvc_per_frame_init
int ff_vvc_per_frame_init(VVCFrameContext *fc)
Definition: dec.c:410
width
#define width
Definition: dsp.h:85
min_positive
static int min_positive(const int idx, const int diff, const int min_diff)
Definition: dec.c:415
ff_refstruct_unref
void ff_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
Definition: refstruct.c:120
skip
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
Definition: bitstream_template.h:375
src
#define src
Definition: vp8dsp.c:248
smvd_find
static int8_t smvd_find(const VVCFrameContext *fc, const SliceContext *sc, int lx, smvd_find_fxn find)
Definition: dec.c:427
ff_vvc_bump_frame
void ff_vvc_bump_frame(VVCContext *s, VVCFrameContext *fc)
Definition: refs.c:272
H266RawSlice
Definition: cbs_h266.h:843
VVCContext
Definition: dec.h:212
dec.h
Tab::tab
void ** tab
Definition: dec.c:43
ff_vvc_ctu_free_cus
void ff_vvc_ctu_free_cus(CodingUnit **cus)
Definition: ctu.c:2542