• 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  * \file    au_parser.h
32  *
33  * \brief   Interfaces introduced in Access Unit level based parser
34  *
35  * \date    03/10/2009 Created
36  *
37  *************************************************************************************
38  */
39 #ifndef WELS_ACCESS_UNIT_PARSER_H__
40 #define WELS_ACCESS_UNIT_PARSER_H__
41 #include "typedefs.h"
42 #include "wels_common_basis.h"
43 #include "nal_prefix.h"
44 #include "dec_frame.h"
45 #include "bit_stream.h"
46 #include "parameter_sets.h"
47 #include "decoder_context.h"
48 
49 namespace WelsDec {
50 
51 /*!
52  *************************************************************************************
53  * \brief   Start Code Prefix (0x 00 00 00 01) detection
54  *
55  * \param   pBuf        bitstream payload buffer
56  * \param   pOffset     offset between NAL rbsp and original bitsteam that
57  *                      start code prefix is seperated from.
58  * \param   iBufSize    count size of buffer
59  *
60  * \return  RBSP buffer of start code prefix exclusive
61  *
62  * \note    N/A
63  *************************************************************************************
64  */
65 uint8_t* DetectStartCodePrefix (const uint8_t* kpBuf, int32_t* pOffset, int32_t iBufSize);
66 
67 /*!
68  *************************************************************************************
69  * \brief   to parse network abstraction layer unit,
70  *          escape emulation_prevention_three_byte within it
71     former name is parse_nal
72  *
73  * \param   pCtx            decoder context
74  * \param   pNalUnitHeader  parsed result of NAL Unit Header to output
75  * \param   pSrcRbsp        bitstream buffer to input
76  * \param   iSrcRbspLen     length size of bitstream buffer payload
77  * \param   pSrcNal
78  * \param   iSrcNalLen
79  * \param   pConsumedBytes  consumed bytes during parsing
80  *
81  * \return  decoded bytes payload, might be (pSrcRbsp+1) if no escapes
82  *
83  * \note    N/A
84  *************************************************************************************
85  */
86 uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeader, uint8_t* pSrcRbsp,
87                          int32_t iSrcRbspLen, uint8_t* pSrcNal, int32_t iSrcNalLen, int32_t* pConsumedBytes);
88 
89 int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t kiSrcLen, uint8_t* pSrcNal,
90                         const int32_t kSrcNalLen);
91 
92 int32_t ParseRefBasePicMarking (PBitStringAux pBs, PRefBasePicMarking pRefBasePicMarking);
93 
94 int32_t ParsePrefixNalUnit (PWelsDecoderContext pCtx, PBitStringAux pBs);
95 
96 bool CheckAccessUnitBoundary (PWelsDecoderContext pCtx, const PNalUnit kpCurNal, const PNalUnit kpLastNal,
97                               const PSps kpSps);
98 bool CheckAccessUnitBoundaryExt (PNalUnitHeaderExt pLastNalHdrExt, PNalUnitHeaderExt pCurNalHeaderExt,
99                                  PSliceHeader pLastSliceHeader, PSliceHeader pCurSliceHeader);
100 bool CheckNextAuNewSeq (PWelsDecoderContext pCtx, const PNalUnit kpCurNal, const PSps kpSps);
101 
102 /*!
103  *************************************************************************************
104  * \brief   to parse Sequence Parameter Set (SPS)
105  *
106  * \param   pCtx        Decoder context
107  * \param   pBsAux      bitstream reader auxiliary
108  * \param   pPicWidth   picture width current Sps represented
109  * \param   pPicHeight  picture height current Sps represented
110  *
111  * \return  0 - successed
112  *          1 - failed
113  *
114  * \note    Call it in case eNalUnitType is SPS.
115  *************************************************************************************
116  */
117 int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicWidth, int32_t* pPicHeight,
118                   uint8_t* pSrcNal, const int32_t kSrcNalLen);
119 
120 /*!
121  *************************************************************************************
122  * \brief   to parse Picture Parameter Set (PPS)
123  *
124  * \param   pCtx        Decoder context
125  * \param   pPpsList    pps list
126  * \param   pBsAux      bitstream reader auxiliary
127  *
128  * \return  0 - successed
129  *          1 - failed
130  *
131  * \note    Call it in case eNalUnitType is PPS.
132  *************************************************************************************
133  */
134 int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux, uint8_t* pSrcNal,
135                   const int32_t kSrcNalLen);
136 
137 /*!
138 *************************************************************************************
139 * \brief   to parse Video Usability Information (VUI) parameter of the SPS
140 *
141 * \param   pCtx        Decoder context
142 * \param   pSps        the sps which current Vui parameter belongs to
143 * \param   pBsAux      bitstream reader auxiliary
144 *
145 * \return  0 - successed
146 *          1 - failed
147 *
148 * \note    Call it in case the flag "vui_parameters_present_flag" in sps is true.
149 *************************************************************************************
150 */
151 int32_t ParseVui (PWelsDecoderContext pCtx, PSps pSps, PBitStringAux pBsAux);
152 
153 /*!
154  *************************************************************************************
155  * \brief to parse scaling list message payload
156  *
157  * \param  PPS SPS scaling list matrix     message to be parsed output
158  * \param pBsAux    bitstream reader auxiliary
159  *
160  * \return  0 - successed
161  *    1 - failed
162  *
163  * \note  Call it in case scaling matrix present at sps or pps
164  *************************************************************************************
165 */
166 int32_t SetScalingListValue (uint8_t* pScalingList, int iScalingListNum, bool* bUseDefaultScalingMatrixFlag,
167                              PBitStringAux pBsAux);
168 int32_t ParseScalingList (PSps pSps, PBitStringAux pBs, bool bPPS, const bool kbTrans8x8ModeFlag,
169                           bool* bScalingListPresentFlag, uint8_t (*iScalingList4x4)[16], uint8_t (*iScalingList8x8)[64]);
170 /*!
171  *************************************************************************************
172  * \brief   to parse SEI message payload
173  *
174  * \param   pSei        sei message to be parsed output
175  * \param   pBsAux      bitstream reader auxiliary
176  *
177  * \return  0 - successed
178  *          1 - failed
179  *
180  * \note    Call it in case eNalUnitType is NAL_UNIT_SEI.
181  *************************************************************************************
182  */
183 int32_t ParseSei (void* pSei, PBitStringAux pBsAux); // reserved Sei_Msg type
184 
185 /*!
186  *************************************************************************************
187  * \brief   reset fmo list due to got Sps now
188  *
189  * \param   pCtx    decoder context
190  *
191  * \return  count number of fmo context units are reset
192  *************************************************************************************
193  */
194 int32_t ResetFmoList (PWelsDecoderContext pCtx);
195 
196 } // namespace WelsDec
197 
198 #endif//WELS_ACCESS_UNIT_PARSER_H__
199 
200