• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*!
2  * \copy
3  *     Copyright (c)  2009-2013, Cisco Systems
4  *     All rights reserved.
5  *
6  *     Redistribution and use in source and binary forms, with or without
7  *     modification, are permitted provided that the following conditions
8  *     are met:
9  *
10  *        * Redistributions of source code must retain the above copyright
11  *          notice, this list of conditions and the following disclaimer.
12  *
13  *        * Redistributions in binary form must reproduce the above copyright
14  *          notice, this list of conditions and the following disclaimer in
15  *          the documentation and/or other materials provided with the
16  *          distribution.
17  *
18  *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  *     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  *     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  *     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22  *     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23  *     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24  *     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26  *     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  *     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28  *     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  *     POSSIBILITY OF SUCH DAMAGE.
30  *
31  *
32  * \file    parse_mb_syn_cavlc.h
33  *
34  * \brief   Parsing all syntax elements of mb and decoding residual with cavlc
35  *
36  * \date    03/17/2009 Created
37  *
38  *************************************************************************************
39  */
40 
41 
42 #ifndef WELS_PARSE_MB_SYN_CAVLC_H__
43 #define WELS_PARSE_MB_SYN_CAVLC_H__
44 
45 #include "wels_common_basis.h"
46 #include "decoder_context.h"
47 #include "dec_frame.h"
48 #include "slice.h"
49 
50 namespace WelsDec {
51 
52 
53 
54 void GetNeighborAvailMbType (PWelsNeighAvail pNeighAvail, PDqLayer pCurDqLayer);
55 void WelsFillCacheNonZeroCount (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, PDqLayer pCurDqLayer);
56 void WelsFillCacheConstrain0IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
57                                       PDqLayer pCurDqLayer);
58 void WelsFillCacheConstrain1IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
59                                       PDqLayer pCurDqLayer);
60 void WelsFillCacheInterCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
61                               int16_t iMvArray[LIST_A][30][MV_A], int16_t iMvdCache[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30],
62                               PDqLayer pCurDqLayer);
63 void WelsFillDirectCacheCabac (PWelsNeighAvail pNeighAvail, int8_t iDirect[30], PDqLayer pCurDqLayer);
64 void WelsFillCacheInter (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
65                          int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurDqLayer);
66 
67 /*!
68  * \brief   check iPredMode for intra16x16 eligible or not
69  * \param   input : current iPredMode
70  * \param   output: 0 indicating decoding correctly; -1 means error occurence
71  */
72 int32_t CheckIntra16x16PredMode (uint8_t uiSampleAvail, int8_t* pMode);
73 
74 /*!
75  * \brief   check iPredMode for intraNxN eligible or not
76  * \param   input : current iPredMode
77  * \param   output: 0 indicating decoding correctly; -1 means error occurence
78  */
79 int32_t CheckIntraNxNPredMode (int32_t* pSampleAvail, int8_t* pMode, int32_t iIndex, bool b8x8);
80 
81 /*!
82  * \brief   check iPredMode for chroma eligible or not
83  * \param   input : current iPredMode
84  * \param   output: 0 indicating decoding correctly; -1 means error occurence
85  */
86 int32_t CheckIntraChromaPredMode (uint8_t uiSampleAvail, int8_t* pMode);
87 
88 /*!
89  * \brief   predict the mode of intra4x4
90  * \param   input : current intra4x4 block index
91  * \param   output: mode index
92  */
93 int32_t PredIntra4x4Mode (int8_t* pIntraPredMode, int32_t iIdx4);
94 
95 
96 void BsStartCavlc (PBitStringAux pBs);
97 void BsEndCavlc (PBitStringAux pBs);
98 
99 int32_t WelsResidualBlockCavlc (SVlcTable* pVlcTable,
100                                 uint8_t* pNonZeroCountCache,
101                                 PBitStringAux pBs,
102                                 /*int16_t* coeff_level,*/
103                                 int32_t iIndex,
104                                 int32_t iMaxNumCoeff,
105                                 const uint8_t* kpZigzagTable,
106                                 int32_t iResidualProperty,
107                                 /*short *tCoeffLevel,*/
108                                 int16_t* pTCoeff,
109                                 uint8_t uiQp,
110                                 PWelsDecoderContext pCtx);
111 
112 // Transform8x8
113 int32_t WelsResidualBlockCavlc8x8 (SVlcTable* pVlcTable,
114                                    uint8_t* pNonZeroCountCache,
115                                    PBitStringAux pBs,
116                                    /*int16_t* coeff_level,*/
117                                    int32_t iIndex,
118                                    int32_t iMaxNumCoeff,
119                                    const uint8_t* kpZigzagTable,
120                                    int32_t iResidualProperty,
121                                    /*short *tCoeffLevel,*/
122                                    int16_t* pTCoeff,
123                                    int32_t  iIdx4x4,
124                                    uint8_t uiQp,
125                                    PWelsDecoderContext pCtx);
126 
127 /*!
128  * \brief   parsing inter info (including ref_index and pMvd)
129  * \param   input : decoding context, current mb, bit-stream
130  * \param   output: 0 indicating decoding correctly; -1 means error
131  */
132 int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30],
133                         PBitStringAux pBs);
134 int32_t ParseInterBInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][MV_A],
135                          int8_t iRefIdxArray[LIST_A][30], PBitStringAux pBs);
136 } // namespace WelsDec
137 #endif//WELS_PARSE_MB_SYN_CAVLC_H__
138