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-2015, 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 | #include "TLibCommon/TComTU.h" |
---|
40 | #include "TLibCommon/TComPrediction.h" |
---|
41 | #if SVC_EXTENSION |
---|
42 | #include "TDecTop.h" |
---|
43 | #endif |
---|
44 | |
---|
45 | |
---|
46 | //! \ingroup TLibDecoder |
---|
47 | //! \{ |
---|
48 | |
---|
49 | // ==================================================================================================================== |
---|
50 | // Constructor / destructor / create / destroy |
---|
51 | // ==================================================================================================================== |
---|
52 | |
---|
53 | TDecCu::TDecCu() |
---|
54 | { |
---|
55 | m_ppcYuvResi = NULL; |
---|
56 | m_ppcYuvReco = NULL; |
---|
57 | m_ppcCU = NULL; |
---|
58 | } |
---|
59 | |
---|
60 | TDecCu::~TDecCu() |
---|
61 | { |
---|
62 | } |
---|
63 | |
---|
64 | #if SVC_EXTENSION |
---|
65 | Void TDecCu::init(TDecTop** ppcDecTop, TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction, UInt layerId) |
---|
66 | { |
---|
67 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
68 | m_pcTrQuant = pcTrQuant; |
---|
69 | m_pcPrediction = pcPrediction; |
---|
70 | m_ppcTDecTop = ppcDecTop; |
---|
71 | m_layerId = layerId; |
---|
72 | |
---|
73 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
74 | { |
---|
75 | m_ppcCU [ui]->setLayerId(layerId); |
---|
76 | } |
---|
77 | |
---|
78 | #if LAYER_CTB |
---|
79 | memcpy(g_auiLayerZscanToRaster[m_layerId], g_auiZscanToRaster, sizeof( g_auiZscanToRaster ) ); |
---|
80 | memcpy(g_auiLayerRasterToZscan[m_layerId], g_auiRasterToZscan, sizeof( g_auiRasterToZscan ) ); |
---|
81 | memcpy(g_auiLayerRasterToPelX[m_layerId], g_auiRasterToPelX, sizeof( g_auiRasterToPelX ) ); |
---|
82 | memcpy(g_auiLayerRasterToPelY[m_layerId], g_auiRasterToPelY, sizeof( g_auiRasterToPelY ) ); |
---|
83 | #endif |
---|
84 | } |
---|
85 | #else |
---|
86 | Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction) |
---|
87 | { |
---|
88 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
89 | m_pcTrQuant = pcTrQuant; |
---|
90 | m_pcPrediction = pcPrediction; |
---|
91 | } |
---|
92 | #endif |
---|
93 | |
---|
94 | /** |
---|
95 | \param uiMaxDepth total number of allowable depth |
---|
96 | \param uiMaxWidth largest CU width |
---|
97 | \param uiMaxHeight largest CU height |
---|
98 | \param chromaFormatIDC chroma format |
---|
99 | */ |
---|
100 | Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight, ChromaFormat chromaFormatIDC ) |
---|
101 | { |
---|
102 | m_uiMaxDepth = uiMaxDepth+1; |
---|
103 | |
---|
104 | m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1]; |
---|
105 | m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1]; |
---|
106 | m_ppcCU = new TComDataCU*[m_uiMaxDepth-1]; |
---|
107 | |
---|
108 | UInt uiNumPartitions; |
---|
109 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
110 | { |
---|
111 | uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 ); |
---|
112 | UInt uiWidth = uiMaxWidth >> ui; |
---|
113 | UInt uiHeight = uiMaxHeight >> ui; |
---|
114 | |
---|
115 | m_ppcYuvResi[ui] = new TComYuv; m_ppcYuvResi[ui]->create( uiWidth, uiHeight, chromaFormatIDC ); |
---|
116 | m_ppcYuvReco[ui] = new TComYuv; m_ppcYuvReco[ui]->create( uiWidth, uiHeight, chromaFormatIDC ); |
---|
117 | m_ppcCU [ui] = new TComDataCU; m_ppcCU [ui]->create( chromaFormatIDC, uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) ); |
---|
118 | } |
---|
119 | |
---|
120 | m_bDecodeDQP = false; |
---|
121 | m_IsChromaQpAdjCoded = false; |
---|
122 | |
---|
123 | // initialize partition order. |
---|
124 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
125 | initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp); |
---|
126 | initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
127 | |
---|
128 | // initialize conversion matrix from partition index to pel |
---|
129 | initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
130 | } |
---|
131 | |
---|
132 | Void TDecCu::destroy() |
---|
133 | { |
---|
134 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
135 | { |
---|
136 | m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL; |
---|
137 | m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL; |
---|
138 | m_ppcCU [ui]->destroy(); delete m_ppcCU [ui]; m_ppcCU [ui] = NULL; |
---|
139 | } |
---|
140 | |
---|
141 | delete [] m_ppcYuvResi; m_ppcYuvResi = NULL; |
---|
142 | delete [] m_ppcYuvReco; m_ppcYuvReco = NULL; |
---|
143 | delete [] m_ppcCU ; m_ppcCU = NULL; |
---|
144 | } |
---|
145 | |
---|
146 | // ==================================================================================================================== |
---|
147 | // Public member functions |
---|
148 | // ==================================================================================================================== |
---|
149 | |
---|
150 | /** |
---|
151 | Parse a CTU. |
---|
152 | \param pCtu [in/out] pointer to CTU data structure |
---|
153 | \param isLastCtuOfSliceSegment [out] true, if last CTU of the slice segment |
---|
154 | */ |
---|
155 | Void TDecCu::decodeCtu( TComDataCU* pCtu, Bool& isLastCtuOfSliceSegment ) |
---|
156 | { |
---|
157 | if ( pCtu->getSlice()->getPPS()->getUseDQP() ) |
---|
158 | { |
---|
159 | setdQPFlag(true); |
---|
160 | } |
---|
161 | |
---|
162 | if ( pCtu->getSlice()->getUseChromaQpAdj() ) |
---|
163 | { |
---|
164 | setIsChromaQpAdjCoded(true); |
---|
165 | } |
---|
166 | |
---|
167 | #if SVC_EXTENSION |
---|
168 | pCtu->setLayerId(m_layerId); |
---|
169 | #endif |
---|
170 | |
---|
171 | // start from the top level CU |
---|
172 | xDecodeCU( pCtu, 0, 0, isLastCtuOfSliceSegment); |
---|
173 | } |
---|
174 | |
---|
175 | /** |
---|
176 | Decoding process for a CTU. |
---|
177 | \param pCtu [in/out] pointer to CTU data structure |
---|
178 | */ |
---|
179 | Void TDecCu::decompressCtu( TComDataCU* pCtu ) |
---|
180 | { |
---|
181 | xDecompressCU( pCtu, 0, 0 ); |
---|
182 | } |
---|
183 | |
---|
184 | // ==================================================================================================================== |
---|
185 | // Protected member functions |
---|
186 | // ==================================================================================================================== |
---|
187 | |
---|
188 | //! decode end-of-slice flag |
---|
189 | Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
190 | { |
---|
191 | UInt uiIsLastCtuOfSliceSegment; |
---|
192 | |
---|
193 | if (pcCU->isLastSubCUOfCtu(uiAbsPartIdx)) |
---|
194 | { |
---|
195 | m_pcEntropyDecoder->decodeTerminatingBit( uiIsLastCtuOfSliceSegment ); |
---|
196 | } |
---|
197 | else |
---|
198 | { |
---|
199 | uiIsLastCtuOfSliceSegment=0; |
---|
200 | } |
---|
201 | |
---|
202 | return uiIsLastCtuOfSliceSegment>0; |
---|
203 | } |
---|
204 | |
---|
205 | //! decode CU block recursively |
---|
206 | Void TDecCu::xDecodeCU( TComDataCU*const pcCU, const UInt uiAbsPartIdx, const UInt uiDepth, Bool &isLastCtuOfSliceSegment) |
---|
207 | { |
---|
208 | TComPic* pcPic = pcCU->getPic(); |
---|
209 | const TComSPS &sps = pcPic->getPicSym()->getSPS(); |
---|
210 | const TComPPS &pps = pcPic->getPicSym()->getPPS(); |
---|
211 | const UInt maxCuWidth = sps.getMaxCUWidth(); |
---|
212 | const UInt maxCuHeight= sps.getMaxCUHeight(); |
---|
213 | UInt uiCurNumParts = pcPic->getNumPartitionsInCtu() >> (uiDepth<<1); |
---|
214 | UInt uiQNumParts = uiCurNumParts>>2; |
---|
215 | |
---|
216 | |
---|
217 | Bool bBoundary = false; |
---|
218 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
219 | UInt uiRPelX = uiLPelX + (maxCuWidth>>uiDepth) - 1; |
---|
220 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
221 | UInt uiBPelY = uiTPelY + (maxCuHeight>>uiDepth) - 1; |
---|
222 | |
---|
223 | #if SVC_EXTENSION |
---|
224 | TComSlice * pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
225 | |
---|
226 | if( ( uiRPelX < pcSlice->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getPicHeightInLumaSamples() ) ) |
---|
227 | #else |
---|
228 | if( ( uiRPelX < sps.getPicWidthInLumaSamples() ) && ( uiBPelY < sps.getPicHeightInLumaSamples() ) ) |
---|
229 | #endif |
---|
230 | { |
---|
231 | m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
232 | } |
---|
233 | else |
---|
234 | { |
---|
235 | bBoundary = true; |
---|
236 | } |
---|
237 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) ) || bBoundary ) |
---|
238 | { |
---|
239 | UInt uiIdx = uiAbsPartIdx; |
---|
240 | if( uiDepth == pps.getMaxCuDQPDepth() && pps.getUseDQP()) |
---|
241 | { |
---|
242 | setdQPFlag(true); |
---|
243 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
244 | } |
---|
245 | |
---|
246 | if( uiDepth == pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcCU->getSlice()->getUseChromaQpAdj() ) |
---|
247 | { |
---|
248 | setIsChromaQpAdjCoded(true); |
---|
249 | } |
---|
250 | |
---|
251 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
252 | { |
---|
253 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
254 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
255 | |
---|
256 | #if SVC_EXTENSION |
---|
257 | if ( !isLastCtuOfSliceSegment && ( uiLPelX < pcCU->getSlice()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getPicHeightInLumaSamples() ) ) |
---|
258 | #else |
---|
259 | if ( !isLastCtuOfSliceSegment && ( uiLPelX < sps.getPicWidthInLumaSamples() ) && ( uiTPelY < sps.getPicHeightInLumaSamples() ) ) |
---|
260 | #endif |
---|
261 | { |
---|
262 | xDecodeCU( pcCU, uiIdx, uiDepth+1, isLastCtuOfSliceSegment ); |
---|
263 | } |
---|
264 | else |
---|
265 | { |
---|
266 | pcCU->setOutsideCUPart( uiIdx, uiDepth+1 ); |
---|
267 | } |
---|
268 | |
---|
269 | uiIdx += uiQNumParts; |
---|
270 | } |
---|
271 | if( uiDepth == pps.getMaxCuDQPDepth() && pps.getUseDQP()) |
---|
272 | { |
---|
273 | if ( getdQPFlag() ) |
---|
274 | { |
---|
275 | UInt uiQPSrcPartIdx = uiAbsPartIdx; |
---|
276 | pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
277 | } |
---|
278 | } |
---|
279 | return; |
---|
280 | } |
---|
281 | |
---|
282 | if( uiDepth <= pps.getMaxCuDQPDepth() && pps.getUseDQP()) |
---|
283 | { |
---|
284 | setdQPFlag(true); |
---|
285 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
286 | } |
---|
287 | |
---|
288 | if( uiDepth <= pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcCU->getSlice()->getUseChromaQpAdj() ) |
---|
289 | { |
---|
290 | setIsChromaQpAdjCoded(true); |
---|
291 | } |
---|
292 | |
---|
293 | if (pps.getTransquantBypassEnableFlag()) |
---|
294 | { |
---|
295 | m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
296 | } |
---|
297 | |
---|
298 | // decode CU mode and the partition size |
---|
299 | if( !pcCU->getSlice()->isIntra()) |
---|
300 | { |
---|
301 | m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
302 | } |
---|
303 | |
---|
304 | #if SVC_EXTENSION |
---|
305 | // Check CU skip for higher layer IRAP skip flag |
---|
306 | if( pcCU->getSlice()->getVPS()->getHigherLayerIrapSkipFlag() && pcCU->getSlice()->getVPS()->getSingleLayerForNonIrapFlag() && pcCU->getLayerId() > 0 ) |
---|
307 | { |
---|
308 | Bool lowerLayerExist = false; |
---|
309 | for(int i=0;i<pcCU->getLayerId();i++) |
---|
310 | { |
---|
311 | if(pcCU->getSlice()->getBaseColPic(pcCU->getSlice()->getInterLayerPredLayerIdc(i))) |
---|
312 | { |
---|
313 | lowerLayerExist = true; |
---|
314 | } |
---|
315 | } |
---|
316 | |
---|
317 | if( lowerLayerExist && !pcCU->isSkipped(uiAbsPartIdx) ) |
---|
318 | { |
---|
319 | printf( "Warning: CU is not skipped with enabled higher layer IRAP skip flag\n" ); |
---|
320 | } |
---|
321 | } |
---|
322 | #endif |
---|
323 | |
---|
324 | if( pcCU->isSkipped(uiAbsPartIdx) ) |
---|
325 | { |
---|
326 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
327 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
328 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
329 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
330 | Int numValidMergeCand = 0; |
---|
331 | for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
332 | { |
---|
333 | uhInterDirNeighbours[ui] = 0; |
---|
334 | } |
---|
335 | m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth ); |
---|
336 | UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx); |
---|
337 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
338 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
339 | |
---|
340 | TComMv cTmpMv( 0, 0 ); |
---|
341 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
342 | { |
---|
343 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
344 | { |
---|
345 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
346 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
347 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
348 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
349 | } |
---|
350 | } |
---|
351 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
---|
352 | return; |
---|
353 | } |
---|
354 | |
---|
355 | m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
356 | m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
357 | |
---|
358 | if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
---|
359 | { |
---|
360 | m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
361 | |
---|
362 | if(pcCU->getIPCMFlag(uiAbsPartIdx)) |
---|
363 | { |
---|
364 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
---|
365 | return; |
---|
366 | } |
---|
367 | } |
---|
368 | |
---|
369 | // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
370 | m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); |
---|
371 | |
---|
372 | // Coefficient decoding |
---|
373 | Bool bCodeDQP = getdQPFlag(); |
---|
374 | Bool isChromaQpAdjCoded = getIsChromaQpAdjCoded(); |
---|
375 | m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, bCodeDQP, isChromaQpAdjCoded ); |
---|
376 | setIsChromaQpAdjCoded( isChromaQpAdjCoded ); |
---|
377 | setdQPFlag( bCodeDQP ); |
---|
378 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
---|
379 | } |
---|
380 | |
---|
381 | Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &isLastCtuOfSliceSegment) |
---|
382 | { |
---|
383 | if( pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
384 | { |
---|
385 | pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP |
---|
386 | } |
---|
387 | |
---|
388 | if (pcCU->getSlice()->getUseChromaQpAdj() && !getIsChromaQpAdjCoded()) |
---|
389 | { |
---|
390 | pcCU->setChromaQpAdjSubParts( pcCU->getCodedChromaQpAdj(), uiAbsPartIdx, uiDepth ); // set QP |
---|
391 | } |
---|
392 | |
---|
393 | isLastCtuOfSliceSegment = xDecodeSliceEnd( pcCU, uiAbsPartIdx ); |
---|
394 | } |
---|
395 | |
---|
396 | Void TDecCu::xDecompressCU( TComDataCU* pCtu, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
397 | { |
---|
398 | TComPic* pcPic = pCtu->getPic(); |
---|
399 | TComSlice * pcSlice = pCtu->getSlice(); |
---|
400 | const TComSPS &sps=*(pcSlice->getSPS()); |
---|
401 | |
---|
402 | Bool bBoundary = false; |
---|
403 | UInt uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
404 | UInt uiRPelX = uiLPelX + (sps.getMaxCUWidth()>>uiDepth) - 1; |
---|
405 | UInt uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
406 | UInt uiBPelY = uiTPelY + (sps.getMaxCUHeight()>>uiDepth) - 1; |
---|
407 | |
---|
408 | #if SVC_EXTENSION |
---|
409 | if( ( uiRPelX >= pcSlice->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getPicHeightInLumaSamples() ) ) |
---|
410 | #else |
---|
411 | if( ( uiRPelX >= sps.getPicWidthInLumaSamples() ) || ( uiBPelY >= sps.getPicHeightInLumaSamples() ) ) |
---|
412 | #endif |
---|
413 | { |
---|
414 | bBoundary = true; |
---|
415 | } |
---|
416 | |
---|
417 | if( ( ( uiDepth < pCtu->getDepth( uiAbsPartIdx ) ) && ( uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) ) || bBoundary ) |
---|
418 | { |
---|
419 | UInt uiNextDepth = uiDepth + 1; |
---|
420 | UInt uiQNumParts = pCtu->getTotalNumPart() >> (uiNextDepth<<1); |
---|
421 | UInt uiIdx = uiAbsPartIdx; |
---|
422 | for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ ) |
---|
423 | { |
---|
424 | uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
425 | uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
426 | |
---|
427 | #if SVC_EXTENSION |
---|
428 | if( ( uiLPelX < pcSlice->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getPicHeightInLumaSamples() ) ) |
---|
429 | #else |
---|
430 | if( ( uiLPelX < sps.getPicWidthInLumaSamples() ) && ( uiTPelY < sps.getPicHeightInLumaSamples() ) ) |
---|
431 | #endif |
---|
432 | { |
---|
433 | xDecompressCU(pCtu, uiIdx, uiNextDepth ); |
---|
434 | } |
---|
435 | |
---|
436 | uiIdx += uiQNumParts; |
---|
437 | } |
---|
438 | return; |
---|
439 | } |
---|
440 | |
---|
441 | // Residual reconstruction |
---|
442 | m_ppcYuvResi[uiDepth]->clear(); |
---|
443 | |
---|
444 | m_ppcCU[uiDepth]->copySubCU( pCtu, uiAbsPartIdx ); |
---|
445 | |
---|
446 | switch( m_ppcCU[uiDepth]->getPredictionMode(0) ) |
---|
447 | { |
---|
448 | case MODE_INTER: |
---|
449 | xReconInter( m_ppcCU[uiDepth], uiDepth ); |
---|
450 | break; |
---|
451 | case MODE_INTRA: |
---|
452 | xReconIntraQT( m_ppcCU[uiDepth], uiDepth ); |
---|
453 | break; |
---|
454 | default: |
---|
455 | assert(0); |
---|
456 | break; |
---|
457 | } |
---|
458 | |
---|
459 | #if DEBUG_STRING |
---|
460 | const PredMode predMode=m_ppcCU[uiDepth]->getPredictionMode(0); |
---|
461 | if (DebugOptionList::DebugString_Structure.getInt()&DebugStringGetPredModeMask(predMode)) |
---|
462 | { |
---|
463 | PartSize eSize=m_ppcCU[uiDepth]->getPartitionSize(0); |
---|
464 | std::ostream &ss(std::cout); |
---|
465 | |
---|
466 | ss <<"###: " << (predMode==MODE_INTRA?"Intra ":"Inter ") << partSizeToString[eSize] << " CU at " << m_ppcCU[uiDepth]->getCUPelX() << ", " << m_ppcCU[uiDepth]->getCUPelY() << " width=" << UInt(m_ppcCU[uiDepth]->getWidth(0)) << std::endl; |
---|
467 | } |
---|
468 | #endif |
---|
469 | |
---|
470 | if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false)) |
---|
471 | { |
---|
472 | xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth); |
---|
473 | } |
---|
474 | |
---|
475 | xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth ); |
---|
476 | } |
---|
477 | |
---|
478 | Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth ) |
---|
479 | { |
---|
480 | |
---|
481 | // inter prediction |
---|
482 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
483 | |
---|
484 | #if DEBUG_STRING |
---|
485 | const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTER); |
---|
486 | if (DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) |
---|
487 | { |
---|
488 | printBlockToStream(std::cout, "###inter-pred: ", *(m_ppcYuvReco[uiDepth])); |
---|
489 | } |
---|
490 | #endif |
---|
491 | |
---|
492 | // inter recon |
---|
493 | xDecodeInterTexture( pcCU, uiDepth ); |
---|
494 | |
---|
495 | #if DEBUG_STRING |
---|
496 | if (DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) |
---|
497 | { |
---|
498 | printBlockToStream(std::cout, "###inter-resi: ", *(m_ppcYuvResi[uiDepth])); |
---|
499 | } |
---|
500 | #endif |
---|
501 | |
---|
502 | // clip for only non-zero cbp case |
---|
503 | if ( pcCU->getQtRootCbf( 0) ) |
---|
504 | { |
---|
505 | #if SVC_EXTENSION |
---|
506 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getBitDepths() ); |
---|
507 | #else |
---|
508 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() ); |
---|
509 | #endif |
---|
510 | } |
---|
511 | else |
---|
512 | { |
---|
513 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
514 | } |
---|
515 | #if DEBUG_STRING |
---|
516 | if (DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) |
---|
517 | { |
---|
518 | printBlockToStream(std::cout, "###inter-reco: ", *(m_ppcYuvReco[uiDepth])); |
---|
519 | } |
---|
520 | #endif |
---|
521 | |
---|
522 | } |
---|
523 | |
---|
524 | |
---|
525 | Void |
---|
526 | TDecCu::xIntraRecBlk( TComYuv* pcRecoYuv, |
---|
527 | TComYuv* pcPredYuv, |
---|
528 | TComYuv* pcResiYuv, |
---|
529 | const ComponentID compID, |
---|
530 | TComTU &rTu) |
---|
531 | { |
---|
532 | if (!rTu.ProcessComponentSection(compID)) |
---|
533 | { |
---|
534 | return; |
---|
535 | } |
---|
536 | const Bool bIsLuma = isLuma(compID); |
---|
537 | |
---|
538 | |
---|
539 | TComDataCU *pcCU = rTu.getCU(); |
---|
540 | const TComSPS &sps=*(pcCU->getSlice()->getSPS()); |
---|
541 | const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU(); |
---|
542 | |
---|
543 | const TComRectangle &tuRect =rTu.getRect(compID); |
---|
544 | const UInt uiWidth = tuRect.width; |
---|
545 | const UInt uiHeight = tuRect.height; |
---|
546 | const UInt uiStride = pcRecoYuv->getStride (compID); |
---|
547 | Pel* piPred = pcPredYuv->getAddr( compID, uiAbsPartIdx ); |
---|
548 | const ChromaFormat chFmt = rTu.GetChromaFormat(); |
---|
549 | |
---|
550 | if (uiWidth != uiHeight) |
---|
551 | { |
---|
552 | //------------------------------------------------ |
---|
553 | |
---|
554 | //split at current level if dividing into square sub-TUs |
---|
555 | |
---|
556 | TComTURecurse subTURecurse(rTu, false, TComTU::VERTICAL_SPLIT, true, compID); |
---|
557 | |
---|
558 | //recurse further |
---|
559 | do |
---|
560 | { |
---|
561 | xIntraRecBlk(pcRecoYuv, pcPredYuv, pcResiYuv, compID, subTURecurse); |
---|
562 | } while (subTURecurse.nextSection(rTu)); |
---|
563 | |
---|
564 | //------------------------------------------------ |
---|
565 | |
---|
566 | return; |
---|
567 | } |
---|
568 | |
---|
569 | const UInt uiChPredMode = pcCU->getIntraDir( toChannelType(compID), uiAbsPartIdx ); |
---|
570 | const UInt partsPerMinCU = 1<<(2*(sps.getMaxTotalCUDepth() - sps.getLog2DiffMaxMinCodingBlockSize())); |
---|
571 | const UInt uiChCodedMode = (uiChPredMode==DM_CHROMA_IDX && !bIsLuma) ? pcCU->getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, chFmt, partsPerMinCU)) : uiChPredMode; |
---|
572 | const UInt uiChFinalMode = ((chFmt == CHROMA_422) && !bIsLuma) ? g_chroma422IntraAngleMappingTable[uiChCodedMode] : uiChCodedMode; |
---|
573 | |
---|
574 | //===== init availability pattern ===== |
---|
575 | Bool bAboveAvail = false; |
---|
576 | Bool bLeftAvail = false; |
---|
577 | |
---|
578 | const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(compID, uiChFinalMode, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag()); |
---|
579 | |
---|
580 | #if DEBUG_STRING |
---|
581 | std::ostream &ss(std::cout); |
---|
582 | #endif |
---|
583 | |
---|
584 | DEBUG_STRING_NEW(sTemp) |
---|
585 | m_pcPrediction->initIntraPatternChType( rTu, bAboveAvail, bLeftAvail, compID, bUseFilteredPredictions DEBUG_STRING_PASS_INTO(sTemp) ); |
---|
586 | |
---|
587 | |
---|
588 | //===== get prediction signal ===== |
---|
589 | |
---|
590 | m_pcPrediction->predIntraAng( compID, uiChFinalMode, 0 /* Decoder does not have an original image */, 0, piPred, uiStride, rTu, bAboveAvail, bLeftAvail, bUseFilteredPredictions ); |
---|
591 | |
---|
592 | #if DEBUG_STRING |
---|
593 | ss << sTemp; |
---|
594 | #endif |
---|
595 | |
---|
596 | //===== inverse transform ===== |
---|
597 | Pel* piResi = pcResiYuv->getAddr( compID, uiAbsPartIdx ); |
---|
598 | TCoeff* pcCoeff = pcCU->getCoeff(compID) + rTu.getCoefficientOffset(compID);//( uiNumCoeffInc * uiAbsPartIdx ); |
---|
599 | |
---|
600 | const QpParam cQP(*pcCU, compID); |
---|
601 | |
---|
602 | |
---|
603 | DEBUG_STRING_NEW(sDebug); |
---|
604 | #if DEBUG_STRING |
---|
605 | const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTRA); |
---|
606 | std::string *psDebug=(DebugOptionList::DebugString_InvTran.getInt()&debugPredModeMask) ? &sDebug : 0; |
---|
607 | #endif |
---|
608 | |
---|
609 | if (pcCU->getCbf(uiAbsPartIdx, compID, rTu.GetTransformDepthRel()) != 0) |
---|
610 | { |
---|
611 | m_pcTrQuant->invTransformNxN( rTu, compID, piResi, uiStride, pcCoeff, cQP DEBUG_STRING_PASS_INTO(psDebug) ); |
---|
612 | } |
---|
613 | else |
---|
614 | { |
---|
615 | for (UInt y = 0; y < uiHeight; y++) |
---|
616 | { |
---|
617 | for (UInt x = 0; x < uiWidth; x++) |
---|
618 | { |
---|
619 | piResi[(y * uiStride) + x] = 0; |
---|
620 | } |
---|
621 | } |
---|
622 | } |
---|
623 | |
---|
624 | #if DEBUG_STRING |
---|
625 | if (psDebug) |
---|
626 | { |
---|
627 | ss << (*psDebug); |
---|
628 | } |
---|
629 | #endif |
---|
630 | |
---|
631 | //===== reconstruction ===== |
---|
632 | const UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride(compID); |
---|
633 | |
---|
634 | const Bool useCrossComponentPrediction = isChroma(compID) && (pcCU->getCrossComponentPredictionAlpha(uiAbsPartIdx, compID) != 0); |
---|
635 | const Pel* pResiLuma = pcResiYuv->getAddr( COMPONENT_Y, uiAbsPartIdx ); |
---|
636 | const Int strideLuma = pcResiYuv->getStride( COMPONENT_Y ); |
---|
637 | |
---|
638 | Pel* pPred = piPred; |
---|
639 | Pel* pResi = piResi; |
---|
640 | Pel* pReco = pcRecoYuv->getAddr( compID, uiAbsPartIdx ); |
---|
641 | Pel* pRecIPred = pcCU->getPic()->getPicYuvRec()->getAddr( compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx ); |
---|
642 | |
---|
643 | |
---|
644 | #if DEBUG_STRING |
---|
645 | const Bool bDebugPred=((DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
646 | const Bool bDebugResi=((DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
647 | const Bool bDebugReco=((DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
648 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
649 | { |
---|
650 | ss << "###: " << "CompID: " << compID << " pred mode (ch/fin): " << uiChPredMode << "/" << uiChFinalMode << " absPartIdx: " << rTu.GetAbsPartIdxTU() << std::endl; |
---|
651 | } |
---|
652 | #endif |
---|
653 | |
---|
654 | #if SVC_EXTENSION |
---|
655 | const Int clipbd = pcCU->getSlice()->getBitDepth(toChannelType(compID)); |
---|
656 | #else |
---|
657 | const Int clipbd = sps.getBitDepth(toChannelType(compID)); |
---|
658 | #endif |
---|
659 | #if O0043_BEST_EFFORT_DECODING |
---|
660 | const Int bitDepthDelta = sps.getStreamBitDepth(toChannelType(compID)) - clipbd; |
---|
661 | #endif |
---|
662 | |
---|
663 | if( useCrossComponentPrediction ) |
---|
664 | { |
---|
665 | TComTrQuant::crossComponentPrediction( rTu, compID, pResiLuma, piResi, piResi, uiWidth, uiHeight, strideLuma, uiStride, uiStride, true ); |
---|
666 | } |
---|
667 | |
---|
668 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
669 | { |
---|
670 | #if DEBUG_STRING |
---|
671 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
672 | { |
---|
673 | ss << "###: "; |
---|
674 | } |
---|
675 | |
---|
676 | if (bDebugPred) |
---|
677 | { |
---|
678 | ss << " - pred: "; |
---|
679 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
680 | { |
---|
681 | ss << pPred[ uiX ] << ", "; |
---|
682 | } |
---|
683 | } |
---|
684 | if (bDebugResi) |
---|
685 | { |
---|
686 | ss << " - resi: "; |
---|
687 | } |
---|
688 | #endif |
---|
689 | |
---|
690 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
691 | { |
---|
692 | #if DEBUG_STRING |
---|
693 | if (bDebugResi) |
---|
694 | { |
---|
695 | ss << pResi[ uiX ] << ", "; |
---|
696 | } |
---|
697 | #endif |
---|
698 | #if O0043_BEST_EFFORT_DECODING |
---|
699 | pReco [ uiX ] = ClipBD( rightShiftEvenRounding<Pel>(pPred[ uiX ] + pResi[ uiX ], bitDepthDelta), clipbd ); |
---|
700 | #else |
---|
701 | pReco [ uiX ] = ClipBD( pPred[ uiX ] + pResi[ uiX ], clipbd ); |
---|
702 | #endif |
---|
703 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
704 | } |
---|
705 | #if DEBUG_STRING |
---|
706 | if (bDebugReco) |
---|
707 | { |
---|
708 | ss << " - reco: "; |
---|
709 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
710 | { |
---|
711 | ss << pReco[ uiX ] << ", "; |
---|
712 | } |
---|
713 | } |
---|
714 | |
---|
715 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
716 | { |
---|
717 | ss << "\n"; |
---|
718 | } |
---|
719 | #endif |
---|
720 | pPred += uiStride; |
---|
721 | pResi += uiStride; |
---|
722 | pReco += uiStride; |
---|
723 | pRecIPred += uiRecIPredStride; |
---|
724 | } |
---|
725 | } |
---|
726 | |
---|
727 | |
---|
728 | Void |
---|
729 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth ) |
---|
730 | { |
---|
731 | if (pcCU->getIPCMFlag(0)) |
---|
732 | { |
---|
733 | xReconPCM( pcCU, uiDepth ); |
---|
734 | return; |
---|
735 | } |
---|
736 | const UInt numChType = pcCU->getPic()->getChromaFormat()!=CHROMA_400 ? 2 : 1; |
---|
737 | for (UInt chType=CHANNEL_TYPE_LUMA; chType<numChType; chType++) |
---|
738 | { |
---|
739 | const ChannelType chanType=ChannelType(chType); |
---|
740 | const Bool NxNPUHas4Parts = ::isChroma(chanType) ? enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) : true; |
---|
741 | const UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) != SIZE_2Nx2N && NxNPUHas4Parts ? 1 : 0 ); |
---|
742 | |
---|
743 | TComTURecurse tuRecurseCU(pcCU, 0); |
---|
744 | TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (uiInitTrDepth==0)?TComTU::DONT_SPLIT : TComTU::QUAD_SPLIT); |
---|
745 | |
---|
746 | do |
---|
747 | { |
---|
748 | xIntraRecQT( m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], chanType, tuRecurseWithPU ); |
---|
749 | } while (tuRecurseWithPU.nextSection(tuRecurseCU)); |
---|
750 | } |
---|
751 | } |
---|
752 | |
---|
753 | |
---|
754 | |
---|
755 | /** Function for deriving reconstructed PU/CU chroma samples with QTree structure |
---|
756 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
757 | * \param pcPredYuv pointer to prediction sample arrays |
---|
758 | * \param pcResiYuv pointer to residue sample arrays |
---|
759 | * \param chType texture channel type (luma/chroma) |
---|
760 | * \param rTu reference to transform data |
---|
761 | * |
---|
762 | \ This function derives reconstructed PU/CU chroma samples with QTree recursive structure |
---|
763 | */ |
---|
764 | |
---|
765 | Void |
---|
766 | TDecCu::xIntraRecQT(TComYuv* pcRecoYuv, |
---|
767 | TComYuv* pcPredYuv, |
---|
768 | TComYuv* pcResiYuv, |
---|
769 | const ChannelType chType, |
---|
770 | TComTU &rTu) |
---|
771 | { |
---|
772 | UInt uiTrDepth = rTu.GetTransformDepthRel(); |
---|
773 | TComDataCU *pcCU = rTu.getCU(); |
---|
774 | UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); |
---|
775 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
776 | if( uiTrMode == uiTrDepth ) |
---|
777 | { |
---|
778 | if (isLuma(chType)) |
---|
779 | { |
---|
780 | xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, COMPONENT_Y, rTu ); |
---|
781 | } |
---|
782 | else |
---|
783 | { |
---|
784 | const UInt numValidComp=getNumberValidComponents(rTu.GetChromaFormat()); |
---|
785 | for(UInt compID=COMPONENT_Cb; compID<numValidComp; compID++) |
---|
786 | { |
---|
787 | xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, ComponentID(compID), rTu ); |
---|
788 | } |
---|
789 | } |
---|
790 | } |
---|
791 | else |
---|
792 | { |
---|
793 | TComTURecurse tuRecurseChild(rTu, false); |
---|
794 | do |
---|
795 | { |
---|
796 | xIntraRecQT( pcRecoYuv, pcPredYuv, pcResiYuv, chType, tuRecurseChild ); |
---|
797 | } while (tuRecurseChild.nextSection(rTu)); |
---|
798 | } |
---|
799 | } |
---|
800 | |
---|
801 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
802 | { |
---|
803 | UInt uiCtuRsAddr = pcCU->getCtuRsAddr(); |
---|
804 | |
---|
805 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCtuRsAddr, uiZorderIdx ); |
---|
806 | |
---|
807 | return; |
---|
808 | } |
---|
809 | |
---|
810 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiDepth ) |
---|
811 | { |
---|
812 | |
---|
813 | TComTURecurse tuRecur(pcCU, 0, uiDepth); |
---|
814 | |
---|
815 | for(UInt ch=0; ch<pcCU->getPic()->getNumberValidComponents(); ch++) |
---|
816 | { |
---|
817 | const ComponentID compID=ComponentID(ch); |
---|
818 | DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[compID]) |
---|
819 | |
---|
820 | m_pcTrQuant->invRecurTransformNxN ( compID, m_ppcYuvResi[uiDepth], tuRecur ); |
---|
821 | } |
---|
822 | |
---|
823 | DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[MAX_NUM_COMPONENT]) |
---|
824 | } |
---|
825 | |
---|
826 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
---|
827 | * \param pcCU pointer to current CU |
---|
828 | * \param uiPartIdx part index |
---|
829 | * \param piPCM pointer to PCM code arrays |
---|
830 | * \param piReco pointer to reconstructed sample arrays |
---|
831 | * \param uiStride stride of reconstructed sample arrays |
---|
832 | * \param uiWidth CU width |
---|
833 | * \param uiHeight CU height |
---|
834 | * \param compID colour component ID |
---|
835 | * \returns Void |
---|
836 | */ |
---|
837 | Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, const UInt uiPartIdx, const Pel *piPCM, Pel* piReco, const UInt uiStride, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) |
---|
838 | { |
---|
839 | Pel* piPicReco = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiPartIdx); |
---|
840 | const UInt uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(compID); |
---|
841 | #if SVC_EXTENSION |
---|
842 | const UInt uiPcmLeftShiftBit = pcCU->getSlice()->getBitDepth(toChannelType(compID)) - pcCU->getSlice()->getSPS()->getPCMBitDepth(toChannelType(compID)); |
---|
843 | #else |
---|
844 | const TComSPS &sps = *(pcCU->getSlice()->getSPS()); |
---|
845 | const UInt uiPcmLeftShiftBit = sps.getBitDepth(toChannelType(compID)) - sps.getPCMBitDepth(toChannelType(compID)); |
---|
846 | #endif |
---|
847 | |
---|
848 | for(UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
849 | { |
---|
850 | for(UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
851 | { |
---|
852 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
---|
853 | piPicReco[uiX] = piReco[uiX]; |
---|
854 | } |
---|
855 | piPCM += uiWidth; |
---|
856 | piReco += uiStride; |
---|
857 | piPicReco += uiPicStride; |
---|
858 | } |
---|
859 | } |
---|
860 | |
---|
861 | /** Function for reconstructing a PCM mode CU. |
---|
862 | * \param pcCU pointer to current CU |
---|
863 | * \param uiDepth CU Depth |
---|
864 | * \returns Void |
---|
865 | */ |
---|
866 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth ) |
---|
867 | { |
---|
868 | const UInt maxCuWidth = pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
869 | const UInt maxCuHeight = pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
870 | for (UInt ch=0; ch < pcCU->getPic()->getNumberValidComponents(); ch++) |
---|
871 | { |
---|
872 | const ComponentID compID = ComponentID(ch); |
---|
873 | const UInt width = (maxCuWidth >>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleX(compID))); |
---|
874 | const UInt height = (maxCuHeight>>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleY(compID))); |
---|
875 | const UInt stride = m_ppcYuvResi[uiDepth]->getStride(compID); |
---|
876 | Pel * pPCMChannel = pcCU->getPCMSample(compID); |
---|
877 | Pel * pRecChannel = m_ppcYuvReco[uiDepth]->getAddr(compID); |
---|
878 | xDecodePCMTexture( pcCU, 0, pPCMChannel, pRecChannel, stride, width, height, compID ); |
---|
879 | } |
---|
880 | } |
---|
881 | |
---|
882 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
---|
883 | * \param pCU pointer to current CU |
---|
884 | * \param depth CU Depth |
---|
885 | */ |
---|
886 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth) |
---|
887 | { |
---|
888 | const ChromaFormat format = pCU->getPic()->getChromaFormat(); |
---|
889 | const UInt numValidComp = getNumberValidComponents(format); |
---|
890 | const UInt maxCuWidth = pCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
891 | const UInt maxCuHeight = pCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
892 | |
---|
893 | for (UInt componentIndex = 0; componentIndex < numValidComp; componentIndex++) |
---|
894 | { |
---|
895 | const ComponentID component = ComponentID(componentIndex); |
---|
896 | |
---|
897 | const UInt width = maxCuWidth >> (depth + getComponentScaleX(component, format)); |
---|
898 | const UInt height = maxCuHeight >> (depth + getComponentScaleY(component, format)); |
---|
899 | |
---|
900 | Pel *source = m_ppcYuvReco[depth]->getAddr(component, 0, width); |
---|
901 | Pel *destination = pCU->getPCMSample(component); |
---|
902 | |
---|
903 | const UInt sourceStride = m_ppcYuvReco[depth]->getStride(component); |
---|
904 | |
---|
905 | for (Int line = 0; line < height; line++) |
---|
906 | { |
---|
907 | for (Int column = 0; column < width; column++) |
---|
908 | { |
---|
909 | destination[column] = source[column]; |
---|
910 | } |
---|
911 | |
---|
912 | source += sourceStride; |
---|
913 | destination += width; |
---|
914 | } |
---|
915 | } |
---|
916 | } |
---|
917 | |
---|
918 | //! \} |
---|