Home | History | Annotate | Download | only in src
      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:  armVCCOMM_SAD.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 SAD for NxM blocks
     28  *
     29  */
     30 
     31 #include "omxtypes.h"
     32 #include "armOMX.h"
     33 #include "omxVC.h"
     34 
     35 #include "armCOMM.h"
     36 
     37 /**
     38  * Function: armVCCOMM_SAD
     39  *
     40  * Description:
     41  * This function calculate the SAD for NxM blocks.
     42  *
     43  * Remarks:
     44  *
     45  * [in]		pSrcOrg		Pointer to the original block
     46  * [in]		iStepOrg	Step of the original block buffer
     47  * [in]		pSrcRef		Pointer to the reference block
     48  * [in]		iStepRef	Step of the reference block buffer
     49  * [in]		iHeight		Height of the block
     50  * [in]		iWidth		Width of the block
     51  * [out]	pDstSAD		Pointer of result SAD
     52  *
     53  * Return Value:
     54  * Standard OMXResult value.
     55  *
     56  */
     57 OMXResult armVCCOMM_SAD(
     58 	const OMX_U8* 	pSrcOrg,
     59 	OMX_U32 	iStepOrg,
     60 	const OMX_U8* 	pSrcRef,
     61 	OMX_U32 	iStepRef,
     62 	OMX_S32*	pDstSAD,
     63 	OMX_U32		iHeight,
     64 	OMX_U32		iWidth
     65 )
     66 {
     67     OMX_INT     x, y;
     68 
     69     /* check for argument error */
     70     armRetArgErrIf(pSrcOrg == NULL, OMX_Sts_BadArgErr)
     71     armRetArgErrIf(pSrcRef == NULL, OMX_Sts_BadArgErr)
     72     armRetArgErrIf(pDstSAD == NULL, OMX_Sts_BadArgErr)
     73 
     74     *pDstSAD = 0;
     75     for (y = 0; y < iHeight; y++)
     76     {
     77         for (x = 0; x < iWidth; x++)
     78         {
     79             *pDstSAD += armAbs(pSrcOrg [(y * iStepOrg) + x] -
     80                        pSrcRef [(y * iStepRef) + x]);
     81         }
     82     }
     83 
     84     return OMX_Sts_NoErr;
     85 }
     86 
     87 /*****************************************************************************
     88  *                              END OF FILE
     89  *****************************************************************************/
     90 
     91