1 |
14 |
jamey.hick |
|
2 |
|
|
/*!
|
3 |
|
|
**************************************************************************************
|
4 |
|
|
* \file
|
5 |
|
|
* parsetcommon.h
|
6 |
|
|
* \brief
|
7 |
|
|
* Picture and Sequence Parameter Sets, structures common to encoder and decoder
|
8 |
|
|
* This code reflects JVT version xxx
|
9 |
|
|
* \date 25 November 2002
|
10 |
|
|
* \author
|
11 |
|
|
* Main contributors (see contributors.h for copyright, address and affiliation details)
|
12 |
|
|
* - Stephan Wenger <stewe@cs.tu-berlin.de>
|
13 |
|
|
***************************************************************************************
|
14 |
|
|
*/
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
// In the JVT syntax, frequently flags are used that indicate the presence of
|
19 |
|
|
// certain pieces of information in the NALU. Here, these flags are also
|
20 |
|
|
// present. In the encoder, those bits indicate that the values signalled to
|
21 |
|
|
// be present are meaningful and that this part of the syntax should be
|
22 |
|
|
// written to the NALU. In the decoder, the flag indicates that information
|
23 |
|
|
// was received from the decoded NALU and should be used henceforth.
|
24 |
|
|
// The structure names were chosen as indicated in the JVT syntax
|
25 |
|
|
|
26 |
|
|
#ifndef _PARSETCOMMON_H_
|
27 |
|
|
#define _PARSETCOMMON_H_
|
28 |
|
|
|
29 |
|
|
#include "defines.h"
|
30 |
|
|
|
31 |
|
|
#define MAXIMUMPARSETRBSPSIZE 1500
|
32 |
|
|
#define MAXIMUMPARSETNALUSIZE 1500
|
33 |
|
|
#define SIZEslice_group_id (sizeof (int) * 60000) // should be sufficient for HUGE pictures, need one int per MB in a picture
|
34 |
|
|
|
35 |
|
|
#define MAXSPS 32
|
36 |
|
|
#define MAXPPS 256
|
37 |
|
|
|
38 |
|
|
//! Boolean Type
|
39 |
|
|
#ifdef FALSE
|
40 |
|
|
# define Boolean int
|
41 |
|
|
#else
|
42 |
|
|
typedef enum {
|
43 |
|
|
FALSE,
|
44 |
|
|
TRUE
|
45 |
|
|
} Boolean;
|
46 |
|
|
#endif
|
47 |
|
|
|
48 |
|
|
#define MAXIMUMVALUEOFcpb_cnt 32
|
49 |
|
|
typedef struct
|
50 |
|
|
{
|
51 |
|
|
unsigned int cpb_cnt_minus1; // ue(v)
|
52 |
|
|
unsigned int bit_rate_scale; // u(4)
|
53 |
|
|
unsigned int cpb_size_scale; // u(4)
|
54 |
|
|
unsigned int bit_rate_value_minus1 [MAXIMUMVALUEOFcpb_cnt]; // ue(v)
|
55 |
|
|
unsigned int cpb_size_value_minus1 [MAXIMUMVALUEOFcpb_cnt]; // ue(v)
|
56 |
|
|
unsigned int cbr_flag [MAXIMUMVALUEOFcpb_cnt]; // u(1)
|
57 |
|
|
unsigned int initial_cpb_removal_delay_length_minus1; // u(5)
|
58 |
|
|
unsigned int cpb_removal_delay_length_minus1; // u(5)
|
59 |
|
|
unsigned int dpb_output_delay_length_minus1; // u(5)
|
60 |
|
|
unsigned int time_offset_length; // u(5)
|
61 |
|
|
} hrd_parameters_t;
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
typedef struct
|
65 |
|
|
{
|
66 |
|
|
Boolean aspect_ratio_info_present_flag; // u(1)
|
67 |
|
|
unsigned int aspect_ratio_idc; // u(8)
|
68 |
|
|
unsigned int sar_width; // u(16)
|
69 |
|
|
unsigned int sar_height; // u(16)
|
70 |
|
|
Boolean overscan_info_present_flag; // u(1)
|
71 |
|
|
Boolean overscan_appropriate_flag; // u(1)
|
72 |
|
|
Boolean video_signal_type_present_flag; // u(1)
|
73 |
|
|
unsigned video_format; // u(3)
|
74 |
|
|
Boolean video_full_range_flag; // u(1)
|
75 |
|
|
Boolean colour_description_present_flag; // u(1)
|
76 |
|
|
unsigned int colour_primaries; // u(8)
|
77 |
|
|
unsigned int transfer_characteristics; // u(8)
|
78 |
|
|
unsigned int matrix_coefficients; // u(8)
|
79 |
|
|
Boolean chroma_location_info_present_flag; // u(1)
|
80 |
|
|
unsigned int chroma_sample_loc_type_top_field; // ue(v)
|
81 |
|
|
unsigned int chroma_sample_loc_type_bottom_field; // ue(v)
|
82 |
|
|
Boolean timing_info_present_flag; // u(1)
|
83 |
|
|
unsigned int num_units_in_tick; // u(32)
|
84 |
|
|
unsigned int time_scale; // u(32)
|
85 |
|
|
Boolean fixed_frame_rate_flag; // u(1)
|
86 |
|
|
Boolean nal_hrd_parameters_present_flag; // u(1)
|
87 |
|
|
hrd_parameters_t nal_hrd_parameters; // hrd_paramters_t
|
88 |
|
|
Boolean vcl_hrd_parameters_present_flag; // u(1)
|
89 |
|
|
hrd_parameters_t vcl_hrd_parameters; // hrd_paramters_t
|
90 |
|
|
// if ((nal_hrd_parameters_present_flag || (vcl_hrd_parameters_present_flag))
|
91 |
|
|
Boolean low_delay_hrd_flag; // u(1)
|
92 |
|
|
Boolean pic_struct_present_flag; // u(1)
|
93 |
|
|
Boolean bitstream_restriction_flag; // u(1)
|
94 |
|
|
Boolean motion_vectors_over_pic_boundaries_flag; // u(1)
|
95 |
|
|
unsigned int max_bytes_per_pic_denom; // ue(v)
|
96 |
|
|
unsigned int max_bits_per_mb_denom; // ue(v)
|
97 |
|
|
unsigned int log2_max_mv_length_vertical; // ue(v)
|
98 |
|
|
unsigned int log2_max_mv_length_horizontal; // ue(v)
|
99 |
|
|
unsigned int num_reorder_frames; // ue(v)
|
100 |
|
|
unsigned int max_dec_frame_buffering; // ue(v)
|
101 |
|
|
} vui_seq_parameters_t;
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
#define MAXnum_slice_groups_minus1 8
|
105 |
|
|
typedef struct
|
106 |
|
|
{
|
107 |
|
|
Boolean Valid; // indicates the parameter set is valid
|
108 |
|
|
unsigned int pic_parameter_set_id; // ue(v)
|
109 |
|
|
unsigned int seq_parameter_set_id; // ue(v)
|
110 |
|
|
Boolean entropy_coding_mode_flag; // u(1)
|
111 |
|
|
|
112 |
|
|
Boolean transform_8x8_mode_flag; // u(1)
|
113 |
|
|
|
114 |
|
|
Boolean pic_scaling_matrix_present_flag; // u(1)
|
115 |
|
|
int pic_scaling_list_present_flag[8]; // u(1)
|
116 |
|
|
int ScalingList4x4[6][16]; // se(v)
|
117 |
|
|
int ScalingList8x8[2][64]; // se(v)
|
118 |
|
|
Boolean UseDefaultScalingMatrix4x4Flag[6];
|
119 |
|
|
Boolean UseDefaultScalingMatrix8x8Flag[2];
|
120 |
|
|
|
121 |
|
|
// if( pic_order_cnt_type < 2 ) in the sequence parameter set
|
122 |
|
|
Boolean pic_order_present_flag; // u(1)
|
123 |
|
|
unsigned int num_slice_groups_minus1; // ue(v)
|
124 |
|
|
unsigned int slice_group_map_type; // ue(v)
|
125 |
|
|
// if( slice_group_map_type = = 0 )
|
126 |
|
|
unsigned int run_length_minus1[MAXnum_slice_groups_minus1]; // ue(v)
|
127 |
|
|
// else if( slice_group_map_type = = 2 )
|
128 |
|
|
unsigned int top_left[MAXnum_slice_groups_minus1]; // ue(v)
|
129 |
|
|
unsigned int bottom_right[MAXnum_slice_groups_minus1]; // ue(v)
|
130 |
|
|
// else if( slice_group_map_type = = 3 || 4 || 5
|
131 |
|
|
Boolean slice_group_change_direction_flag; // u(1)
|
132 |
|
|
unsigned int slice_group_change_rate_minus1; // ue(v)
|
133 |
|
|
// else if( slice_group_map_type = = 6 )
|
134 |
|
|
unsigned int num_slice_group_map_units_minus1; // ue(v)
|
135 |
|
|
unsigned int *slice_group_id; // complete MBAmap u(v)
|
136 |
|
|
unsigned int num_ref_idx_l0_active_minus1; // ue(v)
|
137 |
|
|
unsigned int num_ref_idx_l1_active_minus1; // ue(v)
|
138 |
|
|
Boolean weighted_pred_flag; // u(1)
|
139 |
|
|
unsigned int weighted_bipred_idc; // u(2)
|
140 |
|
|
int pic_init_qp_minus26; // se(v)
|
141 |
|
|
int pic_init_qs_minus26; // se(v)
|
142 |
|
|
int chroma_qp_index_offset; // se(v)
|
143 |
|
|
|
144 |
|
|
int second_chroma_qp_index_offset; // se(v)
|
145 |
|
|
|
146 |
|
|
Boolean deblocking_filter_control_present_flag; // u(1)
|
147 |
|
|
Boolean constrained_intra_pred_flag; // u(1)
|
148 |
|
|
Boolean redundant_pic_cnt_present_flag; // u(1)
|
149 |
|
|
} pic_parameter_set_rbsp_t;
|
150 |
|
|
|
151 |
|
|
|
152 |
|
|
#define MAXnum_ref_frames_in_pic_order_cnt_cycle 256
|
153 |
|
|
typedef struct
|
154 |
|
|
{
|
155 |
|
|
Boolean Valid; // indicates the parameter set is valid
|
156 |
|
|
|
157 |
|
|
unsigned int profile_idc; // u(8)
|
158 |
|
|
Boolean constrained_set0_flag; // u(1)
|
159 |
|
|
Boolean constrained_set1_flag; // u(1)
|
160 |
|
|
Boolean constrained_set2_flag; // u(1)
|
161 |
|
|
Boolean constrained_set3_flag; // u(1)
|
162 |
|
|
unsigned int level_idc; // u(8)
|
163 |
|
|
unsigned int seq_parameter_set_id; // ue(v)
|
164 |
|
|
unsigned int chroma_format_idc; // ue(v)
|
165 |
|
|
|
166 |
|
|
Boolean seq_scaling_matrix_present_flag; // u(1)
|
167 |
|
|
int seq_scaling_list_present_flag[8]; // u(1)
|
168 |
|
|
int ScalingList4x4[6][16]; // se(v)
|
169 |
|
|
int ScalingList8x8[2][64]; // se(v)
|
170 |
|
|
Boolean UseDefaultScalingMatrix4x4Flag[6];
|
171 |
|
|
Boolean UseDefaultScalingMatrix8x8Flag[2];
|
172 |
|
|
|
173 |
|
|
unsigned int bit_depth_luma_minus8; // ue(v)
|
174 |
|
|
unsigned int bit_depth_chroma_minus8; // ue(v)
|
175 |
|
|
|
176 |
|
|
unsigned int log2_max_frame_num_minus4; // ue(v)
|
177 |
|
|
unsigned int pic_order_cnt_type;
|
178 |
|
|
// if( pic_order_cnt_type == 0 )
|
179 |
|
|
unsigned log2_max_pic_order_cnt_lsb_minus4; // ue(v)
|
180 |
|
|
// else if( pic_order_cnt_type == 1 )
|
181 |
|
|
Boolean delta_pic_order_always_zero_flag; // u(1)
|
182 |
|
|
int offset_for_non_ref_pic; // se(v)
|
183 |
|
|
int offset_for_top_to_bottom_field; // se(v)
|
184 |
|
|
unsigned int num_ref_frames_in_pic_order_cnt_cycle; // ue(v)
|
185 |
|
|
// for( i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++ )
|
186 |
|
|
int offset_for_ref_frame[MAXnum_ref_frames_in_pic_order_cnt_cycle]; // se(v)
|
187 |
|
|
unsigned int num_ref_frames; // ue(v)
|
188 |
|
|
Boolean gaps_in_frame_num_value_allowed_flag; // u(1)
|
189 |
|
|
unsigned int pic_width_in_mbs_minus1; // ue(v)
|
190 |
|
|
unsigned int pic_height_in_map_units_minus1; // ue(v)
|
191 |
|
|
Boolean frame_mbs_only_flag; // u(1)
|
192 |
|
|
// if( !frame_mbs_only_flag )
|
193 |
|
|
Boolean mb_adaptive_frame_field_flag; // u(1)
|
194 |
|
|
Boolean direct_8x8_inference_flag; // u(1)
|
195 |
|
|
Boolean frame_cropping_flag; // u(1)
|
196 |
|
|
unsigned int frame_cropping_rect_left_offset; // ue(v)
|
197 |
|
|
unsigned int frame_cropping_rect_right_offset; // ue(v)
|
198 |
|
|
unsigned int frame_cropping_rect_top_offset; // ue(v)
|
199 |
|
|
unsigned int frame_cropping_rect_bottom_offset; // ue(v)
|
200 |
|
|
Boolean vui_parameters_present_flag; // u(1)
|
201 |
|
|
vui_seq_parameters_t vui_seq_parameters; // vui_seq_parameters_t
|
202 |
|
|
} seq_parameter_set_rbsp_t;
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
pic_parameter_set_rbsp_t *AllocPPS ();
|
206 |
|
|
seq_parameter_set_rbsp_t *AllocSPS ();
|
207 |
|
|
|
208 |
|
|
void FreePPS (pic_parameter_set_rbsp_t *pps);
|
209 |
|
|
void FreeSPS (seq_parameter_set_rbsp_t *sps);
|
210 |
|
|
|
211 |
|
|
int sps_is_equal(seq_parameter_set_rbsp_t *sps1, seq_parameter_set_rbsp_t *sps2);
|
212 |
|
|
int pps_is_equal(pic_parameter_set_rbsp_t *pps1, pic_parameter_set_rbsp_t *pps2);
|
213 |
|
|
|
214 |
|
|
#endif
|