1 /* 2 * 3 * Copyright 2015 Rockchip Electronics Co. LTD 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 19 #ifndef __H265_SYNTAX_H__ 20 #define __H265_SYNTAX_H__ 21 22 #define PIXW_1080P (1920) 23 #define PIXH_1080P (1088) 24 #define PIXW_4Kx2K (4096) 25 #define PIXH_4Kx2K (2304) 26 #define PIXW_8Kx4K (8192) 27 #define PIXH_8Kx4K (4320) 28 29 #if 0 30 31 #define REF_PIC_LIST_NUM_IDX 32 32 #define H265E_UUID_LENGTH 16 33 34 #define MAX_CPB_CNT 32 ///< Upper bound of (cpb_cnt_minus1 + 1) 35 #define MAX_NUM_LAYER_IDS 64 36 #define MAX_NUM_VPS 16 37 #define MAX_NUM_SPS 16 38 #define MAX_NUM_PPS 64 39 #define MAX_TLAYER 7 ///< max number of temporal layer 40 #define MAX_VPS_NUM_HRD_PARAMETERS 1 41 #define MAX_VPS_OP_SETS_PLUS1 1024 42 #define MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 1 43 #define MAX_NUM_REF_PICS 16 ///< max. number of pictures used for reference 44 #define MAX_NUM_REF 16 ///< max. number of entries in picture reference list 45 #define MAX_CU_DEPTH 6 // log2(LCUSize) 46 47 #define REF_PIC_LIST_0 0 48 #define REF_PIC_LIST_1 1 49 #define REF_PIC_LIST_X 100 50 #define REF_BY_RECN(idx) (0x00000001 << idx) 51 #define REF_BY_REFR(idx) (0x00000001 << idx) 52 #define MAX_NUM_REF_PICS 16 53 54 #endif 55 56 #define MAX_DPB_SIZE 17 // A.4.1 57 #define MAX_REFS 16 58 59 /** 60 * 7.4.2.1 61 */ 62 #define MAX_SUB_LAYERS 7 63 #define MAX_VPS_COUNT 16 64 #define MAX_SPS_COUNT 16 65 #define MAX_PPS_COUNT 64 66 #define MAX_SHORT_TERM_RPS_COUNT 64 67 #define MAX_CU_SIZE 128 68 69 //TODO: check if this is really the maximum 70 #define MAX_TRANSFORM_DEPTH 5 71 72 #define MAX_TB_SIZE 32 73 #define MAX_PB_SIZE 64 74 #define MAX_LOG2_CTB_SIZE 6 75 #define MAX_QP 51 76 #define DEFAULT_INTRA_TC_OFFSET 2 77 78 #define HEVC_CONTEXTS 183 79 80 #define MRG_MAX_NUM_CANDS 5 81 82 #define L0 0 83 #define L1 1 84 85 #define REF_PIC_LIST_NUM_IDX 32 86 #define MAX_CPB_CNT 32 //< Upper bound of (cpb_cnt_minus1 + 1) 87 #define MAX_CU_DEPTH 6 // log2(LCUSize) 88 #define MAX_VPS_NUM_HRD_PARAMETERS 1 89 #define MAX_VPS_OP_SETS_PLUS1 1024 90 #define MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 1 91 #define MAX_NUM_LONG_TERM_REF_PIC_POC 20 92 #define REF_BY_RECN(idx) (0x00000001 << idx) 93 #define REF_BY_REFR(idx) (0x00000001 << idx) 94 95 96 97 98 #define EPEL_EXTRA_BEFORE 1 99 #define EPEL_EXTRA_AFTER 2 100 #define EPEL_EXTRA 3 101 #define QPEL_EXTRA_BEFORE 3 102 #define QPEL_EXTRA_AFTER 4 103 #define QPEL_EXTRA 7 104 105 #define EDGE_EMU_BUFFER_STRIDE 80 106 107 #define MPP_INPUT_BUFFER_PADDING_SIZE 8 108 109 #define MPP_PROFILE_HEVC_MAIN 1 110 #define MPP_PROFILE_HEVC_MAIN_10 2 111 #define MPP_PROFILE_HEVC_MAIN_STILL_PICTURE 3 112 113 #define LOG2_MAX_CTB_SIZE 6 114 #define LOG2_MIN_CTB_SIZE 4 115 #define LOG2_MAX_PU_SIZE 6 116 #define LOG2_MIN_PU_SIZE 2 117 #define LOG2_MAX_TU_SIZE 5 118 #define LOG2_MIN_TU_SIZE 2 119 #define LOG2_MAX_CU_SIZE 6 120 #define LOG2_MIN_CU_SIZE 3 121 122 /** 123 * Value of the luma sample at position (x, y) in the 2D array tab. 124 */ 125 #define IS_IDR(s) (s->nal_unit_type == NAL_IDR_W_RADL || s->nal_unit_type == NAL_IDR_N_LP) 126 #define IS_BLA(s) (s->nal_unit_type == NAL_BLA_W_RADL || s->nal_unit_type == NAL_BLA_W_LP || \ 127 s->nal_unit_type == NAL_BLA_N_LP) 128 #define IS_IRAP(s) (s->nal_unit_type >= 16 && s->nal_unit_type <= 23) 129 #define IS_CRA(s) (s->nal_unit_type == NAL_CRA_NUT) 130 131 /** 132 * Table 7-3: NAL unit type codes 133 */ 134 enum NALUnitType { 135 NAL_INIT_VALUE = -1, 136 NAL_TRAIL_N = 0, 137 NAL_TRAIL_R = 1, 138 NAL_TSA_N = 2, 139 NAL_TSA_R = 3, 140 NAL_STSA_N = 4, 141 NAL_STSA_R = 5, 142 NAL_RADL_N = 6, 143 NAL_RADL_R = 7, 144 NAL_RASL_N = 8, 145 NAL_RASL_R = 9, 146 NAL_BLA_W_LP = 16, 147 NAL_BLA_W_RADL = 17, 148 NAL_BLA_N_LP = 18, 149 NAL_IDR_W_RADL = 19, 150 NAL_IDR_N_LP = 20, 151 NAL_CRA_NUT = 21, 152 NAL_VPS = 32, 153 NAL_SPS = 33, 154 NAL_PPS = 34, 155 NAL_AUD = 35, 156 NAL_EOS_NUT = 36, 157 NAL_EOB_NUT = 37, 158 NAL_FD_NUT = 38, 159 NAL_SEI_PREFIX = 39, 160 NAL_SEI_SUFFIX = 40, 161 NAL_UNSPEC62 = 62, 162 }; 163 164 typedef enum H265NalPriority_t { 165 H265_NAL_PRIORITY_DISPOSABLE = 0, 166 H265_NAL_PRIORITY_LOW = 1, 167 H265_NAL_PRIORITY_HIGH = 2, 168 H265_NAL_PRIORITY_HIGHEST = 3, 169 } H265NalPriority; 170 171 172 enum RPSType { 173 ST_CURR_BEF = 0, 174 ST_CURR_AFT, 175 ST_FOLL, 176 LT_CURR, 177 LT_FOLL, 178 NB_RPS_TYPE, 179 }; 180 181 typedef enum SliceType_t { 182 B_SLICE = 0, 183 P_SLICE = 1, 184 I_SLICE = 2, 185 } SliceType; 186 187 typedef enum { 188 H265_LEVEL_NONE = 0, 189 H265_LEVEL1 = 30, 190 H265_LEVEL2 = 60, 191 H265_LEVEL2_1 = 63, 192 H265_LEVEL3 = 90, 193 H265_LEVEL3_1 = 93, 194 H265_LEVEL4 = 120, 195 H265_LEVEL4_1 = 123, 196 H265_LEVEL5 = 150, 197 H265_LEVEL5_1 = 153, 198 H265_LEVEL5_2 = 156, 199 H265_LEVEL6 = 180, 200 H265_LEVEL6_1 = 183, 201 H265_LEVEL6_2 = 186, 202 H265_LEVEL8_5 = 255, 203 } H265Level; 204 205 #endif 206