1 /** 2 * 3 * File Name: omxVCCOMM_ComputeTextureErrorBlock_SAD.c 4 * OpenMAX DL: v1.0.2 5 * Revision: 9641 6 * Date: Thursday, February 7, 2008 7 * 8 * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved. 9 * 10 * 11 * 12 * Description: 13 * Contains module computing the error for a MB of size 8x8 14 * 15 */ 16 #include "omxtypes.h" 17 #include "armOMX.h" 18 #include "omxVC.h" 19 20 #include "armCOMM.h" 21 22 23 /** 24 * Function: omxVCCOMM_ComputeTextureErrorBlock_SAD (6.1.4.1.1) 25 * 26 * Description: 27 * Computes texture error of the block; also returns SAD. 28 * 29 * Input Arguments: 30 * 31 * pSrc - pointer to the source plane; must be aligned on an 8-byte 32 * boundary. 33 * srcStep - step of the source plane 34 * pSrcRef - pointer to the reference buffer, an 8x8 block; must be aligned 35 * on an 8-byte boundary. 36 * 37 * Output Arguments: 38 * 39 * pDst - pointer to the destination buffer, an 8x8 block; must be aligned 40 * on an 8-byte boundary. 41 * pDstSAD - pointer to the Sum of Absolute Differences (SAD) value 42 * 43 * Return Value: 44 * 45 * OMX_Sts_NoErr - no error 46 * OMX_Sts_BadArgErr - bad arguments 47 * - At least one of the following 48 * pointers is NULL: pSrc, pSrcRef, pDst and pDstSAD. 49 * - pSrc is not 8-byte aligned. 50 * - SrcStep <= 0 or srcStep is not a multiple of 8. 51 * - pSrcRef is not 8-byte aligned. 52 * - pDst is not 8-byte aligned. 53 * 54 */ 55 56 OMXResult omxVCCOMM_ComputeTextureErrorBlock_SAD( 57 const OMX_U8 *pSrc, 58 OMX_INT srcStep, 59 const OMX_U8 *pSrcRef, 60 OMX_S16 * pDst, 61 OMX_INT *pDstSAD 62 ) 63 { 64 65 OMX_INT x, y, count; 66 67 /* Argument error checks */ 68 armRetArgErrIf(pSrc == NULL, OMX_Sts_BadArgErr); 69 armRetArgErrIf(pSrcRef == NULL, OMX_Sts_BadArgErr); 70 armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr); 71 armRetArgErrIf(pDstSAD == NULL, OMX_Sts_BadArgErr); 72 armRetArgErrIf(!armIs8ByteAligned(pSrc), OMX_Sts_BadArgErr); 73 armRetArgErrIf(!armIs8ByteAligned(pSrcRef), OMX_Sts_BadArgErr); 74 armRetArgErrIf(!armIs8ByteAligned(pDst), OMX_Sts_BadArgErr); 75 armRetArgErrIf((srcStep <= 0) || (srcStep & 7), OMX_Sts_BadArgErr); 76 77 /* Calculate the error block */ 78 for (y = 0, count = 0, *pDstSAD = 0; 79 y < 8; 80 y++, pSrc += srcStep) 81 { 82 for (x = 0; x < 8; x++, count++) 83 { 84 pDst[count] = pSrc[x] - pSrcRef[count]; 85 *pDstSAD += armAbs(pDst[count]); 86 } 87 } 88 89 return OMX_Sts_NoErr; 90 91 } 92 93 /* End of file */ 94