omxVCM4P2_BlockMatch_Half_16x16.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_16x16.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 * Function:  omxVCM4P2_BlockMatch_Half_16x16   (6.2.4.2.3)
42 *
43 * Description:
44 * Performs a 16x16 block match with half-pixel resolution.  Returns the
45 * estimated motion vector and associated minimum SAD.  This function
46 * estimates the half-pixel motion vector by interpolating the integer
47 * resolution motion vector referenced by the input parameter pSrcDstMV, i.e.,
48 * the initial integer MV is generated externally.  The input parameters
49 * pSrcRefBuf and pSearchPointRefPos should be shifted by the winning MV of
50 * 16x16 integer search prior to calling BlockMatch_Half_16x16. The function
51 * BlockMatch_Integer_16x16 may be used for integer motion estimation.
52 *
53 * Input Arguments:
54 *
55 *   pSrcRefBuf - pointer to the reference Y plane; points to the reference
56 *            macroblock that corresponds to the location of the current
57 *            macroblock in the current plane.
58 *   refWidth - width of the reference plane
59 *   pRefRect - reference plane valid region rectangle
60 *   pSrcCurrBuf - pointer to the current block in the current macroblock
61 *            buffer extracted from the original plane (linear array, 256
62 *            entries); must be aligned on a 16-byte boundary.  The number of
63 *            bytes between lines (step) is 16.
64 *   pSearchPointRefPos - position of the starting point for half pixel
65 *            search (specified in terms of integer pixel units) in the
66 *            reference plane, i.e., the reference position pointed to by the
67 *            predicted motion vector.
68 *   rndVal - rounding control parameter: 0 - disabled; 1 - enabled.
69 *   pSrcDstMV - pointer to the initial MV estimate; typically generated
70 *            during a prior 16X16 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: pSrcRefBuf,
84 *         pRefRect, pSrcCurrBuff, pSearchPointRefPos, pSrcDstMV.
85 *    -    pSrcCurrBuf is not 16-byte aligned, or
86 *
87 */
88
89OMXResult omxVCM4P2_BlockMatch_Half_16x16(
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
101    /* For a blocksize of 16x16 */
102    OMX_U8 BlockSize = 16;
103
104    /* Argument error checks */
105    armRetArgErrIf(pSrcRefBuf         == NULL, OMX_Sts_BadArgErr);
106    armRetArgErrIf(pRefRect           == NULL, OMX_Sts_BadArgErr);
107    armRetArgErrIf(pSrcCurrBuf        == NULL, OMX_Sts_BadArgErr);
108    armRetArgErrIf(pSearchPointRefPos == NULL, OMX_Sts_BadArgErr);
109    armRetArgErrIf(pSrcDstMV          == NULL, OMX_Sts_BadArgErr);
110    armRetArgErrIf(!armIs16ByteAligned(pSrcCurrBuf), OMX_Sts_BadArgErr);
111
112    return (armVCM4P2_BlockMatch_Half(
113                                pSrcRefBuf,
114                                refWidth,
115                                pRefRect,
116                                pSrcCurrBuf,
117                                pSearchPointRefPos,
118                                rndVal,
119                                pSrcDstMV,
120                                pDstSAD,
121                                BlockSize));
122
123
124}
125
126/* End of file */
127