omxVCM4P10_Average_4x.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:  omxVCM4P10_Average_4x.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 4x4 or 4x8 blocks
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:  omxVCM4P10_Average_4x   (6.3.5.5.3)
40 *
41 * Description:
42 * This function calculates the average of two 4x4, 4x8 blocks.  The result
43 * is rounded according to (a+b+1)/2.
44 *
45 * Input Arguments:
46 *
47 *   pPred0 - Pointer to the top-left corner of reference block 0
48 *   pPred1 - Pointer to the top-left corner of reference block 1
49 *   iPredStep0 - Step of reference block 0; must be a multiple of 4.
50 *   iPredStep1 - Step of reference block 1; must be a multiple of 4.
51 *   iDstStep - Step of the destination buffer; must be a multiple of 4.
52 *   iHeight - Height of the blocks; must be either 4 or 8.
53 *
54 * Output Arguments:
55 *
56 *   pDstPred - Pointer to the destination buffer. 4-byte alignment required.
57 *
58 * Return Value:
59 *
60 *    OMX_Sts_NoErr - no error
61 *    OMX_Sts_BadArgErr - bad arguments; returned if any of the following
62 *              conditions are true:
63 *    -    at least one of the following pointers is NULL:
64 *           pPred0, pPred1, or pDstPred
65 *    -    pDstPred is not aligned on a 4-byte boundary
66 *    -    iPredStep0 <= 0 or iPredStep0 is not a multiple of 4
67 *    -    iPredStep1 <= 0 or iPredStep1 is not a multiple of 4
68 *    -    iDstStep <= 0 or iDstStep is not a multiple of 4
69 *    -    iHeight is not equal to either 4 or 8
70 *
71 */
72 OMXResult omxVCM4P10_Average_4x (
73	 const OMX_U8* 	    pPred0,
74	 const OMX_U8* 	    pPred1,
75	 OMX_U32		iPredStep0,
76	 OMX_U32		iPredStep1,
77	 OMX_U8*		pDstPred,
78	 OMX_U32		iDstStep,
79	 OMX_U32		iHeight
80)
81{
82    /* check for argument error */
83    armRetArgErrIf(pPred0 == NULL, OMX_Sts_BadArgErr)
84    armRetArgErrIf(pPred1 == NULL, OMX_Sts_BadArgErr)
85    armRetArgErrIf(pDstPred == NULL, OMX_Sts_BadArgErr)
86    armRetArgErrIf((iHeight != 4) && (iHeight != 8), OMX_Sts_BadArgErr)
87    armRetArgErrIf((iPredStep0 == 0) || (iPredStep0 & 3), OMX_Sts_BadArgErr)
88    armRetArgErrIf((iPredStep1 == 0) || (iPredStep1 & 3), OMX_Sts_BadArgErr)
89    armRetArgErrIf((iDstStep == 0) || (iDstStep & 3), OMX_Sts_BadArgErr)
90    armRetArgErrIf(armNot4ByteAligned(pDstPred), OMX_Sts_BadArgErr)
91
92    return armVCCOMM_Average
93        (pPred0, pPred1, iPredStep0, iPredStep1, pDstPred, iDstStep, 4, iHeight);
94}
95
96/*****************************************************************************
97 *                              END OF FILE
98 *****************************************************************************/
99
100