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