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

📄 mp4eutil.c

📁 Intel提供的在PCA(例如Sitsang开发板)使用IPP4.0库的MPEG-4编码源程序
💻 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:    Utility functions of MPEG-4 video encoder sample code for//                  Intel(R) Integrated Performance Primitives.//  Functions List://		set_ref_frame_enc_mpeg4()//		expand_frame_enc_mpeg4()//		lookup_uvmv_mpeg4()******************************************************************************/#include "sampmp4.h"/******************************************************************************// Name:            set_ref_frame_enc_mpeg4// Description:		set reference plane, namely switch current frame and //					forward reference frame, current reconstructed frame and//                  forward reference reconstructed frame.//// Input Arguments:	//			enc_state - pointer to the general state struct of MPEG-4 encoder//// Output Arguments:	//			enc_state - pointer to the updated state struct of MPEG-4 encoder//// Returns:  //          none******************************************************************************/void set_ref_frame_enc_mpeg4(mp4_enc_state *enc_state){    sample_spacial_ptrset tmp_frame;        tmp_frame = enc_state->fwd_ref_frame;    enc_state->fwd_ref_frame = enc_state->cur_frame;    enc_state->cur_frame = tmp_frame;    tmp_frame = enc_state->fwd_ref_rec_frame;    enc_state->fwd_ref_rec_frame = enc_state->rec_frame;    enc_state->rec_frame = tmp_frame;    return;}/******************************************************************************// Name:            expand_frame_enc_mpeg4// Description:		expand reference rectangular VOP and reference reconstruct//					VOP in order to perform motion compensated prediction//// Input Arguments:	//			enc_state - pointer to the general state struct of MPEG-4 encoder// Output Arguments:	//			enc_state - pointer to the updated state struct of MPEG-4 encoder//// Returns:  //          none******************************************************************************/void expand_frame_enc_mpeg4(mp4_enc_state *enc_state){    int y_step  = enc_state->frame_step_set.y_step;    int cb_step = enc_state->frame_step_set.cb_step;    int cr_step = enc_state->frame_step_set.cr_step;    int width  = enc_state->frame_dimension.width;    int height = enc_state->frame_dimension.height;    Ipp8u *y_ptr, *cb_ptr, *cr_ptr;        /* forward reference plane */    y_ptr  = enc_state->fwd_ref_frame.y_ptr  - SAMPLE_VIDEO_MB_SIZE        * y_step  - SAMPLE_VIDEO_MB_SIZE;    cb_ptr = enc_state->fwd_ref_frame.cb_ptr - SAMPLE_VIDEO_BLOCK_SIZE        * cb_step - SAMPLE_VIDEO_BLOCK_SIZE;            cr_ptr = enc_state->fwd_ref_frame.cr_ptr - SAMPLE_VIDEO_BLOCK_SIZE        * cr_step - SAMPLE_VIDEO_BLOCK_SIZE;    /* Padding expandY */    /* y_ptr must be 8 bytes aligned */    ippiExpandFrame_H263_8u(y_ptr, width, height, SAMPLE_VIDEO_MB_SIZE,        y_step);        /* Padding expandU */    /* cb_ptr must be 8 bytes aligned */    ippiExpandFrame_H263_8u(cb_ptr, width/2, height/2, SAMPLE_VIDEO_BLOCK_SIZE,        cb_step);        /* Padding expandV */    /* cr_ptr must be 8 bytes aligned */    ippiExpandFrame_H263_8u(cr_ptr, width/2, height/2, SAMPLE_VIDEO_BLOCK_SIZE,        cr_step);    /* forward reference reconstructed plane */    y_ptr  = enc_state->fwd_ref_rec_frame.y_ptr - SAMPLE_VIDEO_MB_SIZE        * y_step - SAMPLE_VIDEO_MB_SIZE;    cb_ptr = enc_state->fwd_ref_rec_frame.cb_ptr - SAMPLE_VIDEO_BLOCK_SIZE        * cb_step - SAMPLE_VIDEO_BLOCK_SIZE;    cr_ptr = enc_state->fwd_ref_rec_frame.cr_ptr - SAMPLE_VIDEO_BLOCK_SIZE        * cr_step - SAMPLE_VIDEO_BLOCK_SIZE;    /* Padding expandY */    /* y_ptr must be 8 bytes aligned */    ippiExpandFrame_H263_8u(y_ptr, width, height, SAMPLE_VIDEO_MB_SIZE,        y_step);        /* Padding expandU */    /* cb_ptr must be 8 bytes aligned */    ippiExpandFrame_H263_8u(cb_ptr, width/2, height/2, SAMPLE_VIDEO_BLOCK_SIZE,        cb_step);        /* Padding expandV */    /* cr_ptr must be 8 bytes aligned */    ippiExpandFrame_H263_8u(cr_ptr, width/2, height/2, SAMPLE_VIDEO_BLOCK_SIZE,        cr_step);}/*****************************************************************************// Name:            lookup_uvmv_mpeg4()// Description:     Look up the motion vector of chrominace block based on the//                  motion vector of luminance block.// Input Arguments: //      mv_lum      Pointer to the Motion Vector of Luminance block.//                  (1st lumianance block in macroblock)//      mb_type     macroblock type// Output Arguments://      mv_chr      Pointer to the Motion Vector of Luminance block.// Returns://      SAMPLE_STATUS_NOERR     If succeeds// Notes:******************************************************************************/sample_status lookup_uvmv_mpeg4(IppMotionVector *mv_lum, IppMotionVector *mv_chr, int mb_type){    int     k ;    int     dx, dy;    if ((IPP_VIDEO_INTER4V == mb_type) || (IPP_VIDEO_DIRECT == mb_type)) {        dx = mv_lum[0].dx + mv_lum[1].dx + mv_lum[2].dx + mv_lum[3].dx;        dy = mv_lum[0].dy + mv_lum[1].dy + mv_lum[2].dy + mv_lum[3].dy;        if (0 == dx) {            mv_chr->dx = 0;        } else if (0 < dx) {            k = dx & 0x0f;            mv_chr->dx = (Ipp16s)((dx >> 4) << 1);            if (13 < k) {                mv_chr->dx += 2;            } else if (2 < k) {                mv_chr->dx += 1;            }        } else {            k = (-dx) & 0x0f;                                               mv_chr->dx = (Ipp16s)(((-dx) >> 4) << 1);            if (13 < k) {                                                        mv_chr->dx += 2;                                                        } else if (2 < k) {                                                  mv_chr->dx += 1;                                                        }                                                                   mv_chr->dx = (Ipp16s)(-(mv_chr->dx));        }                                                                   if (0 == dy) {                                                     mv_chr->dy = 0;                                                     } else if (0 < dy) {                                                 k = dy & 0x0f;                                              mv_chr->dy = (Ipp16s)((dy >> 4) << 1);            if(13 < k) {                mv_chr->dy += 2;            } else if(2 < k) {                mv_chr->dy += 1;            }                                                               } else {                                                                k = (-dy) & 0x0f;                                               mv_chr->dy = (Ipp16s)(((-dy) >> 4) << 1);                                 if (13 < k) {                                                        mv_chr->dy += 2;                                                        } else if (2 < k) {                                                  mv_chr->dy += 1;                                                        }                                                                   mv_chr->dy = (Ipp16s)(-(mv_chr->dy));        }                                                                           }   else {        if (0 == mv_lum[0].dx) {                                                       mv_chr->dx = 0;                                                     } else if (0 < mv_lum[0].dx) {                                                   mv_chr->dx = (Ipp16s)((mv_lum[0].dx >> 2) << 1);            if(mv_lum[0].dx & 0x3) {                                                        mv_chr->dx += 1;                                                        }                                                               } else {                                                                mv_chr->dx = (Ipp16s)(((-mv_lum[0].dx) >> 2) << 1);            if(mv_lum[0].dx & 0x3) {                                                        mv_chr->dx += 1;                                                        }                                                                   mv_chr->dx = (Ipp16s)(-(mv_chr->dx));        }                                                                   if (0 == mv_lum[0].dy) {                                                       mv_chr->dy = 0;                                                     } else if(0 < mv_lum[0].dy) {                                                   mv_chr->dy = (Ipp16s)((mv_lum[0].dy >> 2) << 1);            if(mv_lum[0].dy & 0x3) {                                                        mv_chr->dy += 1;                                                        }                                                               } else {                                                                mv_chr->dy = (Ipp16s)(((-mv_lum[0].dy) >> 2) << 1);            if(mv_lum[0].dy & 0x3) {                                                        mv_chr->dy += 1;                                                        }                                                                   mv_chr->dy = (Ipp16s)(-(mv_chr->dy));        }               }        return SAMPLE_STATUS_NOERR;}

⌨️ 快捷键说明

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