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