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