FFmpeg  4.4.5
hevcdec.h
Go to the documentation of this file.
1 /*
2  * HEVC video decoder
3  *
4  * Copyright (C) 2012 - 2013 Guillaume Martres
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #ifndef AVCODEC_HEVCDEC_H
24 #define AVCODEC_HEVCDEC_H
25 
26 #include <stdatomic.h>
27 
28 #include "libavutil/buffer.h"
29 #include "libavutil/md5.h"
30 #include "libavutil/mem_internal.h"
31 
32 #include "avcodec.h"
33 #include "bswapdsp.h"
34 #include "cabac.h"
35 #include "get_bits.h"
36 #include "hevcpred.h"
37 #include "h2645_parse.h"
38 #include "hevc.h"
39 #include "hevc_ps.h"
40 #include "hevc_sei.h"
41 #include "hevcdsp.h"
42 #include "internal.h"
43 #include "thread.h"
44 #include "videodsp.h"
45 
46 #define SHIFT_CTB_WPP 2
47 
48 //TODO: check if this is really the maximum
49 #define MAX_TRANSFORM_DEPTH 5
50 
51 #define MAX_TB_SIZE 32
52 #define MAX_QP 51
53 #define DEFAULT_INTRA_TC_OFFSET 2
54 
55 #define HEVC_CONTEXTS 199
56 #define HEVC_STAT_COEFFS 4
57 
58 #define MRG_MAX_NUM_CANDS 5
59 
60 #define L0 0
61 #define L1 1
62 
63 #define EPEL_EXTRA_BEFORE 1
64 #define EPEL_EXTRA_AFTER 2
65 #define EPEL_EXTRA 3
66 #define QPEL_EXTRA_BEFORE 3
67 #define QPEL_EXTRA_AFTER 4
68 #define QPEL_EXTRA 7
69 
70 #define EDGE_EMU_BUFFER_STRIDE 80
71 
72 /**
73  * Value of the luma sample at position (x, y) in the 2D array tab.
74  */
75 #define SAMPLE(tab, x, y) ((tab)[(y) * s->sps->width + (x)])
76 #define SAMPLE_CTB(tab, x, y) ((tab)[(y) * min_cb_width + (x)])
77 
78 #define IS_IDR(s) ((s)->nal_unit_type == HEVC_NAL_IDR_W_RADL || (s)->nal_unit_type == HEVC_NAL_IDR_N_LP)
79 #define IS_BLA(s) ((s)->nal_unit_type == HEVC_NAL_BLA_W_RADL || (s)->nal_unit_type == HEVC_NAL_BLA_W_LP || \
80  (s)->nal_unit_type == HEVC_NAL_BLA_N_LP)
81 #define IS_IRAP(s) ((s)->nal_unit_type >= 16 && (s)->nal_unit_type <= 23)
82 
83 enum RPSType {
90 };
91 
142 };
143 
144 enum PartMode {
148  PART_NxN = 3,
153 };
154 
155 enum PredMode {
159 };
160 
162  PRED_L0 = 0,
165 };
166 
167 enum PredFlag {
168  PF_INTRA = 0,
172 };
173 
210 };
211 
212 enum SAOType {
217 };
218 
224 };
225 
226 enum ScanType {
230 };
231 
232 typedef struct LongTermRPS {
233  int poc[32];
237 } LongTermRPS;
238 
239 typedef struct RefPicList {
243  int nb_refs;
244 } RefPicList;
245 
246 typedef struct RefPicListTab {
248 } RefPicListTab;
249 
250 typedef struct SliceHeader {
251  unsigned int pps_id;
252 
253  ///< address (in raster order) of the first block in the current slice segment
254  unsigned int slice_segment_addr;
255  ///< address (in raster order) of the first block in the current slice
256  unsigned int slice_addr;
257 
259 
261 
266 
267  ///< RPS coded in the slice header itself is stored here
274  unsigned int list_entry_lx[2][32];
275 
279 
280  unsigned int nb_refs[2];
281 
284 
286  uint8_t disable_deblocking_filter_flag; ///< slice_header_disable_deblocking_filter_flag
289 
290  unsigned int collocated_ref_idx;
291 
295 
297 
298  int beta_offset; ///< beta_offset_div2 * 2
299  int tc_offset; ///< tc_offset_div2 * 2
300 
301  unsigned int max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand
302 
304  int * offset;
305  int * size;
307 
308  int8_t slice_qp;
309 
312 
313  int16_t luma_weight_l0[16];
314  int16_t chroma_weight_l0[16][2];
315  int16_t chroma_weight_l1[16][2];
316  int16_t luma_weight_l1[16];
317 
318  int16_t luma_offset_l0[16];
319  int16_t chroma_offset_l0[16][2];
320 
321  int16_t luma_offset_l1[16];
322  int16_t chroma_offset_l1[16][2];
323 
325 } SliceHeader;
326 
327 typedef struct CodingUnit {
328  int x;
329  int y;
330 
331  enum PredMode pred_mode; ///< PredMode
332  enum PartMode part_mode; ///< PartMode
333 
334  // Inferred parameters
335  uint8_t intra_split_flag; ///< IntraSplitFlag
336  uint8_t max_trafo_depth; ///< MaxTrafoDepth
338 } CodingUnit;
339 
340 typedef struct Mv {
341  int16_t x; ///< horizontal component of motion vector
342  int16_t y; ///< vertical component of motion vector
343 } Mv;
344 
345 typedef struct MvField {
347  int8_t ref_idx[2];
348  int8_t pred_flag;
349 } MvField;
350 
351 typedef struct NeighbourAvailable {
354  int cand_up;
359 
360 typedef struct PredictionUnit {
361  int mpm_idx;
369 
370 typedef struct TransformUnit {
372 
374 
375  // Inferred parameters;
384 } TransformUnit;
385 
386 typedef struct DBParams {
389 } DBParams;
390 
391 #define HEVC_FRAME_FLAG_OUTPUT (1 << 0)
392 #define HEVC_FRAME_FLAG_SHORT_REF (1 << 1)
393 #define HEVC_FRAME_FLAG_LONG_REF (1 << 2)
394 #define HEVC_FRAME_FLAG_BUMPING (1 << 3)
395 
396 typedef struct HEVCFrame {
403  int poc;
405 
409 
412 
413  /**
414  * A sequence counter, so that old frames are output first
415  * after a POC reset
416  */
417  uint16_t sequence;
418 
419  /**
420  * A combination of HEVC_FRAME_FLAG_*
421  */
423 } HEVCFrame;
424 
425 typedef struct HEVCLocalContext {
427 
429 
431 
434 
435  int8_t qp_y;
436  int8_t curr_qp_y;
437 
438  int qPy_pred;
439 
441 
448  /* +7 is for subpixel interpolation, *2 for high bit depths */
450  /* The extended size between the new edge emu buffer is abused by SAO */
453 
454  int ct_depth;
458 
459 #define BOUNDARY_LEFT_SLICE (1 << 0)
460 #define BOUNDARY_LEFT_TILE (1 << 1)
461 #define BOUNDARY_UPPER_SLICE (1 << 2)
462 #define BOUNDARY_UPPER_TILE (1 << 3)
463  /* properties of the boundary of the current CTB for the purposes
464  * of the deblocking filter */
467 
468 typedef struct HEVCContext {
469  const AVClass *c; // needed by private avoptions
471 
472  struct HEVCContext **sList;
473 
476 
479 
480  int width;
481  int height;
482 
485 
486  /** 1 if the independent slice segment header was successfully parsed */
488 
493 
496  struct AVMD5 *md5_ctx;
497 
500 
501  ///< candidate references for the current frame
503 
508  int temporal_id; ///< temporal_id_plus1 - 1
511  int poc;
512  int pocTid0;
513  int slice_idx; ///< number of the slice being currently decoded
514  int eos; ///< current packet contains an EOS/EOB NAL
515  int last_eos; ///< last packet contains an EOS/EOB NAL
516  int max_ra;
517  int bs_width;
519  int overlap;
520 
523 
528  int8_t *qp_y_tab;
531 
533 
534  // CU
537  // PU
539 
540  uint8_t *cbf_luma; // cbf_luma of colocated TU
542 
543  // CTB-level flags affecting loop filter operation
545 
546  /** used on BE to byteswap the lines for checksumming */
549 
550  /**
551  * Sequence counters for decoded and output frames, so that old
552  * frames are output first after a POC reset
553  */
554  uint16_t seq_decode;
555  uint16_t seq_output;
556 
559 
560  const uint8_t *data;
561 
563  // type of the first VCL NAL of the current frame
565 
567  int is_nalff; ///< this flag is != 0 if bitstream is encapsulated
568  ///< as a format defined in 14496-15
570 
571  int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4)
573 } HEVCContext;
574 
575 /**
576  * Mark all frames in DPB as unused for reference.
577  */
579 
580 /**
581  * Drop all frames currently in DPB.
582  */
584 
586  int x0, int y0);
587 
588 /**
589  * Construct the reference picture sets for the current frame.
590  */
592 
593 /**
594  * Construct the reference picture list(s) for the current slice.
595  */
597 
598 void ff_hevc_save_states(HEVCContext *s, int ctb_addr_ts);
599 int ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts, int thread);
608 int ff_hevc_skip_flag_decode(HEVCContext *s, int x0, int y0,
609  int x_cb, int y_cb);
612  int x0, int y0);
613 int ff_hevc_part_mode_decode(HEVCContext *s, int log2_cb_size);
621 int ff_hevc_inter_pred_idc_decode(HEVCContext *s, int nPbW, int nPbH);
622 int ff_hevc_ref_idx_lx_decode(HEVCContext *s, int num_ref_idx_lx);
625 int ff_hevc_split_transform_flag_decode(HEVCContext *s, int log2_trafo_size);
626 int ff_hevc_cbf_cb_cr_decode(HEVCContext *s, int trafo_depth);
627 int ff_hevc_cbf_luma_decode(HEVCContext *s, int trafo_depth);
630 
631 /**
632  * Get the number of candidate references for the current frame.
633  */
635 
636 int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc);
637 
639 {
640  switch (type) {
641  case HEVC_NAL_TRAIL_N:
642  case HEVC_NAL_TSA_N:
643  case HEVC_NAL_STSA_N:
644  case HEVC_NAL_RADL_N:
645  case HEVC_NAL_RASL_N:
646  case HEVC_NAL_VCL_N10:
647  case HEVC_NAL_VCL_N12:
648  case HEVC_NAL_VCL_N14:
649  return 1;
650  default: break;
651  }
652  return 0;
653 }
654 
655 /**
656  * Find next frame in output order and put a reference to it in frame.
657  * @return 1 if a frame was output, 0 otherwise
658  */
660 
662 
664 
665 void ff_hevc_set_neighbour_available(HEVCContext *s, int x0, int y0,
666  int nPbW, int nPbH);
667 void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int y0,
668  int nPbW, int nPbH, int log2_cb_size,
669  int part_idx, int merge_idx, MvField *mv);
670 void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0,
671  int nPbW, int nPbH, int log2_cb_size,
672  int part_idx, int merge_idx,
673  MvField *mv, int mvp_lx_flag, int LX);
674 void ff_hevc_set_qPy(HEVCContext *s, int xBase, int yBase,
675  int log2_cb_size);
677  int log2_trafo_size);
682 void ff_hevc_hls_filter(HEVCContext *s, int x, int y, int ctb_size);
683 void ff_hevc_hls_filters(HEVCContext *s, int x_ctb, int y_ctb, int ctb_size);
684 void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
685  int log2_trafo_size, enum ScanType scan_idx,
686  int c_idx);
687 
688 void ff_hevc_hls_mvd_coding(HEVCContext *s, int x0, int y0, int log2_cb_size);
689 
690 extern const uint8_t ff_hevc_qpel_extra_before[4];
691 extern const uint8_t ff_hevc_qpel_extra_after[4];
692 extern const uint8_t ff_hevc_qpel_extra[4];
693 
694 #endif /* AVCODEC_HEVCDEC_H */
static void flush(AVCodecContext *avctx)
#define av_always_inline
Definition: attributes.h:45
uint8_t
int32_t
Libavcodec external API header.
refcounted data buffer API
#define flags(name, subs,...)
Definition: cbs_av1.c:572
#define s(width, name)
Definition: cbs_vp9.c:257
static AVFrame * frame
intptr_t atomic_int
Definition: stdatomic.h:55
bitstream reader API header.
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
Definition: mem.h:117
int ff_hevc_inter_pred_idc_decode(HEVCContext *s, int nPbW, int nPbH)
Definition: hevc_cabac.c:804
void ff_hevc_set_neighbour_available(HEVCContext *s, int x0, int y0, int nPbW, int nPbH)
Definition: hevc_mvs.c:42
RefPicList * ff_hevc_get_ref_list(HEVCContext *s, HEVCFrame *frame, int x0, int y0)
Definition: hevc_refs.c:57
int ff_hevc_intra_chroma_pred_mode_decode(HEVCContext *s)
Definition: hevc_cabac.c:777
int ff_hevc_cu_transquant_bypass_flag_decode(HEVCContext *s)
Definition: hevc_cabac.c:620
int ff_hevc_frame_nb_refs(const HEVCContext *s)
Get the number of candidate references for the current frame.
Definition: hevc_refs.c:503
#define HEVC_STAT_COEFFS
Definition: hevcdec.h:56
void ff_hevc_flush_dpb(HEVCContext *s)
Drop all frames currently in DPB.
Definition: hevc_refs.c:75
int ff_hevc_sao_offset_abs_decode(HEVCContext *s)
Definition: hevc_cabac.c:593
PredMode
Definition: hevcdec.h:155
@ MODE_INTRA
Definition: hevcdec.h:157
@ MODE_INTER
Definition: hevcdec.h:156
@ MODE_SKIP
Definition: hevcdec.h:158
PartMode
Definition: hevcdec.h:144
@ PART_2Nx2N
Definition: hevcdec.h:145
@ PART_Nx2N
Definition: hevcdec.h:147
@ PART_NxN
Definition: hevcdec.h:148
@ PART_2NxnD
Definition: hevcdec.h:150
@ PART_nLx2N
Definition: hevcdec.h:151
@ PART_2NxN
Definition: hevcdec.h:146
@ PART_2NxnU
Definition: hevcdec.h:149
@ PART_nRx2N
Definition: hevcdec.h:152
PredFlag
Definition: hevcdec.h:167
@ PF_L1
Definition: hevcdec.h:170
@ PF_BI
Definition: hevcdec.h:171
@ PF_L0
Definition: hevcdec.h:169
@ PF_INTRA
Definition: hevcdec.h:168
SyntaxElement
Definition: hevcdec.h:92
@ LOG2_RES_SCALE_ABS
Definition: hevcdec.h:138
@ REF_IDX_L1
Definition: hevcdec.h:115
@ SAO_OFFSET_ABS
Definition: hevcdec.h:97
@ PART_MODE
Definition: hevcdec.h:105
@ COEFF_SIGN_FLAG
Definition: hevcdec.h:137
@ MVP_LX_FLAG
Definition: hevcdec.h:120
@ SPLIT_CODING_UNIT_FLAG
Definition: hevcdec.h:100
@ SPLIT_TRANSFORM_FLAG
Definition: hevcdec.h:122
@ CU_QP_DELTA
Definition: hevcdec.h:103
@ SIGNIFICANT_COEFF_FLAG
Definition: hevcdec.h:133
@ CU_TRANSQUANT_BYPASS_FLAG
Definition: hevcdec.h:101
@ RES_SCALE_SIGN_FLAG
Definition: hevcdec.h:139
@ EXPLICIT_RDPCM_DIR_FLAG
Definition: hevcdec.h:127
@ SAO_BAND_POSITION
Definition: hevcdec.h:96
@ LAST_SIGNIFICANT_COEFF_Y_PREFIX
Definition: hevcdec.h:129
@ MVD_SIGN_FLAG
Definition: hevcdec.h:119
@ END_OF_SLICE_FLAG
Definition: hevcdec.h:99
@ COEFF_ABS_LEVEL_REMAINING
Definition: hevcdec.h:136
@ SKIP_FLAG
Definition: hevcdec.h:102
@ EXPLICIT_RDPCM_FLAG
Definition: hevcdec.h:126
@ CBF_CB_CR
Definition: hevcdec.h:124
@ REM_INTRA_LUMA_PRED_MODE
Definition: hevcdec.h:109
@ SAO_OFFSET_SIGN
Definition: hevcdec.h:98
@ ABS_MVD_MINUS2
Definition: hevcdec.h:118
@ INTER_PRED_IDC
Definition: hevcdec.h:113
@ LAST_SIGNIFICANT_COEFF_X_SUFFIX
Definition: hevcdec.h:130
@ ABS_MVD_GREATER0_FLAG
Definition: hevcdec.h:116
@ LAST_SIGNIFICANT_COEFF_Y_SUFFIX
Definition: hevcdec.h:131
@ LAST_SIGNIFICANT_COEFF_X_PREFIX
Definition: hevcdec.h:128
@ CU_CHROMA_QP_OFFSET_FLAG
Definition: hevcdec.h:140
@ TRANSFORM_SKIP_FLAG
Definition: hevcdec.h:125
@ PRED_MODE_FLAG
Definition: hevcdec.h:104
@ SAO_TYPE_IDX
Definition: hevcdec.h:94
@ REF_IDX_L0
Definition: hevcdec.h:114
@ MERGE_IDX
Definition: hevcdec.h:112
@ COEFF_ABS_LEVEL_GREATER1_FLAG
Definition: hevcdec.h:134
@ CBF_LUMA
Definition: hevcdec.h:123
@ PCM_FLAG
Definition: hevcdec.h:106
@ COEFF_ABS_LEVEL_GREATER2_FLAG
Definition: hevcdec.h:135
@ MPM_IDX
Definition: hevcdec.h:108
@ CU_CHROMA_QP_OFFSET_IDX
Definition: hevcdec.h:141
@ SAO_EO_CLASS
Definition: hevcdec.h:95
@ ABS_MVD_GREATER1_FLAG
Definition: hevcdec.h:117
@ SIGNIFICANT_COEFF_GROUP_FLAG
Definition: hevcdec.h:132
@ SAO_MERGE_FLAG
Definition: hevcdec.h:93
@ PREV_INTRA_LUMA_PRED_FLAG
Definition: hevcdec.h:107
@ INTRA_CHROMA_PRED_MODE
Definition: hevcdec.h:110
@ NO_RESIDUAL_DATA_FLAG
Definition: hevcdec.h:121
@ MERGE_FLAG
Definition: hevcdec.h:111
int ff_hevc_split_coding_unit_flag_decode(HEVCContext *s, int ct_depth, int x0, int y0)
Definition: hevc_cabac.c:693
int ff_hevc_res_scale_sign_flag(HEVCContext *s, int idx)
Definition: hevc_cabac.c:912
int ff_hevc_rem_intra_luma_pred_mode_decode(HEVCContext *s)
Definition: hevc_cabac.c:767
IntraPredMode
Definition: hevcdec.h:174
@ INTRA_ANGULAR_22
Definition: hevcdec.h:197
@ INTRA_ANGULAR_7
Definition: hevcdec.h:182
@ INTRA_ANGULAR_17
Definition: hevcdec.h:192
@ INTRA_ANGULAR_26
Definition: hevcdec.h:201
@ INTRA_ANGULAR_31
Definition: hevcdec.h:206
@ INTRA_ANGULAR_4
Definition: hevcdec.h:179
@ INTRA_DC
Definition: hevcdec.h:176
@ INTRA_ANGULAR_14
Definition: hevcdec.h:189
@ INTRA_ANGULAR_5
Definition: hevcdec.h:180
@ INTRA_ANGULAR_8
Definition: hevcdec.h:183
@ INTRA_ANGULAR_3
Definition: hevcdec.h:178
@ INTRA_ANGULAR_13
Definition: hevcdec.h:188
@ INTRA_ANGULAR_21
Definition: hevcdec.h:196
@ INTRA_ANGULAR_23
Definition: hevcdec.h:198
@ INTRA_ANGULAR_10
Definition: hevcdec.h:185
@ INTRA_ANGULAR_12
Definition: hevcdec.h:187
@ INTRA_ANGULAR_19
Definition: hevcdec.h:194
@ INTRA_ANGULAR_29
Definition: hevcdec.h:204
@ INTRA_ANGULAR_34
Definition: hevcdec.h:209
@ INTRA_ANGULAR_33
Definition: hevcdec.h:208
@ INTRA_ANGULAR_6
Definition: hevcdec.h:181
@ INTRA_ANGULAR_2
Definition: hevcdec.h:177
@ INTRA_ANGULAR_25
Definition: hevcdec.h:200
@ INTRA_ANGULAR_20
Definition: hevcdec.h:195
@ INTRA_ANGULAR_18
Definition: hevcdec.h:193
@ INTRA_ANGULAR_24
Definition: hevcdec.h:199
@ INTRA_ANGULAR_9
Definition: hevcdec.h:184
@ INTRA_ANGULAR_30
Definition: hevcdec.h:205
@ INTRA_ANGULAR_16
Definition: hevcdec.h:191
@ INTRA_ANGULAR_11
Definition: hevcdec.h:186
@ INTRA_ANGULAR_28
Definition: hevcdec.h:203
@ INTRA_ANGULAR_15
Definition: hevcdec.h:190
@ INTRA_PLANAR
Definition: hevcdec.h:175
@ INTRA_ANGULAR_32
Definition: hevcdec.h:207
@ INTRA_ANGULAR_27
Definition: hevcdec.h:202
void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int part_idx, int merge_idx, MvField *mv)
Definition: hevc_mvs.c:479
int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc)
Definition: hevc_refs.c:135
int ff_hevc_no_residual_syntax_flag_decode(HEVCContext *s)
Definition: hevc_cabac.c:835
int ff_hevc_mvp_lx_flag_decode(HEVCContext *s)
Definition: hevc_cabac.c:830
InterPredIdc
Definition: hevcdec.h:161
@ PRED_L0
Definition: hevcdec.h:162
@ PRED_BI
Definition: hevcdec.h:164
@ PRED_L1
Definition: hevcdec.h:163
void ff_hevc_deblocking_boundary_strengths(HEVCContext *s, int x0, int y0, int log2_trafo_size)
Definition: hevc_filter.c:725
int ff_hevc_pred_mode_decode(HEVCContext *s)
Definition: hevc_cabac.c:688
void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags)
Definition: hevc_refs.c:32
SAOType
Definition: hevcdec.h:212
@ SAO_BAND
Definition: hevcdec.h:214
@ SAO_NOT_APPLIED
Definition: hevcdec.h:213
@ SAO_EDGE
Definition: hevcdec.h:215
@ SAO_APPLIED
Definition: hevcdec.h:216
void ff_hevc_set_qPy(HEVCContext *s, int xBase, int yBase, int log2_cb_size)
Definition: hevc_filter.c:121
int ff_hevc_prev_intra_luma_pred_flag_decode(HEVCContext *s)
Definition: hevc_cabac.c:754
#define HEVC_CONTEXTS
Definition: hevcdec.h:55
int ff_hevc_cu_qp_delta_abs(HEVCContext *s)
Definition: hevc_cabac.c:640
void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0, int log2_trafo_size, enum ScanType scan_idx, int c_idx)
Definition: hevc_cabac.c:1031
int ff_hevc_split_transform_flag_decode(HEVCContext *s, int log2_trafo_size)
Definition: hevc_cabac.c:873
int ff_hevc_output_frame(HEVCContext *s, AVFrame *frame, int flush)
Find next frame in output order and put a reference to it in frame.
Definition: hevc_refs.c:174
int ff_hevc_cu_chroma_qp_offset_flag(HEVCContext *s)
Definition: hevc_cabac.c:672
void ff_hevc_bump_frame(HEVCContext *s)
Definition: hevc_refs.c:233
int ff_hevc_log2_res_scale_abs(HEVCContext *s, int idx)
Definition: hevc_cabac.c:903
int ff_hevc_cbf_luma_decode(HEVCContext *s, int trafo_depth)
Definition: hevc_cabac.c:883
void ff_hevc_hls_filters(HEVCContext *s, int x_ctb, int y_ctb, int ctb_size)
Definition: hevc_filter.c:889
int ff_hevc_part_mode_decode(HEVCContext *s, int log2_cb_size)
Definition: hevc_cabac.c:712
int ff_hevc_cu_chroma_qp_offset_idx(HEVCContext *s)
Definition: hevc_cabac.c:677
static av_always_inline int ff_hevc_nal_is_nonref(enum HEVCNALUnitType type)
Definition: hevcdec.h:638
const uint8_t ff_hevc_qpel_extra_after[4]
void ff_hevc_save_states(HEVCContext *s, int ctb_addr_ts)
Definition: hevc_cabac.c:450
int ff_hevc_cabac_init(HEVCContext *s, int ctb_addr_ts, int thread)
Definition: hevc_cabac.c:511
int ff_hevc_sao_band_position_decode(HEVCContext *s)
Definition: hevc_cabac.c:583
SAOEOClass
Definition: hevcdec.h:219
@ SAO_EO_VERT
Definition: hevcdec.h:221
@ SAO_EO_45D
Definition: hevcdec.h:223
@ SAO_EO_135D
Definition: hevcdec.h:222
@ SAO_EO_HORIZ
Definition: hevcdec.h:220
int ff_hevc_ref_idx_lx_decode(HEVCContext *s, int num_ref_idx_lx)
Definition: hevc_cabac.c:814
int ff_hevc_skip_flag_decode(HEVCContext *s, int x0, int y0, int x_cb, int y_cb)
Definition: hevc_cabac.c:625
int ff_hevc_sao_type_idx_decode(HEVCContext *s)
Definition: hevc_cabac.c:573
int ff_hevc_sao_offset_sign_decode(HEVCContext *s)
Definition: hevc_cabac.c:603
int ff_hevc_frame_rps(HEVCContext *s)
Construct the reference picture sets for the current frame.
Definition: hevc_refs.c:443
int ff_hevc_cbf_cb_cr_decode(HEVCContext *s, int trafo_depth)
Definition: hevc_cabac.c:878
int ff_hevc_end_of_slice_flag_decode(HEVCContext *s)
Definition: hevc_cabac.c:615
int ff_hevc_sao_merge_flag_decode(HEVCContext *s)
Definition: hevc_cabac.c:568
void ff_hevc_hls_filter(HEVCContext *s, int x, int y, int ctb_size)
Definition: hevc_filter.c:853
void ff_hevc_clear_refs(HEVCContext *s)
Mark all frames in DPB as unused for reference.
Definition: hevc_refs.c:66
int ff_hevc_merge_idx_decode(HEVCContext *s)
Definition: hevc_cabac.c:788
int ff_hevc_merge_flag_decode(HEVCContext *s)
Definition: hevc_cabac.c:799
int ff_hevc_slice_rpl(HEVCContext *s)
Construct the reference picture list(s) for the current slice.
Definition: hevc_refs.c:291
int ff_hevc_sao_eo_class_decode(HEVCContext *s)
Definition: hevc_cabac.c:608
const uint8_t ff_hevc_qpel_extra[4]
int ff_hevc_pcm_flag_decode(HEVCContext *s)
Definition: hevc_cabac.c:749
ScanType
Definition: hevcdec.h:226
@ SCAN_HORIZ
Definition: hevcdec.h:228
@ SCAN_DIAG
Definition: hevcdec.h:227
@ SCAN_VERT
Definition: hevcdec.h:229
int ff_hevc_mpm_idx_decode(HEVCContext *s)
Definition: hevc_cabac.c:759
void ff_hevc_hls_mvd_coding(HEVCContext *s, int x0, int y0, int log2_cb_size)
Definition: hevc_cabac.c:1541
#define EDGE_EMU_BUFFER_STRIDE
Definition: hevcdec.h:70
void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int part_idx, int merge_idx, MvField *mv, int mvp_lx_flag, int LX)
Definition: hevc_mvs.c:582
int ff_hevc_cu_qp_delta_sign_flag(HEVCContext *s)
Definition: hevc_cabac.c:667
const uint8_t ff_hevc_qpel_extra_before[4]
RPSType
Definition: hevcdec.h:83
@ ST_CURR_AFT
Definition: hevcdec.h:85
@ NB_RPS_TYPE
Definition: hevcdec.h:89
@ LT_FOLL
Definition: hevcdec.h:88
@ ST_CURR_BEF
Definition: hevcdec.h:84
@ LT_CURR
Definition: hevcdec.h:87
@ ST_FOLL
Definition: hevcdec.h:86
#define MAX_PB_SIZE
Definition: hevcdsp.h:32
cl_device_type type
static const int8_t mv[256][2]
Definition: 4xm.c:78
HEVCNALUnitType
Table 7-1 – NAL unit type codes and NAL unit type classes in T-REC-H.265-201802.
Definition: hevc.h:28
@ HEVC_NAL_RASL_N
Definition: hevc.h:37
@ HEVC_NAL_TRAIL_N
Definition: hevc.h:29
@ HEVC_NAL_VCL_N14
Definition: hevc.h:43
@ HEVC_NAL_VCL_N12
Definition: hevc.h:41
@ HEVC_NAL_TSA_N
Definition: hevc.h:31
@ HEVC_NAL_VCL_N10
Definition: hevc.h:39
@ HEVC_NAL_STSA_N
Definition: hevc.h:33
@ HEVC_NAL_RADL_N
Definition: hevc.h:35
HEVCSliceType
Definition: hevc.h:95
@ HEVC_MAX_REFS
Definition: hevc.h:119
internal header for HEVC (de)muxer utilities
common internal API header
Public header for MD5 hash function implementation.
The buffer pool.
A reference to a data buffer.
Definition: buffer.h:84
Describe the class of an AVClass context structure.
Definition: log.h:67
main external API structure.
Definition: avcodec.h:536
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
Definition: md5.c:40
enum PredMode pred_mode
PredMode.
Definition: hevcdec.h:331
uint8_t intra_split_flag
IntraSplitFlag.
Definition: hevcdec.h:335
uint8_t max_trafo_depth
MaxTrafoDepth.
Definition: hevcdec.h:336
enum PartMode part_mode
PartMode.
Definition: hevcdec.h:332
uint8_t cu_transquant_bypass_flag
Definition: hevcdec.h:337
int beta_offset
Definition: hevcdec.h:387
int tc_offset
Definition: hevcdec.h:388
Decoded Picture Buffer (DPB).
Definition: vaapi_h264.c:82
int is_nalff
this flag is != 0 if bitstream is encapsulated as a format defined in 14496-15
Definition: hevcdec.h:567
AVFrame * output_frame
Definition: hevcdec.h:490
uint8_t * horizontal_bs
Definition: hevcdec.h:529
int last_eos
last packet contains an EOS/EOB NAL
Definition: hevcdec.h:515
uint8_t * is_pcm
Definition: hevcdec.h:541
int temporal_id
temporal_id_plus1 - 1
Definition: hevcdec.h:508
int is_decoded
Definition: hevcdec.h:521
int pocTid0
Definition: hevcdec.h:512
DBParams * deblock
Definition: hevcdec.h:506
int nal_length_size
Number of bytes used for nal length (1, 2 or 4)
Definition: hevcdec.h:571
uint8_t * sao_pixel_buffer_h[3]
Definition: hevcdec.h:491
uint16_t seq_output
Definition: hevcdec.h:555
HEVCSEI sei
Definition: hevcdec.h:495
BswapDSPContext bdsp
Definition: hevcdec.h:527
uint8_t context_initialized
Definition: hevcdec.h:566
HEVCDSPContext hevcdsp
Definition: hevcdec.h:525
int32_t * tab_slice_address
Definition: hevcdec.h:532
H2645Packet pkt
Definition: hevcdec.h:562
int enable_parallel_tiles
Definition: hevcdec.h:557
int bs_width
Definition: hevcdec.h:517
AVCodecContext * avctx
Definition: hevcdec.h:470
SliceHeader sh
Definition: hevcdec.h:504
const AVClass * c
Definition: hevcdec.h:469
uint8_t * checksum_buf
used on BE to byteswap the lines for checksumming
Definition: hevcdec.h:547
int8_t * qp_y_tab
Definition: hevcdec.h:528
uint8_t * tab_ct_depth
Definition: hevcdec.h:536
uint8_t * skip_flag
Definition: hevcdec.h:535
uint8_t * tab_ipm
Definition: hevcdec.h:538
AVFrame * frame
Definition: hevcdec.h:489
RefPicList rps[5]
Definition: hevcdec.h:502
HEVCLocalContext ** HEVClcList
Definition: hevcdec.h:474
uint8_t threads_number
Definition: hevcdec.h:478
int height
Definition: hevcdec.h:481
VideoDSPContext vdsp
Definition: hevcdec.h:526
HEVCPredContext hpc
Definition: hevcdec.h:524
SAOParams * sao
Definition: hevcdec.h:505
int eos
current packet contains an EOS/EOB NAL
Definition: hevcdec.h:514
int max_ra
Definition: hevcdec.h:516
struct AVMD5 * md5_ctx
Definition: hevcdec.h:496
AVBufferPool * tab_mvf_pool
Definition: hevcdec.h:498
HEVCParamSets ps
Definition: hevcdec.h:494
int width
Definition: hevcdec.h:480
int apply_defdispwin
Definition: hevcdec.h:569
atomic_int wpp_err
Definition: hevcdec.h:558
uint8_t slice_initialized
1 if the independent slice segment header was successfully parsed
Definition: hevcdec.h:487
enum HEVCNALUnitType first_nal_type
Definition: hevcdec.h:564
uint16_t seq_decode
Sequence counters for decoded and output frames, so that old frames are output first after a POC rese...
Definition: hevcdec.h:554
uint8_t * cabac_state
Definition: hevcdec.h:483
uint8_t * cbf_luma
Definition: hevcdec.h:540
uint8_t stat_coeff[HEVC_STAT_COEFFS]
Definition: hevcdec.h:484
uint8_t * vertical_bs
Definition: hevcdec.h:530
uint8_t threads_type
Definition: hevcdec.h:477
enum HEVCNALUnitType nal_unit_type
Definition: hevcdec.h:507
HEVCLocalContext * HEVClc
Definition: hevcdec.h:475
AVBufferPool * rpl_tab_pool
candidate references for the current frame
Definition: hevcdec.h:499
int bs_height
Definition: hevcdec.h:518
struct HEVCContext ** sList
Definition: hevcdec.h:472
int slice_idx
number of the slice being currently decoded
Definition: hevcdec.h:513
uint8_t * filter_slice_edges
Definition: hevcdec.h:544
int overlap
Definition: hevcdec.h:519
const uint8_t * data
Definition: hevcdec.h:560
int checksum_buf_size
Definition: hevcdec.h:548
HEVCFrame * ref
Definition: hevcdec.h:509
uint8_t * sao_pixel_buffer_v[3]
Definition: hevcdec.h:492
int nuh_layer_id
Definition: hevcdec.h:572
int no_rasl_output_flag
Definition: hevcdec.h:522
AVBufferRef * rpl_buf
Definition: hevcdec.h:408
RefPicListTab ** rpl_tab
Definition: hevcdec.h:401
void * hwaccel_picture_private
Definition: hevcdec.h:411
struct HEVCFrame * collocated_ref
Definition: hevcdec.h:404
uint8_t flags
A combination of HEVC_FRAME_FLAG_*.
Definition: hevcdec.h:422
int poc
Definition: hevcdec.h:403
uint16_t sequence
A sequence counter, so that old frames are output first after a POC reset.
Definition: hevcdec.h:417
AVBufferRef * rpl_tab_buf
Definition: hevcdec.h:407
RefPicList * refPicList
Definition: hevcdec.h:400
MvField * tab_mvf
Definition: hevcdec.h:399
AVBufferRef * tab_mvf_buf
Definition: hevcdec.h:406
int ctb_count
Definition: hevcdec.h:402
AVFrame * frame
Definition: hevcdec.h:397
ThreadFrame tf
Definition: hevcdec.h:398
AVBufferRef * hwaccel_priv_buf
Definition: hevcdec.h:410
int8_t curr_qp_y
Definition: hevcdec.h:436
GetBitContext gb
Definition: hevcdec.h:432
uint8_t ctb_left_flag
Definition: hevcdec.h:442
PredictionUnit pu
Definition: hevcdec.h:456
uint8_t ctb_up_left_flag
Definition: hevcdec.h:445
uint8_t edge_emu_buffer[(MAX_PB_SIZE+7) *EDGE_EMU_BUFFER_STRIDE *2]
Definition: hevcdec.h:449
uint8_t cabac_state[HEVC_CONTEXTS]
Definition: hevcdec.h:426
TransformUnit tu
Definition: hevcdec.h:440
int end_of_tiles_x
Definition: hevcdec.h:446
NeighbourAvailable na
Definition: hevcdec.h:457
int16_t tmp[MAX_PB_SIZE *MAX_PB_SIZE]
Definition: hevcdec.h:452
uint8_t ctb_up_flag
Definition: hevcdec.h:443
CodingUnit cu
Definition: hevcdec.h:455
uint8_t first_qp_group
Definition: hevcdec.h:430
uint8_t ctb_up_right_flag
Definition: hevcdec.h:444
int boundary_flags
Definition: hevcdec.h:465
uint8_t edge_emu_buffer2[(MAX_PB_SIZE+7) *EDGE_EMU_BUFFER_STRIDE *2]
Definition: hevcdec.h:451
int end_of_tiles_y
Definition: hevcdec.h:447
CABACContext cc
Definition: hevcdec.h:433
uint8_t stat_coeff[HEVC_STAT_COEFFS]
Definition: hevcdec.h:428
uint8_t used[32]
Definition: hevcdec.h:235
uint8_t nb_refs
Definition: hevcdec.h:236
int poc[32]
Definition: hevcdec.h:233
uint8_t poc_msb_present[32]
Definition: hevcdec.h:234
int8_t pred_flag
Definition: hevcdec.h:348
Mv mv[2]
Definition: hevcdec.h:346
int8_t ref_idx[2]
Definition: hevcdec.h:347
Definition: hevcdec.h:340
int16_t x
horizontal component of motion vector
Definition: hevcdec.h:341
int16_t y
vertical component of motion vector
Definition: hevcdec.h:342
uint8_t intra_pred_mode_c[4]
Definition: hevcdec.h:366
uint8_t intra_pred_mode[4]
Definition: hevcdec.h:363
int rem_intra_luma_pred_mode
Definition: hevcdec.h:362
uint8_t merge_flag
Definition: hevcdec.h:365
uint8_t chroma_mode_c[4]
Definition: hevcdec.h:367
RefPicList refPicList[2]
Definition: hevcdec.h:247
int isLongTerm[HEVC_MAX_REFS]
Definition: hevcdec.h:242
struct HEVCFrame * ref[HEVC_MAX_REFS]
Definition: hevcdec.h:240
int nb_refs
Definition: hevcdec.h:243
int list[HEVC_MAX_REFS]
Definition: hevcdec.h:241
int16_t chroma_weight_l1[16][2]
Definition: hevcdec.h:315
uint8_t cu_chroma_qp_offset_enabled_flag
Definition: hevcdec.h:296
const ShortTermRPS * short_term_rps
Definition: hevcdec.h:271
unsigned int slice_addr
Definition: hevcdec.h:256
int16_t luma_weight_l0[16]
Definition: hevcdec.h:313
uint8_t disable_deblocking_filter_flag
slice_header_disable_deblocking_filter_flag
Definition: hevcdec.h:286
uint8_t mvd_l1_zero_flag
Definition: hevcdec.h:283
uint8_t slice_temporal_mvp_enabled_flag
Definition: hevcdec.h:278
int tc_offset
tc_offset_div2 * 2
Definition: hevcdec.h:299
uint8_t luma_log2_weight_denom
Definition: hevcdec.h:310
int8_t slice_qp
Definition: hevcdec.h:308
uint8_t no_output_of_prior_pics_flag
Definition: hevcdec.h:277
unsigned int pps_id
address (in raster order) of the first block in the current slice segment
Definition: hevcdec.h:251
int16_t luma_weight_l1[16]
Definition: hevcdec.h:316
uint8_t colour_plane_id
RPS coded in the slice header itself is stored here.
Definition: hevcdec.h:265
int short_term_ref_pic_set_sps_flag
Definition: hevcdec.h:268
unsigned int max_num_merge_cand
5 - 5_minus_max_num_merge_cand
Definition: hevcdec.h:301
int slice_cb_qp_offset
Definition: hevcdec.h:293
int16_t luma_offset_l1[16]
Definition: hevcdec.h:321
int16_t chroma_offset_l1[16][2]
Definition: hevcdec.h:322
enum HEVCSliceType slice_type
Definition: hevcdec.h:258
int * size
Definition: hevcdec.h:305
unsigned int list_entry_lx[2][32]
Definition: hevcdec.h:274
unsigned * entry_point_offset
Definition: hevcdec.h:303
int16_t chroma_offset_l0[16][2]
Definition: hevcdec.h:319
unsigned int slice_segment_addr
address (in raster order) of the first block in the current slice
Definition: hevcdec.h:254
int slice_ctb_addr_rs
Definition: hevcdec.h:324
unsigned int nb_refs[2]
Definition: hevcdec.h:280
int slice_qp_delta
Definition: hevcdec.h:292
uint8_t cabac_init_flag
Definition: hevcdec.h:285
int16_t chroma_log2_weight_denom
Definition: hevcdec.h:311
int16_t chroma_weight_l0[16][2]
Definition: hevcdec.h:314
uint8_t dependent_slice_segment_flag
Definition: hevcdec.h:263
int * offset
Definition: hevcdec.h:304
ShortTermRPS slice_rps
Definition: hevcdec.h:270
uint8_t rpl_modification_flag[2]
Definition: hevcdec.h:276
int short_term_ref_pic_set_size
Definition: hevcdec.h:269
uint8_t first_slice_in_pic_flag
Definition: hevcdec.h:262
LongTermRPS long_term_rps
Definition: hevcdec.h:273
int num_entry_point_offsets
Definition: hevcdec.h:306
uint8_t slice_sample_adaptive_offset_flag[3]
Definition: hevcdec.h:282
unsigned int collocated_ref_idx
Definition: hevcdec.h:290
int16_t luma_offset_l0[16]
Definition: hevcdec.h:318
int beta_offset
beta_offset_div2 * 2
Definition: hevcdec.h:298
uint8_t slice_loop_filter_across_slices_enabled_flag
Definition: hevcdec.h:287
uint8_t collocated_list
Definition: hevcdec.h:288
uint8_t pic_output_flag
Definition: hevcdec.h:264
int slice_cr_qp_offset
Definition: hevcdec.h:294
int long_term_ref_pic_set_size
Definition: hevcdec.h:272
int pic_order_cnt_lsb
Definition: hevcdec.h:260
uint8_t is_cu_chroma_qp_offset_coded
Definition: hevcdec.h:380
uint8_t cross_pf
Definition: hevcdec.h:383
int cu_qp_delta
Definition: hevcdec.h:371
int8_t cu_qp_offset_cr
Definition: hevcdec.h:382
int intra_pred_mode_c
Definition: hevcdec.h:377
int8_t cu_qp_offset_cb
Definition: hevcdec.h:381
int chroma_mode_c
Definition: hevcdec.h:378
uint8_t is_cu_qp_delta_coded
Definition: hevcdec.h:379
int res_scale_val
Definition: hevcdec.h:373
int intra_pred_mode
Definition: hevcdec.h:376
Core video DSP helper functions.