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