📄 mp4parse.c
字号:
if (VOL->ComplexityEstimation.vlc_bits) VOL->ComplexityEstimation.dcecs_vlc_bits = mp4_GetBits9(pInfo, 4);
if (VOL->ComplexityEstimation.inter_blocks) VOL->ComplexityEstimation.dcecs_inter_blocks = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.inter4v_blocks) VOL->ComplexityEstimation.dcecs_inter4v_blocks = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.apm) VOL->ComplexityEstimation.dcecs_apm = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.npm) VOL->ComplexityEstimation.dcecs_npm = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.forw_back_mc_q) VOL->ComplexityEstimation.dcecs_forw_back_mc_q = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.halfpel2) VOL->ComplexityEstimation.dcecs_halfpel2 = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.halfpel4) VOL->ComplexityEstimation.dcecs_halfpel4 = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.sadct) VOL->ComplexityEstimation.dcecs_sadct = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.quarterpel) VOL->ComplexityEstimation.dcecs_quarterpel = mp4_GetBits9(pInfo, 8);
}
if (VOP->coding_type == MP4_VOP_TYPE_B) {
if (VOL->ComplexityEstimation.opaque) VOL->ComplexityEstimation.dcecs_opaque = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.transparent) VOL->ComplexityEstimation.dcecs_transparent = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.intra_cae) VOL->ComplexityEstimation.dcecs_intra_cae = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.inter_cae) VOL->ComplexityEstimation.dcecs_inter_cae = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.no_update) VOL->ComplexityEstimation.dcecs_no_update = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.upsampling) VOL->ComplexityEstimation.dcecs_upsampling = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.intra_blocks) VOL->ComplexityEstimation.dcecs_intra_blocks = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.not_coded_blocks) VOL->ComplexityEstimation.dcecs_not_coded_blocks = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.dct_coefs) VOL->ComplexityEstimation.dcecs_dct_coefs = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.dct_lines) VOL->ComplexityEstimation.dcecs_dct_lines = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.vlc_symbols) VOL->ComplexityEstimation.dcecs_vlc_symbols = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.vlc_bits) VOL->ComplexityEstimation.dcecs_vlc_bits = mp4_GetBits9(pInfo, 4);
if (VOL->ComplexityEstimation.inter_blocks) VOL->ComplexityEstimation.dcecs_inter_blocks = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.inter4v_blocks) VOL->ComplexityEstimation.dcecs_inter4v_blocks = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.apm) VOL->ComplexityEstimation.dcecs_apm = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.npm) VOL->ComplexityEstimation.dcecs_npm = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.forw_back_mc_q) VOL->ComplexityEstimation.dcecs_forw_back_mc_q = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.halfpel2) VOL->ComplexityEstimation.dcecs_halfpel2 = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.halfpel4) VOL->ComplexityEstimation.dcecs_halfpel4 = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.interpolate_mc_q) VOL->ComplexityEstimation.dcecs_interpolate_mc_q = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.sadct) VOL->ComplexityEstimation.dcecs_sadct = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.quarterpel) VOL->ComplexityEstimation.dcecs_quarterpel = mp4_GetBits9(pInfo, 8);
}
if (VOP->coding_type == MP4_VOP_TYPE_S && VOL->sprite_enable == MP4_SPRITE_STATIC) {
if (VOL->ComplexityEstimation.intra_blocks) VOL->ComplexityEstimation.dcecs_intra_blocks = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.not_coded_blocks) VOL->ComplexityEstimation.dcecs_not_coded_blocks = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.dct_coefs) VOL->ComplexityEstimation.dcecs_dct_coefs = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.dct_lines) VOL->ComplexityEstimation.dcecs_dct_lines = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.vlc_symbols) VOL->ComplexityEstimation.dcecs_vlc_symbols = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.vlc_bits) VOL->ComplexityEstimation.dcecs_vlc_bits = mp4_GetBits9(pInfo, 4);
if (VOL->ComplexityEstimation.inter_blocks) VOL->ComplexityEstimation.dcecs_inter_blocks = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.inter4v_blocks) VOL->ComplexityEstimation.dcecs_inter4v_blocks = mp4_GetBits(pInfo, 8);
if (VOL->ComplexityEstimation.apm) VOL->ComplexityEstimation.dcecs_apm = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.npm) VOL->ComplexityEstimation.dcecs_npm = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.forw_back_mc_q) VOL->ComplexityEstimation.dcecs_forw_back_mc_q = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.halfpel2) VOL->ComplexityEstimation.dcecs_halfpel2 = mp4_GetBits9(pInfo, 8);
if (VOL->ComplexityEstimation.halfpel4) VOL->ComplexityEstimation.dcecs_halfpel4 = mp4_GetBits(pInfo, 8);
if (VOL->ComplexityEstimation.interpolate_mc_q) VOL->ComplexityEstimation.dcecs_interpolate_mc_q = mp4_GetBits9(pInfo, 8);
}
}
}
VOP->intra_dc_vlc_thr = mp4_GetBits9(pInfo, 3);
if (VOL->interlaced) {
VOP->top_field_first = mp4_GetBit(pInfo);
VOP->alternate_vertical_scan_flag = mp4_GetBit(pInfo);
}
}
if ((VOL->sprite_enable == MP4_SPRITE_STATIC || VOL->sprite_enable == MP4_SPRITE_GMC) && VOP->coding_type == MP4_VOP_TYPE_S) {
if (VOL->sprite_warping_points > 0)
if (mp4_Sprite_Trajectory(pInfo) != MP4_STATUS_OK)
return MP4_STATUS_PARSE_ERROR;
if (VOL->sprite_brightness_change) {
code = mp4_ShowBits9(pInfo, 4);
if (code == 15) {
mp4_FlushBits(pInfo, 4);
VOP->brightness_change_factor = 625 + mp4_GetBits(pInfo, 10);
} else if (code == 14) {
mp4_FlushBits(pInfo, 4);
VOP->brightness_change_factor = 113 + mp4_GetBits9(pInfo, 9);
} else if (code >= 12) {
mp4_FlushBits(pInfo, 3);
code = mp4_GetBits9(pInfo, 7);
VOP->brightness_change_factor = (code < 64) ? code - 112 : code - 15;
} else if (code >= 8) {
mp4_FlushBits(pInfo, 2);
code = mp4_GetBits9(pInfo, 6);
VOP->brightness_change_factor = (code < 32) ? code - 48 : code - 15;
} else {
mp4_FlushBits(pInfo, 1);
code = mp4_GetBits9(pInfo, 5);
VOP->brightness_change_factor = (code < 16) ? code - 16 : code - 15;
}
} else
VOP->brightness_change_factor = 0;
if (VOL->sprite_enable == MP4_SPRITE_STATIC)
return MP4_STATUS_OK;
}
if (VOL->shape != MP4_SHAPE_TYPE_BINARYONLY) {
VOP->quant = mp4_GetBits9(pInfo, VOL->quant_precision);
if (VOL->shape == MP4_SHAPE_TYPE_GRAYSCALE) {
Ipp32s ac, i;
ac = mp4_aux_comp_count[VOL->shape_extension];
for (i = 0; i < ac; i ++)
VOP->alpha_quant[i] = mp4_GetBits9(pInfo, 6);
}
if (VOP->coding_type != MP4_VOP_TYPE_I) {
VOP->fcode_forward = mp4_GetBits9(pInfo, 3);
if (VOP->fcode_forward == 0) {
mp4_Error("Error: vop_fcode_forward == 0");
return MP4_STATUS_PARSE_ERROR;
}
}
if (VOP->coding_type == MP4_VOP_TYPE_B) {
VOP->fcode_backward = mp4_GetBits9(pInfo, 3);
if (VOP->fcode_backward == 0) {
mp4_Error("Error: vop_fcode_backward == 0");
return MP4_STATUS_PARSE_ERROR;
}
}
if (!VOL->scalability) {
if (VOL->shape != MP4_SHAPE_TYPE_RECTANGULAR && VOP->coding_type != MP4_VOP_TYPE_I)
VOP->shape_coding_type = mp4_GetBit(pInfo);
} else {
//f if (VOL->enhancement_type) {
//f VOP->load_backward_shape = mp4_GetBit(pInfo);
//f if (VOP->load_backward_shape) {
//f shape
//f }
//f }
VOP->ref_select_code = mp4_GetBits9(pInfo, 2);
}
}
return MP4_STATUS_OK;
}
/*
// decode VideoPacket
*/
mp4_Status mp4_CheckDecodeVideoPacket(mp4_Info* pInfo, Ipp32s *found)
{
Ipp32u code;
Ipp32s header_extension_code, rml;
mp4_VideoObject *VOL = &pInfo->VisualObject.VideoObject;
mp4_VideoObjectPlane *VOP = &pInfo->VisualObject.VideoObject.VideoObjectPlane;
*found = 0;
// check stuffing bits
if (mp4_ShowBit(pInfo) != 0)
return MP4_STATUS_OK;
if (mp4_ShowBits9(pInfo, 8 - pInfo->bitoff) != (Ipp32u)((1 << (7 - pInfo->bitoff)) - 1))
return MP4_STATUS_OK;
if (VOP->coding_type == MP4_VOP_TYPE_I)
rml = 17;
else if (VOP->coding_type == MP4_VOP_TYPE_B)
rml = 16 + IPP_MAX(VOP->fcode_forward, VOP->fcode_backward);
else
rml = 16 + VOP->fcode_forward;
code = (pInfo->bufptr[1] << 16) | (pInfo->bufptr[2] << 8) | pInfo->bufptr[3];
code >>= 24 - rml;
if (code == 1) { // is resync_marker
mp4_FlushBits(pInfo, rml + 8 - pInfo->bitoff);
header_extension_code = 0;
if (VOL->shape != MP4_SHAPE_TYPE_RECTANGULAR) {
header_extension_code = mp4_GetBit(pInfo);
if (header_extension_code && !(VOL->sprite_enable == MP4_SPRITE_STATIC && VOP->coding_type == MP4_VOP_TYPE_I)) {
VOP->vop_width = mp4_GetBits(pInfo, 13);
if (!mp4_GetBit(pInfo))
if (pInfo->stopOnErr)
goto Err;
VOP->vop_height = mp4_GetBits(pInfo, 13);
if (!mp4_GetBit(pInfo))
if (pInfo->stopOnErr)
goto Err;
VOP->vop_horizontal_mc_spatial_ref = mp4_GetBits(pInfo, 13);
if (!mp4_GetBit(pInfo))
if (pInfo->stopOnErr)
goto Err;
VOP->vop_vertical_mc_spatial_ref = mp4_GetBits(pInfo, 13);
if (!mp4_GetBit(pInfo))
if (pInfo->stopOnErr)
goto Err;
}
}
pInfo->VisualObject.VideoObject.VideoObjectPlane.macroblock_num = mp4_GetBits(pInfo, pInfo->VisualObject.VideoObject.mbns);
if (pInfo->VisualObject.VideoObject.VideoObjectPlane.macroblock_num >= pInfo->VisualObject.VideoObject.MacroBlockPerVOP)
goto Err;
if (VOL->shape != MP4_SHAPE_TYPE_BINARYONLY) {
pInfo->VisualObject.VideoObject.VideoObjectPlane.quant_scale = mp4_GetBits9(pInfo, VOL->quant_precision); // quant_scale
}
if (VOL->shape == MP4_SHAPE_TYPE_RECTANGULAR) {
header_extension_code = mp4_GetBit(pInfo);
}
if (header_extension_code) {
//f ignore modulo_time_base
do {
code = mp4_GetBit(pInfo);
} while (code);
if (!mp4_GetBit(pInfo))
if (pInfo->stopOnErr)
goto Err;
//f ignore vop_time_increment
if (VOL->vop_time_increment_resolution_bits != 0 ) {
code = mp4_GetBits(pInfo, VOL->vop_time_increment_resolution_bits);
}
if (!mp4_GetBit(pInfo))
if (pInfo->stopOnErr)
goto Err;
//f ignore vop_coding_type
code = mp4_GetBits9(pInfo, 2);
if (VOL->shape != MP4_SHAPE_TYPE_RECTANGULAR) {
VOP->change_conv_ratio_disable = mp4_GetBit(pInfo);
if (VOP->coding_type != MP4_VOP_TYPE_I)
VOP->shape_coding_type = mp4_GetBit(pInfo);
}
if (VOL->shape != MP4_SHAPE_TYPE_BINARYONLY) {
//f ignore intra_dc_vlc_thr
code = mp4_GetBits9(pInfo, 3);
if (VOL->sprite_enable == MP4_SPRITE_GMC && VOP->coding_type == MP4_VOP_TYPE_S && VOL->sprite_warping_points > 0)
if (mp4_Sprite_Trajectory(pInfo) != MP4_STATUS_OK)
if (pInfo->stopOnErr)
goto Err;
//f ignore vop_reduced_resolution
if (VOL->reduced_resolution_vop_enable && VOL->shape == MP4_SHAPE_TYPE_RECTANGULAR &&
(VOP->coding_type == MP4_VOP_TYPE_I || VOP->coding_type == MP4_VOP_TYPE_P))
code = mp4_GetBit(pInfo);
if (VOP->coding_type != MP4_VOP_TYPE_I)
VOP->fcode_forward = mp4_GetBits9(pInfo, 3);
if (VOP->coding_type == MP4_VOP_TYPE_B)
VOP->fcode_backward = mp4_GetBits9(pInfo, 3);
}
}
if (VOL->newpred_enable) {
int vop_id_length = VOL->vop_time_increment_resolution_bits + 3;
if (vop_id_length > 15)
vop_id_length = 15;
VOP->vop_id = mp4_GetBits(pInfo, vop_id_length);
VOP->vop_id_for_prediction_indication = mp4_GetBit(pInfo);
if (VOP->vop_id_for_prediction_indication)
VOP->vop_id_for_prediction = mp4_GetBits(pInfo, vop_id_length);
if (!mp4_GetMarkerBit(pInfo))
if (pInfo->stopOnErr)
goto Err;
}
*found = 1;
return MP4_STATUS_OK;
}
return MP4_STATUS_OK;
Err:
mp4_Error("Error: decoding Video Packet Header");
return MP4_STATUS_PARSE_ERROR;
}
Ipp32s mp4_CheckDecodeGOB_SVH(mp4_Info* pInfo)
{
Ipp32s code;
pInfo->VisualObject.VideoObject.VideoObjectPlaneH263.gob_number ++;
pInfo->VisualObject.VideoObject.VideoObjectPlaneH263.gob_header_empty = 1;
code = mp4_ShowBits(pInfo, 17); /* check gob_resync_marker */
if (code != 1) {
code = mp4_ShowBitsAlign(pInfo, 17); /* check next aligned bits are gob_resync_marker */
if (code == 1)
mp4_AlignBits(pInfo);
}
if (code == 1) {
mp4_FlushBits(pInfo, 17);
pInfo->VisualObject.VideoObject.VideoObjectPlaneH263.gob_header_empty = 0;
code = mp4_GetBits9(pInfo, 5); /* gob_number */
pInfo->VisualObject.VideoObject.VideoObjectPlaneH263.gob_frame_id = mp4_GetBits9(pInfo, 2);
pInfo->VisualObject.VideoObject.VideoObjectPlaneH263.quant_scale = mp4_GetBits9(pInfo, 5);
// check gob_number is valid
//if (code > pInfo->VisualObject.VideoObject.VideoObjectPlaneH263.gob_number && code <= pInfo->VisualObject.VideoObject.VideoObjectPlaneH263.num_gobs_in_vop)
if (code <= pInfo->VisualObject.VideoObject.VideoObjectPlaneH263.num_gobs_in_vop)
pInfo->VisualObject.VideoObject.VideoObjectPlaneH263.gob_number = code;
else {
mp4_Error("Error: bad gob_number in GOB header");
return MP4_STATUS_ERROR;
}
}
return MP4_STATUS_OK;
}
#endif //defined (UMC_ENABLE_MPEG4_VIDEO_DECODER)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -