omxVCM4P10_TransformDequantLumaDCFromPair.c revision 0c1bc742181ded4930842b46e9507372f0b1b963
1/* ----------------------------------------------------------------
2 *
3 *
4 * File Name:  omxVCM4P10_TransformDequantLumaDCFromPair.c
5 * OpenMAX DL: v1.0.2
6 * Revision:   9641
7 * Date:       Thursday, February 7, 2008
8 *
9 * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.
10 *
11 *
12 *
13 * H.264 inverse quantize and transform module
14 *
15 */
16
17#include "omxtypes.h"
18#include "armOMX.h"
19#include "omxVC.h"
20
21#include "armCOMM.h"
22#include "armVC.h"
23
24/*
25 * Description:
26 * Dequantize Luma DC block
27 */
28
29static void DequantLumaDC4x4(
30     OMX_S16* pDst,
31     OMX_INT QP
32)
33{
34    int Shift = (QP/6)-2 ;
35    int Scale = armVCM4P10_VMatrix[QP%6][0];
36    int i, Round, Value;
37
38    if (Shift >= 0)
39    {
40        for (i=0; i<16; i++)
41        {
42            Value = (pDst[i] * Scale) << Shift;
43            pDst[i] = (OMX_S16)Value;
44        }
45    }
46    else
47    {
48        Shift = -Shift;;
49        Round = 1<<(Shift-1);
50
51        for (i=0; i<16; i++)
52        {
53            Value = (pDst[i] * Scale + Round) >> Shift;
54            pDst[i] = (OMX_S16)Value;
55        }
56    }
57}
58
59
60
61/*
62 * Description:
63 * Inverse Transform DC 4x4 Coefficients
64 */
65static void InvTransformDC4x4(OMX_S16* pData)
66{
67    int i;
68
69    /* Transform rows */
70    for (i=0; i<16; i+=4)
71    {
72        int c0 = pData[i+0];
73        int c1 = pData[i+1];
74        int c2 = pData[i+2];
75        int c3 = pData[i+3];
76        pData[i+0] = (OMX_S16)(c0+c1+c2+c3);
77        pData[i+1] = (OMX_S16)(c0+c1-c2-c3);
78        pData[i+2] = (OMX_S16)(c0-c1-c2+c3);
79        pData[i+3] = (OMX_S16)(c0-c1+c2-c3);
80    }
81
82    /* Transform columns */
83    for (i=0; i<4; i++)
84    {
85        int c0 = pData[i+0];
86        int c1 = pData[i+4];
87        int c2 = pData[i+8];
88        int c3 = pData[i+12];
89        pData[i+0] = (OMX_S16)(c0+c1+c2+c3);
90        pData[i+4] = (OMX_S16)(c0+c1-c2-c3);
91        pData[i+8] = (OMX_S16)(c0-c1-c2+c3);
92        pData[i+12] = (OMX_S16)(c0-c1+c2-c3);
93    }
94}
95
96
97/**
98 * Function:  omxVCM4P10_TransformDequantLumaDCFromPair   (6.3.4.2.1)
99 *
100 * Description:
101 * Reconstructs the 4x4 LumaDC block from the coefficient-position pair
102 * buffer, performs integer inverse, and dequantization for 4x4 LumaDC
103 * coefficients, and updates the pair buffer pointer to the next non-empty
104 * block.
105 *
106 * Input Arguments:
107 *
108 *   ppSrc - Double pointer to residual coefficient-position pair buffer
109 *            output by CALVC decoding
110 *   QP - Quantization parameter QpY
111 *
112 * Output Arguments:
113 *
114 *   ppSrc - *ppSrc is updated to the start of next non empty block
115 *   pDst - Pointer to the reconstructed 4x4 LumaDC coefficients buffer; must
116 *            be aligned on a 8-byte boundary.
117 *
118 * Return Value:
119 *    OMX_Sts_NoErr, if the function runs without error.
120 *    OMX_Sts_BadArgErr - bad arguments: if one of the following cases occurs:
121 *    -    ppSrc or pDst is NULL.
122 *    -    pDst is not 8 byte aligned.
123 *    -    QP is not in the range of [0-51].
124 *
125 */
126
127OMXResult omxVCM4P10_TransformDequantLumaDCFromPair(
128     const OMX_U8 **ppSrc,
129     OMX_S16* pDst,
130     OMX_INT QP
131 )
132{
133    armRetArgErrIf(ppSrc  == NULL,           OMX_Sts_BadArgErr);
134    armRetArgErrIf(*ppSrc == NULL,           OMX_Sts_BadArgErr);
135    armRetArgErrIf(pDst   == NULL,           OMX_Sts_BadArgErr);
136    armRetArgErrIf(armNot8ByteAligned(pDst), OMX_Sts_BadArgErr);
137    armRetArgErrIf(QP<0,                     OMX_Sts_BadArgErr);
138    armRetArgErrIf(QP>51,                    OMX_Sts_BadArgErr);
139
140    armVCM4P10_UnpackBlock4x4(ppSrc, pDst);
141    /*InvTransformDequantLumaDC4x4(pDst, QP);*/
142    InvTransformDC4x4(pDst);
143    DequantLumaDC4x4(pDst, QP);
144
145    return OMX_Sts_NoErr;
146}
147
148/* End of file */
149