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