00001
00016 #include "global.h"
00017 #include "parsetcommon.h"
00018 #include "memalloc.h"
00029 pic_parameter_set_rbsp_t *AllocPPS ()
00030 {
00031 pic_parameter_set_rbsp_t *p;
00032
00033 if ((p=calloc (sizeof (pic_parameter_set_rbsp_t), 1)) == NULL)
00034 no_mem_exit ("AllocPPS: PPS");
00035 p->slice_group_id = NULL;
00036 return p;
00037 }
00038
00039
00050 seq_parameter_set_rbsp_t *AllocSPS ()
00051 {
00052 seq_parameter_set_rbsp_t *p;
00053
00054 if ((p=calloc (sizeof (seq_parameter_set_rbsp_t), 1)) == NULL)
00055 no_mem_exit ("AllocSPS: SPS");
00056 return p;
00057 }
00058
00059
00070 void FreePPS (pic_parameter_set_rbsp_t *pps)
00071 {
00072 assert (pps != NULL);
00073 if (pps->slice_group_id != NULL)
00074 free (pps->slice_group_id);
00075 free (pps);
00076 }
00077
00078
00089 void FreeSPS (seq_parameter_set_rbsp_t *sps)
00090 {
00091 assert (sps != NULL);
00092 free (sps);
00093 }
00094
00095
00096 int sps_is_equal(seq_parameter_set_rbsp_t *sps1, seq_parameter_set_rbsp_t *sps2)
00097 {
00098 unsigned i;
00099 int equal = 1;
00100
00101 if ((!sps1->Valid) || (!sps2->Valid))
00102 return 0;
00103
00104 equal &= (sps1->profile_idc == sps2->profile_idc);
00105 equal &= (sps1->constrained_set0_flag == sps2->constrained_set0_flag);
00106 equal &= (sps1->constrained_set1_flag == sps2->constrained_set1_flag);
00107 equal &= (sps1->constrained_set2_flag == sps2->constrained_set2_flag);
00108 equal &= (sps1->level_idc == sps2->level_idc);
00109 equal &= (sps1->seq_parameter_set_id == sps2->seq_parameter_set_id);
00110 equal &= (sps1->log2_max_frame_num_minus4 == sps2->log2_max_frame_num_minus4);
00111 equal &= (sps1->pic_order_cnt_type == sps2->pic_order_cnt_type);
00112
00113 if (!equal) return equal;
00114
00115 if( sps1->pic_order_cnt_type == 0 )
00116 {
00117 equal &= (sps1->log2_max_pic_order_cnt_lsb_minus4 == sps2->log2_max_pic_order_cnt_lsb_minus4);
00118 }
00119
00120 else if( sps1->pic_order_cnt_type == 1 )
00121 {
00122 equal &= (sps1->delta_pic_order_always_zero_flag == sps2->delta_pic_order_always_zero_flag);
00123 equal &= (sps1->offset_for_non_ref_pic == sps2->offset_for_non_ref_pic);
00124 equal &= (sps1->offset_for_top_to_bottom_field == sps2->offset_for_top_to_bottom_field);
00125 equal &= (sps1->num_ref_frames_in_pic_order_cnt_cycle == sps2->num_ref_frames_in_pic_order_cnt_cycle);
00126 if (!equal) return equal;
00127
00128 for ( i = 0 ; i< sps1->num_ref_frames_in_pic_order_cnt_cycle ;i ++)
00129 equal &= (sps1->offset_for_ref_frame[i] == sps2->offset_for_ref_frame[i]);
00130 }
00131
00132 equal &= (sps1->num_ref_frames == sps2->num_ref_frames);
00133 equal &= (sps1->gaps_in_frame_num_value_allowed_flag == sps2->gaps_in_frame_num_value_allowed_flag);
00134 equal &= (sps1->pic_width_in_mbs_minus1 == sps2->pic_width_in_mbs_minus1);
00135 equal &= (sps1->pic_height_in_map_units_minus1 == sps2->pic_height_in_map_units_minus1);
00136 equal &= (sps1->frame_mbs_only_flag == sps2->frame_mbs_only_flag);
00137
00138 if (!equal) return equal;
00139 if( !sps1->frame_mbs_only_flag )
00140 equal &= (sps1->mb_adaptive_frame_field_flag == sps2->mb_adaptive_frame_field_flag);
00141
00142 equal &= (sps1->direct_8x8_inference_flag == sps2->direct_8x8_inference_flag);
00143 equal &= (sps1->frame_cropping_flag == sps2->frame_cropping_flag);
00144 if (!equal) return equal;
00145 if (sps1->frame_cropping_flag)
00146 {
00147 equal &= (sps1->frame_cropping_rect_left_offset == sps2->frame_cropping_rect_left_offset);
00148 equal &= (sps1->frame_cropping_rect_right_offset == sps2->frame_cropping_rect_right_offset);
00149 equal &= (sps1->frame_cropping_rect_top_offset == sps2->frame_cropping_rect_top_offset);
00150 equal &= (sps1->frame_cropping_rect_bottom_offset == sps2->frame_cropping_rect_bottom_offset);
00151 }
00152 equal &= (sps1->vui_parameters_present_flag == sps2->vui_parameters_present_flag);
00153
00154 return equal;
00155 }
00156
00157 int pps_is_equal(pic_parameter_set_rbsp_t *pps1, pic_parameter_set_rbsp_t *pps2)
00158 {
00159 unsigned i, j;
00160 int equal = 1;
00161
00162 if ((!pps1->Valid) || (!pps2->Valid))
00163 return 0;
00164
00165 equal &= (pps1->pic_parameter_set_id == pps2->pic_parameter_set_id);
00166 equal &= (pps1->seq_parameter_set_id == pps2->seq_parameter_set_id);
00167 equal &= (pps1->entropy_coding_mode_flag == pps2->entropy_coding_mode_flag);
00168 equal &= (pps1->bottom_field_pic_order_in_frame_present_flag == pps2->bottom_field_pic_order_in_frame_present_flag);
00169 equal &= (pps1->num_slice_groups_minus1 == pps2->num_slice_groups_minus1);
00170
00171 if (!equal) return equal;
00172
00173 if (pps1->num_slice_groups_minus1>0)
00174 {
00175 equal &= (pps1->slice_group_map_type == pps2->slice_group_map_type);
00176 if (!equal) return equal;
00177 if (pps1->slice_group_map_type == 0)
00178 {
00179 for (i=0; i<=pps1->num_slice_groups_minus1; i++)
00180 equal &= (pps1->run_length_minus1[i] == pps2->run_length_minus1[i]);
00181 }
00182 else if( pps1->slice_group_map_type == 2 )
00183 {
00184 for (i=0; i<pps1->num_slice_groups_minus1; i++)
00185 {
00186 equal &= (pps1->top_left[i] == pps2->top_left[i]);
00187 equal &= (pps1->bottom_right[i] == pps2->bottom_right[i]);
00188 }
00189 }
00190 else if( pps1->slice_group_map_type == 3 || pps1->slice_group_map_type==4 || pps1->slice_group_map_type==5 )
00191 {
00192 equal &= (pps1->slice_group_change_direction_flag == pps2->slice_group_change_direction_flag);
00193 equal &= (pps1->slice_group_change_rate_minus1 == pps2->slice_group_change_rate_minus1);
00194 }
00195 else if( pps1->slice_group_map_type == 6 )
00196 {
00197 equal &= (pps1->pic_size_in_map_units_minus1 == pps2->pic_size_in_map_units_minus1);
00198 if (!equal) return equal;
00199 for (i=0; i<=pps1->pic_size_in_map_units_minus1; i++)
00200 equal &= (pps1->slice_group_id[i] == pps2->slice_group_id[i]);
00201 }
00202 }
00203
00204 equal &= (pps1->num_ref_idx_l0_active_minus1 == pps2->num_ref_idx_l0_active_minus1);
00205 equal &= (pps1->num_ref_idx_l1_active_minus1 == pps2->num_ref_idx_l1_active_minus1);
00206 equal &= (pps1->weighted_pred_flag == pps2->weighted_pred_flag);
00207 equal &= (pps1->weighted_bipred_idc == pps2->weighted_bipred_idc);
00208 equal &= (pps1->pic_init_qp_minus26 == pps2->pic_init_qp_minus26);
00209 equal &= (pps1->pic_init_qs_minus26 == pps2->pic_init_qs_minus26);
00210 equal &= (pps1->chroma_qp_index_offset == pps2->chroma_qp_index_offset);
00211 equal &= (pps1->deblocking_filter_control_present_flag == pps2->deblocking_filter_control_present_flag);
00212 equal &= (pps1->constrained_intra_pred_flag == pps2->constrained_intra_pred_flag);
00213 equal &= (pps1->redundant_pic_cnt_present_flag == pps2->redundant_pic_cnt_present_flag);
00214
00215 if (!equal) return equal;
00216
00217
00218
00219 equal &= (pps1->transform_8x8_mode_flag == pps2->transform_8x8_mode_flag);
00220 equal &= (pps1->pic_scaling_matrix_present_flag == pps2->pic_scaling_matrix_present_flag);
00221 if(pps1->pic_scaling_matrix_present_flag)
00222 {
00223 for(i = 0; i < (6 + ((unsigned)pps1->transform_8x8_mode_flag << 1)); i++)
00224 {
00225 equal &= (pps1->pic_scaling_list_present_flag[i] == pps2->pic_scaling_list_present_flag[i]);
00226 if(pps1->pic_scaling_list_present_flag[i])
00227 {
00228 if(i < 6)
00229 {
00230 for (j = 0; j < 16; j++)
00231 equal &= (pps1->ScalingList4x4[i][j] == pps2->ScalingList4x4[i][j]);
00232 }
00233 else
00234 {
00235 for (j = 0; j < 64; j++)
00236 equal &= (pps1->ScalingList8x8[i-6][j] == pps2->ScalingList8x8[i-6][j]);
00237 }
00238 }
00239 }
00240 }
00241 equal &= (pps1->second_chroma_qp_index_offset == pps2->second_chroma_qp_index_offset);
00242
00243 return equal;
00244 }