1/**
2 *
3 * File Name:  omxVCM4P2_QuantInter_I.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 inter Quantization
14 *
15 */
16
17#include "omxtypes.h"
18#include "armOMX.h"
19#include "omxVC.h"
20
21#include "armCOMM.h"
22
23/**
24 * Function:  omxVCM4P2_QuantInter_I   (6.2.4.4.3)
25 *
26 * Description:
27 * Performs quantization on an inter coefficient block; supports
28 * bits_per_pixel == 8.
29 *
30 * Input Arguments:
31 *
32 *   pSrcDst - pointer to the input inter block coefficients; must be aligned
33 *            on a 16-byte boundary.
34 *   QP - quantization parameter (quantizer_scale)
35 *   shortVideoHeader - binary flag indicating presence of short_video_header;
36 *            shortVideoHeader==1 selects linear intra DC mode, and
37 *            shortVideoHeader==0 selects non linear intra DC mode.
38 *
39 * Output Arguments:
40 *
41 *   pSrcDst - pointer to the output (quantized) interblock coefficients.
42 *            When shortVideoHeader==1, AC coefficients are saturated on the
43 *            interval [-127, 127], and DC coefficients are saturated on the
44 *            interval [1, 254].  When shortVideoHeader==0, AC coefficients
45 *            are saturated on the interval [-2047, 2047].
46 *
47 * Return Value:
48 *
49 *    OMX_Sts_NoErr - no error
50 *    OMX_Sts_BadArgErr - bad arguments:
51 *    -    pSrcDst is NULL.
52 *    -    QP <= 0 or QP >= 32.
53 *
54 */
55
56OMXResult omxVCM4P2_QuantInter_I(
57     OMX_S16 * pSrcDst,
58     OMX_U8 QP,
59	 OMX_INT shortVideoHeader
60)
61{
62
63    /* Definitions and Initializations*/
64    OMX_INT coeffCount;
65    OMX_INT fSign;
66    OMX_INT maxClpAC = 0, minClpAC = 0;
67    OMX_INT maxClpDC = 0, minClpDC = 0;
68
69    /* Argument error checks */
70    armRetArgErrIf(pSrcDst == NULL, OMX_Sts_BadArgErr);
71    armRetArgErrIf(((QP <= 0) || (QP >= 32)), OMX_Sts_BadArgErr);
72   /* One argument check is delayed until we have ascertained that  */
73   /* pQMatrix is not NULL.                                         */
74
75    /* Set the Clip Range based on SVH on/off */
76    if(shortVideoHeader == 1)
77    {
78       maxClpDC = 254;
79       minClpDC = 1;
80       maxClpAC = 127;
81       minClpAC = -127;
82    }
83    else
84    {
85        maxClpDC = 2047;
86        minClpDC = -2047;
87        maxClpAC = 2047;
88        minClpAC = -2047;
89    }
90
91    /* Second Inverse quantisation method */
92    for (coeffCount = 0; coeffCount < 64; coeffCount++)
93    {
94        fSign =  armSignCheck (pSrcDst[coeffCount]);
95        pSrcDst[coeffCount] = (armAbs(pSrcDst[coeffCount])
96                              - (QP/2))/(2 * QP);
97        pSrcDst[coeffCount] *= fSign;
98
99        /* Clip */
100        if (coeffCount == 0)
101        {
102           pSrcDst[coeffCount] =
103           (OMX_S16) armClip (minClpDC, maxClpDC, pSrcDst[coeffCount]);
104        }
105        else
106        {
107           pSrcDst[coeffCount] =
108           (OMX_S16) armClip (minClpAC, maxClpAC, pSrcDst[coeffCount]);
109        }
110    }
111    return OMX_Sts_NoErr;
112
113}
114
115/* End of file */
116
117
118