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