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 | #if NO_RESIDUAL_FLAG_FOR_BLPRED |
---|
475 | xReconIntraBL( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
476 | #else |
---|
477 | xReconIntraQT( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
478 | #endif |
---|
479 | break; |
---|
480 | #endif |
---|
481 | default: |
---|
482 | assert(0); |
---|
483 | break; |
---|
484 | } |
---|
485 | if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false)) |
---|
486 | { |
---|
487 | xFillPCMBuffer(m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth); |
---|
488 | } |
---|
489 | |
---|
490 | xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth ); |
---|
491 | } |
---|
492 | |
---|
493 | Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
494 | { |
---|
495 | |
---|
496 | // inter prediction |
---|
497 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
498 | |
---|
499 | // inter recon |
---|
500 | xDecodeInterTexture( pcCU, 0, uiDepth ); |
---|
501 | |
---|
502 | // clip for only non-zero cbp case |
---|
503 | if ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) ) |
---|
504 | { |
---|
505 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
506 | } |
---|
507 | else |
---|
508 | { |
---|
509 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
510 | } |
---|
511 | } |
---|
512 | |
---|
513 | Void |
---|
514 | TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU, |
---|
515 | UInt uiTrDepth, |
---|
516 | UInt uiAbsPartIdx, |
---|
517 | TComYuv* pcRecoYuv, |
---|
518 | TComYuv* pcPredYuv, |
---|
519 | TComYuv* pcResiYuv ) |
---|
520 | { |
---|
521 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> uiTrDepth; |
---|
522 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> uiTrDepth; |
---|
523 | UInt uiStride = pcRecoYuv->getStride (); |
---|
524 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
525 | Pel* piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
526 | Pel* piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
527 | |
---|
528 | UInt uiNumCoeffInc = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ); |
---|
529 | TCoeff* pcCoeff = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
530 | |
---|
531 | UInt uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
532 | |
---|
533 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
534 | Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
535 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
536 | Bool useTransformSkip = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA); |
---|
537 | //===== init availability pattern ===== |
---|
538 | Bool bAboveAvail = false; |
---|
539 | Bool bLeftAvail = false; |
---|
540 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
541 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
542 | m_pcPrediction->getPredicBuf (), |
---|
543 | m_pcPrediction->getPredicBufWidth (), |
---|
544 | m_pcPrediction->getPredicBufHeight (), |
---|
545 | bAboveAvail, bLeftAvail ); |
---|
546 | |
---|
547 | //===== get prediction signal ===== |
---|
548 | #if INTRA_BL |
---|
549 | if(pcCU->isIntraBL ( uiAbsPartIdx ) ) |
---|
550 | { |
---|
551 | pcCU->getBaseLumaBlk( uiWidth, uiHeight, uiAbsPartIdx, piPred, uiStride ); |
---|
552 | } |
---|
553 | else |
---|
554 | #endif |
---|
555 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); |
---|
556 | |
---|
557 | //===== inverse transform ===== |
---|
558 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
559 | |
---|
560 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA]; |
---|
561 | assert(scalingListType < 6); |
---|
562 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip ); |
---|
563 | |
---|
564 | |
---|
565 | //===== reconstruction ===== |
---|
566 | Pel* pPred = piPred; |
---|
567 | Pel* pResi = piResi; |
---|
568 | Pel* pReco = piReco; |
---|
569 | Pel* pRecIPred = piRecIPred; |
---|
570 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
571 | { |
---|
572 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
573 | { |
---|
574 | pReco [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] ); |
---|
575 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
576 | } |
---|
577 | pPred += uiStride; |
---|
578 | pResi += uiStride; |
---|
579 | pReco += uiStride; |
---|
580 | pRecIPred += uiRecIPredStride; |
---|
581 | } |
---|
582 | } |
---|
583 | |
---|
584 | |
---|
585 | Void |
---|
586 | TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU, |
---|
587 | UInt uiTrDepth, |
---|
588 | UInt uiAbsPartIdx, |
---|
589 | TComYuv* pcRecoYuv, |
---|
590 | TComYuv* pcPredYuv, |
---|
591 | TComYuv* pcResiYuv, |
---|
592 | UInt uiChromaId ) |
---|
593 | { |
---|
594 | UInt uiFullDepth = pcCU->getDepth( 0 ) + uiTrDepth; |
---|
595 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2; |
---|
596 | |
---|
597 | if( uiLog2TrSize == 2 ) |
---|
598 | { |
---|
599 | assert( uiTrDepth > 0 ); |
---|
600 | uiTrDepth--; |
---|
601 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 ); |
---|
602 | Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 ); |
---|
603 | if( !bFirstQ ) |
---|
604 | { |
---|
605 | return; |
---|
606 | } |
---|
607 | } |
---|
608 | |
---|
609 | TextType eText = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U ); |
---|
610 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> ( uiTrDepth + 1 ); |
---|
611 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> ( uiTrDepth + 1 ); |
---|
612 | UInt uiStride = pcRecoYuv->getCStride (); |
---|
613 | Pel* piReco = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
614 | Pel* piPred = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
615 | Pel* piResi = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
616 | |
---|
617 | UInt uiNumCoeffInc = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2; |
---|
618 | TCoeff* pcCoeff = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
619 | |
---|
620 | UInt uiChromaPredMode = pcCU->getChromaIntraDir( 0 ); |
---|
621 | |
---|
622 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
623 | Pel* piRecIPred = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) ); |
---|
624 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
625 | Bool useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText); |
---|
626 | //===== init availability pattern ===== |
---|
627 | Bool bAboveAvail = false; |
---|
628 | Bool bLeftAvail = false; |
---|
629 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
630 | |
---|
631 | #if !REMOVE_LMCHROMA |
---|
632 | if( uiChromaPredMode == LM_CHROMA_IDX && uiChromaId == 0 ) |
---|
633 | { |
---|
634 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
635 | m_pcPrediction->getPredicBuf (), |
---|
636 | m_pcPrediction->getPredicBufWidth (), |
---|
637 | m_pcPrediction->getPredicBufHeight (), |
---|
638 | bAboveAvail, bLeftAvail, |
---|
639 | true ); |
---|
640 | |
---|
641 | m_pcPrediction->getLumaRecPixels( pcCU->getPattern(), uiWidth, uiHeight ); |
---|
642 | } |
---|
643 | #endif |
---|
644 | |
---|
645 | pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
646 | m_pcPrediction->getPredicBuf (), |
---|
647 | m_pcPrediction->getPredicBufWidth (), |
---|
648 | m_pcPrediction->getPredicBufHeight (), |
---|
649 | bAboveAvail, bLeftAvail ); |
---|
650 | Int* pPatChroma = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) ); |
---|
651 | |
---|
652 | //===== get prediction signal ===== |
---|
653 | #if INTRA_BL |
---|
654 | if(pcCU->isIntraBL ( uiAbsPartIdx ) ) |
---|
655 | { |
---|
656 | pcCU->getBaseChromaBlk( uiWidth, uiHeight, uiAbsPartIdx, piPred, uiStride, uiChromaId ); |
---|
657 | } |
---|
658 | else |
---|
659 | #endif |
---|
660 | #if !REMOVE_LMCHROMA |
---|
661 | if( uiChromaPredMode == LM_CHROMA_IDX ) |
---|
662 | { |
---|
663 | m_pcPrediction->predLMIntraChroma( pcCU->getPattern(), pPatChroma, piPred, uiStride, uiWidth, uiHeight, uiChromaId ); |
---|
664 | } |
---|
665 | else |
---|
666 | #endif |
---|
667 | { |
---|
668 | if( uiChromaPredMode == DM_CHROMA_IDX ) |
---|
669 | { |
---|
670 | uiChromaPredMode = pcCU->getLumaIntraDir( 0 ); |
---|
671 | } |
---|
672 | m_pcPrediction->predIntraChromaAng( pcCU->getPattern(), pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); |
---|
673 | } |
---|
674 | |
---|
675 | //===== inverse transform ===== |
---|
676 | #if CHROMA_QP_EXTENSION |
---|
677 | Int curChromaQpOffset; |
---|
678 | if(eText == TEXT_CHROMA_U) |
---|
679 | { |
---|
680 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
---|
681 | } |
---|
682 | else |
---|
683 | { |
---|
684 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
---|
685 | } |
---|
686 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
687 | #else |
---|
688 | if(eText == TEXT_CHROMA_U) |
---|
689 | { |
---|
690 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaCbQpOffset() ); |
---|
691 | } |
---|
692 | else |
---|
693 | { |
---|
694 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaCrQpOffset() ); |
---|
695 | } |
---|
696 | #endif |
---|
697 | |
---|
698 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText]; |
---|
699 | assert(scalingListType < 6); |
---|
700 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma ); |
---|
701 | |
---|
702 | //===== reconstruction ===== |
---|
703 | Pel* pPred = piPred; |
---|
704 | Pel* pResi = piResi; |
---|
705 | Pel* pReco = piReco; |
---|
706 | Pel* pRecIPred = piRecIPred; |
---|
707 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
708 | { |
---|
709 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
710 | { |
---|
711 | pReco [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] ); |
---|
712 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
713 | } |
---|
714 | pPred += uiStride; |
---|
715 | pResi += uiStride; |
---|
716 | pReco += uiStride; |
---|
717 | pRecIPred += uiRecIPredStride; |
---|
718 | } |
---|
719 | } |
---|
720 | |
---|
721 | |
---|
722 | Void |
---|
723 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
724 | { |
---|
725 | UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 ); |
---|
726 | UInt uiNumPart = pcCU->getNumPartInter(); |
---|
727 | UInt uiNumQParts = pcCU->getTotalNumPart() >> 2; |
---|
728 | |
---|
729 | if (pcCU->getIPCMFlag(0)) |
---|
730 | { |
---|
731 | xReconPCM( pcCU, uiAbsPartIdx, uiDepth ); |
---|
732 | return; |
---|
733 | } |
---|
734 | |
---|
735 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
736 | { |
---|
737 | xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
738 | } |
---|
739 | |
---|
740 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
741 | { |
---|
742 | xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
743 | } |
---|
744 | |
---|
745 | } |
---|
746 | |
---|
747 | #if NO_RESIDUAL_FLAG_FOR_BLPRED |
---|
748 | Void |
---|
749 | TDecCu::xReconIntraBL( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
750 | { |
---|
751 | m_ppcYuvReco[uiDepth]->copyFromPicLuma ( pcCU->getSlice()->getFullPelBaseRec(), pcCU->getAddr(), pcCU->getZorderIdxInCU(), 0, pcCU->getWidth(0), pcCU->getHeight(0)); |
---|
752 | m_ppcYuvReco[uiDepth]->copyFromPicChroma( pcCU->getSlice()->getFullPelBaseRec(), pcCU->getAddr(), pcCU->getZorderIdxInCU(), 0, (pcCU->getWidth(0)>>1), (pcCU->getHeight(0)>>1), 0); |
---|
753 | m_ppcYuvReco[uiDepth]->copyFromPicChroma( pcCU->getSlice()->getFullPelBaseRec(), pcCU->getAddr(), pcCU->getZorderIdxInCU(), 0, (pcCU->getWidth(0)>>1), (pcCU->getHeight(0)>>1), 1); |
---|
754 | |
---|
755 | // inter recon |
---|
756 | xDecodeInterTexture( pcCU, 0, uiDepth ); |
---|
757 | |
---|
758 | // clip for only non-zero cbp case |
---|
759 | if ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) ) |
---|
760 | { |
---|
761 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
762 | } |
---|
763 | else |
---|
764 | { |
---|
765 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
766 | } |
---|
767 | } |
---|
768 | #endif |
---|
769 | |
---|
770 | /** Function for deriving recontructed PU/CU Luma sample with QTree structure |
---|
771 | * \param pcCU pointer of current CU |
---|
772 | * \param uiTrDepth current tranform split depth |
---|
773 | * \param uiAbsPartIdx part index |
---|
774 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
775 | * \param pcPredYuv pointer to prediction sample arrays |
---|
776 | * \param pcResiYuv pointer to residue sample arrays |
---|
777 | * |
---|
778 | \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure |
---|
779 | */ |
---|
780 | Void |
---|
781 | TDecCu::xIntraLumaRecQT( TComDataCU* pcCU, |
---|
782 | UInt uiTrDepth, |
---|
783 | UInt uiAbsPartIdx, |
---|
784 | TComYuv* pcRecoYuv, |
---|
785 | TComYuv* pcPredYuv, |
---|
786 | TComYuv* pcResiYuv ) |
---|
787 | { |
---|
788 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
789 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
790 | if( uiTrMode == uiTrDepth ) |
---|
791 | { |
---|
792 | xIntraRecLumaBlk ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
793 | } |
---|
794 | else |
---|
795 | { |
---|
796 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
797 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
798 | { |
---|
799 | xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
800 | } |
---|
801 | } |
---|
802 | } |
---|
803 | |
---|
804 | /** Function for deriving recontructed PU/CU chroma samples with QTree structure |
---|
805 | * \param pcCU pointer of current CU |
---|
806 | * \param uiTrDepth current tranform split depth |
---|
807 | * \param uiAbsPartIdx part index |
---|
808 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
809 | * \param pcPredYuv pointer to prediction sample arrays |
---|
810 | * \param pcResiYuv pointer to residue sample arrays |
---|
811 | * |
---|
812 | \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure |
---|
813 | */ |
---|
814 | Void |
---|
815 | TDecCu::xIntraChromaRecQT( TComDataCU* pcCU, |
---|
816 | UInt uiTrDepth, |
---|
817 | UInt uiAbsPartIdx, |
---|
818 | TComYuv* pcRecoYuv, |
---|
819 | TComYuv* pcPredYuv, |
---|
820 | TComYuv* pcResiYuv ) |
---|
821 | { |
---|
822 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
823 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
824 | if( uiTrMode == uiTrDepth ) |
---|
825 | { |
---|
826 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 ); |
---|
827 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 ); |
---|
828 | } |
---|
829 | else |
---|
830 | { |
---|
831 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
832 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
833 | { |
---|
834 | xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
835 | } |
---|
836 | } |
---|
837 | } |
---|
838 | |
---|
839 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
840 | { |
---|
841 | UInt uiCUAddr = pcCU->getAddr(); |
---|
842 | |
---|
843 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx ); |
---|
844 | |
---|
845 | return; |
---|
846 | } |
---|
847 | |
---|
848 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
849 | { |
---|
850 | UInt uiWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
851 | UInt uiHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
852 | TCoeff* piCoeff; |
---|
853 | |
---|
854 | Pel* pResi; |
---|
855 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
856 | |
---|
857 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode ); |
---|
858 | |
---|
859 | // Y |
---|
860 | piCoeff = pcCU->getCoeffY(); |
---|
861 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr(); |
---|
862 | |
---|
863 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
864 | |
---|
865 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, uiLumaTrMode, 0, piCoeff ); |
---|
866 | |
---|
867 | // Cb and Cr |
---|
868 | #if CHROMA_QP_EXTENSION |
---|
869 | Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
---|
870 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
871 | #else |
---|
872 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaCbQpOffset() ); |
---|
873 | #endif |
---|
874 | |
---|
875 | uiWidth >>= 1; |
---|
876 | uiHeight >>= 1; |
---|
877 | piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr(); |
---|
878 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff ); |
---|
879 | |
---|
880 | #if CHROMA_QP_EXTENSION |
---|
881 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
---|
882 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
883 | #else |
---|
884 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaCrQpOffset() ); |
---|
885 | #endif |
---|
886 | |
---|
887 | piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr(); |
---|
888 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff ); |
---|
889 | } |
---|
890 | |
---|
891 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
---|
892 | * \param pcCU pointer to current CU |
---|
893 | * \param uiPartIdx part index |
---|
894 | * \param piPCM pointer to PCM code arrays |
---|
895 | * \param piReco pointer to reconstructed sample arrays |
---|
896 | * \param uiStride stride of reconstructed sample arrays |
---|
897 | * \param uiWidth CU width |
---|
898 | * \param uiHeight CU height |
---|
899 | * \param ttText texture component type |
---|
900 | * \returns Void |
---|
901 | */ |
---|
902 | Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText) |
---|
903 | { |
---|
904 | UInt uiX, uiY; |
---|
905 | Pel* piPicReco; |
---|
906 | UInt uiPicStride; |
---|
907 | UInt uiPcmLeftShiftBit; |
---|
908 | |
---|
909 | if( ttText == TEXT_LUMA ) |
---|
910 | { |
---|
911 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(); |
---|
912 | piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
913 | uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
914 | } |
---|
915 | else |
---|
916 | { |
---|
917 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
918 | |
---|
919 | if( ttText == TEXT_CHROMA_U ) |
---|
920 | { |
---|
921 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
922 | } |
---|
923 | else |
---|
924 | { |
---|
925 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
926 | } |
---|
927 | uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
928 | } |
---|
929 | |
---|
930 | for( uiY = 0; uiY < uiHeight; uiY++ ) |
---|
931 | { |
---|
932 | for( uiX = 0; uiX < uiWidth; uiX++ ) |
---|
933 | { |
---|
934 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
---|
935 | piPicReco[uiX] = piReco[uiX]; |
---|
936 | } |
---|
937 | piPCM += uiWidth; |
---|
938 | piReco += uiStride; |
---|
939 | piPicReco += uiPicStride; |
---|
940 | } |
---|
941 | } |
---|
942 | |
---|
943 | /** Function for reconstructing a PCM mode CU. |
---|
944 | * \param pcCU pointer to current CU |
---|
945 | * \param uiAbsPartIdx CU index |
---|
946 | * \param uiDepth CU Depth |
---|
947 | * \returns Void |
---|
948 | */ |
---|
949 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
950 | { |
---|
951 | // Luma |
---|
952 | UInt uiWidth = (g_uiMaxCUWidth >> uiDepth); |
---|
953 | UInt uiHeight = (g_uiMaxCUHeight >> uiDepth); |
---|
954 | |
---|
955 | Pel* piPcmY = pcCU->getPCMSampleY(); |
---|
956 | Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth); |
---|
957 | |
---|
958 | UInt uiStride = m_ppcYuvResi[uiDepth]->getStride(); |
---|
959 | |
---|
960 | xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA); |
---|
961 | |
---|
962 | // Cb and Cr |
---|
963 | UInt uiCWidth = (uiWidth>>1); |
---|
964 | UInt uiCHeight = (uiHeight>>1); |
---|
965 | |
---|
966 | Pel* piPcmCb = pcCU->getPCMSampleCb(); |
---|
967 | Pel* piPcmCr = pcCU->getPCMSampleCr(); |
---|
968 | Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
---|
969 | Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
---|
970 | |
---|
971 | UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride(); |
---|
972 | |
---|
973 | xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U); |
---|
974 | xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V); |
---|
975 | } |
---|
976 | |
---|
977 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
---|
978 | * \param pcCU pointer to current CU |
---|
979 | * \param uiAbsPartIdx CU index |
---|
980 | * \param uiDepth CU Depth |
---|
981 | * \returns Void |
---|
982 | */ |
---|
983 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt absPartIdx, UInt depth) |
---|
984 | { |
---|
985 | // Luma |
---|
986 | UInt width = (g_uiMaxCUWidth >> depth); |
---|
987 | UInt height = (g_uiMaxCUHeight >> depth); |
---|
988 | |
---|
989 | Pel* pPcmY = pCU->getPCMSampleY(); |
---|
990 | Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width); |
---|
991 | |
---|
992 | UInt stride = m_ppcYuvReco[depth]->getStride(); |
---|
993 | |
---|
994 | for(Int y = 0; y < height; y++ ) |
---|
995 | { |
---|
996 | for(Int x = 0; x < width; x++ ) |
---|
997 | { |
---|
998 | pPcmY[x] = pRecoY[x]; |
---|
999 | } |
---|
1000 | pPcmY += width; |
---|
1001 | pRecoY += stride; |
---|
1002 | } |
---|
1003 | |
---|
1004 | // Cb and Cr |
---|
1005 | UInt widthC = (width>>1); |
---|
1006 | UInt heightC = (height>>1); |
---|
1007 | |
---|
1008 | Pel* pPcmCb = pCU->getPCMSampleCb(); |
---|
1009 | Pel* pPcmCr = pCU->getPCMSampleCr(); |
---|
1010 | Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr(); |
---|
1011 | Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr(); |
---|
1012 | |
---|
1013 | UInt strideC = m_ppcYuvReco[depth]->getCStride(); |
---|
1014 | |
---|
1015 | for(Int y = 0; y < heightC; y++ ) |
---|
1016 | { |
---|
1017 | for(Int x = 0; x < widthC; x++ ) |
---|
1018 | { |
---|
1019 | pPcmCb[x] = pRecoCb[x]; |
---|
1020 | pPcmCr[x] = pRecoCr[x]; |
---|
1021 | } |
---|
1022 | pPcmCr += widthC; |
---|
1023 | pPcmCb += widthC; |
---|
1024 | pRecoCb += strideC; |
---|
1025 | pRecoCr += strideC; |
---|
1026 | } |
---|
1027 | |
---|
1028 | } |
---|
1029 | |
---|
1030 | //! \} |
---|