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 #define MPP_PROFILE_HEVC_FORMAT_RANGE_EXTENDIONS 4 113 114 #define LOG2_MAX_CTB_SIZE 6 115 #define LOG2_MIN_CTB_SIZE 4 116 #define LOG2_MAX_PU_SIZE 6 117 #define LOG2_MIN_PU_SIZE 2 118 #define LOG2_MAX_TU_SIZE 5 119 #define LOG2_MIN_TU_SIZE 2 120 #define LOG2_MAX_CU_SIZE 6 121 #define LOG2_MIN_CU_SIZE 3 122 123 /** 124 * Value of the luma sample at position (x, y) in the 2D array tab. 125 */ 126 #define IS_IDR(s) (s->nal_unit_type == NAL_IDR_W_RADL || s->nal_unit_type == NAL_IDR_N_LP) 127 #define IS_BLA(s) (s->nal_unit_type == NAL_BLA_W_RADL || s->nal_unit_type == NAL_BLA_W_LP || \ 128 s->nal_unit_type == NAL_BLA_N_LP) 129 #define IS_IRAP(s) (s->nal_unit_type >= 16 && s->nal_unit_type <= 23) 130 #define IS_CRA(s) (s->nal_unit_type == NAL_CRA_NUT) 131 132 /** 133 * Table 7-3: NAL unit type codes 134 */ 135 enum NALUnitType { 136 NAL_INIT_VALUE = -1, 137 NAL_TRAIL_N = 0, 138 NAL_TRAIL_R = 1, 139 NAL_TSA_N = 2, 140 NAL_TSA_R = 3, 141 NAL_STSA_N = 4, 142 NAL_STSA_R = 5, 143 NAL_RADL_N = 6, 144 NAL_RADL_R = 7, 145 NAL_RASL_N = 8, 146 NAL_RASL_R = 9, 147 NAL_BLA_W_LP = 16, 148 NAL_BLA_W_RADL = 17, 149 NAL_BLA_N_LP = 18, 150 NAL_IDR_W_RADL = 19, 151 NAL_IDR_N_LP = 20, 152 NAL_CRA_NUT = 21, 153 NAL_VPS = 32, 154 NAL_SPS = 33, 155 NAL_PPS = 34, 156 NAL_AUD = 35, 157 NAL_EOS_NUT = 36, 158 NAL_EOB_NUT = 37, 159 NAL_FD_NUT = 38, 160 NAL_SEI_PREFIX = 39, 161 NAL_SEI_SUFFIX = 40, 162 NAL_UNSPEC62 = 62, 163 }; 164 165 typedef enum H265NalPriority_t { 166 H265_NAL_PRIORITY_DISPOSABLE = 0, 167 H265_NAL_PRIORITY_LOW = 1, 168 H265_NAL_PRIORITY_HIGH = 2, 169 H265_NAL_PRIORITY_HIGHEST = 3, 170 } H265NalPriority; 171 172 typedef enum { 173 H265_LEVEL_NONE = 0, 174 H265_LEVEL1 = 30, 175 H265_LEVEL2 = 60, 176 H265_LEVEL2_1 = 63, 177 H265_LEVEL3 = 90, 178 H265_LEVEL3_1 = 93, 179 H265_LEVEL4 = 120, 180 H265_LEVEL4_1 = 123, 181 H265_LEVEL5 = 150, 182 H265_LEVEL5_1 = 153, 183 H265_LEVEL5_2 = 156, 184 H265_LEVEL6 = 180, 185 H265_LEVEL6_1 = 183, 186 H265_LEVEL6_2 = 186, 187 H265_LEVEL8_5 = 255, 188 } H265Level; 189 190 typedef enum H265ChromaFmt_e { 191 H265_CHROMA_400 = 0, //!< Monochrome 192 H265_CHROMA_420 = 1, //!< 4:2:0 193 H265_CHROMA_422 = 2, //!< 4:2:2 194 H265_CHROMA_444 = 3 //!< 4:4:4 195 } H265ChromaFmt; 196 197 typedef enum SliceType_t { 198 B_SLICE = 0, 199 P_SLICE = 1, 200 I_SLICE = 2, 201 } SliceType; 202 203 enum RPSType { 204 ST_CURR_BEF = 0, 205 ST_CURR_AFT, 206 ST_FOLL, 207 LT_CURR, 208 LT_FOLL, 209 NB_RPS_TYPE, 210 }; 211 212 #endif 213