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