10c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
20c1bc742181ded4930842b46e9507372f0b1b963James Dong *
30c1bc742181ded4930842b46e9507372f0b1b963James Dong * File Name:  omxVCCOMM_Average_8x.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 8x4 or 8x8 or 8x16 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:  omxVCCOMM_Average_8x   (6.1.3.1.1)
250c1bc742181ded4930842b46e9507372f0b1b963James Dong *
260c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
270c1bc742181ded4930842b46e9507372f0b1b963James Dong * This function calculates the average of two 8x4, 8x8, or 8x16 blocks.  The
280c1bc742181ded4930842b46e9507372f0b1b963James Dong * result is rounded according to (a+b+1)/2.  The block average function can
290c1bc742181ded4930842b46e9507372f0b1b963James Dong * be used in conjunction with half-pixel interpolation to obtain quarter
300c1bc742181ded4930842b46e9507372f0b1b963James Dong * pixel motion estimates, as described in [ISO14496-10], subclause 8.4.2.2.1.
310c1bc742181ded4930842b46e9507372f0b1b963James Dong *
320c1bc742181ded4930842b46e9507372f0b1b963James Dong * Input Arguments:
330c1bc742181ded4930842b46e9507372f0b1b963James Dong *
340c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pPred0     - Pointer to the top-left corner of reference block 0
350c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pPred1     - Pointer to the top-left corner of reference block 1
360c1bc742181ded4930842b46e9507372f0b1b963James Dong *   iPredStep0 - Step of reference block 0
370c1bc742181ded4930842b46e9507372f0b1b963James Dong *   iPredStep1 - Step of reference block 1
380c1bc742181ded4930842b46e9507372f0b1b963James Dong *   iDstStep   - Step of the destination buffer.
390c1bc742181ded4930842b46e9507372f0b1b963James Dong *   iHeight    - Height of the blocks
400c1bc742181ded4930842b46e9507372f0b1b963James Dong *
410c1bc742181ded4930842b46e9507372f0b1b963James Dong * Output Arguments:
420c1bc742181ded4930842b46e9507372f0b1b963James Dong *
430c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pDstPred - Pointer to the destination buffer. 8-byte aligned.
440c1bc742181ded4930842b46e9507372f0b1b963James Dong *
450c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value:
460c1bc742181ded4930842b46e9507372f0b1b963James Dong *
470c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_NoErr - no error
480c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_BadArgErr - bad arguments; returned under any of the following
490c1bc742181ded4930842b46e9507372f0b1b963James Dong *              conditions:
500c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -   one or more of the following pointers is NULL: pPred0, pPred1, or
510c1bc742181ded4930842b46e9507372f0b1b963James Dong *              pDstPred.
520c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -   pDstPred is not aligned on an 8-byte boundary.
530c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -   iPredStep0 <= 0 or iPredStep0 is not a multiple of 8.
540c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -   iPredStep1 <= 0 or iPredStep1 is not a multiple of 8.
550c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -   iDstStep   <= 0 or iDstStep is not a multiple of 8.
560c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -   iHeight is not 4, 8, or 16.
570c1bc742181ded4930842b46e9507372f0b1b963James Dong *
580c1bc742181ded4930842b46e9507372f0b1b963James Dong */
590c1bc742181ded4930842b46e9507372f0b1b963James Dong OMXResult omxVCCOMM_Average_8x (
600c1bc742181ded4930842b46e9507372f0b1b963James Dong	 const OMX_U8* 	    pPred0,
610c1bc742181ded4930842b46e9507372f0b1b963James Dong	 const OMX_U8* 	    pPred1,
620c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_U32		iPredStep0,
630c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_U32		iPredStep1,
640c1bc742181ded4930842b46e9507372f0b1b963James Dong	 OMX_U8*		pDstPred,
650c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_U32		iDstStep,
660c1bc742181ded4930842b46e9507372f0b1b963James Dong	 OMX_U32		iHeight
670c1bc742181ded4930842b46e9507372f0b1b963James Dong)
680c1bc742181ded4930842b46e9507372f0b1b963James Dong{
690c1bc742181ded4930842b46e9507372f0b1b963James Dong    /* check for argument error */
700c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pPred0 == NULL, OMX_Sts_BadArgErr)
710c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pPred1 == NULL, OMX_Sts_BadArgErr)
720c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pDstPred == NULL, OMX_Sts_BadArgErr)
730c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf((iPredStep0 == 0) || (iPredStep0 & 7), OMX_Sts_BadArgErr)
740c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf((iPredStep1 == 0) || (iPredStep1 & 7), OMX_Sts_BadArgErr)
750c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf((iDstStep == 0) || (iDstStep & 7), OMX_Sts_BadArgErr)
760c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf((iHeight != 4) && (iHeight != 8) && (iHeight != 16), OMX_Sts_BadArgErr)
770c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(armNot8ByteAligned(pDstPred), OMX_Sts_BadArgErr)
780c1bc742181ded4930842b46e9507372f0b1b963James Dong
790c1bc742181ded4930842b46e9507372f0b1b963James Dong    return armVCCOMM_Average
800c1bc742181ded4930842b46e9507372f0b1b963James Dong        (pPred0, pPred1, iPredStep0, iPredStep1, pDstPred, iDstStep, 8, iHeight);
810c1bc742181ded4930842b46e9507372f0b1b963James Dong}
820c1bc742181ded4930842b46e9507372f0b1b963James Dong
830c1bc742181ded4930842b46e9507372f0b1b963James Dong
840c1bc742181ded4930842b46e9507372f0b1b963James Dong/*****************************************************************************
850c1bc742181ded4930842b46e9507372f0b1b963James Dong *                              END OF FILE
860c1bc742181ded4930842b46e9507372f0b1b963James Dong *****************************************************************************/
870c1bc742181ded4930842b46e9507372f0b1b963James Dong
88