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