1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * HEVC shared code 3cabdff1aSopenharmony_ci * 4cabdff1aSopenharmony_ci * This file is part of FFmpeg. 5cabdff1aSopenharmony_ci * 6cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or 7cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 8cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either 9cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version. 10cabdff1aSopenharmony_ci * 11cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful, 12cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 13cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14cabdff1aSopenharmony_ci * Lesser General Public License for more details. 15cabdff1aSopenharmony_ci * 16cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 17cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software 18cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19cabdff1aSopenharmony_ci */ 20cabdff1aSopenharmony_ci 21cabdff1aSopenharmony_ci#ifndef AVCODEC_HEVC_H 22cabdff1aSopenharmony_ci#define AVCODEC_HEVC_H 23cabdff1aSopenharmony_ci 24cabdff1aSopenharmony_ci/** 25cabdff1aSopenharmony_ci * Table 7-1 – NAL unit type codes and NAL unit type classes in 26cabdff1aSopenharmony_ci * T-REC-H.265-201802 27cabdff1aSopenharmony_ci */ 28cabdff1aSopenharmony_cienum HEVCNALUnitType { 29cabdff1aSopenharmony_ci HEVC_NAL_TRAIL_N = 0, 30cabdff1aSopenharmony_ci HEVC_NAL_TRAIL_R = 1, 31cabdff1aSopenharmony_ci HEVC_NAL_TSA_N = 2, 32cabdff1aSopenharmony_ci HEVC_NAL_TSA_R = 3, 33cabdff1aSopenharmony_ci HEVC_NAL_STSA_N = 4, 34cabdff1aSopenharmony_ci HEVC_NAL_STSA_R = 5, 35cabdff1aSopenharmony_ci HEVC_NAL_RADL_N = 6, 36cabdff1aSopenharmony_ci HEVC_NAL_RADL_R = 7, 37cabdff1aSopenharmony_ci HEVC_NAL_RASL_N = 8, 38cabdff1aSopenharmony_ci HEVC_NAL_RASL_R = 9, 39cabdff1aSopenharmony_ci HEVC_NAL_VCL_N10 = 10, 40cabdff1aSopenharmony_ci HEVC_NAL_VCL_R11 = 11, 41cabdff1aSopenharmony_ci HEVC_NAL_VCL_N12 = 12, 42cabdff1aSopenharmony_ci HEVC_NAL_VCL_R13 = 13, 43cabdff1aSopenharmony_ci HEVC_NAL_VCL_N14 = 14, 44cabdff1aSopenharmony_ci HEVC_NAL_VCL_R15 = 15, 45cabdff1aSopenharmony_ci HEVC_NAL_BLA_W_LP = 16, 46cabdff1aSopenharmony_ci HEVC_NAL_BLA_W_RADL = 17, 47cabdff1aSopenharmony_ci HEVC_NAL_BLA_N_LP = 18, 48cabdff1aSopenharmony_ci HEVC_NAL_IDR_W_RADL = 19, 49cabdff1aSopenharmony_ci HEVC_NAL_IDR_N_LP = 20, 50cabdff1aSopenharmony_ci HEVC_NAL_CRA_NUT = 21, 51cabdff1aSopenharmony_ci HEVC_NAL_RSV_IRAP_VCL22 = 22, 52cabdff1aSopenharmony_ci HEVC_NAL_RSV_IRAP_VCL23 = 23, 53cabdff1aSopenharmony_ci HEVC_NAL_RSV_VCL24 = 24, 54cabdff1aSopenharmony_ci HEVC_NAL_RSV_VCL25 = 25, 55cabdff1aSopenharmony_ci HEVC_NAL_RSV_VCL26 = 26, 56cabdff1aSopenharmony_ci HEVC_NAL_RSV_VCL27 = 27, 57cabdff1aSopenharmony_ci HEVC_NAL_RSV_VCL28 = 28, 58cabdff1aSopenharmony_ci HEVC_NAL_RSV_VCL29 = 29, 59cabdff1aSopenharmony_ci HEVC_NAL_RSV_VCL30 = 30, 60cabdff1aSopenharmony_ci HEVC_NAL_RSV_VCL31 = 31, 61cabdff1aSopenharmony_ci HEVC_NAL_VPS = 32, 62cabdff1aSopenharmony_ci HEVC_NAL_SPS = 33, 63cabdff1aSopenharmony_ci HEVC_NAL_PPS = 34, 64cabdff1aSopenharmony_ci HEVC_NAL_AUD = 35, 65cabdff1aSopenharmony_ci HEVC_NAL_EOS_NUT = 36, 66cabdff1aSopenharmony_ci HEVC_NAL_EOB_NUT = 37, 67cabdff1aSopenharmony_ci HEVC_NAL_FD_NUT = 38, 68cabdff1aSopenharmony_ci HEVC_NAL_SEI_PREFIX = 39, 69cabdff1aSopenharmony_ci HEVC_NAL_SEI_SUFFIX = 40, 70cabdff1aSopenharmony_ci HEVC_NAL_RSV_NVCL41 = 41, 71cabdff1aSopenharmony_ci HEVC_NAL_RSV_NVCL42 = 42, 72cabdff1aSopenharmony_ci HEVC_NAL_RSV_NVCL43 = 43, 73cabdff1aSopenharmony_ci HEVC_NAL_RSV_NVCL44 = 44, 74cabdff1aSopenharmony_ci HEVC_NAL_RSV_NVCL45 = 45, 75cabdff1aSopenharmony_ci HEVC_NAL_RSV_NVCL46 = 46, 76cabdff1aSopenharmony_ci HEVC_NAL_RSV_NVCL47 = 47, 77cabdff1aSopenharmony_ci HEVC_NAL_UNSPEC48 = 48, 78cabdff1aSopenharmony_ci HEVC_NAL_UNSPEC49 = 49, 79cabdff1aSopenharmony_ci HEVC_NAL_UNSPEC50 = 50, 80cabdff1aSopenharmony_ci HEVC_NAL_UNSPEC51 = 51, 81cabdff1aSopenharmony_ci HEVC_NAL_UNSPEC52 = 52, 82cabdff1aSopenharmony_ci HEVC_NAL_UNSPEC53 = 53, 83cabdff1aSopenharmony_ci HEVC_NAL_UNSPEC54 = 54, 84cabdff1aSopenharmony_ci HEVC_NAL_UNSPEC55 = 55, 85cabdff1aSopenharmony_ci HEVC_NAL_UNSPEC56 = 56, 86cabdff1aSopenharmony_ci HEVC_NAL_UNSPEC57 = 57, 87cabdff1aSopenharmony_ci HEVC_NAL_UNSPEC58 = 58, 88cabdff1aSopenharmony_ci HEVC_NAL_UNSPEC59 = 59, 89cabdff1aSopenharmony_ci HEVC_NAL_UNSPEC60 = 60, 90cabdff1aSopenharmony_ci HEVC_NAL_UNSPEC61 = 61, 91cabdff1aSopenharmony_ci HEVC_NAL_UNSPEC62 = 62, 92cabdff1aSopenharmony_ci HEVC_NAL_UNSPEC63 = 63, 93cabdff1aSopenharmony_ci}; 94cabdff1aSopenharmony_ci 95cabdff1aSopenharmony_cienum HEVCSliceType { 96cabdff1aSopenharmony_ci HEVC_SLICE_B = 0, 97cabdff1aSopenharmony_ci HEVC_SLICE_P = 1, 98cabdff1aSopenharmony_ci HEVC_SLICE_I = 2, 99cabdff1aSopenharmony_ci}; 100cabdff1aSopenharmony_ci 101cabdff1aSopenharmony_cienum { 102cabdff1aSopenharmony_ci // 7.4.3.1: vps_max_layers_minus1 is in [0, 62]. 103cabdff1aSopenharmony_ci HEVC_MAX_LAYERS = 63, 104cabdff1aSopenharmony_ci // 7.4.3.1: vps_max_sub_layers_minus1 is in [0, 6]. 105cabdff1aSopenharmony_ci HEVC_MAX_SUB_LAYERS = 7, 106cabdff1aSopenharmony_ci // 7.4.3.1: vps_num_layer_sets_minus1 is in [0, 1023]. 107cabdff1aSopenharmony_ci HEVC_MAX_LAYER_SETS = 1024, 108cabdff1aSopenharmony_ci 109cabdff1aSopenharmony_ci // 7.4.2.1: vps_video_parameter_set_id is u(4). 110cabdff1aSopenharmony_ci HEVC_MAX_VPS_COUNT = 16, 111cabdff1aSopenharmony_ci // 7.4.3.2.1: sps_seq_parameter_set_id is in [0, 15]. 112cabdff1aSopenharmony_ci HEVC_MAX_SPS_COUNT = 16, 113cabdff1aSopenharmony_ci // 7.4.3.3.1: pps_pic_parameter_set_id is in [0, 63]. 114cabdff1aSopenharmony_ci HEVC_MAX_PPS_COUNT = 64, 115cabdff1aSopenharmony_ci 116cabdff1aSopenharmony_ci // A.4.2: MaxDpbSize is bounded above by 16. 117cabdff1aSopenharmony_ci HEVC_MAX_DPB_SIZE = 16, 118cabdff1aSopenharmony_ci // 7.4.3.1: vps_max_dec_pic_buffering_minus1[i] is in [0, MaxDpbSize - 1]. 119cabdff1aSopenharmony_ci HEVC_MAX_REFS = HEVC_MAX_DPB_SIZE, 120cabdff1aSopenharmony_ci 121cabdff1aSopenharmony_ci // 7.4.3.2.1: num_short_term_ref_pic_sets is in [0, 64]. 122cabdff1aSopenharmony_ci HEVC_MAX_SHORT_TERM_REF_PIC_SETS = 64, 123cabdff1aSopenharmony_ci // 7.4.3.2.1: num_long_term_ref_pics_sps is in [0, 32]. 124cabdff1aSopenharmony_ci HEVC_MAX_LONG_TERM_REF_PICS = 32, 125cabdff1aSopenharmony_ci 126cabdff1aSopenharmony_ci // A.3: all profiles require that CtbLog2SizeY is in [4, 6]. 127cabdff1aSopenharmony_ci HEVC_MIN_LOG2_CTB_SIZE = 4, 128cabdff1aSopenharmony_ci HEVC_MAX_LOG2_CTB_SIZE = 6, 129cabdff1aSopenharmony_ci 130cabdff1aSopenharmony_ci // E.3.2: cpb_cnt_minus1[i] is in [0, 31]. 131cabdff1aSopenharmony_ci HEVC_MAX_CPB_CNT = 32, 132cabdff1aSopenharmony_ci 133cabdff1aSopenharmony_ci // A.4.1: in table A.6 the highest level allows a MaxLumaPs of 35 651 584. 134cabdff1aSopenharmony_ci HEVC_MAX_LUMA_PS = 35651584, 135cabdff1aSopenharmony_ci // A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are 136cabdff1aSopenharmony_ci // constrained to be not greater than sqrt(MaxLumaPs * 8). Hence height/ 137cabdff1aSopenharmony_ci // width are bounded above by sqrt(8 * 35651584) = 16888.2 samples. 138cabdff1aSopenharmony_ci HEVC_MAX_WIDTH = 16888, 139cabdff1aSopenharmony_ci HEVC_MAX_HEIGHT = 16888, 140cabdff1aSopenharmony_ci 141cabdff1aSopenharmony_ci // A.4.1: table A.6 allows at most 22 tile rows for any level. 142cabdff1aSopenharmony_ci HEVC_MAX_TILE_ROWS = 22, 143cabdff1aSopenharmony_ci // A.4.1: table A.6 allows at most 20 tile columns for any level. 144cabdff1aSopenharmony_ci HEVC_MAX_TILE_COLUMNS = 20, 145cabdff1aSopenharmony_ci 146cabdff1aSopenharmony_ci // A.4.2: table A.6 allows at most 600 slice segments for any level. 147cabdff1aSopenharmony_ci HEVC_MAX_SLICE_SEGMENTS = 600, 148cabdff1aSopenharmony_ci 149cabdff1aSopenharmony_ci // 7.4.7.1: in the worst case (tiles_enabled_flag and 150cabdff1aSopenharmony_ci // entropy_coding_sync_enabled_flag are both set), entry points can be 151cabdff1aSopenharmony_ci // placed at the beginning of every Ctb row in every tile, giving an 152cabdff1aSopenharmony_ci // upper bound of (num_tile_columns_minus1 + 1) * PicHeightInCtbsY - 1. 153cabdff1aSopenharmony_ci // Only a stream with very high resolution and perverse parameters could 154cabdff1aSopenharmony_ci // get near that, though, so set a lower limit here with the maximum 155cabdff1aSopenharmony_ci // possible value for 4K video (at most 135 16x16 Ctb rows). 156cabdff1aSopenharmony_ci HEVC_MAX_ENTRY_POINT_OFFSETS = HEVC_MAX_TILE_COLUMNS * 135, 157cabdff1aSopenharmony_ci}; 158cabdff1aSopenharmony_ci 159cabdff1aSopenharmony_ci 160cabdff1aSopenharmony_ci#endif /* AVCODEC_HEVC_H */ 161