github.com/cnotch/ipchub@v1.1.0/av/codec/hevc/const.go (about) 1 // Copyright (c) 2019,CAOHONGJU All rights reserved. 2 // Use of this source code is governed by a MIT-style 3 // license that can be found in the LICENSE file. 4 5 package hevc 6 7 /** 8 * Table 7-1 – NAL unit type codes and NAL unit type classes in 9 * T-REC-H.265-201802 10 */ 11 const ( 12 NalTrailN = 0 13 NalTrailR = 1 14 NalTsaN = 2 15 NalTsaR = 3 16 NalStsaN = 4 17 NalStsaR = 5 18 NalRadlN = 6 19 NalRadlR = 7 20 NalRaslN = 8 21 NalRaslR = 9 22 NalVclN10 = 10 23 NalVclR11 = 11 24 NalVclN12 = 12 25 NalVclR13 = 13 26 NalVclN14 = 14 27 NalVclR15 = 15 28 NalBlaWLp = 16 29 NalBlaWRadl = 17 30 NalBlaNLp = 18 31 NalIdrWRadl = 19 32 NalIdrNLp = 20 33 NalCraNut = 21 34 NalIrapVcl22 = 22 35 NalIrapVcl23 = 23 36 NalRsvVcl24 = 24 37 NalRsvVcl25 = 25 38 NalRsvVcl26 = 26 39 NalRsvVcl27 = 27 40 NalRsvVcl28 = 28 41 NalRsvVcl29 = 29 42 NalRsvVcl30 = 30 43 NalRsvVcl31 = 31 44 NalVps = 32 45 NalSps = 33 46 NalPps = 34 47 NalAud = 35 48 NalEosNut = 36 49 NalEobNut = 37 50 NalFdNut = 38 51 NalSeiPrefix = 39 52 NalSeiSuffix = 40 53 NalRsvNvcl41 = 41 54 NalRsvNvcl42 = 42 55 NalRsvNvcl43 = 43 56 NalRsvNvcl44 = 44 57 NalRsvNvcl45 = 45 58 NalRsvNvcl46 = 46 59 NalRsvNvcl47 = 47 60 NalUnspec48 = 48 61 NalUnspec49 = 49 62 NalUnspec50 = 50 63 NalUnspec51 = 51 64 NalUnspec52 = 52 65 NalUnspec53 = 53 66 NalUnspec54 = 54 67 NalUnspec55 = 55 68 NalUnspec56 = 56 69 NalUnspec57 = 57 70 NalUnspec58 = 58 71 NalUnspec59 = 59 72 NalUnspec60 = 60 73 NalUnspec61 = 61 74 NalUnspec62 = 62 75 NalUnspec63 = 63 76 77 // RTP 中扩展 78 NalStapInRtp = 48 79 NalFuInRtp = 49 80 ) 81 82 // HEVC(h265) 的图像片类型 83 const ( 84 SliceB = 0 85 SliceP = 1 86 SliceI = 2 87 ) 88 89 /** ffmpeg 中帧统计代码 90 static int hevc_probe(char* pbuf, int buf_size) 91 { 92 unsigned int code = -1; 93 int vps = 0, sps = 0, pps = 0, irap = 0; 94 int i; 95 96 for (i = 0; i < buf_size - 1; i++) { 97 code = (code << 8) + pbuf[i]; 98 if ((code & 0xffffff00) == 0x100) { 99 char nal2 = pbuf[i + 1]; 100 int type = (code & 0x7E) >> 1; 101 102 if (code & 0x81) // forbidden and reserved zero bits 103 return 0; 104 105 if (nal2 & 0xf8) // reserved zero 106 return 0; 107 108 switch (type) { 109 case NalVPS: vps++; break; 110 case NalSPS: sps++; break; 111 case NalPPS: pps++; break; 112 case NalBLA_N_LP: 113 case NalBLA_W_LP: 114 case NalBLA_W_RADL: 115 case NalCRA_NUT: 116 case NalIDR_N_LP: 117 case NalIDR_W_RADL: irap++; break; 118 } 119 } 120 } 121 122 return 0; 123 } 124 **/ 125 126 const ( 127 // 7.4.3.1: vps_max_layers_minus1 is in [0, 62]. 128 HEVC_MAX_LAYERS = 63 129 // 7.4.3.1: vps_max_sub_layers_minus1 is in [0, 6]. 130 HEVC_MAX_SUB_LAYERS = 7 131 // 7.4.3.1: vps_num_layer_sets_minus1 is in [0, 1023]. 132 HEVC_MAX_LAYER_SETS = 1024 133 134 // 7.4.2.1: vps_video_parameter_set_id is u(4). 135 HEVC_MAX_VPS_COUNT = 16 136 // 7.4.3.2.1: sps_seq_parameter_set_id is in [0, 15]. 137 HEVC_MAX_SPS_COUNT = 16 138 // 7.4.3.3.1: pps_pic_parameter_set_id is in [0, 63]. 139 HEVC_MAX_PPS_COUNT = 64 140 141 // A.4.2: MaxDpbSize is bounded above by 16. 142 HEVC_MAX_DPB_SIZE = 16 143 // 7.4.3.1: vps_max_dec_pic_buffering_minus1[i] is in [0, MaxDpbSize - 1]. 144 HEVC_MAX_REFS = HEVC_MAX_DPB_SIZE 145 146 // 7.4.3.2.1: num_short_term_ref_pic_sets is in [0, 64]. 147 HEVC_MAX_SHORT_TERM_REF_PIC_SETS = 64 148 // 7.4.3.2.1: num_long_term_ref_pics_sps is in [0, 32]. 149 HEVC_MAX_LONG_TERM_REF_PICS = 32 150 151 // A.3: all profiles require that CtbLog2SizeY is in [4, 6]. 152 HEVC_MIN_LOG2_CTB_SIZE = 4 153 HEVC_MAX_LOG2_CTB_SIZE = 6 154 155 // E.3.2: cpb_cnt_minus1[i] is in [0, 31]. 156 HEVC_MAX_CPB_CNT = 32 157 158 // A.4.1: in table A.6 the highest level allows a MaxLumaPs of 35 651 584. 159 HEVC_MAX_LUMA_PS = 35651584 160 // A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are 161 // constrained to be not greater than sqrt(MaxLumaPs * 8). Hence height/ 162 // width are bounded above by sqrt(8 * 35651584) = 16888.2 samples. 163 HEVC_MAX_WIDTH = 16888 164 HEVC_MAX_HEIGHT = 16888 165 166 // A.4.1: table A.6 allows at most 22 tile rows for any level. 167 HEVC_MAX_TILE_ROWS = 22 168 // A.4.1: table A.6 allows at most 20 tile columns for any level. 169 HEVC_MAX_TILE_COLUMNS = 20 170 171 // A.4.2: table A.6 allows at most 600 slice segments for any level. 172 HEVC_MAX_SLICE_SEGMENTS = 600 173 174 // 7.4.7.1: in the worst case (tiles_enabled_flag and 175 // entropy_coding_sync_enabled_flag are both set), entry points can be 176 // placed at the beginning of every Ctb row in every tile, giving an 177 // upper bound of (num_tile_columns_minus1 + 1) * PicHeightInCtbsY - 1. 178 // Only a stream with very high resolution and perverse parameters could 179 // get near that, though, so set a lower limit here with the maximum 180 // possible value for 4K video (at most 135 16x16 Ctb rows). 181 HEVC_MAX_ENTRY_POINT_OFFSETS = HEVC_MAX_TILE_COLUMNS * 135 182 )