omxVCM4P2_BlockMatch_Half_8x8.c revision 0c1bc742181ded4930842b46e9507372f0b1b963
1/**
2 *
3 * File Name:  omxVCM4P2_BlockMatch_Half_8x8.c
4 * OpenMAX DL: v1.0.2
5 * Revision:   9641
6 * Date:       Thursday, February 7, 2008
7 *
8 * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
9 *
10 *
11 *
12 * Description:
13 * Contains modules for Block matching, a full search algorithm
14 * is implemented
15 *
16 */
17
18#include "omxtypes.h"
19#include "armOMX.h"
20#include "omxVC.h"
21
22#include "armVC.h"
23#include "armCOMM.h"
24
25
26/**
27 * Function:  omxVCM4P2_BlockMatch_Half_8x8   (6.2.4.2.4)
28 *
29 * Description:
30 * Performs an 8x8 block match with half-pixel resolution. Returns the
31 * estimated motion vector and associated minimum SAD.  This function
32 * estimates the half-pixel motion vector by interpolating the integer
33 * resolution motion vector referenced by the input parameter pSrcDstMV, i.e.,
34 * the initial integer MV is generated externally.  The input parameters
35 * pSrcRefBuf and pSearchPointRefPos should be shifted by the winning MV of
36 * 8x8 integer search prior to calling BlockMatch_Half_8x8. The function
37 * BlockMatch_Integer_8x8 may be used for integer motion estimation.
38 *
39 * Input Arguments:
40 *
41 *   pSrcRefBuf - pointer to the reference Y plane; points to the reference
42 *            block that corresponds to the location of the current 8x8 block
43 *            in the current plane.
44 *   refWidth - width of the reference plane
45 *   pRefRect - reference plane valid region rectangle
46 *   pSrcCurrBuf - pointer to the current block in the current macroblock
47 *            buffer extracted from the original plane (linear array, 128
48 *            entries); must be aligned on a 8-byte boundary.  The number of
49 *            bytes between lines (step) is 16.
50 *   pSearchPointRefPos - position of the starting point for half pixel
51 *            search (specified in terms of integer pixel units) in the
52 *            reference plane.
53 *   rndVal - rounding control parameter: 0 - disabled; 1 - enabled.
54 *   pSrcDstMV - pointer to the initial MV estimate; typically generated
55 *            during a prior 8x8 integer search, specified in terms of
56 *            half-pixel units.
57 *
58 * Output Arguments:
59 *
60 *   pSrcDstMV - pointer to estimated MV
61 *   pDstSAD - pointer to minimum SAD
62 *
63 * Return Value:
64 *
65 *    OMX_Sts_NoErr - no error
66 *    OMX_Sts_BadArgErr - bad arguments.  Returned if one of the following
67 *              conditions is true:
68 *    -    at least one of the following pointers is NULL:
69 *         pSrcRefBuf, pRefRect, pSrcCurrBuff, pSearchPointRefPos, pSrcDstMV
70 *    -    pSrcCurrBuf is not 8-byte aligned
71 *
72 */
73
74OMXResult omxVCM4P2_BlockMatch_Half_8x8(
75     const OMX_U8 *pSrcRefBuf,
76     OMX_INT refWidth,
77     const OMXRect *pRefRect,
78     const OMX_U8 *pSrcCurrBuf,
79     const OMXVCM4P2Coordinate *pSearchPointRefPos,
80     OMX_INT rndVal,
81     OMXVCMotionVector *pSrcDstMV,
82     OMX_INT *pDstSAD
83)
84{
85    /* For a blocksize of 8x8 */
86    OMX_U8 BlockSize = 8;
87
88    /* Argument error checks */
89    armRetArgErrIf(pSrcRefBuf         == NULL, OMX_Sts_BadArgErr);
90    armRetArgErrIf(pRefRect           == NULL, OMX_Sts_BadArgErr);
91    armRetArgErrIf(pSrcCurrBuf        == NULL, OMX_Sts_BadArgErr);
92    armRetArgErrIf(pSearchPointRefPos == NULL, OMX_Sts_BadArgErr);
93    armRetArgErrIf(pSrcDstMV          == NULL, OMX_Sts_BadArgErr);
94    armRetArgErrIf(!armIs8ByteAligned(pSrcCurrBuf), OMX_Sts_BadArgErr);
95
96    return (armVCM4P2_BlockMatch_Half(
97                                pSrcRefBuf,
98                                refWidth,
99                                pRefRect,
100                                pSrcCurrBuf,
101                                pSearchPointRefPos,
102                                rndVal,
103                                pSrcDstMV,
104                                pDstSAD,
105                                BlockSize));
106
107}
108
109/* End of file */
110