1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2011, ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | |
---|
35 | |
---|
36 | /** \file TDecSbac.cpp |
---|
37 | \brief Context-adaptive entropy decoder class |
---|
38 | */ |
---|
39 | |
---|
40 | #include "TDecSbac.h" |
---|
41 | |
---|
42 | ////////////////////////////////////////////////////////////////////// |
---|
43 | // Construction/Destruction |
---|
44 | ////////////////////////////////////////////////////////////////////// |
---|
45 | |
---|
46 | TDecSbac::TDecSbac() |
---|
47 | // new structure here |
---|
48 | : m_pcBitstream ( 0 ) |
---|
49 | , m_pcTDecBinIf ( NULL ) |
---|
50 | , m_bAlfCtrl ( false ) |
---|
51 | , m_uiMaxAlfCtrlDepth ( 0 ) |
---|
52 | , m_cCUSkipFlagSCModel ( 1, 1, NUM_SKIP_FLAG_CTX ) |
---|
53 | , m_cCUSplitFlagSCModel ( 1, 1, NUM_SPLIT_FLAG_CTX ) |
---|
54 | , m_cCUMergeFlagExtSCModel ( 1, 1, NUM_MERGE_FLAG_EXT_CTX ) |
---|
55 | , m_cCUMergeIdxExtSCModel ( 1, 1, NUM_MERGE_IDX_EXT_CTX ) |
---|
56 | , m_cCUMVMergeIdxExtSCModel ( 1, 1, NUM_MV_MERGE_IDX_EXT_CTX ) |
---|
57 | , m_cResPredFlagSCModel ( 1, 1, NUM_RES_PRED_FLAG_CTX ) |
---|
58 | , m_cCUAlfCtrlFlagSCModel ( 1, 1, NUM_ALF_CTRL_FLAG_CTX ) |
---|
59 | , m_cCUPartSizeSCModel ( 1, 1, NUM_PART_SIZE_CTX ) |
---|
60 | , m_cCUPredModeSCModel ( 1, 1, NUM_PRED_MODE_CTX ) |
---|
61 | , m_cCUIntraPredSCModel ( 1, 1, NUM_ADI_CTX ) |
---|
62 | #if ADD_PLANAR_MODE |
---|
63 | , m_cPlanarFlagSCModel ( 1, 1, NUM_PLANARFLAG_CTX ) |
---|
64 | #endif |
---|
65 | , m_cCUChromaPredSCModel ( 1, 1, NUM_CHROMA_PRED_CTX ) |
---|
66 | , m_cCUInterDirSCModel ( 1, 1, NUM_INTER_DIR_CTX ) |
---|
67 | , m_cCURefPicSCModel ( 1, 1, NUM_REF_NO_CTX ) |
---|
68 | , m_cCUMvdSCModel ( 1, 2, NUM_MV_RES_CTX ) |
---|
69 | , m_cCUTransSubdivFlagSCModel ( 1, 1, NUM_TRANS_SUBDIV_FLAG_CTX ) |
---|
70 | , m_cCUQtRootCbfSCModel ( 1, 1, NUM_QT_ROOT_CBF_CTX ) |
---|
71 | , m_cCUDeltaQpSCModel ( 1, 1, NUM_DELTA_QP_CTX ) |
---|
72 | , m_cCUQtCbfSCModel ( 1, 3, NUM_QT_CBF_CTX ) |
---|
73 | #if SIMPLE_CONTEXT_SIG |
---|
74 | , m_cCUSigSCModel ( 4, 2, NUM_SIG_FLAG_CTX ) |
---|
75 | #else |
---|
76 | , m_cCUSigSCModel ( MAX_CU_DEPTH, 2, NUM_SIG_FLAG_CTX ) |
---|
77 | #endif |
---|
78 | #if PCP_SIGMAP_SIMPLE_LAST |
---|
79 | , m_cCuCtxLastX ( 1, 2, NUM_CTX_LAST_FLAG_XY ) |
---|
80 | , m_cCuCtxLastY ( 1, 2, NUM_CTX_LAST_FLAG_XY ) |
---|
81 | #else |
---|
82 | , m_cCULastSCModel ( MAX_CU_DEPTH, 2, NUM_LAST_FLAG_CTX ) |
---|
83 | #endif |
---|
84 | , m_cCUOneSCModel ( 1, 2, NUM_ONE_FLAG_CTX ) |
---|
85 | , m_cCUAbsSCModel ( 1, 2, NUM_ABS_FLAG_CTX ) |
---|
86 | , m_cMVPIdxSCModel ( 1, 1, NUM_MVP_IDX_CTX ) |
---|
87 | , m_cALFFlagSCModel ( 1, 1, NUM_ALF_FLAG_CTX ) |
---|
88 | , m_cALFUvlcSCModel ( 1, 1, NUM_ALF_UVLC_CTX ) |
---|
89 | , m_cALFSvlcSCModel ( 1, 1, NUM_ALF_SVLC_CTX ) |
---|
90 | #if MTK_SAO |
---|
91 | , m_cAOFlagSCModel ( 1, 1, NUM_AO_FLAG_CTX ) |
---|
92 | , m_cAOUvlcSCModel ( 1, 1, NUM_AO_UVLC_CTX ) |
---|
93 | , m_cAOSvlcSCModel ( 1, 1, NUM_AO_SVLC_CTX ) |
---|
94 | #endif |
---|
95 | , m_cViewIdxSCModel ( 1, 1, NUM_VIEW_IDX_CTX ) |
---|
96 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
97 | , m_cIntraDMMSCModel ( 1, 1, NUM_DMM_CTX ) |
---|
98 | , m_cIntraWedgeSCModel ( 1, 1, NUM_WEDGE_CTX ) |
---|
99 | #endif |
---|
100 | { |
---|
101 | } |
---|
102 | |
---|
103 | TDecSbac::~TDecSbac() |
---|
104 | { |
---|
105 | } |
---|
106 | |
---|
107 | // ==================================================================================================================== |
---|
108 | // Public member functions |
---|
109 | // ==================================================================================================================== |
---|
110 | |
---|
111 | Void TDecSbac::resetEntropy (TComSlice* pcSlice) |
---|
112 | { |
---|
113 | Int iQp = pcSlice->getSliceQp(); |
---|
114 | SliceType eSliceType = pcSlice->getSliceType(); |
---|
115 | |
---|
116 | m_cCUSplitFlagSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_SPLIT_FLAG ); |
---|
117 | m_cCUSkipFlagSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_SKIP_FLAG ); |
---|
118 | m_cCUMergeFlagExtSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_MERGE_FLAG_EXT ); |
---|
119 | m_cCUMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_MERGE_IDX_EXT ); |
---|
120 | m_cCUMVMergeIdxExtSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_MV_MERGE_IDX_EXT ); |
---|
121 | m_cResPredFlagSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_RES_PRED_FLAG ); |
---|
122 | m_cCUAlfCtrlFlagSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_ALF_CTRL_FLAG ); |
---|
123 | m_cCUPartSizeSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_PART_SIZE ); |
---|
124 | m_cCUPredModeSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_PRED_MODE ); |
---|
125 | m_cCUIntraPredSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_INTRA_PRED_MODE ); |
---|
126 | #if ADD_PLANAR_MODE |
---|
127 | m_cPlanarFlagSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_PLANARFLAG ); |
---|
128 | #endif |
---|
129 | m_cCUChromaPredSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_CHROMA_PRED_MODE ); |
---|
130 | m_cCUInterDirSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_INTER_DIR ); |
---|
131 | m_cCUMvdSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_MVD ); |
---|
132 | m_cCURefPicSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_REF_PIC ); |
---|
133 | m_cCUDeltaQpSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_DQP ); |
---|
134 | m_cCUQtCbfSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_QT_CBF ); |
---|
135 | m_cCUQtRootCbfSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_QT_ROOT_CBF ); |
---|
136 | m_cCUSigSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_SIG_FLAG ); |
---|
137 | #if PCP_SIGMAP_SIMPLE_LAST |
---|
138 | m_cCuCtxLastX.initBuffer ( eSliceType, iQp, (Short*)INIT_LAST_X ); |
---|
139 | m_cCuCtxLastY.initBuffer ( eSliceType, iQp, (Short*)INIT_LAST_Y ); |
---|
140 | #else |
---|
141 | m_cCULastSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_LAST_FLAG ); |
---|
142 | #endif |
---|
143 | m_cCUOneSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_ONE_FLAG ); |
---|
144 | m_cCUAbsSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_ABS_FLAG ); |
---|
145 | m_cMVPIdxSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_MVP_IDX ); |
---|
146 | m_cALFFlagSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_ALF_FLAG ); |
---|
147 | m_cALFUvlcSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_ALF_UVLC ); |
---|
148 | m_cALFSvlcSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_ALF_SVLC ); |
---|
149 | #if MTK_SAO |
---|
150 | m_cAOFlagSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_AO_FLAG ); |
---|
151 | m_cAOUvlcSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_AO_UVLC ); |
---|
152 | m_cAOSvlcSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_AO_SVLC ); |
---|
153 | #endif |
---|
154 | m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_TRANS_SUBDIV_FLAG ); |
---|
155 | m_cViewIdxSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_VIEW_IDX ); |
---|
156 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
157 | m_cIntraDMMSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_INTRA_DMM ); |
---|
158 | m_cIntraWedgeSCModel.initBuffer ( eSliceType, iQp, (Short*)INIT_INTRA_WEDGELET ); |
---|
159 | #endif |
---|
160 | |
---|
161 | m_uiLastDQpNonZero = 0; |
---|
162 | |
---|
163 | // new structure |
---|
164 | m_uiLastQp = iQp; |
---|
165 | |
---|
166 | m_pcTDecBinIf->start(); |
---|
167 | } |
---|
168 | |
---|
169 | Void TDecSbac::parseTerminatingBit( UInt& ruiBit ) |
---|
170 | { |
---|
171 | m_pcTDecBinIf->decodeBinTrm( ruiBit ); |
---|
172 | } |
---|
173 | |
---|
174 | |
---|
175 | Void TDecSbac::xReadUnaryMaxSymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset, UInt uiMaxSymbol ) |
---|
176 | { |
---|
177 | if (uiMaxSymbol == 0) |
---|
178 | { |
---|
179 | ruiSymbol = 0; |
---|
180 | return; |
---|
181 | } |
---|
182 | |
---|
183 | m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] ); |
---|
184 | |
---|
185 | if( ruiSymbol == 0 || uiMaxSymbol == 1 ) |
---|
186 | { |
---|
187 | return; |
---|
188 | } |
---|
189 | |
---|
190 | UInt uiSymbol = 0; |
---|
191 | UInt uiCont; |
---|
192 | |
---|
193 | do |
---|
194 | { |
---|
195 | m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] ); |
---|
196 | uiSymbol++; |
---|
197 | } |
---|
198 | while( uiCont && ( uiSymbol < uiMaxSymbol - 1 ) ); |
---|
199 | |
---|
200 | if( uiCont && ( uiSymbol == uiMaxSymbol - 1 ) ) |
---|
201 | { |
---|
202 | uiSymbol++; |
---|
203 | } |
---|
204 | |
---|
205 | ruiSymbol = uiSymbol; |
---|
206 | } |
---|
207 | |
---|
208 | #if MVD_CTX |
---|
209 | /** Decode a motion vector difference |
---|
210 | * \param riMvdComp motion vector difference |
---|
211 | * \param uiAbsSumL motion vector difference of left PU |
---|
212 | * \param uiAbsSumA motion vector difference of above PU |
---|
213 | * \param uiCtx index for context set based on vertical or horizontal component |
---|
214 | */ |
---|
215 | Void TDecSbac::xReadMvd( Int& riMvdComp, UInt uiAbsSumL, UInt uiAbsSumA, UInt uiCtx ) |
---|
216 | #else |
---|
217 | Void TDecSbac::xReadMvd( Int& riMvdComp, UInt uiAbsSum, UInt uiCtx ) |
---|
218 | #endif |
---|
219 | { |
---|
220 | UInt uiLocalCtx = 0; |
---|
221 | |
---|
222 | #if MVD_CTX |
---|
223 | uiLocalCtx += (uiAbsSumA>16) ? 1 : 0; |
---|
224 | uiLocalCtx += (uiAbsSumL>16) ? 1 : 0; |
---|
225 | #else |
---|
226 | if( uiAbsSum >= 3 ) |
---|
227 | { |
---|
228 | uiLocalCtx += ( uiAbsSum > 32) ? 2 : 1; |
---|
229 | } |
---|
230 | #endif |
---|
231 | |
---|
232 | riMvdComp = 0; |
---|
233 | |
---|
234 | UInt uiSymbol; |
---|
235 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMvdSCModel.get( 0, uiCtx, uiLocalCtx ) ); |
---|
236 | |
---|
237 | if (!uiSymbol) |
---|
238 | { |
---|
239 | return; |
---|
240 | } |
---|
241 | |
---|
242 | xReadExGolombMvd( uiSymbol, &m_cCUMvdSCModel.get( 0, uiCtx, 3 ), 3 ); |
---|
243 | uiSymbol++; |
---|
244 | |
---|
245 | UInt uiSign; |
---|
246 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
247 | |
---|
248 | riMvdComp = ( 0 != uiSign ) ? -(Int)uiSymbol : (Int)uiSymbol; |
---|
249 | |
---|
250 | return; |
---|
251 | } |
---|
252 | |
---|
253 | Void TDecSbac::xReadExGolombMvd( UInt& ruiSymbol, ContextModel* pcSCModel, UInt uiMaxBin ) |
---|
254 | { |
---|
255 | UInt uiSymbol; |
---|
256 | |
---|
257 | m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] ); |
---|
258 | |
---|
259 | if( !ruiSymbol ) |
---|
260 | { |
---|
261 | return; |
---|
262 | } |
---|
263 | |
---|
264 | m_pcTDecBinIf->decodeBin( uiSymbol, pcSCModel[1] ); |
---|
265 | |
---|
266 | ruiSymbol = 1; |
---|
267 | |
---|
268 | if( !uiSymbol ) |
---|
269 | { |
---|
270 | return; |
---|
271 | } |
---|
272 | |
---|
273 | pcSCModel += 2; |
---|
274 | UInt uiCount = 2; |
---|
275 | |
---|
276 | do |
---|
277 | { |
---|
278 | if( uiMaxBin == uiCount ) |
---|
279 | { |
---|
280 | pcSCModel++; |
---|
281 | } |
---|
282 | m_pcTDecBinIf->decodeBin( uiSymbol, *pcSCModel ); |
---|
283 | uiCount++; |
---|
284 | } |
---|
285 | while( uiSymbol && ( uiCount != 8 ) ); |
---|
286 | |
---|
287 | ruiSymbol = uiCount - 1; |
---|
288 | |
---|
289 | if( uiSymbol ) |
---|
290 | { |
---|
291 | xReadEpExGolomb( uiSymbol, 3 ); |
---|
292 | ruiSymbol += uiSymbol + 1; |
---|
293 | } |
---|
294 | |
---|
295 | return; |
---|
296 | } |
---|
297 | |
---|
298 | Void TDecSbac::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount ) |
---|
299 | { |
---|
300 | UInt uiSymbol = 0; |
---|
301 | UInt uiBit = 1; |
---|
302 | |
---|
303 | while( uiBit ) |
---|
304 | { |
---|
305 | m_pcTDecBinIf->decodeBinEP( uiBit ); |
---|
306 | uiSymbol += uiBit << uiCount++; |
---|
307 | } |
---|
308 | |
---|
309 | uiCount--; |
---|
310 | while( uiCount-- ) |
---|
311 | { |
---|
312 | m_pcTDecBinIf->decodeBinEP( uiBit ); |
---|
313 | uiSymbol += uiBit << uiCount; |
---|
314 | } |
---|
315 | |
---|
316 | ruiSymbol = uiSymbol; |
---|
317 | |
---|
318 | return; |
---|
319 | } |
---|
320 | |
---|
321 | Void TDecSbac::xReadUnarySymbol( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset ) |
---|
322 | { |
---|
323 | m_pcTDecBinIf->decodeBin( ruiSymbol, pcSCModel[0] ); |
---|
324 | |
---|
325 | if( !ruiSymbol ) |
---|
326 | { |
---|
327 | return; |
---|
328 | } |
---|
329 | |
---|
330 | UInt uiSymbol = 0; |
---|
331 | UInt uiCont; |
---|
332 | |
---|
333 | do |
---|
334 | { |
---|
335 | m_pcTDecBinIf->decodeBin( uiCont, pcSCModel[ iOffset ] ); |
---|
336 | uiSymbol++; |
---|
337 | } |
---|
338 | while( uiCont ); |
---|
339 | |
---|
340 | ruiSymbol = uiSymbol; |
---|
341 | } |
---|
342 | |
---|
343 | #if E253 |
---|
344 | /** Parsing of coeff_abs_level_minus3 |
---|
345 | * \param ruiSymbol reference to coeff_abs_level_minus3 |
---|
346 | * \param ruiGoRiceParam reference to Rice parameter |
---|
347 | * \returns Void |
---|
348 | */ |
---|
349 | Void TDecSbac::xReadGoRiceExGolomb( UInt &ruiSymbol, UInt &ruiGoRiceParam ) |
---|
350 | { |
---|
351 | Bool bExGolomb = false; |
---|
352 | UInt uiCodeWord = 0; |
---|
353 | UInt uiQuotient = 0; |
---|
354 | UInt uiRemainder = 0; |
---|
355 | UInt uiMaxVlc = g_auiGoRiceRange[ ruiGoRiceParam ]; |
---|
356 | UInt uiMaxPreLen = g_auiGoRicePrefixLen[ ruiGoRiceParam ]; |
---|
357 | |
---|
358 | do |
---|
359 | { |
---|
360 | uiQuotient++; |
---|
361 | m_pcTDecBinIf->decodeBinEP( uiCodeWord ); |
---|
362 | } |
---|
363 | while( uiCodeWord && uiQuotient < uiMaxPreLen ); |
---|
364 | |
---|
365 | uiCodeWord = 1 - uiCodeWord; |
---|
366 | uiQuotient -= uiCodeWord; |
---|
367 | |
---|
368 | for( UInt ui = 0; ui < ruiGoRiceParam; ui++ ) |
---|
369 | { |
---|
370 | m_pcTDecBinIf->decodeBinEP( uiCodeWord ); |
---|
371 | if( uiCodeWord ) |
---|
372 | { |
---|
373 | uiRemainder += 1 << ui; |
---|
374 | } |
---|
375 | } |
---|
376 | |
---|
377 | ruiSymbol = uiRemainder + ( uiQuotient << ruiGoRiceParam ); |
---|
378 | bExGolomb = ruiSymbol == ( uiMaxVlc + 1 ); |
---|
379 | |
---|
380 | if( bExGolomb ) |
---|
381 | { |
---|
382 | xReadEpExGolomb( uiCodeWord, 0 ); |
---|
383 | ruiSymbol += uiCodeWord; |
---|
384 | } |
---|
385 | |
---|
386 | ruiGoRiceParam = g_aauiGoRiceUpdate[ ruiGoRiceParam ][ min<UInt>( ruiSymbol, 15 ) ]; |
---|
387 | |
---|
388 | return; |
---|
389 | } |
---|
390 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
391 | Void TDecSbac::xReadExGolombLevel( UInt& ruiSymbol, ContextModel& rcSCModel ) |
---|
392 | { |
---|
393 | UInt uiSymbol; |
---|
394 | UInt uiCount = 0; |
---|
395 | do |
---|
396 | { |
---|
397 | m_pcTDecBinIf->decodeBin( uiSymbol, rcSCModel ); |
---|
398 | uiCount++; |
---|
399 | } |
---|
400 | while( uiSymbol && ( uiCount != 13 ) ); |
---|
401 | |
---|
402 | ruiSymbol = uiCount - 1; |
---|
403 | |
---|
404 | if( uiSymbol ) |
---|
405 | { |
---|
406 | xReadEpExGolomb( uiSymbol, 0 ); |
---|
407 | ruiSymbol += uiSymbol + 1; |
---|
408 | } |
---|
409 | |
---|
410 | return; |
---|
411 | } |
---|
412 | #endif |
---|
413 | #else |
---|
414 | Void TDecSbac::xReadExGolombLevel( UInt& ruiSymbol, ContextModel& rcSCModel ) |
---|
415 | { |
---|
416 | UInt uiSymbol; |
---|
417 | UInt uiCount = 0; |
---|
418 | do |
---|
419 | { |
---|
420 | m_pcTDecBinIf->decodeBin( uiSymbol, rcSCModel ); |
---|
421 | uiCount++; |
---|
422 | } |
---|
423 | while( uiSymbol && ( uiCount != 13 ) ); |
---|
424 | |
---|
425 | ruiSymbol = uiCount - 1; |
---|
426 | |
---|
427 | if( uiSymbol ) |
---|
428 | { |
---|
429 | xReadEpExGolomb( uiSymbol, 0 ); |
---|
430 | ruiSymbol += uiSymbol + 1; |
---|
431 | } |
---|
432 | |
---|
433 | return; |
---|
434 | } |
---|
435 | #endif |
---|
436 | |
---|
437 | Void TDecSbac::parseAlfCtrlDepth( UInt& ruiAlfCtrlDepth ) |
---|
438 | { |
---|
439 | UInt uiSymbol; |
---|
440 | xReadUnaryMaxSymbol( uiSymbol, m_cALFUvlcSCModel.get( 0 ), 1, g_uiMaxCUDepth - 1 ); |
---|
441 | ruiAlfCtrlDepth = uiSymbol; |
---|
442 | } |
---|
443 | |
---|
444 | Void TDecSbac::parseAlfCtrlFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
445 | { |
---|
446 | if( !m_bAlfCtrl ) |
---|
447 | { |
---|
448 | return; |
---|
449 | } |
---|
450 | |
---|
451 | if( uiDepth > m_uiMaxAlfCtrlDepth && !pcCU->isFirstAbsZorderIdxInDepth( uiAbsPartIdx, m_uiMaxAlfCtrlDepth ) ) |
---|
452 | { |
---|
453 | return; |
---|
454 | } |
---|
455 | |
---|
456 | UInt uiSymbol; |
---|
457 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUAlfCtrlFlagSCModel.get( 0, 0, pcCU->getCtxAlfCtrlFlag( uiAbsPartIdx ) ) ); |
---|
458 | |
---|
459 | if( uiDepth > m_uiMaxAlfCtrlDepth ) |
---|
460 | { |
---|
461 | pcCU->setAlfCtrlFlagSubParts( uiSymbol, uiAbsPartIdx, m_uiMaxAlfCtrlDepth ); |
---|
462 | } |
---|
463 | else |
---|
464 | { |
---|
465 | pcCU->setAlfCtrlFlagSubParts( uiSymbol, uiAbsPartIdx, uiDepth ); |
---|
466 | } |
---|
467 | } |
---|
468 | |
---|
469 | /** parse skip flag |
---|
470 | * \param pcCU |
---|
471 | * \param uiAbsPartIdx |
---|
472 | * \param uiDepth |
---|
473 | * \returns Void |
---|
474 | */ |
---|
475 | Void TDecSbac::parseSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
476 | { |
---|
477 | if( pcCU->getSlice()->isIntra() ) |
---|
478 | { |
---|
479 | return; |
---|
480 | } |
---|
481 | |
---|
482 | UInt uiSymbol = 0; |
---|
483 | UInt uiCtxSkip = pcCU->getCtxSkipFlag( uiAbsPartIdx ); |
---|
484 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSkipFlagSCModel.get( 0, 0, uiCtxSkip ) ); |
---|
485 | DTRACE_CABAC_V( g_nSymbolCounter++ ); |
---|
486 | DTRACE_CABAC_T( "\tSkipFlag" ); |
---|
487 | DTRACE_CABAC_T( "\tuiCtxSkip: "); |
---|
488 | DTRACE_CABAC_V( uiCtxSkip ); |
---|
489 | DTRACE_CABAC_T( "\tuiSymbol: "); |
---|
490 | DTRACE_CABAC_V( uiSymbol ); |
---|
491 | DTRACE_CABAC_T( "\n"); |
---|
492 | |
---|
493 | if( uiSymbol ) |
---|
494 | { |
---|
495 | pcCU->setPredModeSubParts( MODE_SKIP, uiAbsPartIdx, uiDepth ); |
---|
496 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
497 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
498 | |
---|
499 | #if HHI_MRG_SKIP |
---|
500 | pcCU->setMergeFlagSubParts( true , uiAbsPartIdx, 0, uiDepth ); |
---|
501 | #else |
---|
502 | TComMv cZeroMv(0,0); |
---|
503 | pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvd ( cZeroMv, SIZE_2Nx2N, uiAbsPartIdx, 0, uiDepth ); |
---|
504 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvd ( cZeroMv, SIZE_2Nx2N, uiAbsPartIdx, 0, uiDepth ); |
---|
505 | |
---|
506 | pcCU->setTrIdxSubParts( 0, uiAbsPartIdx, uiDepth ); |
---|
507 | pcCU->setCbfSubParts ( 0, 0, 0, uiAbsPartIdx, uiDepth ); |
---|
508 | |
---|
509 | if ( pcCU->getSlice()->isInterP() ) |
---|
510 | { |
---|
511 | pcCU->setInterDirSubParts( 1, uiAbsPartIdx, 0, uiDepth ); |
---|
512 | |
---|
513 | if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) |
---|
514 | pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllRefIdx( 0, SIZE_2Nx2N, uiAbsPartIdx, 0, uiDepth ); |
---|
515 | if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) |
---|
516 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( NOT_VALID, SIZE_2Nx2N, uiAbsPartIdx, 0, uiDepth ); |
---|
517 | } |
---|
518 | else |
---|
519 | { |
---|
520 | pcCU->setInterDirSubParts( 3, uiAbsPartIdx, 0, uiDepth ); |
---|
521 | |
---|
522 | if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) |
---|
523 | pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllRefIdx( 0, SIZE_2Nx2N, uiAbsPartIdx, 0, uiDepth ); |
---|
524 | if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) |
---|
525 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( 0, SIZE_2Nx2N, uiAbsPartIdx, 0, uiDepth ); |
---|
526 | } |
---|
527 | #endif // HHI_MRG_SKIP |
---|
528 | } |
---|
529 | } |
---|
530 | |
---|
531 | /** parse merge flag |
---|
532 | * \param pcCU |
---|
533 | * \param uiAbsPartIdx |
---|
534 | * \param uiDepth |
---|
535 | * \param uiPUIdx |
---|
536 | * \returns Void |
---|
537 | */ |
---|
538 | Void TDecSbac::parseMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) |
---|
539 | { |
---|
540 | UInt uiSymbol; |
---|
541 | UInt uiCtx = 0; |
---|
542 | #if CHANGE_MERGE_CONTEXT |
---|
543 | uiCtx = pcCU->getCtxMergeFlag( uiAbsPartIdx ); |
---|
544 | #else |
---|
545 | for(UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ ) |
---|
546 | { |
---|
547 | if( pcCU->getNeighbourCandIdx( uiIter, uiAbsPartIdx ) == uiIter + 1 ) |
---|
548 | { |
---|
549 | if( uiIter == 0 ) |
---|
550 | { |
---|
551 | uiCtx++; |
---|
552 | } |
---|
553 | else if( uiIter == 1 ) |
---|
554 | { |
---|
555 | uiCtx++; |
---|
556 | } |
---|
557 | } |
---|
558 | } |
---|
559 | #endif |
---|
560 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMergeFlagExtSCModel.get( 0, 0, uiCtx ) ); |
---|
561 | pcCU->setMergeFlagSubParts( uiSymbol ? true : false, uiAbsPartIdx, uiPUIdx, uiDepth ); |
---|
562 | |
---|
563 | DTRACE_CABAC_V( g_nSymbolCounter++ ); |
---|
564 | DTRACE_CABAC_T( "\tMergeFlag: " ); |
---|
565 | DTRACE_CABAC_V( uiSymbol ); |
---|
566 | DTRACE_CABAC_T( "\tAddress: " ); |
---|
567 | DTRACE_CABAC_V( pcCU->getAddr() ); |
---|
568 | DTRACE_CABAC_T( "\tuiAbsPartIdx: " ); |
---|
569 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
570 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
571 | { |
---|
572 | DTRACE_CABAC_T( "\tNumMrgCand: " ); |
---|
573 | DTRACE_CABAC_V( ui ); |
---|
574 | DTRACE_CABAC_T( "\t==\t" ); |
---|
575 | DTRACE_CABAC_V( UInt( pcCU->getNeighbourCandIdx( ui, uiAbsPartIdx ) ) ); |
---|
576 | } |
---|
577 | DTRACE_CABAC_T( "\n" ); |
---|
578 | } |
---|
579 | |
---|
580 | |
---|
581 | #if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI |
---|
582 | Void TDecSbac::parseMergeIndexMV( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
583 | { |
---|
584 | #if HHI_MPI |
---|
585 | const Bool bMVIAvailable = pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE; |
---|
586 | const UInt uiMviMergePos = bMVIAvailable ? HHI_MPI_MERGE_POS : MRG_MAX_NUM_CANDS; |
---|
587 | #endif |
---|
588 | //--- set number of candidates and availability --- |
---|
589 | Bool abAvailable[ MRG_MAX_NUM_CANDS ]; |
---|
590 | UInt uiNumCand = 0; |
---|
591 | for( UInt uiIdx = 0; uiIdx < MRG_MAX_NUM_CANDS; uiIdx++ ) |
---|
592 | { |
---|
593 | #if HHI_MPI |
---|
594 | if( uiIdx == uiMviMergePos ) |
---|
595 | { |
---|
596 | abAvailable[ uiIdx ] = true; |
---|
597 | uiNumCand++; |
---|
598 | } |
---|
599 | else if( uiIdx > uiMviMergePos ) |
---|
600 | { |
---|
601 | if( ( abAvailable[ uiIdx ] = ( pcCU->getNeighbourCandIdx( uiIdx - 1, uiAbsPartIdx ) == uiIdx ) ) ) |
---|
602 | { |
---|
603 | uiNumCand++; |
---|
604 | } |
---|
605 | } |
---|
606 | else |
---|
607 | #endif |
---|
608 | if( ( abAvailable[ uiIdx ] = ( pcCU->getNeighbourCandIdx( uiIdx, uiAbsPartIdx ) == uiIdx + 1 ) ) ) |
---|
609 | { |
---|
610 | uiNumCand++; |
---|
611 | } |
---|
612 | } |
---|
613 | AOF( uiNumCand > 1 ); |
---|
614 | |
---|
615 | //--- determine contexts --- |
---|
616 | AOF( NUM_MV_MERGE_IDX_EXT_CTX >= MRG_MAX_NUM_CANDS - 1 ); |
---|
617 | UInt auiCtx[ MRG_MAX_NUM_CANDS - 1 ]; |
---|
618 | for( UInt uiIdx = 0; uiIdx < MRG_MAX_NUM_CANDS - 1; uiIdx++ ) |
---|
619 | { |
---|
620 | auiCtx[ uiIdx ] = MRG_MAX_NUM_CANDS; |
---|
621 | if( uiNumCand > uiIdx + 1 ) |
---|
622 | { |
---|
623 | Bool bAvComb = false; |
---|
624 | for( UInt uiCId = uiIdx; uiCId < MRG_MAX_NUM_CANDS - 1; uiCId++ ) |
---|
625 | { |
---|
626 | bAvComb = ( bAvComb || abAvailable[ uiCId ] ); |
---|
627 | if( abAvailable[ uiCId + 1 ] && bAvComb ) |
---|
628 | { |
---|
629 | auiCtx[ uiIdx ] = uiCId; |
---|
630 | break; |
---|
631 | } |
---|
632 | } |
---|
633 | AOT( auiCtx[ uiIdx ] == MRG_MAX_NUM_CANDS ); |
---|
634 | } |
---|
635 | } |
---|
636 | |
---|
637 | //--- parse unary index --- |
---|
638 | UInt uiUnaryIdx = 0; |
---|
639 | for( ; uiUnaryIdx < uiNumCand - 1; uiUnaryIdx++ ) |
---|
640 | { |
---|
641 | UInt uiSymbol = 0; |
---|
642 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMVMergeIdxExtSCModel.get( 0, 0, auiCtx[uiUnaryIdx] ) ); |
---|
643 | if( uiSymbol == 0 ) |
---|
644 | { |
---|
645 | break; |
---|
646 | } |
---|
647 | } |
---|
648 | |
---|
649 | //--- determine merge index --- |
---|
650 | ruiMergeIndex = uiUnaryIdx; |
---|
651 | for( UInt uiIdx = 0; uiIdx <= ruiMergeIndex; uiIdx++ ) |
---|
652 | { |
---|
653 | if( ! abAvailable[ uiIdx ] ) |
---|
654 | { |
---|
655 | ruiMergeIndex++; |
---|
656 | } |
---|
657 | } |
---|
658 | |
---|
659 | #if HHI_MPI |
---|
660 | if( ruiMergeIndex > uiMviMergePos ) |
---|
661 | { |
---|
662 | ruiMergeIndex--; |
---|
663 | } |
---|
664 | else if( ruiMergeIndex == uiMviMergePos ) |
---|
665 | { |
---|
666 | pcCU->setTextureModeDepthSubParts( uiDepth, uiAbsPartIdx, uiDepth ); |
---|
667 | } |
---|
668 | #endif |
---|
669 | |
---|
670 | //--- trace --- |
---|
671 | DTRACE_CABAC_V( g_nSymbolCounter++ ); |
---|
672 | DTRACE_CABAC_T( "\tparseMergeIndex():" ); |
---|
673 | DTRACE_CABAC_T( " MRGIdx = " ); |
---|
674 | DTRACE_CABAC_V( ruiMergeIndex ); |
---|
675 | DTRACE_CABAC_T( " UnaryIdx = " ); |
---|
676 | DTRACE_CABAC_V( uiUnaryIdx ); |
---|
677 | DTRACE_CABAC_T( " NumCand = " ); |
---|
678 | DTRACE_CABAC_V( uiNumCand ); |
---|
679 | DTRACE_CABAC_T( " Availibility = " ); |
---|
680 | for( UInt uiIdx = 0; uiIdx < MRG_MAX_NUM_CANDS; uiIdx++ ) |
---|
681 | { |
---|
682 | DTRACE_CABAC_V( abAvailable[ uiIdx ] ? 1 : 0 ); |
---|
683 | } |
---|
684 | DTRACE_CABAC_T( " Contexts = " ); |
---|
685 | for( UInt uiIdx = 0; uiIdx < MRG_MAX_NUM_CANDS - 1; uiIdx++ ) |
---|
686 | { |
---|
687 | DTRACE_CABAC_V( auiCtx[ uiIdx ] ); |
---|
688 | } |
---|
689 | DTRACE_CABAC_T( "\n" ); |
---|
690 | } |
---|
691 | #endif |
---|
692 | |
---|
693 | |
---|
694 | Void TDecSbac::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
695 | { |
---|
696 | #if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI |
---|
697 | if( |
---|
698 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
699 | ( pcCU->getSlice()->getSPS()->getViewId() > 0 && ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) == PDM_USE_FOR_MERGE ) || |
---|
700 | #endif |
---|
701 | #if HHI_MPI |
---|
702 | ( pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) || |
---|
703 | #endif |
---|
704 | 0 |
---|
705 | ) |
---|
706 | { |
---|
707 | parseMergeIndexMV( pcCU, ruiMergeIndex, uiAbsPartIdx, uiDepth ); |
---|
708 | return; |
---|
709 | } |
---|
710 | #endif |
---|
711 | |
---|
712 | Bool bLeftInvolved = false; |
---|
713 | Bool bAboveInvolved = false; |
---|
714 | Bool bCollocatedInvolved = false; |
---|
715 | Bool bCornerInvolved = false; |
---|
716 | Bool bCornerBLInvolved = false; |
---|
717 | UInt uiNumCand = 0; |
---|
718 | for( UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; ++uiIter ) |
---|
719 | { |
---|
720 | if( pcCU->getNeighbourCandIdx( uiIter, uiAbsPartIdx ) == uiIter + 1 ) |
---|
721 | { |
---|
722 | uiNumCand++; |
---|
723 | if( uiIter == 0 ) |
---|
724 | { |
---|
725 | bLeftInvolved = true; |
---|
726 | } |
---|
727 | else if( uiIter == 1 ) |
---|
728 | { |
---|
729 | bAboveInvolved = true; |
---|
730 | } |
---|
731 | else if( uiIter == 2 ) |
---|
732 | { |
---|
733 | bCollocatedInvolved = true; |
---|
734 | } |
---|
735 | else if( uiIter == 3 ) |
---|
736 | { |
---|
737 | bCornerInvolved = true; |
---|
738 | } |
---|
739 | else if( uiIter == 4 ) |
---|
740 | { |
---|
741 | bCornerBLInvolved = true; |
---|
742 | } |
---|
743 | } |
---|
744 | } |
---|
745 | assert( uiNumCand > 1 ); |
---|
746 | |
---|
747 | UInt auiCtx[4] = { 0, 0, 0, 3 }; |
---|
748 | if( bLeftInvolved && bAboveInvolved ) |
---|
749 | { |
---|
750 | auiCtx[0] = 0; |
---|
751 | } |
---|
752 | else if( bLeftInvolved || bAboveInvolved ) |
---|
753 | { |
---|
754 | auiCtx[0] = bCollocatedInvolved ? 1 : 2; |
---|
755 | } |
---|
756 | else |
---|
757 | { |
---|
758 | auiCtx[0] = bCollocatedInvolved ? 2 : 3; |
---|
759 | } |
---|
760 | |
---|
761 | if( uiNumCand >= 3 ) |
---|
762 | { |
---|
763 | if( bAboveInvolved ) |
---|
764 | { |
---|
765 | auiCtx[1] = bCollocatedInvolved ? 1 : 2; |
---|
766 | } |
---|
767 | else |
---|
768 | { |
---|
769 | auiCtx[1] = bCollocatedInvolved ? 2 : 3; |
---|
770 | } |
---|
771 | } |
---|
772 | |
---|
773 | if( uiNumCand >= 4 ) |
---|
774 | { |
---|
775 | auiCtx[2] = bCollocatedInvolved ? 2 : 3; |
---|
776 | } |
---|
777 | |
---|
778 | UInt uiUnaryIdx = 0; |
---|
779 | for( ; uiUnaryIdx < uiNumCand - 1; ++uiUnaryIdx ) |
---|
780 | { |
---|
781 | UInt uiSymbol = 0; |
---|
782 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, auiCtx[uiUnaryIdx] ) ); |
---|
783 | if( uiSymbol == 0 ) |
---|
784 | { |
---|
785 | break; |
---|
786 | } |
---|
787 | } |
---|
788 | |
---|
789 | if( !bLeftInvolved ) |
---|
790 | { |
---|
791 | ++uiUnaryIdx; |
---|
792 | } |
---|
793 | if( !bAboveInvolved && uiUnaryIdx >= 1 ) |
---|
794 | { |
---|
795 | ++uiUnaryIdx; |
---|
796 | } |
---|
797 | if( !bCollocatedInvolved && uiUnaryIdx >= 2 ) |
---|
798 | { |
---|
799 | ++uiUnaryIdx; |
---|
800 | } |
---|
801 | if( !bCornerInvolved && uiUnaryIdx >= 3 ) |
---|
802 | { |
---|
803 | ++uiUnaryIdx; |
---|
804 | } |
---|
805 | |
---|
806 | ruiMergeIndex = uiUnaryIdx; |
---|
807 | |
---|
808 | DTRACE_CABAC_V( g_nSymbolCounter++ ) |
---|
809 | DTRACE_CABAC_T( "\tparseMergeIndex()" ) |
---|
810 | DTRACE_CABAC_T( "\tuiMRGIdx= " ) |
---|
811 | DTRACE_CABAC_V( ruiMergeIndex ) |
---|
812 | DTRACE_CABAC_T( "\tuiNumCand= " ) |
---|
813 | DTRACE_CABAC_V( uiNumCand ) |
---|
814 | DTRACE_CABAC_T( "\tbLeftInvolved= " ) |
---|
815 | DTRACE_CABAC_V( bLeftInvolved ) |
---|
816 | DTRACE_CABAC_T( "\tbAboveInvolved= " ) |
---|
817 | DTRACE_CABAC_V( bAboveInvolved ) |
---|
818 | DTRACE_CABAC_T( "\tbCollocatedInvolved= " ) |
---|
819 | DTRACE_CABAC_V( bCollocatedInvolved ) |
---|
820 | DTRACE_CABAC_T( "\tbCornerRTInvolved= " ) |
---|
821 | DTRACE_CABAC_V( bCornerInvolved ) |
---|
822 | DTRACE_CABAC_T( "\tbCornerBLInvolved= " ) |
---|
823 | DTRACE_CABAC_V( bCornerBLInvolved ) |
---|
824 | DTRACE_CABAC_T( "\n" ) |
---|
825 | } |
---|
826 | |
---|
827 | |
---|
828 | Void |
---|
829 | TDecSbac::parseResPredFlag( TComDataCU* pcCU, Bool& rbResPredFlag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
830 | { |
---|
831 | UInt uiCtx = 0; |
---|
832 | UInt uiSymbol = 0; |
---|
833 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cResPredFlagSCModel.get( 0, 0, uiCtx ) ); |
---|
834 | rbResPredFlag = ( uiSymbol != 0 ); |
---|
835 | } |
---|
836 | |
---|
837 | |
---|
838 | Void TDecSbac::parseMVPIdx ( TComDataCU* pcCU, Int& riMVPIdx, Int iMVPNum, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
839 | { |
---|
840 | UInt uiSymbol; |
---|
841 | xReadUnaryMaxSymbol(uiSymbol, m_cMVPIdxSCModel.get(0), 1, iMVPNum-1); |
---|
842 | |
---|
843 | riMVPIdx = uiSymbol; |
---|
844 | } |
---|
845 | |
---|
846 | Void TDecSbac::parseSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
847 | { |
---|
848 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
849 | { |
---|
850 | pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx ); |
---|
851 | return; |
---|
852 | } |
---|
853 | |
---|
854 | UInt uiSymbol; |
---|
855 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ) ) ); |
---|
856 | DTRACE_CABAC_V( g_nSymbolCounter++ ) |
---|
857 | DTRACE_CABAC_T( "\tSplitFlag\n" ) |
---|
858 | pcCU->setDepthSubParts( uiDepth + uiSymbol, uiAbsPartIdx ); |
---|
859 | |
---|
860 | return; |
---|
861 | } |
---|
862 | |
---|
863 | /** parse partition size |
---|
864 | * \param pcCU |
---|
865 | * \param uiAbsPartIdx |
---|
866 | * \param uiDepth |
---|
867 | * \returns Void |
---|
868 | */ |
---|
869 | Void TDecSbac::parsePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
870 | { |
---|
871 | UInt uiSymbol, uiMode = 0; |
---|
872 | PartSize eMode; |
---|
873 | |
---|
874 | if ( pcCU->isIntra( uiAbsPartIdx ) ) |
---|
875 | { |
---|
876 | #if MTK_DISABLE_INTRA_NxN_SPLIT |
---|
877 | uiSymbol = 1; |
---|
878 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
879 | #endif |
---|
880 | { |
---|
881 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
882 | } |
---|
883 | eMode = uiSymbol ? SIZE_2Nx2N : SIZE_NxN; |
---|
884 | } |
---|
885 | else |
---|
886 | { |
---|
887 | #if HHI_RMP_SWITCH |
---|
888 | if ( !pcCU->getSlice()->getSPS()->getUseRMP()) |
---|
889 | { |
---|
890 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
891 | if( uiSymbol ) |
---|
892 | uiMode = 0; |
---|
893 | else |
---|
894 | uiMode = 3; |
---|
895 | } |
---|
896 | else |
---|
897 | #endif |
---|
898 | { |
---|
899 | UInt uiMaxNumBits = 3; |
---|
900 | for ( UInt ui = 0; ui < uiMaxNumBits; ui++ ) |
---|
901 | { |
---|
902 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) ); |
---|
903 | if ( uiSymbol ) |
---|
904 | { |
---|
905 | break; |
---|
906 | } |
---|
907 | uiMode++; |
---|
908 | } |
---|
909 | } |
---|
910 | eMode = (PartSize) uiMode; |
---|
911 | |
---|
912 | if (pcCU->getSlice()->isInterB() && uiMode == 3) |
---|
913 | { |
---|
914 | #if HHI_DISABLE_INTER_NxN_SPLIT |
---|
915 | uiSymbol = 0; |
---|
916 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
917 | #endif |
---|
918 | { |
---|
919 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3) ); |
---|
920 | } |
---|
921 | |
---|
922 | if (uiSymbol == 0) |
---|
923 | { |
---|
924 | pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth ); |
---|
925 | #if MTK_DISABLE_INTRA_NxN_SPLIT |
---|
926 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
927 | #endif |
---|
928 | { |
---|
929 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 4) ); |
---|
930 | } |
---|
931 | if (uiSymbol == 0) |
---|
932 | eMode = SIZE_2Nx2N; |
---|
933 | } |
---|
934 | } |
---|
935 | } |
---|
936 | |
---|
937 | pcCU->setPartSizeSubParts( eMode, uiAbsPartIdx, uiDepth ); |
---|
938 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
939 | |
---|
940 | UInt uiTrLevel = 0; |
---|
941 | |
---|
942 | UInt uiWidthInBit = g_aucConvertToBit[pcCU->getWidth(uiAbsPartIdx)]+2; |
---|
943 | UInt uiTrSizeInBit = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxTrSize()]+2; |
---|
944 | uiTrLevel = uiWidthInBit >= uiTrSizeInBit ? uiWidthInBit - uiTrSizeInBit : 0; |
---|
945 | |
---|
946 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA ) |
---|
947 | { |
---|
948 | if( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) |
---|
949 | { |
---|
950 | pcCU->setTrIdxSubParts( 1+uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
951 | } |
---|
952 | else |
---|
953 | { |
---|
954 | pcCU->setTrIdxSubParts( uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
955 | } |
---|
956 | } |
---|
957 | } |
---|
958 | |
---|
959 | /** parse prediction mode |
---|
960 | * \param pcCU |
---|
961 | * \param uiAbsPartIdx |
---|
962 | * \param uiDepth |
---|
963 | * \returns Void |
---|
964 | */ |
---|
965 | Void TDecSbac::parsePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
966 | { |
---|
967 | if( pcCU->getSlice()->isIntra() ) |
---|
968 | { |
---|
969 | pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth ); |
---|
970 | return; |
---|
971 | } |
---|
972 | |
---|
973 | UInt uiSymbol; |
---|
974 | Int iPredMode = MODE_INTER; |
---|
975 | if ( pcCU->getSlice()->isInterB() ) |
---|
976 | { |
---|
977 | pcCU->setPredModeSubParts( (PredMode)iPredMode, uiAbsPartIdx, uiDepth ); |
---|
978 | return; |
---|
979 | } |
---|
980 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPredModeSCModel.get( 0, 0, 1 ) ); |
---|
981 | iPredMode += uiSymbol; |
---|
982 | pcCU->setPredModeSubParts( (PredMode)iPredMode, uiAbsPartIdx, uiDepth ); |
---|
983 | } |
---|
984 | |
---|
985 | #if HHI_DMM_WEDGE_INTRA |
---|
986 | Void TDecSbac::xParseWedgeFullInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
987 | { |
---|
988 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
989 | Int iBits = g_aucWedgeFullBitsListIdx[iIntraIdx]; |
---|
990 | |
---|
991 | UInt uiSymbol, uiTabIdx = 0; |
---|
992 | for ( Int i = 0; i < iBits; i++ ) |
---|
993 | { |
---|
994 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraWedgeSCModel.get(0, 0, 0) ); |
---|
995 | uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0; |
---|
996 | uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0; |
---|
997 | uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0; |
---|
998 | uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0; |
---|
999 | uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0; |
---|
1000 | uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0; |
---|
1001 | uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0; |
---|
1002 | uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0; |
---|
1003 | uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0; |
---|
1004 | uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0; |
---|
1005 | uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0; |
---|
1006 | uiTabIdx += ( uiSymbol && i == 11 ) ? 2048 : 0; |
---|
1007 | uiTabIdx += ( uiSymbol && i == 12 ) ? 4096 : 0; |
---|
1008 | } |
---|
1009 | pcCU->setWedgeFullTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth ); |
---|
1010 | } |
---|
1011 | |
---|
1012 | Void TDecSbac::xParseWedgeFullDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1013 | { |
---|
1014 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
1015 | Int iBits = g_aucWedgeFullBitsListIdx[iIntraIdx]; |
---|
1016 | |
---|
1017 | UInt uiSymbol, uiTabIdx = 0; |
---|
1018 | for ( Int i = 0; i < iBits; i++ ) |
---|
1019 | { |
---|
1020 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraWedgeSCModel.get(0, 0, 0) ); |
---|
1021 | uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0; |
---|
1022 | uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0; |
---|
1023 | uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0; |
---|
1024 | uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0; |
---|
1025 | uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0; |
---|
1026 | uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0; |
---|
1027 | uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0; |
---|
1028 | uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0; |
---|
1029 | uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0; |
---|
1030 | uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0; |
---|
1031 | uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0; |
---|
1032 | uiTabIdx += ( uiSymbol && i == 11 ) ? 2048 : 0; |
---|
1033 | uiTabIdx += ( uiSymbol && i == 12 ) ? 4096 : 0; |
---|
1034 | } |
---|
1035 | pcCU->setWedgeFullTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth ); |
---|
1036 | |
---|
1037 | UInt uiDC1, uiDC2; |
---|
1038 | xReadExGolombLevel( uiDC1, m_cIntraWedgeSCModel.get(0, 0, 1) ); |
---|
1039 | Int iDC1 = uiDC1; |
---|
1040 | if ( uiDC1 ) |
---|
1041 | { |
---|
1042 | UInt uiSign; |
---|
1043 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1044 | if ( uiSign ) |
---|
1045 | { |
---|
1046 | iDC1 = -iDC1; |
---|
1047 | } |
---|
1048 | } |
---|
1049 | xReadExGolombLevel( uiDC2, m_cIntraWedgeSCModel.get(0, 0, 1) ); |
---|
1050 | Int iDC2 = uiDC2; |
---|
1051 | if ( uiDC2 ) |
---|
1052 | { |
---|
1053 | UInt uiSign; |
---|
1054 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1055 | if ( uiSign ) |
---|
1056 | { |
---|
1057 | iDC2 = -iDC2; |
---|
1058 | } |
---|
1059 | } |
---|
1060 | |
---|
1061 | pcCU->setWedgeFullDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
1062 | pcCU->setWedgeFullDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
1063 | } |
---|
1064 | |
---|
1065 | Void TDecSbac::xParseWedgePredDirInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1066 | { |
---|
1067 | if( DMM_WEDGE_PREDDIR_DELTAEND_MAX > 0 ) |
---|
1068 | { |
---|
1069 | UInt uiDeltaEnd = 0; |
---|
1070 | m_pcTDecBinIf->decodeBin( uiDeltaEnd, m_cIntraWedgeSCModel.get(0, 0, 3) ); |
---|
1071 | |
---|
1072 | Int iDeltaEnd; |
---|
1073 | if( uiDeltaEnd != 0 ) |
---|
1074 | { |
---|
1075 | UInt uiAbsValMinus1; |
---|
1076 | UInt uiSymbol; |
---|
1077 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraWedgeSCModel.get(0, 0, 3) ); uiAbsValMinus1 = uiSymbol; |
---|
1078 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraWedgeSCModel.get(0, 0, 3) ); uiAbsValMinus1 |= uiSymbol << 1; |
---|
1079 | uiDeltaEnd = uiAbsValMinus1 + 1; |
---|
1080 | |
---|
1081 | iDeltaEnd = uiDeltaEnd; |
---|
1082 | UInt uiSign; |
---|
1083 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1084 | if( uiSign ) |
---|
1085 | { |
---|
1086 | iDeltaEnd = -iDeltaEnd; |
---|
1087 | } |
---|
1088 | } |
---|
1089 | else |
---|
1090 | { |
---|
1091 | iDeltaEnd = 0; |
---|
1092 | } |
---|
1093 | pcCU->setWedgePredDirDeltaEndSubParts( iDeltaEnd, uiAbsPartIdx, uiDepth ); |
---|
1094 | } |
---|
1095 | } |
---|
1096 | |
---|
1097 | Void TDecSbac::xParseWedgePredDirDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1098 | { |
---|
1099 | if( DMM_WEDGE_PREDDIR_DELTAEND_MAX > 0 ) |
---|
1100 | { |
---|
1101 | UInt uiDeltaEnd = 0; |
---|
1102 | m_pcTDecBinIf->decodeBin( uiDeltaEnd, m_cIntraWedgeSCModel.get(0, 0, 3) ); |
---|
1103 | |
---|
1104 | Int iDeltaEnd; |
---|
1105 | if( uiDeltaEnd != 0 ) |
---|
1106 | { |
---|
1107 | UInt uiAbsValMinus1; |
---|
1108 | UInt uiSymbol; |
---|
1109 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraWedgeSCModel.get(0, 0, 3) ); uiAbsValMinus1 = uiSymbol; |
---|
1110 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraWedgeSCModel.get(0, 0, 3) ); uiAbsValMinus1 |= uiSymbol << 1; |
---|
1111 | uiDeltaEnd = uiAbsValMinus1 + 1; |
---|
1112 | |
---|
1113 | iDeltaEnd = uiDeltaEnd; |
---|
1114 | UInt uiSign; |
---|
1115 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1116 | if( uiSign ) |
---|
1117 | { |
---|
1118 | iDeltaEnd = -iDeltaEnd; |
---|
1119 | } |
---|
1120 | } |
---|
1121 | else |
---|
1122 | { |
---|
1123 | iDeltaEnd = 0; |
---|
1124 | } |
---|
1125 | |
---|
1126 | pcCU->setWedgePredDirDeltaEndSubParts( iDeltaEnd, uiAbsPartIdx, uiDepth ); |
---|
1127 | } |
---|
1128 | |
---|
1129 | UInt uiDC1, uiDC2; |
---|
1130 | xReadExGolombLevel( uiDC1, m_cIntraWedgeSCModel.get(0, 0, 1) ); |
---|
1131 | Int iDC1 = uiDC1; |
---|
1132 | if ( uiDC1 ) |
---|
1133 | { |
---|
1134 | UInt uiSign; |
---|
1135 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1136 | if ( uiSign ) |
---|
1137 | { |
---|
1138 | iDC1 = -iDC1; |
---|
1139 | } |
---|
1140 | } |
---|
1141 | xReadExGolombLevel( uiDC2, m_cIntraWedgeSCModel.get(0, 0, 1) ); |
---|
1142 | Int iDC2 = uiDC2; |
---|
1143 | if ( uiDC2 ) |
---|
1144 | { |
---|
1145 | UInt uiSign; |
---|
1146 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1147 | if ( uiSign ) |
---|
1148 | { |
---|
1149 | iDC2 = -iDC2; |
---|
1150 | } |
---|
1151 | } |
---|
1152 | |
---|
1153 | pcCU->setWedgePredDirDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
1154 | pcCU->setWedgePredDirDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
1155 | } |
---|
1156 | #endif |
---|
1157 | #if HHI_DMM_PRED_TEX |
---|
1158 | Void TDecSbac::xParseWedgePredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1159 | { |
---|
1160 | UInt uiDC1, uiDC2; |
---|
1161 | xReadExGolombLevel( uiDC1, m_cIntraWedgeSCModel.get(0, 0, 1) ); |
---|
1162 | Int iDC1 = uiDC1; |
---|
1163 | if ( uiDC1 ) |
---|
1164 | { |
---|
1165 | UInt uiSign; |
---|
1166 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1167 | if ( uiSign ) |
---|
1168 | { |
---|
1169 | iDC1 = -iDC1; |
---|
1170 | } |
---|
1171 | } |
---|
1172 | xReadExGolombLevel( uiDC2, m_cIntraWedgeSCModel.get(0, 0, 1) ); |
---|
1173 | Int iDC2 = uiDC2; |
---|
1174 | if ( uiDC2 ) |
---|
1175 | { |
---|
1176 | UInt uiSign; |
---|
1177 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1178 | if ( uiSign ) |
---|
1179 | { |
---|
1180 | iDC2 = -iDC2; |
---|
1181 | } |
---|
1182 | } |
---|
1183 | |
---|
1184 | pcCU->setWedgePredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
1185 | pcCU->setWedgePredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
1186 | } |
---|
1187 | |
---|
1188 | Void TDecSbac::xParseContourPredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1189 | { |
---|
1190 | UInt uiDC1, uiDC2; |
---|
1191 | xReadExGolombLevel( uiDC1, m_cIntraWedgeSCModel.get(0, 0, 1) ); |
---|
1192 | Int iDC1 = uiDC1; |
---|
1193 | if ( uiDC1 ) |
---|
1194 | { |
---|
1195 | UInt uiSign; |
---|
1196 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1197 | if ( uiSign ) |
---|
1198 | { |
---|
1199 | iDC1 = -iDC1; |
---|
1200 | } |
---|
1201 | } |
---|
1202 | xReadExGolombLevel( uiDC2, m_cIntraWedgeSCModel.get(0, 0, 1) ); |
---|
1203 | Int iDC2 = uiDC2; |
---|
1204 | if ( uiDC2 ) |
---|
1205 | { |
---|
1206 | UInt uiSign; |
---|
1207 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1208 | if ( uiSign ) |
---|
1209 | { |
---|
1210 | iDC2 = -iDC2; |
---|
1211 | } |
---|
1212 | } |
---|
1213 | |
---|
1214 | pcCU->setContourPredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
1215 | pcCU->setContourPredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
1216 | } |
---|
1217 | #endif |
---|
1218 | |
---|
1219 | #if MTK_DCM_MPM |
---|
1220 | Void TDecSbac::parseIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1221 | { |
---|
1222 | Int uiIPredMode; |
---|
1223 | UInt uiSymbol; |
---|
1224 | |
---|
1225 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1226 | UInt uiFlag = 0; |
---|
1227 | if ( pcCU->getSlice()->getSPS()->isDepth() && pcCU->getSlice()->getSPS()->getUseDMM() && g_uiMaxCUWidth>>uiDepth < 64 ) |
---|
1228 | { |
---|
1229 | m_pcTDecBinIf->decodeBin( uiFlag, m_cIntraDMMSCModel.get(0, 0, 0) ); |
---|
1230 | } |
---|
1231 | if ( uiFlag ) |
---|
1232 | { |
---|
1233 | UInt uiDMMode; |
---|
1234 | |
---|
1235 | #if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX |
---|
1236 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode = uiSymbol; |
---|
1237 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode |= uiSymbol << 1; |
---|
1238 | if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 ) |
---|
1239 | { |
---|
1240 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode |= uiSymbol << 2; |
---|
1241 | } |
---|
1242 | #else |
---|
1243 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode = uiSymbol; |
---|
1244 | if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 ) |
---|
1245 | { |
---|
1246 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode |= uiSymbol << 1; |
---|
1247 | } |
---|
1248 | #endif |
---|
1249 | uiIPredMode = uiDMMode + MAX_MODE_ID_INTRA_DIR + 1; |
---|
1250 | |
---|
1251 | #if HHI_DMM_WEDGE_INTRA |
---|
1252 | if( uiIPredMode == DMM_WEDGE_FULL_IDX ) { xParseWedgeFullInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1253 | if( uiIPredMode == DMM_WEDGE_FULL_D_IDX ) { xParseWedgeFullDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1254 | if( uiIPredMode == DMM_WEDGE_PREDDIR_IDX ) { xParseWedgePredDirInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1255 | if( uiIPredMode == DMM_WEDGE_PREDDIR_D_IDX ) { xParseWedgePredDirDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1256 | #endif |
---|
1257 | #if HHI_DMM_PRED_TEX |
---|
1258 | if( uiIPredMode == DMM_WEDGE_PREDTEX_D_IDX ) { xParseWedgePredTexDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1259 | if( uiIPredMode == DMM_CONTOUR_PREDTEX_D_IDX ) { xParseContourPredTexDeltaInfo( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1260 | #endif |
---|
1261 | } |
---|
1262 | else |
---|
1263 | #endif |
---|
1264 | { |
---|
1265 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
1266 | |
---|
1267 | Int uiPreds[2] = {-1, -1}; |
---|
1268 | Int uiPredNum = pcCU->getIntraDirLumaPredictor(uiAbsPartIdx, uiPreds); |
---|
1269 | |
---|
1270 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 0) ); |
---|
1271 | |
---|
1272 | if ( uiSymbol ) |
---|
1273 | { |
---|
1274 | if(uiPredNum == 1) |
---|
1275 | { |
---|
1276 | uiIPredMode = uiPreds[0]; |
---|
1277 | } |
---|
1278 | else |
---|
1279 | { |
---|
1280 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 2) ); |
---|
1281 | uiIPredMode = uiPreds[uiSymbol]; |
---|
1282 | } |
---|
1283 | } |
---|
1284 | else |
---|
1285 | { |
---|
1286 | if ( g_aucIntraModeBitsAng[iIntraIdx] < 6 ) |
---|
1287 | { |
---|
1288 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode = uiSymbol; |
---|
1289 | if ( g_aucIntraModeBitsAng[iIntraIdx] > 2 ) { m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 1; } |
---|
1290 | if ( g_aucIntraModeBitsAng[iIntraIdx] > 3 ) { m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 2; } |
---|
1291 | if ( g_aucIntraModeBitsAng[iIntraIdx] > 4 ) { m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 3; } |
---|
1292 | } |
---|
1293 | else |
---|
1294 | { |
---|
1295 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode = uiSymbol; |
---|
1296 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 1; |
---|
1297 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 2; |
---|
1298 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 3; |
---|
1299 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 4; |
---|
1300 | |
---|
1301 | if (uiIPredMode == 31) |
---|
1302 | { // Escape coding for the last two modes |
---|
1303 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); |
---|
1304 | uiIPredMode = uiSymbol ? 32 : 31; |
---|
1305 | } |
---|
1306 | } |
---|
1307 | |
---|
1308 | for(UInt i = 0; i < uiPredNum; i++) |
---|
1309 | { |
---|
1310 | if(uiIPredMode >= uiPreds[i]) { uiIPredMode ++; } |
---|
1311 | } |
---|
1312 | } |
---|
1313 | #if ADD_PLANAR_MODE |
---|
1314 | if (uiIPredMode == 2) |
---|
1315 | { |
---|
1316 | UInt planarFlag; |
---|
1317 | m_pcTDecBinIf->decodeBin( planarFlag, m_cPlanarFlagSCModel.get(0,0,0) ); |
---|
1318 | if ( planarFlag ) |
---|
1319 | { |
---|
1320 | uiIPredMode = PLANAR_IDX; |
---|
1321 | } |
---|
1322 | } |
---|
1323 | #endif |
---|
1324 | } |
---|
1325 | |
---|
1326 | pcCU->setLumaIntraDirSubParts( (UChar)uiIPredMode, uiAbsPartIdx, uiDepth ); |
---|
1327 | } |
---|
1328 | #else |
---|
1329 | Void TDecSbac::parseIntraDirLumaAng ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1330 | { |
---|
1331 | Int uiIPredMode; |
---|
1332 | UInt uiSymbol; |
---|
1333 | |
---|
1334 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1335 | UInt uiFlag = 0; |
---|
1336 | if ( pcCU->getSlice()->getSPS()->isDepth() && pcCU->getSlice()->getSPS()->getUseDMM() && g_uiMaxCUWidth>>uiDepth < 64 ) |
---|
1337 | { |
---|
1338 | m_pcTDecBinIf->decodeBin( uiFlag, m_cIntraDMMSCModel.get(0, 0, 0) ); |
---|
1339 | } |
---|
1340 | if ( uiFlag ) |
---|
1341 | { |
---|
1342 | UInt uiDMMode; |
---|
1343 | |
---|
1344 | #if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX |
---|
1345 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode = uiSymbol; |
---|
1346 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode |= uiSymbol << 1; |
---|
1347 | if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 ) |
---|
1348 | { |
---|
1349 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode |= uiSymbol << 2; |
---|
1350 | } |
---|
1351 | #else |
---|
1352 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode = uiSymbol; |
---|
1353 | if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 ) |
---|
1354 | { |
---|
1355 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode |= uiSymbol << 1; |
---|
1356 | } |
---|
1357 | #endif |
---|
1358 | uiIPredMode = g_aucAdditionalIntraModeList[uiDMMode]; |
---|
1359 | |
---|
1360 | #if HHI_DMM_WEDGE_INTRA |
---|
1361 | if( uiIPredMode == DMM_WEDGE_FULL_IDX ) { xParseWedgeFullInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1362 | if( uiIPredMode == DMM_WEDGE_FULL_D_IDX ) { xParseWedgeFullDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1363 | if( uiIPredMode == DMM_WEDGE_PREDDIR_IDX ) { xParseWedgePredDirInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1364 | if( uiIPredMode == DMM_WEDGE_PREDDIR_D_IDX ) { xParseWedgePredDirDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1365 | #endif |
---|
1366 | #if HHI_DMM_PRED_TEX |
---|
1367 | if( uiIPredMode == DMM_WEDGE_PREDTEX_D_IDX ) { xParseWedgePredTexDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1368 | if( uiIPredMode == DMM_CONTOUR_PREDTEX_D_IDX ) { xParseContourPredTexDeltaInfo( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1369 | #endif |
---|
1370 | } |
---|
1371 | else |
---|
1372 | #endif |
---|
1373 | { |
---|
1374 | Int iMostProbable = pcCU->getMostProbableIntraDirLuma( uiAbsPartIdx ); |
---|
1375 | |
---|
1376 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 0) ); |
---|
1377 | |
---|
1378 | if ( uiSymbol ) |
---|
1379 | uiIPredMode = iMostProbable; |
---|
1380 | else |
---|
1381 | { |
---|
1382 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
1383 | if ( g_aucIntraModeBitsAng[iIntraIdx] < 6 ) |
---|
1384 | { |
---|
1385 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode = uiSymbol; |
---|
1386 | if ( g_aucIntraModeBitsAng[iIntraIdx] > 2 ) { m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 1; } |
---|
1387 | if ( g_aucIntraModeBitsAng[iIntraIdx] > 3 ) { m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 2; } |
---|
1388 | if ( g_aucIntraModeBitsAng[iIntraIdx] > 4 ) { m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 3; } |
---|
1389 | } |
---|
1390 | else |
---|
1391 | { |
---|
1392 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode = uiSymbol; |
---|
1393 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 1; |
---|
1394 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 2; |
---|
1395 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 3; |
---|
1396 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 4; |
---|
1397 | |
---|
1398 | if (uiIPredMode == 31) |
---|
1399 | { // Escape coding for the last two modes |
---|
1400 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); |
---|
1401 | uiIPredMode = uiSymbol ? 32 : 31; |
---|
1402 | } |
---|
1403 | } |
---|
1404 | |
---|
1405 | if (uiIPredMode >= iMostProbable) |
---|
1406 | uiIPredMode++; |
---|
1407 | } |
---|
1408 | |
---|
1409 | #if ADD_PLANAR_MODE |
---|
1410 | if (uiIPredMode == 2) |
---|
1411 | { |
---|
1412 | UInt planarFlag; |
---|
1413 | m_pcTDecBinIf->decodeBin( planarFlag, m_cPlanarFlagSCModel.get(0,0,0) ); |
---|
1414 | if ( planarFlag ) |
---|
1415 | { |
---|
1416 | uiIPredMode = PLANAR_IDX; |
---|
1417 | } |
---|
1418 | } |
---|
1419 | #endif |
---|
1420 | } |
---|
1421 | |
---|
1422 | pcCU->setLumaIntraDirSubParts( (UChar)uiIPredMode, uiAbsPartIdx, uiDepth ); |
---|
1423 | } |
---|
1424 | #endif |
---|
1425 | Void TDecSbac::parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1426 | { |
---|
1427 | UInt uiSymbol; |
---|
1428 | |
---|
1429 | #if CHROMA_CODEWORD |
---|
1430 | UInt uiMode = pcCU->getLumaIntraDir(uiAbsPartIdx); |
---|
1431 | #if ADD_PLANAR_MODE |
---|
1432 | if ( (uiMode == 2 ) || (uiMode == PLANAR_IDX) ) |
---|
1433 | { |
---|
1434 | uiMode = 4; |
---|
1435 | } |
---|
1436 | #endif |
---|
1437 | |
---|
1438 | #if LM_CHROMA |
---|
1439 | Int iMaxMode = pcCU->getSlice()->getSPS()->getUseLMChroma() ? 3 : 4; |
---|
1440 | Int iMax = uiMode < iMaxMode ? 2 : 3; |
---|
1441 | |
---|
1442 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, pcCU->getCtxIntraDirChroma( uiAbsPartIdx ) ) ); |
---|
1443 | |
---|
1444 | if ( uiSymbol ) |
---|
1445 | { |
---|
1446 | xReadUnaryMaxSymbol( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0 ) + 3, 0, iMax ); |
---|
1447 | uiSymbol++; |
---|
1448 | } |
---|
1449 | |
---|
1450 | //switch codeword |
---|
1451 | if (uiSymbol == 0) |
---|
1452 | { |
---|
1453 | uiSymbol = 4; |
---|
1454 | } |
---|
1455 | else if (uiSymbol == 1 && pcCU->getSlice()->getSPS()->getUseLMChroma()) |
---|
1456 | { |
---|
1457 | uiSymbol = 3; |
---|
1458 | } |
---|
1459 | else |
---|
1460 | { |
---|
1461 | #if CHROMA_CODEWORD_SWITCH |
---|
1462 | uiSymbol = ChromaMapping[iMax-2][uiSymbol]; |
---|
1463 | #endif |
---|
1464 | |
---|
1465 | if (pcCU->getSlice()->getSPS()->getUseLMChroma()) |
---|
1466 | uiSymbol --; |
---|
1467 | |
---|
1468 | if (uiSymbol <= uiMode) |
---|
1469 | uiSymbol --; |
---|
1470 | } |
---|
1471 | #else // <-- LM_CHROMA |
---|
1472 | Int iMax = uiMode < 4 ? 2 : 3; |
---|
1473 | |
---|
1474 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, pcCU->getCtxIntraDirChroma( uiAbsPartIdx ) ) ); |
---|
1475 | |
---|
1476 | if ( uiSymbol ) |
---|
1477 | { |
---|
1478 | xReadUnaryMaxSymbol( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0 ) + 3, 0, iMax ); |
---|
1479 | uiSymbol++; |
---|
1480 | } |
---|
1481 | |
---|
1482 | //switch codeword |
---|
1483 | if (uiSymbol == 0) |
---|
1484 | { |
---|
1485 | uiSymbol = 4; |
---|
1486 | } |
---|
1487 | #if CHROMA_CODEWORD_SWITCH |
---|
1488 | else |
---|
1489 | { |
---|
1490 | uiSymbol = ChromaMapping[iMax-2][uiSymbol]; |
---|
1491 | if (uiSymbol <= uiMode) |
---|
1492 | { |
---|
1493 | uiSymbol --; |
---|
1494 | } |
---|
1495 | } |
---|
1496 | #else |
---|
1497 | else if (uiSymbol <= uiMode) |
---|
1498 | { |
---|
1499 | uiSymbol --; |
---|
1500 | } |
---|
1501 | #endif |
---|
1502 | #endif // <-- LM_CHROMA |
---|
1503 | |
---|
1504 | #else // CHROMA_CODEWORD |
---|
1505 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, pcCU->getCtxIntraDirChroma( uiAbsPartIdx ) ) ); |
---|
1506 | |
---|
1507 | if ( uiSymbol ) |
---|
1508 | { |
---|
1509 | xReadUnaryMaxSymbol( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0 ) + 3, 0, 3 ); |
---|
1510 | uiSymbol++; |
---|
1511 | } |
---|
1512 | #endif |
---|
1513 | |
---|
1514 | #if ADD_PLANAR_MODE |
---|
1515 | if (uiSymbol == 2) |
---|
1516 | { |
---|
1517 | #if CHROMA_CODEWORD |
---|
1518 | uiMode = pcCU->getLumaIntraDir(uiAbsPartIdx); |
---|
1519 | if (uiMode == 2) |
---|
1520 | { |
---|
1521 | uiSymbol = PLANAR_IDX; |
---|
1522 | } |
---|
1523 | else if (uiMode != PLANAR_IDX) |
---|
1524 | #endif |
---|
1525 | { |
---|
1526 | UInt planarFlag; |
---|
1527 | m_pcTDecBinIf->decodeBin( planarFlag, m_cPlanarFlagSCModel.get(0,0,1) ); |
---|
1528 | if ( planarFlag ) |
---|
1529 | { |
---|
1530 | uiSymbol = PLANAR_IDX; |
---|
1531 | } |
---|
1532 | } |
---|
1533 | } |
---|
1534 | #endif |
---|
1535 | pcCU->setChromIntraDirSubParts( uiSymbol, uiAbsPartIdx, uiDepth ); |
---|
1536 | |
---|
1537 | return; |
---|
1538 | } |
---|
1539 | |
---|
1540 | Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1541 | { |
---|
1542 | UInt uiSymbol; |
---|
1543 | UInt uiCtx = pcCU->getCtxInterDir( uiAbsPartIdx ); |
---|
1544 | |
---|
1545 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUInterDirSCModel.get( 0, 0, uiCtx ) ); |
---|
1546 | |
---|
1547 | if ( uiSymbol ) |
---|
1548 | { |
---|
1549 | uiSymbol = 2; |
---|
1550 | } |
---|
1551 | #if DCM_COMB_LIST |
---|
1552 | else if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0) |
---|
1553 | { |
---|
1554 | uiSymbol = 0; |
---|
1555 | } |
---|
1556 | #endif |
---|
1557 | else if ( pcCU->getSlice()->getNoBackPredFlag() ) |
---|
1558 | { |
---|
1559 | uiSymbol = 0; |
---|
1560 | } |
---|
1561 | else |
---|
1562 | { |
---|
1563 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUInterDirSCModel.get( 0, 0, 3 ) ); |
---|
1564 | } |
---|
1565 | uiSymbol++; |
---|
1566 | ruiInterDir = uiSymbol; |
---|
1567 | return; |
---|
1568 | } |
---|
1569 | |
---|
1570 | Void TDecSbac::parseRefFrmIdx( TComDataCU* pcCU, Int& riRefFrmIdx, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
1571 | { |
---|
1572 | UInt uiSymbol; |
---|
1573 | |
---|
1574 | #if DCM_COMB_LIST |
---|
1575 | if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C ) > 0 && eRefList==REF_PIC_LIST_C) |
---|
1576 | { |
---|
1577 | UInt uiCtx; |
---|
1578 | |
---|
1579 | uiCtx = pcCU->getCtxRefIdx( uiAbsPartIdx, RefPicList(pcCU->getSlice()->getListIdFromIdxOfLC(0)) ); |
---|
1580 | |
---|
1581 | m_pcTDecBinIf->decodeBin ( uiSymbol, m_cCURefPicSCModel.get( 0, 0, uiCtx ) ); |
---|
1582 | |
---|
1583 | if ( uiSymbol ) |
---|
1584 | { |
---|
1585 | xReadUnaryMaxSymbol( uiSymbol, &m_cCURefPicSCModel.get( 0, 0, 4 ), 1, pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_C )-2 ); |
---|
1586 | |
---|
1587 | uiSymbol++; |
---|
1588 | } |
---|
1589 | |
---|
1590 | riRefFrmIdx = uiSymbol; |
---|
1591 | } |
---|
1592 | else |
---|
1593 | { |
---|
1594 | #endif |
---|
1595 | |
---|
1596 | UInt uiCtx = pcCU->getCtxRefIdx( uiAbsPartIdx, eRefList ); |
---|
1597 | |
---|
1598 | m_pcTDecBinIf->decodeBin ( uiSymbol, m_cCURefPicSCModel.get( 0, 0, uiCtx ) ); |
---|
1599 | if ( uiSymbol ) |
---|
1600 | { |
---|
1601 | xReadUnaryMaxSymbol( uiSymbol, &m_cCURefPicSCModel.get( 0, 0, 4 ), 1, pcCU->getSlice()->getNumRefIdx( eRefList )-2 ); |
---|
1602 | |
---|
1603 | uiSymbol++; |
---|
1604 | } |
---|
1605 | riRefFrmIdx = uiSymbol; |
---|
1606 | |
---|
1607 | #if DCM_COMB_LIST |
---|
1608 | } |
---|
1609 | #endif |
---|
1610 | |
---|
1611 | return; |
---|
1612 | } |
---|
1613 | |
---|
1614 | Void TDecSbac::parseViewIdx(Int &riViewIdx) |
---|
1615 | { |
---|
1616 | assert(0) ; // not implemented yet |
---|
1617 | UInt uiSymbol; |
---|
1618 | xReadUnaryMaxSymbol(uiSymbol, &m_cViewIdxSCModel.get(0,0,4), 1, MAX_NUMBER_VIEWS); |
---|
1619 | riViewIdx = uiSymbol; |
---|
1620 | } |
---|
1621 | |
---|
1622 | Void TDecSbac::parseMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
1623 | { |
---|
1624 | Int iHor, iVer; |
---|
1625 | UInt uiAbsPartIdxL, uiAbsPartIdxA; |
---|
1626 | #if MVD_CTX |
---|
1627 | Int iHorPredL, iVerPredL; |
---|
1628 | Int iHorPredA, iVerPredA; |
---|
1629 | #else |
---|
1630 | Int iHorPred, iVerPred; |
---|
1631 | #endif |
---|
1632 | |
---|
1633 | TComDataCU* pcCUL = pcCU->getPULeft ( uiAbsPartIdxL, pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
1634 | TComDataCU* pcCUA = pcCU->getPUAbove( uiAbsPartIdxA, pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
1635 | |
---|
1636 | TComCUMvField* pcCUMvFieldL = ( pcCUL == NULL || pcCUL->isIntra( uiAbsPartIdxL ) ) ? NULL : pcCUL->getCUMvField( eRefList ); |
---|
1637 | TComCUMvField* pcCUMvFieldA = ( pcCUA == NULL || pcCUA->isIntra( uiAbsPartIdxA ) ) ? NULL : pcCUA->getCUMvField( eRefList ); |
---|
1638 | |
---|
1639 | #if MVD_CTX |
---|
1640 | iHorPredL = ( (pcCUMvFieldL == NULL) ? 0 : pcCUMvFieldL->getMvd( uiAbsPartIdxL ).getAbsHor() ); |
---|
1641 | iVerPredL = ( (pcCUMvFieldL == NULL) ? 0 : pcCUMvFieldL->getMvd( uiAbsPartIdxL ).getAbsVer() ); |
---|
1642 | iHorPredA = ( (pcCUMvFieldA == NULL) ? 0 : pcCUMvFieldA->getMvd( uiAbsPartIdxA ).getAbsHor() ); |
---|
1643 | iVerPredA = ( (pcCUMvFieldA == NULL) ? 0 : pcCUMvFieldA->getMvd( uiAbsPartIdxA ).getAbsVer() ); |
---|
1644 | #else |
---|
1645 | iHorPred = ( (pcCUMvFieldL == NULL) ? 0 : pcCUMvFieldL->getMvd( uiAbsPartIdxL ).getAbsHor() ) + |
---|
1646 | ( (pcCUMvFieldA == NULL) ? 0 : pcCUMvFieldA->getMvd( uiAbsPartIdxA ).getAbsHor() ); |
---|
1647 | iVerPred = ( (pcCUMvFieldL == NULL) ? 0 : pcCUMvFieldL->getMvd( uiAbsPartIdxL ).getAbsVer() ) + |
---|
1648 | ( (pcCUMvFieldA == NULL) ? 0 : pcCUMvFieldA->getMvd( uiAbsPartIdxA ).getAbsVer() ); |
---|
1649 | #endif |
---|
1650 | |
---|
1651 | TComMv cTmpMv( 0, 0 ); |
---|
1652 | pcCU->getCUMvField( eRefList )->setAllMv( cTmpMv, pcCU->getPartitionSize( uiAbsPartIdx ), uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
1653 | |
---|
1654 | #if MVD_CTX |
---|
1655 | xReadMvd( iHor, iHorPredL, iHorPredA, 0 ); |
---|
1656 | xReadMvd( iVer, iVerPredL, iVerPredA, 1 ); |
---|
1657 | #else |
---|
1658 | xReadMvd( iHor, iHorPred, 0 ); |
---|
1659 | xReadMvd( iVer, iVerPred, 1 ); |
---|
1660 | #endif |
---|
1661 | |
---|
1662 | // set mvd |
---|
1663 | TComMv cMv( iHor, iVer ); |
---|
1664 | pcCU->getCUMvField( eRefList )->setAllMvd( cMv, pcCU->getPartitionSize( uiAbsPartIdx ), uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
1665 | |
---|
1666 | return; |
---|
1667 | } |
---|
1668 | |
---|
1669 | |
---|
1670 | Void TDecSbac::parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ) |
---|
1671 | { |
---|
1672 | m_pcTDecBinIf->decodeBin( ruiSubdivFlag, m_cCUTransSubdivFlagSCModel.get( 0, 0, uiLog2TransformBlockSize ) ); |
---|
1673 | DTRACE_CABAC_V( g_nSymbolCounter++ ) |
---|
1674 | DTRACE_CABAC_T( "\tparseTransformSubdivFlag()" ) |
---|
1675 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1676 | DTRACE_CABAC_V( ruiSubdivFlag ) |
---|
1677 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1678 | DTRACE_CABAC_V( uiLog2TransformBlockSize ) |
---|
1679 | DTRACE_CABAC_T( "\n" ) |
---|
1680 | } |
---|
1681 | |
---|
1682 | Void TDecSbac::parseQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf ) |
---|
1683 | { |
---|
1684 | UInt uiSymbol; |
---|
1685 | const UInt uiCtx = pcCU->getCtxQtRootCbf( uiAbsPartIdx ); |
---|
1686 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) ); |
---|
1687 | DTRACE_CABAC_V( g_nSymbolCounter++ ) |
---|
1688 | DTRACE_CABAC_T( "\tparseQtRootCbf()" ) |
---|
1689 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1690 | DTRACE_CABAC_V( uiSymbol ) |
---|
1691 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1692 | DTRACE_CABAC_V( uiCtx ) |
---|
1693 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1694 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1695 | DTRACE_CABAC_T( "\n" ) |
---|
1696 | |
---|
1697 | uiQtRootCbf = uiSymbol; |
---|
1698 | } |
---|
1699 | |
---|
1700 | Void TDecSbac::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1701 | { |
---|
1702 | UInt uiDQp; |
---|
1703 | Int iDQp; |
---|
1704 | |
---|
1705 | m_pcTDecBinIf->decodeBin( uiDQp, m_cCUDeltaQpSCModel.get( 0, 0, 0 ) ); |
---|
1706 | |
---|
1707 | if ( uiDQp == 0 ) |
---|
1708 | { |
---|
1709 | uiDQp = pcCU->getSlice()->getSliceQp(); |
---|
1710 | } |
---|
1711 | else |
---|
1712 | { |
---|
1713 | xReadUnarySymbol( uiDQp, &m_cCUDeltaQpSCModel.get( 0, 0, 2 ), 1 ); |
---|
1714 | iDQp = ( uiDQp + 2 ) / 2; |
---|
1715 | |
---|
1716 | if ( uiDQp & 1 ) |
---|
1717 | { |
---|
1718 | iDQp = -iDQp; |
---|
1719 | } |
---|
1720 | uiDQp = pcCU->getSlice()->getSliceQp() + iDQp; |
---|
1721 | } |
---|
1722 | |
---|
1723 | pcCU->setQPSubParts( uiDQp, uiAbsPartIdx, uiDepth ); |
---|
1724 | } |
---|
1725 | |
---|
1726 | Void TDecSbac::parseQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth ) |
---|
1727 | { |
---|
1728 | UInt uiSymbol; |
---|
1729 | const UInt uiCtx = pcCU->getCtxQtCbf( uiAbsPartIdx, eType, uiTrDepth ); |
---|
1730 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtCbfSCModel.get( 0, eType ? eType - 1: eType, uiCtx ) ); |
---|
1731 | |
---|
1732 | DTRACE_CABAC_V( g_nSymbolCounter++ ) |
---|
1733 | DTRACE_CABAC_T( "\tparseQtCbf()" ) |
---|
1734 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1735 | DTRACE_CABAC_V( uiSymbol ) |
---|
1736 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1737 | DTRACE_CABAC_V( uiCtx ) |
---|
1738 | DTRACE_CABAC_T( "\tetype=" ) |
---|
1739 | DTRACE_CABAC_V( eType ) |
---|
1740 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1741 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1742 | DTRACE_CABAC_T( "\n" ) |
---|
1743 | |
---|
1744 | pcCU->setCbfSubParts( uiSymbol << uiTrDepth, eType, uiAbsPartIdx, uiDepth ); |
---|
1745 | } |
---|
1746 | |
---|
1747 | |
---|
1748 | #if PCP_SIGMAP_SIMPLE_LAST |
---|
1749 | /** Parse (X,Y) position of the last significant coefficient |
---|
1750 | * \param uiPosLastX reference to X component of last coefficient |
---|
1751 | * \param uiPosLastY reference to Y component of last coefficient |
---|
1752 | * \param uiWidth block width |
---|
1753 | * \param eTType plane type / luminance or chrominance |
---|
1754 | * \param uiCTXIdx block size context |
---|
1755 | * \param uiScanIdx scan type (zig-zag, hor, ver) |
---|
1756 | * \returns Void |
---|
1757 | * This method decodes the X and Y component within a block of the last significant coefficient. |
---|
1758 | */ |
---|
1759 | __inline Void TDecSbac::parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, const UInt uiWidth, const TextType eTType, const UInt uiCTXIdx, const UInt uiScanIdx ) |
---|
1760 | { |
---|
1761 | UInt uiLast; |
---|
1762 | const UInt uiCtxOffset = g_uiCtxXYOffset[uiCTXIdx]; |
---|
1763 | |
---|
1764 | for(uiPosLastX=0; uiPosLastX<uiWidth-1; uiPosLastX++) |
---|
1765 | { |
---|
1766 | m_pcTDecBinIf->decodeBin( uiLast, m_cCuCtxLastX.get( 0, eTType, uiCtxOffset + g_uiCtxXY[uiPosLastX] ) ); |
---|
1767 | if(uiLast) |
---|
1768 | { |
---|
1769 | break; |
---|
1770 | } |
---|
1771 | } |
---|
1772 | |
---|
1773 | for(uiPosLastY=0; uiPosLastY<uiWidth-1; uiPosLastY++) |
---|
1774 | { |
---|
1775 | m_pcTDecBinIf->decodeBin( uiLast, m_cCuCtxLastY.get( 0, eTType, uiCtxOffset + g_uiCtxXY[uiPosLastY] ) ); |
---|
1776 | if(uiLast) |
---|
1777 | { |
---|
1778 | break; |
---|
1779 | } |
---|
1780 | } |
---|
1781 | |
---|
1782 | if( uiScanIdx == SCAN_VER ) |
---|
1783 | { |
---|
1784 | swap( uiPosLastX, uiPosLastY ); |
---|
1785 | } |
---|
1786 | } |
---|
1787 | #endif |
---|
1788 | |
---|
1789 | Void TDecSbac::parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) |
---|
1790 | { |
---|
1791 | DTRACE_CABAC_V( g_nSymbolCounter++ ) |
---|
1792 | DTRACE_CABAC_T( "\tparseCoeffNxN()\teType=" ) |
---|
1793 | DTRACE_CABAC_V( eTType ) |
---|
1794 | DTRACE_CABAC_T( "\twidth=" ) |
---|
1795 | DTRACE_CABAC_V( uiWidth ) |
---|
1796 | DTRACE_CABAC_T( "\theight=" ) |
---|
1797 | DTRACE_CABAC_V( uiHeight ) |
---|
1798 | DTRACE_CABAC_T( "\tdepth=" ) |
---|
1799 | DTRACE_CABAC_V( uiDepth ) |
---|
1800 | DTRACE_CABAC_T( "\tabspartidx=" ) |
---|
1801 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1802 | DTRACE_CABAC_T( "\ttoCU-X=" ) |
---|
1803 | DTRACE_CABAC_V( pcCU->getCUPelX() ) |
---|
1804 | DTRACE_CABAC_T( "\ttoCU-Y=" ) |
---|
1805 | DTRACE_CABAC_V( pcCU->getCUPelY() ) |
---|
1806 | DTRACE_CABAC_T( "\tCU-addr=" ) |
---|
1807 | DTRACE_CABAC_V( pcCU->getAddr() ) |
---|
1808 | DTRACE_CABAC_T( "\tinCU-X=" ) |
---|
1809 | DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
1810 | DTRACE_CABAC_T( "\tinCU-Y=" ) |
---|
1811 | DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
1812 | DTRACE_CABAC_T( "\tpredmode=" ) |
---|
1813 | DTRACE_CABAC_V( pcCU->getPredictionMode( uiAbsPartIdx ) ) |
---|
1814 | DTRACE_CABAC_T( "\n" ) |
---|
1815 | |
---|
1816 | if( uiWidth > pcCU->getSlice()->getSPS()->getMaxTrSize() ) |
---|
1817 | { |
---|
1818 | uiWidth = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
1819 | uiHeight = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
1820 | } |
---|
1821 | |
---|
1822 | UInt uiCTXIdx; |
---|
1823 | |
---|
1824 | switch(uiWidth) |
---|
1825 | { |
---|
1826 | case 2: uiCTXIdx = 6; break; |
---|
1827 | case 4: uiCTXIdx = 5; break; |
---|
1828 | case 8: uiCTXIdx = 4; break; |
---|
1829 | case 16: uiCTXIdx = 3; break; |
---|
1830 | case 32: uiCTXIdx = 2; break; |
---|
1831 | case 64: uiCTXIdx = 1; break; |
---|
1832 | default: uiCTXIdx = 0; break; |
---|
1833 | } |
---|
1834 | |
---|
1835 | eTType = eTType == TEXT_LUMA ? TEXT_LUMA : ( eTType == TEXT_NONE ? TEXT_NONE : TEXT_CHROMA ); |
---|
1836 | |
---|
1837 | //----- parse significance map ----- |
---|
1838 | const UInt uiLog2BlockSize = g_aucConvertToBit[ uiWidth ] + 2; |
---|
1839 | const UInt uiMaxNumCoeff = 1 << ( uiLog2BlockSize << 1 ); |
---|
1840 | const UInt uiMaxNumCoeffM1 = uiMaxNumCoeff - 1; |
---|
1841 | const UInt uiNum4x4Blk = max<UInt>( 1, uiMaxNumCoeff >> 4 ); |
---|
1842 | #if !PCP_SIGMAP_SIMPLE_LAST |
---|
1843 | bool bLastReceived = false; |
---|
1844 | #endif |
---|
1845 | #if QC_MDCS |
---|
1846 | const UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx)); |
---|
1847 | #endif //QC_MDCS |
---|
1848 | |
---|
1849 | #if PCP_SIGMAP_SIMPLE_LAST |
---|
1850 | //===== decode last significant ===== |
---|
1851 | UInt uiPosLastX, uiPosLastY; |
---|
1852 | parseLastSignificantXY( uiPosLastX, uiPosLastY, uiWidth, eTType, uiCTXIdx, uiScanIdx ); |
---|
1853 | UInt uiBlkPosLast = uiPosLastX + (uiPosLastY<<uiLog2BlockSize); |
---|
1854 | pcCoef[ uiBlkPosLast ] = 1; |
---|
1855 | |
---|
1856 | //===== decode significance flags ===== |
---|
1857 | for( UInt uiScanPos = 0; uiScanPos < uiMaxNumCoeffM1; uiScanPos++ ) |
---|
1858 | { |
---|
1859 | #if QC_MDCS |
---|
1860 | UInt uiBlkPos = g_auiSigLastScan[uiScanIdx][uiLog2BlockSize-1][uiScanPos]; |
---|
1861 | #else |
---|
1862 | UInt uiBlkPos = g_auiFrameScanXY[ uiLog2BlockSize-1 ][ uiScanPos ]; |
---|
1863 | #endif //QC_MDCS |
---|
1864 | if( uiBlkPosLast == uiBlkPos ) |
---|
1865 | { |
---|
1866 | break; |
---|
1867 | } |
---|
1868 | UInt uiPosY = uiBlkPos >> uiLog2BlockSize; |
---|
1869 | UInt uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize ); |
---|
1870 | UInt uiSig = 0; |
---|
1871 | UInt uiCtxSig = TComTrQuant::getSigCtxInc( pcCoef, uiPosX, uiPosY, uiLog2BlockSize, uiWidth ); |
---|
1872 | #if SIMPLE_CONTEXT_SIG |
---|
1873 | if( uiCtxSig < 4 || eTType ) |
---|
1874 | { |
---|
1875 | m_pcTDecBinIf->decodeBin( uiSig, m_cCUSigSCModel.get( uiCTXIdx-2, eTType, uiCtxSig ) ); |
---|
1876 | } |
---|
1877 | else |
---|
1878 | { |
---|
1879 | m_pcTDecBinIf->decodeBin( uiSig, m_cCUSigSCModel.get( uiCTXIdx-2 ? uiCTXIdx-2 : 1 , eTType, uiCtxSig ) ); |
---|
1880 | } |
---|
1881 | #else |
---|
1882 | m_pcTDecBinIf->decodeBin( uiSig, m_cCUSigSCModel.get( uiCTXIdx, eTType, uiCtxSig ) ); |
---|
1883 | #endif |
---|
1884 | pcCoef[ uiBlkPos ] = uiSig; |
---|
1885 | } |
---|
1886 | |
---|
1887 | #else |
---|
1888 | for( UInt uiScanPos = 0; uiScanPos < uiMaxNumCoeffM1; uiScanPos++ ) |
---|
1889 | { |
---|
1890 | #if QC_MDCS |
---|
1891 | UInt uiBlkPos = g_auiSigLastScan[uiScanIdx][uiLog2BlockSize-1][uiScanPos]; |
---|
1892 | #else |
---|
1893 | UInt uiBlkPos = g_auiFrameScanXY[ uiLog2BlockSize-1 ][ uiScanPos ]; |
---|
1894 | #endif //QC_MDCS |
---|
1895 | UInt uiPosY = uiBlkPos >> uiLog2BlockSize; |
---|
1896 | UInt uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize ); |
---|
1897 | |
---|
1898 | //===== code significance flag ===== |
---|
1899 | UInt uiSig = 0; |
---|
1900 | UInt uiCtxSig = TComTrQuant::getSigCtxInc( pcCoef, uiPosX, uiPosY, uiLog2BlockSize, uiWidth ); |
---|
1901 | #if SIMPLE_CONTEXT_SIG |
---|
1902 | if( uiCtxSig < 4 || eTType ) |
---|
1903 | { |
---|
1904 | m_pcTDecBinIf->decodeBin( uiSig, m_cCUSigSCModel.get( uiCTXIdx-2, eTType, uiCtxSig ) ); |
---|
1905 | } |
---|
1906 | else |
---|
1907 | { |
---|
1908 | m_pcTDecBinIf->decodeBin( uiSig, m_cCUSigSCModel.get( uiCTXIdx-2 ? uiCTXIdx-2 : 1 , eTType, uiCtxSig ) ); |
---|
1909 | } |
---|
1910 | #else |
---|
1911 | m_pcTDecBinIf->decodeBin( uiSig, m_cCUSigSCModel.get( uiCTXIdx, eTType, uiCtxSig ) ); |
---|
1912 | #endif |
---|
1913 | if( uiSig ) |
---|
1914 | { |
---|
1915 | pcCoef[ uiBlkPos ] = 1; |
---|
1916 | |
---|
1917 | //===== code last flag ===== |
---|
1918 | UInt uiLast = 0; |
---|
1919 | UInt uiCtxLast = TComTrQuant::getLastCtxInc( uiPosX, uiPosY, uiLog2BlockSize ); |
---|
1920 | m_pcTDecBinIf->decodeBin( uiLast, m_cCULastSCModel.get( uiCTXIdx, eTType, uiCtxLast ) ); |
---|
1921 | |
---|
1922 | if( uiLast ) |
---|
1923 | { |
---|
1924 | bLastReceived = true; |
---|
1925 | break; |
---|
1926 | } |
---|
1927 | } |
---|
1928 | } |
---|
1929 | if( !bLastReceived ) |
---|
1930 | { |
---|
1931 | pcCoef[ uiMaxNumCoeffM1 ] = 1; |
---|
1932 | } |
---|
1933 | #endif |
---|
1934 | |
---|
1935 | /* |
---|
1936 | * Sign and bin0 PCP (Section 3.2 and 3.3 of JCTVC-B088) |
---|
1937 | */ |
---|
1938 | Int c1, c2; |
---|
1939 | UInt uiSign; |
---|
1940 | UInt uiLevel; |
---|
1941 | #if E253 |
---|
1942 | UInt uiGoRiceParam = 0; |
---|
1943 | #endif |
---|
1944 | |
---|
1945 | if( uiNum4x4Blk > 1 ) |
---|
1946 | { |
---|
1947 | Bool b1stBlk = true; |
---|
1948 | UInt uiNumOne = 0; |
---|
1949 | |
---|
1950 | for( UInt uiSubBlk = 0; uiSubBlk < uiNum4x4Blk; uiSubBlk++ ) |
---|
1951 | { |
---|
1952 | UInt uiCtxSet = 0; |
---|
1953 | UInt uiSubNumSig = 0; |
---|
1954 | UInt uiSubPosX = 0; |
---|
1955 | UInt uiSubPosY = 0; |
---|
1956 | #if E253 |
---|
1957 | uiGoRiceParam = 0; |
---|
1958 | #endif |
---|
1959 | |
---|
1960 | uiSubPosX = g_auiFrameScanX[ g_aucConvertToBit[ uiWidth ] - 1 ][ uiSubBlk ] << 2; |
---|
1961 | uiSubPosY = g_auiFrameScanY[ g_aucConvertToBit[ uiWidth ] - 1 ][ uiSubBlk ] << 2; |
---|
1962 | |
---|
1963 | TCoeff* piCurr = &pcCoef[ uiSubPosX + uiSubPosY * uiWidth ]; |
---|
1964 | |
---|
1965 | for( UInt uiY = 0; uiY < 4; uiY++ ) |
---|
1966 | { |
---|
1967 | for( UInt uiX = 0; uiX < 4; uiX++ ) |
---|
1968 | { |
---|
1969 | if( piCurr[ uiX ] ) |
---|
1970 | { |
---|
1971 | uiSubNumSig++; |
---|
1972 | } |
---|
1973 | } |
---|
1974 | piCurr += uiWidth; |
---|
1975 | } |
---|
1976 | |
---|
1977 | if( uiSubNumSig > 0 ) |
---|
1978 | { |
---|
1979 | c1 = 1; |
---|
1980 | c2 = 0; |
---|
1981 | |
---|
1982 | if( b1stBlk ) |
---|
1983 | { |
---|
1984 | b1stBlk = false; |
---|
1985 | uiCtxSet = 5; |
---|
1986 | } |
---|
1987 | else |
---|
1988 | { |
---|
1989 | uiCtxSet = ( uiNumOne >> 2 ) + 1; |
---|
1990 | uiNumOne = 0; |
---|
1991 | } |
---|
1992 | |
---|
1993 | for( UInt uiScanPos = 0; uiScanPos < 16; uiScanPos++ ) |
---|
1994 | { |
---|
1995 | UInt uiBlkPos = g_auiFrameScanXY[ 1 ][ 15 - uiScanPos ]; |
---|
1996 | UInt uiPosY = uiBlkPos >> 2; |
---|
1997 | UInt uiPosX = uiBlkPos - ( uiPosY << 2 ); |
---|
1998 | UInt uiIndex = ( ( uiSubPosY + uiPosY ) << uiLog2BlockSize ) + uiSubPosX + uiPosX; |
---|
1999 | |
---|
2000 | uiLevel = pcCoef[ uiIndex ]; |
---|
2001 | |
---|
2002 | if( uiLevel ) |
---|
2003 | { |
---|
2004 | UInt uiCtx = min<UInt>(c1, 4); |
---|
2005 | m_pcTDecBinIf->decodeBin( uiLevel, m_cCUOneSCModel.get( 0, eTType, ( uiCtxSet << 2 ) + uiCtxSet + uiCtx ) ); |
---|
2006 | if( uiLevel == 1 ) |
---|
2007 | { |
---|
2008 | c1 = 0; |
---|
2009 | uiLevel = 2; |
---|
2010 | } |
---|
2011 | else if( c1 ) |
---|
2012 | { |
---|
2013 | c1++; |
---|
2014 | uiLevel++; |
---|
2015 | } |
---|
2016 | else |
---|
2017 | { |
---|
2018 | uiLevel++; |
---|
2019 | } |
---|
2020 | pcCoef[ uiIndex ] = uiLevel; |
---|
2021 | } |
---|
2022 | } |
---|
2023 | |
---|
2024 | for( UInt uiScanPos = 0; uiScanPos < 16; uiScanPos++ ) |
---|
2025 | { |
---|
2026 | UInt uiBlkPos = g_auiFrameScanXY[ 1 ][ 15 - uiScanPos ]; |
---|
2027 | UInt uiPosY = uiBlkPos >> 2; |
---|
2028 | UInt uiPosX = uiBlkPos - ( uiPosY << 2 ); |
---|
2029 | UInt uiIndex = ( ( uiSubPosY + uiPosY ) << uiLog2BlockSize ) + uiSubPosX + uiPosX; |
---|
2030 | |
---|
2031 | uiLevel = pcCoef[ uiIndex ]; |
---|
2032 | |
---|
2033 | if( uiLevel ) |
---|
2034 | { |
---|
2035 | if( uiLevel == 2 ) |
---|
2036 | { |
---|
2037 | UInt uiCtx = min<UInt>(c2, 4); |
---|
2038 | c2++; |
---|
2039 | uiNumOne++; |
---|
2040 | #if E253 |
---|
2041 | m_pcTDecBinIf->decodeBin( uiLevel, m_cCUAbsSCModel.get( 0, eTType, ( uiCtxSet << 2 ) + uiCtxSet + uiCtx ) ); |
---|
2042 | |
---|
2043 | if( uiLevel ) |
---|
2044 | { |
---|
2045 | xReadGoRiceExGolomb( uiLevel, uiGoRiceParam ); |
---|
2046 | uiLevel += 3; |
---|
2047 | } |
---|
2048 | else |
---|
2049 | { |
---|
2050 | uiLevel = 2; |
---|
2051 | } |
---|
2052 | #else |
---|
2053 | xReadExGolombLevel( uiLevel, m_cCUAbsSCModel.get( 0, eTType, ( uiCtxSet << 2 ) + uiCtxSet + uiCtx ) ); |
---|
2054 | uiLevel += 2; |
---|
2055 | #endif |
---|
2056 | } |
---|
2057 | pcCoef[ uiIndex ] = uiLevel; |
---|
2058 | } |
---|
2059 | } |
---|
2060 | |
---|
2061 | for( UInt uiScanPos = 0; uiScanPos < 16; uiScanPos++ ) |
---|
2062 | { |
---|
2063 | UInt uiBlkPos = g_auiFrameScanXY[ 1 ][ 15 - uiScanPos ]; |
---|
2064 | UInt uiPosY = uiBlkPos >> 2; |
---|
2065 | UInt uiPosX = uiBlkPos - ( uiPosY << 2 ); |
---|
2066 | UInt uiIndex = (uiSubPosY + uiPosY) * uiWidth + uiSubPosX + uiPosX; |
---|
2067 | |
---|
2068 | uiLevel = pcCoef[ uiIndex ]; |
---|
2069 | |
---|
2070 | if( uiLevel ) |
---|
2071 | { |
---|
2072 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2073 | pcCoef[ uiIndex ] = ( uiSign ? -(Int)uiLevel : (Int)uiLevel ); |
---|
2074 | } |
---|
2075 | } |
---|
2076 | } |
---|
2077 | } |
---|
2078 | } |
---|
2079 | else |
---|
2080 | { |
---|
2081 | c1 = 1; |
---|
2082 | c2 = 0; |
---|
2083 | |
---|
2084 | for( UInt uiScanPos = 0; uiScanPos < 16; uiScanPos++ ) |
---|
2085 | { |
---|
2086 | UInt uiIndex = g_auiFrameScanXY[ 1 ][ 15 - uiScanPos ]; |
---|
2087 | uiLevel = pcCoef[ uiIndex ]; |
---|
2088 | |
---|
2089 | if( uiLevel ) |
---|
2090 | { |
---|
2091 | UInt uiCtx = min<UInt>(c1, 4); |
---|
2092 | m_pcTDecBinIf->decodeBin( uiLevel, m_cCUOneSCModel.get( 0, eTType, uiCtx ) ); |
---|
2093 | if( uiLevel == 1 ) |
---|
2094 | { |
---|
2095 | c1 = 0; |
---|
2096 | uiLevel = 2; |
---|
2097 | } |
---|
2098 | else if( c1 ) |
---|
2099 | { |
---|
2100 | c1++; |
---|
2101 | uiLevel++; |
---|
2102 | } |
---|
2103 | else |
---|
2104 | { |
---|
2105 | uiLevel++; |
---|
2106 | } |
---|
2107 | pcCoef[ uiIndex ] = uiLevel; |
---|
2108 | } |
---|
2109 | } |
---|
2110 | |
---|
2111 | for( UInt uiScanPos = 0; uiScanPos < 16; uiScanPos++ ) |
---|
2112 | { |
---|
2113 | UInt uiIndex = g_auiFrameScanXY[ 1 ][ 15 - uiScanPos ]; |
---|
2114 | uiLevel = pcCoef[ uiIndex ]; |
---|
2115 | |
---|
2116 | if( uiLevel ) |
---|
2117 | { |
---|
2118 | if( uiLevel == 2 ) |
---|
2119 | { |
---|
2120 | UInt uiCtx = min<UInt>(c2, 4); |
---|
2121 | c2++; |
---|
2122 | #if E253 |
---|
2123 | m_pcTDecBinIf->decodeBin( uiLevel, m_cCUAbsSCModel.get( 0, eTType, uiCtx ) ); |
---|
2124 | |
---|
2125 | if( uiLevel ) |
---|
2126 | { |
---|
2127 | xReadGoRiceExGolomb( uiLevel, uiGoRiceParam ); |
---|
2128 | uiLevel += 3; |
---|
2129 | } |
---|
2130 | else |
---|
2131 | { |
---|
2132 | uiLevel = 2; |
---|
2133 | } |
---|
2134 | #else |
---|
2135 | xReadExGolombLevel( uiLevel, m_cCUAbsSCModel.get( 0, eTType, uiCtx ) ); |
---|
2136 | uiLevel += 2; |
---|
2137 | #endif |
---|
2138 | } |
---|
2139 | pcCoef[ uiIndex ] = uiLevel; |
---|
2140 | } |
---|
2141 | } |
---|
2142 | |
---|
2143 | for( UInt uiScanPos = 0; uiScanPos < 16; uiScanPos++ ) |
---|
2144 | { |
---|
2145 | UInt uiIndex = g_auiFrameScanXY[ 1 ][ 15 - uiScanPos ]; |
---|
2146 | uiLevel = pcCoef[ uiIndex ]; |
---|
2147 | |
---|
2148 | if( uiLevel ) |
---|
2149 | { |
---|
2150 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2151 | pcCoef[ uiIndex ] = ( uiSign ? -(Int)uiLevel : (Int)uiLevel ); |
---|
2152 | } |
---|
2153 | } |
---|
2154 | } |
---|
2155 | |
---|
2156 | return; |
---|
2157 | } |
---|
2158 | |
---|
2159 | Void TDecSbac::parseAlfFlag (UInt& ruiVal) |
---|
2160 | { |
---|
2161 | UInt uiSymbol; |
---|
2162 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cALFFlagSCModel.get( 0, 0, 0 ) ); |
---|
2163 | |
---|
2164 | ruiVal = uiSymbol; |
---|
2165 | } |
---|
2166 | |
---|
2167 | #if TSB_ALF_HEADER |
---|
2168 | Void TDecSbac::parseAlfFlagNum( UInt& ruiVal, UInt minValue, UInt depth ) |
---|
2169 | { |
---|
2170 | UInt uiLength = 0; |
---|
2171 | UInt maxValue = (minValue << (depth*2)); |
---|
2172 | UInt temp = maxValue - minValue; |
---|
2173 | for(UInt i=0; i<32; i++) |
---|
2174 | { |
---|
2175 | if(temp&0x1) |
---|
2176 | { |
---|
2177 | uiLength = i+1; |
---|
2178 | } |
---|
2179 | temp = (temp >> 1); |
---|
2180 | } |
---|
2181 | ruiVal = 0; |
---|
2182 | UInt uiBit; |
---|
2183 | if(uiLength) |
---|
2184 | { |
---|
2185 | while( uiLength-- ) |
---|
2186 | { |
---|
2187 | m_pcTDecBinIf->decodeBinEP( uiBit ); |
---|
2188 | ruiVal += uiBit << uiLength; |
---|
2189 | } |
---|
2190 | } |
---|
2191 | else |
---|
2192 | { |
---|
2193 | ruiVal = 0; |
---|
2194 | } |
---|
2195 | ruiVal += minValue; |
---|
2196 | } |
---|
2197 | |
---|
2198 | Void TDecSbac::parseAlfCtrlFlag( UInt &ruiAlfCtrlFlag ) |
---|
2199 | { |
---|
2200 | UInt uiSymbol; |
---|
2201 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUAlfCtrlFlagSCModel.get( 0, 0, 0 ) ); |
---|
2202 | ruiAlfCtrlFlag = uiSymbol; |
---|
2203 | } |
---|
2204 | #endif |
---|
2205 | |
---|
2206 | Void TDecSbac::parseAlfUvlc (UInt& ruiVal) |
---|
2207 | { |
---|
2208 | UInt uiCode; |
---|
2209 | Int i; |
---|
2210 | |
---|
2211 | m_pcTDecBinIf->decodeBin( uiCode, m_cALFUvlcSCModel.get( 0, 0, 0 ) ); |
---|
2212 | if ( uiCode == 0 ) |
---|
2213 | { |
---|
2214 | ruiVal = 0; |
---|
2215 | return; |
---|
2216 | } |
---|
2217 | |
---|
2218 | i=1; |
---|
2219 | while (1) |
---|
2220 | { |
---|
2221 | m_pcTDecBinIf->decodeBin( uiCode, m_cALFUvlcSCModel.get( 0, 0, 1 ) ); |
---|
2222 | if ( uiCode == 0 ) break; |
---|
2223 | i++; |
---|
2224 | } |
---|
2225 | |
---|
2226 | ruiVal = i; |
---|
2227 | } |
---|
2228 | |
---|
2229 | Void TDecSbac::parseAlfSvlc (Int& riVal) |
---|
2230 | { |
---|
2231 | UInt uiCode; |
---|
2232 | Int iSign; |
---|
2233 | Int i; |
---|
2234 | |
---|
2235 | m_pcTDecBinIf->decodeBin( uiCode, m_cALFSvlcSCModel.get( 0, 0, 0 ) ); |
---|
2236 | |
---|
2237 | if ( uiCode == 0 ) |
---|
2238 | { |
---|
2239 | riVal = 0; |
---|
2240 | return; |
---|
2241 | } |
---|
2242 | |
---|
2243 | // read sign |
---|
2244 | m_pcTDecBinIf->decodeBin( uiCode, m_cALFSvlcSCModel.get( 0, 0, 1 ) ); |
---|
2245 | |
---|
2246 | if ( uiCode == 0 ) iSign = 1; |
---|
2247 | else iSign = -1; |
---|
2248 | |
---|
2249 | // read magnitude |
---|
2250 | i=1; |
---|
2251 | while (1) |
---|
2252 | { |
---|
2253 | m_pcTDecBinIf->decodeBin( uiCode, m_cALFSvlcSCModel.get( 0, 0, 2 ) ); |
---|
2254 | if ( uiCode == 0 ) break; |
---|
2255 | i++; |
---|
2256 | } |
---|
2257 | |
---|
2258 | riVal = i*iSign; |
---|
2259 | } |
---|
2260 | |
---|
2261 | #if MTK_SAO |
---|
2262 | Void TDecSbac::parseAoFlag (UInt& ruiVal) |
---|
2263 | { |
---|
2264 | UInt uiSymbol; |
---|
2265 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cAOFlagSCModel.get( 0, 0, 0 ) ); |
---|
2266 | |
---|
2267 | ruiVal = uiSymbol; |
---|
2268 | } |
---|
2269 | |
---|
2270 | Void TDecSbac::parseAoUvlc (UInt& ruiVal) |
---|
2271 | { |
---|
2272 | UInt uiCode; |
---|
2273 | Int i; |
---|
2274 | |
---|
2275 | m_pcTDecBinIf->decodeBin( uiCode, m_cAOUvlcSCModel.get( 0, 0, 0 ) ); |
---|
2276 | if ( uiCode == 0 ) |
---|
2277 | { |
---|
2278 | ruiVal = 0; |
---|
2279 | return; |
---|
2280 | } |
---|
2281 | |
---|
2282 | i=1; |
---|
2283 | while (1) |
---|
2284 | { |
---|
2285 | m_pcTDecBinIf->decodeBin( uiCode, m_cAOUvlcSCModel.get( 0, 0, 1 ) ); |
---|
2286 | if ( uiCode == 0 ) break; |
---|
2287 | i++; |
---|
2288 | } |
---|
2289 | |
---|
2290 | ruiVal = i; |
---|
2291 | } |
---|
2292 | |
---|
2293 | Void TDecSbac::parseAoSvlc (Int& riVal) |
---|
2294 | { |
---|
2295 | UInt uiCode; |
---|
2296 | Int iSign; |
---|
2297 | Int i; |
---|
2298 | |
---|
2299 | m_pcTDecBinIf->decodeBin( uiCode, m_cAOSvlcSCModel.get( 0, 0, 0 ) ); |
---|
2300 | |
---|
2301 | if ( uiCode == 0 ) |
---|
2302 | { |
---|
2303 | riVal = 0; |
---|
2304 | return; |
---|
2305 | } |
---|
2306 | |
---|
2307 | // read sign |
---|
2308 | m_pcTDecBinIf->decodeBin( uiCode, m_cAOSvlcSCModel.get( 0, 0, 1 ) ); |
---|
2309 | |
---|
2310 | if ( uiCode == 0 ) iSign = 1; |
---|
2311 | else iSign = -1; |
---|
2312 | |
---|
2313 | // read magnitude |
---|
2314 | i=1; |
---|
2315 | while (1) |
---|
2316 | { |
---|
2317 | m_pcTDecBinIf->decodeBin( uiCode, m_cAOSvlcSCModel.get( 0, 0, 2 ) ); |
---|
2318 | if ( uiCode == 0 ) break; |
---|
2319 | i++; |
---|
2320 | } |
---|
2321 | |
---|
2322 | riVal = i*iSign; |
---|
2323 | } |
---|
2324 | #endif |
---|