1 /* 2 * H.265 video codec. 3 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de> 4 * 5 * This file is part of libde265. 6 * 7 * libde265 is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU Lesser General Public License as 9 * published by the Free Software Foundation, either version 3 of 10 * the License, or (at your option) any later version. 11 * 12 * libde265 is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public License 18 * along with libde265. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef DE265_VPS_H 22 #define DE265_VPS_H 23 24 #ifdef HAVE_CONFIG_H 25 #include <config.h> 26 #endif 27 28 #ifdef HAVE_STDBOOL_H 29 #include <stdbool.h> 30 #endif 31 32 #include "libde265/bitstream.h" 33 #include "libde265/de265.h" 34 #include "libde265/cabac.h" 35 36 #include <vector> 37 38 class error_queue; 39 40 #define MAX_TEMPORAL_SUBLAYERS 8 41 42 43 enum profile_idc { 44 Profile_Main = 1, 45 Profile_Main10 = 2, 46 Profile_MainStillPicture = 3, 47 Profile_FormatRangeExtensions = 4 48 }; 49 50 51 class profile_data { 52 public: 53 void read(bitreader* reader); 54 void write(CABAC_encoder& writer) const; 55 void dump(bool general, FILE* fh) const; 56 57 void set_defaults(enum profile_idc, int level_major, int level_minor); 58 59 // --- profile --- 60 61 char profile_present_flag; // always true for general profile 62 63 char profile_space; // currently always 0 64 char tier_flag; // main tier or low tier (see Table A-66/A-67) 65 enum profile_idc profile_idc; // profile 66 67 char profile_compatibility_flag[32]; // to which profile we are compatible 68 69 char progressive_source_flag; 70 char interlaced_source_flag; 71 char non_packed_constraint_flag; 72 char frame_only_constraint_flag; 73 74 75 // --- level --- 76 77 char level_present_flag; // always true for general level 78 int level_idc; // level * 30 79 }; 80 81 82 class profile_tier_level 83 { 84 public: 85 void read(bitreader* reader, int max_sub_layers); 86 void write(CABAC_encoder& writer, int max_sub_layers) const; 87 void dump(int max_sub_layers, FILE* fh) const; 88 89 profile_data general; 90 91 //bool sub_layer_profile_present[MAX_TEMPORAL_SUBLAYERS]; 92 //bool sub_layer_level_present[MAX_TEMPORAL_SUBLAYERS]; 93 94 profile_data sub_layer[MAX_TEMPORAL_SUBLAYERS]; 95 }; 96 97 98 /* 99 struct bit_rate_pic_rate_info { 100 char bit_rate_info_present_flag[8]; 101 char pic_rate_info_present_flag[8]; 102 103 int avg_bit_rate[8]; 104 int max_bit_rate[8]; 105 106 char constant_pic_rate_idc[8]; 107 int avg_pic_rate[8]; 108 109 }; 110 111 void read_bit_rate_pic_rate_info(bitreader* reader, 112 struct bit_rate_pic_rate_info* hdr, 113 int TempLevelLow, 114 int TempLevelHigh); 115 116 void dump_bit_rate_pic_rate_info(struct bit_rate_pic_rate_info* hdr, 117 int TempLevelLow, 118 int TempLevelHigh); 119 */ 120 121 122 typedef struct { 123 int vps_max_dec_pic_buffering; // [1 ; ] 124 int vps_max_num_reorder_pics; // [0 ; ] 125 int vps_max_latency_increase; // 0 -> no limit, otherwise value is (x-1) 126 } layer_data; 127 128 129 class video_parameter_set 130 { 131 public: 132 de265_error read(error_queue* errqueue, bitreader* reader); 133 de265_error write(error_queue* errqueue, CABAC_encoder& out) const; 134 void dump(int fd) const; 135 136 void set_defaults(enum profile_idc profile, int level_major, int level_minor); 137 138 int video_parameter_set_id; 139 int vps_max_layers; // [1;?] currently always 1 140 int vps_max_sub_layers; // [1;7] number of temporal sub-layers 141 int vps_temporal_id_nesting_flag; // indicate temporal up-switching always possible 142 profile_tier_level profile_tier_level_; 143 144 int vps_sub_layer_ordering_info_present_flag; 145 layer_data layer[MAX_TEMPORAL_SUBLAYERS]; 146 147 uint8_t vps_max_layer_id; // max value for nuh_layer_id in NALs 148 int vps_num_layer_sets; // [1;1024], currently always 1 149 150 std::vector<std::vector<bool> > layer_id_included_flag; // max size = [1024][64] 151 152 153 // --- timing info --- 154 155 char vps_timing_info_present_flag; 156 uint32_t vps_num_units_in_tick; 157 uint32_t vps_time_scale; 158 char vps_poc_proportional_to_timing_flag; 159 uint32_t vps_num_ticks_poc_diff_one; 160 161 int vps_num_hrd_parameters; // currently [0;1] 162 163 std::vector<uint16_t> hrd_layer_set_idx; // max size = 1024 164 std::vector<char> cprms_present_flag; // max size = 1024 165 166 167 // --- vps extension --- 168 169 char vps_extension_flag; 170 }; 171 172 173 #endif 174