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 || POZNAN_DBMP |
---|
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 | #if POZNAN_DBMP |
---|
589 | const Bool bDBMPAvailable = pcCU->getSlice()->getMP()->isDBMPEnabled(); |
---|
590 | Bool bDBMPModifyMergeIdx = true; |
---|
591 | #endif |
---|
592 | //--- set number of candidates and availability --- |
---|
593 | Bool abAvailable[ MRG_MAX_NUM_CANDS ]; |
---|
594 | UInt uiNumCand = 0; |
---|
595 | for( UInt uiIdx = 0; uiIdx < MRG_MAX_NUM_CANDS; uiIdx++ ) |
---|
596 | { |
---|
597 | #if HHI_MPI |
---|
598 | if( uiIdx == uiMviMergePos ) |
---|
599 | { |
---|
600 | abAvailable[ uiIdx ] = true; |
---|
601 | uiNumCand++; |
---|
602 | } |
---|
603 | else if( uiIdx > uiMviMergePos ) |
---|
604 | { |
---|
605 | if( ( abAvailable[ uiIdx ] = ( pcCU->getNeighbourCandIdx( uiIdx - 1, uiAbsPartIdx ) == uiIdx ) ) ) |
---|
606 | { |
---|
607 | uiNumCand++; |
---|
608 | } |
---|
609 | } |
---|
610 | else |
---|
611 | #endif |
---|
612 | if( ( abAvailable[ uiIdx ] = ( pcCU->getNeighbourCandIdx( uiIdx, uiAbsPartIdx ) == uiIdx + 1 ) ) ) |
---|
613 | { |
---|
614 | uiNumCand++; |
---|
615 | } |
---|
616 | } |
---|
617 | |
---|
618 | #if POZNAN_DBMP |
---|
619 | if(bDBMPAvailable) |
---|
620 | { |
---|
621 | UInt uiDBMPMergePos = POZNAN_DBMP_MERGE_POS; |
---|
622 | #if HHI_MPI |
---|
623 | if(bMVIAvailable && uiDBMPMergePos>=uiMviMergePos) uiDBMPMergePos++; |
---|
624 | #endif |
---|
625 | for( Int iIdx = MRG_MAX_NUM_CANDS-2; iIdx >= (Int)uiDBMPMergePos; iIdx-- ) |
---|
626 | { |
---|
627 | Int iWrIdx = iIdx+1; |
---|
628 | #if HHI_MPI |
---|
629 | if(bMVIAvailable) |
---|
630 | { |
---|
631 | if(iIdx==(Int)uiMviMergePos) continue; |
---|
632 | if(iWrIdx==(Int)uiMviMergePos) iWrIdx++; |
---|
633 | } |
---|
634 | #endif |
---|
635 | if(iWrIdx>=MRG_MAX_NUM_CANDS) continue; |
---|
636 | |
---|
637 | abAvailable[ iWrIdx ] = abAvailable[ iIdx ]; |
---|
638 | } |
---|
639 | abAvailable[ uiDBMPMergePos ] = ( pcCU->getNeighbourCandIdx( POZNAN_DBMP_MRG_CAND, uiAbsPartIdx ) == POZNAN_DBMP_MRG_CAND + 1 ); |
---|
640 | |
---|
641 | uiNumCand = 0; for( UInt uiIdx = 0; uiIdx < MRG_MAX_NUM_CANDS; uiIdx++ ) if(abAvailable[ uiIdx ]) uiNumCand++; |
---|
642 | } |
---|
643 | #endif |
---|
644 | |
---|
645 | AOF( uiNumCand > 1 ); |
---|
646 | |
---|
647 | //--- determine contexts --- |
---|
648 | AOF( NUM_MV_MERGE_IDX_EXT_CTX >= MRG_MAX_NUM_CANDS - 1 ); |
---|
649 | UInt auiCtx[ MRG_MAX_NUM_CANDS - 1 ]; |
---|
650 | for( UInt uiIdx = 0; uiIdx < MRG_MAX_NUM_CANDS - 1; uiIdx++ ) |
---|
651 | { |
---|
652 | auiCtx[ uiIdx ] = MRG_MAX_NUM_CANDS; |
---|
653 | if( uiNumCand > uiIdx + 1 ) |
---|
654 | { |
---|
655 | Bool bAvComb = false; |
---|
656 | for( UInt uiCId = uiIdx; uiCId < MRG_MAX_NUM_CANDS - 1; uiCId++ ) |
---|
657 | { |
---|
658 | bAvComb = ( bAvComb || abAvailable[ uiCId ] ); |
---|
659 | if( abAvailable[ uiCId + 1 ] && bAvComb ) |
---|
660 | { |
---|
661 | auiCtx[ uiIdx ] = uiCId; |
---|
662 | break; |
---|
663 | } |
---|
664 | } |
---|
665 | AOT( auiCtx[ uiIdx ] == MRG_MAX_NUM_CANDS ); |
---|
666 | } |
---|
667 | } |
---|
668 | |
---|
669 | //--- parse unary index --- |
---|
670 | UInt uiUnaryIdx = 0; |
---|
671 | for( ; uiUnaryIdx < uiNumCand - 1; uiUnaryIdx++ ) |
---|
672 | { |
---|
673 | UInt uiSymbol = 0; |
---|
674 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMVMergeIdxExtSCModel.get( 0, 0, auiCtx[uiUnaryIdx] ) ); |
---|
675 | if( uiSymbol == 0 ) |
---|
676 | { |
---|
677 | break; |
---|
678 | } |
---|
679 | } |
---|
680 | |
---|
681 | //--- determine merge index --- |
---|
682 | ruiMergeIndex = uiUnaryIdx; |
---|
683 | for( UInt uiIdx = 0; uiIdx <= ruiMergeIndex; uiIdx++ ) |
---|
684 | { |
---|
685 | if( ! abAvailable[ uiIdx ] ) |
---|
686 | { |
---|
687 | ruiMergeIndex++; |
---|
688 | } |
---|
689 | } |
---|
690 | |
---|
691 | #if HHI_MPI |
---|
692 | if( ruiMergeIndex > uiMviMergePos ) |
---|
693 | { |
---|
694 | ruiMergeIndex--; |
---|
695 | } |
---|
696 | else if( ruiMergeIndex == uiMviMergePos ) |
---|
697 | { |
---|
698 | pcCU->setTextureModeDepthSubParts( uiDepth, uiAbsPartIdx, uiDepth ); |
---|
699 | #if POZNAN_DBMP |
---|
700 | bDBMPModifyMergeIdx = false; |
---|
701 | #endif |
---|
702 | } |
---|
703 | #endif |
---|
704 | |
---|
705 | #if POZNAN_DBMP |
---|
706 | if(bDBMPAvailable && bDBMPModifyMergeIdx) |
---|
707 | { |
---|
708 | if(ruiMergeIndex==POZNAN_DBMP_MERGE_POS) ruiMergeIndex = POZNAN_DBMP_MRG_CAND; |
---|
709 | else if(ruiMergeIndex>POZNAN_DBMP_MERGE_POS) ruiMergeIndex--; |
---|
710 | } |
---|
711 | #endif |
---|
712 | |
---|
713 | //--- trace --- |
---|
714 | DTRACE_CABAC_V( g_nSymbolCounter++ ); |
---|
715 | DTRACE_CABAC_T( "\tparseMergeIndex():" ); |
---|
716 | DTRACE_CABAC_T( " MRGIdx = " ); |
---|
717 | DTRACE_CABAC_V( ruiMergeIndex ); |
---|
718 | DTRACE_CABAC_T( " UnaryIdx = " ); |
---|
719 | DTRACE_CABAC_V( uiUnaryIdx ); |
---|
720 | DTRACE_CABAC_T( " NumCand = " ); |
---|
721 | DTRACE_CABAC_V( uiNumCand ); |
---|
722 | DTRACE_CABAC_T( " Availibility = " ); |
---|
723 | for( UInt uiIdx = 0; uiIdx < MRG_MAX_NUM_CANDS; uiIdx++ ) |
---|
724 | { |
---|
725 | DTRACE_CABAC_V( abAvailable[ uiIdx ] ? 1 : 0 ); |
---|
726 | } |
---|
727 | DTRACE_CABAC_T( " Contexts = " ); |
---|
728 | for( UInt uiIdx = 0; uiIdx < MRG_MAX_NUM_CANDS - 1; uiIdx++ ) |
---|
729 | { |
---|
730 | DTRACE_CABAC_V( auiCtx[ uiIdx ] ); |
---|
731 | } |
---|
732 | DTRACE_CABAC_T( "\n" ); |
---|
733 | } |
---|
734 | #endif |
---|
735 | |
---|
736 | |
---|
737 | Void TDecSbac::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
738 | { |
---|
739 | #if HHI_INTER_VIEW_MOTION_PRED || HHI_MPI || POZNAN_DBMP |
---|
740 | if( |
---|
741 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
742 | ( pcCU->getSlice()->getSPS()->getViewId() > 0 && ( pcCU->getSlice()->getSPS()->getMultiviewMvPredMode() & PDM_USE_FOR_MERGE ) == PDM_USE_FOR_MERGE ) || |
---|
743 | #endif |
---|
744 | #if HHI_MPI |
---|
745 | ( pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) || |
---|
746 | #endif |
---|
747 | #if POZNAN_DBMP |
---|
748 | ( pcCU->getSlice()->getMP()->isDBMPEnabled() ) || |
---|
749 | #endif |
---|
750 | 0 |
---|
751 | ) |
---|
752 | { |
---|
753 | parseMergeIndexMV( pcCU, ruiMergeIndex, uiAbsPartIdx, uiDepth ); |
---|
754 | return; |
---|
755 | } |
---|
756 | #endif |
---|
757 | |
---|
758 | Bool bLeftInvolved = false; |
---|
759 | Bool bAboveInvolved = false; |
---|
760 | Bool bCollocatedInvolved = false; |
---|
761 | Bool bCornerInvolved = false; |
---|
762 | Bool bCornerBLInvolved = false; |
---|
763 | UInt uiNumCand = 0; |
---|
764 | for( UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; ++uiIter ) |
---|
765 | { |
---|
766 | if( pcCU->getNeighbourCandIdx( uiIter, uiAbsPartIdx ) == uiIter + 1 ) |
---|
767 | { |
---|
768 | uiNumCand++; |
---|
769 | if( uiIter == 0 ) |
---|
770 | { |
---|
771 | bLeftInvolved = true; |
---|
772 | } |
---|
773 | else if( uiIter == 1 ) |
---|
774 | { |
---|
775 | bAboveInvolved = true; |
---|
776 | } |
---|
777 | else if( uiIter == 2 ) |
---|
778 | { |
---|
779 | bCollocatedInvolved = true; |
---|
780 | } |
---|
781 | else if( uiIter == 3 ) |
---|
782 | { |
---|
783 | bCornerInvolved = true; |
---|
784 | } |
---|
785 | else if( uiIter == 4 ) |
---|
786 | { |
---|
787 | bCornerBLInvolved = true; |
---|
788 | } |
---|
789 | } |
---|
790 | } |
---|
791 | assert( uiNumCand > 1 ); |
---|
792 | |
---|
793 | UInt auiCtx[4] = { 0, 0, 0, 3 }; |
---|
794 | if( bLeftInvolved && bAboveInvolved ) |
---|
795 | { |
---|
796 | auiCtx[0] = 0; |
---|
797 | } |
---|
798 | else if( bLeftInvolved || bAboveInvolved ) |
---|
799 | { |
---|
800 | auiCtx[0] = bCollocatedInvolved ? 1 : 2; |
---|
801 | } |
---|
802 | else |
---|
803 | { |
---|
804 | auiCtx[0] = bCollocatedInvolved ? 2 : 3; |
---|
805 | } |
---|
806 | |
---|
807 | if( uiNumCand >= 3 ) |
---|
808 | { |
---|
809 | if( bAboveInvolved ) |
---|
810 | { |
---|
811 | auiCtx[1] = bCollocatedInvolved ? 1 : 2; |
---|
812 | } |
---|
813 | else |
---|
814 | { |
---|
815 | auiCtx[1] = bCollocatedInvolved ? 2 : 3; |
---|
816 | } |
---|
817 | } |
---|
818 | |
---|
819 | if( uiNumCand >= 4 ) |
---|
820 | { |
---|
821 | auiCtx[2] = bCollocatedInvolved ? 2 : 3; |
---|
822 | } |
---|
823 | |
---|
824 | UInt uiUnaryIdx = 0; |
---|
825 | for( ; uiUnaryIdx < uiNumCand - 1; ++uiUnaryIdx ) |
---|
826 | { |
---|
827 | UInt uiSymbol = 0; |
---|
828 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUMergeIdxExtSCModel.get( 0, 0, auiCtx[uiUnaryIdx] ) ); |
---|
829 | if( uiSymbol == 0 ) |
---|
830 | { |
---|
831 | break; |
---|
832 | } |
---|
833 | } |
---|
834 | |
---|
835 | if( !bLeftInvolved ) |
---|
836 | { |
---|
837 | ++uiUnaryIdx; |
---|
838 | } |
---|
839 | if( !bAboveInvolved && uiUnaryIdx >= 1 ) |
---|
840 | { |
---|
841 | ++uiUnaryIdx; |
---|
842 | } |
---|
843 | if( !bCollocatedInvolved && uiUnaryIdx >= 2 ) |
---|
844 | { |
---|
845 | ++uiUnaryIdx; |
---|
846 | } |
---|
847 | if( !bCornerInvolved && uiUnaryIdx >= 3 ) |
---|
848 | { |
---|
849 | ++uiUnaryIdx; |
---|
850 | } |
---|
851 | |
---|
852 | ruiMergeIndex = uiUnaryIdx; |
---|
853 | |
---|
854 | DTRACE_CABAC_V( g_nSymbolCounter++ ) |
---|
855 | DTRACE_CABAC_T( "\tparseMergeIndex()" ) |
---|
856 | DTRACE_CABAC_T( "\tuiMRGIdx= " ) |
---|
857 | DTRACE_CABAC_V( ruiMergeIndex ) |
---|
858 | DTRACE_CABAC_T( "\tuiNumCand= " ) |
---|
859 | DTRACE_CABAC_V( uiNumCand ) |
---|
860 | DTRACE_CABAC_T( "\tbLeftInvolved= " ) |
---|
861 | DTRACE_CABAC_V( bLeftInvolved ) |
---|
862 | DTRACE_CABAC_T( "\tbAboveInvolved= " ) |
---|
863 | DTRACE_CABAC_V( bAboveInvolved ) |
---|
864 | DTRACE_CABAC_T( "\tbCollocatedInvolved= " ) |
---|
865 | DTRACE_CABAC_V( bCollocatedInvolved ) |
---|
866 | DTRACE_CABAC_T( "\tbCornerRTInvolved= " ) |
---|
867 | DTRACE_CABAC_V( bCornerInvolved ) |
---|
868 | DTRACE_CABAC_T( "\tbCornerBLInvolved= " ) |
---|
869 | DTRACE_CABAC_V( bCornerBLInvolved ) |
---|
870 | DTRACE_CABAC_T( "\n" ) |
---|
871 | } |
---|
872 | |
---|
873 | |
---|
874 | Void |
---|
875 | TDecSbac::parseResPredFlag( TComDataCU* pcCU, Bool& rbResPredFlag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
876 | { |
---|
877 | UInt uiCtx = 0; |
---|
878 | UInt uiSymbol = 0; |
---|
879 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cResPredFlagSCModel.get( 0, 0, uiCtx ) ); |
---|
880 | rbResPredFlag = ( uiSymbol != 0 ); |
---|
881 | } |
---|
882 | |
---|
883 | |
---|
884 | Void TDecSbac::parseMVPIdx ( TComDataCU* pcCU, Int& riMVPIdx, Int iMVPNum, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
885 | { |
---|
886 | UInt uiSymbol; |
---|
887 | xReadUnaryMaxSymbol(uiSymbol, m_cMVPIdxSCModel.get(0), 1, iMVPNum-1); |
---|
888 | |
---|
889 | riMVPIdx = uiSymbol; |
---|
890 | } |
---|
891 | |
---|
892 | Void TDecSbac::parseSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
893 | { |
---|
894 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
895 | { |
---|
896 | pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx ); |
---|
897 | return; |
---|
898 | } |
---|
899 | |
---|
900 | UInt uiSymbol; |
---|
901 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUSplitFlagSCModel.get( 0, 0, pcCU->getCtxSplitFlag( uiAbsPartIdx, uiDepth ) ) ); |
---|
902 | DTRACE_CABAC_V( g_nSymbolCounter++ ) |
---|
903 | DTRACE_CABAC_T( "\tSplitFlag\n" ) |
---|
904 | pcCU->setDepthSubParts( uiDepth + uiSymbol, uiAbsPartIdx ); |
---|
905 | |
---|
906 | return; |
---|
907 | } |
---|
908 | |
---|
909 | /** parse partition size |
---|
910 | * \param pcCU |
---|
911 | * \param uiAbsPartIdx |
---|
912 | * \param uiDepth |
---|
913 | * \returns Void |
---|
914 | */ |
---|
915 | Void TDecSbac::parsePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
916 | { |
---|
917 | UInt uiSymbol, uiMode = 0; |
---|
918 | PartSize eMode; |
---|
919 | |
---|
920 | if ( pcCU->isIntra( uiAbsPartIdx ) ) |
---|
921 | { |
---|
922 | #if MTK_DISABLE_INTRA_NxN_SPLIT |
---|
923 | uiSymbol = 1; |
---|
924 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
925 | #endif |
---|
926 | { |
---|
927 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
928 | } |
---|
929 | eMode = uiSymbol ? SIZE_2Nx2N : SIZE_NxN; |
---|
930 | } |
---|
931 | else |
---|
932 | { |
---|
933 | #if HHI_RMP_SWITCH |
---|
934 | if ( !pcCU->getSlice()->getSPS()->getUseRMP()) |
---|
935 | { |
---|
936 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 0) ); |
---|
937 | if( uiSymbol ) |
---|
938 | uiMode = 0; |
---|
939 | else |
---|
940 | uiMode = 3; |
---|
941 | } |
---|
942 | else |
---|
943 | #endif |
---|
944 | { |
---|
945 | UInt uiMaxNumBits = 3; |
---|
946 | for ( UInt ui = 0; ui < uiMaxNumBits; ui++ ) |
---|
947 | { |
---|
948 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, ui) ); |
---|
949 | if ( uiSymbol ) |
---|
950 | { |
---|
951 | break; |
---|
952 | } |
---|
953 | uiMode++; |
---|
954 | } |
---|
955 | } |
---|
956 | eMode = (PartSize) uiMode; |
---|
957 | |
---|
958 | if (pcCU->getSlice()->isInterB() && uiMode == 3) |
---|
959 | { |
---|
960 | #if HHI_DISABLE_INTER_NxN_SPLIT |
---|
961 | uiSymbol = 0; |
---|
962 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
963 | #endif |
---|
964 | { |
---|
965 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 3) ); |
---|
966 | } |
---|
967 | |
---|
968 | if (uiSymbol == 0) |
---|
969 | { |
---|
970 | pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth ); |
---|
971 | #if MTK_DISABLE_INTRA_NxN_SPLIT |
---|
972 | if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) |
---|
973 | #endif |
---|
974 | { |
---|
975 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPartSizeSCModel.get( 0, 0, 4) ); |
---|
976 | } |
---|
977 | if (uiSymbol == 0) |
---|
978 | eMode = SIZE_2Nx2N; |
---|
979 | } |
---|
980 | } |
---|
981 | } |
---|
982 | |
---|
983 | pcCU->setPartSizeSubParts( eMode, uiAbsPartIdx, uiDepth ); |
---|
984 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
985 | |
---|
986 | UInt uiTrLevel = 0; |
---|
987 | |
---|
988 | UInt uiWidthInBit = g_aucConvertToBit[pcCU->getWidth(uiAbsPartIdx)]+2; |
---|
989 | UInt uiTrSizeInBit = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxTrSize()]+2; |
---|
990 | uiTrLevel = uiWidthInBit >= uiTrSizeInBit ? uiWidthInBit - uiTrSizeInBit : 0; |
---|
991 | |
---|
992 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA ) |
---|
993 | { |
---|
994 | if( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) |
---|
995 | { |
---|
996 | pcCU->setTrIdxSubParts( 1+uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
997 | } |
---|
998 | else |
---|
999 | { |
---|
1000 | pcCU->setTrIdxSubParts( uiTrLevel, uiAbsPartIdx, uiDepth ); |
---|
1001 | } |
---|
1002 | } |
---|
1003 | } |
---|
1004 | |
---|
1005 | /** parse prediction mode |
---|
1006 | * \param pcCU |
---|
1007 | * \param uiAbsPartIdx |
---|
1008 | * \param uiDepth |
---|
1009 | * \returns Void |
---|
1010 | */ |
---|
1011 | Void TDecSbac::parsePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1012 | { |
---|
1013 | if( pcCU->getSlice()->isIntra() ) |
---|
1014 | { |
---|
1015 | pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth ); |
---|
1016 | return; |
---|
1017 | } |
---|
1018 | |
---|
1019 | UInt uiSymbol; |
---|
1020 | Int iPredMode = MODE_INTER; |
---|
1021 | if ( pcCU->getSlice()->isInterB() ) |
---|
1022 | { |
---|
1023 | pcCU->setPredModeSubParts( (PredMode)iPredMode, uiAbsPartIdx, uiDepth ); |
---|
1024 | return; |
---|
1025 | } |
---|
1026 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUPredModeSCModel.get( 0, 0, 1 ) ); |
---|
1027 | iPredMode += uiSymbol; |
---|
1028 | pcCU->setPredModeSubParts( (PredMode)iPredMode, uiAbsPartIdx, uiDepth ); |
---|
1029 | } |
---|
1030 | |
---|
1031 | #if HHI_DMM_WEDGE_INTRA |
---|
1032 | Void TDecSbac::xParseWedgeFullInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1033 | { |
---|
1034 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
1035 | Int iBits = g_aucWedgeFullBitsListIdx[iIntraIdx]; |
---|
1036 | |
---|
1037 | UInt uiSymbol, uiTabIdx = 0; |
---|
1038 | for ( Int i = 0; i < iBits; i++ ) |
---|
1039 | { |
---|
1040 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraWedgeSCModel.get(0, 0, 0) ); |
---|
1041 | uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0; |
---|
1042 | uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0; |
---|
1043 | uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0; |
---|
1044 | uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0; |
---|
1045 | uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0; |
---|
1046 | uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0; |
---|
1047 | uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0; |
---|
1048 | uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0; |
---|
1049 | uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0; |
---|
1050 | uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0; |
---|
1051 | uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0; |
---|
1052 | uiTabIdx += ( uiSymbol && i == 11 ) ? 2048 : 0; |
---|
1053 | uiTabIdx += ( uiSymbol && i == 12 ) ? 4096 : 0; |
---|
1054 | } |
---|
1055 | pcCU->setWedgeFullTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth ); |
---|
1056 | } |
---|
1057 | |
---|
1058 | Void TDecSbac::xParseWedgeFullDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1059 | { |
---|
1060 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
1061 | Int iBits = g_aucWedgeFullBitsListIdx[iIntraIdx]; |
---|
1062 | |
---|
1063 | UInt uiSymbol, uiTabIdx = 0; |
---|
1064 | for ( Int i = 0; i < iBits; i++ ) |
---|
1065 | { |
---|
1066 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraWedgeSCModel.get(0, 0, 0) ); |
---|
1067 | uiTabIdx += ( uiSymbol && i == 0 ) ? 1 : 0; |
---|
1068 | uiTabIdx += ( uiSymbol && i == 1 ) ? 2 : 0; |
---|
1069 | uiTabIdx += ( uiSymbol && i == 2 ) ? 4 : 0; |
---|
1070 | uiTabIdx += ( uiSymbol && i == 3 ) ? 8 : 0; |
---|
1071 | uiTabIdx += ( uiSymbol && i == 4 ) ? 16 : 0; |
---|
1072 | uiTabIdx += ( uiSymbol && i == 5 ) ? 32 : 0; |
---|
1073 | uiTabIdx += ( uiSymbol && i == 6 ) ? 64 : 0; |
---|
1074 | uiTabIdx += ( uiSymbol && i == 7 ) ? 128 : 0; |
---|
1075 | uiTabIdx += ( uiSymbol && i == 8 ) ? 256 : 0; |
---|
1076 | uiTabIdx += ( uiSymbol && i == 9 ) ? 512 : 0; |
---|
1077 | uiTabIdx += ( uiSymbol && i == 10 ) ? 1024 : 0; |
---|
1078 | uiTabIdx += ( uiSymbol && i == 11 ) ? 2048 : 0; |
---|
1079 | uiTabIdx += ( uiSymbol && i == 12 ) ? 4096 : 0; |
---|
1080 | } |
---|
1081 | pcCU->setWedgeFullTabIdxSubParts( uiTabIdx, uiAbsPartIdx, uiDepth ); |
---|
1082 | |
---|
1083 | UInt uiDC1, uiDC2; |
---|
1084 | xReadExGolombLevel( uiDC1, m_cIntraWedgeSCModel.get(0, 0, 1) ); |
---|
1085 | Int iDC1 = uiDC1; |
---|
1086 | if ( uiDC1 ) |
---|
1087 | { |
---|
1088 | UInt uiSign; |
---|
1089 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1090 | if ( uiSign ) |
---|
1091 | { |
---|
1092 | iDC1 = -iDC1; |
---|
1093 | } |
---|
1094 | } |
---|
1095 | xReadExGolombLevel( uiDC2, m_cIntraWedgeSCModel.get(0, 0, 1) ); |
---|
1096 | Int iDC2 = uiDC2; |
---|
1097 | if ( uiDC2 ) |
---|
1098 | { |
---|
1099 | UInt uiSign; |
---|
1100 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1101 | if ( uiSign ) |
---|
1102 | { |
---|
1103 | iDC2 = -iDC2; |
---|
1104 | } |
---|
1105 | } |
---|
1106 | |
---|
1107 | pcCU->setWedgeFullDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
1108 | pcCU->setWedgeFullDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
1109 | } |
---|
1110 | |
---|
1111 | Void TDecSbac::xParseWedgePredDirInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1112 | { |
---|
1113 | if( DMM_WEDGE_PREDDIR_DELTAEND_MAX > 0 ) |
---|
1114 | { |
---|
1115 | UInt uiDeltaEnd = 0; |
---|
1116 | m_pcTDecBinIf->decodeBin( uiDeltaEnd, m_cIntraWedgeSCModel.get(0, 0, 3) ); |
---|
1117 | |
---|
1118 | Int iDeltaEnd; |
---|
1119 | if( uiDeltaEnd != 0 ) |
---|
1120 | { |
---|
1121 | UInt uiAbsValMinus1; |
---|
1122 | UInt uiSymbol; |
---|
1123 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraWedgeSCModel.get(0, 0, 3) ); uiAbsValMinus1 = uiSymbol; |
---|
1124 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraWedgeSCModel.get(0, 0, 3) ); uiAbsValMinus1 |= uiSymbol << 1; |
---|
1125 | uiDeltaEnd = uiAbsValMinus1 + 1; |
---|
1126 | |
---|
1127 | iDeltaEnd = uiDeltaEnd; |
---|
1128 | UInt uiSign; |
---|
1129 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1130 | if( uiSign ) |
---|
1131 | { |
---|
1132 | iDeltaEnd = -iDeltaEnd; |
---|
1133 | } |
---|
1134 | } |
---|
1135 | else |
---|
1136 | { |
---|
1137 | iDeltaEnd = 0; |
---|
1138 | } |
---|
1139 | pcCU->setWedgePredDirDeltaEndSubParts( iDeltaEnd, uiAbsPartIdx, uiDepth ); |
---|
1140 | } |
---|
1141 | } |
---|
1142 | |
---|
1143 | Void TDecSbac::xParseWedgePredDirDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1144 | { |
---|
1145 | if( DMM_WEDGE_PREDDIR_DELTAEND_MAX > 0 ) |
---|
1146 | { |
---|
1147 | UInt uiDeltaEnd = 0; |
---|
1148 | m_pcTDecBinIf->decodeBin( uiDeltaEnd, m_cIntraWedgeSCModel.get(0, 0, 3) ); |
---|
1149 | |
---|
1150 | Int iDeltaEnd; |
---|
1151 | if( uiDeltaEnd != 0 ) |
---|
1152 | { |
---|
1153 | UInt uiAbsValMinus1; |
---|
1154 | UInt uiSymbol; |
---|
1155 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraWedgeSCModel.get(0, 0, 3) ); uiAbsValMinus1 = uiSymbol; |
---|
1156 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraWedgeSCModel.get(0, 0, 3) ); uiAbsValMinus1 |= uiSymbol << 1; |
---|
1157 | uiDeltaEnd = uiAbsValMinus1 + 1; |
---|
1158 | |
---|
1159 | iDeltaEnd = uiDeltaEnd; |
---|
1160 | UInt uiSign; |
---|
1161 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1162 | if( uiSign ) |
---|
1163 | { |
---|
1164 | iDeltaEnd = -iDeltaEnd; |
---|
1165 | } |
---|
1166 | } |
---|
1167 | else |
---|
1168 | { |
---|
1169 | iDeltaEnd = 0; |
---|
1170 | } |
---|
1171 | |
---|
1172 | pcCU->setWedgePredDirDeltaEndSubParts( iDeltaEnd, uiAbsPartIdx, uiDepth ); |
---|
1173 | } |
---|
1174 | |
---|
1175 | UInt uiDC1, uiDC2; |
---|
1176 | xReadExGolombLevel( uiDC1, m_cIntraWedgeSCModel.get(0, 0, 1) ); |
---|
1177 | Int iDC1 = uiDC1; |
---|
1178 | if ( uiDC1 ) |
---|
1179 | { |
---|
1180 | UInt uiSign; |
---|
1181 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1182 | if ( uiSign ) |
---|
1183 | { |
---|
1184 | iDC1 = -iDC1; |
---|
1185 | } |
---|
1186 | } |
---|
1187 | xReadExGolombLevel( uiDC2, m_cIntraWedgeSCModel.get(0, 0, 1) ); |
---|
1188 | Int iDC2 = uiDC2; |
---|
1189 | if ( uiDC2 ) |
---|
1190 | { |
---|
1191 | UInt uiSign; |
---|
1192 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1193 | if ( uiSign ) |
---|
1194 | { |
---|
1195 | iDC2 = -iDC2; |
---|
1196 | } |
---|
1197 | } |
---|
1198 | |
---|
1199 | pcCU->setWedgePredDirDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
1200 | pcCU->setWedgePredDirDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
1201 | } |
---|
1202 | #endif |
---|
1203 | #if HHI_DMM_PRED_TEX |
---|
1204 | Void TDecSbac::xParseWedgePredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1205 | { |
---|
1206 | UInt uiDC1, uiDC2; |
---|
1207 | xReadExGolombLevel( uiDC1, m_cIntraWedgeSCModel.get(0, 0, 1) ); |
---|
1208 | Int iDC1 = uiDC1; |
---|
1209 | if ( uiDC1 ) |
---|
1210 | { |
---|
1211 | UInt uiSign; |
---|
1212 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1213 | if ( uiSign ) |
---|
1214 | { |
---|
1215 | iDC1 = -iDC1; |
---|
1216 | } |
---|
1217 | } |
---|
1218 | xReadExGolombLevel( uiDC2, m_cIntraWedgeSCModel.get(0, 0, 1) ); |
---|
1219 | Int iDC2 = uiDC2; |
---|
1220 | if ( uiDC2 ) |
---|
1221 | { |
---|
1222 | UInt uiSign; |
---|
1223 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1224 | if ( uiSign ) |
---|
1225 | { |
---|
1226 | iDC2 = -iDC2; |
---|
1227 | } |
---|
1228 | } |
---|
1229 | |
---|
1230 | pcCU->setWedgePredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
1231 | pcCU->setWedgePredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
1232 | } |
---|
1233 | |
---|
1234 | Void TDecSbac::xParseContourPredTexDeltaInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1235 | { |
---|
1236 | UInt uiDC1, uiDC2; |
---|
1237 | xReadExGolombLevel( uiDC1, m_cIntraWedgeSCModel.get(0, 0, 1) ); |
---|
1238 | Int iDC1 = uiDC1; |
---|
1239 | if ( uiDC1 ) |
---|
1240 | { |
---|
1241 | UInt uiSign; |
---|
1242 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1243 | if ( uiSign ) |
---|
1244 | { |
---|
1245 | iDC1 = -iDC1; |
---|
1246 | } |
---|
1247 | } |
---|
1248 | xReadExGolombLevel( uiDC2, m_cIntraWedgeSCModel.get(0, 0, 1) ); |
---|
1249 | Int iDC2 = uiDC2; |
---|
1250 | if ( uiDC2 ) |
---|
1251 | { |
---|
1252 | UInt uiSign; |
---|
1253 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
1254 | if ( uiSign ) |
---|
1255 | { |
---|
1256 | iDC2 = -iDC2; |
---|
1257 | } |
---|
1258 | } |
---|
1259 | |
---|
1260 | pcCU->setContourPredTexDeltaDC1SubParts( iDC1, uiAbsPartIdx, uiDepth ); |
---|
1261 | pcCU->setContourPredTexDeltaDC2SubParts( iDC2, uiAbsPartIdx, uiDepth ); |
---|
1262 | } |
---|
1263 | #endif |
---|
1264 | |
---|
1265 | #if MTK_DCM_MPM |
---|
1266 | Void TDecSbac::parseIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1267 | { |
---|
1268 | Int uiIPredMode; |
---|
1269 | UInt uiSymbol; |
---|
1270 | |
---|
1271 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1272 | UInt uiFlag = 0; |
---|
1273 | if ( pcCU->getSlice()->getSPS()->isDepth() && pcCU->getSlice()->getSPS()->getUseDMM() && g_uiMaxCUWidth>>uiDepth < 64 ) |
---|
1274 | { |
---|
1275 | m_pcTDecBinIf->decodeBin( uiFlag, m_cIntraDMMSCModel.get(0, 0, 0) ); |
---|
1276 | } |
---|
1277 | if ( uiFlag ) |
---|
1278 | { |
---|
1279 | UInt uiDMMode; |
---|
1280 | |
---|
1281 | #if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX |
---|
1282 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode = uiSymbol; |
---|
1283 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode |= uiSymbol << 1; |
---|
1284 | if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 ) |
---|
1285 | { |
---|
1286 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode |= uiSymbol << 2; |
---|
1287 | } |
---|
1288 | #else |
---|
1289 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode = uiSymbol; |
---|
1290 | if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 ) |
---|
1291 | { |
---|
1292 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode |= uiSymbol << 1; |
---|
1293 | } |
---|
1294 | #endif |
---|
1295 | uiIPredMode = uiDMMode + MAX_MODE_ID_INTRA_DIR + 1; |
---|
1296 | |
---|
1297 | #if HHI_DMM_WEDGE_INTRA |
---|
1298 | if( uiIPredMode == DMM_WEDGE_FULL_IDX ) { xParseWedgeFullInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1299 | if( uiIPredMode == DMM_WEDGE_FULL_D_IDX ) { xParseWedgeFullDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1300 | if( uiIPredMode == DMM_WEDGE_PREDDIR_IDX ) { xParseWedgePredDirInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1301 | if( uiIPredMode == DMM_WEDGE_PREDDIR_D_IDX ) { xParseWedgePredDirDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1302 | #endif |
---|
1303 | #if HHI_DMM_PRED_TEX |
---|
1304 | if( uiIPredMode == DMM_WEDGE_PREDTEX_D_IDX ) { xParseWedgePredTexDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1305 | if( uiIPredMode == DMM_CONTOUR_PREDTEX_D_IDX ) { xParseContourPredTexDeltaInfo( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1306 | #endif |
---|
1307 | } |
---|
1308 | else |
---|
1309 | #endif |
---|
1310 | { |
---|
1311 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
1312 | |
---|
1313 | Int uiPreds[2] = {-1, -1}; |
---|
1314 | Int uiPredNum = pcCU->getIntraDirLumaPredictor(uiAbsPartIdx, uiPreds); |
---|
1315 | |
---|
1316 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 0) ); |
---|
1317 | |
---|
1318 | if ( uiSymbol ) |
---|
1319 | { |
---|
1320 | if(uiPredNum == 1) |
---|
1321 | { |
---|
1322 | uiIPredMode = uiPreds[0]; |
---|
1323 | } |
---|
1324 | else |
---|
1325 | { |
---|
1326 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 2) ); |
---|
1327 | uiIPredMode = uiPreds[uiSymbol]; |
---|
1328 | } |
---|
1329 | } |
---|
1330 | else |
---|
1331 | { |
---|
1332 | if ( g_aucIntraModeBitsAng[iIntraIdx] < 6 ) |
---|
1333 | { |
---|
1334 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode = uiSymbol; |
---|
1335 | if ( g_aucIntraModeBitsAng[iIntraIdx] > 2 ) { m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 1; } |
---|
1336 | if ( g_aucIntraModeBitsAng[iIntraIdx] > 3 ) { m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 2; } |
---|
1337 | if ( g_aucIntraModeBitsAng[iIntraIdx] > 4 ) { m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 3; } |
---|
1338 | } |
---|
1339 | else |
---|
1340 | { |
---|
1341 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode = uiSymbol; |
---|
1342 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 1; |
---|
1343 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 2; |
---|
1344 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 3; |
---|
1345 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 4; |
---|
1346 | |
---|
1347 | if (uiIPredMode == 31) |
---|
1348 | { // Escape coding for the last two modes |
---|
1349 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); |
---|
1350 | uiIPredMode = uiSymbol ? 32 : 31; |
---|
1351 | } |
---|
1352 | } |
---|
1353 | |
---|
1354 | for(UInt i = 0; i < uiPredNum; i++) |
---|
1355 | { |
---|
1356 | if(uiIPredMode >= uiPreds[i]) { uiIPredMode ++; } |
---|
1357 | } |
---|
1358 | } |
---|
1359 | #if ADD_PLANAR_MODE |
---|
1360 | if (uiIPredMode == 2) |
---|
1361 | { |
---|
1362 | UInt planarFlag; |
---|
1363 | m_pcTDecBinIf->decodeBin( planarFlag, m_cPlanarFlagSCModel.get(0,0,0) ); |
---|
1364 | if ( planarFlag ) |
---|
1365 | { |
---|
1366 | uiIPredMode = PLANAR_IDX; |
---|
1367 | } |
---|
1368 | } |
---|
1369 | #endif |
---|
1370 | } |
---|
1371 | |
---|
1372 | pcCU->setLumaIntraDirSubParts( (UChar)uiIPredMode, uiAbsPartIdx, uiDepth ); |
---|
1373 | } |
---|
1374 | #else |
---|
1375 | Void TDecSbac::parseIntraDirLumaAng ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1376 | { |
---|
1377 | Int uiIPredMode; |
---|
1378 | UInt uiSymbol; |
---|
1379 | |
---|
1380 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1381 | UInt uiFlag = 0; |
---|
1382 | if ( pcCU->getSlice()->getSPS()->isDepth() && pcCU->getSlice()->getSPS()->getUseDMM() && g_uiMaxCUWidth>>uiDepth < 64 ) |
---|
1383 | { |
---|
1384 | m_pcTDecBinIf->decodeBin( uiFlag, m_cIntraDMMSCModel.get(0, 0, 0) ); |
---|
1385 | } |
---|
1386 | if ( uiFlag ) |
---|
1387 | { |
---|
1388 | UInt uiDMMode; |
---|
1389 | |
---|
1390 | #if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX |
---|
1391 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode = uiSymbol; |
---|
1392 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode |= uiSymbol << 1; |
---|
1393 | if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 ) |
---|
1394 | { |
---|
1395 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode |= uiSymbol << 2; |
---|
1396 | } |
---|
1397 | #else |
---|
1398 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode = uiSymbol; |
---|
1399 | if ( pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_NxN && g_uiMaxCUWidth>>uiDepth > 4 ) |
---|
1400 | { |
---|
1401 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cIntraDMMSCModel.get(0, 0, 1) ); uiDMMode |= uiSymbol << 1; |
---|
1402 | } |
---|
1403 | #endif |
---|
1404 | uiIPredMode = g_aucAdditionalIntraModeList[uiDMMode]; |
---|
1405 | |
---|
1406 | #if HHI_DMM_WEDGE_INTRA |
---|
1407 | if( uiIPredMode == DMM_WEDGE_FULL_IDX ) { xParseWedgeFullInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1408 | if( uiIPredMode == DMM_WEDGE_FULL_D_IDX ) { xParseWedgeFullDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1409 | if( uiIPredMode == DMM_WEDGE_PREDDIR_IDX ) { xParseWedgePredDirInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1410 | if( uiIPredMode == DMM_WEDGE_PREDDIR_D_IDX ) { xParseWedgePredDirDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1411 | #endif |
---|
1412 | #if HHI_DMM_PRED_TEX |
---|
1413 | if( uiIPredMode == DMM_WEDGE_PREDTEX_D_IDX ) { xParseWedgePredTexDeltaInfo ( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1414 | if( uiIPredMode == DMM_CONTOUR_PREDTEX_D_IDX ) { xParseContourPredTexDeltaInfo( pcCU, uiAbsPartIdx, uiDepth ); } |
---|
1415 | #endif |
---|
1416 | } |
---|
1417 | else |
---|
1418 | #endif |
---|
1419 | { |
---|
1420 | Int iMostProbable = pcCU->getMostProbableIntraDirLuma( uiAbsPartIdx ); |
---|
1421 | |
---|
1422 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 0) ); |
---|
1423 | |
---|
1424 | if ( uiSymbol ) |
---|
1425 | uiIPredMode = iMostProbable; |
---|
1426 | else |
---|
1427 | { |
---|
1428 | Int iIntraIdx = pcCU->getIntraSizeIdx(uiAbsPartIdx); |
---|
1429 | if ( g_aucIntraModeBitsAng[iIntraIdx] < 6 ) |
---|
1430 | { |
---|
1431 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode = uiSymbol; |
---|
1432 | if ( g_aucIntraModeBitsAng[iIntraIdx] > 2 ) { m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 1; } |
---|
1433 | if ( g_aucIntraModeBitsAng[iIntraIdx] > 3 ) { m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 2; } |
---|
1434 | if ( g_aucIntraModeBitsAng[iIntraIdx] > 4 ) { m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 3; } |
---|
1435 | } |
---|
1436 | else |
---|
1437 | { |
---|
1438 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode = uiSymbol; |
---|
1439 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 1; |
---|
1440 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 2; |
---|
1441 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 3; |
---|
1442 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); uiIPredMode |= uiSymbol << 4; |
---|
1443 | |
---|
1444 | if (uiIPredMode == 31) |
---|
1445 | { // Escape coding for the last two modes |
---|
1446 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUIntraPredSCModel.get( 0, 0, 1 ) ); |
---|
1447 | uiIPredMode = uiSymbol ? 32 : 31; |
---|
1448 | } |
---|
1449 | } |
---|
1450 | |
---|
1451 | if (uiIPredMode >= iMostProbable) |
---|
1452 | uiIPredMode++; |
---|
1453 | } |
---|
1454 | |
---|
1455 | #if ADD_PLANAR_MODE |
---|
1456 | if (uiIPredMode == 2) |
---|
1457 | { |
---|
1458 | UInt planarFlag; |
---|
1459 | m_pcTDecBinIf->decodeBin( planarFlag, m_cPlanarFlagSCModel.get(0,0,0) ); |
---|
1460 | if ( planarFlag ) |
---|
1461 | { |
---|
1462 | uiIPredMode = PLANAR_IDX; |
---|
1463 | } |
---|
1464 | } |
---|
1465 | #endif |
---|
1466 | } |
---|
1467 | |
---|
1468 | pcCU->setLumaIntraDirSubParts( (UChar)uiIPredMode, uiAbsPartIdx, uiDepth ); |
---|
1469 | } |
---|
1470 | #endif |
---|
1471 | Void TDecSbac::parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1472 | { |
---|
1473 | UInt uiSymbol; |
---|
1474 | |
---|
1475 | #if CHROMA_CODEWORD |
---|
1476 | UInt uiMode = pcCU->getLumaIntraDir(uiAbsPartIdx); |
---|
1477 | #if ADD_PLANAR_MODE |
---|
1478 | if ( (uiMode == 2 ) || (uiMode == PLANAR_IDX) ) |
---|
1479 | { |
---|
1480 | uiMode = 4; |
---|
1481 | } |
---|
1482 | #endif |
---|
1483 | |
---|
1484 | #if LM_CHROMA |
---|
1485 | Int iMaxMode = pcCU->getSlice()->getSPS()->getUseLMChroma() ? 3 : 4; |
---|
1486 | Int iMax = uiMode < iMaxMode ? 2 : 3; |
---|
1487 | |
---|
1488 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, pcCU->getCtxIntraDirChroma( uiAbsPartIdx ) ) ); |
---|
1489 | |
---|
1490 | if ( uiSymbol ) |
---|
1491 | { |
---|
1492 | xReadUnaryMaxSymbol( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0 ) + 3, 0, iMax ); |
---|
1493 | uiSymbol++; |
---|
1494 | } |
---|
1495 | |
---|
1496 | //switch codeword |
---|
1497 | if (uiSymbol == 0) |
---|
1498 | { |
---|
1499 | uiSymbol = 4; |
---|
1500 | } |
---|
1501 | else if (uiSymbol == 1 && pcCU->getSlice()->getSPS()->getUseLMChroma()) |
---|
1502 | { |
---|
1503 | uiSymbol = 3; |
---|
1504 | } |
---|
1505 | else |
---|
1506 | { |
---|
1507 | #if CHROMA_CODEWORD_SWITCH |
---|
1508 | uiSymbol = ChromaMapping[iMax-2][uiSymbol]; |
---|
1509 | #endif |
---|
1510 | |
---|
1511 | if (pcCU->getSlice()->getSPS()->getUseLMChroma()) |
---|
1512 | uiSymbol --; |
---|
1513 | |
---|
1514 | if (uiSymbol <= uiMode) |
---|
1515 | uiSymbol --; |
---|
1516 | } |
---|
1517 | #else // <-- LM_CHROMA |
---|
1518 | Int iMax = uiMode < 4 ? 2 : 3; |
---|
1519 | |
---|
1520 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, pcCU->getCtxIntraDirChroma( uiAbsPartIdx ) ) ); |
---|
1521 | |
---|
1522 | if ( uiSymbol ) |
---|
1523 | { |
---|
1524 | xReadUnaryMaxSymbol( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0 ) + 3, 0, iMax ); |
---|
1525 | uiSymbol++; |
---|
1526 | } |
---|
1527 | |
---|
1528 | //switch codeword |
---|
1529 | if (uiSymbol == 0) |
---|
1530 | { |
---|
1531 | uiSymbol = 4; |
---|
1532 | } |
---|
1533 | #if CHROMA_CODEWORD_SWITCH |
---|
1534 | else |
---|
1535 | { |
---|
1536 | uiSymbol = ChromaMapping[iMax-2][uiSymbol]; |
---|
1537 | if (uiSymbol <= uiMode) |
---|
1538 | { |
---|
1539 | uiSymbol --; |
---|
1540 | } |
---|
1541 | } |
---|
1542 | #else |
---|
1543 | else if (uiSymbol <= uiMode) |
---|
1544 | { |
---|
1545 | uiSymbol --; |
---|
1546 | } |
---|
1547 | #endif |
---|
1548 | #endif // <-- LM_CHROMA |
---|
1549 | |
---|
1550 | #else // CHROMA_CODEWORD |
---|
1551 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, pcCU->getCtxIntraDirChroma( uiAbsPartIdx ) ) ); |
---|
1552 | |
---|
1553 | if ( uiSymbol ) |
---|
1554 | { |
---|
1555 | xReadUnaryMaxSymbol( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0 ) + 3, 0, 3 ); |
---|
1556 | uiSymbol++; |
---|
1557 | } |
---|
1558 | #endif |
---|
1559 | |
---|
1560 | #if ADD_PLANAR_MODE |
---|
1561 | if (uiSymbol == 2) |
---|
1562 | { |
---|
1563 | #if CHROMA_CODEWORD |
---|
1564 | uiMode = pcCU->getLumaIntraDir(uiAbsPartIdx); |
---|
1565 | if (uiMode == 2) |
---|
1566 | { |
---|
1567 | uiSymbol = PLANAR_IDX; |
---|
1568 | } |
---|
1569 | else if (uiMode != PLANAR_IDX) |
---|
1570 | #endif |
---|
1571 | { |
---|
1572 | UInt planarFlag; |
---|
1573 | m_pcTDecBinIf->decodeBin( planarFlag, m_cPlanarFlagSCModel.get(0,0,1) ); |
---|
1574 | if ( planarFlag ) |
---|
1575 | { |
---|
1576 | uiSymbol = PLANAR_IDX; |
---|
1577 | } |
---|
1578 | } |
---|
1579 | } |
---|
1580 | #endif |
---|
1581 | pcCU->setChromIntraDirSubParts( uiSymbol, uiAbsPartIdx, uiDepth ); |
---|
1582 | |
---|
1583 | return; |
---|
1584 | } |
---|
1585 | |
---|
1586 | Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1587 | { |
---|
1588 | UInt uiSymbol; |
---|
1589 | UInt uiCtx = pcCU->getCtxInterDir( uiAbsPartIdx ); |
---|
1590 | |
---|
1591 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUInterDirSCModel.get( 0, 0, uiCtx ) ); |
---|
1592 | |
---|
1593 | if ( uiSymbol ) |
---|
1594 | { |
---|
1595 | uiSymbol = 2; |
---|
1596 | } |
---|
1597 | #if DCM_COMB_LIST |
---|
1598 | else if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0) |
---|
1599 | { |
---|
1600 | uiSymbol = 0; |
---|
1601 | } |
---|
1602 | #endif |
---|
1603 | else if ( pcCU->getSlice()->getNoBackPredFlag() ) |
---|
1604 | { |
---|
1605 | uiSymbol = 0; |
---|
1606 | } |
---|
1607 | else |
---|
1608 | { |
---|
1609 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUInterDirSCModel.get( 0, 0, 3 ) ); |
---|
1610 | } |
---|
1611 | uiSymbol++; |
---|
1612 | ruiInterDir = uiSymbol; |
---|
1613 | return; |
---|
1614 | } |
---|
1615 | |
---|
1616 | Void TDecSbac::parseRefFrmIdx( TComDataCU* pcCU, Int& riRefFrmIdx, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
1617 | { |
---|
1618 | UInt uiSymbol; |
---|
1619 | |
---|
1620 | #if DCM_COMB_LIST |
---|
1621 | if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C ) > 0 && eRefList==REF_PIC_LIST_C) |
---|
1622 | { |
---|
1623 | UInt uiCtx; |
---|
1624 | |
---|
1625 | uiCtx = pcCU->getCtxRefIdx( uiAbsPartIdx, RefPicList(pcCU->getSlice()->getListIdFromIdxOfLC(0)) ); |
---|
1626 | |
---|
1627 | m_pcTDecBinIf->decodeBin ( uiSymbol, m_cCURefPicSCModel.get( 0, 0, uiCtx ) ); |
---|
1628 | |
---|
1629 | if ( uiSymbol ) |
---|
1630 | { |
---|
1631 | xReadUnaryMaxSymbol( uiSymbol, &m_cCURefPicSCModel.get( 0, 0, 4 ), 1, pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_C )-2 ); |
---|
1632 | |
---|
1633 | uiSymbol++; |
---|
1634 | } |
---|
1635 | |
---|
1636 | riRefFrmIdx = uiSymbol; |
---|
1637 | } |
---|
1638 | else |
---|
1639 | { |
---|
1640 | #endif |
---|
1641 | |
---|
1642 | UInt uiCtx = pcCU->getCtxRefIdx( uiAbsPartIdx, eRefList ); |
---|
1643 | |
---|
1644 | m_pcTDecBinIf->decodeBin ( uiSymbol, m_cCURefPicSCModel.get( 0, 0, uiCtx ) ); |
---|
1645 | if ( uiSymbol ) |
---|
1646 | { |
---|
1647 | xReadUnaryMaxSymbol( uiSymbol, &m_cCURefPicSCModel.get( 0, 0, 4 ), 1, pcCU->getSlice()->getNumRefIdx( eRefList )-2 ); |
---|
1648 | |
---|
1649 | uiSymbol++; |
---|
1650 | } |
---|
1651 | riRefFrmIdx = uiSymbol; |
---|
1652 | |
---|
1653 | #if DCM_COMB_LIST |
---|
1654 | } |
---|
1655 | #endif |
---|
1656 | |
---|
1657 | return; |
---|
1658 | } |
---|
1659 | |
---|
1660 | Void TDecSbac::parseViewIdx(Int &riViewIdx) |
---|
1661 | { |
---|
1662 | assert(0) ; // not implemented yet |
---|
1663 | UInt uiSymbol; |
---|
1664 | xReadUnaryMaxSymbol(uiSymbol, &m_cViewIdxSCModel.get(0,0,4), 1, MAX_NUMBER_VIEWS); |
---|
1665 | riViewIdx = uiSymbol; |
---|
1666 | } |
---|
1667 | |
---|
1668 | Void TDecSbac::parseMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
1669 | { |
---|
1670 | Int iHor, iVer; |
---|
1671 | UInt uiAbsPartIdxL, uiAbsPartIdxA; |
---|
1672 | #if MVD_CTX |
---|
1673 | Int iHorPredL, iVerPredL; |
---|
1674 | Int iHorPredA, iVerPredA; |
---|
1675 | #else |
---|
1676 | Int iHorPred, iVerPred; |
---|
1677 | #endif |
---|
1678 | |
---|
1679 | TComDataCU* pcCUL = pcCU->getPULeft ( uiAbsPartIdxL, pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
1680 | TComDataCU* pcCUA = pcCU->getPUAbove( uiAbsPartIdxA, pcCU->getZorderIdxInCU() + uiAbsPartIdx ); |
---|
1681 | |
---|
1682 | TComCUMvField* pcCUMvFieldL = ( pcCUL == NULL || pcCUL->isIntra( uiAbsPartIdxL ) ) ? NULL : pcCUL->getCUMvField( eRefList ); |
---|
1683 | TComCUMvField* pcCUMvFieldA = ( pcCUA == NULL || pcCUA->isIntra( uiAbsPartIdxA ) ) ? NULL : pcCUA->getCUMvField( eRefList ); |
---|
1684 | |
---|
1685 | #if MVD_CTX |
---|
1686 | iHorPredL = ( (pcCUMvFieldL == NULL) ? 0 : pcCUMvFieldL->getMvd( uiAbsPartIdxL ).getAbsHor() ); |
---|
1687 | iVerPredL = ( (pcCUMvFieldL == NULL) ? 0 : pcCUMvFieldL->getMvd( uiAbsPartIdxL ).getAbsVer() ); |
---|
1688 | iHorPredA = ( (pcCUMvFieldA == NULL) ? 0 : pcCUMvFieldA->getMvd( uiAbsPartIdxA ).getAbsHor() ); |
---|
1689 | iVerPredA = ( (pcCUMvFieldA == NULL) ? 0 : pcCUMvFieldA->getMvd( uiAbsPartIdxA ).getAbsVer() ); |
---|
1690 | #else |
---|
1691 | iHorPred = ( (pcCUMvFieldL == NULL) ? 0 : pcCUMvFieldL->getMvd( uiAbsPartIdxL ).getAbsHor() ) + |
---|
1692 | ( (pcCUMvFieldA == NULL) ? 0 : pcCUMvFieldA->getMvd( uiAbsPartIdxA ).getAbsHor() ); |
---|
1693 | iVerPred = ( (pcCUMvFieldL == NULL) ? 0 : pcCUMvFieldL->getMvd( uiAbsPartIdxL ).getAbsVer() ) + |
---|
1694 | ( (pcCUMvFieldA == NULL) ? 0 : pcCUMvFieldA->getMvd( uiAbsPartIdxA ).getAbsVer() ); |
---|
1695 | #endif |
---|
1696 | |
---|
1697 | TComMv cTmpMv( 0, 0 ); |
---|
1698 | pcCU->getCUMvField( eRefList )->setAllMv( cTmpMv, pcCU->getPartitionSize( uiAbsPartIdx ), uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
1699 | |
---|
1700 | #if MVD_CTX |
---|
1701 | xReadMvd( iHor, iHorPredL, iHorPredA, 0 ); |
---|
1702 | xReadMvd( iVer, iVerPredL, iVerPredA, 1 ); |
---|
1703 | #else |
---|
1704 | xReadMvd( iHor, iHorPred, 0 ); |
---|
1705 | xReadMvd( iVer, iVerPred, 1 ); |
---|
1706 | #endif |
---|
1707 | |
---|
1708 | // set mvd |
---|
1709 | TComMv cMv( iHor, iVer ); |
---|
1710 | pcCU->getCUMvField( eRefList )->setAllMvd( cMv, pcCU->getPartitionSize( uiAbsPartIdx ), uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
1711 | |
---|
1712 | return; |
---|
1713 | } |
---|
1714 | |
---|
1715 | |
---|
1716 | Void TDecSbac::parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ) |
---|
1717 | { |
---|
1718 | m_pcTDecBinIf->decodeBin( ruiSubdivFlag, m_cCUTransSubdivFlagSCModel.get( 0, 0, uiLog2TransformBlockSize ) ); |
---|
1719 | DTRACE_CABAC_V( g_nSymbolCounter++ ) |
---|
1720 | DTRACE_CABAC_T( "\tparseTransformSubdivFlag()" ) |
---|
1721 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1722 | DTRACE_CABAC_V( ruiSubdivFlag ) |
---|
1723 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1724 | DTRACE_CABAC_V( uiLog2TransformBlockSize ) |
---|
1725 | DTRACE_CABAC_T( "\n" ) |
---|
1726 | } |
---|
1727 | |
---|
1728 | Void TDecSbac::parseQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf ) |
---|
1729 | { |
---|
1730 | UInt uiSymbol; |
---|
1731 | const UInt uiCtx = pcCU->getCtxQtRootCbf( uiAbsPartIdx ); |
---|
1732 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtRootCbfSCModel.get( 0, 0, uiCtx ) ); |
---|
1733 | DTRACE_CABAC_V( g_nSymbolCounter++ ) |
---|
1734 | DTRACE_CABAC_T( "\tparseQtRootCbf()" ) |
---|
1735 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1736 | DTRACE_CABAC_V( uiSymbol ) |
---|
1737 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1738 | DTRACE_CABAC_V( uiCtx ) |
---|
1739 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1740 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1741 | DTRACE_CABAC_T( "\n" ) |
---|
1742 | |
---|
1743 | uiQtRootCbf = uiSymbol; |
---|
1744 | } |
---|
1745 | |
---|
1746 | Void TDecSbac::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1747 | { |
---|
1748 | UInt uiDQp; |
---|
1749 | Int iDQp; |
---|
1750 | |
---|
1751 | m_pcTDecBinIf->decodeBin( uiDQp, m_cCUDeltaQpSCModel.get( 0, 0, 0 ) ); |
---|
1752 | |
---|
1753 | if ( uiDQp == 0 ) |
---|
1754 | { |
---|
1755 | uiDQp = pcCU->getSlice()->getSliceQp(); |
---|
1756 | } |
---|
1757 | else |
---|
1758 | { |
---|
1759 | xReadUnarySymbol( uiDQp, &m_cCUDeltaQpSCModel.get( 0, 0, 2 ), 1 ); |
---|
1760 | iDQp = ( uiDQp + 2 ) / 2; |
---|
1761 | |
---|
1762 | if ( uiDQp & 1 ) |
---|
1763 | { |
---|
1764 | iDQp = -iDQp; |
---|
1765 | } |
---|
1766 | uiDQp = pcCU->getSlice()->getSliceQp() + iDQp; |
---|
1767 | } |
---|
1768 | |
---|
1769 | pcCU->setQPSubParts( uiDQp, uiAbsPartIdx, uiDepth ); |
---|
1770 | } |
---|
1771 | |
---|
1772 | Void TDecSbac::parseQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth ) |
---|
1773 | { |
---|
1774 | UInt uiSymbol; |
---|
1775 | const UInt uiCtx = pcCU->getCtxQtCbf( uiAbsPartIdx, eType, uiTrDepth ); |
---|
1776 | m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtCbfSCModel.get( 0, eType ? eType - 1: eType, uiCtx ) ); |
---|
1777 | |
---|
1778 | DTRACE_CABAC_V( g_nSymbolCounter++ ) |
---|
1779 | DTRACE_CABAC_T( "\tparseQtCbf()" ) |
---|
1780 | DTRACE_CABAC_T( "\tsymbol=" ) |
---|
1781 | DTRACE_CABAC_V( uiSymbol ) |
---|
1782 | DTRACE_CABAC_T( "\tctx=" ) |
---|
1783 | DTRACE_CABAC_V( uiCtx ) |
---|
1784 | DTRACE_CABAC_T( "\tetype=" ) |
---|
1785 | DTRACE_CABAC_V( eType ) |
---|
1786 | DTRACE_CABAC_T( "\tuiAbsPartIdx=" ) |
---|
1787 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1788 | DTRACE_CABAC_T( "\n" ) |
---|
1789 | |
---|
1790 | pcCU->setCbfSubParts( uiSymbol << uiTrDepth, eType, uiAbsPartIdx, uiDepth ); |
---|
1791 | } |
---|
1792 | |
---|
1793 | |
---|
1794 | #if PCP_SIGMAP_SIMPLE_LAST |
---|
1795 | /** Parse (X,Y) position of the last significant coefficient |
---|
1796 | * \param uiPosLastX reference to X component of last coefficient |
---|
1797 | * \param uiPosLastY reference to Y component of last coefficient |
---|
1798 | * \param uiWidth block width |
---|
1799 | * \param eTType plane type / luminance or chrominance |
---|
1800 | * \param uiCTXIdx block size context |
---|
1801 | * \param uiScanIdx scan type (zig-zag, hor, ver) |
---|
1802 | * \returns Void |
---|
1803 | * This method decodes the X and Y component within a block of the last significant coefficient. |
---|
1804 | */ |
---|
1805 | __inline Void TDecSbac::parseLastSignificantXY( UInt& uiPosLastX, UInt& uiPosLastY, const UInt uiWidth, const TextType eTType, const UInt uiCTXIdx, const UInt uiScanIdx ) |
---|
1806 | { |
---|
1807 | UInt uiLast; |
---|
1808 | const UInt uiCtxOffset = g_uiCtxXYOffset[uiCTXIdx]; |
---|
1809 | |
---|
1810 | for(uiPosLastX=0; uiPosLastX<uiWidth-1; uiPosLastX++) |
---|
1811 | { |
---|
1812 | m_pcTDecBinIf->decodeBin( uiLast, m_cCuCtxLastX.get( 0, eTType, uiCtxOffset + g_uiCtxXY[uiPosLastX] ) ); |
---|
1813 | if(uiLast) |
---|
1814 | { |
---|
1815 | break; |
---|
1816 | } |
---|
1817 | } |
---|
1818 | |
---|
1819 | for(uiPosLastY=0; uiPosLastY<uiWidth-1; uiPosLastY++) |
---|
1820 | { |
---|
1821 | m_pcTDecBinIf->decodeBin( uiLast, m_cCuCtxLastY.get( 0, eTType, uiCtxOffset + g_uiCtxXY[uiPosLastY] ) ); |
---|
1822 | if(uiLast) |
---|
1823 | { |
---|
1824 | break; |
---|
1825 | } |
---|
1826 | } |
---|
1827 | |
---|
1828 | if( uiScanIdx == SCAN_VER ) |
---|
1829 | { |
---|
1830 | swap( uiPosLastX, uiPosLastY ); |
---|
1831 | } |
---|
1832 | } |
---|
1833 | #endif |
---|
1834 | |
---|
1835 | Void TDecSbac::parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) |
---|
1836 | { |
---|
1837 | DTRACE_CABAC_V( g_nSymbolCounter++ ) |
---|
1838 | DTRACE_CABAC_T( "\tparseCoeffNxN()\teType=" ) |
---|
1839 | DTRACE_CABAC_V( eTType ) |
---|
1840 | DTRACE_CABAC_T( "\twidth=" ) |
---|
1841 | DTRACE_CABAC_V( uiWidth ) |
---|
1842 | DTRACE_CABAC_T( "\theight=" ) |
---|
1843 | DTRACE_CABAC_V( uiHeight ) |
---|
1844 | DTRACE_CABAC_T( "\tdepth=" ) |
---|
1845 | DTRACE_CABAC_V( uiDepth ) |
---|
1846 | DTRACE_CABAC_T( "\tabspartidx=" ) |
---|
1847 | DTRACE_CABAC_V( uiAbsPartIdx ) |
---|
1848 | DTRACE_CABAC_T( "\ttoCU-X=" ) |
---|
1849 | DTRACE_CABAC_V( pcCU->getCUPelX() ) |
---|
1850 | DTRACE_CABAC_T( "\ttoCU-Y=" ) |
---|
1851 | DTRACE_CABAC_V( pcCU->getCUPelY() ) |
---|
1852 | DTRACE_CABAC_T( "\tCU-addr=" ) |
---|
1853 | DTRACE_CABAC_V( pcCU->getAddr() ) |
---|
1854 | DTRACE_CABAC_T( "\tinCU-X=" ) |
---|
1855 | DTRACE_CABAC_V( g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
1856 | DTRACE_CABAC_T( "\tinCU-Y=" ) |
---|
1857 | DTRACE_CABAC_V( g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ] ) |
---|
1858 | DTRACE_CABAC_T( "\tpredmode=" ) |
---|
1859 | DTRACE_CABAC_V( pcCU->getPredictionMode( uiAbsPartIdx ) ) |
---|
1860 | DTRACE_CABAC_T( "\n" ) |
---|
1861 | |
---|
1862 | if( uiWidth > pcCU->getSlice()->getSPS()->getMaxTrSize() ) |
---|
1863 | { |
---|
1864 | uiWidth = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
1865 | uiHeight = pcCU->getSlice()->getSPS()->getMaxTrSize(); |
---|
1866 | } |
---|
1867 | |
---|
1868 | UInt uiCTXIdx; |
---|
1869 | |
---|
1870 | switch(uiWidth) |
---|
1871 | { |
---|
1872 | case 2: uiCTXIdx = 6; break; |
---|
1873 | case 4: uiCTXIdx = 5; break; |
---|
1874 | case 8: uiCTXIdx = 4; break; |
---|
1875 | case 16: uiCTXIdx = 3; break; |
---|
1876 | case 32: uiCTXIdx = 2; break; |
---|
1877 | case 64: uiCTXIdx = 1; break; |
---|
1878 | default: uiCTXIdx = 0; break; |
---|
1879 | } |
---|
1880 | |
---|
1881 | eTType = eTType == TEXT_LUMA ? TEXT_LUMA : ( eTType == TEXT_NONE ? TEXT_NONE : TEXT_CHROMA ); |
---|
1882 | |
---|
1883 | //----- parse significance map ----- |
---|
1884 | const UInt uiLog2BlockSize = g_aucConvertToBit[ uiWidth ] + 2; |
---|
1885 | const UInt uiMaxNumCoeff = 1 << ( uiLog2BlockSize << 1 ); |
---|
1886 | const UInt uiMaxNumCoeffM1 = uiMaxNumCoeff - 1; |
---|
1887 | const UInt uiNum4x4Blk = max<UInt>( 1, uiMaxNumCoeff >> 4 ); |
---|
1888 | #if !PCP_SIGMAP_SIMPLE_LAST |
---|
1889 | bool bLastReceived = false; |
---|
1890 | #endif |
---|
1891 | #if QC_MDCS |
---|
1892 | const UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx)); |
---|
1893 | #endif //QC_MDCS |
---|
1894 | |
---|
1895 | #if PCP_SIGMAP_SIMPLE_LAST |
---|
1896 | //===== decode last significant ===== |
---|
1897 | UInt uiPosLastX, uiPosLastY; |
---|
1898 | parseLastSignificantXY( uiPosLastX, uiPosLastY, uiWidth, eTType, uiCTXIdx, uiScanIdx ); |
---|
1899 | UInt uiBlkPosLast = uiPosLastX + (uiPosLastY<<uiLog2BlockSize); |
---|
1900 | pcCoef[ uiBlkPosLast ] = 1; |
---|
1901 | |
---|
1902 | //===== decode significance flags ===== |
---|
1903 | for( UInt uiScanPos = 0; uiScanPos < uiMaxNumCoeffM1; uiScanPos++ ) |
---|
1904 | { |
---|
1905 | #if QC_MDCS |
---|
1906 | UInt uiBlkPos = g_auiSigLastScan[uiScanIdx][uiLog2BlockSize-1][uiScanPos]; |
---|
1907 | #else |
---|
1908 | UInt uiBlkPos = g_auiFrameScanXY[ uiLog2BlockSize-1 ][ uiScanPos ]; |
---|
1909 | #endif //QC_MDCS |
---|
1910 | if( uiBlkPosLast == uiBlkPos ) |
---|
1911 | { |
---|
1912 | break; |
---|
1913 | } |
---|
1914 | UInt uiPosY = uiBlkPos >> uiLog2BlockSize; |
---|
1915 | UInt uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize ); |
---|
1916 | UInt uiSig = 0; |
---|
1917 | UInt uiCtxSig = TComTrQuant::getSigCtxInc( pcCoef, uiPosX, uiPosY, uiLog2BlockSize, uiWidth ); |
---|
1918 | #if SIMPLE_CONTEXT_SIG |
---|
1919 | if( uiCtxSig < 4 || eTType ) |
---|
1920 | { |
---|
1921 | m_pcTDecBinIf->decodeBin( uiSig, m_cCUSigSCModel.get( uiCTXIdx-2, eTType, uiCtxSig ) ); |
---|
1922 | } |
---|
1923 | else |
---|
1924 | { |
---|
1925 | m_pcTDecBinIf->decodeBin( uiSig, m_cCUSigSCModel.get( uiCTXIdx-2 ? uiCTXIdx-2 : 1 , eTType, uiCtxSig ) ); |
---|
1926 | } |
---|
1927 | #else |
---|
1928 | m_pcTDecBinIf->decodeBin( uiSig, m_cCUSigSCModel.get( uiCTXIdx, eTType, uiCtxSig ) ); |
---|
1929 | #endif |
---|
1930 | pcCoef[ uiBlkPos ] = uiSig; |
---|
1931 | } |
---|
1932 | |
---|
1933 | #else |
---|
1934 | for( UInt uiScanPos = 0; uiScanPos < uiMaxNumCoeffM1; uiScanPos++ ) |
---|
1935 | { |
---|
1936 | #if QC_MDCS |
---|
1937 | UInt uiBlkPos = g_auiSigLastScan[uiScanIdx][uiLog2BlockSize-1][uiScanPos]; |
---|
1938 | #else |
---|
1939 | UInt uiBlkPos = g_auiFrameScanXY[ uiLog2BlockSize-1 ][ uiScanPos ]; |
---|
1940 | #endif //QC_MDCS |
---|
1941 | UInt uiPosY = uiBlkPos >> uiLog2BlockSize; |
---|
1942 | UInt uiPosX = uiBlkPos - ( uiPosY << uiLog2BlockSize ); |
---|
1943 | |
---|
1944 | //===== code significance flag ===== |
---|
1945 | UInt uiSig = 0; |
---|
1946 | UInt uiCtxSig = TComTrQuant::getSigCtxInc( pcCoef, uiPosX, uiPosY, uiLog2BlockSize, uiWidth ); |
---|
1947 | #if SIMPLE_CONTEXT_SIG |
---|
1948 | if( uiCtxSig < 4 || eTType ) |
---|
1949 | { |
---|
1950 | m_pcTDecBinIf->decodeBin( uiSig, m_cCUSigSCModel.get( uiCTXIdx-2, eTType, uiCtxSig ) ); |
---|
1951 | } |
---|
1952 | else |
---|
1953 | { |
---|
1954 | m_pcTDecBinIf->decodeBin( uiSig, m_cCUSigSCModel.get( uiCTXIdx-2 ? uiCTXIdx-2 : 1 , eTType, uiCtxSig ) ); |
---|
1955 | } |
---|
1956 | #else |
---|
1957 | m_pcTDecBinIf->decodeBin( uiSig, m_cCUSigSCModel.get( uiCTXIdx, eTType, uiCtxSig ) ); |
---|
1958 | #endif |
---|
1959 | if( uiSig ) |
---|
1960 | { |
---|
1961 | pcCoef[ uiBlkPos ] = 1; |
---|
1962 | |
---|
1963 | //===== code last flag ===== |
---|
1964 | UInt uiLast = 0; |
---|
1965 | UInt uiCtxLast = TComTrQuant::getLastCtxInc( uiPosX, uiPosY, uiLog2BlockSize ); |
---|
1966 | m_pcTDecBinIf->decodeBin( uiLast, m_cCULastSCModel.get( uiCTXIdx, eTType, uiCtxLast ) ); |
---|
1967 | |
---|
1968 | if( uiLast ) |
---|
1969 | { |
---|
1970 | bLastReceived = true; |
---|
1971 | break; |
---|
1972 | } |
---|
1973 | } |
---|
1974 | } |
---|
1975 | if( !bLastReceived ) |
---|
1976 | { |
---|
1977 | pcCoef[ uiMaxNumCoeffM1 ] = 1; |
---|
1978 | } |
---|
1979 | #endif |
---|
1980 | |
---|
1981 | /* |
---|
1982 | * Sign and bin0 PCP (Section 3.2 and 3.3 of JCTVC-B088) |
---|
1983 | */ |
---|
1984 | Int c1, c2; |
---|
1985 | UInt uiSign; |
---|
1986 | UInt uiLevel; |
---|
1987 | #if E253 |
---|
1988 | UInt uiGoRiceParam = 0; |
---|
1989 | #endif |
---|
1990 | |
---|
1991 | if( uiNum4x4Blk > 1 ) |
---|
1992 | { |
---|
1993 | Bool b1stBlk = true; |
---|
1994 | UInt uiNumOne = 0; |
---|
1995 | |
---|
1996 | for( UInt uiSubBlk = 0; uiSubBlk < uiNum4x4Blk; uiSubBlk++ ) |
---|
1997 | { |
---|
1998 | UInt uiCtxSet = 0; |
---|
1999 | UInt uiSubNumSig = 0; |
---|
2000 | UInt uiSubPosX = 0; |
---|
2001 | UInt uiSubPosY = 0; |
---|
2002 | #if E253 |
---|
2003 | uiGoRiceParam = 0; |
---|
2004 | #endif |
---|
2005 | |
---|
2006 | uiSubPosX = g_auiFrameScanX[ g_aucConvertToBit[ uiWidth ] - 1 ][ uiSubBlk ] << 2; |
---|
2007 | uiSubPosY = g_auiFrameScanY[ g_aucConvertToBit[ uiWidth ] - 1 ][ uiSubBlk ] << 2; |
---|
2008 | |
---|
2009 | TCoeff* piCurr = &pcCoef[ uiSubPosX + uiSubPosY * uiWidth ]; |
---|
2010 | |
---|
2011 | for( UInt uiY = 0; uiY < 4; uiY++ ) |
---|
2012 | { |
---|
2013 | for( UInt uiX = 0; uiX < 4; uiX++ ) |
---|
2014 | { |
---|
2015 | if( piCurr[ uiX ] ) |
---|
2016 | { |
---|
2017 | uiSubNumSig++; |
---|
2018 | } |
---|
2019 | } |
---|
2020 | piCurr += uiWidth; |
---|
2021 | } |
---|
2022 | |
---|
2023 | if( uiSubNumSig > 0 ) |
---|
2024 | { |
---|
2025 | c1 = 1; |
---|
2026 | c2 = 0; |
---|
2027 | |
---|
2028 | if( b1stBlk ) |
---|
2029 | { |
---|
2030 | b1stBlk = false; |
---|
2031 | uiCtxSet = 5; |
---|
2032 | } |
---|
2033 | else |
---|
2034 | { |
---|
2035 | uiCtxSet = ( uiNumOne >> 2 ) + 1; |
---|
2036 | uiNumOne = 0; |
---|
2037 | } |
---|
2038 | |
---|
2039 | for( UInt uiScanPos = 0; uiScanPos < 16; uiScanPos++ ) |
---|
2040 | { |
---|
2041 | UInt uiBlkPos = g_auiFrameScanXY[ 1 ][ 15 - uiScanPos ]; |
---|
2042 | UInt uiPosY = uiBlkPos >> 2; |
---|
2043 | UInt uiPosX = uiBlkPos - ( uiPosY << 2 ); |
---|
2044 | UInt uiIndex = ( ( uiSubPosY + uiPosY ) << uiLog2BlockSize ) + uiSubPosX + uiPosX; |
---|
2045 | |
---|
2046 | uiLevel = pcCoef[ uiIndex ]; |
---|
2047 | |
---|
2048 | if( uiLevel ) |
---|
2049 | { |
---|
2050 | UInt uiCtx = min<UInt>(c1, 4); |
---|
2051 | m_pcTDecBinIf->decodeBin( uiLevel, m_cCUOneSCModel.get( 0, eTType, ( uiCtxSet << 2 ) + uiCtxSet + uiCtx ) ); |
---|
2052 | if( uiLevel == 1 ) |
---|
2053 | { |
---|
2054 | c1 = 0; |
---|
2055 | uiLevel = 2; |
---|
2056 | } |
---|
2057 | else if( c1 ) |
---|
2058 | { |
---|
2059 | c1++; |
---|
2060 | uiLevel++; |
---|
2061 | } |
---|
2062 | else |
---|
2063 | { |
---|
2064 | uiLevel++; |
---|
2065 | } |
---|
2066 | pcCoef[ uiIndex ] = uiLevel; |
---|
2067 | } |
---|
2068 | } |
---|
2069 | |
---|
2070 | for( UInt uiScanPos = 0; uiScanPos < 16; uiScanPos++ ) |
---|
2071 | { |
---|
2072 | UInt uiBlkPos = g_auiFrameScanXY[ 1 ][ 15 - uiScanPos ]; |
---|
2073 | UInt uiPosY = uiBlkPos >> 2; |
---|
2074 | UInt uiPosX = uiBlkPos - ( uiPosY << 2 ); |
---|
2075 | UInt uiIndex = ( ( uiSubPosY + uiPosY ) << uiLog2BlockSize ) + uiSubPosX + uiPosX; |
---|
2076 | |
---|
2077 | uiLevel = pcCoef[ uiIndex ]; |
---|
2078 | |
---|
2079 | if( uiLevel ) |
---|
2080 | { |
---|
2081 | if( uiLevel == 2 ) |
---|
2082 | { |
---|
2083 | UInt uiCtx = min<UInt>(c2, 4); |
---|
2084 | c2++; |
---|
2085 | uiNumOne++; |
---|
2086 | #if E253 |
---|
2087 | m_pcTDecBinIf->decodeBin( uiLevel, m_cCUAbsSCModel.get( 0, eTType, ( uiCtxSet << 2 ) + uiCtxSet + uiCtx ) ); |
---|
2088 | |
---|
2089 | if( uiLevel ) |
---|
2090 | { |
---|
2091 | xReadGoRiceExGolomb( uiLevel, uiGoRiceParam ); |
---|
2092 | uiLevel += 3; |
---|
2093 | } |
---|
2094 | else |
---|
2095 | { |
---|
2096 | uiLevel = 2; |
---|
2097 | } |
---|
2098 | #else |
---|
2099 | xReadExGolombLevel( uiLevel, m_cCUAbsSCModel.get( 0, eTType, ( uiCtxSet << 2 ) + uiCtxSet + uiCtx ) ); |
---|
2100 | uiLevel += 2; |
---|
2101 | #endif |
---|
2102 | } |
---|
2103 | pcCoef[ uiIndex ] = uiLevel; |
---|
2104 | } |
---|
2105 | } |
---|
2106 | |
---|
2107 | for( UInt uiScanPos = 0; uiScanPos < 16; uiScanPos++ ) |
---|
2108 | { |
---|
2109 | UInt uiBlkPos = g_auiFrameScanXY[ 1 ][ 15 - uiScanPos ]; |
---|
2110 | UInt uiPosY = uiBlkPos >> 2; |
---|
2111 | UInt uiPosX = uiBlkPos - ( uiPosY << 2 ); |
---|
2112 | UInt uiIndex = (uiSubPosY + uiPosY) * uiWidth + uiSubPosX + uiPosX; |
---|
2113 | |
---|
2114 | uiLevel = pcCoef[ uiIndex ]; |
---|
2115 | |
---|
2116 | if( uiLevel ) |
---|
2117 | { |
---|
2118 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2119 | pcCoef[ uiIndex ] = ( uiSign ? -(Int)uiLevel : (Int)uiLevel ); |
---|
2120 | } |
---|
2121 | } |
---|
2122 | } |
---|
2123 | } |
---|
2124 | } |
---|
2125 | else |
---|
2126 | { |
---|
2127 | c1 = 1; |
---|
2128 | c2 = 0; |
---|
2129 | |
---|
2130 | for( UInt uiScanPos = 0; uiScanPos < 16; uiScanPos++ ) |
---|
2131 | { |
---|
2132 | UInt uiIndex = g_auiFrameScanXY[ 1 ][ 15 - uiScanPos ]; |
---|
2133 | uiLevel = pcCoef[ uiIndex ]; |
---|
2134 | |
---|
2135 | if( uiLevel ) |
---|
2136 | { |
---|
2137 | UInt uiCtx = min<UInt>(c1, 4); |
---|
2138 | m_pcTDecBinIf->decodeBin( uiLevel, m_cCUOneSCModel.get( 0, eTType, uiCtx ) ); |
---|
2139 | if( uiLevel == 1 ) |
---|
2140 | { |
---|
2141 | c1 = 0; |
---|
2142 | uiLevel = 2; |
---|
2143 | } |
---|
2144 | else if( c1 ) |
---|
2145 | { |
---|
2146 | c1++; |
---|
2147 | uiLevel++; |
---|
2148 | } |
---|
2149 | else |
---|
2150 | { |
---|
2151 | uiLevel++; |
---|
2152 | } |
---|
2153 | pcCoef[ uiIndex ] = uiLevel; |
---|
2154 | } |
---|
2155 | } |
---|
2156 | |
---|
2157 | for( UInt uiScanPos = 0; uiScanPos < 16; uiScanPos++ ) |
---|
2158 | { |
---|
2159 | UInt uiIndex = g_auiFrameScanXY[ 1 ][ 15 - uiScanPos ]; |
---|
2160 | uiLevel = pcCoef[ uiIndex ]; |
---|
2161 | |
---|
2162 | if( uiLevel ) |
---|
2163 | { |
---|
2164 | if( uiLevel == 2 ) |
---|
2165 | { |
---|
2166 | UInt uiCtx = min<UInt>(c2, 4); |
---|
2167 | c2++; |
---|
2168 | #if E253 |
---|
2169 | m_pcTDecBinIf->decodeBin( uiLevel, m_cCUAbsSCModel.get( 0, eTType, uiCtx ) ); |
---|
2170 | |
---|
2171 | if( uiLevel ) |
---|
2172 | { |
---|
2173 | xReadGoRiceExGolomb( uiLevel, uiGoRiceParam ); |
---|
2174 | uiLevel += 3; |
---|
2175 | } |
---|
2176 | else |
---|
2177 | { |
---|
2178 | uiLevel = 2; |
---|
2179 | } |
---|
2180 | #else |
---|
2181 | xReadExGolombLevel( uiLevel, m_cCUAbsSCModel.get( 0, eTType, uiCtx ) ); |
---|
2182 | uiLevel += 2; |
---|
2183 | #endif |
---|
2184 | } |
---|
2185 | pcCoef[ uiIndex ] = uiLevel; |
---|
2186 | } |
---|
2187 | } |
---|
2188 | |
---|
2189 | for( UInt uiScanPos = 0; uiScanPos < 16; uiScanPos++ ) |
---|
2190 | { |
---|
2191 | UInt uiIndex = g_auiFrameScanXY[ 1 ][ 15 - uiScanPos ]; |
---|
2192 | uiLevel = pcCoef[ uiIndex ]; |
---|
2193 | |
---|
2194 | if( uiLevel ) |
---|
2195 | { |
---|
2196 | m_pcTDecBinIf->decodeBinEP( uiSign ); |
---|
2197 | pcCoef[ uiIndex ] = ( uiSign ? -(Int)uiLevel : (Int)uiLevel ); |
---|
2198 | } |
---|
2199 | } |
---|
2200 | } |
---|
2201 | |
---|
2202 | return; |
---|
2203 | } |
---|
2204 | |
---|
2205 | Void TDecSbac::parseAlfFlag (UInt& ruiVal) |
---|
2206 | { |
---|
2207 | UInt uiSymbol; |
---|
2208 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cALFFlagSCModel.get( 0, 0, 0 ) ); |
---|
2209 | |
---|
2210 | ruiVal = uiSymbol; |
---|
2211 | } |
---|
2212 | |
---|
2213 | #if TSB_ALF_HEADER |
---|
2214 | Void TDecSbac::parseAlfFlagNum( UInt& ruiVal, UInt minValue, UInt depth ) |
---|
2215 | { |
---|
2216 | UInt uiLength = 0; |
---|
2217 | UInt maxValue = (minValue << (depth*2)); |
---|
2218 | UInt temp = maxValue - minValue; |
---|
2219 | for(UInt i=0; i<32; i++) |
---|
2220 | { |
---|
2221 | if(temp&0x1) |
---|
2222 | { |
---|
2223 | uiLength = i+1; |
---|
2224 | } |
---|
2225 | temp = (temp >> 1); |
---|
2226 | } |
---|
2227 | ruiVal = 0; |
---|
2228 | UInt uiBit; |
---|
2229 | if(uiLength) |
---|
2230 | { |
---|
2231 | while( uiLength-- ) |
---|
2232 | { |
---|
2233 | m_pcTDecBinIf->decodeBinEP( uiBit ); |
---|
2234 | ruiVal += uiBit << uiLength; |
---|
2235 | } |
---|
2236 | } |
---|
2237 | else |
---|
2238 | { |
---|
2239 | ruiVal = 0; |
---|
2240 | } |
---|
2241 | ruiVal += minValue; |
---|
2242 | } |
---|
2243 | |
---|
2244 | Void TDecSbac::parseAlfCtrlFlag( UInt &ruiAlfCtrlFlag ) |
---|
2245 | { |
---|
2246 | UInt uiSymbol; |
---|
2247 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUAlfCtrlFlagSCModel.get( 0, 0, 0 ) ); |
---|
2248 | ruiAlfCtrlFlag = uiSymbol; |
---|
2249 | } |
---|
2250 | #endif |
---|
2251 | |
---|
2252 | Void TDecSbac::parseAlfUvlc (UInt& ruiVal) |
---|
2253 | { |
---|
2254 | UInt uiCode; |
---|
2255 | Int i; |
---|
2256 | |
---|
2257 | m_pcTDecBinIf->decodeBin( uiCode, m_cALFUvlcSCModel.get( 0, 0, 0 ) ); |
---|
2258 | if ( uiCode == 0 ) |
---|
2259 | { |
---|
2260 | ruiVal = 0; |
---|
2261 | return; |
---|
2262 | } |
---|
2263 | |
---|
2264 | i=1; |
---|
2265 | while (1) |
---|
2266 | { |
---|
2267 | m_pcTDecBinIf->decodeBin( uiCode, m_cALFUvlcSCModel.get( 0, 0, 1 ) ); |
---|
2268 | if ( uiCode == 0 ) break; |
---|
2269 | i++; |
---|
2270 | } |
---|
2271 | |
---|
2272 | ruiVal = i; |
---|
2273 | } |
---|
2274 | |
---|
2275 | Void TDecSbac::parseAlfSvlc (Int& riVal) |
---|
2276 | { |
---|
2277 | UInt uiCode; |
---|
2278 | Int iSign; |
---|
2279 | Int i; |
---|
2280 | |
---|
2281 | m_pcTDecBinIf->decodeBin( uiCode, m_cALFSvlcSCModel.get( 0, 0, 0 ) ); |
---|
2282 | |
---|
2283 | if ( uiCode == 0 ) |
---|
2284 | { |
---|
2285 | riVal = 0; |
---|
2286 | return; |
---|
2287 | } |
---|
2288 | |
---|
2289 | // read sign |
---|
2290 | m_pcTDecBinIf->decodeBin( uiCode, m_cALFSvlcSCModel.get( 0, 0, 1 ) ); |
---|
2291 | |
---|
2292 | if ( uiCode == 0 ) iSign = 1; |
---|
2293 | else iSign = -1; |
---|
2294 | |
---|
2295 | // read magnitude |
---|
2296 | i=1; |
---|
2297 | while (1) |
---|
2298 | { |
---|
2299 | m_pcTDecBinIf->decodeBin( uiCode, m_cALFSvlcSCModel.get( 0, 0, 2 ) ); |
---|
2300 | if ( uiCode == 0 ) break; |
---|
2301 | i++; |
---|
2302 | } |
---|
2303 | |
---|
2304 | riVal = i*iSign; |
---|
2305 | } |
---|
2306 | |
---|
2307 | #if MTK_SAO |
---|
2308 | Void TDecSbac::parseAoFlag (UInt& ruiVal) |
---|
2309 | { |
---|
2310 | UInt uiSymbol; |
---|
2311 | m_pcTDecBinIf->decodeBin( uiSymbol, m_cAOFlagSCModel.get( 0, 0, 0 ) ); |
---|
2312 | |
---|
2313 | ruiVal = uiSymbol; |
---|
2314 | } |
---|
2315 | |
---|
2316 | Void TDecSbac::parseAoUvlc (UInt& ruiVal) |
---|
2317 | { |
---|
2318 | UInt uiCode; |
---|
2319 | Int i; |
---|
2320 | |
---|
2321 | m_pcTDecBinIf->decodeBin( uiCode, m_cAOUvlcSCModel.get( 0, 0, 0 ) ); |
---|
2322 | if ( uiCode == 0 ) |
---|
2323 | { |
---|
2324 | ruiVal = 0; |
---|
2325 | return; |
---|
2326 | } |
---|
2327 | |
---|
2328 | i=1; |
---|
2329 | while (1) |
---|
2330 | { |
---|
2331 | m_pcTDecBinIf->decodeBin( uiCode, m_cAOUvlcSCModel.get( 0, 0, 1 ) ); |
---|
2332 | if ( uiCode == 0 ) break; |
---|
2333 | i++; |
---|
2334 | } |
---|
2335 | |
---|
2336 | ruiVal = i; |
---|
2337 | } |
---|
2338 | |
---|
2339 | Void TDecSbac::parseAoSvlc (Int& riVal) |
---|
2340 | { |
---|
2341 | UInt uiCode; |
---|
2342 | Int iSign; |
---|
2343 | Int i; |
---|
2344 | |
---|
2345 | m_pcTDecBinIf->decodeBin( uiCode, m_cAOSvlcSCModel.get( 0, 0, 0 ) ); |
---|
2346 | |
---|
2347 | if ( uiCode == 0 ) |
---|
2348 | { |
---|
2349 | riVal = 0; |
---|
2350 | return; |
---|
2351 | } |
---|
2352 | |
---|
2353 | // read sign |
---|
2354 | m_pcTDecBinIf->decodeBin( uiCode, m_cAOSvlcSCModel.get( 0, 0, 1 ) ); |
---|
2355 | |
---|
2356 | if ( uiCode == 0 ) iSign = 1; |
---|
2357 | else iSign = -1; |
---|
2358 | |
---|
2359 | // read magnitude |
---|
2360 | i=1; |
---|
2361 | while (1) |
---|
2362 | { |
---|
2363 | m_pcTDecBinIf->decodeBin( uiCode, m_cAOSvlcSCModel.get( 0, 0, 2 ) ); |
---|
2364 | if ( uiCode == 0 ) break; |
---|
2365 | i++; |
---|
2366 | } |
---|
2367 | |
---|
2368 | riVal = i*iSign; |
---|
2369 | } |
---|
2370 | #endif |
---|