⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mp4evops.c

📁 Intel提供的在PCA(例如Sitsang开发板)使用IPP4.0库的MPEG-4编码源程序
💻 C
📖 第 1 页 / 共 2 页
字号:
			vop_infor->tranp_buf += 4;			if (0 == mby_indx) {				for(i=0;i<4;i++){					vop_infor->tranp_buf[i] = IPP_VIDEO_OPAQUE;				}			}			            mv_cur_mb += 4;            type_cur_mb ++;            vop_infor->qp_buf ++;            vop_infor->qp_buf[0] = vop_infor->cur_qp;                } /* loop for each row */        /* position the 1st MB in the next row of the VOP */        vop_infor->cur_mb.y_ptr  += enc_state->frame_step_set.y_step            * SAMPLE_VIDEO_MB_SIZE - enc_state->mb_per_row            * SAMPLE_VIDEO_MB_SIZE;        vop_infor->cur_mb.cb_ptr += enc_state->frame_step_set.cb_step            * SAMPLE_VIDEO_BLOCK_SIZE - enc_state->mb_per_row            * SAMPLE_VIDEO_BLOCK_SIZE;        vop_infor->cur_mb.cr_ptr += enc_state->frame_step_set.cr_step            * SAMPLE_VIDEO_BLOCK_SIZE - enc_state->mb_per_row            * SAMPLE_VIDEO_BLOCK_SIZE;        vop_infor->rec_mb.y_ptr  += enc_state->frame_step_set.y_step            * SAMPLE_VIDEO_MB_SIZE - enc_state->mb_per_row            * SAMPLE_VIDEO_MB_SIZE;        vop_infor->rec_mb.cb_ptr += enc_state->frame_step_set.cb_step            * SAMPLE_VIDEO_BLOCK_SIZE - enc_state->mb_per_row            * SAMPLE_VIDEO_BLOCK_SIZE;        vop_infor->rec_mb.cr_ptr += enc_state->frame_step_set.cr_step            * SAMPLE_VIDEO_BLOCK_SIZE - enc_state->mb_per_row            * SAMPLE_VIDEO_BLOCK_SIZE;        vop_infor->fwd_ref_mb.y_ptr  += enc_state->frame_step_set.y_step            * SAMPLE_VIDEO_MB_SIZE - enc_state->mb_per_row            * SAMPLE_VIDEO_MB_SIZE;        vop_infor->fwd_ref_mb.cb_ptr += enc_state->frame_step_set.cb_step            * SAMPLE_VIDEO_BLOCK_SIZE - enc_state->mb_per_row            * SAMPLE_VIDEO_BLOCK_SIZE;        vop_infor->fwd_ref_mb.cr_ptr += enc_state->frame_step_set.cr_step            * SAMPLE_VIDEO_BLOCK_SIZE - enc_state->mb_per_row            * SAMPLE_VIDEO_BLOCK_SIZE;        vop_infor->fwd_ref_rec_mb.y_ptr  += enc_state->frame_step_set.y_step            * SAMPLE_VIDEO_MB_SIZE - enc_state->mb_per_row            * SAMPLE_VIDEO_MB_SIZE;        vop_infor->fwd_ref_rec_mb.cb_ptr += enc_state->frame_step_set.cb_step            * SAMPLE_VIDEO_BLOCK_SIZE - enc_state->mb_per_row            * SAMPLE_VIDEO_BLOCK_SIZE;        vop_infor->fwd_ref_rec_mb.cr_ptr += enc_state->frame_step_set.cr_step            * SAMPLE_VIDEO_BLOCK_SIZE - enc_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  = enc_state->coef_buf_row.y_ptr            + SAMPLE_VIDEO_MB_SIZE;        vop_infor->coef_buf_row.cb_ptr = enc_state->coef_buf_row.cb_ptr            + SAMPLE_VIDEO_BLOCK_SIZE;        vop_infor->coef_buf_row.cr_ptr = enc_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    = enc_state->qp_buf;        vop_infor->qp_buf[0] = enc_state->qp_buf[enc_state->mb_per_row];        vop_infor->tranp_buf = enc_state->tranp_buf;        mv_cur_mb += 2 * 4;        } /* loop for each column */	return SAMPLE_STATUS_NOERR;}/******************************************************************************// Name:        encode_ivop_mpeg4// Desicription://      Encode the IVOP data in non-ER mode////  Input Arguments://      stream_buf  - Pointer to the output video bitstream//      enc_state   - Pointer to the general state struct of MPEG-4 encoder//      vop_infor   - Pointer to the vop information struct of MPEG-4 encoder////  Output Arguments://      stream_buf  - Pointer to the updated output video bitstream after//                    compression//      enc_state   - Pointer to the updated general state struct of MPEG-4//                    encoder//      vop_infor   - Pointer to the updated vop information struct of MPEG-4//                    encoder////  Returns://      SAMPLE_STATUS_NOERR      If succeeds//      SAMPLE_STATUS_ERR        If encoding fails//  Note://  ******************************************************************************/sample_status encode_ivop_mpeg4(sample_bitstream  *stream_buf,                                mp4_enc_state     *enc_state,                                mp4_enc_vop_infor *vop_infor){    int mby_indx = 0, mbx_indx = 0;    sample_status ret_code;    /* initialize high-level encoder state */    init_vop_infor_enc_mpeg4(enc_state, vop_infor);        /* dump vop header information into output stream */    create_vop_header_mpeg4(stream_buf, enc_state, vop_infor);        /* loop for each column */    for (mby_indx = 0; mby_indx < enc_state->mb_per_col; mby_indx++) {        /* loop for each row */        for (mbx_indx = 0; mbx_indx < enc_state->mb_per_row; mbx_indx++) {                        /* determine the mb_type */            /* rate control is not supported, so quant para doesn't change with            // macroblocks or frames and mb_type is always IPP_VIDEO_INTRA */            if (vop_infor->delta_qp) {                vop_infor->mb_type = IPP_VIDEO_INTRA_Q;            } else {                vop_infor->mb_type = IPP_VIDEO_INTRA;            }                        ret_code = encode_intra_mb_mpeg4(stream_buf, enc_state, vop_infor);            if (SAMPLE_STATUS_NOERR != ret_code) {                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->rec_mb.y_ptr  += SAMPLE_VIDEO_MB_SIZE;            vop_infor->rec_mb.cb_ptr += SAMPLE_VIDEO_BLOCK_SIZE;            vop_infor->rec_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  += enc_state->frame_step_set.y_step            * SAMPLE_VIDEO_MB_SIZE - enc_state->mb_per_row            * SAMPLE_VIDEO_MB_SIZE;        vop_infor->cur_mb.cb_ptr += enc_state->frame_step_set.cb_step            * SAMPLE_VIDEO_BLOCK_SIZE - enc_state->mb_per_row            * SAMPLE_VIDEO_BLOCK_SIZE;        vop_infor->cur_mb.cr_ptr += enc_state->frame_step_set.cr_step            * SAMPLE_VIDEO_BLOCK_SIZE - enc_state->mb_per_row            * SAMPLE_VIDEO_BLOCK_SIZE;        vop_infor->rec_mb.y_ptr  += enc_state->frame_step_set.y_step            * SAMPLE_VIDEO_MB_SIZE - enc_state->mb_per_row            * SAMPLE_VIDEO_MB_SIZE;        vop_infor->rec_mb.cb_ptr += enc_state->frame_step_set.cb_step            * SAMPLE_VIDEO_BLOCK_SIZE - enc_state->mb_per_row            * SAMPLE_VIDEO_BLOCK_SIZE;        vop_infor->rec_mb.cr_ptr += enc_state->frame_step_set.cr_step            * SAMPLE_VIDEO_BLOCK_SIZE - enc_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  = enc_state->coef_buf_row.y_ptr            + SAMPLE_VIDEO_MB_SIZE;        vop_infor->coef_buf_row.cb_ptr = enc_state->coef_buf_row.cb_ptr            + SAMPLE_VIDEO_BLOCK_SIZE;        vop_infor->coef_buf_row.cr_ptr = enc_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    = enc_state->qp_buf;        vop_infor->qp_buf[0] = enc_state->qp_buf[enc_state->mb_per_row];    }    return SAMPLE_STATUS_NOERR;    }/******************************************************************************// Name:            encode_mpeg4// Description:     Frame encoding function for MPEG-4 baseline encoder,//                  it includes preprocess for preparing VOP encoding,//                  VOP encoding and postprocess for preparing output//// Input Arguments: //      stream_buf      Pointer to the output video bitstream//      enc_state       Pointer to the general state struct of MPEG-4 encoder////  Output Arguments://      stream_buf      Pointer to the updated output video bitstream after//                      compression.//      enc_state       Pointer to the updated general state struct of MPEG-4//                      encoder.////  Returns:    //      SAMPLE_STATUS_NOERR             If succeeds//      SAMPLE_STATUS_ERR               If encoding fails******************************************************************************/sample_status encode_mpeg4(sample_bitstream *stream_buf,                           mp4_enc_state    *enc_state){    mp4_enc_vop_infor   vop_infor;    sample_status       ret_code;    /* determine the vop_coding_type*/    if (0 == (enc_state->vop_indx % (enc_state->ivop_interval + 1))) {        enc_state->vop_coding_type = IVOP;        ret_code = encode_ivop_mpeg4(stream_buf, enc_state, &vop_infor);    } else {        enc_state->vop_coding_type = PVOP;        expand_frame_enc_mpeg4(enc_state);        ret_code = encode_pvop_mpeg4(stream_buf, enc_state, &vop_infor);            }    if (SAMPLE_STATUS_NOERR != ret_code) {        return ret_code;    }    /* fill stuffing bits */    if (!stream_buf->bs_cur_bitoffset) {        stream_buf->bs_cur_byte[0]  = 0x7F;    } else {        stream_buf->bs_cur_byte[0] |=            bits_stuf_tbl[7 - stream_buf->bs_cur_bitoffset];        stream_buf->bs_cur_bitoffset = 0;    }    stream_buf->bs_cur_byte++;    /* exchange between current and reference frame */    set_ref_frame_enc_mpeg4(enc_state);    /* update input info pic pointers */    enc_state->info_pic->pic_plane[0] = enc_state->cur_frame.y_ptr;    enc_state->info_pic->pic_plane[1] = enc_state->cur_frame.cb_ptr;    enc_state->info_pic->pic_plane[2] = enc_state->cur_frame.cr_ptr;    enc_state->vop_indx++;    return SAMPLE_STATUS_NOERR;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -