FFmpeg
Loading...
Searching...
No Matches
dec.h
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 */
23
24#ifndef AVCODEC_VVC_DEC_H
25#define AVCODEC_VVC_DEC_H
26
27#include "libavcodec/videodsp.h"
28#include "libavcodec/vvc.h"
29#include "libavcodec/h274.h"
30
31#include "ps.h"
32#include "dsp.h"
33#include "sei.h"
34
35#define LUMA 0
36#define CHROMA 1
37#define CB 1
38#define CR 2
39#define JCBCR 3
40
41#define MIN_TU_LOG2 2 ///< MinTbLog2SizeY
42#define MIN_PU_LOG2 2
43
44#define L0 0
45#define L1 1
46
47typedef struct VVCRefPic {
48 struct VVCFrame *ref;
49 int poc;
50 int is_lt; // is long term reference
51
52 // for RPR
53 int is_scaled; ///< RprConstraintsActiveFlag
54 int scale[2]; ///< RefPicScale[]
55} VVCRefPic;
56
57typedef struct RefPicList {
59 int nb_refs;
61
62typedef struct RefPicListTab {
65
66typedef struct VVCWindow {
67 int16_t left_offset;
68 int16_t right_offset;
69 int16_t top_offset;
71} VVCWindow;
72
73typedef struct VVCFrame {
74 struct AVFrame *frame;
76 const VVCSPS *sps; ///< RefStruct reference
77 const VVCPPS *pps; ///< RefStruct reference
78 struct MvField *tab_dmvr_mvf; ///< RefStruct reference
79 RefPicListTab **rpl_tab; ///< RefStruct reference
80 RefPicListTab *rpl; ///< RefStruct reference
81
82 int needs_fg; ///< 1 if grain needs to be applied by the decoder
83
85
87
88 int poc;
89
90 //for RPR
91 VVCWindow scaling_win; ///< pps_scaling_win_left_offset * SubWithC, pps_scaling_win_right_offset * SubWithC,
92 ///< pps_scaling_win_top_offset * SubHeigtC, pps_scaling_win_bottom_offset * SubHiehgtC
93 int ref_width; ///< CurrPicScalWinWidthL
94 int ref_height; ///< CurrPicScalWinHeightL
95
97
98 struct FrameProgress *progress; ///< RefStruct reference
99
100 /**
101 * A sequence counter, so that old frames are output first
102 * after a POC reset
103 */
104 uint16_t sequence;
105 /**
106 * A combination of VVC_FRAME_FLAG_*
107 */
108 uint8_t flags;
109
110 void *hwaccel_picture_private; ///< hardware accelerator private data
111} VVCFrame;
112
113typedef struct SliceContext {
119 void *ref; ///< RefStruct reference, backing slice data
121
122typedef struct VVCFrameContext {
123 void *log_ctx;
124
125 // +1 for the current frame
127
128 struct AVFrame *frame;
130
133
137
139
142
144
145 uint64_t decode_order;
146
149
152
153 struct {
154 int16_t *slice_idx;
155
157 struct SAOParams *sao;
158 struct ALFParams *alf;
159
160 int *cb_pos_x[2]; ///< CbPosX[][][]
161 int *cb_pos_y[2]; ///< CbPosY[][][]
162 uint8_t *cb_width[2]; ///< CbWidth[][][]
163 uint8_t *cb_height[2]; ///< CbHeight[][][]
164 uint8_t *cqt_depth[2]; ///< CqtDepth[][][]
166
167 uint8_t *skip; ///< CuSkipFlag[][]
168 uint8_t *ispmf; ///< intra_sub_partitions_mode_flag
169 uint8_t *msm[2]; ///< MttSplitMode[][][] in 32 pixels
170 uint8_t *imf; ///< IntraMipFlag[][], intra_mip_transposed_flag[][], intra_mip_mode[][]
171 uint8_t *ipm; ///< IntraPredModeY[][]
172 uint8_t *cpm[2]; ///< CuPredMode[][][]
173 uint8_t *msf; ///< MergeSubblockFlag[][]
174 uint8_t *iaf; ///< InterAffineFlag[][]
175 uint8_t *mmi; ///< MotionModelIdc[][]
176 struct Mv *cp_mv[2]; ///< CpMvLX[][][][MAX_CONTROL_POINTS];
177 struct MvField *mvf; ///< MvDmvrL0, MvDmvrL1
178
179 uint8_t *tu_coded_flag[VVC_MAX_SAMPLE_ARRAYS]; ///< tu_y_coded_flag[][], tu_cb_coded_flag[][], tu_cr_coded_flag[][]
180 uint8_t *tu_joint_cbcr_residual_flag; ///< tu_joint_cbcr_residual_flag[][]
181 uint8_t *tb_width[2];
182 uint8_t *tb_height[2];
183 uint8_t *pcmf[2];
184
185 uint8_t *bs[2][VVC_MAX_SAMPLE_ARRAYS]; ///< horizontal, vertical boundary filtering strength
186 uint8_t *max_len_p[2]; ///< horizontal, vertical maxFilterLengthPs for luma
187 uint8_t *max_len_q[2]; ///< horizontal, vertical maxFilterLengthQs for luma
188
193
194 int *coeffs;
195 struct CTU *ctus;
196 struct CodingUnit **cus;
197
198 uint8_t *ibc_vir_buf[VVC_MAX_SAMPLE_ARRAYS]; ///< IbcVirBuf[]
199
200 //used in arrays_init only
201 struct {
209 int width;
213 int ibc_buffer_width; ///< IbcBufWidth
214 } sz;
217
218typedef struct VVCContext {
220
223
225
226 int temporal_id; ///< temporal_id_plus1 - 1
228
229 int eos; ///< current packet contains an EOS/EOB NAL
230 int last_eos; ///< last packet contains an EOS/EOB NAL
231
233 int no_output_before_recovery_flag; ///< NoOutputBeforeRecoveryFlag
234 int gdr_recovery_point_poc; ///< recoveryPointPocVal
236
237 /**
238 * Sequence counters for decoded and output frames, so that old
239 * frames are output first after a POC reset
240 */
241 uint16_t seq_decode;
242 uint16_t seq_output;
243
245
248
249 uint64_t nb_frames; ///< processed frames
250 int nb_delayed; ///< delayed frames
251
253} VVCContext ;
254
255#endif /* AVCODEC_VVC_DEC_H */
H.274 film grain synthesis.
@ VVC_MAX_REF_ENTRIES
Definition vvc.h:115
@ VVC_MAX_DPB_SIZE
Definition vvc.h:109
@ VVC_MAX_SAMPLE_ARRAYS
Definition vvc.h:77
VVCNALUnitType
Table 5 – NAL unit type codes and NAL unit type classes in T-REC-H.266-202008.
Definition vvc.h:28
main external API structure.
Definition avcodec.h:443
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
AVRefStructPool is an API for a thread-safe pool of objects managed via the RefStruct API.
Definition refstruct.c:183
Definition ctu.h:345
Context structure for coded bitstream operations.
Definition cbs.h:226
Coded bitstream fragment structure, combining one or more units.
Definition cbs.h:129
Definition hevcdec.h:303
RefPicList refPicList[2]
Definition hevcdec.h:202
VVCRefPic refs[VVC_MAX_REF_ENTRIES]
Definition dec.h:58
int nb_refs
Definition hevcdec.h:198
VVCSH sh
Definition dec.h:115
int slice_idx
Definition dec.h:114
int nb_eps
Definition dec.h:117
void * ref
RefStruct reference, backing slice data.
Definition dec.h:119
struct EntryPoint * eps
Definition dec.h:116
RefPicList * rpl
Definition dec.h:118
int no_output_before_recovery_flag
NoOutputBeforeRecoveryFlag.
Definition dec.h:233
int temporal_id
temporal_id_plus1 - 1
Definition dec.h:226
int eos
current packet contains an EOS/EOB NAL
Definition dec.h:229
int last_eos
last packet contains an EOS/EOB NAL
Definition dec.h:230
struct AVCodecContext * avctx
Definition dec.h:219
CodedBitstreamContext * cbc
Definition dec.h:221
VVCParamSets ps
Definition dec.h:224
struct FFExecutor * executor
Definition dec.h:244
int nb_fcs
Definition dec.h:247
enum VVCNALUnitType vcl_unit_type
Definition dec.h:232
int gdr_recovery_point_poc
recoveryPointPocVal
Definition dec.h:234
uint16_t seq_decode
Sequence counters for decoded and output frames, so that old frames are output first after a POC rese...
Definition dec.h:241
int poc_tid0
Definition dec.h:227
H274HashContext * hash_ctx
Definition dec.h:252
CodedBitstreamFragment current_frame
Definition dec.h:222
int film_grain_warning_shown
Definition dec.h:235
uint64_t nb_frames
processed frames
Definition dec.h:249
uint16_t seq_output
Definition dec.h:242
int nb_delayed
delayed frames
Definition dec.h:250
VVCFrameContext * fcs
Definition dec.h:246
struct CTU * ctus
Definition dec.h:195
uint8_t * sao_pixel_buffer_v[VVC_MAX_SAMPLE_ARRAYS]
Definition dec.h:190
VVCDSPContext vvcdsp
Definition dec.h:140
uint8_t * imf
IntraMipFlag[][], intra_mip_transposed_flag[][], intra_mip_mode[][].
Definition dec.h:170
uint8_t * pcmf[2]
Definition dec.h:183
SliceContext ** slices
Definition dec.h:134
int pic_size_in_min_tu
Definition dec.h:206
struct VVCFrameThread * ft
Definition dec.h:143
int * coeffs
Definition dec.h:194
int ctu_size
Definition dec.h:203
struct AVFrame * frame
Definition dec.h:128
int pic_size_in_min_pu
Definition dec.h:205
uint8_t * tu_joint_cbcr_residual_flag
tu_joint_cbcr_residual_flag[][]
Definition dec.h:180
uint8_t * ipm
IntraPredModeY[][].
Definition dec.h:171
uint8_t * ispmf
intra_sub_partitions_mode_flag
Definition dec.h:168
void * log_ctx
Definition dec.h:123
uint8_t * cb_width[2]
CbWidth[][][].
Definition dec.h:162
uint8_t * skip
CuSkipFlag[][].
Definition dec.h:167
uint8_t * tu_coded_flag[VVC_MAX_SAMPLE_ARRAYS]
tu_y_coded_flag[][], tu_cb_coded_flag[][], tu_cr_coded_flag[][]
Definition dec.h:179
uint8_t * sao_pixel_buffer_h[VVC_MAX_SAMPLE_ARRAYS]
Definition dec.h:189
struct AVRefStructPool * cu_pool
Definition dec.h:150
uint8_t * msm[2]
MttSplitMode[][][] in 32 pixels.
Definition dec.h:169
int nb_slices
Definition dec.h:135
uint8_t * alf_pixel_buffer_h[VVC_MAX_SAMPLE_ARRAYS][2]
Definition dec.h:191
uint8_t * ibc_vir_buf[VVC_MAX_SAMPLE_ARRAYS]
IbcVirBuf[].
Definition dec.h:198
struct Mv * cp_mv[2]
CpMvLX[][][][MAX_CONTROL_POINTS];.
Definition dec.h:176
DBParams * deblock
Definition dec.h:156
struct AVRefStructPool * rpl_tab_pool
Definition dec.h:148
struct SAOParams * sao
Definition dec.h:157
VVCFrame * ref
Definition dec.h:138
struct AVRefStructPool * tu_pool
Definition dec.h:151
int pic_size_in_min_cb
Definition dec.h:204
uint8_t * tb_width[2]
Definition dec.h:181
uint8_t * alf_pixel_buffer_v[VVC_MAX_SAMPLE_ARRAYS][2]
Definition dec.h:192
uint8_t * max_len_p[2]
horizontal, vertical maxFilterLengthPs for luma
Definition dec.h:186
VVCFrame DPB[VVC_MAX_DPB_SIZE+1]
Definition dec.h:126
uint8_t * mmi
MotionModelIdc[][].
Definition dec.h:175
uint8_t * bs[2][VVC_MAX_SAMPLE_ARRAYS]
horizontal, vertical boundary filtering strength
Definition dec.h:185
struct AVRefStructPool * tab_dmvr_mvf_pool
Definition dec.h:147
int * cb_pos_y[2]
CbPosY[][][].
Definition dec.h:161
VVCFrameParamSets ps
Definition dec.h:131
int chroma_format_idc
Definition dec.h:211
struct MvField * mvf
MvDmvrL0, MvDmvrL1.
Definition dec.h:177
uint64_t decode_order
Definition dec.h:145
int ctu_height
Definition dec.h:208
int8_t * qp[VVC_MAX_SAMPLE_ARRAYS]
Definition dec.h:165
int ctu_width
Definition dec.h:207
uint8_t * cpm[2]
CuPredMode[][][].
Definition dec.h:172
int * cb_pos_x[2]
CbPosX[][][].
Definition dec.h:160
int16_t * slice_idx
Definition dec.h:154
VideoDSPContext vdsp
Definition dec.h:141
uint8_t * iaf
InterAffineFlag[][].
Definition dec.h:174
uint8_t * msf
MergeSubblockFlag[][].
Definition dec.h:173
uint8_t * cb_height[2]
CbHeight[][][].
Definition dec.h:163
struct ALFParams * alf
Definition dec.h:158
struct AVFrame * output_frame
Definition dec.h:129
struct CodingUnit ** cus
Definition dec.h:196
int ctu_count
Definition dec.h:202
int pixel_shift
Definition dec.h:212
uint8_t * max_len_q[2]
horizontal, vertical maxFilterLengthQs for luma
Definition dec.h:187
VVCSEI sei
Definition dec.h:132
uint8_t * tb_height[2]
Definition dec.h:182
int ibc_buffer_width
IbcBufWidth.
Definition dec.h:213
uint8_t * cqt_depth[2]
CqtDepth[][][].
Definition dec.h:164
int nb_slices_allocated
Definition dec.h:136
Definition dec.h:73
void * hwaccel_picture_private
hardware accelerator private data
Definition dec.h:110
int poc
Definition dec.h:88
struct AVFrame * frame
Definition dec.h:74
RefPicListTab ** rpl_tab
RefStruct reference.
Definition dec.h:79
VVCWindow scaling_win
pps_scaling_win_left_offset * SubWithC, pps_scaling_win_right_offset * SubWithC, pps_scaling_win_top_...
Definition dec.h:91
uint8_t flags
A combination of VVC_FRAME_FLAG_*.
Definition dec.h:108
int ctb_count
Definition dec.h:86
RefPicListTab * rpl
RefStruct reference.
Definition dec.h:80
int needs_fg
1 if grain needs to be applied by the decoder
Definition dec.h:82
struct VVCFrame * collocated_ref
Definition dec.h:96
struct AVFrame * frame_grain
Definition dec.h:75
int nb_rpl_elems
Definition dec.h:84
struct FrameProgress * progress
RefStruct reference.
Definition dec.h:98
const VVCPPS * pps
RefStruct reference.
Definition dec.h:77
int ref_width
CurrPicScalWinWidthL.
Definition dec.h:93
uint16_t sequence
A sequence counter, so that old frames are output first after a POC reset.
Definition dec.h:104
int ref_height
CurrPicScalWinHeightL.
Definition dec.h:94
const VVCSPS * sps
RefStruct reference.
Definition dec.h:76
struct MvField * tab_dmvr_mvf
RefStruct reference.
Definition dec.h:78
Definition ps.h:92
int scale[2]
RefPicScale[].
Definition dec.h:54
int is_lt
Definition dec.h:50
int poc
Definition dec.h:49
int is_scaled
RprConstraintsActiveFlag.
Definition dec.h:53
struct VVCFrame * ref
Definition dec.h:48
Definition sei.h:36
Definition ps.h:238
Definition ps.h:58
int16_t bottom_offset
Definition dec.h:70
int16_t top_offset
Definition dec.h:69
int16_t left_offset
Definition dec.h:67
int16_t right_offset
Definition dec.h:68
static const struct twinvq_data tab
Core video DSP helper functions.