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