📄 umc_h264_dec_bitstream.cpp
字号:
sps->type_of_scaling_list_used[1] = SCLDEFAULT;
}
// 2
if(Get1Bit())
{
GetScalingList4x4(&sps->ScalingLists4x4[2],(Ipp8u*) default_intra_scaling_list4x4,&sps->type_of_scaling_list_used[2]);
}
else
{
FillScalingList4x4(&sps->ScalingLists4x4[2],(Ipp8u*) sps->ScalingLists4x4[1].ScalingListCoeffs);
sps->type_of_scaling_list_used[2] = SCLDEFAULT;
}
// 3
if(Get1Bit())
{
GetScalingList4x4(&sps->ScalingLists4x4[3],(Ipp8u*)default_inter_scaling_list4x4,&sps->type_of_scaling_list_used[3]);
}
else
{
FillScalingList4x4(&sps->ScalingLists4x4[3],(Ipp8u*) default_inter_scaling_list4x4);
sps->type_of_scaling_list_used[3] = SCLDEFAULT;
}
// 4
if(Get1Bit())
{
GetScalingList4x4(&sps->ScalingLists4x4[4],(Ipp8u*) default_inter_scaling_list4x4,&sps->type_of_scaling_list_used[4]);
}
else
{
FillScalingList4x4(&sps->ScalingLists4x4[4],(Ipp8u*) sps->ScalingLists4x4[3].ScalingListCoeffs);
sps->type_of_scaling_list_used[4] = SCLDEFAULT;
}
// 5
if(Get1Bit())
{
GetScalingList4x4(&sps->ScalingLists4x4[5],(Ipp8u*) default_inter_scaling_list4x4,&sps->type_of_scaling_list_used[5]);
}
else
{
FillScalingList4x4(&sps->ScalingLists4x4[5],(Ipp8u*) sps->ScalingLists4x4[4].ScalingListCoeffs);
sps->type_of_scaling_list_used[5] = SCLDEFAULT;
}
// 0
if(Get1Bit())
{
GetScalingList8x8(&sps->ScalingLists8x8[0],(Ipp8u*)default_intra_scaling_list8x8,&sps->type_of_scaling_list_used[6]);
}
else
{
FillScalingList8x8(&sps->ScalingLists8x8[0],(Ipp8u*) default_intra_scaling_list8x8);
sps->type_of_scaling_list_used[6] = SCLDEFAULT;
}
// 1
if(Get1Bit())
{
GetScalingList8x8(&sps->ScalingLists8x8[1],(Ipp8u*) default_inter_scaling_list8x8,&sps->type_of_scaling_list_used[7]);
}
else
{
FillScalingList8x8(&sps->ScalingLists8x8[1],(Ipp8u*) default_inter_scaling_list8x8);
sps->type_of_scaling_list_used[7] = SCLDEFAULT;
}
}
else
{
Ipp32s i;
for (i = 0; i < 6; i += 1)
{
FillFlatScalingList4x4(&sps->ScalingLists4x4[i]);
}
for (i = 0; i < 2; i += 1)
{
FillFlatScalingList8x8(&sps->ScalingLists8x8[i]);
}
}
}
else
{
sps->chroma_format_idc = 1;
sps->bit_depth_luma = 8;
sps->bit_depth_chroma = 8;
SetDefaultScalingLists(sps);
}
// log2 max frame num (bitstream contains value - 4)
sps->log2_max_frame_num = (Ipp8u)(GetVLCElement(false) + 4);
if (sps->log2_max_frame_num > 16 || sps->log2_max_frame_num < 4)
return UMC_ERR_INVALID_STREAM;
// pic order cnt type (0..2)
sps->pic_order_cnt_type = (Ipp8u)GetVLCElement(false);
if (sps->pic_order_cnt_type > 2)
{
ps = UMC_ERR_INVALID_STREAM;
}
if (sps->pic_order_cnt_type == 0)
{
// log2 max pic order count lsb (bitstream contains value - 4)
sps->log2_max_pic_order_cnt_lsb = (Ipp8u)GetVLCElement(false) + 4;
if (sps->log2_max_pic_order_cnt_lsb > 16 || sps->log2_max_pic_order_cnt_lsb < 4)
return UMC_ERR_INVALID_STREAM;
sps->MaxPicOrderCntLsb = (1 << sps->log2_max_pic_order_cnt_lsb);
}
else if (sps->pic_order_cnt_type == 1)
{
sps->delta_pic_order_always_zero_flag = (Ipp8u)Get1Bit();
sps->offset_for_non_ref_pic = GetVLCElement(true);
sps->offset_for_top_to_bottom_field = GetVLCElement(true);
sps->num_ref_frames_in_pic_order_cnt_cycle = GetVLCElement(false);
// alloc memory for stored frame offsets
size_t len = IPP_MAX(1, sps->num_ref_frames_in_pic_order_cnt_cycle*sizeof(Ipp32u));
sps->poffset_for_ref_frame = (Ipp32s *)ippsMalloc_8u((Ipp32s) len);
if (sps->poffset_for_ref_frame == NULL)
ps = UMC_ERR_ALLOC;
// get offsets
for (Ipp32u i=0; i<sps->num_ref_frames_in_pic_order_cnt_cycle; i++)
{
sps->poffset_for_ref_frame[i] = GetVLCElement(true);
}
} // pic order count type 1
// num ref frames
sps->num_ref_frames = GetVLCElement(false);
if (sps->num_ref_frames > 16)
return UMC_ERR_INVALID_STREAM;
sps->gaps_in_frame_num_value_allowed_flag = (Ipp8u)Get1Bit();
// picture width in MBs (bitstream contains value - 1)
sps->frame_width_in_mbs = GetVLCElement(false) + 1;
// picture height in MBs (bitstream contains value - 1)
sps->frame_height_in_mbs = GetVLCElement(false) + 1;
sps->frame_mbs_only_flag = (Ipp8u)Get1Bit();
sps->frame_height_in_mbs = (2-sps->frame_mbs_only_flag)*sps->frame_height_in_mbs;
if (sps->frame_mbs_only_flag == 0)
{
sps->mb_adaptive_frame_field_flag = (Ipp8u)Get1Bit();
}
sps->direct_8x8_inference_flag = (Ipp8u)Get1Bit();
if (sps->frame_mbs_only_flag==0)
{
sps->direct_8x8_inference_flag = 1;
}
sps->frame_cropping_flag = (Ipp8u)Get1Bit();
if (sps->frame_cropping_flag)
{
sps->frame_cropping_rect_left_offset = GetVLCElement(false);
sps->frame_cropping_rect_right_offset = GetVLCElement(false);
sps->frame_cropping_rect_top_offset = GetVLCElement(false);
sps->frame_cropping_rect_bottom_offset = GetVLCElement(false);
}
sps->vui_parameters_present_flag = (Ipp8u)Get1Bit();
if (sps->vui_parameters_present_flag)
{
if (ps == UMC_OK)
ps = GetVUIParam(sps);
}
return ps;
} // GetSequenceParamSet
// ---------------------------------------------------------------------------
// H264Bitstream::GetSequenceParamSetExtension()
// Read sequence parameter set extension data from bitstream.
// ---------------------------------------------------------------------------
Status H264Bitstream::GetSequenceParamSetExtension(H264SeqParamSetExtension *sps_ex)
{
// Not all members of the seq param set structure are contained in all
// seq param sets. So start by init all to zero.
Status ps = UMC_OK;
ippsZero_8u((Ipp8u*)sps_ex, sizeof (H264SeqParamSetExtension));
sps_ex->seq_parameter_set_id = (Ipp8u)GetVLCElement(false);
if (sps_ex->seq_parameter_set_id > MAX_NUM_SEQ_PARAM_SETS-1)
{
return UMC_ERR_INVALID_STREAM;
}
sps_ex->aux_format_idc = (Ipp8u)GetVLCElement(false);
if (sps_ex->aux_format_idc > 3)
{
ps = UMC_ERR_INVALID_STREAM;
}
if (sps_ex->aux_format_idc != 1 && sps_ex->aux_format_idc != 2)
sps_ex->aux_format_idc = 0;
if (sps_ex->aux_format_idc)
{
sps_ex->bit_depth_aux = (Ipp8u)(GetVLCElement(false) + 8);
if (sps_ex->bit_depth_aux > 12)
{
ps = UMC_ERR_INVALID_STREAM;
}
sps_ex->alpha_incr_flag = (Ipp8u)Get1Bit();
if (sps_ex->alpha_incr_flag > 1)
{
ps = UMC_ERR_INVALID_STREAM;
}
sps_ex->alpha_opaque_value = (Ipp8u)GetBits(sps_ex->bit_depth_aux + 1);
sps_ex->alpha_transparent_value = (Ipp8u)GetBits(sps_ex->bit_depth_aux + 1);
}
sps_ex->additional_extension_flag = (Ipp8u)Get1Bit();
return ps;
} // GetSequenceParamSetExtension
Status H264Bitstream::GetPictureParamSetPart1(H264PicParamSet *pps)
{
// Not all members of the pic param set structure are contained in all
// pic param sets. So start by init all to zero.
memset(pps, 0, sizeof (H264PicParamSet));
// id
pps->pic_parameter_set_id = (Ipp16u)GetVLCElement(false);
if (pps->pic_parameter_set_id > MAX_NUM_PIC_PARAM_SETS-1)
{
return UMC_ERR_INVALID_STREAM;
}
// seq param set referred to by this pic param set
pps->seq_parameter_set_id = (Ipp8u)GetVLCElement(false);
if (pps->seq_parameter_set_id > MAX_NUM_SEQ_PARAM_SETS-1)
{
return UMC_ERR_INVALID_STREAM;
}
return UMC_OK;
} // GetPictureParamSetPart1
// Number of bits required to code slice group ID, index is num_slice_groups - 2
static const Ipp8u SGIdBits[7] = {1,2,2,3,3,3,3};
// ---------------------------------------------------------------------------
// CH263pBs::GetPictureParamSet()
// Read picture parameter set data from bitstream.
// ---------------------------------------------------------------------------
Status H264Bitstream::GetPictureParamSetPart2(H264PicParamSet *pps,
const H264SeqParamSet *sps)
{
pps->entropy_coding_mode = (Ipp8u)Get1Bit();
pps->pic_order_present_flag = (Ipp8u)Get1Bit();
// number of slice groups, bitstream has value - 1
pps->num_slice_groups = GetVLCElement(false) + 1;
if (pps->num_slice_groups != 1)
{
Ipp32u slice_group;
Ipp32u PicSizeInMapUnits; // for range checks
PicSizeInMapUnits = sps->frame_width_in_mbs * sps->frame_height_in_mbs;
// TBD: needs adjust for fields
if (pps->num_slice_groups > MAX_NUM_SLICE_GROUPS)
{
return UMC_ERR_INVALID_STREAM;
}
pps->SliceGroupInfo.slice_group_map_type = (Ipp8u)GetVLCElement(false);
// Get additional, map type dependent slice group data
switch (pps->SliceGroupInfo.slice_group_map_type)
{
case 0:
for (slice_group=0; slice_group<pps->num_slice_groups; slice_group++)
{
// run length, bitstream has value - 1
pps->SliceGroupInfo.run_length[slice_group] = GetVLCElement(false) + 1;
if (pps->SliceGroupInfo.run_length[slice_group] > PicSizeInMapUnits)
{
return UMC_ERR_INVALID_STREAM;
}
}
break;
case 1:
// no additional info
break;
case 2:
for (slice_group=0; slice_group<(Ipp32u)(pps->num_slice_groups-1); slice_group++)
{
pps->SliceGroupInfo.t1.top_left[slice_group] = GetVLCElement(false);
pps->SliceGroupInfo.t1.bottom_right[slice_group] = GetVLCElement(false);
// check for legal values
if (pps->SliceGroupInfo.t1.top_left[slice_group] >
pps->SliceGroupInfo.t1.bottom_right[slice_group])
{
return UMC_ERR_INVALID_STREAM;
}
if (pps->SliceGroupInfo.t1.bottom_right[slice_group] >= PicSizeInMapUnits)
{
return UMC_ERR_INVALID_STREAM;
}
if ((pps->SliceGroupInfo.t1.top_left[slice_group] %
sps->frame_width_in_mbs) >
(pps->SliceGroupInfo.t1.bottom_right[slice_group] %
sps->frame_width_in_mbs))
{
return UMC_ERR_INVALID_STREAM;
}
}
break;
case 3:
case 4:
case 5:
// For map types 3..5, number of slice groups must be 2
if (pps->num_slice_groups != 2)
{
return UMC_ERR_INVALID_STREAM;
}
pps->SliceGroupInfo.t2.slice_group_change_direction_flag = (Ipp8u)Get1Bit();
pps->SliceGroupInfo.t2.slice_group_change_rate = GetVLCElement(false) + 1;
if (pps->SliceGroupInfo.t2.slice_group_change_rate > PicSizeInMapUnits)
{
return UMC_ERR_INVALID_STREAM;
}
break;
case 6:
// mapping of slice group to map unit (macroblock if not fields) is
// per map unit, read from bitstream
{
Ipp32u map_unit;
Ipp32u num_bits; // number of bits used to code each slice group id
// number of map units, bitstream has value - 1
pps->SliceGroupInfo.t3.pic_size_in_map_units = GetVLCElement(false) + 1;
if (pps->SliceGroupInfo.t3.pic_size_in_map_units != PicSizeInMapUnits)
{
return UMC_ERR_INVALID_STREAM;
}
Ipp32s len = IPP_MAX(1, pps->SliceGroupInfo.t3.pic_size_in_map_units);
pps->SliceGroupInfo.t3.pSliceGroupIDMap = ippsMalloc_8u(len);
if (pps->SliceGroupInfo.t3.pSliceGroupIDMap == NULL)
return UMC_ERR_ALLOC;
// num_bits is Ceil(log2(num_groups))
num_bits = SGIdBits[pps->num_slice_groups - 2];
for (map_unit = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -