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