armVCM4P2_CompareMV.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:  armVCM4P2_CompareMV.c
20 * OpenMAX DL: v1.0.2
21 * Revision:   9641
22 * Date:       Thursday, February 7, 2008
23 *
24 *
25 *
26 *
27 * Description:
28 * Contains module for comparing motion vectors and SAD's to decide
29 * the best MV and SAD
30 *
31 */
32
33#include "omxtypes.h"
34#include "armOMX.h"
35
36#include "armVC.h"
37#include "armCOMM.h"
38
39/**
40 * Function: armVCM4P2_CompareMV
41 *
42 * Description:
43 * Performs comparision of motion vectors and SAD's to decide the
44 * best MV and SAD
45 *
46 * Remarks:
47 *
48 * Parameters:
49 * [in]	    mvX		x coordinate of the candidate motion vector
50 * [in]	    mvY		y coordinate of the candidate motion vector
51 * [in]	    candSAD	Candidate SAD
52 * [in]	    bestMVX	x coordinate of the best motion vector
53 * [in]	    bestMVY	y coordinate of the best motion vector
54 * [in]	    bestSAD	best SAD
55 *
56 * Return Value:
57 * OMX_INT -- 1 to indicate that the current sad is the best
58 *            0 to indicate that it is NOT the best SAD
59 */
60
61OMX_INT armVCM4P2_CompareMV (
62    OMX_S16 mvX,
63    OMX_S16 mvY,
64    OMX_INT candSAD,
65    OMX_S16 bestMVX,
66    OMX_S16 bestMVY,
67    OMX_INT bestSAD
68)
69{
70    if (candSAD < bestSAD)
71    {
72        return 1;
73    }
74    if (candSAD > bestSAD)
75    {
76        return 0;
77    }
78    /* shorter motion vector */
79    if ( (mvX * mvX + mvY * mvY) < (bestMVX*bestMVX+bestMVY*bestMVY) )
80    {
81         return 1;
82    }
83    return 0;
84}
85
86/*End of File*/
87