omxVCM4P2_QuantInvInter_I.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_QuantInvInter_I.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 inter inverse Quantization
29 *
30 */
31
32#include "omxtypes.h"
33#include "armOMX.h"
34#include "omxVC.h"
35
36#include "armCOMM.h"
37
38
39/**
40 * Function:  omxVCM4P2_QuantInvInter_I   (6.2.5.3.2)
41 *
42 * Description:
43 * Performs the second inverse quantization mode on an intra/inter coded
44 * block. Supports bits_per_pixel = 8. The output coefficients are clipped to
45 * the range [-2048, 2047].
46 *
47 * Input Arguments:
48 *
49 *   pSrcDst - pointer to the input (quantized) intra/inter block; must be
50 *            aligned on a 16-byte boundary.
51 *   QP - quantization parameter (quantizer_scale)
52 *   videoComp - video component type of the current block. Takes one of the
53 *            following flags: OMX_VC_LUMINANCE, OMX_VC_CHROMINANCE (intra
54 *            version only).
55 *   shortVideoHeader - binary flag indicating presence of short_video_header
56 *            (intra version only).
57 *
58 * Output Arguments:
59 *
60 *   pSrcDst - pointer to the output (dequantized) intra/inter block
61 *
62 * Return Value:
63 *
64 *    OMX_Sts_NoErr - no error
65 *    OMX_Sts_BadArgErr - bad arguments; one or more of the following is
66 *              true:
67 *    -    pSrcDst is NULL
68 *    -    QP <= 0 or QP >=31
69 *    -    videoComp is neither OMX_VC_LUMINANCE nor OMX_VC_CHROMINANCE.
70 *
71 */
72
73OMXResult omxVCM4P2_QuantInvInter_I(
74     OMX_S16 * pSrcDst,
75     OMX_INT QP
76	 )
77{
78
79    OMX_INT coeffCount, Sign;
80
81    /* Argument error checks */
82    armRetArgErrIf(pSrcDst == NULL, OMX_Sts_BadArgErr);
83    armRetArgErrIf(((QP <= 0) || (QP >= 32)), OMX_Sts_BadArgErr);
84
85    /* Second Inverse quantisation method */
86    for (coeffCount = 0; coeffCount < 64; coeffCount++)
87    {
88        /* check sign */
89        Sign =  armSignCheck (pSrcDst[coeffCount]);
90
91        /* Quantize the coeff */
92        if (QP & 0x1)
93        {
94            pSrcDst[coeffCount] = (2* armAbs(pSrcDst[coeffCount]) + 1) * QP;
95            pSrcDst[coeffCount] *= Sign;
96        }
97        else
98        {
99            pSrcDst[coeffCount] = (2* armAbs(pSrcDst[coeffCount]) + 1)
100                                                                * QP - 1;
101            pSrcDst[coeffCount] *= Sign;
102        }
103        /* Saturate */
104        pSrcDst[coeffCount] = armClip (-2048, 2047, pSrcDst[coeffCount]);
105    }
106    return OMX_Sts_NoErr;
107}
108
109/* End of file */
110
111
112