armVCM4P10_Interpolate_Chroma.c revision 0c1bc742181ded4930842b46e9507372f0b1b963
1/**
2 *
3 * File Name:  armVCM4P10_Interpolate_Chroma.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 function will calculate interpolation for chroma components
13 *
14 */
15
16#include "omxtypes.h"
17#include "armOMX.h"
18
19#include "armCOMM.h"
20
21/**
22 * Function: armVCM4P10_Interpolate_Chroma
23 *
24 * Description:
25 * This function performs interpolation for chroma components.
26 *
27 * Remarks:
28 *
29 *  [in]    pSrc            Pointer to top-left corner of block used to
30 *                                              interpolate in the reconstructed frame plane
31 *  [in]    iSrcStep    Step of the source buffer.
32 *  [in]    iDstStep    Step of the destination(interpolation) buffer.
33 *  [in]    iWidth      Width of the current block
34 *  [in]    iHeight     Height of the current block
35 *  [in]    dx              Fractional part of horizontal motion vector
36 *                                              component in 1/8 pixel unit (0~7)
37 *  [in]    dy              Fractional part of vertical motion vector
38 *                                              component in 1/8 pixel unit (0~7)
39 *  [out]   pDst            Pointer to the interpolation buffer
40 *
41 * Return Value:
42 * Standard OMXResult value.
43 *
44 */
45 OMXResult armVCM4P10_Interpolate_Chroma(
46        OMX_U8      *pSrc,
47        OMX_U32     iSrcStep,
48        OMX_U8      *pDst,
49        OMX_U32     iDstStep,
50        OMX_U32     iWidth,
51        OMX_U32     iHeight,
52        OMX_U32     dx,
53        OMX_U32     dy
54)
55{
56    OMX_U32     EightMinusdx = 8 - dx;
57    OMX_U32     EightMinusdy = 8 - dy;
58    OMX_U32     ACoeff, BCoeff, CCoeff, DCoeff;
59    OMX_U32     x, y;
60
61    /* check for argument error */
62    armRetArgErrIf(pSrc == NULL, OMX_Sts_BadArgErr)
63    armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr)
64    armRetArgErrIf(dx > 7, OMX_Sts_BadArgErr)
65    armRetArgErrIf(dy > 7, OMX_Sts_BadArgErr)
66    armRetArgErrIf(iSrcStep == 0, OMX_Sts_BadArgErr)
67    armRetArgErrIf(iDstStep == 0, OMX_Sts_BadArgErr)
68    armRetArgErrIf(iWidth == 0, OMX_Sts_BadArgErr)
69    armRetArgErrIf(iHeight == 0, OMX_Sts_BadArgErr)
70
71    /* if fractionl mv is not (0, 0) */
72    if (dx != 0 || dy != 0)
73    {
74        ACoeff = EightMinusdx * EightMinusdy;
75        BCoeff = dx * EightMinusdy;
76        CCoeff = EightMinusdx * dy;
77        DCoeff = dx * dy;
78
79        for (y = 0; y < iHeight; y++)
80        {
81            for (x = 0; x < iWidth; x++)
82            {
83                pDst [y * iDstStep + x] = (
84                    ACoeff * pSrc [y * iSrcStep + x] +
85                    BCoeff * pSrc [y * iSrcStep + x + 1] +
86                    CCoeff * pSrc [(y + 1) * iSrcStep + x] +
87                    DCoeff * pSrc [(y + 1) * iSrcStep + x + 1] +
88                    32) >> 6;
89            }
90        }
91    }
92    else
93    {
94        for (y = 0; y < iHeight; y++)
95        {
96            for (x = 0; x < iWidth; x++)
97            {
98                pDst [y * iDstStep + x] = pSrc [y * iSrcStep + x];
99            }
100        }
101    }
102
103    return OMX_Sts_NoErr;
104}
105
106/*****************************************************************************
107 *                              END OF FILE
108 *****************************************************************************/
109
110