1 /** 2 * 3 * File Name: armVCM4P10_InterpolateHalfDiag_Luma.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 * Description: 12 * This functions will help to calculate Half Pel luma interpolation 13 * 14 */ 15 16 #include "omxtypes.h" 17 #include "armOMX.h" 18 #include "omxVC.h" 19 20 #include "armCOMM.h" 21 #include "armVC.h" 22 23 24 /** 25 * Function: armVCM4P10_InterpolateHalfDiag_Luma 26 * 27 * Description: 28 * This function performs interpolation for (1/2, 1/2) positions 29 * around a full-pel position. 30 * 31 * Remarks: 32 * 33 * [in] pSrc Pointer to top-left corner of block used to interpolate 34 * in the reconstructed frame plane 35 * [in] iSrcStep Step of the source buffer. 36 * [in] iDstStep Step of the destination(interpolation) buffer. 37 * [in] iWidth Width of the current block 38 * [in] iHeight Height of the current block 39 * [out] pDst Pointer to the interpolation buffer of the (1/2,1/2)-pel 40 * 41 * Return Value: 42 * Standard OMXResult value. 43 * 44 */ 45 46 OMXResult armVCM4P10_InterpolateHalfDiag_Luma( 47 const OMX_U8* pSrc, 48 OMX_U32 iSrcStep, 49 OMX_U8* pDst, 50 OMX_U32 iDstStep, 51 OMX_U32 iWidth, 52 OMX_U32 iHeight 53 ) 54 { 55 OMX_S32 HalfCoeff, pos; 56 OMX_S16 Buf [21 * 16]; /* 21 rows by 16 pixels per row */ 57 OMX_U32 y, x; 58 59 /* check for argument error */ 60 armRetArgErrIf(pSrc == NULL, OMX_Sts_BadArgErr) 61 armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr) 62 63 /* 64 * Intermediate values will be 1/2 pel at Horizontal direction 65 * Starting at (0.5, -2) at top extending to (0.5, height + 3) at bottom 66 * Buf contains a 2D array of size (iWidth)X(iHeight + 5) 67 */ 68 for (y = 0; y < iHeight + 5; y++) 69 { 70 for (x = 0; x < iWidth; x++) 71 { 72 pos = (y-2) * iSrcStep + x; 73 HalfCoeff = 74 pSrc [pos - 2] - 75 5 * pSrc [pos - 1] + 76 20 * pSrc [pos] + 77 20 * pSrc [pos + 1] - 78 5 * pSrc [pos + 2] + 79 pSrc [pos + 3]; 80 Buf [y * iWidth + x] = (OMX_S16)HalfCoeff; 81 } /* x */ 82 } /* y */ 83 84 /* Vertical interpolate */ 85 for (y = 0; y < iHeight; y++) 86 { 87 for (x = 0; x < iWidth; x++) 88 { 89 pos = y * iWidth + x; 90 HalfCoeff = 91 Buf [pos] - 92 5 * Buf [pos + 1 * iWidth] + 93 20 * Buf [pos + 2 * iWidth] + 94 20 * Buf [pos + 3 * iWidth] - 95 5 * Buf [pos + 4 * iWidth] + 96 Buf [pos + 5 * iWidth]; 97 98 HalfCoeff = (HalfCoeff + 512) >> 10; 99 HalfCoeff = armClip(0, 255, HalfCoeff); 100 101 pDst [y * iDstStep + x] = (OMX_U8) HalfCoeff; 102 } 103 } 104 105 return OMX_Sts_NoErr; 106 } 107