omxvcm4p2_motionestimationmb.c
来自「The OpenMAX DL (Development Layer) APIs 」· C语言 代码 · 共 631 行 · 第 1/2 页
C
631 行
/** * * File Name: omxVCM4P2_MotionEstimationMB.c * OpenMAX DL: v1.0.2 * Revision: 10586 * Date: Wednesday, March 5, 2008 * * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved. * * * * Description: * Contains module for motion search 16x16 macroblock * */ #include "omxtypes.h"#include "armOMX.h"#include "omxVC.h"#include "armVC.h"#include "armCOMM.h"/** * Function: armVCM4P2_BlockMatch_16x16 * * Description: * 16x16 block match wrapper function, calls omxVCM4P2_BlockMatch_Integer_16x16. * If half pel search is enabled it also calls omxVCM4P2_BlockMatch_Half_16x16 * * Remarks: * * Parameters: * [in] pSrcRefBuf pointer to the reference Y plane; points to the reference MB that * corresponds to the location of the current macroblock in the current * plane. * [in] srcRefStep width of the reference plane * [in] pRefRect pointer to the valid rectangular in reference plane. Relative to image origin. * It's not limited to the image boundary, but depended on the padding. For example, * if you pad 4 pixels outside the image border, then the value for left border * can be -4 * [in] pSrcCurrBuf pointer to the current macroblock extracted from original plane (linear array, * 256 entries); must be aligned on an 16-byte boundary. * [in] pCurrPointPos position of the current macroblock in the current plane * [in] pSrcPreMV pointer to predicted motion vector; NULL indicates no predicted MV * [in] pSrcPreSAD pointer to SAD associated with the predicted MV (referenced by pSrcPreMV); may be set to NULL if unavailable. * [in] pMESpec vendor-specific motion estimation specification structure; must have been allocated * and then initialized using omxVCM4P2_MEInit prior to calling the block matching * function. * [out] pDstMV pointer to estimated MV * [out] pDstSAD pointer to minimum SAD * * * Return Value: * OMX_Sts_NoErr - no error * OMX_Sts_BadArgErr - bad arguments * */static OMXResult armVCM4P2_BlockMatch_16x16( const OMX_U8 *pSrcRefBuf, const OMX_INT srcRefStep, const OMXRect *pRefRect, const OMX_U8 *pSrcCurrBuf, const OMXVCM4P2Coordinate *pCurrPointPos, OMXVCMotionVector *pSrcPreMV, OMX_INT *pSrcPreSAD, void *pMESpec, OMXVCMotionVector *pDstMV, OMX_INT *pDstSAD){ OMXVCM4P2MEParams *pMEParams = (OMXVCM4P2MEParams *)pMESpec; OMX_INT rndVal; rndVal = pMEParams->rndVal; omxVCM4P2_BlockMatch_Integer_16x16( pSrcRefBuf, srcRefStep, pRefRect, pSrcCurrBuf, pCurrPointPos, pSrcPreMV, pSrcPreSAD, pMEParams, pDstMV, pDstSAD); if (pMEParams->halfPelSearchEnable) { omxVCM4P2_BlockMatch_Half_16x16( pSrcRefBuf, srcRefStep, pRefRect, pSrcCurrBuf, pCurrPointPos, rndVal, pDstMV, pDstSAD); } return OMX_Sts_NoErr; }/** * Function: armVCM4P2_BlockMatch_8x8 * * Description: * 8x8 block match wrapper function, calls omxVCM4P2_BlockMatch_Integer_8x8. * If half pel search is enabled it also calls omxVCM4P2_BlockMatch_Half_8x8 * * Remarks: * * Parameters: * [in] pSrcRefBuf pointer to the reference Y plane; points to the reference MB that * corresponds to the location of the current macroblock in the current * plane. * [in] srcRefStep width of the reference plane * [in] pRefRect pointer to the valid rectangular in reference plane. Relative to image origin. * It's not limited to the image boundary, but depended on the padding. For example, * if you pad 4 pixels outside the image border, then the value for left border * can be -4 * [in] pSrcCurrBuf pointer to the current macroblock extracted from original plane (linear array, * 256 entries); must be aligned on an 16-byte boundary. * [in] pCurrPointPos position of the current macroblock in the current plane * [in] pSrcPreMV pointer to predicted motion vector; NULL indicates no predicted MV * [in] pSrcPreSAD pointer to SAD associated with the predicted MV (referenced by pSrcPreMV); may be set to NULL if unavailable. * [in] pMESpec vendor-specific motion estimation specification structure; must have been allocated * and then initialized using omxVCM4P2_MEInit prior to calling the block matching * function. * [out] pDstMV pointer to estimated MV * [out] pDstSAD pointer to minimum SAD * * * Return Value: * OMX_Sts_NoErr - no error * OMX_Sts_BadArgErr - bad arguments * */static OMXResult armVCM4P2_BlockMatch_8x8( const OMX_U8 *pSrcRefBuf, OMX_INT srcRefStep, const OMXRect *pRefRect, const OMX_U8 *pSrcCurrBuf, const OMXVCM4P2Coordinate *pCurrPointPos, OMXVCMotionVector *pSrcPreMV, OMX_INT *pSrcPreSAD, void *pMESpec, OMXVCMotionVector *pSrcDstMV, OMX_INT *pDstSAD){ OMXVCM4P2MEParams *pMEParams = (OMXVCM4P2MEParams *)pMESpec; OMX_INT rndVal; rndVal = pMEParams->rndVal; omxVCM4P2_BlockMatch_Integer_8x8( pSrcRefBuf, srcRefStep, pRefRect, pSrcCurrBuf, pCurrPointPos, pSrcPreMV, pSrcPreSAD, pMEParams, pSrcDstMV, pDstSAD); if (pMEParams->halfPelSearchEnable) { omxVCM4P2_BlockMatch_Half_8x8( pSrcRefBuf, srcRefStep, pRefRect, pSrcCurrBuf, pCurrPointPos, rndVal, pSrcDstMV, pDstSAD); } return OMX_Sts_NoErr; }/** * Function: omxVCM4P2_MotionEstimationMB (6.2.4.3.1) * * Description: * Performs motion search for a 16x16 macroblock. Selects best motion search * strategy from among inter-1MV, inter-4MV, and intra modes. Supports * integer and half pixel resolution. * * Input Arguments: * * pSrcCurrBuf - pointer to the top-left corner of the current MB in the * original picture plane; must be aligned on a 16-byte boundary. * The function does not expect source data outside the region * bounded by the MB to be available; for example it is not * necessary for the caller to guarantee the availability of * pSrcCurrBuf[-SrcCurrStep], i.e., the row of pixels above the MB * to be processed. * srcCurrStep - width of the original picture plane, in terms of full * pixels; must be a multiple of 16. * pSrcRefBuf - pointer to the reference Y plane; points to the reference * plane location corresponding to the location of the current * macroblock in the current plane; must be aligned on a 16-byte * boundary. * srcRefStep - width of the reference picture plane, in terms of full * pixels; must be a multiple of 16. * pRefRect - reference plane valid region rectangle, specified relative to * the image origin * pCurrPointPos - position of the current macroblock in the current plane * pMESpec - pointer to the vendor-specific motion estimation specification * structure; must be allocated and then initialized using * omxVCM4P2_MEInit prior to calling this function. * pMBInfo - array, of dimension four, containing pointers to information * associated with four nearby MBs: * - pMBInfo[0] - pointer to left MB information * - pMBInfo[1] - pointer to top MB information * - pMBInfo[2] - pointer to top-left MB information * - pMBInfo[3] - pointer to top-right MB information * Any pointer in the array may be set equal to NULL if the * corresponding MB doesn't exist. For each MB, the following structure * members are used: * - mbType - macroblock type, either OMX_VC_INTRA, OMX_VC_INTER, or * OMX_VC_INTER4V * - pMV0[2][2] - estimated motion vectors; represented * in 1/2 pixel units * - sliceID - number of the slice to which the MB belongs * pSrcDstMBCurr - pointer to information structure for the current MB. * The following entries should be set prior to calling the * function: sliceID - the number of the slice the to which the * current MB belongs. The structure elements cbpy and cbpc are * ignored. * * Output Arguments: * * pSrcDstMBCurr - pointer to updated information structure for the current * MB after MB-level motion estimation has been completed. The * following structure members are updated by the ME function: * - mbType - macroblock type: OMX_VC_INTRA, OMX_VC_INTER, or * OMX_VC_INTER4V. * - pMV0[2][2] - estimated motion vectors; represented in * terms of 1/2 pel units. * - pMVPred[2][2] - predicted motion vectors; represented * in terms of 1/2 pel units. * The structure members cbpy and cbpc are not updated by the function. * pDstSAD - pointer to the minimum SAD for INTER1V, or sum of minimum SADs * for INTER4V * pDstBlockSAD - pointer to an array of SAD values for each of the four * 8x8 luma blocks in the MB. The block SADs are in scan order for * each MB. * * Return Value: * * OMX_Sts_NoErr - no error * OMX_Sts_BadArgErr - bad arguments. Returned if one or more of the * following conditions is true: * - at least one of the following pointers is NULL: pSrcCurrBuf, * pSrcRefBuf, pRefRect, pCurrPointPos, pMBInter, pMBIntra, * pSrcDstMBCurr, or pDstSAD. * */OMXResult omxVCM4P2_MotionEstimationMB ( const OMX_U8 *pSrcCurrBuf, OMX_S32 srcCurrStep, const OMX_U8 *pSrcRefBuf, OMX_S32 srcRefStep, const OMXRect*pRefRect, const OMXVCM4P2Coordinate *pCurrPointPos, void *pMESpec, const OMXVCM4P2MBInfoPtr *pMBInfo, OMXVCM4P2MBInfo *pSrcDstMBCurr, OMX_U16 *pDstSAD, OMX_U16 *pDstBlockSAD){ OMX_INT intraSAD, average, count, index, x, y; OMXVCMotionVector dstMV16x16; OMX_INT dstSAD16x16; OMX_INT dstSAD8x8; OMXVCM4P2MEParams *pMEParams; OMXVCM4P2Coordinate TempCurrPointPos; OMXVCM4P2Coordinate *pTempCurrPointPos; OMX_U8 aTempSrcCurrBuf[271]; OMX_U8 *pTempSrcCurrBuf; OMX_U8 *pDst; OMX_U8 aDst[71]; OMX_S32 dstStep = 8; OMX_INT predictType; OMX_S32 Sad; const OMX_U8 *pTempSrcRefBuf; OMXVCMotionVector* pSrcCandMV1[4]; OMXVCMotionVector* pSrcCandMV2[4]; OMXVCMotionVector* pSrcCandMV3[4]; /* Argument error checks */ armRetArgErrIf(!armIs16ByteAligned(pSrcCurrBuf), OMX_Sts_BadArgErr); armRetArgErrIf(!armIs16ByteAligned(pSrcRefBuf), OMX_Sts_BadArgErr); armRetArgErrIf(((srcCurrStep % 16) || (srcRefStep % 16)), OMX_Sts_BadArgErr); armRetArgErrIf(pSrcCurrBuf == NULL, OMX_Sts_BadArgErr); armRetArgErrIf(pSrcRefBuf == NULL, OMX_Sts_BadArgErr); armRetArgErrIf(pRefRect == NULL, OMX_Sts_BadArgErr); armRetArgErrIf(pCurrPointPos == NULL, OMX_Sts_BadArgErr); armRetArgErrIf(pSrcDstMBCurr == NULL, OMX_Sts_BadArgErr); armRetArgErrIf(pDstSAD == NULL, OMX_Sts_BadArgErr); pTempCurrPointPos = &(TempCurrPointPos); pTempSrcCurrBuf = armAlignTo16Bytes(aTempSrcCurrBuf); pMEParams = (OMXVCM4P2MEParams *)pMESpec; pTempCurrPointPos->x = pCurrPointPos->x; pTempCurrPointPos->y = pCurrPointPos->y; pSrcDstMBCurr->mbType = OMX_VC_INTER;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?