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-2012, ITU/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 ITU/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 | /** \file TDecEntropy.cpp |
---|
35 | \brief entropy decoder class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "TDecEntropy.h" |
---|
39 | |
---|
40 | //! \ingroup TLibDecoder |
---|
41 | //! \{ |
---|
42 | |
---|
43 | Void TDecEntropy::setEntropyDecoder ( TDecEntropyIf* p ) |
---|
44 | { |
---|
45 | m_pcEntropyDecoderIf = p; |
---|
46 | } |
---|
47 | |
---|
48 | #include "TLibCommon/TComAdaptiveLoopFilter.h" |
---|
49 | #include "TLibCommon/TComSampleAdaptiveOffset.h" |
---|
50 | |
---|
51 | Void TDecEntropy::decodeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
52 | { |
---|
53 | m_pcEntropyDecoderIf->parseSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
54 | } |
---|
55 | |
---|
56 | /** decode merge flag |
---|
57 | * \param pcSubCU |
---|
58 | * \param uiAbsPartIdx |
---|
59 | * \param uiDepth |
---|
60 | * \param uiPUIdx |
---|
61 | * \returns Void |
---|
62 | */ |
---|
63 | Void TDecEntropy::decodeMergeFlag( TComDataCU* pcSubCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) |
---|
64 | { |
---|
65 | // at least one merge candidate exists |
---|
66 | m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx ); |
---|
67 | } |
---|
68 | |
---|
69 | #if LGE_ILLUCOMP_B0045 |
---|
70 | Void TDecEntropy::decodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
71 | { |
---|
72 | pcCU->setICFlagSubParts( false , uiAbsPartIdx, 0, uiDepth ); |
---|
73 | |
---|
74 | if (pcCU->isIntra(uiAbsPartIdx) || (pcCU->getSlice()->getViewId() == 0) || pcCU->getSlice()->getSPS()->isDepth()) |
---|
75 | { |
---|
76 | return; |
---|
77 | } |
---|
78 | |
---|
79 | if(!pcCU->getSlice()->getApplyIC()) |
---|
80 | return; |
---|
81 | |
---|
82 | if(pcCU->isICFlagRequired(uiAbsPartIdx)) |
---|
83 | m_pcEntropyDecoderIf->parseICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
84 | } |
---|
85 | #endif |
---|
86 | /** decode merge index |
---|
87 | * \param pcCU |
---|
88 | * \param uiPartIdx |
---|
89 | * \param uiAbsPartIdx |
---|
90 | * \param puhInterDirNeighbours pointer to list of inter direction from the casual neighbours |
---|
91 | * \param pcMvFieldNeighbours pointer to list of motion vector field from the casual neighbours |
---|
92 | * \param uiDepth |
---|
93 | * \returns Void |
---|
94 | */ |
---|
95 | Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, PartSize eCUMode, UChar* puhInterDirNeighbours, TComMvField* pcMvFieldNeighbours, UInt uiDepth ) |
---|
96 | { |
---|
97 | UInt uiMergeIndex = 0; |
---|
98 | m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex, uiAbsPartIdx, uiDepth ); |
---|
99 | pcCU->setMergeIndexSubParts( uiMergeIndex, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
100 | } |
---|
101 | |
---|
102 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
103 | Void |
---|
104 | TDecEntropy::decodeResPredFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU, UInt uiPUIdx ) |
---|
105 | { |
---|
106 | Bool bResPredAvailable = false; |
---|
107 | Bool bResPredFlag = false; |
---|
108 | |
---|
109 | Bool bResPredAllowed = (!pcCU->getSlice()->getSPS()->isDepth () ); |
---|
110 | bResPredAllowed = bResPredAllowed && ( pcCU->getSlice()->getSPS()->getViewId () ); |
---|
111 | bResPredAllowed = bResPredAllowed && ( pcCU->getSlice()->getSPS()->getMultiviewResPredMode() ); |
---|
112 | bResPredAllowed = bResPredAllowed && (!pcCU->isIntra ( uiAbsPartIdx ) ); |
---|
113 | |
---|
114 | // check if supported |
---|
115 | if( bResPredAllowed ) |
---|
116 | { |
---|
117 | bResPredAvailable = pcSubCU->getResidualSamples( uiPUIdx |
---|
118 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
119 | , false |
---|
120 | #endif |
---|
121 | ); |
---|
122 | } |
---|
123 | |
---|
124 | // read from bitstream |
---|
125 | if( bResPredAvailable ) |
---|
126 | { |
---|
127 | #if LG_RESTRICTEDRESPRED_M24766 |
---|
128 | Int iPUResiPredShift[4]; |
---|
129 | pcCU->getPUResiPredShift(iPUResiPredShift, uiAbsPartIdx); |
---|
130 | if(iPUResiPredShift[0] >= 0 || iPUResiPredShift[1] >= 0 || iPUResiPredShift[2] >= 0 || iPUResiPredShift[3] >= 0 ) |
---|
131 | #endif |
---|
132 | m_pcEntropyDecoderIf->parseResPredFlag( pcCU, bResPredFlag, uiAbsPartIdx, uiDepth ); |
---|
133 | } |
---|
134 | |
---|
135 | // set data |
---|
136 | pcCU->setResPredAvailSubParts ( bResPredAvailable, uiAbsPartIdx, uiPUIdx, uiDepth ); |
---|
137 | pcCU->setResPredFlagSubParts ( bResPredFlag, uiAbsPartIdx, uiPUIdx, uiDepth ); |
---|
138 | } |
---|
139 | #endif |
---|
140 | |
---|
141 | Void TDecEntropy::decodeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
142 | { |
---|
143 | m_pcEntropyDecoderIf->parseSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
144 | } |
---|
145 | |
---|
146 | Void TDecEntropy::decodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
147 | { |
---|
148 | m_pcEntropyDecoderIf->parsePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
149 | } |
---|
150 | |
---|
151 | Void TDecEntropy::decodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
152 | { |
---|
153 | m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
154 | } |
---|
155 | |
---|
156 | Void TDecEntropy::decodePredInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ) |
---|
157 | { |
---|
158 | PartSize eMode = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
159 | |
---|
160 | if( pcCU->isIntra( uiAbsPartIdx ) ) // If it is Intra mode, encode intra prediction mode. |
---|
161 | { |
---|
162 | if( eMode == SIZE_NxN ) // if it is NxN size, encode 4 intra directions. |
---|
163 | { |
---|
164 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth(uiAbsPartIdx) << 1 ) ) >> 2; |
---|
165 | // 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. |
---|
166 | decodeIntraDirModeLuma( pcCU, uiAbsPartIdx, uiDepth+1 ); |
---|
167 | decodeIntraDirModeLuma( pcCU, uiAbsPartIdx + uiPartOffset, uiDepth+1 ); |
---|
168 | decodeIntraDirModeLuma( pcCU, uiAbsPartIdx + uiPartOffset*2, uiDepth+1 ); |
---|
169 | decodeIntraDirModeLuma( pcCU, uiAbsPartIdx + uiPartOffset*3, uiDepth+1 ); |
---|
170 | decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
171 | } |
---|
172 | else // if it is not NxN size, encode 1 intra directions |
---|
173 | { |
---|
174 | decodeIntraDirModeLuma ( pcCU, uiAbsPartIdx, uiDepth ); |
---|
175 | decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
176 | } |
---|
177 | } |
---|
178 | else // if it is Inter mode, encode motion vector and reference index |
---|
179 | { |
---|
180 | decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU ); |
---|
181 | } |
---|
182 | } |
---|
183 | |
---|
184 | /** Parse I_PCM information. |
---|
185 | * \param pcCU pointer to CUpointer to CU |
---|
186 | * \param uiAbsPartIdx CU index |
---|
187 | * \param uiDepth CU depth |
---|
188 | * \returns Void |
---|
189 | */ |
---|
190 | Void TDecEntropy::decodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
191 | { |
---|
192 | if(!pcCU->getSlice()->getSPS()->getUsePCM() |
---|
193 | || pcCU->getWidth(uiAbsPartIdx) > (1<<pcCU->getSlice()->getSPS()->getPCMLog2MaxSize()) |
---|
194 | || pcCU->getWidth(uiAbsPartIdx) < (1<<pcCU->getSlice()->getSPS()->getPCMLog2MinSize()) ) |
---|
195 | { |
---|
196 | return; |
---|
197 | } |
---|
198 | |
---|
199 | m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
200 | } |
---|
201 | |
---|
202 | Void TDecEntropy::decodeIntraDirModeLuma ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
203 | { |
---|
204 | m_pcEntropyDecoderIf->parseIntraDirLumaAng( pcCU, uiAbsPartIdx, uiDepth ); |
---|
205 | } |
---|
206 | |
---|
207 | Void TDecEntropy::decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
208 | { |
---|
209 | m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
210 | } |
---|
211 | |
---|
212 | /** decode motion information for every PU block. |
---|
213 | * \param pcCU |
---|
214 | * \param uiAbsPartIdx |
---|
215 | * \param uiDepth |
---|
216 | * \param pcSubCU |
---|
217 | * \returns Void |
---|
218 | */ |
---|
219 | Void TDecEntropy::decodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ) |
---|
220 | { |
---|
221 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
222 | UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) ); |
---|
223 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
224 | |
---|
225 | #if CU_BASED_MRG_CAND_LIST |
---|
226 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
227 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
---|
228 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
---|
229 | for ( UInt ui = 0; ui < MRG_MAX_NUM_CANDS_MEM; ui++ ) |
---|
230 | #else |
---|
231 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
232 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
233 | for ( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ui++ ) |
---|
234 | #endif |
---|
235 | { |
---|
236 | uhInterDirNeighbours[ui] = 0; |
---|
237 | } |
---|
238 | Int numValidMergeCand = 0; |
---|
239 | bool isMerged = false; |
---|
240 | #endif |
---|
241 | |
---|
242 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
243 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
244 | for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset ) |
---|
245 | { |
---|
246 | #if !CU_BASED_MRG_CAND_LIST |
---|
247 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
248 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
---|
249 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
---|
250 | Int numValidMergeCand = 0; |
---|
251 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS_MEM; ++ui ) |
---|
252 | #else |
---|
253 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
254 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
255 | Int numValidMergeCand = 0; |
---|
256 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ++ui ) |
---|
257 | #endif |
---|
258 | { |
---|
259 | uhInterDirNeighbours[ui] = 0; |
---|
260 | } |
---|
261 | #endif |
---|
262 | decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
263 | if ( pcCU->getMergeFlag( uiSubPartIdx ) ) |
---|
264 | { |
---|
265 | decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, ePartSize, uhInterDirNeighbours, cMvFieldNeighbours, uiDepth ); |
---|
266 | #if CU_BASED_MRG_CAND_LIST |
---|
267 | UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
---|
268 | if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) |
---|
269 | { |
---|
270 | pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
271 | if ( !isMerged ) |
---|
272 | { |
---|
273 | pcSubCU->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
274 | isMerged = true; |
---|
275 | } |
---|
276 | pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); |
---|
277 | } |
---|
278 | else |
---|
279 | { |
---|
280 | #if SIMP_MRG_PRUN |
---|
281 | uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
---|
282 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
283 | #else |
---|
284 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
285 | uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
---|
286 | #endif |
---|
287 | } |
---|
288 | #else |
---|
289 | #if SIMP_MRG_PRUN |
---|
290 | UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
---|
291 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
292 | #else |
---|
293 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
294 | UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
---|
295 | #endif |
---|
296 | #endif |
---|
297 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
298 | |
---|
299 | TComMv cTmpMv( 0, 0 ); |
---|
300 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
301 | { |
---|
302 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
303 | { |
---|
304 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth); |
---|
305 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth); |
---|
306 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
307 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
308 | |
---|
309 | } |
---|
310 | } |
---|
311 | } |
---|
312 | else |
---|
313 | { |
---|
314 | decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
315 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
316 | { |
---|
317 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
318 | { |
---|
319 | decodeRefFrmIdxPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
320 | decodeMvdPU ( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
321 | decodeMVPIdxPU ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
322 | } |
---|
323 | } |
---|
324 | } |
---|
325 | } |
---|
326 | return; |
---|
327 | } |
---|
328 | |
---|
329 | /** decode inter direction for a PU block |
---|
330 | * \param pcCU |
---|
331 | * \param uiAbsPartIdx |
---|
332 | * \param uiDepth |
---|
333 | * \param uiPartIdx |
---|
334 | * \returns Void |
---|
335 | */ |
---|
336 | Void TDecEntropy::decodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx ) |
---|
337 | { |
---|
338 | UInt uiInterDir; |
---|
339 | |
---|
340 | if ( pcCU->getSlice()->isInterP() ) |
---|
341 | { |
---|
342 | uiInterDir = 1; |
---|
343 | } |
---|
344 | else |
---|
345 | { |
---|
346 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth ); |
---|
347 | } |
---|
348 | |
---|
349 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
350 | } |
---|
351 | |
---|
352 | Void TDecEntropy::decodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
353 | { |
---|
354 | if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getInterDir( uiAbsPartIdx ) != 3) |
---|
355 | { |
---|
356 | if(eRefList == REF_PIC_LIST_1) |
---|
357 | { |
---|
358 | return; |
---|
359 | } |
---|
360 | |
---|
361 | Int iRefFrmIdx = 0; |
---|
362 | Int iRefFrmIdxTemp; |
---|
363 | UInt uiInterDir; |
---|
364 | RefPicList eRefListTemp; |
---|
365 | |
---|
366 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
367 | |
---|
368 | if ( pcCU->getSlice()->getNumRefIdx ( REF_PIC_LIST_C ) > 1 ) |
---|
369 | { |
---|
370 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, REF_PIC_LIST_C ); |
---|
371 | } |
---|
372 | else |
---|
373 | { |
---|
374 | iRefFrmIdx=0; |
---|
375 | } |
---|
376 | uiInterDir = pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx) + 1; |
---|
377 | iRefFrmIdxTemp = pcCU->getSlice()->getRefIdxFromIdxOfLC(iRefFrmIdx); |
---|
378 | eRefListTemp = (RefPicList)pcCU->getSlice()->getListIdFromIdxOfLC(iRefFrmIdx); |
---|
379 | |
---|
380 | pcCU->getCUMvField( eRefListTemp )->setAllRefIdx( iRefFrmIdxTemp, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
381 | |
---|
382 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
383 | } |
---|
384 | else |
---|
385 | { |
---|
386 | Int iRefFrmIdx = 0; |
---|
387 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
388 | |
---|
389 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx ) |
---|
390 | { |
---|
391 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList ); |
---|
392 | } |
---|
393 | else if ( !iParseRefFrmIdx ) |
---|
394 | { |
---|
395 | iRefFrmIdx = NOT_VALID; |
---|
396 | } |
---|
397 | else |
---|
398 | { |
---|
399 | iRefFrmIdx = 0; |
---|
400 | } |
---|
401 | |
---|
402 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
403 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
404 | } |
---|
405 | } |
---|
406 | |
---|
407 | /** decode motion vector difference for a PU block |
---|
408 | * \param pcCU |
---|
409 | * \param uiAbsPartIdx |
---|
410 | * \param uiDepth |
---|
411 | * \param uiPartIdx |
---|
412 | * \param eRefList |
---|
413 | * \returns Void |
---|
414 | */ |
---|
415 | Void TDecEntropy::decodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
416 | { |
---|
417 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
418 | { |
---|
419 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, uiPartIdx, uiDepth, eRefList ); |
---|
420 | } |
---|
421 | } |
---|
422 | |
---|
423 | Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
424 | { |
---|
425 | Int iMVPIdx = -1; |
---|
426 | |
---|
427 | TComMv cZeroMv( 0, 0 ); |
---|
428 | TComMv cMv = cZeroMv; |
---|
429 | Int iRefIdx = -1; |
---|
430 | |
---|
431 | TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList ); |
---|
432 | AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo(); |
---|
433 | |
---|
434 | iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr); |
---|
435 | cMv = cZeroMv; |
---|
436 | |
---|
437 | if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) && (pcSubCU->getAMVPMode(uiPartAddr) == AM_EXPL) ) |
---|
438 | { |
---|
439 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
440 | const Int iNumAMVPCands = AMVP_MAX_NUM_CANDS + ( pcSubCU->getSlice()->getSPS()->getMultiviewMvPredMode() ? 1 : 0 ); |
---|
441 | m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx, iNumAMVPCands ); |
---|
442 | #else |
---|
443 | m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx ); |
---|
444 | #endif |
---|
445 | } |
---|
446 | pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo); |
---|
447 | pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth); |
---|
448 | pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth ); |
---|
449 | if ( iRefIdx >= 0 ) |
---|
450 | { |
---|
451 | m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, iRefIdx, cMv); |
---|
452 | cMv += pcSubCUMvField->getMvd( uiPartAddr ); |
---|
453 | } |
---|
454 | |
---|
455 | PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr ); |
---|
456 | pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx); |
---|
457 | } |
---|
458 | |
---|
459 | #if UNIFIED_TRANSFORM_TREE |
---|
460 | Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3, Bool& bCodeDQP ) |
---|
461 | #else |
---|
462 | Void TDecEntropy::xDecodeTransformSubdiv( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt uiInnerQuadIdx, UInt& uiYCbfFront3, UInt& uiUCbfFront3, UInt& uiVCbfFront3 ) |
---|
463 | #endif |
---|
464 | { |
---|
465 | UInt uiSubdiv; |
---|
466 | const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth; |
---|
467 | |
---|
468 | #if UNIFIED_TRANSFORM_TREE |
---|
469 | if(uiTrIdx==0) |
---|
470 | { |
---|
471 | m_bakAbsPartIdxCU = uiAbsPartIdx; |
---|
472 | } |
---|
473 | if( uiLog2TrafoSize == 2 ) |
---|
474 | { |
---|
475 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
476 | if( ( uiAbsPartIdx % partNum ) == 0 ) |
---|
477 | { |
---|
478 | m_uiBakAbsPartIdx = uiAbsPartIdx; |
---|
479 | m_uiBakChromaOffset = offsetChroma; |
---|
480 | } |
---|
481 | } |
---|
482 | #endif // UNIFIED_TRANSFORM_TREE |
---|
483 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) ) |
---|
484 | { |
---|
485 | uiSubdiv = 1; |
---|
486 | } |
---|
487 | #if G519_TU_AMP_NSQT_HARMONIZATION |
---|
488 | else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) ) |
---|
489 | #else |
---|
490 | else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2NxN || pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_Nx2N) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) ) |
---|
491 | #endif |
---|
492 | { |
---|
493 | uiSubdiv = (uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx)); |
---|
494 | } |
---|
495 | else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
496 | { |
---|
497 | uiSubdiv = 1; |
---|
498 | } |
---|
499 | else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
500 | { |
---|
501 | uiSubdiv = 0; |
---|
502 | } |
---|
503 | else if( uiLog2TrafoSize == pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ) |
---|
504 | { |
---|
505 | uiSubdiv = 0; |
---|
506 | } |
---|
507 | else |
---|
508 | { |
---|
509 | assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) ); |
---|
510 | m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, uiDepth ); |
---|
511 | } |
---|
512 | |
---|
513 | const UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx ); |
---|
514 | |
---|
515 | if( uiLog2TrafoSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
516 | { |
---|
517 | const Bool bFirstCbfOfCU = uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() || uiTrDepth == 0; |
---|
518 | if( bFirstCbfOfCU ) |
---|
519 | { |
---|
520 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
521 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
522 | } |
---|
523 | if( bFirstCbfOfCU || uiLog2TrafoSize > 2 ) |
---|
524 | { |
---|
525 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) ) |
---|
526 | { |
---|
527 | if ( uiInnerQuadIdx == 3 && uiUCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
528 | { |
---|
529 | uiUCbfFront3++; |
---|
530 | pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
531 | //printf( " \nsave bits, U Cbf"); |
---|
532 | } |
---|
533 | else |
---|
534 | { |
---|
535 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth ); |
---|
536 | uiUCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth ); |
---|
537 | } |
---|
538 | } |
---|
539 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) ) |
---|
540 | { |
---|
541 | if ( uiInnerQuadIdx == 3 && uiVCbfFront3 == 0 && uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
542 | { |
---|
543 | uiVCbfFront3++; |
---|
544 | pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
545 | //printf( " \nsave bits, V Cbf"); |
---|
546 | } |
---|
547 | else |
---|
548 | { |
---|
549 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth ); |
---|
550 | uiVCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth ); |
---|
551 | } |
---|
552 | } |
---|
553 | } |
---|
554 | else |
---|
555 | { |
---|
556 | pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
557 | pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
558 | if ( uiLog2TrafoSize == 2 ) |
---|
559 | { |
---|
560 | uiUCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth ); |
---|
561 | uiVCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth ); |
---|
562 | } |
---|
563 | } |
---|
564 | } |
---|
565 | |
---|
566 | if( uiSubdiv ) |
---|
567 | { |
---|
568 | #if UNIFIED_TRANSFORM_TREE |
---|
569 | UInt size; |
---|
570 | width >>= 1; |
---|
571 | height >>= 1; |
---|
572 | size = width*height; |
---|
573 | uiTrIdx++; |
---|
574 | #endif |
---|
575 | ++uiDepth; |
---|
576 | const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
577 | const UInt uiStartAbsPartIdx = uiAbsPartIdx; |
---|
578 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
579 | pcCU->convertTransIdx( uiStartAbsPartIdx, uiTrDepth+1, uiLumaTrMode, uiChromaTrMode ); |
---|
580 | UInt uiYCbf = 0; |
---|
581 | UInt uiUCbf = 0; |
---|
582 | UInt uiVCbf = 0; |
---|
583 | |
---|
584 | UInt uiCurrentCbfY = 0; |
---|
585 | UInt uiCurrentCbfU = 0; |
---|
586 | UInt uiCurrentCbfV = 0; |
---|
587 | |
---|
588 | for( Int i = 0; i < 4; i++ ) |
---|
589 | { |
---|
590 | #if UNIFIED_TRANSFORM_TREE |
---|
591 | UInt nsAddr = 0; |
---|
592 | nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, i, uiTrDepth+1 ); |
---|
593 | xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, nsAddr, uiDepth, width, height, uiTrIdx, i, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV, bCodeDQP ); |
---|
594 | #else |
---|
595 | UInt nsAddr = 0; |
---|
596 | nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, i, uiTrDepth+1 ); |
---|
597 | xDecodeTransformSubdiv( pcCU, uiAbsPartIdx, nsAddr, uiDepth, i, uiCurrentCbfY, uiCurrentCbfU, uiCurrentCbfV ); |
---|
598 | #endif |
---|
599 | uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode ); |
---|
600 | uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiChromaTrMode ); |
---|
601 | uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiChromaTrMode ); |
---|
602 | uiAbsPartIdx += uiQPartNum; |
---|
603 | #if UNIFIED_TRANSFORM_TREE |
---|
604 | offsetLuma += size; offsetChroma += (size>>2); |
---|
605 | #endif |
---|
606 | } |
---|
607 | |
---|
608 | uiYCbfFront3 += uiCurrentCbfY; |
---|
609 | uiUCbfFront3 += uiCurrentCbfU; |
---|
610 | uiVCbfFront3 += uiCurrentCbfV; |
---|
611 | |
---|
612 | pcCU->convertTransIdx( uiStartAbsPartIdx, uiTrDepth, uiLumaTrMode, uiChromaTrMode ); |
---|
613 | for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui ) |
---|
614 | { |
---|
615 | pcCU->getCbf( TEXT_LUMA )[uiStartAbsPartIdx + ui] |= uiYCbf << uiLumaTrMode; |
---|
616 | pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiChromaTrMode; |
---|
617 | pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiChromaTrMode; |
---|
618 | } |
---|
619 | } |
---|
620 | else |
---|
621 | { |
---|
622 | assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) ); |
---|
623 | pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth ); |
---|
624 | |
---|
625 | { |
---|
626 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
627 | DTRACE_CABAC_T( "\tTrIdx: abspart=" ); |
---|
628 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
629 | DTRACE_CABAC_T( "\tdepth=" ); |
---|
630 | DTRACE_CABAC_V( uiDepth ); |
---|
631 | DTRACE_CABAC_T( "\ttrdepth=" ); |
---|
632 | DTRACE_CABAC_V( uiTrDepth ); |
---|
633 | DTRACE_CABAC_T( "\n" ); |
---|
634 | } |
---|
635 | |
---|
636 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
637 | pcCU->convertTransIdx( uiAbsPartIdx, uiTrDepth, uiLumaTrMode, uiChromaTrMode ); |
---|
638 | if(pcCU->getPredictionMode( uiAbsPartIdx ) == MODE_INTER && pcCU->useNonSquarePU( uiAbsPartIdx ) ) |
---|
639 | { |
---|
640 | pcCU->setNSQTIdxSubParts( uiLog2TrafoSize, uiAbsPartIdx, absTUPartIdx, uiLumaTrMode ); |
---|
641 | } |
---|
642 | pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
643 | if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) ) |
---|
644 | { |
---|
645 | pcCU->setCbfSubParts( 1 << uiLumaTrMode, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
646 | } |
---|
647 | else |
---|
648 | { |
---|
649 | const UInt uiLog2CUSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()] + 2 - pcCU->getDepth( uiAbsPartIdx ); |
---|
650 | if ( pcCU->getPredictionMode( uiAbsPartIdx ) != MODE_INTRA && uiInnerQuadIdx == 3 && uiYCbfFront3 == 0 && uiUCbfFront3 == 0 && uiVCbfFront3 == 0 |
---|
651 | && ( uiLog2CUSize <= pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() + 1 || uiLog2TrafoSize < pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) ) |
---|
652 | { |
---|
653 | pcCU->setCbfSubParts( 1 << uiLumaTrMode, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
654 | //printf( " \nsave bits, Y Cbf"); |
---|
655 | uiYCbfFront3++; |
---|
656 | } |
---|
657 | else |
---|
658 | { |
---|
659 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode, uiDepth ); |
---|
660 | uiYCbfFront3 += pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode ); |
---|
661 | } |
---|
662 | } |
---|
663 | #if UNIFIED_TRANSFORM_TREE |
---|
664 | // transform_unit begin |
---|
665 | UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA , uiTrIdx ); |
---|
666 | UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
667 | UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
668 | if( uiLog2TrafoSize == 2 ) |
---|
669 | { |
---|
670 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
671 | if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) |
---|
672 | { |
---|
673 | cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
674 | cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
675 | } |
---|
676 | } |
---|
677 | if ( cbfY || cbfU || cbfV ) |
---|
678 | { |
---|
679 | // dQP: only for LCU |
---|
680 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
681 | { |
---|
682 | if ( bCodeDQP ) |
---|
683 | { |
---|
684 | decodeQP( pcCU, m_bakAbsPartIdxCU); |
---|
685 | bCodeDQP = false; |
---|
686 | } |
---|
687 | } |
---|
688 | } |
---|
689 | if( cbfY ) |
---|
690 | { |
---|
691 | Int trWidth = width; |
---|
692 | Int trHeight = height; |
---|
693 | pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight ); |
---|
694 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA ); |
---|
695 | } |
---|
696 | if( uiLog2TrafoSize > 2 ) |
---|
697 | { |
---|
698 | Int trWidth = width >> 1; |
---|
699 | Int trHeight = height >> 1; |
---|
700 | pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight ); |
---|
701 | if( cbfU ) |
---|
702 | { |
---|
703 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
704 | } |
---|
705 | if( cbfV ) |
---|
706 | { |
---|
707 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
708 | } |
---|
709 | } |
---|
710 | else |
---|
711 | { |
---|
712 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
713 | if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) |
---|
714 | { |
---|
715 | Int trWidth = width; |
---|
716 | Int trHeight = height; |
---|
717 | pcCU->getNSQTSize( uiTrIdx - 1, uiAbsPartIdx, trWidth, trHeight ); |
---|
718 | if( cbfU ) |
---|
719 | { |
---|
720 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
721 | } |
---|
722 | if( cbfV ) |
---|
723 | { |
---|
724 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
725 | } |
---|
726 | } |
---|
727 | } |
---|
728 | // transform_unit end |
---|
729 | #endif // UNIFIED_TRANSFORM_TREE |
---|
730 | } |
---|
731 | } |
---|
732 | |
---|
733 | #if !UNIFIED_TRANSFORM_TREE |
---|
734 | Void TDecEntropy::decodeTransformIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
735 | { |
---|
736 | DTRACE_CABAC_VL( g_nSymbolCounter++ ) |
---|
737 | DTRACE_CABAC_T( "\tdecodeTransformIdx()\tCUDepth=" ) |
---|
738 | DTRACE_CABAC_V( uiDepth ) |
---|
739 | DTRACE_CABAC_T( "\n" ) |
---|
740 | UInt temp = 0; |
---|
741 | UInt temp1 = 0; |
---|
742 | UInt temp2 = 0; |
---|
743 | xDecodeTransformSubdiv( pcCU, uiAbsPartIdx, uiAbsPartIdx, uiDepth, 0, temp, temp1, temp2 ); |
---|
744 | } |
---|
745 | #endif // UNIFIED_TRANSFORM_TREE |
---|
746 | |
---|
747 | #if UNIFIED_TRANSFORM_TREE |
---|
748 | Void TDecEntropy::decodeQP ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
749 | { |
---|
750 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
751 | { |
---|
752 | m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) ); |
---|
753 | } |
---|
754 | } |
---|
755 | #else |
---|
756 | Void TDecEntropy::decodeQP ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
757 | { |
---|
758 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
759 | { |
---|
760 | m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, uiDepth ); |
---|
761 | } |
---|
762 | } |
---|
763 | #endif |
---|
764 | |
---|
765 | #if !UNIFIED_TRANSFORM_TREE |
---|
766 | Void TDecEntropy::xDecodeCoeff( TComDataCU* pcCU, UInt uiLumaOffset, UInt uiChromaOffset, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, UInt uiTrIdx, UInt uiCurrTrIdx, Bool& bCodeDQP ) |
---|
767 | { |
---|
768 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiDepth ] + 2; |
---|
769 | UInt uiCbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrIdx ); |
---|
770 | UInt uiCbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
771 | UInt uiCbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
772 | if( uiLog2TrSize == 2 ) |
---|
773 | { |
---|
774 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
775 | if( ( uiAbsPartIdx % uiQPDiv ) == 0 ) |
---|
776 | { |
---|
777 | m_uiBakAbsPartIdx = uiAbsPartIdx; |
---|
778 | m_uiBakChromaOffset = uiChromaOffset; |
---|
779 | } |
---|
780 | else if( ( uiAbsPartIdx % uiQPDiv ) == (uiQPDiv - 1) ) |
---|
781 | { |
---|
782 | uiCbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
783 | uiCbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
784 | } |
---|
785 | } |
---|
786 | |
---|
787 | if ( uiCbfY || uiCbfU || uiCbfV ) |
---|
788 | { |
---|
789 | // dQP: only for LCU |
---|
790 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
791 | { |
---|
792 | if ( bCodeDQP ) |
---|
793 | { |
---|
794 | decodeQP( pcCU, uiAbsPartIdx, uiDepth); |
---|
795 | bCodeDQP = false; |
---|
796 | } |
---|
797 | } |
---|
798 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
799 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode ); |
---|
800 | const UInt uiStopTrMode = uiLumaTrMode; |
---|
801 | |
---|
802 | if( uiTrIdx == uiStopTrMode ) |
---|
803 | { |
---|
804 | if( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrIdx ) ) |
---|
805 | { |
---|
806 | Int trWidth = uiWidth; |
---|
807 | Int trHeight = uiHeight; |
---|
808 | pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight ); |
---|
809 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+uiLumaOffset), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA ); |
---|
810 | } |
---|
811 | |
---|
812 | uiWidth >>= 1; |
---|
813 | uiHeight >>= 1; |
---|
814 | |
---|
815 | if( uiLog2TrSize == 2 ) |
---|
816 | { |
---|
817 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
818 | if( ( uiAbsPartIdx % uiQPDiv ) == (uiQPDiv - 1) ) |
---|
819 | { |
---|
820 | uiWidth <<= 1; |
---|
821 | uiHeight <<= 1; |
---|
822 | Int trWidth = uiWidth; |
---|
823 | Int trHeight = uiHeight; |
---|
824 | pcCU->getNSQTSize( uiTrIdx-1, uiAbsPartIdx, trWidth, trHeight ); |
---|
825 | if( pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ) ) |
---|
826 | { |
---|
827 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
828 | } |
---|
829 | if( pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ) ) |
---|
830 | { |
---|
831 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
832 | } |
---|
833 | } |
---|
834 | } |
---|
835 | else |
---|
836 | { |
---|
837 | Int trWidth = uiWidth; |
---|
838 | Int trHeight = uiHeight; |
---|
839 | pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight ); |
---|
840 | if( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ) ) |
---|
841 | { |
---|
842 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+uiChromaOffset), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
843 | } |
---|
844 | if( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ) ) |
---|
845 | { |
---|
846 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+uiChromaOffset), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
847 | } |
---|
848 | } |
---|
849 | } |
---|
850 | else |
---|
851 | { |
---|
852 | { |
---|
853 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
854 | DTRACE_CABAC_T( "\tgoing down\tdepth=" ); |
---|
855 | DTRACE_CABAC_V( uiDepth ); |
---|
856 | DTRACE_CABAC_T( "\ttridx=" ); |
---|
857 | DTRACE_CABAC_V( uiTrIdx ); |
---|
858 | DTRACE_CABAC_T( "\n" ); |
---|
859 | } |
---|
860 | if( uiCurrTrIdx <= uiTrIdx ) |
---|
861 | { |
---|
862 | assert(1); |
---|
863 | } |
---|
864 | UInt uiSize; |
---|
865 | uiWidth >>= 1; |
---|
866 | uiHeight >>= 1; |
---|
867 | uiSize = uiWidth*uiHeight; |
---|
868 | uiDepth++; |
---|
869 | uiTrIdx++; |
---|
870 | |
---|
871 | UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
872 | UInt uiIdx = uiAbsPartIdx; |
---|
873 | |
---|
874 | xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP ); |
---|
875 | uiLumaOffset += uiSize; uiChromaOffset += (uiSize>>2); uiIdx += uiQPartNum; |
---|
876 | |
---|
877 | xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP ); |
---|
878 | uiLumaOffset += uiSize; uiChromaOffset += (uiSize>>2); uiIdx += uiQPartNum; |
---|
879 | |
---|
880 | xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP ); |
---|
881 | uiLumaOffset += uiSize; uiChromaOffset += (uiSize>>2); uiIdx += uiQPartNum; |
---|
882 | |
---|
883 | xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiIdx, uiDepth, uiWidth, uiHeight, uiTrIdx, uiCurrTrIdx, bCodeDQP ); |
---|
884 | { |
---|
885 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
886 | DTRACE_CABAC_T( "\tgoing up\n" ); |
---|
887 | } |
---|
888 | } |
---|
889 | } |
---|
890 | } |
---|
891 | #endif // !UNIFIED_TRANSFORM_TREE |
---|
892 | |
---|
893 | /** decode coefficients |
---|
894 | * \param pcCU |
---|
895 | * \param uiAbsPartIdx |
---|
896 | * \param uiDepth |
---|
897 | * \param uiWidth |
---|
898 | * \param uiHeight |
---|
899 | * \returns Void |
---|
900 | */ |
---|
901 | Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP ) |
---|
902 | { |
---|
903 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
904 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
905 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
906 | #if UNIFIED_TRANSFORM_TREE |
---|
907 | UInt temp = 0; |
---|
908 | UInt temp1 = 0; |
---|
909 | UInt temp2 = 0; |
---|
910 | #else |
---|
911 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
912 | #endif |
---|
913 | |
---|
914 | if( pcCU->isIntra(uiAbsPartIdx) ) |
---|
915 | { |
---|
916 | #if !UNIFIED_TRANSFORM_TREE |
---|
917 | decodeTransformIdx( pcCU, uiAbsPartIdx, pcCU->getDepth(uiAbsPartIdx) ); |
---|
918 | |
---|
919 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx(uiAbsPartIdx), uiLumaTrMode, uiChromaTrMode ); |
---|
920 | |
---|
921 | #endif // !UNIFIED_TRANSFORM_TREE |
---|
922 | } |
---|
923 | else |
---|
924 | { |
---|
925 | UInt uiQtRootCbf = 1; |
---|
926 | #if HHI_MPI |
---|
927 | if( !(pcCU->getMergeFlag( uiAbsPartIdx ) && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N && |
---|
928 | ( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth == pcCU->getTextureModeDepth( uiAbsPartIdx ) ) ) ) |
---|
929 | #else |
---|
930 | if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) ) |
---|
931 | #endif |
---|
932 | { |
---|
933 | m_pcEntropyDecoderIf->parseQtRootCbf( pcCU, uiAbsPartIdx, uiDepth, uiQtRootCbf ); |
---|
934 | } |
---|
935 | if ( !uiQtRootCbf ) |
---|
936 | { |
---|
937 | pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth ); |
---|
938 | pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth ); |
---|
939 | pcCU->setNSQTIdxSubParts( uiAbsPartIdx, uiDepth ); |
---|
940 | return; |
---|
941 | } |
---|
942 | |
---|
943 | #if !UNIFIED_TRANSFORM_TREE |
---|
944 | decodeTransformIdx( pcCU, uiAbsPartIdx, pcCU->getDepth(uiAbsPartIdx) ); |
---|
945 | |
---|
946 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx(uiAbsPartIdx), uiLumaTrMode, uiChromaTrMode ); |
---|
947 | #endif // !UNIFIED_TRANSFORM_TREE |
---|
948 | } |
---|
949 | #if UNIFIED_TRANSFORM_TREE |
---|
950 | xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, 0, temp, temp1, temp2, bCodeDQP ); |
---|
951 | #else // UNIFIED_TRANSFORM_TREE |
---|
952 | xDecodeCoeff( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, uiLumaTrMode, bCodeDQP ); |
---|
953 | #endif // UNIFIED_TRANSFORM_TREE |
---|
954 | } |
---|
955 | |
---|
956 | //! \} |
---|