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 TDecCu.cpp |
---|
35 | \brief CU decoder class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "TDecCu.h" |
---|
39 | #if SVC_EXTENSION |
---|
40 | #include "TDecTop.h" |
---|
41 | #endif |
---|
42 | |
---|
43 | |
---|
44 | //! \ingroup TLibDecoder |
---|
45 | //! \{ |
---|
46 | |
---|
47 | // ==================================================================================================================== |
---|
48 | // Constructor / destructor / create / destroy |
---|
49 | // ==================================================================================================================== |
---|
50 | |
---|
51 | TDecCu::TDecCu() |
---|
52 | { |
---|
53 | m_ppcYuvResi = NULL; |
---|
54 | m_ppcYuvReco = NULL; |
---|
55 | m_ppcCU = NULL; |
---|
56 | } |
---|
57 | |
---|
58 | TDecCu::~TDecCu() |
---|
59 | { |
---|
60 | } |
---|
61 | |
---|
62 | #if SVC_EXTENSION |
---|
63 | Void TDecCu::init(TDecTop** ppcDecTop, TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction, UInt layerId) |
---|
64 | #else |
---|
65 | Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction) |
---|
66 | #endif |
---|
67 | { |
---|
68 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
69 | m_pcTrQuant = pcTrQuant; |
---|
70 | m_pcPrediction = pcPrediction; |
---|
71 | #if SVC_EXTENSION |
---|
72 | m_ppcTDecTop = ppcDecTop; |
---|
73 | m_layerId = layerId; |
---|
74 | |
---|
75 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
76 | { |
---|
77 | m_ppcCU [ui]->setLayerId(layerId); |
---|
78 | } |
---|
79 | #endif |
---|
80 | } |
---|
81 | |
---|
82 | /** |
---|
83 | \param uiMaxDepth total number of allowable depth |
---|
84 | \param uiMaxWidth largest CU width |
---|
85 | \param uiMaxHeight largest CU height |
---|
86 | */ |
---|
87 | Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight ) |
---|
88 | { |
---|
89 | m_uiMaxDepth = uiMaxDepth+1; |
---|
90 | |
---|
91 | m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1]; |
---|
92 | m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1]; |
---|
93 | m_ppcCU = new TComDataCU*[m_uiMaxDepth-1]; |
---|
94 | |
---|
95 | UInt uiNumPartitions; |
---|
96 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
97 | { |
---|
98 | uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 ); |
---|
99 | UInt uiWidth = uiMaxWidth >> ui; |
---|
100 | UInt uiHeight = uiMaxHeight >> ui; |
---|
101 | |
---|
102 | m_ppcYuvResi[ui] = new TComYuv; m_ppcYuvResi[ui]->create( uiWidth, uiHeight ); |
---|
103 | m_ppcYuvReco[ui] = new TComYuv; m_ppcYuvReco[ui]->create( uiWidth, uiHeight ); |
---|
104 | m_ppcCU [ui] = new TComDataCU; m_ppcCU [ui]->create( uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) ); |
---|
105 | } |
---|
106 | |
---|
107 | m_bDecodeDQP = false; |
---|
108 | |
---|
109 | // initialize partition order. |
---|
110 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
111 | initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp); |
---|
112 | initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
113 | |
---|
114 | // initialize conversion matrix from partition index to pel |
---|
115 | initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
116 | initMotionReferIdx ( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
117 | } |
---|
118 | |
---|
119 | Void TDecCu::destroy() |
---|
120 | { |
---|
121 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
122 | { |
---|
123 | m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL; |
---|
124 | m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL; |
---|
125 | m_ppcCU [ui]->destroy(); delete m_ppcCU [ui]; m_ppcCU [ui] = NULL; |
---|
126 | } |
---|
127 | |
---|
128 | delete [] m_ppcYuvResi; m_ppcYuvResi = NULL; |
---|
129 | delete [] m_ppcYuvReco; m_ppcYuvReco = NULL; |
---|
130 | delete [] m_ppcCU ; m_ppcCU = NULL; |
---|
131 | } |
---|
132 | |
---|
133 | // ==================================================================================================================== |
---|
134 | // Public member functions |
---|
135 | // ==================================================================================================================== |
---|
136 | |
---|
137 | /** \param pcCU pointer of CU data |
---|
138 | \param ruiIsLast last data? |
---|
139 | */ |
---|
140 | Void TDecCu::decodeCU( TComDataCU* pcCU, UInt& ruiIsLast ) |
---|
141 | { |
---|
142 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
143 | { |
---|
144 | setdQPFlag(true); |
---|
145 | } |
---|
146 | |
---|
147 | pcCU->setNumSucIPCM(0); |
---|
148 | |
---|
149 | // start from the top level CU |
---|
150 | #if SVC_EXTENSION |
---|
151 | pcCU->setLayerId(m_layerId); |
---|
152 | #endif |
---|
153 | xDecodeCU( pcCU, 0, 0, ruiIsLast); |
---|
154 | } |
---|
155 | |
---|
156 | /** \param pcCU pointer of CU data |
---|
157 | */ |
---|
158 | Void TDecCu::decompressCU( TComDataCU* pcCU ) |
---|
159 | { |
---|
160 | xDecompressCU( pcCU, pcCU, 0, 0 ); |
---|
161 | } |
---|
162 | |
---|
163 | // ==================================================================================================================== |
---|
164 | // Protected member functions |
---|
165 | // ==================================================================================================================== |
---|
166 | |
---|
167 | /**decode end-of-slice flag |
---|
168 | * \param pcCU |
---|
169 | * \param uiAbsPartIdx |
---|
170 | * \param uiDepth |
---|
171 | * \returns Bool |
---|
172 | */ |
---|
173 | Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth) |
---|
174 | { |
---|
175 | UInt uiIsLast; |
---|
176 | TComPic* pcPic = pcCU->getPic(); |
---|
177 | TComSlice * pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
178 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
179 | UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); |
---|
180 | UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); |
---|
181 | #if REMOVE_FGS |
---|
182 | UInt uiGranularityWidth = g_uiMaxCUWidth; |
---|
183 | #else |
---|
184 | UInt uiGranularityWidth = g_uiMaxCUWidth>>(pcSlice->getPPS()->getSliceGranularity()); |
---|
185 | #endif |
---|
186 | UInt uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
187 | UInt uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
188 | |
---|
189 | if(((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth)) |
---|
190 | &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight))) |
---|
191 | { |
---|
192 | m_pcEntropyDecoder->decodeTerminatingBit( uiIsLast ); |
---|
193 | } |
---|
194 | else |
---|
195 | { |
---|
196 | uiIsLast=0; |
---|
197 | } |
---|
198 | |
---|
199 | if(uiIsLast) |
---|
200 | { |
---|
201 | if(pcSlice->isNextDependentSlice()&&!pcSlice->isNextSlice()) |
---|
202 | { |
---|
203 | pcSlice->setDependentSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
204 | } |
---|
205 | else |
---|
206 | { |
---|
207 | pcSlice->setSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
208 | pcSlice->setDependentSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
209 | } |
---|
210 | } |
---|
211 | |
---|
212 | return uiIsLast>0; |
---|
213 | } |
---|
214 | |
---|
215 | /** decode CU block recursively |
---|
216 | * \param pcCU |
---|
217 | * \param uiAbsPartIdx |
---|
218 | * \param uiDepth |
---|
219 | * \returns Void |
---|
220 | */ |
---|
221 | |
---|
222 | Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast) |
---|
223 | { |
---|
224 | TComPic* pcPic = pcCU->getPic(); |
---|
225 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
226 | UInt uiQNumParts = uiCurNumParts>>2; |
---|
227 | |
---|
228 | Bool bBoundary = false; |
---|
229 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
230 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
231 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
232 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
233 | |
---|
234 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
235 | Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getDependentSliceCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getDependentSliceCurStartCUAddr(); |
---|
236 | if((!bStartInCU) && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
237 | { |
---|
238 | if(pcCU->getNumSucIPCM() == 0) |
---|
239 | { |
---|
240 | m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
241 | } |
---|
242 | else |
---|
243 | { |
---|
244 | pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx ); |
---|
245 | } |
---|
246 | } |
---|
247 | else |
---|
248 | { |
---|
249 | bBoundary = true; |
---|
250 | } |
---|
251 | |
---|
252 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
253 | { |
---|
254 | UInt uiIdx = uiAbsPartIdx; |
---|
255 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
256 | { |
---|
257 | setdQPFlag(true); |
---|
258 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
259 | } |
---|
260 | |
---|
261 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
262 | { |
---|
263 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
264 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
265 | |
---|
266 | Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getDependentSliceCurStartCUAddr(); |
---|
267 | if ( bSubInSlice ) |
---|
268 | { |
---|
269 | if ( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
270 | { |
---|
271 | xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast ); |
---|
272 | } |
---|
273 | else |
---|
274 | { |
---|
275 | pcCU->setOutsideCUPart( uiIdx, uiDepth+1 ); |
---|
276 | } |
---|
277 | } |
---|
278 | if(ruiIsLast) |
---|
279 | { |
---|
280 | break; |
---|
281 | } |
---|
282 | |
---|
283 | uiIdx += uiQNumParts; |
---|
284 | } |
---|
285 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
286 | { |
---|
287 | if ( getdQPFlag() ) |
---|
288 | { |
---|
289 | UInt uiQPSrcPartIdx; |
---|
290 | if ( pcPic->getCU( pcCU->getAddr() )->getDependentSliceStartCU(uiAbsPartIdx) != pcSlice->getDependentSliceCurStartCUAddr() ) |
---|
291 | { |
---|
292 | uiQPSrcPartIdx = pcSlice->getDependentSliceCurStartCUAddr() % pcPic->getNumPartInCU(); |
---|
293 | } |
---|
294 | else |
---|
295 | { |
---|
296 | uiQPSrcPartIdx = uiAbsPartIdx; |
---|
297 | } |
---|
298 | pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
299 | } |
---|
300 | } |
---|
301 | return; |
---|
302 | } |
---|
303 | |
---|
304 | if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
305 | { |
---|
306 | setdQPFlag(true); |
---|
307 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
308 | } |
---|
309 | |
---|
310 | if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag() && pcCU->getNumSucIPCM() == 0 ) |
---|
311 | { |
---|
312 | m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
313 | } |
---|
314 | |
---|
315 | // decode CU mode and the partition size |
---|
316 | if( !pcCU->getSlice()->isIntra() && pcCU->getNumSucIPCM() == 0 ) |
---|
317 | { |
---|
318 | m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
319 | } |
---|
320 | |
---|
321 | if( pcCU->isSkipped(uiAbsPartIdx) ) |
---|
322 | { |
---|
323 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
324 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
325 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
326 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
327 | Int numValidMergeCand = 0; |
---|
328 | for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
329 | { |
---|
330 | uhInterDirNeighbours[ui] = 0; |
---|
331 | } |
---|
332 | m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, SIZE_2Nx2N, uhInterDirNeighbours, cMvFieldNeighbours, uiDepth ); |
---|
333 | UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx); |
---|
334 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
335 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
336 | |
---|
337 | TComMv cTmpMv( 0, 0 ); |
---|
338 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
339 | { |
---|
340 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
341 | { |
---|
342 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
343 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
344 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
345 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
346 | } |
---|
347 | } |
---|
348 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
349 | return; |
---|
350 | } |
---|
351 | #if INTRA_BL |
---|
352 | m_pcEntropyDecoder->decodeIntraBLFlag( pcCU, uiAbsPartIdx, 0, uiDepth ); |
---|
353 | if ( pcCU->isIntraBL( uiAbsPartIdx ) ) |
---|
354 | { |
---|
355 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
356 | } |
---|
357 | else |
---|
358 | { |
---|
359 | #endif |
---|
360 | |
---|
361 | if( pcCU->getNumSucIPCM() == 0 ) |
---|
362 | { |
---|
363 | m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
364 | m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
365 | } |
---|
366 | else |
---|
367 | { |
---|
368 | pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth ); |
---|
369 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
370 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
371 | pcCU->setTrIdxSubParts( 0, uiAbsPartIdx, uiDepth ); |
---|
372 | } |
---|
373 | |
---|
374 | if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
---|
375 | { |
---|
376 | m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
377 | |
---|
378 | if(pcCU->getIPCMFlag(uiAbsPartIdx)) |
---|
379 | { |
---|
380 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
381 | return; |
---|
382 | } |
---|
383 | } |
---|
384 | #if INTRA_BL |
---|
385 | // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
386 | m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); |
---|
387 | } |
---|
388 | #endif |
---|
389 | |
---|
390 | UInt uiCurrWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
391 | UInt uiCurrHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
392 | |
---|
393 | #if !INTRA_BL |
---|
394 | // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
395 | m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); |
---|
396 | #endif |
---|
397 | |
---|
398 | // Coefficient decoding |
---|
399 | Bool bCodeDQP = getdQPFlag(); |
---|
400 | m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP ); |
---|
401 | setdQPFlag( bCodeDQP ); |
---|
402 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
403 | } |
---|
404 | |
---|
405 | Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast) |
---|
406 | { |
---|
407 | if( pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
408 | { |
---|
409 | pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP |
---|
410 | } |
---|
411 | if( pcCU->getNumSucIPCM() > 0 ) |
---|
412 | { |
---|
413 | ruiIsLast = 0; |
---|
414 | return; |
---|
415 | } |
---|
416 | |
---|
417 | ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth); |
---|
418 | } |
---|
419 | |
---|
420 | Void TDecCu::xDecompressCU( TComDataCU* pcCU, TComDataCU* pcCUCur, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
421 | { |
---|
422 | TComPic* pcPic = pcCU->getPic(); |
---|
423 | |
---|
424 | Bool bBoundary = false; |
---|
425 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
426 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
427 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
428 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
429 | |
---|
430 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
431 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
432 | Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getDependentSliceCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getDependentSliceCurStartCUAddr(); |
---|
433 | if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
434 | { |
---|
435 | bBoundary = true; |
---|
436 | } |
---|
437 | |
---|
438 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
439 | { |
---|
440 | UInt uiNextDepth = uiDepth + 1; |
---|
441 | UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1); |
---|
442 | UInt uiIdx = uiAbsPartIdx; |
---|
443 | for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ ) |
---|
444 | { |
---|
445 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
446 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
447 | |
---|
448 | Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getDependentSliceCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getDependentSliceCurEndCUAddr()); |
---|
449 | if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
450 | { |
---|
451 | xDecompressCU(pcCU, m_ppcCU[uiNextDepth], uiIdx, uiNextDepth ); |
---|
452 | } |
---|
453 | |
---|
454 | uiIdx += uiQNumParts; |
---|
455 | } |
---|
456 | return; |
---|
457 | } |
---|
458 | |
---|
459 | // Residual reconstruction |
---|
460 | m_ppcYuvResi[uiDepth]->clear(); |
---|
461 | |
---|
462 | m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth ); |
---|
463 | |
---|
464 | switch( m_ppcCU[uiDepth]->getPredictionMode(0) ) |
---|
465 | { |
---|
466 | case MODE_INTER: |
---|
467 | xReconInter( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
468 | break; |
---|
469 | case MODE_INTRA: |
---|
470 | xReconIntraQT( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
471 | break; |
---|
472 | #if INTRA_BL |
---|
473 | case MODE_INTRA_BL: |
---|
474 | xReconIntraQT( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
475 | break; |
---|
476 | #endif |
---|
477 | default: |
---|
478 | assert(0); |
---|
479 | break; |
---|
480 | } |
---|
481 | if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false)) |
---|
482 | { |
---|
483 | xFillPCMBuffer(m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth); |
---|
484 | } |
---|
485 | |
---|
486 | xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth ); |
---|
487 | } |
---|
488 | |
---|
489 | Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
490 | { |
---|
491 | |
---|
492 | // inter prediction |
---|
493 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
494 | |
---|
495 | // inter recon |
---|
496 | xDecodeInterTexture( pcCU, 0, uiDepth ); |
---|
497 | |
---|
498 | // clip for only non-zero cbp case |
---|
499 | if ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) ) |
---|
500 | { |
---|
501 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
502 | } |
---|
503 | else |
---|
504 | { |
---|
505 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
506 | } |
---|
507 | } |
---|
508 | |
---|
509 | Void |
---|
510 | TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU, |
---|
511 | UInt uiTrDepth, |
---|
512 | UInt uiAbsPartIdx, |
---|
513 | TComYuv* pcRecoYuv, |
---|
514 | TComYuv* pcPredYuv, |
---|
515 | TComYuv* pcResiYuv ) |
---|
516 | { |
---|
517 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> uiTrDepth; |
---|
518 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> uiTrDepth; |
---|
519 | UInt uiStride = pcRecoYuv->getStride (); |
---|
520 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
521 | Pel* piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
522 | Pel* piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
523 | |
---|
524 | UInt uiNumCoeffInc = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ); |
---|
525 | TCoeff* pcCoeff = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
526 | |
---|
527 | UInt uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
528 | |
---|
529 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
530 | Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
531 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
532 | Bool useTransformSkip = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA); |
---|
533 | //===== init availability pattern ===== |
---|
534 | Bool bAboveAvail = false; |
---|
535 | Bool bLeftAvail = false; |
---|
536 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
537 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
538 | m_pcPrediction->getPredicBuf (), |
---|
539 | m_pcPrediction->getPredicBufWidth (), |
---|
540 | m_pcPrediction->getPredicBufHeight (), |
---|
541 | bAboveAvail, bLeftAvail ); |
---|
542 | |
---|
543 | //===== get prediction signal ===== |
---|
544 | #if INTRA_BL |
---|
545 | if(pcCU->isIntraBL ( uiAbsPartIdx ) ) |
---|
546 | { |
---|
547 | pcCU->getBaseLumaBlk( uiWidth, uiHeight, uiAbsPartIdx, piPred, uiStride ); |
---|
548 | } |
---|
549 | else |
---|
550 | #endif |
---|
551 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); |
---|
552 | |
---|
553 | //===== inverse transform ===== |
---|
554 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
555 | |
---|
556 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA]; |
---|
557 | assert(scalingListType < 6); |
---|
558 | #if INTRA_BL_DCT_FIX |
---|
559 | if(pcCU->isIntraBL(uiAbsPartIdx)) |
---|
560 | { |
---|
561 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip ); |
---|
562 | } |
---|
563 | else |
---|
564 | { |
---|
565 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip ); |
---|
566 | } |
---|
567 | #else |
---|
568 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip ); |
---|
569 | #endif |
---|
570 | |
---|
571 | |
---|
572 | //===== reconstruction ===== |
---|
573 | Pel* pPred = piPred; |
---|
574 | Pel* pResi = piResi; |
---|
575 | Pel* pReco = piReco; |
---|
576 | Pel* pRecIPred = piRecIPred; |
---|
577 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
578 | { |
---|
579 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
580 | { |
---|
581 | pReco [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] ); |
---|
582 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
583 | } |
---|
584 | pPred += uiStride; |
---|
585 | pResi += uiStride; |
---|
586 | pReco += uiStride; |
---|
587 | pRecIPred += uiRecIPredStride; |
---|
588 | } |
---|
589 | } |
---|
590 | |
---|
591 | |
---|
592 | Void |
---|
593 | TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU, |
---|
594 | UInt uiTrDepth, |
---|
595 | UInt uiAbsPartIdx, |
---|
596 | TComYuv* pcRecoYuv, |
---|
597 | TComYuv* pcPredYuv, |
---|
598 | TComYuv* pcResiYuv, |
---|
599 | UInt uiChromaId ) |
---|
600 | { |
---|
601 | UInt uiFullDepth = pcCU->getDepth( 0 ) + uiTrDepth; |
---|
602 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2; |
---|
603 | |
---|
604 | if( uiLog2TrSize == 2 ) |
---|
605 | { |
---|
606 | assert( uiTrDepth > 0 ); |
---|
607 | uiTrDepth--; |
---|
608 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 ); |
---|
609 | Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 ); |
---|
610 | if( !bFirstQ ) |
---|
611 | { |
---|
612 | return; |
---|
613 | } |
---|
614 | } |
---|
615 | |
---|
616 | TextType eText = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U ); |
---|
617 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> ( uiTrDepth + 1 ); |
---|
618 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> ( uiTrDepth + 1 ); |
---|
619 | UInt uiStride = pcRecoYuv->getCStride (); |
---|
620 | Pel* piReco = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
621 | Pel* piPred = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
622 | Pel* piResi = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
623 | |
---|
624 | UInt uiNumCoeffInc = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2; |
---|
625 | TCoeff* pcCoeff = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
626 | |
---|
627 | UInt uiChromaPredMode = pcCU->getChromaIntraDir( 0 ); |
---|
628 | |
---|
629 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
630 | Pel* piRecIPred = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) ); |
---|
631 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
632 | Bool useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText); |
---|
633 | //===== init availability pattern ===== |
---|
634 | Bool bAboveAvail = false; |
---|
635 | Bool bLeftAvail = false; |
---|
636 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
637 | |
---|
638 | #if !REMOVE_LMCHROMA |
---|
639 | if( uiChromaPredMode == LM_CHROMA_IDX && uiChromaId == 0 ) |
---|
640 | { |
---|
641 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
642 | m_pcPrediction->getPredicBuf (), |
---|
643 | m_pcPrediction->getPredicBufWidth (), |
---|
644 | m_pcPrediction->getPredicBufHeight (), |
---|
645 | bAboveAvail, bLeftAvail, |
---|
646 | true ); |
---|
647 | |
---|
648 | m_pcPrediction->getLumaRecPixels( pcCU->getPattern(), uiWidth, uiHeight ); |
---|
649 | } |
---|
650 | #endif |
---|
651 | |
---|
652 | pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
653 | m_pcPrediction->getPredicBuf (), |
---|
654 | m_pcPrediction->getPredicBufWidth (), |
---|
655 | m_pcPrediction->getPredicBufHeight (), |
---|
656 | bAboveAvail, bLeftAvail ); |
---|
657 | Int* pPatChroma = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) ); |
---|
658 | |
---|
659 | //===== get prediction signal ===== |
---|
660 | #if INTRA_BL |
---|
661 | if(pcCU->isIntraBL ( uiAbsPartIdx ) ) |
---|
662 | { |
---|
663 | pcCU->getBaseChromaBlk( uiWidth, uiHeight, uiAbsPartIdx, piPred, uiStride, uiChromaId ); |
---|
664 | } |
---|
665 | else |
---|
666 | #endif |
---|
667 | #if !REMOVE_LMCHROMA |
---|
668 | if( uiChromaPredMode == LM_CHROMA_IDX ) |
---|
669 | { |
---|
670 | m_pcPrediction->predLMIntraChroma( pcCU->getPattern(), pPatChroma, piPred, uiStride, uiWidth, uiHeight, uiChromaId ); |
---|
671 | } |
---|
672 | else |
---|
673 | #endif |
---|
674 | { |
---|
675 | if( uiChromaPredMode == DM_CHROMA_IDX ) |
---|
676 | { |
---|
677 | uiChromaPredMode = pcCU->getLumaIntraDir( 0 ); |
---|
678 | } |
---|
679 | m_pcPrediction->predIntraChromaAng( pcCU->getPattern(), pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); |
---|
680 | } |
---|
681 | |
---|
682 | //===== inverse transform ===== |
---|
683 | #if CHROMA_QP_EXTENSION |
---|
684 | Int curChromaQpOffset; |
---|
685 | if(eText == TEXT_CHROMA_U) |
---|
686 | { |
---|
687 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
---|
688 | } |
---|
689 | else |
---|
690 | { |
---|
691 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
---|
692 | } |
---|
693 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
694 | #else |
---|
695 | if(eText == TEXT_CHROMA_U) |
---|
696 | { |
---|
697 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaCbQpOffset() ); |
---|
698 | } |
---|
699 | else |
---|
700 | { |
---|
701 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaCrQpOffset() ); |
---|
702 | } |
---|
703 | #endif |
---|
704 | |
---|
705 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText]; |
---|
706 | assert(scalingListType < 6); |
---|
707 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma ); |
---|
708 | |
---|
709 | //===== reconstruction ===== |
---|
710 | Pel* pPred = piPred; |
---|
711 | Pel* pResi = piResi; |
---|
712 | Pel* pReco = piReco; |
---|
713 | Pel* pRecIPred = piRecIPred; |
---|
714 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
715 | { |
---|
716 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
717 | { |
---|
718 | pReco [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] ); |
---|
719 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
720 | } |
---|
721 | pPred += uiStride; |
---|
722 | pResi += uiStride; |
---|
723 | pReco += uiStride; |
---|
724 | pRecIPred += uiRecIPredStride; |
---|
725 | } |
---|
726 | } |
---|
727 | |
---|
728 | |
---|
729 | Void |
---|
730 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
731 | { |
---|
732 | UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 ); |
---|
733 | UInt uiNumPart = pcCU->getNumPartInter(); |
---|
734 | UInt uiNumQParts = pcCU->getTotalNumPart() >> 2; |
---|
735 | |
---|
736 | if (pcCU->getIPCMFlag(0)) |
---|
737 | { |
---|
738 | xReconPCM( pcCU, uiAbsPartIdx, uiDepth ); |
---|
739 | return; |
---|
740 | } |
---|
741 | |
---|
742 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
743 | { |
---|
744 | xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
745 | } |
---|
746 | |
---|
747 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
748 | { |
---|
749 | xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
750 | } |
---|
751 | |
---|
752 | } |
---|
753 | |
---|
754 | |
---|
755 | /** Function for deriving recontructed PU/CU Luma sample with QTree structure |
---|
756 | * \param pcCU pointer of current CU |
---|
757 | * \param uiTrDepth current tranform split depth |
---|
758 | * \param uiAbsPartIdx part index |
---|
759 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
760 | * \param pcPredYuv pointer to prediction sample arrays |
---|
761 | * \param pcResiYuv pointer to residue sample arrays |
---|
762 | * |
---|
763 | \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure |
---|
764 | */ |
---|
765 | Void |
---|
766 | TDecCu::xIntraLumaRecQT( TComDataCU* pcCU, |
---|
767 | UInt uiTrDepth, |
---|
768 | UInt uiAbsPartIdx, |
---|
769 | TComYuv* pcRecoYuv, |
---|
770 | TComYuv* pcPredYuv, |
---|
771 | TComYuv* pcResiYuv ) |
---|
772 | { |
---|
773 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
774 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
775 | if( uiTrMode == uiTrDepth ) |
---|
776 | { |
---|
777 | xIntraRecLumaBlk ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
778 | } |
---|
779 | else |
---|
780 | { |
---|
781 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
782 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
783 | { |
---|
784 | xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
785 | } |
---|
786 | } |
---|
787 | } |
---|
788 | |
---|
789 | /** Function for deriving recontructed PU/CU chroma samples with QTree structure |
---|
790 | * \param pcCU pointer of current CU |
---|
791 | * \param uiTrDepth current tranform split depth |
---|
792 | * \param uiAbsPartIdx part index |
---|
793 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
794 | * \param pcPredYuv pointer to prediction sample arrays |
---|
795 | * \param pcResiYuv pointer to residue sample arrays |
---|
796 | * |
---|
797 | \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure |
---|
798 | */ |
---|
799 | Void |
---|
800 | TDecCu::xIntraChromaRecQT( TComDataCU* pcCU, |
---|
801 | UInt uiTrDepth, |
---|
802 | UInt uiAbsPartIdx, |
---|
803 | TComYuv* pcRecoYuv, |
---|
804 | TComYuv* pcPredYuv, |
---|
805 | TComYuv* pcResiYuv ) |
---|
806 | { |
---|
807 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
808 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
809 | if( uiTrMode == uiTrDepth ) |
---|
810 | { |
---|
811 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 ); |
---|
812 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 ); |
---|
813 | } |
---|
814 | else |
---|
815 | { |
---|
816 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
817 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
818 | { |
---|
819 | xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
820 | } |
---|
821 | } |
---|
822 | } |
---|
823 | |
---|
824 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
825 | { |
---|
826 | UInt uiCUAddr = pcCU->getAddr(); |
---|
827 | |
---|
828 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx ); |
---|
829 | |
---|
830 | return; |
---|
831 | } |
---|
832 | |
---|
833 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
834 | { |
---|
835 | UInt uiWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
836 | UInt uiHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
837 | TCoeff* piCoeff; |
---|
838 | |
---|
839 | Pel* pResi; |
---|
840 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
841 | |
---|
842 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode ); |
---|
843 | |
---|
844 | // Y |
---|
845 | piCoeff = pcCU->getCoeffY(); |
---|
846 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr(); |
---|
847 | |
---|
848 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
849 | |
---|
850 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, uiLumaTrMode, 0, piCoeff ); |
---|
851 | |
---|
852 | // Cb and Cr |
---|
853 | #if CHROMA_QP_EXTENSION |
---|
854 | Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
---|
855 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
856 | #else |
---|
857 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaCbQpOffset() ); |
---|
858 | #endif |
---|
859 | |
---|
860 | uiWidth >>= 1; |
---|
861 | uiHeight >>= 1; |
---|
862 | piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr(); |
---|
863 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff ); |
---|
864 | |
---|
865 | #if CHROMA_QP_EXTENSION |
---|
866 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
---|
867 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
868 | #else |
---|
869 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaCrQpOffset() ); |
---|
870 | #endif |
---|
871 | |
---|
872 | piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr(); |
---|
873 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff ); |
---|
874 | } |
---|
875 | |
---|
876 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
---|
877 | * \param pcCU pointer to current CU |
---|
878 | * \param uiPartIdx part index |
---|
879 | * \param piPCM pointer to PCM code arrays |
---|
880 | * \param piReco pointer to reconstructed sample arrays |
---|
881 | * \param uiStride stride of reconstructed sample arrays |
---|
882 | * \param uiWidth CU width |
---|
883 | * \param uiHeight CU height |
---|
884 | * \param ttText texture component type |
---|
885 | * \returns Void |
---|
886 | */ |
---|
887 | Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText) |
---|
888 | { |
---|
889 | UInt uiX, uiY; |
---|
890 | Pel* piPicReco; |
---|
891 | UInt uiPicStride; |
---|
892 | UInt uiPcmLeftShiftBit; |
---|
893 | |
---|
894 | if( ttText == TEXT_LUMA ) |
---|
895 | { |
---|
896 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(); |
---|
897 | piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
898 | uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
899 | } |
---|
900 | else |
---|
901 | { |
---|
902 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
903 | |
---|
904 | if( ttText == TEXT_CHROMA_U ) |
---|
905 | { |
---|
906 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
907 | } |
---|
908 | else |
---|
909 | { |
---|
910 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
911 | } |
---|
912 | uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
913 | } |
---|
914 | |
---|
915 | for( uiY = 0; uiY < uiHeight; uiY++ ) |
---|
916 | { |
---|
917 | for( uiX = 0; uiX < uiWidth; uiX++ ) |
---|
918 | { |
---|
919 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
---|
920 | piPicReco[uiX] = piReco[uiX]; |
---|
921 | } |
---|
922 | piPCM += uiWidth; |
---|
923 | piReco += uiStride; |
---|
924 | piPicReco += uiPicStride; |
---|
925 | } |
---|
926 | } |
---|
927 | |
---|
928 | /** Function for reconstructing a PCM mode CU. |
---|
929 | * \param pcCU pointer to current CU |
---|
930 | * \param uiAbsPartIdx CU index |
---|
931 | * \param uiDepth CU Depth |
---|
932 | * \returns Void |
---|
933 | */ |
---|
934 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
935 | { |
---|
936 | // Luma |
---|
937 | UInt uiWidth = (g_uiMaxCUWidth >> uiDepth); |
---|
938 | UInt uiHeight = (g_uiMaxCUHeight >> uiDepth); |
---|
939 | |
---|
940 | Pel* piPcmY = pcCU->getPCMSampleY(); |
---|
941 | Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth); |
---|
942 | |
---|
943 | UInt uiStride = m_ppcYuvResi[uiDepth]->getStride(); |
---|
944 | |
---|
945 | xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA); |
---|
946 | |
---|
947 | // Cb and Cr |
---|
948 | UInt uiCWidth = (uiWidth>>1); |
---|
949 | UInt uiCHeight = (uiHeight>>1); |
---|
950 | |
---|
951 | Pel* piPcmCb = pcCU->getPCMSampleCb(); |
---|
952 | Pel* piPcmCr = pcCU->getPCMSampleCr(); |
---|
953 | Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
---|
954 | Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
---|
955 | |
---|
956 | UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride(); |
---|
957 | |
---|
958 | xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U); |
---|
959 | xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V); |
---|
960 | } |
---|
961 | |
---|
962 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
---|
963 | * \param pcCU pointer to current CU |
---|
964 | * \param uiAbsPartIdx CU index |
---|
965 | * \param uiDepth CU Depth |
---|
966 | * \returns Void |
---|
967 | */ |
---|
968 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt absPartIdx, UInt depth) |
---|
969 | { |
---|
970 | // Luma |
---|
971 | UInt width = (g_uiMaxCUWidth >> depth); |
---|
972 | UInt height = (g_uiMaxCUHeight >> depth); |
---|
973 | |
---|
974 | Pel* pPcmY = pCU->getPCMSampleY(); |
---|
975 | Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width); |
---|
976 | |
---|
977 | UInt stride = m_ppcYuvReco[depth]->getStride(); |
---|
978 | |
---|
979 | for(Int y = 0; y < height; y++ ) |
---|
980 | { |
---|
981 | for(Int x = 0; x < width; x++ ) |
---|
982 | { |
---|
983 | pPcmY[x] = pRecoY[x]; |
---|
984 | } |
---|
985 | pPcmY += width; |
---|
986 | pRecoY += stride; |
---|
987 | } |
---|
988 | |
---|
989 | // Cb and Cr |
---|
990 | UInt widthC = (width>>1); |
---|
991 | UInt heightC = (height>>1); |
---|
992 | |
---|
993 | Pel* pPcmCb = pCU->getPCMSampleCb(); |
---|
994 | Pel* pPcmCr = pCU->getPCMSampleCr(); |
---|
995 | Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr(); |
---|
996 | Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr(); |
---|
997 | |
---|
998 | UInt strideC = m_ppcYuvReco[depth]->getCStride(); |
---|
999 | |
---|
1000 | for(Int y = 0; y < heightC; y++ ) |
---|
1001 | { |
---|
1002 | for(Int x = 0; x < widthC; x++ ) |
---|
1003 | { |
---|
1004 | pPcmCb[x] = pRecoCb[x]; |
---|
1005 | pPcmCr[x] = pRecoCr[x]; |
---|
1006 | } |
---|
1007 | pPcmCr += widthC; |
---|
1008 | pPcmCb += widthC; |
---|
1009 | pRecoCb += strideC; |
---|
1010 | pRecoCr += strideC; |
---|
1011 | } |
---|
1012 | |
---|
1013 | } |
---|
1014 | |
---|
1015 | //! \} |
---|