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