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-2014, 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/TComSampleAdaptiveOffset.h" |
---|
49 | |
---|
50 | Void TDecEntropy::decodeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
51 | { |
---|
52 | m_pcEntropyDecoderIf->parseSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
53 | } |
---|
54 | |
---|
55 | Void TDecEntropy::decodeCUTransquantBypassFlag(TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
56 | { |
---|
57 | m_pcEntropyDecoderIf->parseCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
58 | } |
---|
59 | |
---|
60 | /** decode merge flag |
---|
61 | * \param pcSubCU |
---|
62 | * \param uiAbsPartIdx |
---|
63 | * \param uiDepth |
---|
64 | * \param uiPUIdx |
---|
65 | * \returns Void |
---|
66 | */ |
---|
67 | Void TDecEntropy::decodeMergeFlag( TComDataCU* pcSubCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) |
---|
68 | { |
---|
69 | // at least one merge candidate exists |
---|
70 | m_pcEntropyDecoderIf->parseMergeFlag( pcSubCU, uiAbsPartIdx, uiDepth, uiPUIdx ); |
---|
71 | } |
---|
72 | |
---|
73 | /** decode merge index |
---|
74 | * \param pcCU |
---|
75 | * \param uiPartIdx |
---|
76 | * \param uiAbsPartIdx |
---|
77 | * \param puhInterDirNeighbours pointer to list of inter direction from the casual neighbours |
---|
78 | * \param pcMvFieldNeighbours pointer to list of motion vector field from the casual neighbours |
---|
79 | * \param uiDepth |
---|
80 | * \returns Void |
---|
81 | */ |
---|
82 | Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
83 | { |
---|
84 | UInt uiMergeIndex = 0; |
---|
85 | m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex ); |
---|
86 | pcCU->setMergeIndexSubParts( uiMergeIndex, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
87 | } |
---|
88 | |
---|
89 | #if H_3D_ARP |
---|
90 | Void TDecEntropy::decodeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
91 | { |
---|
92 | if( !pcCU->getSlice()->getARPStepNum() || pcCU->isIntra( uiAbsPartIdx ) ) |
---|
93 | { |
---|
94 | return; |
---|
95 | } |
---|
96 | |
---|
97 | if( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) |
---|
98 | { |
---|
99 | pcCU->setARPWSubParts( 0 , uiAbsPartIdx, uiDepth ); |
---|
100 | } |
---|
101 | else |
---|
102 | { |
---|
103 | m_pcEntropyDecoderIf->parseARPW( pcCU , uiAbsPartIdx , uiDepth ); |
---|
104 | } |
---|
105 | } |
---|
106 | #endif |
---|
107 | |
---|
108 | #if H_3D_IC |
---|
109 | Void TDecEntropy::decodeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
110 | { |
---|
111 | pcCU->setICFlagSubParts( false , uiAbsPartIdx, 0, uiDepth ); |
---|
112 | |
---|
113 | if ( pcCU->isIntra( uiAbsPartIdx ) || ( pcCU->getSlice()->getViewIndex() == 0 ) || pcCU->getSlice()->getIsDepth() || pcCU->getARPW( uiAbsPartIdx ) > 0 ) |
---|
114 | { |
---|
115 | return; |
---|
116 | } |
---|
117 | |
---|
118 | if( !pcCU->getSlice()->getApplyIC() ) |
---|
119 | return; |
---|
120 | |
---|
121 | if( pcCU->isICFlagRequired( uiAbsPartIdx ) ) |
---|
122 | m_pcEntropyDecoderIf->parseICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
123 | } |
---|
124 | #endif |
---|
125 | |
---|
126 | Void TDecEntropy::decodeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
127 | { |
---|
128 | m_pcEntropyDecoderIf->parseSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
129 | } |
---|
130 | |
---|
131 | Void TDecEntropy::decodePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
132 | { |
---|
133 | m_pcEntropyDecoderIf->parsePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
134 | } |
---|
135 | |
---|
136 | Void TDecEntropy::decodePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
137 | { |
---|
138 | m_pcEntropyDecoderIf->parsePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
139 | |
---|
140 | #if H_3D_DBBP |
---|
141 | |
---|
142 | #if MTK_DBBP_SIGNALING_H0094 |
---|
143 | if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) ) |
---|
144 | #else |
---|
145 | if( pcCU->getSlice()->getVPS()->getUseDBBP(pcCU->getSlice()->getLayerIdInVps()) && pcCU->getPartitionSize(uiAbsPartIdx) == RWTH_DBBP_PACK_MODE ) |
---|
146 | #endif |
---|
147 | { |
---|
148 | decodeDBBPFlag(pcCU, uiAbsPartIdx, uiDepth); |
---|
149 | |
---|
150 | if( pcCU->getDBBPFlag(uiAbsPartIdx) ) |
---|
151 | { |
---|
152 | #if !MTK_DBBP_SIGNALING_H0094 |
---|
153 | AOF( pcCU->getPartitionSize(uiAbsPartIdx) == RWTH_DBBP_PACK_MODE ); |
---|
154 | #endif |
---|
155 | |
---|
156 | // get collocated depth block |
---|
157 | UInt uiDepthStride = 0; |
---|
158 | Pel* pDepthPels = NULL; |
---|
159 | pDepthPels = pcCU->getVirtualDepthBlock(uiAbsPartIdx, pcCU->getWidth(uiAbsPartIdx), pcCU->getHeight(uiAbsPartIdx), uiDepthStride); |
---|
160 | |
---|
161 | AOF( pDepthPels != NULL ); |
---|
162 | AOF( uiDepthStride != 0 ); |
---|
163 | |
---|
164 | // derive true partitioning for this CU based on depth |
---|
165 | // (needs to be done in parsing process as motion vector predictors are also derived during parsing) |
---|
166 | PartSize eVirtualPartSize = m_pcPrediction->getPartitionSizeFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(uiAbsPartIdx)); |
---|
167 | AOF( eVirtualPartSize != SIZE_NONE ); |
---|
168 | |
---|
169 | pcCU->setPartSizeSubParts(eVirtualPartSize, uiAbsPartIdx, uiDepth); |
---|
170 | |
---|
171 | #if RWTH_DBBP_NO_SPU_H0057 |
---|
172 | // make sure that DBBP flag is set for both segments |
---|
173 | UInt uiPUOffset = ( g_auiPUOffset[UInt( eVirtualPartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
174 | pcCU->setDBBPFlagSubParts(true, uiAbsPartIdx, 0, uiDepth); |
---|
175 | pcCU->setDBBPFlagSubParts(true, uiAbsPartIdx+uiPUOffset, 1, uiDepth); |
---|
176 | #endif |
---|
177 | } |
---|
178 | } |
---|
179 | #endif |
---|
180 | } |
---|
181 | |
---|
182 | Void TDecEntropy::decodePredInfo ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ) |
---|
183 | { |
---|
184 | if( pcCU->isIntra( uiAbsPartIdx ) ) // If it is Intra mode, encode intra prediction mode. |
---|
185 | { |
---|
186 | decodeIntraDirModeLuma ( pcCU, uiAbsPartIdx, uiDepth ); |
---|
187 | #if H_3D_DIM_SDC |
---|
188 | if(!pcCU->getSDCFlag(uiAbsPartIdx)) |
---|
189 | #endif |
---|
190 | decodeIntraDirModeChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
191 | } |
---|
192 | else // if it is Inter mode, encode motion vector and reference index |
---|
193 | { |
---|
194 | decodePUWise( pcCU, uiAbsPartIdx, uiDepth, pcSubCU ); |
---|
195 | } |
---|
196 | } |
---|
197 | |
---|
198 | /** Parse I_PCM information. |
---|
199 | * \param pcCU pointer to CUpointer to CU |
---|
200 | * \param uiAbsPartIdx CU index |
---|
201 | * \param uiDepth CU depth |
---|
202 | * \returns Void |
---|
203 | */ |
---|
204 | Void TDecEntropy::decodeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
205 | { |
---|
206 | if(!pcCU->getSlice()->getSPS()->getUsePCM() |
---|
207 | || pcCU->getWidth(uiAbsPartIdx) > (1<<pcCU->getSlice()->getSPS()->getPCMLog2MaxSize()) |
---|
208 | || pcCU->getWidth(uiAbsPartIdx) < (1<<pcCU->getSlice()->getSPS()->getPCMLog2MinSize()) ) |
---|
209 | { |
---|
210 | return; |
---|
211 | } |
---|
212 | #if !MTK_SDC_FLAG_FIX_H0095 |
---|
213 | #if H_3D_DIM_SDC |
---|
214 | if( pcCU->getSDCFlag(uiAbsPartIdx) ) |
---|
215 | { |
---|
216 | return; |
---|
217 | } |
---|
218 | #endif |
---|
219 | #endif |
---|
220 | |
---|
221 | m_pcEntropyDecoderIf->parseIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
222 | } |
---|
223 | |
---|
224 | Void TDecEntropy::decodeIntraDirModeLuma ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
225 | { |
---|
226 | m_pcEntropyDecoderIf->parseIntraDirLumaAng( pcCU, uiAbsPartIdx, uiDepth ); |
---|
227 | } |
---|
228 | |
---|
229 | Void TDecEntropy::decodeIntraDirModeChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
230 | { |
---|
231 | m_pcEntropyDecoderIf->parseIntraDirChroma( pcCU, uiAbsPartIdx, uiDepth ); |
---|
232 | } |
---|
233 | |
---|
234 | /** decode motion information for every PU block. |
---|
235 | * \param pcCU |
---|
236 | * \param uiAbsPartIdx |
---|
237 | * \param uiDepth |
---|
238 | * \param pcSubCU |
---|
239 | * \returns Void |
---|
240 | */ |
---|
241 | Void TDecEntropy::decodePUWise( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComDataCU* pcSubCU ) |
---|
242 | { |
---|
243 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
244 | UInt uiNumPU = ( ePartSize == SIZE_2Nx2N ? 1 : ( ePartSize == SIZE_NxN ? 4 : 2 ) ); |
---|
245 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
246 | |
---|
247 | #if H_3D_IV_MERGE |
---|
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 | #else |
---|
251 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
252 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
253 | #endif |
---|
254 | #if H_3D_SPIVMP |
---|
255 | Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
256 | TComMvField* pcMvFieldSP; |
---|
257 | UChar* puhInterDirSP; |
---|
258 | pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; |
---|
259 | puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; |
---|
260 | #endif |
---|
261 | for ( UInt ui = 0; ui < pcCU->getSlice()->getMaxNumMergeCand(); ui++ ) |
---|
262 | { |
---|
263 | uhInterDirNeighbours[ui] = 0; |
---|
264 | } |
---|
265 | Int numValidMergeCand = 0; |
---|
266 | Bool isMerged = false; |
---|
267 | |
---|
268 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
269 | pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
270 | #if H_3D_IV_MERGE |
---|
271 | pcSubCU->copyDVInfoFrom( pcCU, uiAbsPartIdx); |
---|
272 | #endif |
---|
273 | for ( UInt uiPartIdx = 0, uiSubPartIdx = uiAbsPartIdx; uiPartIdx < uiNumPU; uiPartIdx++, uiSubPartIdx += uiPUOffset ) |
---|
274 | { |
---|
275 | #if H_MV_ENC_DEC_TRAC |
---|
276 | DTRACE_PU_S("=========== prediction_unit ===========\n") |
---|
277 | // ToDo: |
---|
278 | //DTRACE_PU("x0", uiLPelX) |
---|
279 | //DTRACE_PU("x1", uiTPelY) |
---|
280 | #endif |
---|
281 | decodeMergeFlag( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
282 | if ( pcCU->getMergeFlag( uiSubPartIdx ) ) |
---|
283 | { |
---|
284 | decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth ); |
---|
285 | UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
---|
286 | #if H_3D_ARP |
---|
287 | decodeARPW ( pcCU, uiAbsPartIdx, uiDepth ); |
---|
288 | #endif |
---|
289 | #if H_3D_IC |
---|
290 | decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
291 | #endif |
---|
292 | #if H_3D_DBBP |
---|
293 | if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 && pcCU->getDBBPFlag(uiAbsPartIdx) == false ) |
---|
294 | #else |
---|
295 | if ( pcCU->getSlice()->getPPS()->getLog2ParallelMergeLevelMinus2() && ePartSize != SIZE_2Nx2N && pcSubCU->getWidth( 0 ) <= 8 ) |
---|
296 | #endif |
---|
297 | { |
---|
298 | pcSubCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
299 | if ( !isMerged ) |
---|
300 | { |
---|
301 | #if H_3D_VSP |
---|
302 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
303 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
---|
304 | InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM]; |
---|
305 | #if H_3D_SPIVMP |
---|
306 | memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); |
---|
307 | #endif |
---|
308 | pcSubCU->initAvailableFlags(); |
---|
309 | pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand); |
---|
310 | pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours |
---|
311 | #if !ETRIKHU_CLEANUP_H0083 |
---|
312 | ,vspFlag |
---|
313 | #endif |
---|
314 | , inheritedVSPDisInfo |
---|
315 | #if H_3D_SPIVMP |
---|
316 | #if !ETRIKHU_CLEANUP_H0083_MISSING |
---|
317 | , bSPIVMPFlag |
---|
318 | #endif |
---|
319 | , pcMvFieldSP, puhInterDirSP |
---|
320 | #endif |
---|
321 | , numValidMergeCand ); |
---|
322 | |
---|
323 | #if ETRIKHU_CLEANUP_H0083 |
---|
324 | pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag |
---|
325 | #if H_3D_SPIVMP |
---|
326 | , bSPIVMPFlag |
---|
327 | #endif |
---|
328 | , numValidMergeCand ); |
---|
329 | #endif |
---|
330 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
331 | |
---|
332 | if(vspFlag[uiMergeIndex]) |
---|
333 | { |
---|
334 | pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeIndex].m_acDvInfo, uiSubPartIdx, uiPartIdx, uiDepth); |
---|
335 | } |
---|
336 | #else |
---|
337 | #if H_3D |
---|
338 | pcSubCU->initAvailableFlags(); |
---|
339 | pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand); |
---|
340 | pcSubCU->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
341 | |
---|
342 | #else |
---|
343 | pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
344 | #endif |
---|
345 | #endif |
---|
346 | isMerged = true; |
---|
347 | } |
---|
348 | pcSubCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); |
---|
349 | } |
---|
350 | else |
---|
351 | { |
---|
352 | uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx); |
---|
353 | #if H_3D_VSP |
---|
354 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
355 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
---|
356 | InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM]; |
---|
357 | #if H_3D_SPIVMP |
---|
358 | memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); |
---|
359 | #endif |
---|
360 | pcSubCU->initAvailableFlags(); |
---|
361 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
362 | pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours |
---|
363 | #if !ETRIKHU_CLEANUP_H0083 |
---|
364 | , vspFlag |
---|
365 | #endif |
---|
366 | , inheritedVSPDisInfo |
---|
367 | #if H_3D_SPIVMP |
---|
368 | #if !ETRIKHU_CLEANUP_H0083_MISSING |
---|
369 | , bSPIVMPFlag |
---|
370 | #endif |
---|
371 | , pcMvFieldSP, puhInterDirSP |
---|
372 | #endif |
---|
373 | ,numValidMergeCand, uiMergeIndex ); |
---|
374 | |
---|
375 | #if ETRIKHU_CLEANUP_H0083 |
---|
376 | pcSubCU->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag |
---|
377 | #if H_3D_SPIVMP |
---|
378 | , bSPIVMPFlag |
---|
379 | #endif |
---|
380 | ,numValidMergeCand ); |
---|
381 | #endif |
---|
382 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
383 | if(vspFlag[uiMergeIndex]) |
---|
384 | { |
---|
385 | pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeIndex].m_acDvInfo, uiSubPartIdx, uiPartIdx, uiDepth); |
---|
386 | } |
---|
387 | #else |
---|
388 | #if H_3D |
---|
389 | pcSubCU->initAvailableFlags(); |
---|
390 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
391 | pcSubCU->xGetInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
392 | #else |
---|
393 | pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
394 | #endif |
---|
395 | #endif |
---|
396 | } |
---|
397 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
398 | |
---|
399 | #if H_3D_DDD |
---|
400 | if( uiMergeIndex == pcSubCU->getUseDDDCandIdx() ) |
---|
401 | { |
---|
402 | assert( pcCU->getSlice()->getViewIndex() != 0 ); |
---|
403 | pcCU->setUseDDD( true, uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
404 | pcCU->setDDDepthSubParts( pcSubCU->getDDTmpDepth(),uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
405 | } |
---|
406 | else |
---|
407 | { |
---|
408 | pcCU->setUseDDD( false, uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
409 | } |
---|
410 | #endif |
---|
411 | |
---|
412 | TComMv cTmpMv( 0, 0 ); |
---|
413 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
414 | { |
---|
415 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
416 | { |
---|
417 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth); |
---|
418 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiSubPartIdx, uiPartIdx, uiDepth); |
---|
419 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
420 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], ePartSize, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
421 | #if H_3D_VSP |
---|
422 | #if H_3D_DBBP |
---|
423 | if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 && !pcCU->getDBBPFlag( uiAbsPartIdx ) ) |
---|
424 | #else |
---|
425 | if( pcCU->getVSPFlag( uiSubPartIdx ) != 0 ) |
---|
426 | #endif |
---|
427 | { |
---|
428 | if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) ) |
---|
429 | { |
---|
430 | UInt dummy; |
---|
431 | Int vspSize; |
---|
432 | Int width, height; |
---|
433 | pcCU->getPartIndexAndSize( uiPartIdx, dummy, width, height, uiSubPartIdx, pcCU->getTotalNumPart()==256 ); |
---|
434 | pcCU->setMvFieldPUForVSP( pcCU, uiSubPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize ); |
---|
435 | pcCU->setVSPFlag( uiSubPartIdx, vspSize ); |
---|
436 | } |
---|
437 | } |
---|
438 | #endif |
---|
439 | } |
---|
440 | } |
---|
441 | #if H_3D_SPIVMP |
---|
442 | pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth ); |
---|
443 | if (bSPIVMPFlag[uiMergeIndex] != 0) |
---|
444 | { |
---|
445 | Int iWidth, iHeight; |
---|
446 | UInt uiIdx; |
---|
447 | pcCU->getPartIndexAndSize( uiPartIdx, uiIdx, iWidth, iHeight, uiSubPartIdx, true ); |
---|
448 | |
---|
449 | UInt uiSPAddr; |
---|
450 | |
---|
451 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
---|
452 | |
---|
453 | pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
---|
454 | |
---|
455 | for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++) |
---|
456 | { |
---|
457 | pcCU->getSPAbsPartIdx(uiSubPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr); |
---|
458 | pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight); |
---|
459 | pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight); |
---|
460 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight); |
---|
461 | } |
---|
462 | } |
---|
463 | #endif |
---|
464 | } |
---|
465 | else |
---|
466 | { |
---|
467 | decodeInterDirPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx ); |
---|
468 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
469 | { |
---|
470 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
471 | { |
---|
472 | decodeRefFrmIdxPU( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
473 | decodeMvdPU ( pcCU, uiSubPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
474 | decodeMVPIdxPU ( pcSubCU, uiSubPartIdx-uiAbsPartIdx, uiDepth, uiPartIdx, RefPicList( uiRefListIdx ) ); |
---|
475 | } |
---|
476 | } |
---|
477 | #if H_3D_ARP |
---|
478 | decodeARPW ( pcCU, uiAbsPartIdx, uiDepth ); |
---|
479 | #endif |
---|
480 | #if H_3D_IC |
---|
481 | decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
482 | #endif |
---|
483 | } |
---|
484 | #if H_3D_VSP |
---|
485 | if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) && (pcCU->getVSPFlag(uiSubPartIdx) == 0)) |
---|
486 | #else |
---|
487 | if ( (pcCU->getInterDir(uiSubPartIdx) == 3) && pcSubCU->isBipredRestriction(uiPartIdx) ) |
---|
488 | #endif |
---|
489 | { |
---|
490 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllMv( TComMv(0,0), ePartSize, uiSubPartIdx, uiDepth, uiPartIdx); |
---|
491 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setAllRefIdx( -1, ePartSize, uiSubPartIdx, uiDepth, uiPartIdx); |
---|
492 | pcCU->setInterDirSubParts( 1, uiSubPartIdx, uiPartIdx, uiDepth); |
---|
493 | } |
---|
494 | } |
---|
495 | #if H_3D_SPIVMP |
---|
496 | delete[] pcMvFieldSP; |
---|
497 | delete[] puhInterDirSP; |
---|
498 | #endif |
---|
499 | return; |
---|
500 | } |
---|
501 | |
---|
502 | /** decode inter direction for a PU block |
---|
503 | * \param pcCU |
---|
504 | * \param uiAbsPartIdx |
---|
505 | * \param uiDepth |
---|
506 | * \param uiPartIdx |
---|
507 | * \returns Void |
---|
508 | */ |
---|
509 | Void TDecEntropy::decodeInterDirPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx ) |
---|
510 | { |
---|
511 | UInt uiInterDir; |
---|
512 | |
---|
513 | if ( pcCU->getSlice()->isInterP() ) |
---|
514 | { |
---|
515 | uiInterDir = 1; |
---|
516 | } |
---|
517 | else |
---|
518 | { |
---|
519 | m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx ); |
---|
520 | } |
---|
521 | |
---|
522 | pcCU->setInterDirSubParts( uiInterDir, uiAbsPartIdx, uiPartIdx, uiDepth ); |
---|
523 | } |
---|
524 | |
---|
525 | Void TDecEntropy::decodeRefFrmIdxPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
526 | { |
---|
527 | Int iRefFrmIdx = 0; |
---|
528 | Int iParseRefFrmIdx = pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ); |
---|
529 | |
---|
530 | if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx ) |
---|
531 | { |
---|
532 | m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, eRefList ); |
---|
533 | } |
---|
534 | else if ( !iParseRefFrmIdx ) |
---|
535 | { |
---|
536 | iRefFrmIdx = NOT_VALID; |
---|
537 | } |
---|
538 | else |
---|
539 | { |
---|
540 | iRefFrmIdx = 0; |
---|
541 | } |
---|
542 | |
---|
543 | PartSize ePartSize = pcCU->getPartitionSize( uiAbsPartIdx ); |
---|
544 | pcCU->getCUMvField( eRefList )->setAllRefIdx( iRefFrmIdx, ePartSize, uiAbsPartIdx, uiDepth, uiPartIdx ); |
---|
545 | } |
---|
546 | |
---|
547 | /** decode motion vector difference for a PU block |
---|
548 | * \param pcCU |
---|
549 | * \param uiAbsPartIdx |
---|
550 | * \param uiDepth |
---|
551 | * \param uiPartIdx |
---|
552 | * \param eRefList |
---|
553 | * \returns Void |
---|
554 | */ |
---|
555 | Void TDecEntropy::decodeMvdPU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
556 | { |
---|
557 | if ( pcCU->getInterDir( uiAbsPartIdx ) & ( 1 << eRefList ) ) |
---|
558 | { |
---|
559 | m_pcEntropyDecoderIf->parseMvd( pcCU, uiAbsPartIdx, uiPartIdx, uiDepth, eRefList ); |
---|
560 | } |
---|
561 | } |
---|
562 | |
---|
563 | Void TDecEntropy::decodeMVPIdxPU( TComDataCU* pcSubCU, UInt uiPartAddr, UInt uiDepth, UInt uiPartIdx, RefPicList eRefList ) |
---|
564 | { |
---|
565 | Int iMVPIdx = -1; |
---|
566 | |
---|
567 | TComMv cZeroMv( 0, 0 ); |
---|
568 | TComMv cMv = cZeroMv; |
---|
569 | Int iRefIdx = -1; |
---|
570 | |
---|
571 | TComCUMvField* pcSubCUMvField = pcSubCU->getCUMvField( eRefList ); |
---|
572 | AMVPInfo* pAMVPInfo = pcSubCUMvField->getAMVPInfo(); |
---|
573 | |
---|
574 | iRefIdx = pcSubCUMvField->getRefIdx(uiPartAddr); |
---|
575 | cMv = cZeroMv; |
---|
576 | |
---|
577 | if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) ) |
---|
578 | { |
---|
579 | m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx ); |
---|
580 | #if H_MV_ENC_DEC_TRAC |
---|
581 | #if ENC_DEC_TRACE |
---|
582 | if ( eRefList == REF_PIC_LIST_0 ) |
---|
583 | { |
---|
584 | DTRACE_PU("mvp_l0_flag", iMVPIdx) |
---|
585 | } |
---|
586 | else |
---|
587 | { |
---|
588 | DTRACE_PU("mvp_l1_flag", iMVPIdx) |
---|
589 | } |
---|
590 | #endif |
---|
591 | #endif |
---|
592 | } |
---|
593 | pcSubCU->fillMvpCand(uiPartIdx, uiPartAddr, eRefList, iRefIdx, pAMVPInfo); |
---|
594 | pcSubCU->setMVPNumSubParts(pAMVPInfo->iN, eRefList, uiPartAddr, uiPartIdx, uiDepth); |
---|
595 | pcSubCU->setMVPIdxSubParts( iMVPIdx, eRefList, uiPartAddr, uiPartIdx, uiDepth ); |
---|
596 | if ( iRefIdx >= 0 ) |
---|
597 | { |
---|
598 | m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, cMv); |
---|
599 | cMv += pcSubCUMvField->getMvd( uiPartAddr ); |
---|
600 | } |
---|
601 | |
---|
602 | PartSize ePartSize = pcSubCU->getPartitionSize( uiPartAddr ); |
---|
603 | pcSubCU->getCUMvField( eRefList )->setAllMv(cMv, ePartSize, uiPartAddr, 0, uiPartIdx); |
---|
604 | } |
---|
605 | |
---|
606 | Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP, Int quadtreeTULog2MinSizeInCU) |
---|
607 | { |
---|
608 | UInt uiSubdiv; |
---|
609 | const UInt uiLog2TrafoSize = g_aucConvertToBit[pcCU->getSlice()->getSPS()->getMaxCUWidth()]+2 - uiDepth; |
---|
610 | |
---|
611 | if(uiTrIdx==0) |
---|
612 | { |
---|
613 | m_bakAbsPartIdxCU = uiAbsPartIdx; |
---|
614 | } |
---|
615 | if( uiLog2TrafoSize == 2 ) |
---|
616 | { |
---|
617 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
618 | if( ( uiAbsPartIdx % partNum ) == 0 ) |
---|
619 | { |
---|
620 | m_uiBakAbsPartIdx = uiAbsPartIdx; |
---|
621 | m_uiBakChromaOffset = offsetChroma; |
---|
622 | } |
---|
623 | } |
---|
624 | if( pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTRA && pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_NxN && uiDepth == pcCU->getDepth(uiAbsPartIdx) ) |
---|
625 | { |
---|
626 | uiSubdiv = 1; |
---|
627 | } |
---|
628 | else if( (pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && (pcCU->getPredictionMode(uiAbsPartIdx) == MODE_INTER) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ) && (uiDepth == pcCU->getDepth(uiAbsPartIdx)) ) |
---|
629 | { |
---|
630 | uiSubdiv = (uiLog2TrafoSize > quadtreeTULog2MinSizeInCU); |
---|
631 | } |
---|
632 | else if( uiLog2TrafoSize > pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) |
---|
633 | { |
---|
634 | uiSubdiv = 1; |
---|
635 | } |
---|
636 | else if( uiLog2TrafoSize == pcCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) |
---|
637 | { |
---|
638 | uiSubdiv = 0; |
---|
639 | } |
---|
640 | else if( uiLog2TrafoSize == quadtreeTULog2MinSizeInCU ) |
---|
641 | { |
---|
642 | uiSubdiv = 0; |
---|
643 | } |
---|
644 | else |
---|
645 | { |
---|
646 | assert( uiLog2TrafoSize > quadtreeTULog2MinSizeInCU ); |
---|
647 | m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize ); |
---|
648 | } |
---|
649 | |
---|
650 | const UInt uiTrDepth = uiDepth - pcCU->getDepth( uiAbsPartIdx ); |
---|
651 | { |
---|
652 | const Bool bFirstCbfOfCU = uiTrDepth == 0; |
---|
653 | if( bFirstCbfOfCU ) |
---|
654 | { |
---|
655 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
656 | pcCU->setCbfSubParts( 0, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
657 | } |
---|
658 | if( bFirstCbfOfCU || uiLog2TrafoSize > 2 ) |
---|
659 | { |
---|
660 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) ) |
---|
661 | { |
---|
662 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth, uiDepth ); |
---|
663 | } |
---|
664 | if( bFirstCbfOfCU || pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) ) |
---|
665 | { |
---|
666 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth, uiDepth ); |
---|
667 | } |
---|
668 | } |
---|
669 | else |
---|
670 | { |
---|
671 | pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_U, uiAbsPartIdx, uiDepth ); |
---|
672 | pcCU->setCbfSubParts( pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth - 1 ) << uiTrDepth, TEXT_CHROMA_V, uiAbsPartIdx, uiDepth ); |
---|
673 | } |
---|
674 | } |
---|
675 | |
---|
676 | if( uiSubdiv ) |
---|
677 | { |
---|
678 | UInt size; |
---|
679 | width >>= 1; |
---|
680 | height >>= 1; |
---|
681 | size = width*height; |
---|
682 | uiTrIdx++; |
---|
683 | ++uiDepth; |
---|
684 | const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
685 | const UInt uiStartAbsPartIdx = uiAbsPartIdx; |
---|
686 | UInt uiYCbf = 0; |
---|
687 | UInt uiUCbf = 0; |
---|
688 | UInt uiVCbf = 0; |
---|
689 | |
---|
690 | for( Int i = 0; i < 4; i++ ) |
---|
691 | { |
---|
692 | xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP, quadtreeTULog2MinSizeInCU ); |
---|
693 | uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth+1 ); |
---|
694 | uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth+1 ); |
---|
695 | uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth+1 ); |
---|
696 | uiAbsPartIdx += uiQPartNum; |
---|
697 | offsetLuma += size; offsetChroma += (size>>2); |
---|
698 | } |
---|
699 | |
---|
700 | for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui ) |
---|
701 | { |
---|
702 | pcCU->getCbf( TEXT_LUMA )[uiStartAbsPartIdx + ui] |= uiYCbf << uiTrDepth; |
---|
703 | pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiTrDepth; |
---|
704 | pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiTrDepth; |
---|
705 | } |
---|
706 | } |
---|
707 | else |
---|
708 | { |
---|
709 | assert( uiDepth >= pcCU->getDepth( uiAbsPartIdx ) ); |
---|
710 | pcCU->setTrIdxSubParts( uiTrDepth, uiAbsPartIdx, uiDepth ); |
---|
711 | |
---|
712 | #if !H_MV_ENC_DEC_TRAC |
---|
713 | { |
---|
714 | DTRACE_CABAC_VL( g_nSymbolCounter++ ); |
---|
715 | DTRACE_CABAC_T( "\tTrIdx: abspart=" ); |
---|
716 | DTRACE_CABAC_V( uiAbsPartIdx ); |
---|
717 | DTRACE_CABAC_T( "\tdepth=" ); |
---|
718 | DTRACE_CABAC_V( uiDepth ); |
---|
719 | DTRACE_CABAC_T( "\ttrdepth=" ); |
---|
720 | DTRACE_CABAC_V( uiTrDepth ); |
---|
721 | DTRACE_CABAC_T( "\n" ); |
---|
722 | } |
---|
723 | #endif |
---|
724 | |
---|
725 | pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
726 | if( pcCU->getPredictionMode(uiAbsPartIdx) != MODE_INTRA && uiDepth == pcCU->getDepth( uiAbsPartIdx ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, 0 ) && !pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, 0 ) ) |
---|
727 | { |
---|
728 | pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_LUMA, uiAbsPartIdx, uiDepth ); |
---|
729 | } |
---|
730 | else |
---|
731 | { |
---|
732 | m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrDepth, uiDepth ); |
---|
733 | } |
---|
734 | |
---|
735 | |
---|
736 | // transform_unit begin |
---|
737 | UInt cbfY = pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA , uiTrIdx ); |
---|
738 | UInt cbfU = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
739 | UInt cbfV = pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
740 | if( uiLog2TrafoSize == 2 ) |
---|
741 | { |
---|
742 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
743 | if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) |
---|
744 | { |
---|
745 | cbfU = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_U, uiTrIdx ); |
---|
746 | cbfV = pcCU->getCbf( m_uiBakAbsPartIdx, TEXT_CHROMA_V, uiTrIdx ); |
---|
747 | } |
---|
748 | } |
---|
749 | if ( cbfY || cbfU || cbfV ) |
---|
750 | { |
---|
751 | // dQP: only for LCU |
---|
752 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
753 | { |
---|
754 | if ( bCodeDQP ) |
---|
755 | { |
---|
756 | decodeQP( pcCU, m_bakAbsPartIdxCU); |
---|
757 | bCodeDQP = false; |
---|
758 | } |
---|
759 | } |
---|
760 | } |
---|
761 | if( cbfY ) |
---|
762 | { |
---|
763 | Int trWidth = width; |
---|
764 | Int trHeight = height; |
---|
765 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA ); |
---|
766 | } |
---|
767 | if( uiLog2TrafoSize > 2 ) |
---|
768 | { |
---|
769 | Int trWidth = width >> 1; |
---|
770 | Int trHeight = height >> 1; |
---|
771 | if( cbfU ) |
---|
772 | { |
---|
773 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
774 | } |
---|
775 | if( cbfV ) |
---|
776 | { |
---|
777 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+offsetChroma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
778 | } |
---|
779 | } |
---|
780 | else |
---|
781 | { |
---|
782 | UInt partNum = pcCU->getPic()->getNumPartInCU() >> ( ( uiDepth - 1 ) << 1 ); |
---|
783 | if( ( uiAbsPartIdx % partNum ) == (partNum - 1) ) |
---|
784 | { |
---|
785 | Int trWidth = width; |
---|
786 | Int trHeight = height; |
---|
787 | if( cbfU ) |
---|
788 | { |
---|
789 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCb()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_U ); |
---|
790 | } |
---|
791 | if( cbfV ) |
---|
792 | { |
---|
793 | m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffCr()+m_uiBakChromaOffset), m_uiBakAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_CHROMA_V ); |
---|
794 | } |
---|
795 | } |
---|
796 | } |
---|
797 | // transform_unit end |
---|
798 | } |
---|
799 | } |
---|
800 | |
---|
801 | Void TDecEntropy::decodeQP ( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
802 | { |
---|
803 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
804 | { |
---|
805 | m_pcEntropyDecoderIf->parseDeltaQP( pcCU, uiAbsPartIdx, pcCU->getDepth( uiAbsPartIdx ) ); |
---|
806 | } |
---|
807 | } |
---|
808 | |
---|
809 | |
---|
810 | /** decode coefficients |
---|
811 | * \param pcCU |
---|
812 | * \param uiAbsPartIdx |
---|
813 | * \param uiDepth |
---|
814 | * \param uiWidth |
---|
815 | * \param uiHeight |
---|
816 | * \returns Void |
---|
817 | */ |
---|
818 | Void TDecEntropy::decodeCoeff( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP ) |
---|
819 | { |
---|
820 | UInt uiMinCoeffSize = pcCU->getPic()->getMinCUWidth()*pcCU->getPic()->getMinCUHeight(); |
---|
821 | UInt uiLumaOffset = uiMinCoeffSize*uiAbsPartIdx; |
---|
822 | UInt uiChromaOffset = uiLumaOffset>>2; |
---|
823 | #if H_3D_DIM_SDC |
---|
824 | if( pcCU->getSDCFlag( uiAbsPartIdx ) && pcCU->isIntra( uiAbsPartIdx) ) |
---|
825 | { |
---|
826 | assert( pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N ); |
---|
827 | assert( pcCU->getTransformIdx(uiAbsPartIdx) == 0 ); |
---|
828 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_LUMA) == 1 ); |
---|
829 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_U) == 1 ); |
---|
830 | assert( pcCU->getCbf(uiAbsPartIdx, TEXT_CHROMA_V) == 1 ); |
---|
831 | } |
---|
832 | |
---|
833 | #if H_3D_INTER_SDC |
---|
834 | if( pcCU->getSDCFlag( uiAbsPartIdx ) && !pcCU->isIntra( uiAbsPartIdx) ) |
---|
835 | { |
---|
836 | assert( !pcCU->isSkipped( uiAbsPartIdx ) ); |
---|
837 | assert( !pcCU->isIntra( uiAbsPartIdx) ); |
---|
838 | assert( pcCU->getSlice()->getIsDepth() ); |
---|
839 | } |
---|
840 | #endif |
---|
841 | if( pcCU->getSlice()->getIsDepth() && ( pcCU->getSDCFlag( uiAbsPartIdx ) || pcCU->isIntra( uiAbsPartIdx ) ) ) |
---|
842 | { |
---|
843 | Int iPartNum = ( pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ? 4 : 1; |
---|
844 | UInt uiPartOffset = ( pcCU->getPic()->getNumPartInCU() >> ( pcCU->getDepth( uiAbsPartIdx ) << 1 ) ) >> 2; |
---|
845 | |
---|
846 | if( !pcCU->getSDCFlag( uiAbsPartIdx ) ) |
---|
847 | { |
---|
848 | for( Int iPart = 0; iPart < iPartNum; iPart++ ) |
---|
849 | { |
---|
850 | if( getDimType( pcCU->getLumaIntraDir( uiAbsPartIdx + uiPartOffset*iPart ) ) < DIM_NUM_TYPE ) |
---|
851 | { |
---|
852 | m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx + uiPartOffset*iPart, uiDepth + ( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_NxN ) ); |
---|
853 | } |
---|
854 | } |
---|
855 | } |
---|
856 | else |
---|
857 | { |
---|
858 | m_pcEntropyDecoderIf->parseDeltaDC( pcCU, uiAbsPartIdx, uiDepth ); |
---|
859 | return; |
---|
860 | } |
---|
861 | } |
---|
862 | #endif |
---|
863 | |
---|
864 | if( pcCU->isIntra(uiAbsPartIdx) ) |
---|
865 | { |
---|
866 | } |
---|
867 | else |
---|
868 | { |
---|
869 | UInt uiQtRootCbf = 1; |
---|
870 | if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) ) |
---|
871 | { |
---|
872 | m_pcEntropyDecoderIf->parseQtRootCbf( uiAbsPartIdx, uiQtRootCbf ); |
---|
873 | } |
---|
874 | if ( !uiQtRootCbf ) |
---|
875 | { |
---|
876 | pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth ); |
---|
877 | pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth ); |
---|
878 | return; |
---|
879 | } |
---|
880 | |
---|
881 | } |
---|
882 | |
---|
883 | Int getQuadtreeTULog2MinSizeInCU = pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx); |
---|
884 | |
---|
885 | xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP, getQuadtreeTULog2MinSizeInCU ); |
---|
886 | } |
---|
887 | |
---|
888 | #if H_3D_INTER_SDC |
---|
889 | Void TDecEntropy::decodeSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
890 | { |
---|
891 | pcCU->setSDCFlagSubParts( false, uiAbsPartIdx, uiDepth ); |
---|
892 | |
---|
893 | if( ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) ) || |
---|
894 | ( pcCU->isIntra( uiAbsPartIdx ) && !pcCU->getSlice()->getVPS()->getVpsDepthModesFlag( pcCU->getSlice()->getLayerIdInVps() ) ) ) |
---|
895 | { |
---|
896 | return; |
---|
897 | } |
---|
898 | |
---|
899 | if( !pcCU->getSlice()->getIsDepth() || pcCU->getPartitionSize( uiAbsPartIdx ) != SIZE_2Nx2N || pcCU->isSkipped( uiAbsPartIdx ) ) |
---|
900 | { |
---|
901 | return; |
---|
902 | } |
---|
903 | |
---|
904 | assert( pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N || ( !pcCU->isIntra( uiAbsPartIdx ) && !pcCU->isSkipped( uiAbsPartIdx ) ) ); |
---|
905 | m_pcEntropyDecoderIf->parseSDCFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
906 | } |
---|
907 | #endif |
---|
908 | #if H_3D_DBBP |
---|
909 | Void TDecEntropy::decodeDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
910 | { |
---|
911 | m_pcEntropyDecoderIf->parseDBBPFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
912 | } |
---|
913 | #endif |
---|
914 | |
---|
915 | //! \} |
---|