| #include "h264.h" |
| #include "h264parse.h" |
| #include <vbp_trace.h> |
| |
| /*---------------------------------------------*/ |
| /*---------------------------------------------*/ |
| /*---------------------------------------------*/ |
| h264_Status h264_Parse_PicParameterSet(void *parent,h264_Info * pInfo,h264_PicParameterSet_t* PictureParameterSet) |
| { |
| h264_Status ret = H264_PPS_ERROR; |
| |
| //h264_PicParameterSet_t* PictureParameterSet = &pInfo->PictureParameterSet; |
| uint32_t code = 0, i = 0; |
| |
| do { |
| ///// PPS par1: pic_parameter_set_id & seq_parameter_set_id |
| code = h264_GetVLCElement(parent, pInfo, false); |
| if (code > MAX_PIC_PARAMS) |
| { |
| ETRACE("PPS id is out of range: %d", code); |
| break; |
| } |
| PictureParameterSet->pic_parameter_set_id = (uint8_t)code; |
| |
| VTRACE("parsing PPS: id = %d", PictureParameterSet->pic_parameter_set_id); |
| |
| code = h264_GetVLCElement(parent, pInfo, false); |
| if (code > MAX_NUM_SPS - 1) |
| { |
| ETRACE("SPS id in PPS is bad: %d", code); |
| break; |
| } |
| PictureParameterSet->seq_parameter_set_id = (uint8_t)code; |
| |
| VTRACE("parsing PPS: refering SPS id = %d", PictureParameterSet->seq_parameter_set_id); |
| |
| ///// entropy_coding_mode_flag |
| viddec_pm_get_bits(parent, &code, 1); |
| PictureParameterSet->entropy_coding_mode_flag = (uint8_t)code; |
| ///// pic_order_present_flag |
| viddec_pm_get_bits(parent, &code, 1); |
| PictureParameterSet->pic_order_present_flag = (uint8_t)code; |
| |
| PictureParameterSet->num_slice_groups_minus1 = h264_GetVLCElement(parent, pInfo, false); |
| |
| // |
| // In main profile, FMO is excluded and num_slice_groups_minus1 should be 0 |
| // |
| if (PictureParameterSet->num_slice_groups_minus1 > 0) //MAX_NUM_SLICE_GRPS) |
| { |
| ETRACE("FMO is not supported"); |
| break; |
| } |
| |
| PictureParameterSet->num_ref_idx_l0_active = h264_GetVLCElement(parent, pInfo, false) + 1; |
| PictureParameterSet->num_ref_idx_l1_active = h264_GetVLCElement(parent, pInfo, false) + 1; |
| |
| //// PPS->num_ref_idx_l0_active --- [0,32] |
| if (((PictureParameterSet->num_ref_idx_l0_active) > MAX_NUM_REF_FRAMES) || ((PictureParameterSet->num_ref_idx_l1_active) > MAX_NUM_REF_FRAMES)) |
| { |
| ETRACE("The number in the ref list is greater than 32"); |
| break; |
| } |
| |
| //// weighting prediction |
| viddec_pm_get_bits(parent, &code, 1); |
| PictureParameterSet->weighted_pred_flag = (uint8_t)code; |
| |
| viddec_pm_get_bits(parent, &code, 2); |
| PictureParameterSet->weighted_bipred_idc = (uint8_t)code; |
| |
| //// QP |
| PictureParameterSet->pic_init_qp_minus26 = h264_GetVLCElement(parent, pInfo, true); |
| PictureParameterSet->pic_init_qs_minus26 = h264_GetVLCElement(parent, pInfo, true); |
| if (((PictureParameterSet->pic_init_qp_minus26 + 26) > MAX_QP) || ((PictureParameterSet->pic_init_qs_minus26 + 26) > MAX_QP)) |
| { |
| ETRACE("QP is greater than 51"); |
| break; |
| } |
| PictureParameterSet->chroma_qp_index_offset = h264_GetVLCElement(parent, pInfo, true); |
| |
| //// Deblocking ctl parameters |
| viddec_pm_get_bits(parent, &code, 1); |
| PictureParameterSet->deblocking_filter_control_present_flag = (uint8_t)code; |
| |
| viddec_pm_get_bits(parent, &code, 1); |
| PictureParameterSet->constrained_intra_pred_flag = (uint8_t)code; |
| |
| if ( viddec_pm_get_bits(parent, &code, 1) == -1) |
| break; |
| PictureParameterSet->redundant_pic_cnt_present_flag = (uint8_t)code; |
| |
| //// Check if have more RBSP Data for additional parameters |
| if (h264_More_RBSP_Data(parent, pInfo)) |
| { |
| viddec_pm_get_bits(parent, &code, 1); |
| PictureParameterSet->transform_8x8_mode_flag = (uint8_t)code; |
| |
| if (viddec_pm_get_bits(parent, &code, 1) == -1) |
| break; |
| PictureParameterSet->pic_scaling_matrix_present_flag = (uint8_t)code; |
| |
| if (PictureParameterSet->pic_scaling_matrix_present_flag) |
| { |
| uint32_t n_ScalingList = 6 + (PictureParameterSet->transform_8x8_mode_flag << 1); |
| for (i = 0; i < n_ScalingList; i++) |
| { |
| if (viddec_pm_get_bits(parent, &code, 1) == -1) |
| break; |
| PictureParameterSet->pic_scaling_list_present_flag[i] = (uint8_t)code; |
| |
| if (PictureParameterSet->pic_scaling_list_present_flag[i]) |
| { |
| if (i < 6) |
| h264_Scaling_List(parent, PictureParameterSet->ScalingList4x4[i], 16, &PictureParameterSet->UseDefaultScalingMatrix4x4Flag[i], pInfo); |
| else |
| h264_Scaling_List(parent, PictureParameterSet->ScalingList8x8[i - 6], 64, &PictureParameterSet->UseDefaultScalingMatrix8x8Flag[i - 6], pInfo); |
| } |
| } |
| } |
| |
| PictureParameterSet->second_chroma_qp_index_offset = h264_GetVLCElement(parent, pInfo, true); //fix |
| } |
| else |
| { |
| PictureParameterSet->transform_8x8_mode_flag = 0; |
| PictureParameterSet->pic_scaling_matrix_present_flag = 0; |
| PictureParameterSet->second_chroma_qp_index_offset = PictureParameterSet->chroma_qp_index_offset; |
| } |
| |
| ret = H264_STATUS_OK; |
| } while (0); |
| |
| //h264_Parse_rbsp_trailing_bits(pInfo); |
| return ret; |
| } |
| |
| ////////// EOF/////////////// |
| |