10c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
20c1bc742181ded4930842b46e9507372f0b1b963James Dong *
30c1bc742181ded4930842b46e9507372f0b1b963James Dong * File Name:  omxVCM4P10_Average_4x.c
40c1bc742181ded4930842b46e9507372f0b1b963James Dong * OpenMAX DL: v1.0.2
50c1bc742181ded4930842b46e9507372f0b1b963James Dong * Revision:   9641
60c1bc742181ded4930842b46e9507372f0b1b963James Dong * Date:       Thursday, February 7, 2008
70c1bc742181ded4930842b46e9507372f0b1b963James Dong *
80c1bc742181ded4930842b46e9507372f0b1b963James Dong * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
90c1bc742181ded4930842b46e9507372f0b1b963James Dong *
100c1bc742181ded4930842b46e9507372f0b1b963James Dong *
110c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
120c1bc742181ded4930842b46e9507372f0b1b963James Dong * This function will calculate Average of two 4x4 or 4x8 blocks
130c1bc742181ded4930842b46e9507372f0b1b963James Dong *
140c1bc742181ded4930842b46e9507372f0b1b963James Dong */
150c1bc742181ded4930842b46e9507372f0b1b963James Dong
160c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxtypes.h"
170c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armOMX.h"
180c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxVC.h"
190c1bc742181ded4930842b46e9507372f0b1b963James Dong
200c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armCOMM.h"
210c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armVC.h"
220c1bc742181ded4930842b46e9507372f0b1b963James Dong
230c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
240c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function:  omxVCM4P10_Average_4x   (6.3.5.5.3)
250c1bc742181ded4930842b46e9507372f0b1b963James Dong *
260c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
270c1bc742181ded4930842b46e9507372f0b1b963James Dong * This function calculates the average of two 4x4, 4x8 blocks.  The result
280c1bc742181ded4930842b46e9507372f0b1b963James Dong * is rounded according to (a+b+1)/2.
290c1bc742181ded4930842b46e9507372f0b1b963James Dong *
300c1bc742181ded4930842b46e9507372f0b1b963James Dong * Input Arguments:
310c1bc742181ded4930842b46e9507372f0b1b963James Dong *
320c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pPred0 - Pointer to the top-left corner of reference block 0
330c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pPred1 - Pointer to the top-left corner of reference block 1
340c1bc742181ded4930842b46e9507372f0b1b963James Dong *   iPredStep0 - Step of reference block 0; must be a multiple of 4.
350c1bc742181ded4930842b46e9507372f0b1b963James Dong *   iPredStep1 - Step of reference block 1; must be a multiple of 4.
360c1bc742181ded4930842b46e9507372f0b1b963James Dong *   iDstStep - Step of the destination buffer; must be a multiple of 4.
370c1bc742181ded4930842b46e9507372f0b1b963James Dong *   iHeight - Height of the blocks; must be either 4 or 8.
380c1bc742181ded4930842b46e9507372f0b1b963James Dong *
390c1bc742181ded4930842b46e9507372f0b1b963James Dong * Output Arguments:
400c1bc742181ded4930842b46e9507372f0b1b963James Dong *
410c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pDstPred - Pointer to the destination buffer. 4-byte alignment required.
420c1bc742181ded4930842b46e9507372f0b1b963James Dong *
430c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value:
440c1bc742181ded4930842b46e9507372f0b1b963James Dong *
450c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_NoErr - no error
460c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_BadArgErr - bad arguments; returned if any of the following
470c1bc742181ded4930842b46e9507372f0b1b963James Dong *              conditions are true:
480c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    at least one of the following pointers is NULL:
490c1bc742181ded4930842b46e9507372f0b1b963James Dong *           pPred0, pPred1, or pDstPred
500c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    pDstPred is not aligned on a 4-byte boundary
510c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    iPredStep0 <= 0 or iPredStep0 is not a multiple of 4
520c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    iPredStep1 <= 0 or iPredStep1 is not a multiple of 4
530c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    iDstStep <= 0 or iDstStep is not a multiple of 4
540c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    iHeight is not equal to either 4 or 8
550c1bc742181ded4930842b46e9507372f0b1b963James Dong *
560c1bc742181ded4930842b46e9507372f0b1b963James Dong */
570c1bc742181ded4930842b46e9507372f0b1b963James Dong OMXResult omxVCM4P10_Average_4x (
580c1bc742181ded4930842b46e9507372f0b1b963James Dong	 const OMX_U8* 	    pPred0,
590c1bc742181ded4930842b46e9507372f0b1b963James Dong	 const OMX_U8* 	    pPred1,
600c1bc742181ded4930842b46e9507372f0b1b963James Dong	 OMX_U32		iPredStep0,
610c1bc742181ded4930842b46e9507372f0b1b963James Dong	 OMX_U32		iPredStep1,
620c1bc742181ded4930842b46e9507372f0b1b963James Dong	 OMX_U8*		pDstPred,
630c1bc742181ded4930842b46e9507372f0b1b963James Dong	 OMX_U32		iDstStep,
640c1bc742181ded4930842b46e9507372f0b1b963James Dong	 OMX_U32		iHeight
650c1bc742181ded4930842b46e9507372f0b1b963James Dong)
660c1bc742181ded4930842b46e9507372f0b1b963James Dong{
670c1bc742181ded4930842b46e9507372f0b1b963James Dong    /* check for argument error */
680c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pPred0 == NULL, OMX_Sts_BadArgErr)
690c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pPred1 == NULL, OMX_Sts_BadArgErr)
700c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pDstPred == NULL, OMX_Sts_BadArgErr)
710c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf((iHeight != 4) && (iHeight != 8), OMX_Sts_BadArgErr)
720c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf((iPredStep0 == 0) || (iPredStep0 & 3), OMX_Sts_BadArgErr)
730c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf((iPredStep1 == 0) || (iPredStep1 & 3), OMX_Sts_BadArgErr)
740c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf((iDstStep == 0) || (iDstStep & 3), OMX_Sts_BadArgErr)
750c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(armNot4ByteAligned(pDstPred), OMX_Sts_BadArgErr)
760c1bc742181ded4930842b46e9507372f0b1b963James Dong
770c1bc742181ded4930842b46e9507372f0b1b963James Dong    return armVCCOMM_Average
780c1bc742181ded4930842b46e9507372f0b1b963James Dong        (pPred0, pPred1, iPredStep0, iPredStep1, pDstPred, iDstStep, 4, iHeight);
790c1bc742181ded4930842b46e9507372f0b1b963James Dong}
800c1bc742181ded4930842b46e9507372f0b1b963James Dong
810c1bc742181ded4930842b46e9507372f0b1b963James Dong/*****************************************************************************
820c1bc742181ded4930842b46e9507372f0b1b963James Dong *                              END OF FILE
830c1bc742181ded4930842b46e9507372f0b1b963James Dong *****************************************************************************/
840c1bc742181ded4930842b46e9507372f0b1b963James Dong
85