1/**
2 *
3 * File Name:  omxVCM4P2_DecodeBlockCoef_Inter.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 reconstruction
14 *
15 */
16
17
18#include "omxtypes.h"
19#include "armOMX.h"
20#include "omxVC.h"
21
22#include "armCOMM.h"
23
24
25/**
26 * Function:  omxVCM4P2_DecodeBlockCoef_Inter   (6.2.5.4.2)
27 *
28 * Description:
29 * Decodes the INTER block coefficients. This function performs inverse
30 * quantization, inverse zigzag positioning, and IDCT (with appropriate
31 * clipping on each step) on the coefficients. The results (residuals) are
32 * placed in a contiguous array of 64 elements. For INTER block, the output
33 * buffer holds the residuals for further reconstruction.
34 *
35 * Input Arguments:
36 *
37 *   ppBitStream - pointer to the pointer to the current byte in the bit
38 *            stream buffer. There is no boundary check for the bit stream
39 *            buffer.
40 *   pBitOffset - pointer to the bit position in the byte pointed to by
41 *            *ppBitStream. *pBitOffset is valid within [0-7]
42 *   QP - quantization parameter
43 *   shortVideoHeader - binary flag indicating presence of
44 *            short_video_header; shortVideoHeader==1 selects linear intra DC
45 *            mode, and shortVideoHeader==0 selects non linear intra DC mode.
46 *
47 * Output Arguments:
48 *
49 *   ppBitStream - *ppBitStream is updated after the block is decoded, so
50 *            that it points to the current byte in the bit stream buffer
51 *   pBitOffset - *pBitOffset is updated so that it points to the current bit
52 *            position in the byte pointed by *ppBitStream
53 *   pDst - pointer to the decoded residual buffer (a contiguous array of 64
54 *            elements of OMX_S16 data type); must be aligned on a 16-byte
55 *            boundary.
56 *
57 * Return Value:
58 *
59 *    OMX_Sts_NoErr - no error
60 *    OMX_Sts_BadArgErr - bad arguments, if:
61 *    -    At least one of the following pointers is Null:
62 *         ppBitStream, *ppBitStream, pBitOffset , pDst
63 *    -    *pBitOffset exceeds [0,7]
64 *    -    QP <= 0.
65 *    -    pDst is not 16-byte aligned
66 *    OMX_Sts_Err - status error. Refer to OMX_Sts_Err of DecodeVLCZigzag_Inter .
67 *
68 */
69OMXResult omxVCM4P2_DecodeBlockCoef_Inter(
70     const OMX_U8 ** ppBitStream,
71     OMX_INT * pBitOffset,
72     OMX_S16 * pDst,
73     OMX_INT QP,
74     OMX_INT shortVideoHeader
75)
76{
77    /* 64 elements are needed but to align it to 16 bytes need
78    15 more elements of padding */
79    OMX_S16 tempBuf[79];
80    OMX_S16 *pTempBuf1;
81    OMXResult errorCode;
82    /* Aligning the local buffers */
83    pTempBuf1 = armAlignTo16Bytes(tempBuf);
84
85    /* Argument error checks */
86    armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr);
87    armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr);
88    armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr);
89    armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr);
90    armRetArgErrIf(!armIs16ByteAligned(pDst), OMX_Sts_BadArgErr);
91    armRetArgErrIf(((QP <= 0) || (QP >= 32)), OMX_Sts_BadArgErr);
92	armRetArgErrIf(((*pBitOffset < 0) || (*pBitOffset > 7)), OMX_Sts_BadArgErr);
93
94
95    /* VLD and zigzag */
96    errorCode = omxVCM4P2_DecodeVLCZigzag_Inter(ppBitStream, pBitOffset,
97                                        pTempBuf1,shortVideoHeader);
98    armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
99
100    /* Dequantization */
101    errorCode = omxVCM4P2_QuantInvInter_I(
102     pTempBuf1,
103     QP);
104    armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
105
106    /* Inverse transform */
107    errorCode = omxVCM4P2_IDCT8x8blk(pTempBuf1, pDst);
108    armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
109
110    return OMX_Sts_NoErr;
111}
112
113/* End of file */
114
115
116