parsetcommon.h 10 KB

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