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:  armVCCOMM_Average.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 Average of two blocks if size iWidth X iHeight
28 *
29 */
30
31#include "omxtypes.h"
32#include "armOMX.h"
33#include "omxVC.h"
34
35#include "armCOMM.h"
36#include "armVC.h"
37
38/**
39 * Function: armVCCOMM_Average
40 *
41 * Description:
42 * This function calculates the average of two blocks and stores the result.
43 *
44 * Remarks:
45 *
46 *	[in]	pPred0			Pointer to the top-left corner of reference block 0
47 *	[in]	pPred1			Pointer to the top-left corner of reference block 1
48 *	[in]	iPredStep0	    Step of reference block 0
49 *	[in]	iPredStep1	    Step of reference block 1
50 *	[in]	iDstStep 		Step of the destination buffer
51 *	[in]	iWidth			Width of the blocks
52 *	[in]	iHeight			Height of the blocks
53 *	[out]	pDstPred		Pointer to the destination buffer
54 *
55 * Return Value:
56 * Standard OMXResult value.
57 *
58 */
59 OMXResult armVCCOMM_Average (
60	 const OMX_U8* 	    pPred0,
61	 const OMX_U8* 	    pPred1,
62	 OMX_U32		iPredStep0,
63	 OMX_U32		iPredStep1,
64	 OMX_U8*		pDstPred,
65	 OMX_U32		iDstStep,
66	 OMX_U32		iWidth,
67	 OMX_U32		iHeight
68)
69{
70    OMX_U32     x, y;
71
72    /* check for argument error */
73    armRetArgErrIf(pPred0 == NULL, OMX_Sts_BadArgErr)
74    armRetArgErrIf(pPred1 == NULL, OMX_Sts_BadArgErr)
75    armRetArgErrIf(pDstPred == NULL, OMX_Sts_BadArgErr)
76
77    for (y = 0; y < iHeight; y++)
78    {
79        for (x = 0; x < iWidth; x++)
80        {
81            pDstPred [y * iDstStep + x] =
82                (OMX_U8)(((OMX_U32)pPred0 [y * iPredStep0 + x] +
83                                  pPred1 [y * iPredStep1 + x] + 1) >> 1);
84        }
85    }
86
87    return OMX_Sts_NoErr;
88}
89
90/*****************************************************************************
91 *                              END OF FILE
92 *****************************************************************************/
93
94