omxVCM4P2_IDCT8x8blk.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:  omxVCM4P2_IDCT8x8blk.c
20 * OpenMAX DL: v1.0.2
21 * Revision:   9641
22 * Date:       Thursday, February 7, 2008
23 *
24 *
25 *
26 *
27 * Description:
28 * Contains modules for 8x8 block IDCT
29 *
30 */
31
32
33#include <math.h>
34#include "omxtypes.h"
35#include "armOMX.h"
36#include "omxVC.h"
37
38#include "armCOMM.h"
39#include "armVCM4P2_DCT_Table.h"
40
41/**
42 * Function:  omxVCM4P2_IDCT8x8blk   (6.2.3.2.1)
43 *
44 * Description:
45 * Computes a 2D inverse DCT for a single 8x8 block, as defined in
46 * [ISO14496-2].
47 *
48 * Input Arguments:
49 *
50 *   pSrc - pointer to the start of the linearly arranged IDCT input buffer;
51 *            must be aligned on a 16-byte boundary.  According to
52 *            [ISO14496-2], the input coefficient values should lie within the
53 *            range [-2048, 2047].
54 *
55 * Output Arguments:
56 *
57 *   pDst - pointer to the start of the linearly arranged IDCT output buffer;
58 *            must be aligned on a 16-byte boundary.
59 *
60 * Return Value:
61 *
62 *    OMX_Sts_NoErr - no error
63 *    OMX_Sts_BadArgErr - bad arguments:
64 *    -    pSrc or pDst is NULL.
65 *    -    pSrc or pDst is not 16-byte aligned.
66 *
67 */
68OMXResult omxVCM4P2_IDCT8x8blk (const OMX_S16 *pSrc, OMX_S16 *pDst)
69{
70    OMX_INT x, y, u, v;
71
72    /* Argument error checks */
73    armRetArgErrIf(pSrc == NULL, OMX_Sts_BadArgErr);
74    armRetArgErrIf(!armIs16ByteAligned(pSrc), OMX_Sts_BadArgErr);
75    armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr);
76    armRetArgErrIf(!armIs16ByteAligned(pDst), OMX_Sts_BadArgErr);
77
78    for (x = 0; x < 8; x++)
79    {
80        for (y = 0; y < 8; y++)
81        {
82            OMX_F64 sum = 0.0;
83            for (u = 0; u < 8; u++)
84            {
85                for (v = 0; v < 8; v++)
86                {
87                    sum += pSrc[(u * 8) + v] *
88                        armVCM4P2_preCalcDCTCos[x][u] *
89                        armVCM4P2_preCalcDCTCos[y][v];
90                }
91            }
92            pDst[(x * 8) + y] = (OMX_S16) floor(sum + 0.5);
93
94            /* Saturate to [-256, 255] */
95            pDst[(x * 8) + y] = armClip (
96                                            -256,
97                                            255,
98                                            pDst[(x * 8) + y]);
99        }
100    }
101
102    return OMX_Sts_NoErr;
103}
104
105/* End of file */
106
107
108