FFmpeg
Loading...
Searching...
No Matches
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_HEVC_HEVCDEC_H
24#define AVCODEC_HEVC_HEVCDEC_H
25
26#include <stdatomic.h>
27
28#include "libavutil/buffer.h"
30
31#include "libavcodec/avcodec.h"
32#include "libavcodec/bswapdsp.h"
33#include "libavcodec/cabac.h"
34#include "libavcodec/dovi_rpu.h"
37#include "libavcodec/videodsp.h"
38
39#include "dsp.h"
40#include "hevc.h"
41#include "pred.h"
42#include "ps.h"
43#include "sei.h"
44
45#define SHIFT_CTB_WPP 2
46
47#define MAX_TB_SIZE 32
48#define MAX_QP 51
49#define DEFAULT_INTRA_TC_OFFSET 2
50
51#define HEVC_CONTEXTS 199
52#define HEVC_STAT_COEFFS 4
53
54#define MRG_MAX_NUM_CANDS 5
55
56#define L0 0
57#define L1 1
58
59#define EPEL_EXTRA_BEFORE 1
60#define EPEL_EXTRA_AFTER 2
61#define EPEL_EXTRA 3
62#define QPEL_EXTRA_BEFORE 3
63#define QPEL_EXTRA_AFTER 4
64#define QPEL_EXTRA 7
65
66#define EDGE_EMU_BUFFER_STRIDE 80
67
68/**
69 * Value of the luma sample at position (x, y) in the 2D array tab.
70 */
71#define SAMPLE(tab, x, y) ((tab)[(y) * s->sps->width + (x)])
72#define SAMPLE_CTB(tab, x, y) ((tab)[(y) * min_cb_width + (x)])
73
74#define IS_IDR(s) ((s)->nal_unit_type == HEVC_NAL_IDR_W_RADL || (s)->nal_unit_type == HEVC_NAL_IDR_N_LP)
75#define IS_BLA(s) ((s)->nal_unit_type == HEVC_NAL_BLA_W_RADL || (s)->nal_unit_type == HEVC_NAL_BLA_W_LP || \
76 (s)->nal_unit_type == HEVC_NAL_BLA_N_LP)
77#define IS_IRAP(s) ((s)->nal_unit_type >= HEVC_NAL_BLA_W_LP && (s)->nal_unit_type <= HEVC_NAL_RSV_IRAP_VCL23)
78
79#define HEVC_RECOVERY_UNSPECIFIED INT_MAX
80#define HEVC_RECOVERY_END INT_MIN
81#define HEVC_IS_RECOVERING(s) ((s)->recovery_poc != HEVC_RECOVERY_UNSPECIFIED && (s)->recovery_poc != HEVC_RECOVERY_END)
82
93
104
110
116
123
161
168
175
181
186
187typedef struct LongTermRPS {
188 int poc[32];
189 uint8_t poc_msb_present[32];
190 uint8_t used[32];
191 uint8_t nb_refs;
193
200
204
205typedef struct SliceHeader {
206 unsigned int pps_id;
207
208 /// address (in raster order) of the first block in the current slice segment
209 unsigned int slice_segment_addr;
210 /// address (in raster order) of the first block in the current slice
211 unsigned int slice_addr;
212
214
216 int poc;
217
223
224 /// RPS coded in the slice header itself is stored here
231 unsigned int list_entry_lx[2][32];
232
236
237 unsigned int nb_refs[2];
238
241
243 uint8_t disable_deblocking_filter_flag; ///< slice_header_disable_deblocking_filter_flag
246
247 unsigned int collocated_ref_idx;
248
252
256
258
259 int beta_offset; ///< beta_offset_div2 * 2
260 int tc_offset; ///< tc_offset_div2 * 2
261
262 uint8_t max_num_merge_cand; ///< 5 - 5_minus_max_num_merge_cand
264
266 int * offset;
267 int * size;
269
270 int8_t slice_qp;
271
274
275 int16_t luma_weight_l0[16];
276 int16_t chroma_weight_l0[16][2];
277 int16_t chroma_weight_l1[16][2];
278 int16_t luma_weight_l1[16];
279
280 int16_t luma_offset_l0[16];
281 int16_t chroma_offset_l0[16][2];
282
283 int16_t luma_offset_l1[16];
284 int16_t chroma_offset_l1[16][2];
285
287 unsigned data_offset;
289
290typedef struct CodingUnit {
291 int x;
292 int y;
293
294 enum PredMode pred_mode; ///< PredMode
295 enum PartMode part_mode; ///< PartMode
296
297 // Inferred parameters
298 uint8_t intra_split_flag; ///< IntraSplitFlag
299 uint8_t max_trafo_depth; ///< MaxTrafoDepth
301} CodingUnit;
302
303typedef struct Mv {
304 int16_t x; ///< horizontal component of motion vector
305 int16_t y; ///< vertical component of motion vector
306} Mv;
307
308typedef struct MvField {
310 int8_t ref_idx[2];
311 int8_t pred_flag;
312} MvField;
313
322
332
348
349typedef struct DBParams {
352} DBParams;
353
354#define HEVC_FRAME_FLAG_OUTPUT (1 << 0)
355#define HEVC_FRAME_FLAG_SHORT_REF (1 << 1)
356#define HEVC_FRAME_FLAG_LONG_REF (1 << 2)
357#define HEVC_FRAME_FLAG_UNAVAILABLE (1 << 3)
358#define HEVC_FRAME_FLAG_CORRUPT (1 << 4)
359
360typedef struct HEVCFrame {
361 union {
362 struct {
364 };
366 };
368 int needs_fg; /* 1 if grain needs to be applied by the decoder */
369 MvField *tab_mvf; ///< RefStruct reference
371 RefPicListTab **rpl_tab; ///< RefStruct reference
373 int poc;
374
375 const HEVCPPS *pps; ///< RefStruct reference
376 RefPicListTab *rpl; ///< RefStruct reference
378
379 void *hwaccel_picture_private; ///< RefStruct reference
380
381 // for secondary-layer frames, this is the DPB index of the base-layer frame
382 // from the same AU, if it exists, otherwise -1
384
385 /**
386 * A combination of HEVC_FRAME_FLAG_*
387 */
388 uint8_t flags;
389} HEVCFrame;
390
391typedef struct HEVCLocalContext {
393
395
397
398 void *logctx;
399 const struct HEVCContext *parent;
400
402
403 /**
404 * This is a pointer to the common CABAC state.
405 * In case entropy_coding_sync_enabled_flag is set,
406 * the CABAC state after decoding the second CTU in a row is
407 * stored here and used to initialize the CABAC state before
408 * decoding the first CTU in the next row.
409 * This is the basis for WPP and in case slice-threading is used,
410 * the next row is decoded by another thread making this state
411 * shared between threads.
412 */
414
415 int8_t qp_y;
416 int8_t curr_qp_y;
417
419
421
423 uint8_t ctb_up_flag;
428 /* +7 is for subpixel interpolation, *2 for high bit depths */
430 /* The extended size between the new edge emu buffer is abused by SAO */
433
438
439#define BOUNDARY_LEFT_SLICE (1 << 0)
440#define BOUNDARY_LEFT_TILE (1 << 1)
441#define BOUNDARY_UPPER_SLICE (1 << 2)
442#define BOUNDARY_UPPER_TILE (1 << 3)
443 /* properties of the boundary of the current CTB for the purposes
444 * of the deblocking filter */
446
447 // an array of these structs is used for per-thread state - pad its size
448 // to avoid false sharing
449 char padding[128];
451
452typedef struct HEVCLayerContext {
455
456 const HEVCSPS *sps; // RefStruct reference
457
460
463
464 // CU
465 uint8_t *skip_flag;
466 uint8_t *tab_ct_depth;
467
468 // PU
469 uint8_t *cbf_luma; // cbf_luma of colocated TU
470 uint8_t *tab_ipm;
471 uint8_t *is_pcm;
472
473 // CTB-level flags affecting loop filter operation
475
477
478 int8_t *qp_y_tab;
479
481 uint8_t *vertical_bs;
482
485
489
490typedef struct HEVCContext {
491 const AVClass *c; // needed by private avoptions
493
495 unsigned nb_local_ctx;
496
497 // per-layer decoding state, addressed by VPS layer indices
499 // VPS index of the layer currently being decoded
500 unsigned cur_layer;
501 // bitmask of layer indices that are active for decoding/output
504
505 /** 1 if the independent slice segment header was successfully parsed */
507
509
512 struct AVMD5 *md5_ctx;
513
514 /// candidate references for the current frame
516
517 const HEVCVPS *vps; ///< RefStruct reference
518 const HEVCPPS *pps; ///< RefStruct reference
521 int temporal_id; ///< temporal_id_plus1 - 1
524 int poc;
526 int slice_idx; ///< number of the slice being currently decoded
527 int eos; ///< current packet contains an EOS/EOB NAL
528 int last_eos; ///< last packet contains an EOS/EOB NAL
530
531 // NoRaslOutputFlag associated with the last IRAP frame
533
538
539 /** used on BE to byteswap the lines for checksumming */
540 uint8_t *checksum_buf;
542
543 /** The target for the common_cabac_state of the local contexts. */
545
548
550
551 const uint8_t *data;
552
554 // type of the first VCL NAL of the current frame
556 // index in pkt.nals of the NAL unit after which we can call
557 // ff_thread_finish_setup()
559
560 int is_nalff; ///< this flag is != 0 if bitstream is encapsulated
561 ///< as a format defined in 14496-15
563
564 // multi-layer AVOptions
566 unsigned nb_view_ids;
567
570
573
574 int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4)
576
578
579 // dts of the packet currently being decoded
581
582 AVBufferRef *rpu_buf; ///< 0 or 1 Dolby Vision RPUs.
583 DOVIContext dovi_ctx; ///< Dolby Vision decoding context
585
586/**
587 * Mark all frames in DPB as unused for reference.
588 */
590
591/**
592 * Drop all frames currently in DPB.
593 */
595
596const RefPicList *ff_hevc_get_ref_list(const HEVCFrame *frame, int x0, int y0);
597
598/**
599 * Construct the reference picture sets for the current frame.
600 */
602
603/**
604 * Construct the reference picture list(s) for the current slice.
605 */
607
609 int ctb_addr_ts);
611 int ctb_addr_ts, const uint8_t *data, size_t size,
612 int is_wpp);
621int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, uint8_t *skip_flag,
622 int x0, int y0, int x_cb, int y_cb, int min_cb_width);
624int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, uint8_t *tab_ct_depth,
625 const HEVCSPS *sps,
626 int ct_depth, int x0, int y0);
627int ff_hevc_part_mode_decode(HEVCLocalContext *lc, const HEVCSPS *sps, int log2_cb_size);
635int ff_hevc_inter_pred_idc_decode(HEVCLocalContext *lc, int nPbW, int nPbH);
636int ff_hevc_ref_idx_lx_decode(HEVCLocalContext *lc, int num_ref_idx_lx);
639int ff_hevc_split_transform_flag_decode(HEVCLocalContext *lc, int log2_trafo_size);
640int ff_hevc_cbf_cb_cr_decode(HEVCLocalContext *lc, int trafo_depth);
641int ff_hevc_cbf_luma_decode(HEVCLocalContext *lc, int trafo_depth);
644
645/**
646 * Get the number of candidate references for the current frame.
647 */
648int ff_hevc_frame_nb_refs(const SliceHeader *sh, const HEVCPPS *pps,
649 unsigned layer_idx);
650
652
654{
655 switch (type) {
656 case HEVC_NAL_TRAIL_N:
657 case HEVC_NAL_TSA_N:
658 case HEVC_NAL_STSA_N:
659 case HEVC_NAL_RADL_N:
660 case HEVC_NAL_RASL_N:
661 case HEVC_NAL_VCL_N10:
662 case HEVC_NAL_VCL_N12:
663 case HEVC_NAL_VCL_N14:
664 return 1;
665 default: break;
666 }
667 return 0;
668}
669
670/**
671 * Find frames in the DPB that are ready for output and either write them to the
672 * output FIFO or drop their output flag, depending on the value of discard.
673 *
674 * @param max_output maximum number of AUs with an output-pending frame in at
675 * least one layer that can be present in the DPB before output
676 * is triggered
677 * @param max_dpb maximum number of any frames that can be present in the DPB
678 * for any layer before output is triggered
679 */
681 unsigned layers_active_decode, unsigned layers_active_output,
682 unsigned max_output, unsigned max_dpb, int discard);
683
685
687 int nPbW, int nPbH, int log2_ctb_size);
689 int x0, int y0,
690 int nPbW, int nPbH, int log2_cb_size,
691 int part_idx, int merge_idx, MvField *mv);
693 int x0, int y0,
694 int nPbW, int nPbH, int log2_cb_size,
695 int part_idx, int merge_idx,
696 MvField *mv, int mvp_lx_flag, int LX);
698 const HEVCPPS *pps,
699 int x, int y, int ctb_size);
701 const HEVCPPS *pps,
702 int x_ctb, int y_ctb, int ctb_size);
704 const HEVCLayerContext *l, const HEVCPPS *pps,
705 int xBase, int yBase, int log2_cb_size);
707 const HEVCPPS *pps,
708 int x0, int y0, int log2_trafo_size);
712int ff_hevc_cu_chroma_qp_offset_idx(HEVCLocalContext *lc, int chroma_qp_offset_list_len_minus1);
714 int x0, int y0,
715 int log2_trafo_size, enum ScanType scan_idx,
716 int c_idx);
717
718void ff_hevc_hls_mvd_coding(HEVCLocalContext *lc, int x0, int y0, int log2_cb_size);
719
721
722extern const uint8_t ff_hevc_qpel_extra_before[4];
723extern const uint8_t ff_hevc_qpel_extra_after[4];
724extern const uint8_t ff_hevc_qpel_extra[4];
725
726#endif /* AVCODEC_HEVC_HEVCDEC_H */
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
Definition af_astats.c:246
int32_t
Libavcodec external API header.
refcounted data buffer API
Context Adaptive Binary Arithmetic Coder.
#define flags(name, subs,...)
Definition cbs_h264.c:74
static int FUNC sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
#define s(width, name)
Definition cbs_vp9.c:198
long long int64_t
Definition coverity.c:34
PredMode
Definition ctu.h:191
static AVFrame * frame
uint64_t pps
Definition dovi_rpuenc.c:36
intptr_t atomic_int
Definition stdatomic.h:55
#define MAX_PB_SIZE
Definition dsp.h:32
#define HEVC_VPS_MAX_LAYERS
Definition ps.h:35
int ff_hevc_end_of_slice_flag_decode(HEVCLocalContext *lc)
Definition cabac.c:563
int ff_hevc_cu_transquant_bypass_flag_decode(HEVCLocalContext *lc)
Definition cabac.c:568
int ff_hevc_output_frames(HEVCContext *s, unsigned layers_active_decode, unsigned layers_active_output, unsigned max_output, unsigned max_dpb, int discard)
Find frames in the DPB that are ready for output and either write them to the output FIFO or drop the...
Definition refs.c:267
int ff_hevc_sao_type_idx_decode(HEVCLocalContext *lc)
Definition cabac.c:521
void ff_hevc_set_qPy(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int xBase, int yBase, int log2_cb_size)
Definition filter.c:122
int ff_hevc_no_residual_syntax_flag_decode(HEVCLocalContext *lc)
Definition cabac.c:783
int ff_hevc_sao_merge_flag_decode(HEVCLocalContext *lc)
Definition cabac.c:516
#define HEVC_STAT_COEFFS
Definition hevcdec.h:52
void ff_hevc_flush_dpb(HEVCContext *s)
Drop all frames currently in DPB.
Definition refs.c:76
int ff_hevc_merge_flag_decode(HEVCLocalContext *lc)
Definition cabac.c:747
int ff_hevc_cu_chroma_qp_offset_flag(HEVCLocalContext *lc)
Definition cabac.c:618
PredMode
Definition hevcdec.h:105
@ MODE_INTER
Definition hevcdec.h:106
@ MODE_SKIP
Definition hevcdec.h:108
PartMode
Definition hevcdec.h:94
@ PART_2Nx2N
Definition hevcdec.h:95
@ PART_Nx2N
Definition hevcdec.h:97
@ PART_NxN
Definition hevcdec.h:98
@ PART_2NxnD
Definition hevcdec.h:100
@ PART_nLx2N
Definition hevcdec.h:101
@ PART_2NxN
Definition hevcdec.h:96
@ PART_2NxnU
Definition hevcdec.h:99
@ PART_nRx2N
Definition hevcdec.h:102
int ff_hevc_cu_chroma_qp_offset_idx(HEVCLocalContext *lc, int chroma_qp_offset_list_len_minus1)
Definition cabac.c:623
PredFlag
Definition hevcdec.h:117
@ PF_L1
Definition hevcdec.h:120
@ PF_BI
Definition hevcdec.h:121
@ PF_L0
Definition hevcdec.h:119
@ PF_INTRA
Definition hevcdec.h:118
int ff_hevc_sao_offset_abs_decode(HEVCLocalContext *lc, int bit_depth)
Definition cabac.c:541
int ff_hevc_frame_nb_refs(const SliceHeader *sh, const HEVCPPS *pps, unsigned layer_idx)
Get the number of candidate references for the current frame.
Definition refs.c:617
int ff_hevc_res_scale_sign_flag(HEVCLocalContext *lc, int idx)
Definition cabac.c:861
void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int x0, int y0, int log2_trafo_size)
Definition filter.c:742
int ff_hevc_cu_qp_delta_abs(HEVCLocalContext *lc)
Definition cabac.c:586
IntraPredMode
Definition hevcdec.h:124
@ INTRA_ANGULAR_22
Definition hevcdec.h:147
@ INTRA_ANGULAR_7
Definition hevcdec.h:132
@ INTRA_ANGULAR_17
Definition hevcdec.h:142
@ INTRA_ANGULAR_26
Definition hevcdec.h:151
@ INTRA_ANGULAR_31
Definition hevcdec.h:156
@ INTRA_ANGULAR_4
Definition hevcdec.h:129
@ INTRA_DC
Definition hevcdec.h:126
@ INTRA_ANGULAR_14
Definition hevcdec.h:139
@ INTRA_ANGULAR_5
Definition hevcdec.h:130
@ INTRA_ANGULAR_8
Definition hevcdec.h:133
@ INTRA_ANGULAR_3
Definition hevcdec.h:128
@ INTRA_ANGULAR_13
Definition hevcdec.h:138
@ INTRA_ANGULAR_21
Definition hevcdec.h:146
@ INTRA_ANGULAR_23
Definition hevcdec.h:148
@ INTRA_ANGULAR_10
Definition hevcdec.h:135
@ INTRA_ANGULAR_12
Definition hevcdec.h:137
@ INTRA_ANGULAR_19
Definition hevcdec.h:144
@ INTRA_ANGULAR_29
Definition hevcdec.h:154
@ INTRA_ANGULAR_34
Definition hevcdec.h:159
@ INTRA_ANGULAR_33
Definition hevcdec.h:158
@ INTRA_ANGULAR_6
Definition hevcdec.h:131
@ INTRA_ANGULAR_2
Definition hevcdec.h:127
@ INTRA_ANGULAR_25
Definition hevcdec.h:150
@ INTRA_ANGULAR_20
Definition hevcdec.h:145
@ INTRA_ANGULAR_18
Definition hevcdec.h:143
@ INTRA_ANGULAR_24
Definition hevcdec.h:149
@ INTRA_ANGULAR_9
Definition hevcdec.h:134
@ INTRA_ANGULAR_30
Definition hevcdec.h:155
@ INTRA_ANGULAR_16
Definition hevcdec.h:141
@ INTRA_ANGULAR_11
Definition hevcdec.h:136
@ INTRA_ANGULAR_28
Definition hevcdec.h:153
@ INTRA_ANGULAR_15
Definition hevcdec.h:140
@ INTRA_PLANAR
Definition hevcdec.h:125
@ INTRA_ANGULAR_32
Definition hevcdec.h:157
@ INTRA_ANGULAR_27
Definition hevcdec.h:152
InterPredIdc
Definition hevcdec.h:111
@ PRED_L0
Definition hevcdec.h:112
@ PRED_BI
Definition hevcdec.h:114
@ PRED_L1
Definition hevcdec.h:113
int ff_hevc_mvp_lx_flag_decode(HEVCLocalContext *lc)
Definition cabac.c:778
void ff_hevc_clear_refs(HEVCLayerContext *l)
Mark all frames in DPB as unused for reference.
Definition refs.c:67
void ff_hevc_save_states(HEVCLocalContext *lc, const HEVCPPS *pps, int ctb_addr_ts)
Definition cabac.c:402
int ff_hevc_split_transform_flag_decode(HEVCLocalContext *lc, int log2_trafo_size)
Definition cabac.c:821
int ff_hevc_cabac_init(HEVCLocalContext *lc, const HEVCPPS *pps, int ctb_addr_ts, const uint8_t *data, size_t size, int is_wpp)
Definition cabac.c:454
int ff_hevc_log2_res_scale_abs(HEVCLocalContext *lc, int idx)
Definition cabac.c:851
const RefPicList * ff_hevc_get_ref_list(const HEVCFrame *frame, int x0, int y0)
Definition refs.c:57
int ff_hevc_sao_eo_class_decode(HEVCLocalContext *lc)
Definition cabac.c:556
void ff_hevc_hls_mvd_coding(HEVCLocalContext *lc, int x0, int y0, int log2_cb_size)
Definition cabac.c:1595
int ff_hevc_set_new_ref(HEVCContext *s, HEVCLayerContext *l, int poc)
Definition refs.c:211
int ff_hevc_frame_rps(HEVCContext *s, HEVCLayerContext *l)
Construct the reference picture sets for the current frame.
Definition refs.c:537
int ff_hevc_mpm_idx_decode(HEVCLocalContext *lc)
Definition cabac.c:707
SAOType
Definition hevcdec.h:162
@ SAO_BAND
Definition hevcdec.h:164
@ SAO_NOT_APPLIED
Definition hevcdec.h:163
@ SAO_EDGE
Definition hevcdec.h:165
@ SAO_APPLIED
Definition hevcdec.h:166
void ff_hevc_luma_mv_mvp_mode(HEVCLocalContext *lc, const HEVCPPS *pps, 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 mvs.c:589
int ff_hevc_is_alpha_video(const HEVCContext *s)
Definition hevcdec.c:440
#define HEVC_CONTEXTS
Definition hevcdec.h:51
int ff_hevc_sao_band_position_decode(HEVCLocalContext *lc)
Definition cabac.c:531
int ff_hevc_inter_pred_idc_decode(HEVCLocalContext *lc, int nPbW, int nPbH)
Definition cabac.c:752
void ff_hevc_hls_filters(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int x_ctb, int y_ctb, int ctb_size)
Definition filter.c:912
int ff_hevc_cbf_cb_cr_decode(HEVCLocalContext *lc, int trafo_depth)
Definition cabac.c:826
int ff_hevc_rem_intra_luma_pred_mode_decode(HEVCLocalContext *lc)
Definition cabac.c:715
int ff_hevc_sao_offset_sign_decode(HEVCLocalContext *lc)
Definition cabac.c:551
int ff_hevc_intra_chroma_pred_mode_decode(HEVCLocalContext *lc)
Definition cabac.c:725
int ff_hevc_cbf_luma_decode(HEVCLocalContext *lc, int trafo_depth)
Definition cabac.c:831
int ff_hevc_merge_idx_decode(HEVCLocalContext *lc)
Definition cabac.c:736
static av_always_inline int ff_hevc_nal_is_nonref(enum HEVCNALUnitType type)
Definition hevcdec.h:653
const uint8_t ff_hevc_qpel_extra_after[4]
void ff_hevc_set_neighbour_available(HEVCLocalContext *lc, int x0, int y0, int nPbW, int nPbH, int log2_ctb_size)
Definition mvs.c:43
void ff_hevc_luma_mv_merge_mode(HEVCLocalContext *lc, const HEVCPPS *pps, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int part_idx, int merge_idx, MvField *mv)
Definition mvs.c:482
void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, const HEVCPPS *pps, int x0, int y0, int log2_trafo_size, enum ScanType scan_idx, int c_idx)
Definition cabac.c:1061
SAOEOClass
Definition hevcdec.h:169
@ SAO_EO_VERT
Definition hevcdec.h:171
@ SAO_EO_45D
Definition hevcdec.h:173
@ SAO_EO_135D
Definition hevcdec.h:172
@ SAO_EO_HORIZ
Definition hevcdec.h:170
int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, uint8_t *tab_ct_depth, const HEVCSPS *sps, int ct_depth, int x0, int y0)
Definition cabac.c:639
int ff_hevc_pcm_flag_decode(HEVCLocalContext *lc)
Definition cabac.c:697
int ff_hevc_part_mode_decode(HEVCLocalContext *lc, const HEVCSPS *sps, int log2_cb_size)
Definition cabac.c:660
void ff_hevc_unref_frame(HEVCFrame *frame, int flags)
Definition refs.c:35
int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, uint8_t *skip_flag, int x0, int y0, int x_cb, int y_cb, int min_cb_width)
Definition cabac.c:573
int ff_hevc_cu_qp_delta_sign_flag(HEVCLocalContext *lc)
Definition cabac.c:613
void ff_hevc_hls_filter(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int x, int y, int ctb_size)
Definition filter.c:872
int ff_hevc_prev_intra_luma_pred_flag_decode(HEVCLocalContext *lc)
Definition cabac.c:702
int ff_hevc_slice_rpl(HEVCContext *s)
Construct the reference picture list(s) for the current slice.
Definition refs.c:345
const uint8_t ff_hevc_qpel_extra[4]
int ff_hevc_pred_mode_decode(HEVCLocalContext *lc)
Definition cabac.c:634
ScanType
Definition hevcdec.h:176
@ SCAN_HORIZ
Definition hevcdec.h:178
@ SCAN_DIAG
Definition hevcdec.h:177
@ SCAN_VERT
Definition hevcdec.h:179
#define EDGE_EMU_BUFFER_STRIDE
Definition hevcdec.h:66
int ff_hevc_ref_idx_lx_decode(HEVCLocalContext *lc, int num_ref_idx_lx)
Definition cabac.c:762
const uint8_t ff_hevc_qpel_extra_before[4]
RPSType
Definition hevcdec.h:83
@ ST_CURR_AFT
Definition hevcdec.h:85
@ INTER_LAYER1
Definition hevcdec.h:90
@ NB_RPS_TYPE
Definition hevcdec.h:91
@ LT_FOLL
Definition hevcdec.h:88
@ ST_CURR_BEF
Definition hevcdec.h:84
@ LT_CURR
Definition hevcdec.h:87
@ INTER_LAYER0
Definition hevcdec.h:89
@ ST_FOLL
Definition hevcdec.h:86
cl_device_type type
static const int8_t mv[256][2]
Definition 4xm.c:81
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:122
#define av_always_inline
Definition attributes.h:72
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
const char data[16]
Definition mxf.c:149
A reference to a data buffer.
Definition buffer.h:82
Describe the class of an AVClass context structure.
Definition log.h:76
main external API structure.
Definition avcodec.h:443
AVContainerFifo is a FIFO for "containers" - dynamically allocated reusable structs (e....
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
Definition md5.c:42
AVRefStructPool is an API for a thread-safe pool of objects managed via the RefStruct API.
Definition refstruct.c:183
enum PredMode pred_mode
PredMode.
Definition hevcdec.h:294
uint8_t intra_split_flag
IntraSplitFlag.
Definition hevcdec.h:298
uint8_t max_trafo_depth
MaxTrafoDepth.
Definition hevcdec.h:299
enum PartMode part_mode
PartMode.
Definition hevcdec.h:295
uint8_t cu_transquant_bypass_flag
Definition hevcdec.h:300
int beta_offset
Definition hevcdec.h:350
int tc_offset
Definition hevcdec.h:351
uint8_t state[HEVC_CONTEXTS]
Definition hevcdec.h:183
uint8_t stat_coeff[HEVC_STAT_COEFFS]
Definition hevcdec.h:184
int is_nalff
this flag is != 0 if bitstream is encapsulated as a format defined in 14496-15
Definition hevcdec.h:560
HEVCLocalContext * local_ctx
Definition hevcdec.h:494
int64_t pkt_dts
Definition hevcdec.h:580
int film_grain_warning_shown
Definition hevcdec.h:577
int * view_ids
Definition hevcdec.h:565
int last_eos
last packet contains an EOS/EOB NAL
Definition hevcdec.h:528
unsigned nb_view_pos_available
Definition hevcdec.h:572
int temporal_id
temporal_id_plus1 - 1
Definition hevcdec.h:521
AVBufferRef * rpu_buf
0 or 1 Dolby Vision RPUs.
Definition hevcdec.h:582
const HEVCPPS * pps
RefStruct reference.
Definition hevcdec.h:518
struct AVContainerFifo * output_fifo
Definition hevcdec.h:508
int nal_length_size
Number of bytes used for nal length (1, 2 or 4)
Definition hevcdec.h:574
unsigned cur_layer
Definition hevcdec.h:500
unsigned nb_view_ids_available
Definition hevcdec.h:569
HEVCLayerContext layers[HEVC_VPS_MAX_LAYERS]
Definition hevcdec.h:498
HEVCSEI sei
Definition hevcdec.h:511
BswapDSPContext bdsp
Definition hevcdec.h:537
HEVCDSPContext hevcdsp
Definition hevcdec.h:535
HEVCFrame * collocated_ref
Definition hevcdec.h:523
H2645Packet pkt
Definition hevcdec.h:553
struct ThreadProgress * wpp_progress
Definition hevcdec.h:546
AVCodecContext * avctx
Definition hevcdec.h:492
SliceHeader sh
Definition hevcdec.h:519
const AVClass * c
Definition hevcdec.h:491
uint8_t * checksum_buf
used on BE to byteswap the lines for checksumming
Definition hevcdec.h:540
unsigned * view_pos_available
Definition hevcdec.h:571
int recovery_poc
Definition hevcdec.h:529
unsigned finish_setup_nal_idx
Definition hevcdec.h:558
HEVCCABACState cabac
The target for the common_cabac_state of the local contexts.
Definition hevcdec.h:544
VideoDSPContext vdsp
Definition hevcdec.h:536
unsigned * view_ids_available
Definition hevcdec.h:568
HEVCPredContext hpc
Definition hevcdec.h:534
RefPicList rps[NB_RPS_TYPE]
candidate references for the current frame
Definition hevcdec.h:515
int eos
current packet contains an EOS/EOB NAL
Definition hevcdec.h:527
struct AVMD5 * md5_ctx
Definition hevcdec.h:512
unsigned layers_active_output
Definition hevcdec.h:503
HEVCParamSets ps
Definition hevcdec.h:510
int apply_defdispwin
Definition hevcdec.h:562
DOVIContext dovi_ctx
Dolby Vision decoding context.
Definition hevcdec.h:583
atomic_int wpp_err
Definition hevcdec.h:549
uint8_t slice_initialized
1 if the independent slice segment header was successfully parsed
Definition hevcdec.h:506
enum HEVCNALUnitType first_nal_type
Definition hevcdec.h:555
HEVCFrame * cur_frame
Definition hevcdec.h:522
const HEVCVPS * vps
RefStruct reference.
Definition hevcdec.h:517
int poc_tid0
Definition hevcdec.h:525
enum HEVCNALUnitType nal_unit_type
Definition hevcdec.h:520
unsigned nb_local_ctx
Definition hevcdec.h:495
int slice_idx
number of the slice being currently decoded
Definition hevcdec.h:526
const uint8_t * data
Definition hevcdec.h:551
unsigned layers_active_decode
Definition hevcdec.h:502
int checksum_buf_size
Definition hevcdec.h:541
unsigned nb_wpp_progress
Definition hevcdec.h:547
int nuh_layer_id
Definition hevcdec.h:575
int no_rasl_output_flag
Definition hevcdec.h:532
unsigned nb_view_ids
Definition hevcdec.h:566
int needs_fg
Definition hevcdec.h:368
RefPicListTab ** rpl_tab
RefStruct reference.
Definition hevcdec.h:371
void * hwaccel_picture_private
RefStruct reference.
Definition hevcdec.h:379
ProgressFrame tf
Definition hevcdec.h:365
const HEVCPPS * pps
RefStruct reference.
Definition hevcdec.h:375
AVFrame * f
Definition hevcdec.h:363
RefPicListTab * rpl
RefStruct reference.
Definition hevcdec.h:376
uint8_t flags
A combination of HEVC_FRAME_FLAG_*.
Definition hevcdec.h:388
int poc
Definition hevcdec.h:373
AVFrame * frame_grain
Definition hevcdec.h:367
RefPicList * refPicList
Definition hevcdec.h:370
MvField * tab_mvf
RefStruct reference.
Definition hevcdec.h:369
int nb_rpl_elems
Definition hevcdec.h:377
int ctb_count
Definition hevcdec.h:372
int base_layer_frame
Definition hevcdec.h:383
uint8_t * skip_flag
Definition hevcdec.h:465
HEVCFrame DPB[32]
Definition hevcdec.h:453
HEVCFrame * cur_frame
Definition hevcdec.h:454
uint8_t * filter_slice_edges
Definition hevcdec.h:474
const HEVCSPS * sps
Definition hevcdec.h:456
struct AVRefStructPool * rpl_tab_pool
Definition hevcdec.h:487
int32_t * tab_slice_address
Definition hevcdec.h:476
uint8_t * sao_pixel_buffer_h[3]
Definition hevcdec.h:483
uint8_t * tab_ct_depth
Definition hevcdec.h:466
int8_t * qp_y_tab
Definition hevcdec.h:478
DBParams * deblock
Definition hevcdec.h:462
uint8_t * cbf_luma
Definition hevcdec.h:469
uint8_t * tab_ipm
Definition hevcdec.h:470
uint8_t * is_pcm
Definition hevcdec.h:471
SAOParams * sao
Definition hevcdec.h:461
struct AVRefStructPool * tab_mvf_pool
Definition hevcdec.h:486
uint8_t * sao_pixel_buffer_v[3]
Definition hevcdec.h:484
uint8_t * vertical_bs
Definition hevcdec.h:481
uint8_t * horizontal_bs
Definition hevcdec.h:480
int8_t curr_qp_y
Definition hevcdec.h:416
uint8_t ctb_left_flag
Definition hevcdec.h:422
PredictionUnit pu
Definition hevcdec.h:436
uint8_t ctb_up_left_flag
Definition hevcdec.h:425
uint8_t edge_emu_buffer[(MAX_PB_SIZE+7) *EDGE_EMU_BUFFER_STRIDE *2]
Definition hevcdec.h:429
uint8_t cabac_state[HEVC_CONTEXTS]
Definition hevcdec.h:392
char padding[128]
Definition hevcdec.h:449
TransformUnit tu
Definition hevcdec.h:420
const struct HEVCContext * parent
Definition hevcdec.h:399
NeighbourAvailable na
Definition hevcdec.h:437
int16_t tmp[MAX_PB_SIZE *MAX_PB_SIZE]
Definition hevcdec.h:432
HEVCCABACState * common_cabac_state
This is a pointer to the common CABAC state.
Definition hevcdec.h:413
uint8_t ctb_up_flag
Definition hevcdec.h:423
CodingUnit cu
Definition hevcdec.h:435
uint8_t first_qp_group
Definition hevcdec.h:396
uint8_t ctb_up_right_flag
Definition hevcdec.h:424
uint8_t edge_emu_buffer2[(MAX_PB_SIZE+7) *EDGE_EMU_BUFFER_STRIDE *2]
Definition hevcdec.h:431
CABACContext cc
Definition hevcdec.h:401
uint8_t stat_coeff[HEVC_STAT_COEFFS]
Definition hevcdec.h:394
Definition ps.h:371
Definition sei.h:106
Definition ps.h:252
Definition ps.h:168
uint8_t used[32]
Definition hevcdec.h:190
uint8_t nb_refs
Definition hevcdec.h:191
int poc[32]
Definition hevcdec.h:188
uint8_t poc_msb_present[32]
Definition hevcdec.h:189
int8_t ref_idx[2]
refIdxL0, refIdxL1
Definition hevcdec.h:310
int8_t pred_flag
Definition hevcdec.h:311
Mv mv[2]
mvL0, vvL1
Definition hevcdec.h:309
Definition hevcdec.h:303
int16_t x
horizontal component of motion vector
Definition hevcdec.h:304
int16_t y
vertical component of motion vector
Definition hevcdec.h:305
uint8_t intra_pred_mode_c[4]
Definition hevcdec.h:329
uint8_t intra_pred_mode[4]
Definition hevcdec.h:326
int rem_intra_luma_pred_mode
Definition hevcdec.h:325
uint8_t merge_flag
Definition hevcdec.h:328
uint8_t chroma_mode_c[4]
Definition hevcdec.h:330
The ProgressFrame structure.
RefPicList refPicList[2]
Definition hevcdec.h:202
int isLongTerm[HEVC_MAX_REFS]
Definition hevcdec.h:197
struct HEVCFrame * ref[HEVC_MAX_REFS]
Definition hevcdec.h:195
int nb_refs
Definition hevcdec.h:198
int list[HEVC_MAX_REFS]
Definition hevcdec.h:196
int16_t chroma_weight_l1[16][2]
Definition hevcdec.h:277
uint8_t cu_chroma_qp_offset_enabled_flag
Definition hevcdec.h:257
const ShortTermRPS * short_term_rps
Definition hevcdec.h:228
unsigned int slice_addr
address (in raster order) of the first block in the current slice
Definition hevcdec.h:211
int16_t luma_weight_l0[16]
Definition hevcdec.h:275
uint8_t disable_deblocking_filter_flag
slice_header_disable_deblocking_filter_flag
Definition hevcdec.h:243
uint8_t max_num_merge_cand
5 - 5_minus_max_num_merge_cand
Definition hevcdec.h:262
uint8_t mvd_l1_zero_flag
Definition hevcdec.h:240
uint8_t slice_temporal_mvp_enabled_flag
Definition hevcdec.h:235
int tc_offset
tc_offset_div2 * 2
Definition hevcdec.h:260
uint8_t luma_log2_weight_denom
Definition hevcdec.h:272
int8_t slice_qp
Definition hevcdec.h:270
uint8_t no_output_of_prior_pics_flag
Definition hevcdec.h:234
unsigned int pps_id
Definition hevcdec.h:206
int16_t luma_weight_l1[16]
Definition hevcdec.h:278
uint8_t colour_plane_id
Definition hevcdec.h:221
int short_term_ref_pic_set_sps_flag
RPS coded in the slice header itself is stored here.
Definition hevcdec.h:225
unsigned data_offset
Definition hevcdec.h:287
uint8_t use_integer_mv_flag
Definition hevcdec.h:263
int slice_cb_qp_offset
Definition hevcdec.h:250
int16_t luma_offset_l1[16]
Definition hevcdec.h:283
int16_t chroma_offset_l1[16][2]
Definition hevcdec.h:284
enum HEVCSliceType slice_type
Definition hevcdec.h:213
int * size
Definition hevcdec.h:267
unsigned int list_entry_lx[2][32]
Definition hevcdec.h:231
uint8_t inter_layer_pred
Definition hevcdec.h:222
unsigned * entry_point_offset
Definition hevcdec.h:265
int16_t chroma_offset_l0[16][2]
Definition hevcdec.h:281
unsigned int slice_segment_addr
address (in raster order) of the first block in the current slice segment
Definition hevcdec.h:209
int slice_ctb_addr_rs
Definition hevcdec.h:286
unsigned int nb_refs[2]
Definition hevcdec.h:237
int slice_act_y_qp_offset
Definition hevcdec.h:253
int slice_qp_delta
Definition hevcdec.h:249
uint8_t cabac_init_flag
Definition hevcdec.h:242
int16_t chroma_log2_weight_denom
Definition hevcdec.h:273
int16_t chroma_weight_l0[16][2]
Definition hevcdec.h:276
int slice_act_cb_qp_offset
Definition hevcdec.h:254
uint8_t dependent_slice_segment_flag
Definition hevcdec.h:219
int * offset
Definition hevcdec.h:266
ShortTermRPS slice_rps
Definition hevcdec.h:227
uint8_t rpl_modification_flag[2]
Definition hevcdec.h:233
int short_term_ref_pic_set_size
Definition hevcdec.h:226
uint8_t first_slice_in_pic_flag
Definition hevcdec.h:218
LongTermRPS long_term_rps
Definition hevcdec.h:230
int num_entry_point_offsets
Definition hevcdec.h:268
uint8_t slice_sample_adaptive_offset_flag[3]
Definition hevcdec.h:239
unsigned int collocated_ref_idx
Definition hevcdec.h:247
int16_t luma_offset_l0[16]
Definition hevcdec.h:280
int beta_offset
beta_offset_div2 * 2
Definition hevcdec.h:259
int slice_act_cr_qp_offset
Definition hevcdec.h:255
uint8_t slice_loop_filter_across_slices_enabled_flag
Definition hevcdec.h:244
uint8_t collocated_list
Definition hevcdec.h:245
uint8_t pic_output_flag
Definition hevcdec.h:220
int slice_cr_qp_offset
Definition hevcdec.h:251
int long_term_ref_pic_set_size
Definition hevcdec.h:229
int pic_order_cnt_lsb
Definition hevcdec.h:215
ThreadProgress is an API to easily notify other threads about progress of any kind as long as it can ...
uint8_t is_cu_chroma_qp_offset_coded
Definition hevcdec.h:343
uint8_t cross_pf
Definition hevcdec.h:346
int cu_qp_delta
Definition hevcdec.h:334
int8_t cu_qp_offset_cr
Definition hevcdec.h:345
int intra_pred_mode_c
Definition hevcdec.h:340
int8_t cu_qp_offset_cb
Definition hevcdec.h:344
int chroma_mode_c
Definition hevcdec.h:341
uint8_t is_cu_qp_delta_coded
Definition hevcdec.h:342
int res_scale_val
Definition hevcdec.h:336
int intra_pred_mode
Definition hevcdec.h:339
int size
Core video DSP helper functions.
#define MODE_INTRA
Definition vp3.c:83