10c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
20c1bc742181ded4930842b46e9507372f0b1b963James Dong *
30c1bc742181ded4930842b46e9507372f0b1b963James Dong * File Name:  omxVCM4P2_BlockMatch_Integer_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 * Function:  omxVCM4P2_BlockMatch_Integer_8x8   (6.2.4.2.2)
270c1bc742181ded4930842b46e9507372f0b1b963James Dong *
280c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
290c1bc742181ded4930842b46e9507372f0b1b963James Dong * Performs an 8x8 block search; estimates motion vector and associated
300c1bc742181ded4930842b46e9507372f0b1b963James Dong * minimum SAD.  Both the input and output motion vectors are represented
310c1bc742181ded4930842b46e9507372f0b1b963James Dong * using half-pixel units, and therefore a shift left or right by 1 bit may be
320c1bc742181ded4930842b46e9507372f0b1b963James Dong * required, respectively, to match the input or output MVs with other
330c1bc742181ded4930842b46e9507372f0b1b963James Dong * functions that either generate output MVs or expect input MVs represented
340c1bc742181ded4930842b46e9507372f0b1b963James Dong * using integer pixel units.
350c1bc742181ded4930842b46e9507372f0b1b963James Dong *
360c1bc742181ded4930842b46e9507372f0b1b963James Dong * Input Arguments:
370c1bc742181ded4930842b46e9507372f0b1b963James Dong *
380c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pSrcRefBuf - pointer to the reference Y plane; points to the reference
390c1bc742181ded4930842b46e9507372f0b1b963James Dong *            block that corresponds to the location of the current 8x8 block
400c1bc742181ded4930842b46e9507372f0b1b963James Dong *            in the current plane.
410c1bc742181ded4930842b46e9507372f0b1b963James Dong *   refWidth - width of the reference plane
420c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pRefRect - pointer to the valid reference plane rectangle; coordinates
430c1bc742181ded4930842b46e9507372f0b1b963James Dong *            are specified relative to the image origin.  Rectangle
440c1bc742181ded4930842b46e9507372f0b1b963James Dong *            boundaries may extend beyond image boundaries if the image has
450c1bc742181ded4930842b46e9507372f0b1b963James Dong *            been padded.
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 an 8-byte boundary.  The number of
490c1bc742181ded4930842b46e9507372f0b1b963James Dong *            bytes between lines (step) is 16 bytes.
500c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pCurrPointPos - position of the current block in the current plane
510c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pSrcPreMV - pointer to predicted motion vector; NULL indicates no
520c1bc742181ded4930842b46e9507372f0b1b963James Dong *            predicted MV
530c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pSrcPreSAD - pointer to SAD associated with the predicted MV (referenced
540c1bc742181ded4930842b46e9507372f0b1b963James Dong *            by pSrcPreMV); may be set to NULL if unavailable.
550c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pMESpec - vendor-specific motion estimation specification structure;
560c1bc742181ded4930842b46e9507372f0b1b963James Dong *            must have been allocated and then initialized using
570c1bc742181ded4930842b46e9507372f0b1b963James Dong *            omxVCM4P2_MEInit prior to calling the block matching function.
580c1bc742181ded4930842b46e9507372f0b1b963James Dong *
590c1bc742181ded4930842b46e9507372f0b1b963James Dong * Output Arguments:
600c1bc742181ded4930842b46e9507372f0b1b963James Dong *
610c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pDstMV - pointer to estimated MV
620c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pDstSAD - pointer to minimum SAD
630c1bc742181ded4930842b46e9507372f0b1b963James Dong *
640c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value:
650c1bc742181ded4930842b46e9507372f0b1b963James Dong *
660c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_NoErr - no error
670c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_BadArgErr - bad arguments.  Returned if one of the following
680c1bc742181ded4930842b46e9507372f0b1b963James Dong *              conditions is true:
690c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    at least one of the following pointers is NULL: pSrcRefBuf,
700c1bc742181ded4930842b46e9507372f0b1b963James Dong *              pRefRect, pSrcCurrBuff, pCurrPointPos, pDstMV, pDstSAD or
710c1bc742181ded4930842b46e9507372f0b1b963James Dong *              pMESpec, or
720c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    pSrcCurrBuf is not 8-byte aligned
730c1bc742181ded4930842b46e9507372f0b1b963James Dong *
740c1bc742181ded4930842b46e9507372f0b1b963James Dong */
750c1bc742181ded4930842b46e9507372f0b1b963James Dong
760c1bc742181ded4930842b46e9507372f0b1b963James DongOMXResult omxVCM4P2_BlockMatch_Integer_8x8(
770c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMX_U8 *pSrcRefBuf,
780c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_INT refWidth,
790c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMXRect *pRefRect,
800c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMX_U8 *pSrcCurrBuf,
810c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMXVCM4P2Coordinate *pCurrPointPos,
820c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMXVCMotionVector *pSrcPreMV,
830c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMX_INT *pSrcPreSAD,
840c1bc742181ded4930842b46e9507372f0b1b963James Dong     void *pMESpec,
850c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMXVCMotionVector *pDstMV,
860c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_INT *pDstSAD
870c1bc742181ded4930842b46e9507372f0b1b963James Dong)
880c1bc742181ded4930842b46e9507372f0b1b963James Dong{
890c1bc742181ded4930842b46e9507372f0b1b963James Dong   OMX_U8 BlockSize = 8;
900c1bc742181ded4930842b46e9507372f0b1b963James Dong
910c1bc742181ded4930842b46e9507372f0b1b963James Dong   /* Argument error checks */
920c1bc742181ded4930842b46e9507372f0b1b963James Dong   armRetArgErrIf(!armIs8ByteAligned(pSrcCurrBuf), OMX_Sts_BadArgErr);
930c1bc742181ded4930842b46e9507372f0b1b963James Dong
940c1bc742181ded4930842b46e9507372f0b1b963James Dong   return ( armVCM4P2_BlockMatch_Integer(
950c1bc742181ded4930842b46e9507372f0b1b963James Dong     pSrcRefBuf,
960c1bc742181ded4930842b46e9507372f0b1b963James Dong     refWidth,
970c1bc742181ded4930842b46e9507372f0b1b963James Dong     pRefRect,
980c1bc742181ded4930842b46e9507372f0b1b963James Dong     pSrcCurrBuf,
990c1bc742181ded4930842b46e9507372f0b1b963James Dong     pCurrPointPos,
1000c1bc742181ded4930842b46e9507372f0b1b963James Dong     pSrcPreMV,
1010c1bc742181ded4930842b46e9507372f0b1b963James Dong     pSrcPreSAD,
1020c1bc742181ded4930842b46e9507372f0b1b963James Dong     pMESpec,
1030c1bc742181ded4930842b46e9507372f0b1b963James Dong     pDstMV,
1040c1bc742181ded4930842b46e9507372f0b1b963James Dong     pDstSAD,
1050c1bc742181ded4930842b46e9507372f0b1b963James Dong     BlockSize)
1060c1bc742181ded4930842b46e9507372f0b1b963James Dong     );
1070c1bc742181ded4930842b46e9507372f0b1b963James Dong
1080c1bc742181ded4930842b46e9507372f0b1b963James Dong}
1090c1bc742181ded4930842b46e9507372f0b1b963James Dong
1100c1bc742181ded4930842b46e9507372f0b1b963James Dong/* End of file */
111