1 | |
---|
2 | |
---|
3 | /** \file TDecEntropy.cpp |
---|
4 | \brief entropy decoder class |
---|
5 | */ |
---|
6 | |
---|
7 | #include "TDecEntropy.h" |
---|
8 | |
---|
9 | Void TDecEntropy::setEntropyDecoder ( TDecEntropyIf* p ) |
---|
10 | { |
---|
11 | m_pcEntropyDecoderIf = p; |
---|
12 | } |
---|
13 | |
---|
14 | #include "../TLibCommon/TComAdaptiveLoopFilter.h" |
---|
15 | |
---|
16 | Void TDecEntropy::decodeAux(ALFParam* pAlfParam) |
---|
17 | { |
---|
18 | UInt uiSymbol; |
---|
19 | Int sqrFiltLengthTab[3] = {SQR_FILT_LENGTH_9SYM, SQR_FILT_LENGTH_7SYM, SQR_FILT_LENGTH_5SYM}; |
---|
20 | Int FiltTab[3] = {9, 7, 5}; |
---|
21 | |
---|
22 | pAlfParam->filters_per_group = 0; |
---|
23 | |
---|
24 | memset (pAlfParam->filterPattern, 0 , sizeof(Int)*NO_VAR_BINS); |
---|
25 | #if ENABLE_FORCECOEFF0 |
---|
26 | m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol); |
---|
27 | if (!uiSymbol) pAlfParam->filtNo = -1; |
---|
28 | else pAlfParam->filtNo = uiSymbol; //nonZeroCoeffs |
---|
29 | #else |
---|
30 | pAlfParam->filtNo = 1; //nonZeroCoeffs |
---|
31 | #endif |
---|
32 | |
---|
33 | #if MQT_BA_RA |
---|
34 | m_pcEntropyDecoderIf->parseAlfFlag (uiSymbol); |
---|
35 | pAlfParam->alf_pcr_region_flag = uiSymbol; |
---|
36 | #endif |
---|
37 | |
---|
38 | m_pcEntropyDecoderIf->parseAlfUvlc(uiSymbol); |
---|
39 | Int TabIdx = uiSymbol; |
---|
40 | pAlfParam->realfiltNo = 2-TabIdx; |
---|
41 | pAlfParam->tap = FiltTab[pAlfParam->realfiltNo]; |
---|
42 | #if TI_ALF_MAX_VSIZE_7 |
---|
43 | pAlfParam->tapV = TComAdaptiveLoopFilter::ALFTapHToTapV(pAlfParam->tap); |
---|
44 | #endif |
---|
45 | pAlfParam->num_coeff = sqrFiltLengthTab[pAlfParam->realfiltNo]; |
---|
46 | |
---|
47 | if (pAlfParam->filtNo>=0) |
---|
48 | { |
---|
49 | if(pAlfParam->realfiltNo >= 0) |
---|
50 | { |
---|
51 | // filters_per_fr |
---|
52 | m_pcEntropyDecoderIf->parseAlfUvlc(uiSymbol); |
---|
53 | pAlfParam->noFilters = uiSymbol + 1; |
---|
54 | pAlfParam->filters_per_group = pAlfParam->noFilters; |
---|
55 | |
---|
56 | if(pAlfParam->noFilters == 2) |
---|
57 | { |
---|
58 | m_pcEntropyDecoderIf->parseAlfUvlc(uiSymbol); |
---|
59 | pAlfParam->startSecondFilter = uiSymbol; |
---|
60 | pAlfParam->filterPattern [uiSymbol] = 1; |
---|
61 | } |
---|
62 | else if (pAlfParam->noFilters > 2) |
---|
63 | { |
---|
64 | pAlfParam->filters_per_group = 1; |
---|
65 | for (int i=1; i<NO_VAR_BINS; i++) |
---|
66 | { |
---|
67 | m_pcEntropyDecoderIf->parseAlfFlag (uiSymbol); |
---|
68 | pAlfParam->filterPattern[i] = uiSymbol; |
---|
69 | pAlfParam->filters_per_group += uiSymbol; |
---|
70 | } |
---|
71 | } |
---|
72 | } |
---|
73 | } |
---|
74 | else |
---|
75 | { |
---|
76 | memset (pAlfParam->filterPattern, 0, NO_VAR_BINS*sizeof(Int)); |
---|
77 | } |
---|
78 | // Reconstruct varIndTab[] |
---|
79 | memset(pAlfParam->varIndTab, 0, NO_VAR_BINS * sizeof(int)); |
---|
80 | if(pAlfParam->filtNo>=0) |
---|
81 | { |
---|
82 | for(Int i = 1; i < NO_VAR_BINS; ++i) |
---|
83 | { |
---|
84 | if(pAlfParam->filterPattern[i]) |
---|
85 | pAlfParam->varIndTab[i] = pAlfParam->varIndTab[i-1] + 1; |
---|
86 | else |
---|
87 | pAlfParam->varIndTab[i] = pAlfParam->varIndTab[i-1]; |
---|
88 | } |
---|
89 | } |
---|
90 | } |
---|
91 | |
---|
92 | Void TDecEntropy::readFilterCodingParams(ALFParam* pAlfParam) |
---|
93 | { |
---|
94 | UInt uiSymbol; |
---|
95 | int ind, scanPos; |
---|
96 | int golombIndexBit; |
---|
97 | int kMin; |
---|
98 | int maxScanVal; |
---|
99 | int *pDepthInt; |
---|
100 | int fl; |
---|
101 | |
---|
102 | // Determine fl |
---|
103 | if(pAlfParam->num_coeff == SQR_FILT_LENGTH_9SYM) |
---|
104 | fl = 4; |
---|
105 | else if(pAlfParam->num_coeff == SQR_FILT_LENGTH_7SYM) |
---|
106 | fl = 3; |
---|
107 | else |
---|
108 | fl = 2; |
---|
109 | |
---|
110 | // Determine maxScanVal |
---|
111 | maxScanVal = 0; |
---|
112 | pDepthInt = pDepthIntTab[fl - 2]; |
---|
113 | for(ind = 0; ind < pAlfParam->num_coeff; ind++) |
---|
114 | maxScanVal = max(maxScanVal, pDepthInt[ind]); |
---|
115 | |
---|
116 | // Golomb parameters |
---|
117 | m_pcEntropyDecoderIf->parseAlfUvlc(uiSymbol); |
---|
118 | pAlfParam->minKStart = 1 + uiSymbol; |
---|
119 | |
---|
120 | kMin = pAlfParam->minKStart; |
---|
121 | for(scanPos = 0; scanPos < maxScanVal; scanPos++) |
---|
122 | { |
---|
123 | m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol); |
---|
124 | golombIndexBit = uiSymbol; |
---|
125 | if(golombIndexBit) |
---|
126 | pAlfParam->kMinTab[scanPos] = kMin + 1; |
---|
127 | else |
---|
128 | pAlfParam->kMinTab[scanPos] = kMin; |
---|
129 | kMin = pAlfParam->kMinTab[scanPos]; |
---|
130 | } |
---|
131 | } |
---|
132 | |
---|
133 | Int TDecEntropy::golombDecode(Int k) |
---|
134 | { |
---|
135 | UInt uiSymbol; |
---|
136 | Int q = -1; |
---|
137 | Int nr = 0; |
---|
138 | Int m = (Int)pow(2.0, k); |
---|
139 | Int a; |
---|
140 | |
---|
141 | uiSymbol = 1; |
---|
142 | while (uiSymbol) |
---|
143 | { |
---|
144 | m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol); |
---|
145 | q++; |
---|
146 | } |
---|
147 | for(a = 0; a < k; ++a) // read out the sequential log2(M) bits |
---|
148 | { |
---|
149 | m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol); |
---|
150 | if(uiSymbol) |
---|
151 | nr += 1 << a; |
---|
152 | } |
---|
153 | nr += q * m; // add the bits and the multiple of M |
---|
154 | if(nr != 0) |
---|
155 | { |
---|
156 | m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol); |
---|
157 | nr = (uiSymbol)? nr: -nr; |
---|
158 | } |
---|
159 | return nr; |
---|
160 | } |
---|
161 | |
---|
162 | |
---|
163 | |
---|
164 | Void TDecEntropy::readFilterCoeffs(ALFParam* pAlfParam) |
---|
165 | { |
---|
166 | int ind, scanPos, i; |
---|
167 | int *pDepthInt; |
---|
168 | int fl; |
---|
169 | |
---|
170 | if(pAlfParam->num_coeff == SQR_FILT_LENGTH_9SYM) |
---|
171 | fl = 4; |
---|
172 | else if(pAlfParam->num_coeff == SQR_FILT_LENGTH_7SYM) |
---|
173 | fl = 3; |
---|
174 | else |
---|
175 | fl = 2; |
---|
176 | |
---|
177 | pDepthInt = pDepthIntTab[fl - 2]; |
---|
178 | |
---|
179 | for(ind = 0; ind < pAlfParam->filters_per_group_diff; ++ind) |
---|
180 | { |
---|
181 | for(i = 0; i < pAlfParam->num_coeff; i++) |
---|
182 | { |
---|
183 | scanPos = pDepthInt[i] - 1; |
---|
184 | pAlfParam->coeffmulti[ind][i] = golombDecode(pAlfParam->kMinTab[scanPos]); |
---|
185 | } |
---|
186 | } |
---|
187 | |
---|
188 | } |
---|
189 | Void TDecEntropy::decodeFilterCoeff (ALFParam* pAlfParam) |
---|
190 | { |
---|
191 | readFilterCodingParams (pAlfParam); |
---|
192 | readFilterCoeffs (pAlfParam); |
---|
193 | } |
---|
194 | |
---|
195 | |
---|
196 | |
---|
197 | Void TDecEntropy::decodeFilt(ALFParam* pAlfParam) |
---|
198 | { |
---|
199 | UInt uiSymbol; |
---|
200 | |
---|
201 | if (pAlfParam->filtNo >= 0) |
---|
202 | { |
---|
203 | pAlfParam->filters_per_group_diff = pAlfParam->filters_per_group; |
---|
204 | if (pAlfParam->filters_per_group > 1) |
---|
205 | { |
---|
206 | #if ENABLE_FORCECOEFF0 |
---|
207 | m_pcEntropyDecoderIf->parseAlfFlag (uiSymbol); |
---|
208 | pAlfParam->forceCoeff0 = uiSymbol; |
---|
209 | |
---|
210 | if (pAlfParam->forceCoeff0) |
---|
211 | { |
---|
212 | pAlfParam->filters_per_group_diff = 0; |
---|
213 | for (int i=0; i<pAlfParam->filters_per_group; i++) |
---|
214 | { |
---|
215 | m_pcEntropyDecoderIf->parseAlfFlag (uiSymbol); |
---|
216 | pAlfParam->codedVarBins[i] = uiSymbol; |
---|
217 | pAlfParam->filters_per_group_diff += uiSymbol; |
---|
218 | } |
---|
219 | } |
---|
220 | else |
---|
221 | #else |
---|
222 | pAlfParam->forceCoeff0 = 0; |
---|
223 | #endif |
---|
224 | { |
---|
225 | for (int i=0; i<NO_VAR_BINS; i++) |
---|
226 | pAlfParam->codedVarBins[i] = 1; |
---|
227 | |
---|
228 | } |
---|
229 | m_pcEntropyDecoderIf->parseAlfFlag (uiSymbol); |
---|
230 | pAlfParam->predMethod = uiSymbol; |
---|
231 | } |
---|
232 | else |
---|
233 | { |
---|
234 | pAlfParam->forceCoeff0 = 0; |
---|
235 | pAlfParam->predMethod = 0; |
---|
236 | } |
---|
237 | |
---|
238 | decodeFilterCoeff (pAlfParam); |
---|
239 | } |
---|
240 | } |
---|
241 | |
---|
242 | Void TDecEntropy::decodeAlfParam(ALFParam* pAlfParam) |
---|
243 | { |
---|
244 | UInt uiSymbol; |
---|
245 | Int iSymbol; |
---|
246 | m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol); |
---|
247 | pAlfParam->alf_flag = uiSymbol; |
---|
248 | |
---|
249 | if (!pAlfParam->alf_flag) |
---|
250 | { |
---|
251 | m_pcEntropyDecoderIf->setAlfCtrl(false); |
---|
252 | m_pcEntropyDecoderIf->setMaxAlfCtrlDepth(0); //unncessary |
---|
253 | return; |
---|
254 | } |
---|
255 | |
---|
256 | Int pos; |
---|
257 | decodeAux(pAlfParam); |
---|
258 | decodeFilt(pAlfParam); |
---|
259 | // filter parameters for chroma |
---|
260 | m_pcEntropyDecoderIf->parseAlfUvlc(uiSymbol); |
---|
261 | pAlfParam->chroma_idc = uiSymbol; |
---|
262 | |
---|
263 | if(pAlfParam->chroma_idc) |
---|
264 | { |
---|
265 | m_pcEntropyDecoderIf->parseAlfUvlc(uiSymbol); |
---|
266 | pAlfParam->tap_chroma = (uiSymbol<<1) + 5; |
---|
267 | pAlfParam->num_coeff_chroma = ((pAlfParam->tap_chroma*pAlfParam->tap_chroma+1)>>1) + 1; |
---|
268 | |
---|
269 | // filter coefficients for chroma |
---|
270 | for(pos=0; pos<pAlfParam->num_coeff_chroma; pos++) |
---|
271 | { |
---|
272 | m_pcEntropyDecoderIf->parseAlfSvlc(iSymbol); |
---|
273 | pAlfParam->coeff_chroma[pos] = iSymbol; |
---|
274 | } |
---|
275 | } |
---|
276 | |
---|
277 | // region control parameters for luma |
---|
278 | m_pcEntropyDecoderIf->parseAlfFlag(uiSymbol); |
---|
279 | pAlfParam->cu_control_flag = uiSymbol; |
---|
280 | if (pAlfParam->cu_control_flag) |
---|
281 | { |
---|
282 | m_pcEntropyDecoderIf->setAlfCtrl(true); |
---|
283 | m_pcEntropyDecoderIf->parseAlfCtrlDepth(uiSymbol); |
---|
284 | m_pcEntropyDecoderIf->setMaxAlfCtrlDepth(uiSymbol); |
---|
285 | #if TSB_ALF_HEADER |
---|
286 | pAlfParam->alf_max_depth = uiSymbol; |
---|
287 | decodeAlfCtrlParam(pAlfParam); |
---|
288 | #endif |
---|
289 | } |
---|
290 | else |
---|
291 | { |
---|
292 | m_pcEntropyDecoderIf->setAlfCtrl(false); |
---|
293 | m_pcEntropyDecoderIf->setMaxAlfCtrlDepth(0); //unncessary |
---|
294 | } |
---|
295 | } |
---|
296 | |
---|
297 | #if TSB_ALF_HEADER |
---|
298 | Void TDecEntropy::decodeAlfCtrlParam( ALFParam* pAlfParam ) |
---|
299 | { |
---|
300 | UInt uiSymbol; |
---|
301 | m_pcEntropyDecoderIf->parseAlfFlagNum( uiSymbol, pAlfParam->num_cus_in_frame, pAlfParam->alf_max_depth ); |
---|
302 | pAlfParam->num_alf_cu_flag = uiSymbol; |
---|
303 | |
---|
304 | for(UInt i=0; i<pAlfParam->num_alf_cu_flag; i++) |
---|
305 | { |
---|
306 | m_pcEntropyDecoderIf->parseAlfCtrlFlag( pAlfParam->alf_cu_flag[i] ); |
---|
307 | } |
---|
308 | } |
---|
309 | #endif |
---|
310 | |
---|
311 | Void TDecEntropy::decodeAlfCtrlFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
312 | { |
---|
313 | m_pcEntropyDecoderIf->parseAlfCtrlFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
314 | } |
---|
315 | |
---|
316 | Void TDecEntropy::decodeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
317 | { |
---|
318 | m_pcEntropyDecoderIf->parseSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
319 | } |
---|
320 | |
---|
321 | /** decode merge flag |
---|
322 | * \param pcSubCU |
---|
323 | * \param uiAbsPartIdx |
---|
324 | * \param uiDepth |
---|
325 | * \param uiPUIdx |
---|
326 | * \returns Void |
---|
327 | */ |
---|
328 | Void TDecEntropy::decodeMergeFlag( TComDataCU* pcSubCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) |
---|
329 | { |
---|
330 | #if !CHANGE_GET_MERGE_CANDIDATE |
---|
331 | UInt uiNumCand = 0; |
---|
332 | for(UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ ) |
---|
333 | { |
---|
334 | if( pcSubCU->getNeighbourCandIdx( uiIter, uiAbsPartIdx ) == ( uiIter + 1 ) ) |
---|
335 | { |
---|
336 | uiNumCand++; |
---|
337 | break; |
---|
338 | } |
---|
339 | } |
---|
340 | if( uiNumCand ) |
---|
341 | { |
---|
342 | #endif |
---|
343 | // at least one merge candidate exists |
---|
344 | m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx ); |
---|
345 | #if !CHANGE_GET_MERGE_CANDIDATE |
---|
346 | } |
---|
347 | else |
---|
348 | { |
---|
349 | assert( !pcSubCU->getMergeFlag( uiAbsPartIdx ) ); |
---|
350 | } |
---|
351 | #endif |
---|
352 | } |
---|
353 | |
---|
354 | /** decode merge index |
---|
355 | * \param pcCU |
---|
356 | * \param uiPartIdx |
---|
357 | * \param uiAbsPartIdx |
---|
358 | * \param puhInterDirNeighbours pointer to list of inter direction from the casual neighbours |
---|
359 | * \param pcMvFieldNeighbours pointer to list of motion vector field from the casual neighbours |
---|
360 | * \param uiDepth |
---|
361 | * \returns Void |
---|
362 | */ |
---|
363 | Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, PartSize eCUMode, UChar* puhInterDirNeighbours, TComMvField* pcMvFieldNeighbours, UInt uiDepth ) |
---|
364 | { |
---|
365 | UInt uiNumCand = 0; |
---|
366 | for(UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ ) |
---|
367 | { |
---|
368 | if( pcCU->getNeighbourCandIdx( uiIter, uiAbsPartIdx ) == ( uiIter + 1 ) ) |
---|
369 | { |
---|
370 | uiNumCand++; |
---|
371 | } |
---|
372 | } |
---|
373 | #if MW_MVI_SIGNALLING_MODE == 1 |
---|
374 | if( pcCU->getSlice()->getSPS()->getUseMVI() && pcCU->getSlice()->getSliceType() != I_SLICE && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
---|
375 | uiNumCand++; |
---|
376 | #endif |
---|
377 | // Merge to left or above depending on uiMergeIndex |
---|
378 | UInt uiMergeIndex = 0; |
---|
379 | if ( uiNumCand > 1 ) |
---|
380 | { |
---|
381 | // two different motion parameter sets exist |
---|
382 | // parse merge index. |
---|
383 | m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex, uiAbsPartIdx, uiDepth ); |
---|
384 | } |
---|
385 | else |
---|
386 | { |
---|
387 | for( UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ ) |
---|
388 | { |
---|
389 | if( pcCU->getNeighbourCandIdx( uiIter, uiAbsPartIdx ) == ( uiIter + 1 ) ) |
---|
390 | { |
---|
391 | uiMergeIndex = uiIter; |
---|
392 | break; |
---|
393 | } |
---|
394 | } |
---|
395 | } |
---|
396 | pcCU->setMergeIndexSubParts( uiMergeIndex, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
397 | pcCU->setInterDirSubParts( puhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
398 | |
---|
399 | TComMv cTmpMv( 0, 0 ); |
---|
400 | if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) //if ( ref. frame list0 has at least 1 entry ) |
---|
401 | { |
---|
402 | pcCU->setMVPIdxSubParts( 0, REF_PIC_LIST_0, uiAbsPartIdx, uiPartIdx, uiDepth); |
---|
403 | pcCU->setMVPNumSubParts( 0, REF_PIC_LIST_0, uiAbsPartIdx, uiPartIdx, uiDepth); |
---|
404 | pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvd( cTmpMv, eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
405 | pcCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( pcMvFieldNeighbours[ 2*uiMergeIndex ].getMv(), pcMvFieldNeighbours[ 2*uiMergeIndex ].getRefIdx(), eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
406 | |
---|
407 | } |
---|
408 | if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) //if ( ref. frame list1 has at least 1 entry ) |
---|
409 | { |
---|
410 | pcCU->setMVPIdxSubParts( 0, REF_PIC_LIST_1, uiAbsPartIdx, uiPartIdx, uiDepth); |
---|
411 | pcCU->setMVPNumSubParts( 0, REF_PIC_LIST_1, uiAbsPartIdx, uiPartIdx, uiDepth); |
---|
412 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvd( cTmpMv, eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
413 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( pcMvFieldNeighbours[ 2*uiMergeIndex + 1 ].getMv(), pcMvFieldNeighbours[ 2*uiMergeIndex + 1 ].getRefIdx(), eCUMode, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
414 | } |
---|
415 | } |
---|
416 | |
---|
417 | |
---|
418 | Void |
---|
419 | TDecEntropy::decodeResPredFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU, UInt uiPUIdx ) |
---|
420 | { |
---|
421 | Bool bResPredAvailable = false; |
---|
422 | Bool bResPredFlag = false; |
---|
423 | |
---|
424 | Bool bResPredAllowed = (!pcCU->getSlice()->getSPS()->isDepth () ); |
---|
425 | bResPredAllowed = bResPredAllowed && ( pcCU->getSlice()->getSPS()->getViewId () ); |
---|
426 | bResPredAllowed = bResPredAllowed && ( pcCU->getSlice()->getSPS()->getMultiviewResPredMode() ); |
---|
427 | bResPredAllowed = bResPredAllowed && (!pcCU->isIntra ( uiAbsPartIdx ) ); |
---|
428 | |
---|
429 | // check if supported |
---|
430 | if( bResPredAllowed ) |
---|
431 | { |
---|
432 | bResPredAvailable = pcSubCU->getResidualSamples( uiPUIdx ); |
---|
433 | } |
---|
434 | |
---|
435 | // read from bitstream |
---|
436 | if( bResPredAvailable ) |
---|
437 | { |
---|
438 | m_pcEntropyDecoderIf->parseResPredFlag( pcCU, bResPredFlag, uiAbsPartIdx, uiDepth ); |
---|
439 | } |
---|
440 | |
---|
441 | // set data |
---|
442 | pcCU->setResPredAvailSubParts ( bResPredAvailable, uiAbsPartIdx, uiPUIdx, uiDepth ); |
---|
443 | pcCU->setResPredFlagSubParts ( bResPredFlag, uiAbsPartIdx, uiPUIdx, uiDepth ); |
---|
444 | } |
---|
445 | |
---|
446 | |
---|
447 | Void TDecEntropy::decodeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
448 | { |
---|
449 | m_pcEntropyDecoderIf->parseSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
450 | } |
---|
451 | |
---|
452 | #if MW_MVI_SIGNALLING_MODE == 0 |
---|
453 | Void TDecEntropy::decodeMvInheritanceFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
454 | { |
---|
455 | m_pcEntropyDecoderIf->parseMvInheritanceFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
456 | } |
---|
457 | #endif |
---|
458 | |
---|
459 | Void TDecEntropy::decodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
460 | { |
---|
461 | m_pcEntropyDecoderIf->parsePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
462 | } |
---|
463 | |
---|
464 | Void TDecEntropy::decodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
465 | { |
---|
466 | m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
467 | } |
---|
468 | |
---|
469 | Void TDecEntropy::decodePredInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ) |
---|
470 | { |
---|
471 | PartSize eMode = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
472 | |
---|
473 | if( pcCU->isIntra( uiAbsPartIdx ) ) // If it is Intra mode, encode intra prediction mode. |
---|
474 | { |
---|
475 | if( eMode == SIZE_NxN ) // if it is NxN size, encode 4 intra directions. |
---|
476 | { |
---|
477 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth(uiAbsPartIdx) << 1 ) ) >> 2; |
---|
478 | // if it is NxN size, this size might be the smallest partition size. // if it is NxN size, this size might be the smallest partition size. |
---|
479 | decodeIntraDirModeLuma( pcCU, uiAbsPartIdx, uiDepth+1 ); |
---|
480 | decodeIntraDirModeLuma( pcCU, uiAbsPartIdx + uiPartOffset, uiDepth+1 ); |
---|
481 | decodeIntraDirModeLuma( pcCU, uiAbsPartIdx + uiPartOffset*2, uiDepth+1 ); |
---|
482 | decodeIntraDirModeLuma( pcCU, uiAbsPartIdx + uiPartOffset*3, uiDepth+1 ); |
---|
483 | decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
484 | } |
---|
485 | else // if it is not NxN size, encode 1 intra directions |
---|
486 | { |
---|
487 | decodeIntraDirModeLuma ( pcCU, uiAbsPartIdx, uiDepth ); |
---|
488 | decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
489 | } |
---|
490 | } |
---|
491 | else // if it is Inter mode, encode motion vector and reference index |
---|
492 | { |
---|
493 | if ( pcCU->getSlice()->getSPS()->getUseMRG() ) |
---|
494 | { |
---|
495 | decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU ); |
---|
496 | } |
---|
497 | else |
---|
498 | { |
---|
499 | #if MS_LCEC_LOOKUP_TABLE_EXCEPTION |
---|
500 | if ( pcCU->getSlice()->getSymbolMode() == 0 ) |
---|
501 | { |
---|
502 | if ( pcCU->isSuroundingRefIdxException( uiAbsPartIdx ) ) |
---|
503 | { |
---|
504 | pcCU->getSlice()->setRefIdxCombineCoding( false ); |
---|
505 | } |
---|
506 | else |
---|
507 | { |
---|
508 | pcCU->getSlice()->setRefIdxCombineCoding( true ); |
---|
509 | } |
---|
510 | } |
---|
511 | #endif |
---|
512 | decodeInterDir( pcCU, uiAbsPartIdx, uiDepth ); |
---|
513 | |
---|
514 | if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_0 ) > 0 ) //if ( ref. frame list0 has at least 1 entry ) |
---|
515 | { |
---|
516 | decodeRefFrmIdx ( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_0 ); |
---|
517 | decodeMvd ( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_0 ); |
---|
518 | decodeMVPIdx( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_0, pcSubCU); |
---|
519 | } |
---|
520 | |
---|
521 | if ( pcCU->getSlice()->getNumRefIdx( REF_PIC_LIST_1 ) > 0 ) //if ( ref. frame list1 has at least 1 entry ) |
---|
522 | { |
---|
523 | decodeRefFrmIdx ( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_1 ); |
---|
524 | decodeMvd ( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_1 ); |
---|
525 | decodeMVPIdx( pcCU, uiAbsPartIdx, uiDepth, REF_PIC_LIST_1, pcSubCU); |
---|
526 | } |
---|
527 | } |
---|
528 | } |
---|
529 | } |
---|
530 | |
---|
531 | Void TDecEntropy::decodeIntraDirModeLuma ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
532 | { |
---|
533 | m_pcEntropyDecoderIf->parseIntraDirLumaAng( pcCU, uiAbsPartIdx, uiDepth ); |
---|
534 | } |
---|
535 | |
---|
536 | Void TDecEntropy::decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
537 | { |
---|
538 | m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
539 | } |
---|
540 | |
---|
541 | Void TDecEntropy::decodeInterDir( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
542 | { |
---|
543 | if ( pcCU->getSlice()->isInterP() ) |
---|
544 | { |
---|
545 | memset( pcCU->getInterDir() + uiAbsPartIdx, 1, sizeof(UChar)*( pcCU->getTotalNumPart() >> (uiDepth << 1) ) ); |
---|
546 | return; |
---|
547 | } |
---|
548 | |
---|
549 | UInt uiInterDir; |
---|
550 | |
---|
551 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( uiDepth << 1 ) ) >> 2; |
---|
552 | |
---|
553 | switch ( pcCU->getPartitionSize( uiAbsPartIdx ) ) |
---|
554 | { |
---|
555 | |
---|
556 | case SIZE_2Nx2N: |
---|
557 | { |
---|
558 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth ); |
---|
559 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
560 | break; |
---|
561 | } |
---|
562 | |
---|
563 | case SIZE_2NxN: |
---|
564 | { |
---|
565 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth ); |
---|
566 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
567 | |
---|
568 | uiAbsPartIdx += uiPartOffset << 1; |
---|
569 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth ); |
---|
570 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
571 | break; |
---|
572 | } |
---|
573 | case SIZE_Nx2N: |
---|
574 | { |
---|
575 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth ); |
---|
576 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
577 | |
---|
578 | uiAbsPartIdx += uiPartOffset; |
---|
579 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth ); |
---|
580 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
581 | break; |
---|
582 | } |
---|
583 | case SIZE_NxN: |
---|
584 | { |
---|
585 | for ( Int iPartIdx = 0; iPartIdx < 4; iPartIdx++ ) |
---|
586 | { |
---|
587 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth ); |
---|
588 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
589 | uiAbsPartIdx += uiPartOffset; |
---|
590 | } |
---|
591 | break; |
---|
592 | } |
---|
593 | default: |
---|
594 | break; |
---|
595 | } |
---|
596 | |
---|
597 | return; |
---|
598 | } |
---|
599 | |
---|
600 | /** decode motion information for every PU block |
---|
601 | * \param pcCU |
---|
602 | * \param uiPartIdx |
---|
603 | * \param uiAbsPartIdx |
---|
604 | * \param uiDepth |
---|
605 | * \param pcSubCU |
---|
606 | * \returns Void |
---|
607 | */ |
---|
608 | Void TDecEntropy::decodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ) |
---|
609 | { |
---|
610 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
611 | UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) ); |
---|
612 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
613 | |
---|
614 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
615 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
616 | for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset ) |
---|
617 | { |
---|
618 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
619 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
620 | UInt uiNeighbourCandIdx[MRG_MAX_NUM_CANDS]; //MVs with same idx => same cand |
---|
621 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ++ui ) |
---|
622 | { |
---|
623 | uhInterDirNeighbours[ui] = 0; |
---|
624 | uiNeighbourCandIdx[ui] = 0; |
---|
625 | } |
---|
626 | #if !CHANGE_GET_MERGE_CANDIDATE |
---|
627 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, uiNeighbourCandIdx ); |
---|
628 | for(UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ ) |
---|
629 | { |
---|
630 | pcCU->setNeighbourCandIdxSubParts( uiIter, uiNeighbourCandIdx[uiIter], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
631 | } |
---|
632 | #endif |
---|
633 | #if PART_MRG |
---|
634 | if (pcCU->getWidth( uiAbsPartIdx ) > 8 && uiNumPU == 2 && uiPartIdx == 0) |
---|
635 | { |
---|
636 | pcCU->setMergeFlagSubParts( true, uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
637 | } |
---|
638 | else |
---|
639 | #endif |
---|
640 | decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
641 | if ( pcCU->getMergeFlag( uiSubPartIdx ) ) |
---|
642 | { |
---|
643 | #if CHANGE_GET_MERGE_CANDIDATE |
---|
644 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, uiNeighbourCandIdx ); |
---|
645 | for(UInt uiIter = 0; uiIter < MRG_MAX_NUM_CANDS; uiIter++ ) |
---|
646 | { |
---|
647 | pcCU->setNeighbourCandIdxSubParts( uiIter, uiNeighbourCandIdx[uiIter], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
648 | } |
---|
649 | #endif |
---|
650 | decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, ePartSize, uhInterDirNeighbours, cMvFieldNeighbours, uiDepth ); |
---|
651 | } |
---|
652 | else |
---|
653 | { |
---|
654 | #if MS_LCEC_LOOKUP_TABLE_EXCEPTION |
---|
655 | if ( pcCU->getSlice()->getSymbolMode() == 0 ) |
---|
656 | { |
---|
657 | if ( pcCU->isSuroundingRefIdxException( uiAbsPartIdx ) ) |
---|
658 | { |
---|
659 | pcCU->getSlice()->setRefIdxCombineCoding( false ); |
---|
660 | } |
---|
661 | else |
---|
662 | { |
---|
663 | pcCU->getSlice()->setRefIdxCombineCoding( true ); |
---|
664 | } |
---|
665 | } |
---|
666 | #endif |
---|
667 | decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
668 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
669 | { |
---|
670 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
671 | { |
---|
672 | decodeRefFrmIdxPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
673 | decodeMvdPU ( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
674 | decodeMVPIdxPU ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
675 | } |
---|
676 | } |
---|
677 | } |
---|
678 | } |
---|
679 | return; |
---|
680 | } |
---|
681 | |
---|
682 | /** decode inter direction for a PU block |
---|
683 | * \param pcCU |
---|
684 | * \param uiAbsPartIdx |
---|
685 | * \param uiDepth |
---|
686 | * \param uiPartIdx |
---|
687 | * \returns Void |
---|
688 | */ |
---|
689 | Void TDecEntropy::decodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx ) |
---|
690 | { |
---|
691 | UInt uiInterDir; |
---|
692 | |
---|
693 | if ( pcCU->getSlice()->isInterP() ) |
---|
694 | { |
---|
695 | uiInterDir = 1; |
---|
696 | } |
---|
697 | else |
---|
698 | { |
---|
699 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth ); |
---|
700 | } |
---|
701 | |
---|
702 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
703 | } |
---|
704 | |
---|
705 | Void TDecEntropy::decodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
706 | { |
---|
707 | #if DCM_COMB_LIST |
---|
708 | if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getInterDir( uiAbsPartIdx ) != 3) |
---|
709 | { |
---|
710 | if(eRefList == REF_PIC_LIST_1) |
---|
711 | { |
---|
712 | return; |
---|
713 | } |
---|
714 | |
---|
715 | Int iRefFrmIdx = 0; |
---|
716 | Int iRefFrmIdxTemp; |
---|
717 | UInt uiInterDir; |
---|
718 | RefPicList eRefListTemp; |
---|
719 | |
---|
720 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
721 | |
---|
722 | if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 ) |
---|
723 | { |
---|
724 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C ); |
---|
725 | }else{ |
---|
726 | iRefFrmIdx=0; |
---|
727 | } |
---|
728 | uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1; |
---|
729 | iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx); |
---|
730 | eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx); |
---|
731 | |
---|
732 | pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, ePartSize, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
733 | |
---|
734 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
735 | } |
---|
736 | else |
---|
737 | { |
---|
738 | #endif |
---|
739 | |
---|
740 | Int iRefFrmIdx = 0; |
---|
741 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
742 | |
---|
743 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx ) |
---|
744 | { |
---|
745 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
746 | } |
---|
747 | else if ( !iParseRefFrmIdx ) |
---|
748 | { |
---|
749 | iRefFrmIdx = NOT_VALID; |
---|
750 | } |
---|
751 | else |
---|
752 | { |
---|
753 | iRefFrmIdx = 0; |
---|
754 | } |
---|
755 | |
---|
756 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
757 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, ePartSize, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
758 | |
---|
759 | #if DCM_COMB_LIST |
---|
760 | } |
---|
761 | #endif |
---|
762 | } |
---|
763 | |
---|
764 | /** decode motion vector difference for a PU block |
---|
765 | * \param pcCU |
---|
766 | * \param uiAbsPartIdx |
---|
767 | * \param uiDepth |
---|
768 | * \param uiPartIdx |
---|
769 | * \param eRefList |
---|
770 | * \returns Void |
---|
771 | */ |
---|
772 | Void TDecEntropy::decodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
773 | { |
---|
774 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
775 | { |
---|
776 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, uiPartIdx, uiDepth, eRefList ); |
---|
777 | } |
---|
778 | } |
---|
779 | |
---|
780 | Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
781 | { |
---|
782 | Int iMVPIdx; |
---|
783 | |
---|
784 | TComMv cZeroMv( 0, 0 ); |
---|
785 | TComMv cMv = cZeroMv; |
---|
786 | Int iRefIdx = -1; |
---|
787 | |
---|
788 | TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList ); |
---|
789 | AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo(); |
---|
790 | |
---|
791 | iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr); |
---|
792 | iMVPIdx = -1; |
---|
793 | cMv = cZeroMv; |
---|
794 | pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo); |
---|
795 | #if DCM_SIMPLIFIED_MVP==0 |
---|
796 | pcSubCU->clearMVPCand(pcSubCUMvField->getMvd(uiPartAddr), pAMVPInfo); |
---|
797 | #endif |
---|
798 | pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth); |
---|
799 | if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) && (pAMVPInfo->iN > 1) && (pcSubCU->getAMVPMode(uiPartAddr) == AM_EXPL) ) |
---|
800 | { |
---|
801 | m_pcEntropyDecoderIf->parseMVPIdx( pcSubCU, iMVPIdx, pAMVPInfo->iN, uiPartAddr, uiDepth, eRefList ); |
---|
802 | } |
---|
803 | pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth ); |
---|
804 | if ( iRefIdx >= 0 ) |
---|
805 | { |
---|
806 | m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, iRefIdx, cMv); |
---|
807 | cMv += pcSubCUMvField->getMvd( uiPartAddr ); |
---|
808 | } |
---|
809 | |
---|
810 | PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr ); |
---|
811 | pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, uiPartIdx, 0); |
---|
812 | } |
---|
813 | |
---|
814 | Void TDecEntropy::decodeMVPIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList, TComDataCU* pcSubCU ) |
---|
815 | { |
---|
816 | Int iMVPIdx; |
---|
817 | |
---|
818 | TComMv cZeroMv( 0, 0 ); |
---|
819 | TComMv cMv = cZeroMv; |
---|
820 | Int iRefIdx = -1; |
---|
821 | |
---|
822 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( uiDepth << 1 ) ) >> 2; |
---|
823 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
824 | |
---|
825 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, eRefList ); |
---|
826 | |
---|
827 | TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList ); |
---|
828 | AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo(); |
---|
829 | |
---|
830 | switch ( ePartSize ) |
---|
831 | { |
---|
832 | case SIZE_2Nx2N: |
---|
833 | { |
---|
834 | iRefIdx = pcSubCUMvField->getRefIdx(0); |
---|
835 | iMVPIdx =-1; |
---|
836 | cMv = cZeroMv; |
---|
837 | pcSubCU->fillMvpCand(0, 0, eRefList, iRefIdx, pAMVPInfo); |
---|
838 | #if DCM_SIMPLIFIED_MVP==0 |
---|
839 | pcSubCU->clearMVPCand(pcSubCUMvField->getMvd(0), pAMVPInfo); |
---|
840 | #endif |
---|
841 | pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, 0, 0, uiDepth); |
---|
842 | if ( (pcSubCU->getInterDir(0) & ( 1 << eRefList )) && (pAMVPInfo->iN > 1) && (pcSubCU->getAMVPMode(0) == AM_EXPL) ) |
---|
843 | { |
---|
844 | m_pcEntropyDecoderIf->parseMVPIdx( pcSubCU, iMVPIdx, pAMVPInfo->iN, uiAbsPartIdx, uiDepth, eRefList ); |
---|
845 | } |
---|
846 | pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, 0, 0, uiDepth ); |
---|
847 | |
---|
848 | if ( iRefIdx >= 0 ) |
---|
849 | { |
---|
850 | m_pcPrediction->getMvPredAMVP( pcSubCU, 0, 0, eRefList, iRefIdx, cMv); |
---|
851 | cMv += pcSubCUMvField->getMvd( 0 ); |
---|
852 | } |
---|
853 | |
---|
854 | pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, 0, 0, 0); |
---|
855 | break; |
---|
856 | } |
---|
857 | case SIZE_2NxN: |
---|
858 | { |
---|
859 | for ( UInt uiPartIdx = 0, uiPartAddr = 0; uiPartIdx < 2; uiPartIdx++, uiPartAddr+=(uiPartOffset << 1)) |
---|
860 | { |
---|
861 | iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr); |
---|
862 | iMVPIdx =-1; |
---|
863 | cMv = cZeroMv; |
---|
864 | pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo); |
---|
865 | #if DCM_SIMPLIFIED_MVP==0 |
---|
866 | pcSubCU->clearMVPCand(pcSubCUMvField->getMvd(uiPartAddr), pAMVPInfo); |
---|
867 | #endif |
---|
868 | pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth); |
---|
869 | if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) && (pAMVPInfo->iN > 1) && (pcSubCU->getAMVPMode(uiPartAddr) == AM_EXPL) ) |
---|
870 | { |
---|
871 | m_pcEntropyDecoderIf->parseMVPIdx( pcSubCU, iMVPIdx, pAMVPInfo->iN, uiPartAddr, uiDepth, eRefList ); |
---|
872 | } |
---|
873 | pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth ); |
---|
874 | if ( iRefIdx >= 0 ) |
---|
875 | { |
---|
876 | m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, iRefIdx, cMv); |
---|
877 | cMv += pcSubCUMvField->getMvd( uiPartAddr ); |
---|
878 | } |
---|
879 | |
---|
880 | pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, uiPartIdx, 0); |
---|
881 | |
---|
882 | } |
---|
883 | break; |
---|
884 | } |
---|
885 | case SIZE_Nx2N: |
---|
886 | { |
---|
887 | for ( UInt uiPartIdx = 0, uiPartAddr = 0; uiPartIdx < 2; uiPartIdx++, uiPartAddr+=uiPartOffset) |
---|
888 | { |
---|
889 | iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr); |
---|
890 | iMVPIdx =-1; |
---|
891 | cMv = cZeroMv; |
---|
892 | pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo); |
---|
893 | #if DCM_SIMPLIFIED_MVP==0 |
---|
894 | pcSubCU->clearMVPCand(pcSubCUMvField->getMvd(uiPartAddr), pAMVPInfo); |
---|
895 | #endif |
---|
896 | pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth); |
---|
897 | if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) && (pAMVPInfo->iN > 1) && (pcSubCU->getAMVPMode(uiPartAddr) == AM_EXPL) ) |
---|
898 | { |
---|
899 | m_pcEntropyDecoderIf->parseMVPIdx( pcSubCU, iMVPIdx, pAMVPInfo->iN, uiPartAddr, uiDepth, eRefList ); |
---|
900 | } |
---|
901 | pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth ); |
---|
902 | |
---|
903 | if ( iRefIdx >= 0 ) |
---|
904 | { |
---|
905 | m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, iRefIdx, cMv); |
---|
906 | cMv += pcSubCUMvField->getMvd( uiPartAddr ); |
---|
907 | } |
---|
908 | |
---|
909 | pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, uiPartIdx, 0); |
---|
910 | |
---|
911 | } |
---|
912 | break; |
---|
913 | } |
---|
914 | case SIZE_NxN: |
---|
915 | { |
---|
916 | for ( UInt uiPartIdx = 0, uiPartAddr = 0; uiPartIdx < 4; uiPartIdx++, uiPartAddr+=uiPartOffset) |
---|
917 | { |
---|
918 | iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr); |
---|
919 | iMVPIdx =-1; |
---|
920 | cMv = cZeroMv; |
---|
921 | pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo); |
---|
922 | #if DCM_SIMPLIFIED_MVP==0 |
---|
923 | pcSubCU->clearMVPCand(pcSubCUMvField->getMvd(uiPartAddr), pAMVPInfo); |
---|
924 | #endif |
---|
925 | pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth); |
---|
926 | if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) && (pAMVPInfo->iN > 1) && (pcSubCU->getAMVPMode(uiPartAddr) == AM_EXPL) ) |
---|
927 | { |
---|
928 | m_pcEntropyDecoderIf->parseMVPIdx( pcSubCU, iMVPIdx, pAMVPInfo->iN, uiPartAddr, uiDepth, eRefList ); |
---|
929 | } |
---|
930 | pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth ); |
---|
931 | if ( iRefIdx >= 0 ) |
---|
932 | { |
---|
933 | m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, iRefIdx, cMv); |
---|
934 | cMv += pcSubCUMvField->getMvd( uiPartAddr ); |
---|
935 | } |
---|
936 | |
---|
937 | pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, uiPartIdx, 0); |
---|
938 | } |
---|
939 | break; |
---|
940 | } |
---|
941 | default: |
---|
942 | break; |
---|
943 | } |
---|
944 | |
---|
945 | return; |
---|
946 | } |
---|
947 | |
---|
948 | /** decode reference frame index |
---|
949 | * \param pcCU |
---|
950 | * \param uiAbsPartIdx |
---|
951 | * \param uiDepth |
---|
952 | * \param eRefList |
---|
953 | * \returns Void |
---|
954 | */ |
---|
955 | Void TDecEntropy::decodeRefFrmIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
956 | { |
---|
957 | #if DCM_COMB_LIST |
---|
958 | if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0) |
---|
959 | { |
---|
960 | Int iRefFrmIdx = 0; |
---|
961 | |
---|
962 | Int iRefFrmIdxTemp; |
---|
963 | UInt uiInterDir; |
---|
964 | RefPicList eRefListTemp; |
---|
965 | |
---|
966 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( uiDepth << 1 ) ) >> 2; |
---|
967 | |
---|
968 | switch ( pcCU->getPartitionSize( uiAbsPartIdx ) ) |
---|
969 | { |
---|
970 | case SIZE_2Nx2N: |
---|
971 | { |
---|
972 | if( pcCU->getInterDir( uiAbsPartIdx ) != 3 && eRefList == REF_PIC_LIST_0) |
---|
973 | { |
---|
974 | if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 ) |
---|
975 | { |
---|
976 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C ); |
---|
977 | } |
---|
978 | else |
---|
979 | { |
---|
980 | iRefFrmIdx=0; |
---|
981 | } |
---|
982 | uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1; |
---|
983 | iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx); |
---|
984 | eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx); |
---|
985 | |
---|
986 | pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, SIZE_2Nx2N, uiAbsPartIdx, 0, uiDepth ); |
---|
987 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
988 | } |
---|
989 | else if(pcCU->getInterDir( uiAbsPartIdx ) == 3) |
---|
990 | { |
---|
991 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
992 | |
---|
993 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
994 | { |
---|
995 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
996 | } |
---|
997 | else if ( !iParseRefFrmIdx ) |
---|
998 | { |
---|
999 | iRefFrmIdx = NOT_VALID; |
---|
1000 | } |
---|
1001 | else |
---|
1002 | { |
---|
1003 | iRefFrmIdx = 0; |
---|
1004 | } |
---|
1005 | |
---|
1006 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_2Nx2N, uiAbsPartIdx, 0, uiDepth ); |
---|
1007 | } |
---|
1008 | break; |
---|
1009 | } |
---|
1010 | case SIZE_2NxN: |
---|
1011 | { |
---|
1012 | if( pcCU->getInterDir( uiAbsPartIdx ) != 3 && eRefList == REF_PIC_LIST_0) |
---|
1013 | { |
---|
1014 | if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 ) |
---|
1015 | { |
---|
1016 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C ); |
---|
1017 | } |
---|
1018 | else |
---|
1019 | { |
---|
1020 | iRefFrmIdx=0; |
---|
1021 | } |
---|
1022 | uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1; |
---|
1023 | iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx); |
---|
1024 | eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx); |
---|
1025 | |
---|
1026 | pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, SIZE_2NxN, uiAbsPartIdx, 0, uiDepth ); |
---|
1027 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
1028 | } |
---|
1029 | else if(pcCU->getInterDir( uiAbsPartIdx ) == 3) |
---|
1030 | { |
---|
1031 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
1032 | |
---|
1033 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
1034 | { |
---|
1035 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
1036 | } |
---|
1037 | else if ( !iParseRefFrmIdx ) |
---|
1038 | { |
---|
1039 | iRefFrmIdx = NOT_VALID; |
---|
1040 | } |
---|
1041 | else |
---|
1042 | { |
---|
1043 | iRefFrmIdx = 0; |
---|
1044 | } |
---|
1045 | |
---|
1046 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_2NxN, uiAbsPartIdx, 0, uiDepth ); |
---|
1047 | } |
---|
1048 | |
---|
1049 | uiAbsPartIdx += uiPartOffset << 1; |
---|
1050 | |
---|
1051 | if( pcCU->getInterDir( uiAbsPartIdx ) != 3 && eRefList == REF_PIC_LIST_0) |
---|
1052 | { |
---|
1053 | if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 ) |
---|
1054 | { |
---|
1055 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C ); |
---|
1056 | } |
---|
1057 | else |
---|
1058 | { |
---|
1059 | iRefFrmIdx=0; |
---|
1060 | } |
---|
1061 | uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1; |
---|
1062 | iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx); |
---|
1063 | eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx); |
---|
1064 | |
---|
1065 | pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, SIZE_2NxN, uiAbsPartIdx, 1, uiDepth ); |
---|
1066 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
1067 | } |
---|
1068 | else if(pcCU->getInterDir( uiAbsPartIdx ) == 3) |
---|
1069 | { |
---|
1070 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
1071 | |
---|
1072 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
1073 | { |
---|
1074 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
1075 | } |
---|
1076 | else if ( !iParseRefFrmIdx ) |
---|
1077 | { |
---|
1078 | iRefFrmIdx = NOT_VALID; |
---|
1079 | } |
---|
1080 | else |
---|
1081 | { |
---|
1082 | iRefFrmIdx = 0; |
---|
1083 | } |
---|
1084 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_2NxN, uiAbsPartIdx, 1, uiDepth ); |
---|
1085 | } |
---|
1086 | break; |
---|
1087 | } |
---|
1088 | case SIZE_Nx2N: |
---|
1089 | { |
---|
1090 | if( pcCU->getInterDir( uiAbsPartIdx ) != 3 && eRefList == REF_PIC_LIST_0) |
---|
1091 | { |
---|
1092 | if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 ) |
---|
1093 | { |
---|
1094 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C ); |
---|
1095 | } |
---|
1096 | else |
---|
1097 | { |
---|
1098 | iRefFrmIdx=0; |
---|
1099 | } |
---|
1100 | uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1; |
---|
1101 | iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx); |
---|
1102 | eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx); |
---|
1103 | |
---|
1104 | pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, SIZE_Nx2N, uiAbsPartIdx, 0, uiDepth ); |
---|
1105 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
1106 | } |
---|
1107 | else if(pcCU->getInterDir( uiAbsPartIdx ) == 3) |
---|
1108 | { |
---|
1109 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
1110 | |
---|
1111 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
1112 | { |
---|
1113 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
1114 | } |
---|
1115 | else if ( !iParseRefFrmIdx ) |
---|
1116 | { |
---|
1117 | iRefFrmIdx = NOT_VALID; |
---|
1118 | } |
---|
1119 | else |
---|
1120 | { |
---|
1121 | iRefFrmIdx = 0; |
---|
1122 | } |
---|
1123 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_Nx2N, uiAbsPartIdx, 0, uiDepth ); |
---|
1124 | } |
---|
1125 | |
---|
1126 | uiAbsPartIdx += uiPartOffset; |
---|
1127 | |
---|
1128 | if( pcCU->getInterDir( uiAbsPartIdx ) != 3 && eRefList == REF_PIC_LIST_0) |
---|
1129 | { |
---|
1130 | if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 ) |
---|
1131 | { |
---|
1132 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C ); |
---|
1133 | } |
---|
1134 | else |
---|
1135 | { |
---|
1136 | iRefFrmIdx=0; |
---|
1137 | } |
---|
1138 | uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1; |
---|
1139 | iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx); |
---|
1140 | eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx); |
---|
1141 | |
---|
1142 | pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, SIZE_Nx2N, uiAbsPartIdx, 1, uiDepth ); |
---|
1143 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
1144 | } |
---|
1145 | else if(pcCU->getInterDir( uiAbsPartIdx ) == 3) |
---|
1146 | { |
---|
1147 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
1148 | |
---|
1149 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
1150 | { |
---|
1151 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
1152 | } |
---|
1153 | else if ( !iParseRefFrmIdx ) |
---|
1154 | { |
---|
1155 | iRefFrmIdx = NOT_VALID; |
---|
1156 | } |
---|
1157 | else |
---|
1158 | { |
---|
1159 | iRefFrmIdx = 0; |
---|
1160 | } |
---|
1161 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_Nx2N, uiAbsPartIdx, 1, uiDepth ); |
---|
1162 | } |
---|
1163 | break; |
---|
1164 | } |
---|
1165 | case SIZE_NxN: |
---|
1166 | { |
---|
1167 | for ( Int iPartIdx = 0; iPartIdx < 4; iPartIdx++ ) |
---|
1168 | { |
---|
1169 | if( pcCU->getInterDir( uiAbsPartIdx ) != 3 && eRefList == REF_PIC_LIST_0) |
---|
1170 | { |
---|
1171 | if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 ) |
---|
1172 | { |
---|
1173 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C ); |
---|
1174 | } |
---|
1175 | else |
---|
1176 | { |
---|
1177 | iRefFrmIdx=0; |
---|
1178 | } |
---|
1179 | uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1; |
---|
1180 | iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx); |
---|
1181 | eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx); |
---|
1182 | |
---|
1183 | pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, SIZE_NxN, uiAbsPartIdx, iPartIdx, uiDepth ); |
---|
1184 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, 0, uiDepth ); |
---|
1185 | } |
---|
1186 | else if(pcCU->getInterDir( uiAbsPartIdx ) == 3) |
---|
1187 | { |
---|
1188 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
1189 | |
---|
1190 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
1191 | { |
---|
1192 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
1193 | } |
---|
1194 | else if ( !iParseRefFrmIdx ) |
---|
1195 | { |
---|
1196 | iRefFrmIdx = NOT_VALID; |
---|
1197 | } |
---|
1198 | else |
---|
1199 | { |
---|
1200 | iRefFrmIdx = 0; |
---|
1201 | } |
---|
1202 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_NxN, uiAbsPartIdx, iPartIdx, uiDepth ); |
---|
1203 | } |
---|
1204 | uiAbsPartIdx += uiPartOffset; |
---|
1205 | } |
---|
1206 | break; |
---|
1207 | } |
---|
1208 | default: |
---|
1209 | break; |
---|
1210 | } |
---|
1211 | } |
---|
1212 | else |
---|
1213 | { |
---|
1214 | #endif |
---|
1215 | |
---|
1216 | Int iRefFrmIdx = 0; |
---|
1217 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
1218 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth(uiAbsPartIdx) << 1 ) ) >> 2; |
---|
1219 | |
---|
1220 | switch ( pcCU->getPartitionSize( uiAbsPartIdx ) ) |
---|
1221 | { |
---|
1222 | case SIZE_2Nx2N: |
---|
1223 | { |
---|
1224 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
1225 | { |
---|
1226 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
1227 | } |
---|
1228 | else if ( !iParseRefFrmIdx ) |
---|
1229 | { |
---|
1230 | iRefFrmIdx = NOT_VALID; |
---|
1231 | } |
---|
1232 | else |
---|
1233 | { |
---|
1234 | iRefFrmIdx = 0; |
---|
1235 | } |
---|
1236 | |
---|
1237 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_2Nx2N, uiAbsPartIdx, 0, uiDepth ); |
---|
1238 | break; |
---|
1239 | } |
---|
1240 | case SIZE_2NxN: |
---|
1241 | { |
---|
1242 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
1243 | { |
---|
1244 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
1245 | } |
---|
1246 | else if ( !iParseRefFrmIdx ) |
---|
1247 | { |
---|
1248 | iRefFrmIdx = NOT_VALID; |
---|
1249 | } |
---|
1250 | else |
---|
1251 | { |
---|
1252 | iRefFrmIdx = 0; |
---|
1253 | } |
---|
1254 | |
---|
1255 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_2NxN, uiAbsPartIdx, 0, uiDepth ); |
---|
1256 | uiAbsPartIdx += (uiPartOffset << 1); |
---|
1257 | |
---|
1258 | iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
1259 | |
---|
1260 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
1261 | { |
---|
1262 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
1263 | } |
---|
1264 | else if ( !iParseRefFrmIdx ) |
---|
1265 | { |
---|
1266 | iRefFrmIdx = NOT_VALID; |
---|
1267 | } |
---|
1268 | else |
---|
1269 | { |
---|
1270 | iRefFrmIdx = 0; |
---|
1271 | } |
---|
1272 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_2NxN, uiAbsPartIdx, 1, uiDepth ); |
---|
1273 | break; |
---|
1274 | } |
---|
1275 | case SIZE_Nx2N: |
---|
1276 | { |
---|
1277 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
1278 | { |
---|
1279 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
1280 | } |
---|
1281 | else if ( !iParseRefFrmIdx ) |
---|
1282 | { |
---|
1283 | iRefFrmIdx = NOT_VALID; |
---|
1284 | } |
---|
1285 | else |
---|
1286 | { |
---|
1287 | iRefFrmIdx = 0; |
---|
1288 | } |
---|
1289 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_Nx2N, uiAbsPartIdx, 0, uiDepth ); |
---|
1290 | uiAbsPartIdx += uiPartOffset; |
---|
1291 | |
---|
1292 | iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
1293 | |
---|
1294 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
1295 | { |
---|
1296 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
1297 | } |
---|
1298 | else if ( !iParseRefFrmIdx ) |
---|
1299 | { |
---|
1300 | iRefFrmIdx = NOT_VALID; |
---|
1301 | } |
---|
1302 | else |
---|
1303 | { |
---|
1304 | iRefFrmIdx = 0; |
---|
1305 | } |
---|
1306 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_Nx2N, uiAbsPartIdx, 1, uiDepth ); |
---|
1307 | break; |
---|
1308 | } |
---|
1309 | case SIZE_NxN: |
---|
1310 | { |
---|
1311 | for ( Int iPartIdx = 0; iPartIdx < 4; iPartIdx++ ) |
---|
1312 | { |
---|
1313 | iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
1314 | |
---|
1315 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx) |
---|
1316 | { |
---|
1317 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
1318 | } |
---|
1319 | else if ( !iParseRefFrmIdx ) |
---|
1320 | { |
---|
1321 | iRefFrmIdx = NOT_VALID; |
---|
1322 | } |
---|
1323 | else |
---|
1324 | { |
---|
1325 | iRefFrmIdx = 0; |
---|
1326 | } |
---|
1327 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, SIZE_NxN, uiAbsPartIdx, iPartIdx, uiDepth ); |
---|
1328 | uiAbsPartIdx += uiPartOffset; |
---|
1329 | } |
---|
1330 | break; |
---|
1331 | } |
---|
1332 | default: |
---|
1333 | break; |
---|
1334 | } |
---|
1335 | #if DCM_COMB_LIST |
---|
1336 | } |
---|
1337 | #endif |
---|
1338 | |
---|
1339 | return; |
---|
1340 | } |
---|
1341 | |
---|
1342 | Void TDecEntropy::decodeMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
1343 | { |
---|
1344 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( uiDepth << 1 ) ) >> 2; |
---|
1345 | |
---|
1346 | switch ( pcCU->getPartitionSize( uiAbsPartIdx ) ) |
---|
1347 | { |
---|
1348 | case SIZE_2Nx2N: |
---|
1349 | { |
---|
1350 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
1351 | { |
---|
1352 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, 0, uiDepth, eRefList ); |
---|
1353 | } |
---|
1354 | break; |
---|
1355 | } |
---|
1356 | case SIZE_2NxN: |
---|
1357 | { |
---|
1358 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
1359 | { |
---|
1360 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, 0, uiDepth, eRefList ); |
---|
1361 | } |
---|
1362 | |
---|
1363 | uiAbsPartIdx += (uiPartOffset << 1); |
---|
1364 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
1365 | { |
---|
1366 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, 0, uiDepth, eRefList ); |
---|
1367 | } |
---|
1368 | break; |
---|
1369 | } |
---|
1370 | case SIZE_Nx2N: |
---|
1371 | { |
---|
1372 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
1373 | { |
---|
1374 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, 0, uiDepth, eRefList ); |
---|
1375 | } |
---|
1376 | |
---|
1377 | uiAbsPartIdx += uiPartOffset; |
---|
1378 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
1379 | { |
---|
1380 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, 0, uiDepth, eRefList ); |
---|
1381 | } |
---|
1382 | break; |
---|
1383 | } |
---|
1384 | case SIZE_NxN: |
---|
1385 | { |
---|
1386 | for ( Int iPartIdx = 0; iPartIdx < 4; iPartIdx++ ) |
---|
1387 | { |
---|
1388 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
1389 | { |
---|
1390 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, 0, uiDepth, eRefList ); |
---|
1391 | } |
---|
1392 | uiAbsPartIdx += uiPartOffset; |
---|
1393 | } |
---|
1394 | break; |
---|
1395 | } |
---|
1396 | default: |
---|
1397 | break; |
---|
1398 | } |
---|
1399 | return; |
---|
1400 | } |
---|
1401 | |
---|
1402 | Void TDecEntropy::xDecodeTransformSubdiv( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3 ) |
---|
1403 | { |
---|
1404 | UInt uiSubdiv; |
---|
1405 | const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth; |
---|
1406 | |
---|
1407 | #if CAVLC_RQT_CBP |
---|
1408 | if(pcCU->getSlice()->getSymbolMode()==0) |
---|
1409 | { |
---|
1410 | // code CBP and transform split flag jointly |
---|
1411 | UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx ); |
---|
1412 | m_pcEntropyDecoderIf->parseCbfTrdiv( pcCU, uiAbsPartIdx, uiTrDepth, uiDepth, uiSubdiv ); |
---|
1413 | } |
---|
1414 | else |
---|
1415 | {//CABAC |
---|
1416 | #endif |
---|
1417 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) ) |
---|
1418 | { |
---|
1419 | uiSubdiv = 1; |
---|
1420 | } |
---|
1421 | else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
1422 | { |
---|
1423 | uiSubdiv = 1; |
---|
1424 | } |
---|
1425 | else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
1426 | { |
---|
1427 | uiSubdiv = 0; |
---|
1428 | } |
---|
1429 | else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) |
---|
1430 | { |
---|
1431 | uiSubdiv = 0; |
---|
1432 | } |
---|
1433 | else |
---|
1434 | { |
---|
1435 | assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ); |
---|
1436 | #if HHI_RQT_FORCE_SPLIT_ACC2_PU |
---|
1437 | const UInt uiTrMode = uiDepth - pcCU->getDepth( uiAbsPartIdx ); |
---|
1438 | UInt uiCtx = uiDepth; |
---|
1439 | #if HHI_RQT_FORCE_SPLIT_NxN |
---|
1440 | const Bool bNxNOK = pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN && uiTrMode > 0; |
---|
1441 | #else |
---|
1442 | const Bool bNxNOK = pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN; |
---|
1443 | #endif |
---|
1444 | #if HHI_RQT_FORCE_SPLIT_RECT |
---|
1445 | const Bool bSymmetricOK = pcCU->getPartitionSize( uiAbsPartIdx ) >= SIZE_2NxN && pcCU->getPartitionSize( uiAbsPartIdx ) < SIZE_NxN && uiTrMode > 0; |
---|
1446 | #else |
---|
1447 | const Bool bSymmetricOK = pcCU->getPartitionSize( uiAbsPartIdx ) >= SIZE_2NxN && pcCU->getPartitionSize( uiAbsPartIdx ) < SIZE_NxN; |
---|
1448 | #endif |
---|
1449 | const Bool bNeedSubdivFlag = pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || pcCU->getPredictionMode( uiAbsPartIdx ) == MODE_INTRA || |
---|
1450 | bNxNOK || bSymmetricOK; |
---|
1451 | |
---|
1452 | if( ! bNeedSubdivFlag ) |
---|
1453 | { |
---|
1454 | uiSubdiv = 1; |
---|
1455 | } |
---|
1456 | else |
---|
1457 | m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, uiCtx ); |
---|
1458 | #else |
---|
1459 | m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, uiDepth ); |
---|
1460 | #endif |
---|
1461 | } |
---|
1462 | #if CAVLC_RQT_CBP |
---|
1463 | } |
---|
1464 | #endif |
---|
1465 | |
---|
1466 | const UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx ); |
---|
1467 | |
---|
1468 | if(pcCU->getSlice()->getSymbolMode()==0) |
---|
1469 | { |
---|
1470 | if( uiSubdiv ) |
---|
1471 | { |
---|
1472 | ++uiDepth; |
---|
1473 | const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
1474 | |
---|
1475 | for( Int i = 0; i < 4; i++ ) |
---|
1476 | { |
---|
1477 | UInt uiDummyCbfY = 0; |
---|
1478 | UInt uiDummyCbfU = 0; |
---|
1479 | UInt uiDummyCbfV = 0; |
---|
1480 | xDecodeTransformSubdiv( pcCU, uiAbsPartIdx, uiDepth, i, uiDummyCbfY, uiDummyCbfU, uiDummyCbfV ); |
---|
1481 | uiAbsPartIdx += uiQPartNum; |
---|
1482 | } |
---|
1483 | } |
---|
1484 | else |
---|
1485 | { |
---|
1486 | assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) ); |
---|
1487 | pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth ); |
---|
1488 | } |
---|
1489 | } |
---|
1490 | else |
---|
1491 | { |
---|
1492 | if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiLog2TrafoSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
1493 | { |
---|
1494 | const Bool bFirstCbfOfCU = uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() || uiTrDepth == 0; |
---|
1495 | if( bFirstCbfOfCU ) |
---|
1496 | { |
---|
1497 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
1498 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
1499 | } |
---|
1500 | if( bFirstCbfOfCU || uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
1501 | { |
---|
1502 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) ) |
---|
1503 | { |
---|
1504 | if ( uiInnerQuadIdx == 3 && uiUCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
1505 | { |
---|
1506 | uiUCbfFront3++; |
---|
1507 | pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
1508 | //printf( " \nsave bits, U Cbf"); |
---|
1509 | } |
---|
1510 | else |
---|
1511 | { |
---|
1512 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth ); |
---|
1513 | uiUCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth ); |
---|
1514 | } |
---|
1515 | } |
---|
1516 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) ) |
---|
1517 | { |
---|
1518 | if ( uiInnerQuadIdx == 3 && uiVCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
1519 | { |
---|
1520 | uiVCbfFront3++; |
---|
1521 | pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
1522 | //printf( " \nsave bits, V Cbf"); |
---|
1523 | } |
---|
1524 | else |
---|
1525 | { |
---|
1526 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth ); |
---|
1527 | uiVCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth ); |
---|
1528 | } |
---|
1529 | } |
---|
1530 | } |
---|
1531 | else |
---|
1532 | { |
---|
1533 | pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
1534 | pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
1535 | |
---|
1536 | if ( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
1537 | { |
---|
1538 | uiUCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth ); |
---|
1539 | uiVCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth ); |
---|
1540 | } |
---|
1541 | } |
---|
1542 | } |
---|
1543 | |
---|
1544 | if( uiSubdiv ) |
---|
1545 | { |
---|
1546 | ++uiDepth; |
---|
1547 | const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
1548 | const UInt uiStartAbsPartIdx = uiAbsPartIdx; |
---|
1549 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
1550 | pcCU->convertTransIdx( uiStartAbsPartIdx, uiTrDepth+1, uiLumaTrMode, uiChromaTrMode ); |
---|
1551 | UInt uiYCbf = 0; |
---|
1552 | UInt uiUCbf = 0; |
---|
1553 | UInt uiVCbf = 0; |
---|
1554 | |
---|
1555 | UInt uiCurrentCbfY = 0; |
---|
1556 | UInt uiCurrentCbfU = 0; |
---|
1557 | UInt uiCurrentCbfV = 0; |
---|
1558 | |
---|
1559 | for( Int i = 0; i < 4; i++ ) |
---|
1560 | { |
---|
1561 | xDecodeTransformSubdiv( pcCU, uiAbsPartIdx, uiDepth, i, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV ); |
---|
1562 | uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode ); |
---|
1563 | uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiChromaTrMode ); |
---|
1564 | uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiChromaTrMode ); |
---|
1565 | uiAbsPartIdx += uiQPartNum; |
---|
1566 | } |
---|
1567 | |
---|
1568 | uiYCbfFront3 += uiCurrentCbfY; |
---|
1569 | uiUCbfFront3 += uiCurrentCbfU; |
---|
1570 | uiVCbfFront3 += uiCurrentCbfV; |
---|
1571 | |
---|
1572 | pcCU->convertTransIdx( uiStartAbsPartIdx, uiTrDepth, uiLumaTrMode, uiChromaTrMode ); |
---|
1573 | for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui ) |
---|
1574 | { |
---|
1575 | pcCU->getCbf( TEXT_LUMA )[uiStartAbsPartIdx + ui] |= uiYCbf << uiLumaTrMode; |
---|
1576 | pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiChromaTrMode; |
---|
1577 | pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiChromaTrMode; |
---|
1578 | } |
---|
1579 | } |
---|
1580 | else |
---|
1581 | { |
---|
1582 | assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) ); |
---|
1583 | pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth ); |
---|
1584 | |
---|
1585 | { |
---|
1586 | DTRACE_CABAC_V( g_nSymbolCounter++ ); |
---|
1587 | DTRACE_CABAC_T( "\tTrIdx: abspart=" ); |
---|
1588 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
1589 | DTRACE_CABAC_T( "\tdepth=" ); |
---|
1590 | DTRACE_CABAC_V( uiDepth ); |
---|
1591 | DTRACE_CABAC_T( "\ttrdepth=" ); |
---|
1592 | DTRACE_CABAC_V( uiTrDepth ); |
---|
1593 | DTRACE_CABAC_T( "\n" ); |
---|
1594 | } |
---|
1595 | |
---|
1596 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
1597 | pcCU->convertTransIdx( uiAbsPartIdx, uiTrDepth, uiLumaTrMode, uiChromaTrMode ); |
---|
1598 | pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
1599 | if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) ) |
---|
1600 | { |
---|
1601 | pcCU->setCbfSubParts( 1 << uiLumaTrMode, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
1602 | } |
---|
1603 | else |
---|
1604 | { |
---|
1605 | if ( pcCU->getPredictionMode( uiAbsPartIdx ) != MODE_INTRA && uiInnerQuadIdx == 3 && uiYCbfFront3 == 0 && uiUCbfFront3 == 0 && uiVCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
1606 | { |
---|
1607 | pcCU->setCbfSubParts( 1 << uiLumaTrMode, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
1608 | //printf( " \nsave bits, Y Cbf"); |
---|
1609 | uiYCbfFront3++; |
---|
1610 | } |
---|
1611 | else |
---|
1612 | { |
---|
1613 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode, uiDepth ); |
---|
1614 | uiYCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode ); |
---|
1615 | } |
---|
1616 | } |
---|
1617 | |
---|
1618 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA ) |
---|
1619 | { |
---|
1620 | Bool bCodeChroma = true; |
---|
1621 | UInt uiDepthChroma = uiDepth; |
---|
1622 | if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
1623 | { |
---|
1624 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
1625 | bCodeChroma = ( ( uiAbsPartIdx % uiQPDiv ) == 0 ); |
---|
1626 | uiDepthChroma--; |
---|
1627 | } |
---|
1628 | if( bCodeChroma ) |
---|
1629 | { |
---|
1630 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepthChroma ); |
---|
1631 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepthChroma ); |
---|
1632 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiChromaTrMode, uiDepthChroma ); |
---|
1633 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiChromaTrMode, uiDepthChroma ); |
---|
1634 | } |
---|
1635 | } |
---|
1636 | } |
---|
1637 | } |
---|
1638 | } |
---|
1639 | |
---|
1640 | Void TDecEntropy::decodeTransformIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1641 | { |
---|
1642 | DTRACE_CABAC_V( g_nSymbolCounter++ ) |
---|
1643 | DTRACE_CABAC_T( "\tdecodeTransformIdx()\tCUDepth=" ) |
---|
1644 | DTRACE_CABAC_V( uiDepth ) |
---|
1645 | DTRACE_CABAC_T( "\n" ) |
---|
1646 | UInt temp = 0; |
---|
1647 | UInt temp1 = 0; |
---|
1648 | UInt temp2 = 0; |
---|
1649 | xDecodeTransformSubdiv( pcCU, uiAbsPartIdx, uiDepth, 0, temp, temp1, temp2 ); |
---|
1650 | } |
---|
1651 | |
---|
1652 | Void TDecEntropy::decodeQP ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1653 | { |
---|
1654 | if ( pcCU->getSlice()->getSPS()->getUseDQP() ) |
---|
1655 | { |
---|
1656 | m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, uiDepth ); |
---|
1657 | } |
---|
1658 | } |
---|
1659 | |
---|
1660 | Void TDecEntropy::decodeViewidx(Int & riViewIdx) |
---|
1661 | { |
---|
1662 | m_pcEntropyDecoderIf->parseViewIdx( riViewIdx ); |
---|
1663 | } |
---|
1664 | |
---|
1665 | Void TDecEntropy::xDecodeCoeff( TComDataCU* pcCU, TCoeff* pcCoeff, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, UInt uiTrIdx, UInt uiCurrTrIdx, TextType eType ) |
---|
1666 | { |
---|
1667 | if ( pcCU->getCbf( uiAbsPartIdx, eType, uiTrIdx ) ) |
---|
1668 | { |
---|
1669 | #if SNY_DQP |
---|
1670 | // dQP: only for LCU |
---|
1671 | if ( pcCU->getSlice()->getSPS()->getUseDQP() ) |
---|
1672 | { |
---|
1673 | if ( pcCU->getdQPFlag())// non-skip |
---|
1674 | { |
---|
1675 | decodeQP( pcCU, 0, 0 ); |
---|
1676 | pcCU->setdQPFlag(false); |
---|
1677 | } |
---|
1678 | } |
---|
1679 | #endif//SNY_DQP |
---|
1680 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
1681 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode ); |
---|
1682 | const UInt uiStopTrMode = eType == TEXT_LUMA ? uiLumaTrMode : uiChromaTrMode; |
---|
1683 | |
---|
1684 | if( uiTrIdx == uiStopTrMode ) |
---|
1685 | { |
---|
1686 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth ] + 2; |
---|
1687 | if( eType != TEXT_LUMA && uiLog2TrSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
1688 | { |
---|
1689 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
1690 | if( ( uiAbsPartIdx % uiQPDiv ) != 0 ) |
---|
1691 | { |
---|
1692 | return; |
---|
1693 | } |
---|
1694 | uiWidth <<= 1; |
---|
1695 | uiHeight <<= 1; |
---|
1696 | } |
---|
1697 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, pcCoeff, uiAbsPartIdx, uiWidth, uiHeight, uiDepth, eType ); |
---|
1698 | } |
---|
1699 | else |
---|
1700 | { |
---|
1701 | { |
---|
1702 | DTRACE_CABAC_V( g_nSymbolCounter++ ); |
---|
1703 | DTRACE_CABAC_T( "\tgoing down\tdepth=" ); |
---|
1704 | DTRACE_CABAC_V( uiDepth ); |
---|
1705 | DTRACE_CABAC_T( "\ttridx=" ); |
---|
1706 | DTRACE_CABAC_V( uiTrIdx ); |
---|
1707 | DTRACE_CABAC_T( "\n" ); |
---|
1708 | } |
---|
1709 | if( uiCurrTrIdx <= uiTrIdx ) |
---|
1710 | assert(1); |
---|
1711 | UInt uiSize; |
---|
1712 | uiWidth >>= 1; |
---|
1713 | uiHeight >>= 1; |
---|
1714 | uiSize = uiWidth*uiHeight; |
---|
1715 | uiDepth++; |
---|
1716 | uiTrIdx++; |
---|
1717 | |
---|
1718 | UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
1719 | UInt uiIdx = uiAbsPartIdx; |
---|
1720 | |
---|
1721 | #if !CAVLC_RQT_CBP |
---|
1722 | if(pcCU->getSlice()->getSymbolMode() == 0) |
---|
1723 | { |
---|
1724 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth ] + 2; |
---|
1725 | if( eType == TEXT_LUMA || uiLog2TrSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
1726 | m_pcEntropyDecoderIf->parseBlockCbf(pcCU, uiIdx, eType, uiTrIdx, uiDepth, uiQPartNum); |
---|
1727 | else |
---|
1728 | { |
---|
1729 | UInt uiCbf = pcCU->getCbf( uiIdx, eType ); |
---|
1730 | pcCU->setCbfSubParts( uiCbf | ( 0x01 << uiTrIdx ), eType, uiIdx, uiDepth ); |
---|
1731 | uiCbf = pcCU->getCbf( uiIdx + uiQPartNum, eType ); |
---|
1732 | pcCU->setCbfSubParts( uiCbf | ( 0x01 << uiTrIdx ), eType, uiIdx + uiQPartNum, uiDepth ); |
---|
1733 | uiCbf = pcCU->getCbf( uiIdx + 2*uiQPartNum, eType ); |
---|
1734 | pcCU->setCbfSubParts( uiCbf | ( 0x01 << uiTrIdx ), eType, uiIdx + 2*uiQPartNum, uiDepth ); |
---|
1735 | uiCbf = pcCU->getCbf( uiIdx + 3*uiQPartNum, eType ); |
---|
1736 | pcCU->setCbfSubParts( uiCbf | ( 0x01 << uiTrIdx ), eType, uiIdx + 3*uiQPartNum, uiDepth ); |
---|
1737 | } |
---|
1738 | xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); pcCoeff += uiSize; uiIdx += uiQPartNum; |
---|
1739 | xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); pcCoeff += uiSize; uiIdx += uiQPartNum; |
---|
1740 | xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); pcCoeff += uiSize; uiIdx += uiQPartNum; |
---|
1741 | xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); |
---|
1742 | } |
---|
1743 | else |
---|
1744 | { |
---|
1745 | #endif |
---|
1746 | xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); pcCoeff += uiSize; uiIdx += uiQPartNum; |
---|
1747 | xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); pcCoeff += uiSize; uiIdx += uiQPartNum; |
---|
1748 | xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); pcCoeff += uiSize; uiIdx += uiQPartNum; |
---|
1749 | xDecodeCoeff( pcCU, pcCoeff, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, eType ); |
---|
1750 | #if !CAVLC_RQT_CBP |
---|
1751 | } |
---|
1752 | #endif |
---|
1753 | { |
---|
1754 | DTRACE_CABAC_V( g_nSymbolCounter++ ); |
---|
1755 | DTRACE_CABAC_T( "\tgoing up\n" ); |
---|
1756 | } |
---|
1757 | } |
---|
1758 | } |
---|
1759 | } |
---|
1760 | |
---|
1761 | /** decode coefficients |
---|
1762 | * \param pcCU |
---|
1763 | * \param uiAbsPartIdx |
---|
1764 | * \param uiDepth |
---|
1765 | * \param uiWidth |
---|
1766 | * \param uiHeight |
---|
1767 | * \returns Void |
---|
1768 | */ |
---|
1769 | Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight ) |
---|
1770 | { |
---|
1771 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
1772 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
1773 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
1774 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
1775 | |
---|
1776 | if( pcCU->isIntra(uiAbsPartIdx) ) |
---|
1777 | { |
---|
1778 | decodeTransformIdx( pcCU, uiAbsPartIdx, pcCU->getDepth(uiAbsPartIdx) ); |
---|
1779 | |
---|
1780 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx(uiAbsPartIdx), uiLumaTrMode, uiChromaTrMode ); |
---|
1781 | |
---|
1782 | if (pcCU->getSlice()->getSymbolMode() == 0) |
---|
1783 | { |
---|
1784 | #if !CAVLC_RQT_CBP |
---|
1785 | m_pcEntropyDecoderIf->parseCbf( pcCU, uiAbsPartIdx, TEXT_ALL, 0, uiDepth ); |
---|
1786 | #endif |
---|
1787 | if(pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA, 0)==0 && pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U, 0)==0 |
---|
1788 | && pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V, 0)==0) |
---|
1789 | return; |
---|
1790 | } |
---|
1791 | } |
---|
1792 | else |
---|
1793 | { |
---|
1794 | if (pcCU->getSlice()->getSymbolMode()==0) |
---|
1795 | { |
---|
1796 | #if !CAVLC_RQT_CBP |
---|
1797 | m_pcEntropyDecoderIf->parseCbf( pcCU, uiAbsPartIdx, TEXT_ALL, 0, uiDepth ); |
---|
1798 | if(pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA, 0)==0 && pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U, 0)==0 |
---|
1799 | && pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V, 0)==0) |
---|
1800 | return; |
---|
1801 | #endif |
---|
1802 | } |
---|
1803 | else |
---|
1804 | { |
---|
1805 | #if HHI_MRG_SKIP |
---|
1806 | UInt uiQtRootCbf = 1; |
---|
1807 | #if MW_MVI_SIGNALLING_MODE == 1 |
---|
1808 | if( !(pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N && |
---|
1809 | ( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth == pcCU->getTextureModeDepth( uiAbsPartIdx ) ) ) ) |
---|
1810 | #else |
---|
1811 | if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) ) |
---|
1812 | #endif |
---|
1813 | { |
---|
1814 | m_pcEntropyDecoderIf->parseQtRootCbf( pcCU, uiAbsPartIdx, uiDepth, uiQtRootCbf ); |
---|
1815 | } |
---|
1816 | #else |
---|
1817 | UInt uiQtRootCbf; |
---|
1818 | m_pcEntropyDecoderIf->parseQtRootCbf( pcCU, uiAbsPartIdx, uiDepth, uiQtRootCbf ); |
---|
1819 | #endif |
---|
1820 | if ( !uiQtRootCbf ) |
---|
1821 | { |
---|
1822 | pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth ); |
---|
1823 | pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth ); |
---|
1824 | return; |
---|
1825 | } |
---|
1826 | } |
---|
1827 | |
---|
1828 | decodeTransformIdx( pcCU, uiAbsPartIdx, pcCU->getDepth(uiAbsPartIdx) ); |
---|
1829 | |
---|
1830 | #if CAVLC_RQT_CBP |
---|
1831 | if (pcCU->getSlice()->getSymbolMode() == 0) |
---|
1832 | { |
---|
1833 | if(pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA, 0)==0 && pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U, 0)==0 |
---|
1834 | && pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V, 0)==0) |
---|
1835 | return; |
---|
1836 | } |
---|
1837 | #endif |
---|
1838 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx(uiAbsPartIdx), uiLumaTrMode, uiChromaTrMode ); |
---|
1839 | } |
---|
1840 | |
---|
1841 | xDecodeCoeff( pcCU, pcCU->getCoeffY() + uiLumaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, uiLumaTrMode, TEXT_LUMA ); |
---|
1842 | xDecodeCoeff( pcCU, pcCU->getCoeffCb() + uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth>>1, uiHeight>>1, 0, uiChromaTrMode, TEXT_CHROMA_U ); |
---|
1843 | xDecodeCoeff( pcCU, pcCU->getCoeffCr() + uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth>>1, uiHeight>>1, 0, uiChromaTrMode, TEXT_CHROMA_V ); |
---|
1844 | } |
---|
1845 | |
---|
1846 | #if MTK_SAO |
---|
1847 | /** decodeQAO One Part |
---|
1848 | * \param pQaoParam, iPartIdx |
---|
1849 | */ |
---|
1850 | Void TDecEntropy::decodeQAOOnePart(SAOParam* pQaoParam, Int iPartIdx) |
---|
1851 | { |
---|
1852 | UInt uiSymbol; |
---|
1853 | Int iSymbol; |
---|
1854 | |
---|
1855 | SAOQTPart* pAlfPart = &(pQaoParam->psSaoPart[iPartIdx]); |
---|
1856 | static Int iTypeLength[MAX_NUM_SAO_TYPE] = { |
---|
1857 | SAO_EO_LEN, |
---|
1858 | SAO_EO_LEN, |
---|
1859 | SAO_EO_LEN, |
---|
1860 | SAO_EO_LEN, |
---|
1861 | SAO_BO_LEN, |
---|
1862 | SAO_BO_LEN |
---|
1863 | }; |
---|
1864 | if(!pAlfPart->bSplit) |
---|
1865 | { |
---|
1866 | |
---|
1867 | m_pcEntropyDecoderIf->parseAoUvlc(uiSymbol); |
---|
1868 | |
---|
1869 | if (uiSymbol) |
---|
1870 | { |
---|
1871 | pAlfPart->iBestType = uiSymbol-1; |
---|
1872 | pAlfPart->bEnableFlag = true; |
---|
1873 | } |
---|
1874 | else |
---|
1875 | { |
---|
1876 | pAlfPart->iBestType = -1; |
---|
1877 | pAlfPart->bEnableFlag = false; |
---|
1878 | } |
---|
1879 | |
---|
1880 | if (pAlfPart->bEnableFlag) |
---|
1881 | { |
---|
1882 | |
---|
1883 | pAlfPart->iLength = iTypeLength[pAlfPart->iBestType]; |
---|
1884 | |
---|
1885 | for(Int i=0; i< pAlfPart->iLength; i++) |
---|
1886 | { |
---|
1887 | m_pcEntropyDecoderIf->parseAoSvlc(iSymbol); |
---|
1888 | pAlfPart->iOffset[i] = iSymbol; |
---|
1889 | } |
---|
1890 | |
---|
1891 | } |
---|
1892 | return; |
---|
1893 | } |
---|
1894 | |
---|
1895 | //split |
---|
1896 | if (pAlfPart->PartLevel < pQaoParam->iMaxSplitLevel) |
---|
1897 | { |
---|
1898 | for(Int i=0;i<NUM_DOWN_PART;i++) |
---|
1899 | { |
---|
1900 | decodeQAOOnePart(pQaoParam, pAlfPart->DownPartsIdx[i]); |
---|
1901 | } |
---|
1902 | } |
---|
1903 | } |
---|
1904 | /** decode QuadTree Split Flag |
---|
1905 | * \param pQaoParam, iPartIdx |
---|
1906 | */ |
---|
1907 | Void TDecEntropy::decodeQuadTreeSplitFlag(SAOParam* pQaoParam, Int iPartIdx) |
---|
1908 | { |
---|
1909 | UInt uiSymbol; |
---|
1910 | SAOQTPart* pAlfPart = &(pQaoParam->psSaoPart[iPartIdx]); |
---|
1911 | |
---|
1912 | if(pAlfPart->PartLevel < pQaoParam->iMaxSplitLevel) |
---|
1913 | { |
---|
1914 | |
---|
1915 | //send one flag |
---|
1916 | m_pcEntropyDecoderIf->parseAoFlag(uiSymbol); |
---|
1917 | pAlfPart->bSplit = uiSymbol? true:false; |
---|
1918 | if(pAlfPart->bSplit) |
---|
1919 | { |
---|
1920 | for (Int i=0;i<NUM_DOWN_PART;i++) |
---|
1921 | { |
---|
1922 | decodeQuadTreeSplitFlag(pQaoParam, pAlfPart->DownPartsIdx[i]); |
---|
1923 | } |
---|
1924 | } |
---|
1925 | } |
---|
1926 | |
---|
1927 | } |
---|
1928 | /** decode Sao Param |
---|
1929 | * \param pQaoParam |
---|
1930 | */ |
---|
1931 | Void TDecEntropy::decodeSaoParam(SAOParam* pQaoParam) |
---|
1932 | { |
---|
1933 | UInt uiSymbol; |
---|
1934 | |
---|
1935 | m_pcEntropyDecoderIf->parseAoFlag(uiSymbol); |
---|
1936 | if (uiSymbol) |
---|
1937 | { |
---|
1938 | pQaoParam->bSaoFlag = true; |
---|
1939 | } |
---|
1940 | else |
---|
1941 | { |
---|
1942 | pQaoParam->bSaoFlag = false; |
---|
1943 | } |
---|
1944 | if (pQaoParam->bSaoFlag) |
---|
1945 | { |
---|
1946 | decodeQuadTreeSplitFlag(pQaoParam, 0); |
---|
1947 | decodeQAOOnePart(pQaoParam, 0); |
---|
1948 | } |
---|
1949 | |
---|
1950 | } |
---|
1951 | |
---|
1952 | #endif |
---|