parsetcommon.h
上传用户:hjq518
上传日期:2021-12-09
资源大小:5084k
文件大小:11k
源码类别:

Audio

开发平台:

Visual C++

  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        <stewe@cs.tu-berlin.de>
  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 signalled 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. //! Boolean Type
  29. #ifdef FALSE
  30. #  define Boolean int
  31. #else
  32. typedef enum {
  33.   FALSE,
  34.   TRUE
  35. } Boolean;
  36. #endif
  37. #define MAXIMUMVALUEOFcpb_cnt   32
  38. typedef struct
  39. {
  40.   unsigned int cpb_cnt_minus1;                                   // ue(v)
  41.   unsigned int bit_rate_scale;                                   // u(4)
  42.   unsigned int cpb_size_scale;                                   // u(4)
  43.     unsigned int bit_rate_value_minus1 [MAXIMUMVALUEOFcpb_cnt];  // ue(v)
  44.     unsigned int cpb_size_value_minus1 [MAXIMUMVALUEOFcpb_cnt];  // ue(v)
  45.     unsigned int cbr_flag              [MAXIMUMVALUEOFcpb_cnt];  // u(1)
  46.   unsigned int initial_cpb_removal_delay_length_minus1;          // u(5)
  47.   unsigned int cpb_removal_delay_length_minus1;                  // u(5)
  48.   unsigned int dpb_output_delay_length_minus1;                   // u(5)
  49.   unsigned int time_offset_length;                               // u(5)
  50. } hrd_parameters_t;
  51. typedef struct
  52. {
  53.   Boolean      aspect_ratio_info_present_flag;                   // u(1)
  54.     unsigned int aspect_ratio_idc;                               // u(8)
  55.       unsigned int sar_width;                                    // u(16)
  56.       unsigned int sar_height;                                   // u(16)
  57.   Boolean      overscan_info_present_flag;                       // u(1)
  58.     Boolean      overscan_appropriate_flag;                      // u(1)
  59.   Boolean      video_signal_type_present_flag;                   // u(1)
  60.     unsigned int video_format;                                   // u(3)
  61.     Boolean      video_full_range_flag;                          // u(1)
  62.     Boolean      colour_description_present_flag;                // u(1)
  63.       unsigned int colour_primaries;                             // u(8)
  64.       unsigned int transfer_characteristics;                     // u(8)
  65.       unsigned int matrix_coefficients;                          // u(8)
  66.   Boolean      chroma_location_info_present_flag;                // u(1)
  67.     unsigned int  chroma_sample_loc_type_top_field;               // ue(v)
  68.     unsigned int  chroma_sample_loc_type_bottom_field;            // ue(v)
  69.   Boolean      timing_info_present_flag;                         // u(1)
  70.     unsigned int num_units_in_tick;                              // u(32)
  71.     unsigned int time_scale;                                     // u(32)
  72.     Boolean      fixed_frame_rate_flag;                          // u(1)
  73.   Boolean      nal_hrd_parameters_present_flag;                  // u(1)
  74.     hrd_parameters_t nal_hrd_parameters;                      // hrd_paramters_t
  75.   Boolean      vcl_hrd_parameters_present_flag;                  // u(1)
  76.     hrd_parameters_t vcl_hrd_parameters;                      // hrd_paramters_t
  77.   // if ((nal_hrd_parameters_present_flag || (vcl_hrd_parameters_present_flag))
  78.     Boolean      low_delay_hrd_flag;                             // u(1)
  79.   Boolean      pic_struct_present_flag;                        // u(1)
  80.   Boolean      bitstream_restriction_flag;                       // u(1)
  81.     Boolean      motion_vectors_over_pic_boundaries_flag;        // u(1)
  82.     unsigned int max_bytes_per_pic_denom;                        // ue(v)
  83.     unsigned int max_bits_per_mb_denom;                          // ue(v)
  84.     unsigned int log2_max_mv_length_vertical;                    // ue(v)
  85.     unsigned int log2_max_mv_length_horizontal;                  // ue(v)
  86.     unsigned int num_reorder_frames;                             // ue(v)
  87.     unsigned int max_dec_frame_buffering;                        // ue(v)
  88. } vui_seq_parameters_t;
  89. #define MAXnum_slice_groups_minus1  8
  90. typedef struct
  91. {
  92.   Boolean   Valid;                  // indicates the parameter set is valid
  93.   unsigned int pic_parameter_set_id;                             // ue(v)
  94.   unsigned int seq_parameter_set_id;                             // ue(v)
  95.   Boolean   entropy_coding_mode_flag;                         // u(1)
  96.   Boolean   transform_8x8_mode_flag;                          // u(1)
  97.   Boolean   pic_scaling_matrix_present_flag;                  // u(1)
  98.   int       pic_scaling_list_present_flag[12];                 // u(1)
  99.   int       ScalingList4x4[6][16];                            // se(v)
  100.   int       ScalingList8x8[6][64];                            // se(v)
  101.   Boolean   UseDefaultScalingMatrix4x4Flag[6];
  102.   Boolean   UseDefaultScalingMatrix8x8Flag[6];
  103.   // if( pic_order_cnt_type < 2 )  in the sequence parameter set
  104.   Boolean      pic_order_present_flag;                           // u(1)
  105.   unsigned int num_slice_groups_minus1;                          // ue(v)
  106.     unsigned int slice_group_map_type;                        // ue(v)
  107.     // if( slice_group_map_type = = 0 )
  108.       unsigned int run_length_minus1[MAXnum_slice_groups_minus1]; // ue(v)
  109.     // else if( slice_group_map_type = = 2 )
  110.       unsigned int top_left[MAXnum_slice_groups_minus1];         // ue(v)
  111.       unsigned int bottom_right[MAXnum_slice_groups_minus1];     // ue(v)
  112.     // else if( slice_group_map_type = = 3 || 4 || 5
  113.       Boolean   slice_group_change_direction_flag;            // u(1)
  114.       unsigned int slice_group_change_rate_minus1;               // ue(v)
  115.     // else if( slice_group_map_type = = 6 )
  116.       unsigned int num_slice_group_map_units_minus1;             // ue(v)
  117.       unsigned char *slice_group_id;                              // complete MBAmap u(v)
  118.   int num_ref_idx_l0_active_minus1;                     // ue(v)
  119.   int num_ref_idx_l1_active_minus1;                     // ue(v)
  120.   Boolean   weighted_pred_flag;                               // u(1)
  121.   unsigned int  weighted_bipred_idc;                              // u(2)
  122.   int       pic_init_qp_minus26;                              // se(v)
  123.   int       pic_init_qs_minus26;                              // se(v)
  124.   int       chroma_qp_index_offset;                           // se(v)
  125.   int       second_chroma_qp_index_offset;                    // se(v)
  126.   Boolean   deblocking_filter_control_present_flag;           // u(1)
  127.   Boolean   constrained_intra_pred_flag;                      // u(1)
  128.   Boolean   redundant_pic_cnt_present_flag;                   // u(1)
  129. } pic_parameter_set_rbsp_t;
  130. #define MAXnum_ref_frames_in_pic_order_cnt_cycle  256
  131. typedef struct
  132. {
  133.   Boolean   Valid;                  // indicates the parameter set is valid
  134.   unsigned int profile_idc;                                      // u(8)
  135.   Boolean   constrained_set0_flag;                            // u(1)
  136.   Boolean   constrained_set1_flag;                            // u(1)
  137.   Boolean   constrained_set2_flag;                            // u(1)
  138.   Boolean   constrained_set3_flag;                            // u(1)
  139.   unsigned  int level_idc;                                        // u(8)
  140.   unsigned  int seq_parameter_set_id;                             // ue(v)
  141.   unsigned  int chroma_format_idc;                                // ue(v)
  142.   Boolean   seq_scaling_matrix_present_flag;                   // u(1)
  143.   int       seq_scaling_list_present_flag[12];                 // u(1)
  144.   int       ScalingList4x4[6][16];                             // se(v)
  145.   int       ScalingList8x8[6][64];                             // se(v)
  146.   Boolean   UseDefaultScalingMatrix4x4Flag[6];
  147.   Boolean   UseDefaultScalingMatrix8x8Flag[6];
  148.   unsigned int bit_depth_luma_minus8;                            // ue(v)
  149.   unsigned int bit_depth_chroma_minus8;                          // ue(v)
  150.   unsigned int log2_max_frame_num_minus4;                        // ue(v)
  151.   unsigned int pic_order_cnt_type;
  152.   // if( pic_order_cnt_type == 0 )
  153.   unsigned int log2_max_pic_order_cnt_lsb_minus4;                 // ue(v)
  154.   // else if( pic_order_cnt_type == 1 )
  155.     Boolean delta_pic_order_always_zero_flag;               // u(1)
  156.     int     offset_for_non_ref_pic;                         // se(v)
  157.     int     offset_for_top_to_bottom_field;                 // se(v)
  158.     unsigned int num_ref_frames_in_pic_order_cnt_cycle;          // ue(v)
  159.     // for( i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++ )
  160.       int   offset_for_ref_frame[MAXnum_ref_frames_in_pic_order_cnt_cycle];   // se(v)
  161.   unsigned int num_ref_frames;                                   // ue(v)
  162.   Boolean   gaps_in_frame_num_value_allowed_flag;             // u(1)
  163.   unsigned int pic_width_in_mbs_minus1;                          // ue(v)
  164.   unsigned int pic_height_in_map_units_minus1;                   // ue(v)
  165.   Boolean   frame_mbs_only_flag;                              // u(1)
  166.   // if( !frame_mbs_only_flag )
  167.     Boolean   mb_adaptive_frame_field_flag;                   // u(1)
  168.   Boolean   direct_8x8_inference_flag;                        // u(1)
  169.   Boolean   frame_cropping_flag;                              // u(1)
  170.     unsigned int frame_cropping_rect_left_offset;                // ue(v)
  171.     unsigned int frame_cropping_rect_right_offset;               // ue(v)
  172.     unsigned int frame_cropping_rect_top_offset;                 // ue(v)
  173.     unsigned int frame_cropping_rect_bottom_offset;              // ue(v)
  174.   Boolean   vui_parameters_present_flag;                      // u(1)
  175.     vui_seq_parameters_t vui_seq_parameters;                  // vui_seq_parameters_t
  176.     unsigned  separate_colour_plane_flag;                       // u(1)
  177. } seq_parameter_set_rbsp_t;
  178. pic_parameter_set_rbsp_t *AllocPPS (void);
  179. seq_parameter_set_rbsp_t *AllocSPS (void);
  180. void FreePPS (pic_parameter_set_rbsp_t *pps);
  181. void FreeSPS (seq_parameter_set_rbsp_t *sps);
  182. int sps_is_equal(seq_parameter_set_rbsp_t *sps1, seq_parameter_set_rbsp_t *sps2);
  183. int pps_is_equal(pic_parameter_set_rbsp_t *pps1, pic_parameter_set_rbsp_t *pps2);
  184. #endif