omxVCM4P2_DCT8x8blk.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_DCT8x8blk.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 DCT
29 *
30 */
31
32#include <math.h>
33#include "omxtypes.h"
34#include "armOMX.h"
35
36#include "armCOMM.h"
37#include "armVCM4P2_DCT_Table.h"
38
39/**
40 * Function:  omxVCM4P2_DCT8x8blk   (6.2.4.4.1)
41 *
42 * Description:
43 * Computes a 2D forward DCT for a single 8x8 block, as defined in
44 * [ISO14496-2].
45 *
46 * Input Arguments:
47 *
48 *   pSrc - pointer to the start of the linearly arranged input buffer; must
49 *            be aligned on a 16-byte boundary.  Input values (pixel
50 *            intensities) are valid in the range [-255,255].
51 *
52 * Output Arguments:
53 *
54 *   pDst - pointer to the start of the linearly arranged output buffer; must
55 *            be aligned on a 16-byte boundary.
56 *
57 * Return Value:
58 *
59 *    OMX_Sts_NoErr - no error
60 *    OMX_Sts_BadArgErr - bad arguments, returned if:
61 *    -    pSrc or pDst is NULL.
62 *    -    pSrc or pDst is not 16-byte aligned.
63 *
64 */
65
66OMXResult omxVCM4P2_DCT8x8blk (const OMX_S16 *pSrc, OMX_S16 *pDst)
67{
68    OMX_INT x, y, u, v;
69
70    /* Argument error checks */
71    armRetArgErrIf(pSrc == NULL, OMX_Sts_BadArgErr);
72    armRetArgErrIf(!armIs16ByteAligned(pSrc), OMX_Sts_BadArgErr);
73    armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr);
74    armRetArgErrIf(!armIs16ByteAligned(pDst), OMX_Sts_BadArgErr);
75
76
77    for (u = 0; u < 8; u++)
78    {
79        for (v = 0; v < 8; v++)
80        {
81            OMX_F64 sum = 0.0;
82            for (x = 0; x < 8; x++)
83            {
84                for (y = 0; y < 8; y++)
85                {
86                    sum += pSrc[(x * 8) + y] *
87                       armVCM4P2_preCalcDCTCos[x][u] *
88                       armVCM4P2_preCalcDCTCos[y][v];
89                }
90            }
91            pDst[(u * 8) + v]= armRoundFloatToS16 (sum);
92        }
93    }
94
95    return OMX_Sts_NoErr;
96}
97
98
99
100/* End of file */
101
102
103