armVCM4P10_InterpolateHalfHor_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_InterpolateHalfHor_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 * Function: armVCM4P10_InterpolateHalfHor_Luma
40 *
41 * Description:
42 * This function performs interpolation for horizontal 1/2-pel positions
43 *
44 * Remarks:
45 *
46 *  [in]    pSrc        Pointer to top-left corner of block used to interpolate
47 *                      in the reconstructed frame plane
48 *  [in]    iSrcStep    Step of the source buffer.
49 *  [in]    iDstStep    Step of the destination(interpolation) buffer.
50 *  [in]    iWidth      Width of the current block
51 *  [in]    iHeight     Height of the current block
52 *  [out]   pDst        Pointer to the interpolation buffer of the 1/2-pel
53 *
54 * Return Value:
55 * Standard OMXResult value.
56 *
57 */
58
59OMXResult armVCM4P10_InterpolateHalfHor_Luma(
60        const OMX_U8*     pSrc,
61        OMX_U32     iSrcStep,
62        OMX_U8*     pDst,
63        OMX_U32     iDstStep,
64        OMX_U32     iWidth,
65        OMX_U32     iHeight
66)
67{
68    OMX_INT     x, y;
69    OMX_S32     HalfCoeff, pos;
70
71    /* check for argument error */
72    armRetArgErrIf(pSrc == NULL, OMX_Sts_BadArgErr)
73    armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr)
74
75    for (y = 0; y < iHeight; y++)
76    {
77        for (x = 0; x < iWidth; x++)
78        {
79            pos = y * iSrcStep + x;
80            HalfCoeff =
81                pSrc [pos - 2] -
82                5 * pSrc [pos - 1] +
83                20 * pSrc [pos] +
84                20 * pSrc [pos + 1] -
85                5 * pSrc [pos + 2] +
86                pSrc [pos + 3];
87
88            HalfCoeff = (HalfCoeff + 16) >> 5;
89            HalfCoeff = armClip(0, 255, HalfCoeff);
90
91            pDst [y * iDstStep + x] = HalfCoeff;
92        } /* x */
93    } /* y */
94
95    return OMX_Sts_NoErr;
96}
97
98