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