📄 mp4dvops.c
字号:
/******************************************************************************
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright (c) 2003 Intel Corporation. All Rights Reserved.
//
// Description: VOP or frame decoding functions of MPEG-4 video decoder
// sample code for Intel(R) Integrated Performance Primitives.
// Functions List:
// decode_pvop_mpeg4()
// decode_ivop_mpeg4()
// decode_mpeg4()
******************************************************************************/
#include "sampmp4.h"
/******************************************************************************
// Name: decode_pvop_mpeg4
// Desicription:
// Decode the PVOP data in non-ER mode
//
// Input Arguments:
// stream_buf - Pointer to the source video bitstream
// dec_state - Pointer to the general state struct of MPEG-4 decoder
// vop_infor - Pointer to the vop information 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
// vop_infor - Pointer to the updated vop information struct of MPEG-4
// decoder
//
// Returns:
// SAMPLE_STATUS_NOERR If succeeds
// SAMPLE_STATUS_ERR If decoding fails
// Note:
//
******************************************************************************/
sample_status decode_pvop_mpeg4
(sample_bitstream *stream_buf, mp4_dec_state *dec_state,
mp4_dec_vop_infor *vop_infor)
{
int mbx_indx = 0;
int mby_indx = 0;
int i = 0;
sample_status ret_code;
/* init vop information each time before frame decoding */
init_vop_infor_dec_mpeg4(dec_state, vop_infor);
/* loop for each column */
for (mby_indx = 0; mby_indx < dec_state->mb_per_col; mby_indx ++) {
/* loop for each row */
for (mbx_indx = 0; mbx_indx < dec_state->mb_per_row; mbx_indx ++) {
/* decode the MacroBlock */
ret_code = decode_mb_pvop_mpeg4(stream_buf, dec_state, vop_infor,
mbx_indx, mby_indx);
if (ret_code != SAMPLE_STATUS_NOERR) {
return ret_code;
}
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->fwd_ref_mb.y_ptr += SAMPLE_VIDEO_MB_SIZE;
vop_infor->fwd_ref_mb.cb_ptr += SAMPLE_VIDEO_BLOCK_SIZE;
vop_infor->fwd_ref_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 tranp_buf ptr */
vop_infor->tranp_buf += 4;
if (0 == mby_indx) {
for (i = 0; i < 4; i++){
vop_infor->tranp_buf[i] = IPP_VIDEO_OPAQUE;
}
}
/* 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;
/* position the 1st ref MB in the next row of the ref VOP */
vop_infor->fwd_ref_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->fwd_ref_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->fwd_ref_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 per 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];
/* restore mv_buf ptr */
vop_infor->mv_buf = dec_state->mv_buf;
/* restore tranp_buf ptr */
vop_infor->tranp_buf = dec_state->tranp_buf;
}
return SAMPLE_STATUS_NOERR;
}
/******************************************************************************
// Name: decode_ivop_mpeg4
// Desicription:
// Decode the IVOP data in non-ER mode
//
// Input Arguments:
// stream_buf - Pointer to the source video bitstream
// dec_state - Pointer to the general state struct of MPEG-4 decoder
// vop_infor - Pointer to the vop information 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
// vop_infor - Pointer to the updated vop information struct of MPEG-4
// decoder
//
// Returns:
// SAMPLE_STATUS_NOERR If succeeds
// SAMPLE_STATUS_ERR If decoding fails
// Note:
//
******************************************************************************/
sample_status decode_ivop_mpeg4
(sample_bitstream *stream_buf, mp4_dec_state *dec_state,
mp4_dec_vop_infor *vop_infor)
{
sample_status ret_code;
int mbx_indx = 0;
int mby_indx = 0;
/* init vop information each time before frame decoding */
init_vop_infor_dec_mpeg4(dec_state, vop_infor);
/* loop for each column */
for (mby_indx = 0; mby_indx < dec_state->mb_per_col; mby_indx ++) {
/* loop for each row */
for (mbx_indx = 0; mbx_indx < dec_state->mb_per_row; mbx_indx++) {
/* decode the MacroBlock */
ret_code = decode_mb_ivop_mpeg4(stream_buf, dec_state, vop_infor);
if (SAMPLE_STATUS_NOERR != ret_code) {
return ret_code;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -