omxVCCOMM_Average_8x.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:  omxVCCOMM_Average_8x.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 8x4 or 8x8 or 8x16 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:  omxVCCOMM_Average_8x   (6.1.3.1.1)
40 *
41 * Description:
42 * This function calculates the average of two 8x4, 8x8, or 8x16 blocks.  The
43 * result is rounded according to (a+b+1)/2.  The block average function can
44 * be used in conjunction with half-pixel interpolation to obtain quarter
45 * pixel motion estimates, as described in [ISO14496-10], subclause 8.4.2.2.1.
46 *
47 * Input Arguments:
48 *
49 *   pPred0     - Pointer to the top-left corner of reference block 0
50 *   pPred1     - Pointer to the top-left corner of reference block 1
51 *   iPredStep0 - Step of reference block 0
52 *   iPredStep1 - Step of reference block 1
53 *   iDstStep   - Step of the destination buffer.
54 *   iHeight    - Height of the blocks
55 *
56 * Output Arguments:
57 *
58 *   pDstPred - Pointer to the destination buffer. 8-byte aligned.
59 *
60 * Return Value:
61 *
62 *    OMX_Sts_NoErr - no error
63 *    OMX_Sts_BadArgErr - bad arguments; returned under any of the following
64 *              conditions:
65 *    -   one or more of the following pointers is NULL: pPred0, pPred1, or
66 *              pDstPred.
67 *    -   pDstPred is not aligned on an 8-byte boundary.
68 *    -   iPredStep0 <= 0 or iPredStep0 is not a multiple of 8.
69 *    -   iPredStep1 <= 0 or iPredStep1 is not a multiple of 8.
70 *    -   iDstStep   <= 0 or iDstStep is not a multiple of 8.
71 *    -   iHeight is not 4, 8, or 16.
72 *
73 */
74 OMXResult omxVCCOMM_Average_8x (
75	 const OMX_U8* 	    pPred0,
76	 const OMX_U8* 	    pPred1,
77     OMX_U32		iPredStep0,
78     OMX_U32		iPredStep1,
79	 OMX_U8*		pDstPred,
80     OMX_U32		iDstStep,
81	 OMX_U32		iHeight
82)
83{
84    /* check for argument error */
85    armRetArgErrIf(pPred0 == NULL, OMX_Sts_BadArgErr)
86    armRetArgErrIf(pPred1 == NULL, OMX_Sts_BadArgErr)
87    armRetArgErrIf(pDstPred == NULL, OMX_Sts_BadArgErr)
88    armRetArgErrIf((iPredStep0 == 0) || (iPredStep0 & 7), OMX_Sts_BadArgErr)
89    armRetArgErrIf((iPredStep1 == 0) || (iPredStep1 & 7), OMX_Sts_BadArgErr)
90    armRetArgErrIf((iDstStep == 0) || (iDstStep & 7), OMX_Sts_BadArgErr)
91    armRetArgErrIf((iHeight != 4) && (iHeight != 8) && (iHeight != 16), OMX_Sts_BadArgErr)
92    armRetArgErrIf(armNot8ByteAligned(pDstPred), OMX_Sts_BadArgErr)
93
94    return armVCCOMM_Average
95        (pPred0, pPred1, iPredStep0, iPredStep1, pDstPred, iDstStep, 8, iHeight);
96}
97
98
99/*****************************************************************************
100 *                              END OF FILE
101 *****************************************************************************/
102
103