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