📄 mp4dvops.c
字号:
vop_infor->mb_indx++;
vop_infor->cur_mb.y_ptr += SAMPLE_VIDEO_MB_SIZE;
vop_infor->cur_mb.cb_ptr += SAMPLE_VIDEO_BLOCK_SIZE;
vop_infor->cur_mb.cr_ptr += SAMPLE_VIDEO_BLOCK_SIZE;
vop_infor->coef_buf_row.y_ptr += SAMPLE_VIDEO_MB_SIZE;
vop_infor->coef_buf_row.cb_ptr += SAMPLE_VIDEO_BLOCK_SIZE;
vop_infor->coef_buf_row.cr_ptr += SAMPLE_VIDEO_BLOCK_SIZE;
/* update qp_buf ptr */
vop_infor->qp_buf++;
vop_infor->qp_buf[0] = vop_infor->cur_qp;
}
/* position the 1st MB in the next row of the VOP */
vop_infor->cur_mb.y_ptr += dec_state->frame_step_set.y_step
* SAMPLE_VIDEO_MB_SIZE - dec_state->mb_per_row
* SAMPLE_VIDEO_MB_SIZE;
vop_infor->cur_mb.cb_ptr += dec_state->frame_step_set.cb_step
* SAMPLE_VIDEO_BLOCK_SIZE - dec_state->mb_per_row
* SAMPLE_VIDEO_BLOCK_SIZE;
vop_infor->cur_mb.cr_ptr += dec_state->frame_step_set.cr_step
* SAMPLE_VIDEO_BLOCK_SIZE - dec_state->mb_per_row
* SAMPLE_VIDEO_BLOCK_SIZE;
/* update dc coefficient of the 4th block in the last MB each row */
vop_infor->coef_buf_row.y_ptr[-8] = vop_infor->coef_buf_col.y_ptr[8];
/* restore ac/dc prediction coefficient row buffer ptrs */
vop_infor->coef_buf_row.y_ptr = dec_state->coef_buf_row.y_ptr
+ SAMPLE_VIDEO_MB_SIZE;
vop_infor->coef_buf_row.cb_ptr = dec_state->coef_buf_row.cb_ptr
+ SAMPLE_VIDEO_BLOCK_SIZE;
vop_infor->coef_buf_row.cr_ptr = dec_state->coef_buf_row.cr_ptr
+ SAMPLE_VIDEO_BLOCK_SIZE;
/* restore the dc coefficient on the left border */
vop_infor->coef_buf_col.y_ptr[0] = -1;
vop_infor->coef_buf_col.y_ptr[8] = -1;
vop_infor->coef_buf_col.cb_ptr[0] = -1;
vop_infor->coef_buf_col.cr_ptr[0] = -1;
/* restore qp_buf ptr */
vop_infor->qp_buf = dec_state->qp_buf;
vop_infor->qp_buf[0] = dec_state->qp_buf[dec_state->mb_per_row];
}
return SAMPLE_STATUS_NOERR;
}
/******************************************************************************
// Name: decode_mpeg4
// Description: Frame decoding function for MPEG-4 simple profile decoder,
// it includes preprocess for preparing VOP decoding,
// VOP decoding and postprocess for preparing output
//
// Input Arguments:
// stream_buf Pointer to the source compressed video bitstream
// dec_state Pointer to the general state struct of MPEG-4 decoder
//
// Output Arguments:
// stream_buf Pointer to the updated video bitstream
// dec_state Pointer to the updated general state struct of MPEG-4
// decoder.
//
// Returns:
// SAMPLE_STATUS_NOERR If succeeds
// SAMPLE_STATUS_ERR If decoding fails
// SAMPLE_STATUS_SYNCNOTFOUND_ERR If cannot find next sync code
// SAMPLE_STATUS_NOTSUPPORTED_ERR If stream syntax is not supported by
// current sample decoder
******************************************************************************/
sample_status decode_mpeg4
(sample_bitstream *stream_buf, sample_picture *picture,
mp4_dec_state *dec_state)
{
mp4_dec_vop_infor vop_infor;
sample_status ret_code;
Ipp32u code;
Ipp8u* next_sync_pos = NULL;
int i;
/* seek the next_start_code to ensure the current object has been resident
// in the buffer completely */
ret_code = search_next_sc_mpeg4(stream_buf, &next_sync_pos);
if (SAMPLE_STATUS_NOERR != ret_code) {
return ret_code;
}
/* identify the type of the current sync code */
code = get_bits_mpeg4(stream_buf, 8);
/* seek until vop_start_code is found */
while (MPEG4_SUFFIX_VOPSC != code) {
/* group_of_vop_start_code */
if (MPEG4_SUFFIX_GOVSC == code) {
/* process gov data here */
parse_gov_mpeg4(stream_buf, dec_state);
} else if (MPEG4_SUFFIX_UDSC == code) { /* user_data_start_code */
/* process user defined data here */
}
/* go on with the next object */
stream_buf->bs_cur_bitoffset = 0;
stream_buf->bs_cur_byte = next_sync_pos;
ret_code = search_next_sc_mpeg4(stream_buf, &next_sync_pos);
if (SAMPLE_STATUS_NOERR != ret_code) {
return ret_code;
}
code = get_bits_mpeg4(stream_buf, 8);
}
/* parse vop header information */
ret_code = parse_vop_header_mpeg4(stream_buf, dec_state, &vop_infor);
if (SAMPLE_STATUS_NOERR != ret_code) {
return ret_code;
}
/* if vop coded */
if (dec_state->vop_coded) {
dec_state->info_pic->pic_plane[0] = dec_state->cur_frame.y_ptr;
dec_state->info_pic->pic_plane[1] = dec_state->cur_frame.cb_ptr;
dec_state->info_pic->pic_plane[2] = dec_state->cur_frame.cr_ptr;
if ((PVOP == dec_state->vop_coding_type) && (0 != dec_state->vop_indx))
{
/* expand reference frame for unrestricted motion compensation */
expand_frame_dec_mpeg4 (dec_state);
}
switch(dec_state->vop_coding_type)
{
case IVOP:
ret_code = decode_ivop_mpeg4(stream_buf, dec_state, &vop_infor);
if (SAMPLE_STATUS_NOERR != ret_code) {
stream_buf->bs_cur_bitoffset = 0;
stream_buf->bs_cur_byte = next_sync_pos;
return ret_code;
}
break;
case PVOP:
ret_code = decode_pvop_mpeg4(stream_buf, dec_state, &vop_infor);
if (SAMPLE_STATUS_NOERR != ret_code) {
stream_buf->bs_cur_bitoffset = 0;
stream_buf->bs_cur_byte = next_sync_pos;
return ret_code;
}
break;
default:
stream_buf->bs_cur_bitoffset = 0;
stream_buf->bs_cur_byte = next_sync_pos;
return SAMPLE_STATUS_NOTSUPPORTED_ERR;
}
set_ref_frame_dec_mpeg4(dec_state);
} else { /* vop not coded */
/* directly copy the previous reference picture plane */
dec_state->info_pic->pic_plane[0] = dec_state->fwd_ref_frame.y_ptr;
dec_state->info_pic->pic_plane[1] = dec_state->fwd_ref_frame.cb_ptr;
dec_state->info_pic->pic_plane[2] = dec_state->fwd_ref_frame.cr_ptr;
}
/* copy to output picture struct */
picture->pic_plane_num = dec_state->info_pic->pic_plane_num;
picture->pic_channel_num = dec_state->info_pic->pic_channel_num;
picture->pic_height = dec_state->info_pic->pic_height;
picture->pic_width = dec_state->info_pic->pic_width;
picture->pic_format = dec_state->info_pic->pic_format;
for ( i = 0; i < SAMPLE_MAXPLANENUM; i++ ) {
picture->pic_plane[i] = dec_state->info_pic->pic_plane[i];
picture->pic_plane_step[i] = dec_state->info_pic->pic_plane_step[i];
}
dec_state->vop_indx ++;
stream_buf->bs_cur_bitoffset = 0;
stream_buf->bs_cur_byte = next_sync_pos;
return SAMPLE_STATUS_NOERR;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -