digiKam
sps.h
Go to the documentation of this file.
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_SPS_H
22 #define DE265_SPS_H
23 
24 #include "libde265/vps.h"
25 #include "libde265/vui.h"
26 #include "libde265/bitstream.h"
27 #include "libde265/refpic.h"
28 #include "libde265/de265.h"
29 #include "libde265/cabac.h"
30 
31 #include <vector>
32 
33 class error_queue;
34 
35 // #define MAX_REF_PIC_SETS 64 // maximum according to standard
36 #define MAX_NUM_LT_REF_PICS_SPS 32
37 
38 // this is just a safety range
39 #define MAX_PICTURE_WIDTH 70000
40 #define MAX_PICTURE_HEIGHT 70000
41 
42 enum {
48 };
49 
50 
51 typedef struct scaling_list_data {
52  // structure size: approx. 4 kB
53 
54  uint8_t ScalingFactor_Size0[6][4][4];
55  uint8_t ScalingFactor_Size1[6][8][8];
56  uint8_t ScalingFactor_Size2[6][16][16];
57  uint8_t ScalingFactor_Size3[2][32][32];
59 
60 
61 enum PresetSet {
63 };
64 
65 
67 {
68  public:
70 
80 
82  void dump(int fd) const;
83 };
84 
85 
87 public:
90 
93 
94  void dump(int fd) const;
95 
97  void set_CB_log2size_range(int mini,int maxi);
98  void set_TB_log2size_range(int mini,int maxi);
99  void set_resolution(int w,int h);
100 
101  bool sps_read; // whether the sps has been read from the bitstream
102 
103 
105  char sps_max_sub_layers; // [1;7]
107 
109 
112 
117 
122 
125 
128 
129  int sps_max_dec_pic_buffering[7]; // for each temporal layer
132 
133  int log2_min_luma_coding_block_size; // smallest CB size [3;6]
135  int log2_min_transform_block_size; // smallest TB size [2;5]
139 
141  char sps_scaling_list_data_present_flag; /* if not set, the default scaling lists will be set
142  in scaling_list */
143 
145 
149 
155 
156  int num_short_term_ref_pic_sets() const { return ref_pic_sets.size(); }
157  std::vector<ref_pic_set> ref_pic_sets; // [0 ; num_short_term_ref_pic_set (<=MAX_REF_PIC_SETS) )
158 
160 
162 
165 
168 
171 
176 
178 
179  /*
180  if( sps_extension_flag )
181  while( more_rbsp_data() )
182  sps_extension_data_flag
183  u(1)
184  rbsp_trailing_bits()
185  */
186 
187 
188  // --- derived values ---
189 
190  de265_error compute_derived_values(bool sanitize_values = false);
191 
196 
200 
202 
206  int CtbSizeY;
214 
216 
217  int PicWidthInTbsY; // not in standard
218  int PicHeightInTbsY; // not in standard
219  int PicSizeInTbsY; // not in standard
220 
223 
225  int PicWidthInMinPUs; // might be rounded up
226  int PicHeightInMinPUs; // might be rounded up
227 
230 
231  int SpsMaxLatencyPictures[7]; // [temporal layer]
232 
237 
238 
239  int getPUIndexRS(int pixelX,int pixelY) const {
240  return (pixelX>>Log2MinPUSize) + (pixelY>>Log2MinPUSize)*PicWidthInMinPUs;
241  }
242 
243  int get_bit_depth(int cIdx) const {
244  if (cIdx==0) return BitDepth_Y;
245  else return BitDepth_C;
246  }
247 
248  int get_chroma_shift_W(int cIdx) const { return cIdx ? SubWidthC -1 : 0; }
249  int get_chroma_shift_H(int cIdx) const { return cIdx ? SubHeightC-1 : 0; }
250 };
251 
254  scaling_list_data* sclist, bool inPPS);
256 
257 #endif
Definition: cabac.h:55
Definition: decctx.h:128
Definition: vps.h:83
Definition: sps.h:86
char separate_colour_plane_flag
Definition: sps.h:113
char sps_extension_6bits
Definition: sps.h:175
int WinUnitX
Definition: sps.h:199
de265_error read(error_queue *, bitreader *)
uint8_t WpOffsetBdShiftY
Definition: sps.h:233
int Log2MinIpcmCbSizeY
Definition: sps.h:228
int BitDepth_C
Definition: sps.h:194
int chroma_format_idc
Definition: sps.h:111
int log2_diff_max_min_luma_coding_block_size
Definition: sps.h:134
int BitDepth_Y
Definition: sps.h:192
int conf_win_right_offset
Definition: sps.h:119
char vui_parameters_present_flag
Definition: sps.h:169
de265_error compute_derived_values(bool sanitize_values=false)
char sample_adaptive_offset_enabled_flag
Definition: sps.h:147
char long_term_ref_pics_present_flag
Definition: sps.h:159
void set_TB_log2size_range(int mini, int maxi)
int num_short_term_ref_pic_sets() const
Definition: sps.h:156
int PicSizeInMinCbsY
Definition: sps.h:211
void set_resolution(int w, int h)
int max_transform_hierarchy_depth_inter
Definition: sps.h:137
video_usability_information vui
Definition: sps.h:170
int sps_max_latency_increase_plus1[7]
Definition: sps.h:131
int32_t WpOffsetHalfRangeY
Definition: sps.h:235
char used_by_curr_pic_lt_sps_flag[MAX_NUM_LT_REF_PICS_SPS]
Definition: sps.h:164
int WinUnitY
Definition: sps.h:199
int get_chroma_shift_W(int cIdx) const
Definition: sps.h:248
int conf_win_left_offset
Definition: sps.h:118
char sps_range_extension_flag
Definition: sps.h:173
sps_range_extension range_extension
Definition: sps.h:177
int Log2MaxTrafoSize
Definition: sps.h:222
int log2_max_pic_order_cnt_lsb
Definition: sps.h:126
void set_CB_log2size_range(int mini, int maxi)
char strong_intra_smoothing_enable_flag
Definition: sps.h:167
char amp_enabled_flag
Definition: sps.h:146
int32_t WpOffsetHalfRangeC
Definition: sps.h:236
int num_long_term_ref_pics_sps
Definition: sps.h:161
char sps_scaling_list_data_present_flag
Definition: sps.h:141
int CtbSizeY
Definition: sps.h:206
int SubWidthC
Definition: sps.h:198
char sps_multilayer_extension_flag
Definition: sps.h:174
int Log2MinCbSizeY
Definition: sps.h:203
int bit_depth_luma
Definition: sps.h:123
int QpBdOffset_C
Definition: sps.h:195
struct scaling_list_data scaling_list
Definition: sps.h:144
int MaxPicOrderCntLsb
Definition: sps.h:201
int log2_diff_max_min_transform_block_size
Definition: sps.h:136
int PicHeightInMinPUs
Definition: sps.h:226
int Log2MinPUSize
Definition: sps.h:224
int PicWidthInMinCbsY
Definition: sps.h:207
int Log2CtbSizeY
Definition: sps.h:204
int PicSizeInTbsY
Definition: sps.h:219
de265_error write(error_queue *, CABAC_encoder &)
int CtbWidthC
Definition: sps.h:215
int PicWidthInTbsY
Definition: sps.h:217
int Log2MaxIpcmCbSizeY
Definition: sps.h:229
int max_transform_hierarchy_depth_intra
Definition: sps.h:138
char sps_extension_present_flag
Definition: sps.h:172
bool sps_read
Definition: sps.h:101
int log2_min_transform_block_size
Definition: sps.h:135
void dump(int fd) const
int sps_max_dec_pic_buffering[7]
Definition: sps.h:129
int CtbHeightC
Definition: sps.h:215
int seq_parameter_set_id
Definition: sps.h:110
char pcm_loop_filter_disable_flag
Definition: sps.h:154
int PicWidthInCtbsY
Definition: sps.h:208
char pcm_sample_bit_depth_luma
Definition: sps.h:150
char pcm_enabled_flag
Definition: sps.h:148
char pcm_sample_bit_depth_chroma
Definition: sps.h:151
char scaling_list_enable_flag
Definition: sps.h:140
int get_bit_depth(int cIdx) const
Definition: sps.h:243
int PicHeightInMinCbsY
Definition: sps.h:209
char video_parameter_set_id
Definition: sps.h:104
int log2_min_pcm_luma_coding_block_size
Definition: sps.h:152
int log2_diff_max_min_pcm_luma_coding_block_size
Definition: sps.h:153
int conf_win_top_offset
Definition: sps.h:120
int MinCbSizeY
Definition: sps.h:205
int log2_min_luma_coding_block_size
Definition: sps.h:133
void set_defaults(enum PresetSet=Preset_Default)
int pic_width_in_luma_samples
Definition: sps.h:114
int pic_height_in_luma_samples
Definition: sps.h:115
char conformance_window_flag
Definition: sps.h:116
int bit_depth_chroma
Definition: sps.h:124
int ChromaArrayType
Definition: sps.h:197
int PicHeightInTbsY
Definition: sps.h:218
profile_tier_level profile_tier_level_
Definition: sps.h:108
int PicSizeInCtbsY
Definition: sps.h:212
int PicSizeInSamplesY
Definition: sps.h:213
int getPUIndexRS(int pixelX, int pixelY) const
Definition: sps.h:239
char sps_temporal_mvp_enabled_flag
Definition: sps.h:166
int sps_max_num_reorder_pics[7]
Definition: sps.h:130
char sps_sub_layer_ordering_info_present_flag
Definition: sps.h:127
int Log2MinTrafoSize
Definition: sps.h:221
int QpBdOffset_Y
Definition: sps.h:193
int SpsMaxLatencyPictures[7]
Definition: sps.h:231
std::vector< ref_pic_set > ref_pic_sets
Definition: sps.h:157
char sps_max_sub_layers
Definition: sps.h:105
int PicHeightInCtbsY
Definition: sps.h:210
int SubHeightC
Definition: sps.h:198
int PicWidthInMinPUs
Definition: sps.h:225
int lt_ref_pic_poc_lsb_sps[MAX_NUM_LT_REF_PICS_SPS]
Definition: sps.h:163
int conf_win_bottom_offset
Definition: sps.h:121
int get_chroma_shift_H(int cIdx) const
Definition: sps.h:249
char sps_temporal_id_nesting_flag
Definition: sps.h:106
uint8_t WpOffsetBdShiftC
Definition: sps.h:234
Definition: sps.h:67
uint8_t explicit_rdpcm_enabled_flag
Definition: sps.h:74
uint8_t high_precision_offsets_enabled_flag
Definition: sps.h:77
uint8_t intra_smoothing_disabled_flag
Definition: sps.h:76
uint8_t cabac_bypass_alignment_enabled_flag
Definition: sps.h:79
uint8_t implicit_rdpcm_enabled_flag
Definition: sps.h:73
void dump(int fd) const
uint8_t transform_skip_rotation_enabled_flag
Definition: sps.h:71
uint8_t transform_skip_context_enabled_flag
Definition: sps.h:72
uint8_t persistent_rice_adaptation_enabled_flag
Definition: sps.h:78
de265_error read(error_queue *, bitreader *)
uint8_t extended_precision_processing_flag
Definition: sps.h:75
Definition: vui.h:46
de265_error
Definition: de265.h:82
de265_error read_scaling_list(bitreader *, const seq_parameter_set *, scaling_list_data *, bool inPPS)
de265_error write_scaling_list(CABAC_encoder &out, const seq_parameter_set *sps, scaling_list_data *sclist, bool inPPS)
@ CHROMA_MONO
Definition: sps.h:43
@ CHROMA_444
Definition: sps.h:46
@ CHROMA_422
Definition: sps.h:45
@ CHROMA_420
Definition: sps.h:44
@ CHROMA_444_SEPARATE
Definition: sps.h:47
#define MAX_NUM_LT_REF_PICS_SPS
Definition: sps.h:36
struct scaling_list_data scaling_list_data
PresetSet
Definition: sps.h:61
@ Preset_Default
Definition: sps.h:62
void set_default_scaling_lists(scaling_list_data *)
Definition: bitstream.h:39
Definition: sps.h:51
uint8_t ScalingFactor_Size0[6][4][4]
Definition: sps.h:54
uint8_t ScalingFactor_Size2[6][16][16]
Definition: sps.h:56
uint8_t ScalingFactor_Size3[2][32][32]
Definition: sps.h:57
uint8_t ScalingFactor_Size1[6][8][8]
Definition: sps.h:55