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