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:  armVCM4P10_SADQuar.c
20 * OpenMAX DL: v1.0.2
21 * Revision:   9641
22 * Date:       Thursday, February 7, 2008
23 *
24 *
25 *
26 * Description:
27 * This function will calculate SAD of pSrc with average of two Ref blocks
28 *
29 */
30
31#include "omxtypes.h"
32#include "armOMX.h"
33
34#include "armVC.h"
35#include "armCOMM.h"
36
37/**
38 * Function: armVCM4P10_SADQuar
39 *
40 * Description:
41 * This function calculates the SAD between one block (pSrc) and the
42 * average of the other two (pSrcRef0 and pSrcRef1)
43 *
44 * Remarks:
45 *
46 * [in]		pSrc				Pointer to the original block
47 * [in]		pSrcRef0		Pointer to reference block 0
48 * [in]		pSrcRef1		Pointer to reference block 1
49 * [in]		iSrcStep 		Step of the original block buffer
50 * [in]		iRefStep0		Step of reference block 0
51 * [in]		iRefStep1 	Step of reference block 1
52 * [in]		iHeight			Height of the block
53 * [in]		iWidth			Width of the block
54 * [out]	pDstSAD			Pointer of result SAD
55 *
56 * Return Value:
57 * Standard OMXResult value.
58 *
59 */
60OMXResult armVCM4P10_SADQuar(
61	const OMX_U8* 	pSrc,
62    const OMX_U8* 	pSrcRef0,
63	const OMX_U8* 	pSrcRef1,
64    OMX_U32 	iSrcStep,
65    OMX_U32		iRefStep0,
66    OMX_U32		iRefStep1,
67    OMX_U32*	pDstSAD,
68    OMX_U32     iHeight,
69    OMX_U32     iWidth
70)
71{
72    OMX_INT     x, y;
73    OMX_S32     SAD = 0;
74
75    /* check for argument error */
76    armRetArgErrIf(pSrc == NULL, OMX_Sts_BadArgErr)
77    armRetArgErrIf(pSrcRef0 == NULL, OMX_Sts_BadArgErr)
78    armRetArgErrIf(pSrcRef1 == NULL, OMX_Sts_BadArgErr)
79    armRetArgErrIf(pDstSAD == NULL, OMX_Sts_BadArgErr)
80
81    for (y = 0; y < iHeight; y++)
82    {
83        for (x = 0; x < iWidth; x++)
84        {
85            SAD += armAbs(pSrc [y * iSrcStep + x] - ((
86                    pSrcRef0 [y * iRefStep0 + x] +
87                    pSrcRef1 [y * iRefStep1 + x] + 1) >> 1));
88        }
89    }
90
91    *pDstSAD = SAD;
92
93    return OMX_Sts_NoErr;
94}
95
96/*****************************************************************************
97 *                              END OF FILE
98 *****************************************************************************/
99
100