1bebc99d6fa433c04139294a5057f8439d772dbd9James Dong/**
2bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
3bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * File Name:  omxVCM4P10_Average_4x.c
4bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * OpenMAX DL: v1.0.2
5bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Revision:   9641
6bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Date:       Thursday, February 7, 2008
7bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
8bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
9bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
10bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
11bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Description:
12bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * This function will calculate Average of two 4x4 or 4x8 blocks
13bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
14bebc99d6fa433c04139294a5057f8439d772dbd9James Dong */
15bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
16bebc99d6fa433c04139294a5057f8439d772dbd9James Dong#include "omxtypes.h"
17bebc99d6fa433c04139294a5057f8439d772dbd9James Dong#include "armOMX.h"
18bebc99d6fa433c04139294a5057f8439d772dbd9James Dong#include "omxVC.h"
19bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
20bebc99d6fa433c04139294a5057f8439d772dbd9James Dong#include "armCOMM.h"
21bebc99d6fa433c04139294a5057f8439d772dbd9James Dong#include "armVC.h"
22bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
23bebc99d6fa433c04139294a5057f8439d772dbd9James Dong/**
24bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Function:  omxVCM4P10_Average_4x   (6.3.5.5.3)
25bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
26bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Description:
27bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * This function calculates the average of two 4x4, 4x8 blocks.  The result
28bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * is rounded according to (a+b+1)/2.
29bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
30bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Input Arguments:
31bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
32bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *   pPred0 - Pointer to the top-left corner of reference block 0
33bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *   pPred1 - Pointer to the top-left corner of reference block 1
34bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *   iPredStep0 - Step of reference block 0; must be a multiple of 4.
35bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *   iPredStep1 - Step of reference block 1; must be a multiple of 4.
36bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *   iDstStep - Step of the destination buffer; must be a multiple of 4.
37bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *   iHeight - Height of the blocks; must be either 4 or 8.
38bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
39bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Output Arguments:
40bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
41bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *   pDstPred - Pointer to the destination buffer. 4-byte alignment required.
42bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
43bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Return Value:
44bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
45bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *    OMX_Sts_NoErr - no error
46bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *    OMX_Sts_BadArgErr - bad arguments; returned if any of the following
47bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *              conditions are true:
48bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *    -    at least one of the following pointers is NULL:
49bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *           pPred0, pPred1, or pDstPred
50bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *    -    pDstPred is not aligned on a 4-byte boundary
51bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *    -    iPredStep0 <= 0 or iPredStep0 is not a multiple of 4
52bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *    -    iPredStep1 <= 0 or iPredStep1 is not a multiple of 4
53bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *    -    iDstStep <= 0 or iDstStep is not a multiple of 4
54bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *    -    iHeight is not equal to either 4 or 8
55bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *
56bebc99d6fa433c04139294a5057f8439d772dbd9James Dong */
57bebc99d6fa433c04139294a5057f8439d772dbd9James Dong OMXResult omxVCM4P10_Average_4x (
58bebc99d6fa433c04139294a5057f8439d772dbd9James Dong	 const OMX_U8* 	    pPred0,
59bebc99d6fa433c04139294a5057f8439d772dbd9James Dong	 const OMX_U8* 	    pPred1,
60bebc99d6fa433c04139294a5057f8439d772dbd9James Dong	 OMX_U32		iPredStep0,
61bebc99d6fa433c04139294a5057f8439d772dbd9James Dong	 OMX_U32		iPredStep1,
62bebc99d6fa433c04139294a5057f8439d772dbd9James Dong	 OMX_U8*		pDstPred,
63bebc99d6fa433c04139294a5057f8439d772dbd9James Dong	 OMX_U32		iDstStep,
64bebc99d6fa433c04139294a5057f8439d772dbd9James Dong	 OMX_U32		iHeight
65bebc99d6fa433c04139294a5057f8439d772dbd9James Dong)
66bebc99d6fa433c04139294a5057f8439d772dbd9James Dong{
67bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    /* check for argument error */
68bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf(pPred0 == NULL, OMX_Sts_BadArgErr)
69bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf(pPred1 == NULL, OMX_Sts_BadArgErr)
70bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf(pDstPred == NULL, OMX_Sts_BadArgErr)
71bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf((iHeight != 4) && (iHeight != 8), OMX_Sts_BadArgErr)
72bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf((iPredStep0 == 0) || (iPredStep0 & 3), OMX_Sts_BadArgErr)
73bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf((iPredStep1 == 0) || (iPredStep1 & 3), OMX_Sts_BadArgErr)
74bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf((iDstStep == 0) || (iDstStep & 3), OMX_Sts_BadArgErr)
75bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    armRetArgErrIf(armNot4ByteAligned(pDstPred), OMX_Sts_BadArgErr)
76bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
77bebc99d6fa433c04139294a5057f8439d772dbd9James Dong    return armVCCOMM_Average
78bebc99d6fa433c04139294a5057f8439d772dbd9James Dong        (pPred0, pPred1, iPredStep0, iPredStep1, pDstPred, iDstStep, 4, iHeight);
79bebc99d6fa433c04139294a5057f8439d772dbd9James Dong}
80bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
81bebc99d6fa433c04139294a5057f8439d772dbd9James Dong/*****************************************************************************
82bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *                              END OF FILE
83bebc99d6fa433c04139294a5057f8439d772dbd9James Dong *****************************************************************************/
84bebc99d6fa433c04139294a5057f8439d772dbd9James Dong
85