1/**
2 *
3 * File Name:  armVCM4P2_DecodeVLCZigzag_intra.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 filling of the coefficient buffer
14 *
15 */
16
17#include "omxtypes.h"
18#include "armOMX.h"
19#include "omxVC.h"
20
21#include "armVC.h"
22#include "armCOMM_Bitstream.h"
23#include "armCOMM.h"
24#include "armVCM4P2_Huff_Tables_VLC.h"
25#include "armVCM4P2_ZigZag_Tables.h"
26
27
28
29/**
30 * Function: armVCM4P2_DecodeVLCZigzag_Intra
31 *
32 * Description:
33 * Performs VLC decoding and inverse zigzag scan for one intra coded block.
34 *
35 * Remarks:
36 *
37 * Parameters:
38 * [in] ppBitStream     pointer to the pointer to the current byte in
39 *                              the bitstream buffer
40 * [in] pBitOffset      pointer to the bit position in the byte pointed
41 *                              to by *ppBitStream. *pBitOffset is valid within
42 *                              [0-7].
43 * [in] predDir         AC prediction direction which is used to decide
44 *                              the zigzag scan pattern. It takes one of the
45 *                              following values:
46 *                              OMX_VC_NONE  AC prediction not used;
47 *                                              perform classical zigzag scan;
48 *                              OMX_VC_HORIZONTAL    Horizontal prediction;
49 *                                                      perform alternate-vertical
50 *                                                      zigzag scan;
51 *                              OMX_VC_VERTICAL      Vertical prediction;
52 *                                                      thus perform
53 *                                                      alternate-horizontal
54 *                                                      zigzag scan.
55 * [in] start           start indicates whether the encoding begins with 0th element
56 *                      or 1st.
57 * [out]    ppBitStream     *ppBitStream is updated after the block is
58 *                              decoded, so that it points to the current byte
59 *                              in the bit stream buffer
60 * [out]    pBitOffset      *pBitOffset is updated so that it points to the
61 *                              current bit position in the byte pointed by
62 *                              *ppBitStream
63 * [out]    pDst            pointer to the coefficient buffer of current
64 *                              block. Should be 32-bit aligned
65 *
66 * Return Value:
67 * Standard OMXResult result. See enumeration for possible result codes.
68 *
69 */
70
71OMXResult armVCM4P2_DecodeVLCZigzag_Intra(
72     const OMX_U8 ** ppBitStream,
73     OMX_INT * pBitOffset,
74     OMX_S16 * pDst,
75     OMX_U8 predDir,
76     OMX_INT shortVideoHeader,
77     OMX_U8  start
78)
79{
80    OMX_U8  last = 0;
81    const OMX_U8  *pZigzagTable = armVCM4P2_aClassicalZigzagScan;
82    OMXResult errorCode;
83
84    /* Argument error checks */
85    armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr);
86    armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr);
87    armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr);
88    armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr);
89    armRetArgErrIf(!armIs4ByteAligned(pDst), OMX_Sts_BadArgErr);
90    armRetArgErrIf((*pBitOffset < 0) || (*pBitOffset >7), OMX_Sts_BadArgErr);
91    armRetArgErrIf((predDir > 2), OMX_Sts_BadArgErr);
92
93    switch (predDir)
94    {
95        case OMX_VC_NONE:
96        {
97            pZigzagTable = armVCM4P2_aClassicalZigzagScan;
98            break;
99        }
100
101        case OMX_VC_HORIZONTAL:
102        {
103            pZigzagTable = armVCM4P2_aVerticalZigzagScan;
104            break;
105        }
106
107        case OMX_VC_VERTICAL:
108        {
109            pZigzagTable = armVCM4P2_aHorizontalZigzagScan;
110            break;
111        }
112    }
113
114    errorCode = armVCM4P2_GetVLCBits (
115              ppBitStream,
116              pBitOffset,
117			  pDst,
118			  shortVideoHeader,
119			  start,
120			  &last,
121			  10,
122			  62,
123			   7,
124			  21,
125              armVCM4P2_IntraL0RunIdx,
126              armVCM4P2_IntraVlcL0,
127			  armVCM4P2_IntraL1RunIdx,
128              armVCM4P2_IntraVlcL1,
129              armVCM4P2_IntraL0LMAX,
130              armVCM4P2_IntraL1LMAX,
131              armVCM4P2_IntraL0RMAX,
132              armVCM4P2_IntraL1RMAX,
133              pZigzagTable );
134    armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode);
135
136    if (last == 0)
137    {
138        return OMX_Sts_Err;
139    }
140    return OMX_Sts_NoErr;
141}
142
143/* End of file */
144
145