10c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
20c1bc742181ded4930842b46e9507372f0b1b963James Dong *
30c1bc742181ded4930842b46e9507372f0b1b963James Dong * File Name:  omxVCM4P10_SADQuar_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 SAD of pSrc with average of two Ref blocks
130c1bc742181ded4930842b46e9507372f0b1b963James Dong * of 8x16 or 8x8 or 8x4
140c1bc742181ded4930842b46e9507372f0b1b963James Dong *
150c1bc742181ded4930842b46e9507372f0b1b963James Dong */
160c1bc742181ded4930842b46e9507372f0b1b963James Dong
170c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxtypes.h"
180c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armOMX.h"
190c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxVC.h"
200c1bc742181ded4930842b46e9507372f0b1b963James Dong
210c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armVC.h"
220c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armCOMM.h"
230c1bc742181ded4930842b46e9507372f0b1b963James Dong
240c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
250c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function:  omxVCM4P10_SADQuar_8x   (6.3.5.4.3)
260c1bc742181ded4930842b46e9507372f0b1b963James Dong *
270c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
280c1bc742181ded4930842b46e9507372f0b1b963James Dong * This function calculates the SAD between one block (pSrc) and the average
290c1bc742181ded4930842b46e9507372f0b1b963James Dong * of the other two (pSrcRef0 and pSrcRef1) for 8x16, 8x8, or 8x4 blocks.
300c1bc742181ded4930842b46e9507372f0b1b963James Dong * Rounding is applied according to the convention (a+b+1)>>1.
310c1bc742181ded4930842b46e9507372f0b1b963James Dong *
320c1bc742181ded4930842b46e9507372f0b1b963James Dong * Input Arguments:
330c1bc742181ded4930842b46e9507372f0b1b963James Dong *
340c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pSrc - Pointer to the original block; must be aligned on an 8-byte
350c1bc742181ded4930842b46e9507372f0b1b963James Dong *            boundary.
360c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pSrcRef0 - Pointer to reference block 0
370c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pSrcRef1 - Pointer to reference block 1
380c1bc742181ded4930842b46e9507372f0b1b963James Dong *   iSrcStep - Step of the original block buffer; must be a multiple of 8.
390c1bc742181ded4930842b46e9507372f0b1b963James Dong *   iRefStep0 - Step of reference block 0
400c1bc742181ded4930842b46e9507372f0b1b963James Dong *   iRefStep1 - Step of reference block 1
410c1bc742181ded4930842b46e9507372f0b1b963James Dong *   iHeight - Height of the block; must be equal either 4, 8, or 16.
420c1bc742181ded4930842b46e9507372f0b1b963James Dong *
430c1bc742181ded4930842b46e9507372f0b1b963James Dong * Output Arguments:
440c1bc742181ded4930842b46e9507372f0b1b963James Dong *
450c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pDstSAD - Pointer of result SAD
460c1bc742181ded4930842b46e9507372f0b1b963James Dong *
470c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value:
480c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_NoErr, if the function runs without error.
490c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_BadArgErr - bad arguments: if one of the following cases occurs:
500c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    iHeight is not equal to either 4, 8, or 16.
510c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    One of more of the following pointers is NULL: pSrc, pSrcRef0,
520c1bc742181ded4930842b46e9507372f0b1b963James Dong *              pSrcRef1, pDstSAD.
530c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    iSrcStep is not a multiple of 8
540c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    Any alignment restrictions are violated
550c1bc742181ded4930842b46e9507372f0b1b963James Dong *
560c1bc742181ded4930842b46e9507372f0b1b963James Dong */
570c1bc742181ded4930842b46e9507372f0b1b963James DongOMXResult omxVCM4P10_SADQuar_8x(
580c1bc742181ded4930842b46e9507372f0b1b963James Dong	const OMX_U8* 	pSrc,
590c1bc742181ded4930842b46e9507372f0b1b963James Dong    const OMX_U8* 	pSrcRef0,
600c1bc742181ded4930842b46e9507372f0b1b963James Dong	const OMX_U8* 	pSrcRef1,
610c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_U32 	iSrcStep,
620c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_U32		iRefStep0,
630c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_U32		iRefStep1,
640c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_U32*	pDstSAD,
650c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_U32     iHeight
660c1bc742181ded4930842b46e9507372f0b1b963James Dong)
670c1bc742181ded4930842b46e9507372f0b1b963James Dong{
680c1bc742181ded4930842b46e9507372f0b1b963James Dong    /* check for argument error */
690c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pSrc == NULL, OMX_Sts_BadArgErr)
700c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pSrcRef0 == NULL, OMX_Sts_BadArgErr)
710c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pSrcRef1 == NULL, OMX_Sts_BadArgErr)
720c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pDstSAD == NULL, OMX_Sts_BadArgErr)
730c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf((iHeight != 16) && (iHeight != 8) &&
740c1bc742181ded4930842b46e9507372f0b1b963James Dong        (iHeight != 4), OMX_Sts_BadArgErr)
750c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(armNot8ByteAligned(pSrc), OMX_Sts_BadArgErr)
760c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf((iSrcStep == 0) || (iSrcStep & 7), OMX_Sts_BadArgErr)
770c1bc742181ded4930842b46e9507372f0b1b963James Dong
780c1bc742181ded4930842b46e9507372f0b1b963James Dong
790c1bc742181ded4930842b46e9507372f0b1b963James Dong    return armVCM4P10_SADQuar
800c1bc742181ded4930842b46e9507372f0b1b963James Dong        (pSrc, pSrcRef0, pSrcRef1, iSrcStep,
810c1bc742181ded4930842b46e9507372f0b1b963James Dong        iRefStep0, iRefStep1, pDstSAD, iHeight, 8);
820c1bc742181ded4930842b46e9507372f0b1b963James Dong}
830c1bc742181ded4930842b46e9507372f0b1b963James Dong
840c1bc742181ded4930842b46e9507372f0b1b963James Dong/*****************************************************************************
850c1bc742181ded4930842b46e9507372f0b1b963James Dong *                              END OF FILE
860c1bc742181ded4930842b46e9507372f0b1b963James Dong *****************************************************************************/
870c1bc742181ded4930842b46e9507372f0b1b963James Dong
88