omxVCM4P2_BlockMatch_Half_8x8.c revision 0c1bc742181ded4930842b46e9507372f0b1b963
10c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 20c1bc742181ded4930842b46e9507372f0b1b963James Dong * 30c1bc742181ded4930842b46e9507372f0b1b963James Dong * File Name: omxVCM4P2_BlockMatch_Half_8x8.c 40c1bc742181ded4930842b46e9507372f0b1b963James Dong * OpenMAX DL: v1.0.2 50c1bc742181ded4930842b46e9507372f0b1b963James Dong * Revision: 9641 60c1bc742181ded4930842b46e9507372f0b1b963James Dong * Date: Thursday, February 7, 2008 70c1bc742181ded4930842b46e9507372f0b1b963James Dong * 80c1bc742181ded4930842b46e9507372f0b1b963James Dong * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved. 90c1bc742181ded4930842b46e9507372f0b1b963James Dong * 100c1bc742181ded4930842b46e9507372f0b1b963James Dong * 110c1bc742181ded4930842b46e9507372f0b1b963James Dong * 120c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 130c1bc742181ded4930842b46e9507372f0b1b963James Dong * Contains modules for Block matching, a full search algorithm 140c1bc742181ded4930842b46e9507372f0b1b963James Dong * is implemented 150c1bc742181ded4930842b46e9507372f0b1b963James Dong * 160c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 170c1bc742181ded4930842b46e9507372f0b1b963James Dong 180c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxtypes.h" 190c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armOMX.h" 200c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxVC.h" 210c1bc742181ded4930842b46e9507372f0b1b963James Dong 220c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armVC.h" 230c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armCOMM.h" 240c1bc742181ded4930842b46e9507372f0b1b963James Dong 250c1bc742181ded4930842b46e9507372f0b1b963James Dong 260c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 270c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: omxVCM4P2_BlockMatch_Half_8x8 (6.2.4.2.4) 280c1bc742181ded4930842b46e9507372f0b1b963James Dong * 290c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 300c1bc742181ded4930842b46e9507372f0b1b963James Dong * Performs an 8x8 block match with half-pixel resolution. Returns the 310c1bc742181ded4930842b46e9507372f0b1b963James Dong * estimated motion vector and associated minimum SAD. This function 320c1bc742181ded4930842b46e9507372f0b1b963James Dong * estimates the half-pixel motion vector by interpolating the integer 330c1bc742181ded4930842b46e9507372f0b1b963James Dong * resolution motion vector referenced by the input parameter pSrcDstMV, i.e., 340c1bc742181ded4930842b46e9507372f0b1b963James Dong * the initial integer MV is generated externally. The input parameters 350c1bc742181ded4930842b46e9507372f0b1b963James Dong * pSrcRefBuf and pSearchPointRefPos should be shifted by the winning MV of 360c1bc742181ded4930842b46e9507372f0b1b963James Dong * 8x8 integer search prior to calling BlockMatch_Half_8x8. The function 370c1bc742181ded4930842b46e9507372f0b1b963James Dong * BlockMatch_Integer_8x8 may be used for integer motion estimation. 380c1bc742181ded4930842b46e9507372f0b1b963James Dong * 390c1bc742181ded4930842b46e9507372f0b1b963James Dong * Input Arguments: 400c1bc742181ded4930842b46e9507372f0b1b963James Dong * 410c1bc742181ded4930842b46e9507372f0b1b963James Dong * pSrcRefBuf - pointer to the reference Y plane; points to the reference 420c1bc742181ded4930842b46e9507372f0b1b963James Dong * block that corresponds to the location of the current 8x8 block 430c1bc742181ded4930842b46e9507372f0b1b963James Dong * in the current plane. 440c1bc742181ded4930842b46e9507372f0b1b963James Dong * refWidth - width of the reference plane 450c1bc742181ded4930842b46e9507372f0b1b963James Dong * pRefRect - reference plane valid region rectangle 460c1bc742181ded4930842b46e9507372f0b1b963James Dong * pSrcCurrBuf - pointer to the current block in the current macroblock 470c1bc742181ded4930842b46e9507372f0b1b963James Dong * buffer extracted from the original plane (linear array, 128 480c1bc742181ded4930842b46e9507372f0b1b963James Dong * entries); must be aligned on a 8-byte boundary. The number of 490c1bc742181ded4930842b46e9507372f0b1b963James Dong * bytes between lines (step) is 16. 500c1bc742181ded4930842b46e9507372f0b1b963James Dong * pSearchPointRefPos - position of the starting point for half pixel 510c1bc742181ded4930842b46e9507372f0b1b963James Dong * search (specified in terms of integer pixel units) in the 520c1bc742181ded4930842b46e9507372f0b1b963James Dong * reference plane. 530c1bc742181ded4930842b46e9507372f0b1b963James Dong * rndVal - rounding control parameter: 0 - disabled; 1 - enabled. 540c1bc742181ded4930842b46e9507372f0b1b963James Dong * pSrcDstMV - pointer to the initial MV estimate; typically generated 550c1bc742181ded4930842b46e9507372f0b1b963James Dong * during a prior 8x8 integer search, specified in terms of 560c1bc742181ded4930842b46e9507372f0b1b963James Dong * half-pixel units. 570c1bc742181ded4930842b46e9507372f0b1b963James Dong * 580c1bc742181ded4930842b46e9507372f0b1b963James Dong * Output Arguments: 590c1bc742181ded4930842b46e9507372f0b1b963James Dong * 600c1bc742181ded4930842b46e9507372f0b1b963James Dong * pSrcDstMV - pointer to estimated MV 610c1bc742181ded4930842b46e9507372f0b1b963James Dong * pDstSAD - pointer to minimum SAD 620c1bc742181ded4930842b46e9507372f0b1b963James Dong * 630c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value: 640c1bc742181ded4930842b46e9507372f0b1b963James Dong * 650c1bc742181ded4930842b46e9507372f0b1b963James Dong * OMX_Sts_NoErr - no error 660c1bc742181ded4930842b46e9507372f0b1b963James Dong * OMX_Sts_BadArgErr - bad arguments. Returned if one of the following 670c1bc742181ded4930842b46e9507372f0b1b963James Dong * conditions is true: 680c1bc742181ded4930842b46e9507372f0b1b963James Dong * - at least one of the following pointers is NULL: 690c1bc742181ded4930842b46e9507372f0b1b963James Dong * pSrcRefBuf, pRefRect, pSrcCurrBuff, pSearchPointRefPos, pSrcDstMV 700c1bc742181ded4930842b46e9507372f0b1b963James Dong * - pSrcCurrBuf is not 8-byte aligned 710c1bc742181ded4930842b46e9507372f0b1b963James Dong * 720c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 730c1bc742181ded4930842b46e9507372f0b1b963James Dong 740c1bc742181ded4930842b46e9507372f0b1b963James DongOMXResult omxVCM4P2_BlockMatch_Half_8x8( 750c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pSrcRefBuf, 760c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT refWidth, 770c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMXRect *pRefRect, 780c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pSrcCurrBuf, 790c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMXVCM4P2Coordinate *pSearchPointRefPos, 800c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT rndVal, 810c1bc742181ded4930842b46e9507372f0b1b963James Dong OMXVCMotionVector *pSrcDstMV, 820c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT *pDstSAD 830c1bc742181ded4930842b46e9507372f0b1b963James Dong) 840c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 850c1bc742181ded4930842b46e9507372f0b1b963James Dong /* For a blocksize of 8x8 */ 860c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8 BlockSize = 8; 870c1bc742181ded4930842b46e9507372f0b1b963James Dong 880c1bc742181ded4930842b46e9507372f0b1b963James Dong /* Argument error checks */ 890c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(pSrcRefBuf == NULL, OMX_Sts_BadArgErr); 900c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(pRefRect == NULL, OMX_Sts_BadArgErr); 910c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(pSrcCurrBuf == NULL, OMX_Sts_BadArgErr); 920c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(pSearchPointRefPos == NULL, OMX_Sts_BadArgErr); 930c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(pSrcDstMV == NULL, OMX_Sts_BadArgErr); 940c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(!armIs8ByteAligned(pSrcCurrBuf), OMX_Sts_BadArgErr); 950c1bc742181ded4930842b46e9507372f0b1b963James Dong 960c1bc742181ded4930842b46e9507372f0b1b963James Dong return (armVCM4P2_BlockMatch_Half( 970c1bc742181ded4930842b46e9507372f0b1b963James Dong pSrcRefBuf, 980c1bc742181ded4930842b46e9507372f0b1b963James Dong refWidth, 990c1bc742181ded4930842b46e9507372f0b1b963James Dong pRefRect, 1000c1bc742181ded4930842b46e9507372f0b1b963James Dong pSrcCurrBuf, 1010c1bc742181ded4930842b46e9507372f0b1b963James Dong pSearchPointRefPos, 1020c1bc742181ded4930842b46e9507372f0b1b963James Dong rndVal, 1030c1bc742181ded4930842b46e9507372f0b1b963James Dong pSrcDstMV, 1040c1bc742181ded4930842b46e9507372f0b1b963James Dong pDstSAD, 1050c1bc742181ded4930842b46e9507372f0b1b963James Dong BlockSize)); 1060c1bc742181ded4930842b46e9507372f0b1b963James Dong 1070c1bc742181ded4930842b46e9507372f0b1b963James Dong} 1080c1bc742181ded4930842b46e9507372f0b1b963James Dong 1090c1bc742181ded4930842b46e9507372f0b1b963James Dong/* End of file */ 110