omxVCM4P10_InvTransformDequant_ChromaDC.c revision 0c1bc742181ded4930842b46e9507372f0b1b963
1/**
2 *
3 * File Name:  omxVCM4P10_InvTransformDequant_ChromaDC.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 4x4 hadamard transform of chroma DC
13 * coefficients and quantization
14 *
15 */
16
17#include "omxtypes.h"
18#include "armOMX.h"
19#include "omxVC.h"
20
21#include "armVC.h"
22#include "armCOMM.h"
23
24/**
25 * Function:  omxVCM4P10_InvTransformDequant_ChromaDC   (6.3.5.6.4)
26 *
27 * Description:
28 * This function performs inverse 2x2 Hadamard transform and then dequantizes
29 * the coefficients.
30 *
31 * Input Arguments:
32 *
33 *   pSrc - Pointer to the 2x2 array of the 2x2 Hadamard-transformed and
34 *            quantized coefficients.  8 byte alignment required.
35 *   iQP - Quantization parameter; must be in the range [0,51].
36 *
37 * Output Arguments:
38 *
39 *   pDst - Pointer to inverse-transformed and dequantized coefficients.
40 *            8-byte alignment required.
41 *
42 * Return Value:
43 *
44 *    OMX_Sts_NoErr - no error
45 *    OMX_Sts_BadArgErr - bad arguments; returned if any of the following
46 *              conditions are true:
47 *    -    at least one of the following pointers is NULL: pSrc
48 *    -    pSrc or pDst is not aligned on an 8-byte boundary
49 *
50 */
51OMXResult omxVCM4P10_InvTransformDequant_ChromaDC(
52	const OMX_S16* 	pSrc,
53	OMX_S16*	pDst,
54	OMX_U32		iQP
55)
56{
57    OMX_INT     i, j;
58    OMX_S32     m[2][2];
59    OMX_S32     QPer, V00, Value;
60
61    /* check for argument error */
62    armRetArgErrIf(pSrc == NULL, OMX_Sts_BadArgErr)
63    armRetArgErrIf(armNot8ByteAligned(pSrc), OMX_Sts_BadArgErr);
64    armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr)
65    armRetArgErrIf(armNot8ByteAligned(pDst), OMX_Sts_BadArgErr);
66    armRetArgErrIf(iQP > 51, OMX_Sts_BadArgErr)
67
68    /* Inv Hadamard Transform for 2x2 block */
69    m[0][0] = pSrc[0] + pSrc[1] +  pSrc[2] + pSrc[3];
70    m[0][1] = pSrc[0] - pSrc[1] +  pSrc[2] - pSrc[3];
71    m[1][0] = pSrc[0] + pSrc[1] -  pSrc[2] - pSrc[3];
72    m[1][1] = pSrc[0] - pSrc[1] -  pSrc[2] + pSrc[3];
73
74    /* Quantization */
75    /* Scaling */
76    QPer = iQP / 6;
77    V00 = armVCM4P10_VMatrix [iQP % 6][0];
78
79    for (j = 0; j < 2; j++)
80    {
81        for (i = 0; i < 2; i++)
82        {
83            if (QPer < 1)
84            {
85                Value = (m[j][i] * V00) >> 1;
86            }
87            else
88            {
89                Value = (m[j][i] * V00) << (QPer - 1);
90            }
91
92            pDst[j * 2 + i] = (OMX_S16) Value;
93        }
94    }
95
96    return OMX_Sts_NoErr;
97}
98
99/*****************************************************************************
100 *                              END OF FILE
101 *****************************************************************************/
102
103