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