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) printBlockToStream(std::cout, "###inter-pred: ", *(m_ppcYuvReco[uiDepth])); |
---|
488 | #endif |
---|
489 | |
---|
490 | // inter recon |
---|
491 | xDecodeInterTexture( pcCU, uiDepth ); |
---|
492 | |
---|
493 | #ifdef DEBUG_STRING |
---|
494 | if (DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) printBlockToStream(std::cout, "###inter-resi: ", *(m_ppcYuvResi[uiDepth])); |
---|
495 | #endif |
---|
496 | |
---|
497 | // clip for only non-zero cbp case |
---|
498 | if ( pcCU->getQtRootCbf( 0) ) |
---|
499 | { |
---|
500 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
501 | } |
---|
502 | else |
---|
503 | { |
---|
504 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
505 | } |
---|
506 | #ifdef DEBUG_STRING |
---|
507 | if (DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) printBlockToStream(std::cout, "###inter-reco: ", *(m_ppcYuvReco[uiDepth])); |
---|
508 | #endif |
---|
509 | |
---|
510 | } |
---|
511 | |
---|
512 | |
---|
513 | Void |
---|
514 | TDecCu::xIntraRecBlk( TComYuv* pcRecoYuv, |
---|
515 | TComYuv* pcPredYuv, |
---|
516 | TComYuv* pcResiYuv, |
---|
517 | const ComponentID compID, |
---|
518 | TComTU &rTu) |
---|
519 | { |
---|
520 | if (!rTu.ProcessComponentSection(compID)) return; |
---|
521 | const Bool bIsLuma = isLuma(compID); |
---|
522 | |
---|
523 | |
---|
524 | TComDataCU *pcCU = rTu.getCU(); |
---|
525 | const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU(); |
---|
526 | |
---|
527 | const TComRectangle &tuRect =rTu.getRect(compID); |
---|
528 | const UInt uiWidth = tuRect.width; |
---|
529 | const UInt uiHeight = tuRect.height; |
---|
530 | const UInt uiStride = pcRecoYuv->getStride (compID); |
---|
531 | Pel* piPred = pcPredYuv->getAddr( compID, uiAbsPartIdx ); |
---|
532 | const ChromaFormat chFmt = rTu.GetChromaFormat(); |
---|
533 | |
---|
534 | if (uiWidth != uiHeight) |
---|
535 | { |
---|
536 | //------------------------------------------------ |
---|
537 | |
---|
538 | //split at current level if dividing into square sub-TUs |
---|
539 | |
---|
540 | TComTURecurse subTURecurse(rTu, false, TComTU::VERTICAL_SPLIT, true, compID); |
---|
541 | |
---|
542 | //recurse further |
---|
543 | do |
---|
544 | { |
---|
545 | xIntraRecBlk(pcRecoYuv, pcPredYuv, pcResiYuv, compID, subTURecurse); |
---|
546 | } |
---|
547 | while (subTURecurse.nextSection(rTu)); |
---|
548 | |
---|
549 | //------------------------------------------------ |
---|
550 | |
---|
551 | return; |
---|
552 | } |
---|
553 | |
---|
554 | const UInt uiChPredMode = pcCU->getIntraDir( toChannelType(compID), uiAbsPartIdx ); |
---|
555 | const UInt uiChCodedMode = (uiChPredMode==DM_CHROMA_IDX && !bIsLuma) ? pcCU->getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, chFmt)) : uiChPredMode; |
---|
556 | const UInt uiChFinalMode = ((chFmt == CHROMA_422) && !bIsLuma) ? g_chroma422IntraAngleMappingTable[uiChCodedMode] : uiChCodedMode; |
---|
557 | |
---|
558 | //===== init availability pattern ===== |
---|
559 | Bool bAboveAvail = false; |
---|
560 | Bool bLeftAvail = false; |
---|
561 | |
---|
562 | const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(compID, uiChFinalMode, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getDisableIntraReferenceSmoothing()); |
---|
563 | |
---|
564 | #ifdef DEBUG_STRING |
---|
565 | std::ostream &ss(std::cout); |
---|
566 | #endif |
---|
567 | |
---|
568 | DEBUG_STRING_NEW(sTemp) |
---|
569 | m_pcPrediction->initAdiPatternChType( rTu, bAboveAvail, bLeftAvail, compID, bUseFilteredPredictions DEBUG_STRING_PASS_INTO(sTemp) ); |
---|
570 | |
---|
571 | |
---|
572 | //===== get prediction signal ===== |
---|
573 | |
---|
574 | m_pcPrediction->predIntraAng( compID, uiChFinalMode, 0 /* Decoder does not have an original image */, 0, piPred, uiStride, rTu, bAboveAvail, bLeftAvail, bUseFilteredPredictions ); |
---|
575 | |
---|
576 | #ifdef DEBUG_STRING |
---|
577 | ss << sTemp; |
---|
578 | #endif |
---|
579 | |
---|
580 | //===== inverse transform ===== |
---|
581 | Pel* piResi = pcResiYuv->getAddr( compID, uiAbsPartIdx ); |
---|
582 | TCoeff* pcCoeff = pcCU->getCoeff(compID) + rTu.getCoefficientOffset(compID);//( uiNumCoeffInc * uiAbsPartIdx ); |
---|
583 | |
---|
584 | const QpParam cQP(*pcCU, compID); |
---|
585 | |
---|
586 | |
---|
587 | DEBUG_STRING_NEW(sDebug); |
---|
588 | #ifdef DEBUG_STRING |
---|
589 | const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTRA); |
---|
590 | std::string *psDebug=(DebugOptionList::DebugString_InvTran.getInt()&debugPredModeMask) ? &sDebug : 0; |
---|
591 | #endif |
---|
592 | |
---|
593 | if (pcCU->getCbf(uiAbsPartIdx, compID, rTu.GetTransformDepthRel()) != 0) |
---|
594 | { |
---|
595 | m_pcTrQuant->invTransformNxN( rTu, compID, piResi, uiStride, pcCoeff, cQP DEBUG_STRING_PASS_INTO(psDebug) ); |
---|
596 | } |
---|
597 | else |
---|
598 | { |
---|
599 | for (UInt y = 0; y < uiHeight; y++) |
---|
600 | for (UInt x = 0; x < uiWidth; x++) |
---|
601 | { |
---|
602 | piResi[(y * uiStride) + x] = 0; |
---|
603 | } |
---|
604 | } |
---|
605 | |
---|
606 | #ifdef DEBUG_STRING |
---|
607 | if (psDebug) |
---|
608 | ss << (*psDebug); |
---|
609 | #endif |
---|
610 | |
---|
611 | //===== reconstruction ===== |
---|
612 | const UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride(compID); |
---|
613 | |
---|
614 | const Bool useCrossComponentPrediction = isChroma(compID) && (pcCU->getCrossComponentPredictionAlpha(uiAbsPartIdx, compID) != 0); |
---|
615 | const Pel* pResiLuma = pcResiYuv->getAddr( COMPONENT_Y, uiAbsPartIdx ); |
---|
616 | const Int strideLuma = pcResiYuv->getStride( COMPONENT_Y ); |
---|
617 | |
---|
618 | Pel* pPred = piPred; |
---|
619 | Pel* pResi = piResi; |
---|
620 | Pel* pReco = pcRecoYuv->getAddr( compID, uiAbsPartIdx ); |
---|
621 | Pel* pRecIPred = pcCU->getPic()->getPicYuvRec()->getAddr( compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx ); |
---|
622 | |
---|
623 | |
---|
624 | #ifdef DEBUG_STRING |
---|
625 | const Bool bDebugPred=((DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
626 | const Bool bDebugResi=((DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
627 | const Bool bDebugReco=((DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
628 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
629 | ss << "###: " << "CompID: " << compID << " pred mode (ch/fin): " << uiChPredMode << "/" << uiChFinalMode << " absPartIdx: " << rTu.GetAbsPartIdxTU() << std::endl; |
---|
630 | #endif |
---|
631 | |
---|
632 | #if O0043_BEST_EFFORT_DECODING |
---|
633 | const Int bitDepthDelta = g_bitDepthInStream[toChannelType(compID)] - g_bitDepth[toChannelType(compID)]; |
---|
634 | #endif |
---|
635 | const Int clipbd = g_bitDepth[toChannelType(compID)]; |
---|
636 | |
---|
637 | if( useCrossComponentPrediction ) |
---|
638 | { |
---|
639 | TComTrQuant::crossComponentPrediction( rTu, compID, pResiLuma, piResi, piResi, uiWidth, uiHeight, strideLuma, uiStride, uiStride, true ); |
---|
640 | } |
---|
641 | |
---|
642 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
643 | { |
---|
644 | #ifdef DEBUG_STRING |
---|
645 | if (bDebugPred || bDebugResi || bDebugReco) ss << "###: "; |
---|
646 | |
---|
647 | if (bDebugPred) |
---|
648 | { |
---|
649 | ss << " - pred: "; |
---|
650 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
651 | { |
---|
652 | ss << pPred[ uiX ] << ", "; |
---|
653 | } |
---|
654 | } |
---|
655 | if (bDebugResi) ss << " - resi: "; |
---|
656 | #endif |
---|
657 | |
---|
658 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
659 | { |
---|
660 | #ifdef DEBUG_STRING |
---|
661 | if (bDebugResi) |
---|
662 | ss << pResi[ uiX ] << ", "; |
---|
663 | #endif |
---|
664 | #if O0043_BEST_EFFORT_DECODING |
---|
665 | pReco [ uiX ] = ClipBD( rightShiftEvenRounding<Pel>(pPred[ uiX ] + pResi[ uiX ], bitDepthDelta), clipbd ); |
---|
666 | #else |
---|
667 | pReco [ uiX ] = ClipBD( pPred[ uiX ] + pResi[ uiX ], clipbd ); |
---|
668 | #endif |
---|
669 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
670 | } |
---|
671 | #ifdef DEBUG_STRING |
---|
672 | if (bDebugReco) |
---|
673 | { |
---|
674 | ss << " - reco: "; |
---|
675 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
676 | { |
---|
677 | ss << pReco[ uiX ] << ", "; |
---|
678 | } |
---|
679 | } |
---|
680 | |
---|
681 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
682 | ss << "\n"; |
---|
683 | #endif |
---|
684 | pPred += uiStride; |
---|
685 | pResi += uiStride; |
---|
686 | pReco += uiStride; |
---|
687 | pRecIPred += uiRecIPredStride; |
---|
688 | } |
---|
689 | } |
---|
690 | |
---|
691 | |
---|
692 | Void |
---|
693 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth ) |
---|
694 | { |
---|
695 | if (pcCU->getIPCMFlag(0)) |
---|
696 | { |
---|
697 | xReconPCM( pcCU, uiDepth ); |
---|
698 | return; |
---|
699 | } |
---|
700 | const UInt numChType = pcCU->getPic()->getChromaFormat()!=CHROMA_400 ? 2 : 1; |
---|
701 | for (UInt chType=CHANNEL_TYPE_LUMA; chType<numChType; chType++) |
---|
702 | { |
---|
703 | const ChannelType chanType=ChannelType(chType); |
---|
704 | const Bool NxNPUHas4Parts = ::isChroma(chanType) ? enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) : true; |
---|
705 | const UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) != SIZE_2Nx2N && NxNPUHas4Parts ? 1 : 0 ); |
---|
706 | |
---|
707 | TComTURecurse tuRecurseCU(pcCU, 0); |
---|
708 | TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (uiInitTrDepth==0)?TComTU::DONT_SPLIT : TComTU::QUAD_SPLIT); |
---|
709 | |
---|
710 | do |
---|
711 | { |
---|
712 | xIntraRecQT( m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], chanType, tuRecurseWithPU ); |
---|
713 | } while (tuRecurseWithPU.nextSection(tuRecurseCU)); |
---|
714 | } |
---|
715 | } |
---|
716 | |
---|
717 | |
---|
718 | |
---|
719 | /** Function for deriving recontructed PU/CU chroma samples with QTree structure |
---|
720 | * \param pcCU pointer of current CU |
---|
721 | * \param uiTrDepth current tranform split depth |
---|
722 | * \param uiAbsPartIdx part index |
---|
723 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
724 | * \param pcPredYuv pointer to prediction sample arrays |
---|
725 | * \param pcResiYuv pointer to residue sample arrays |
---|
726 | * |
---|
727 | \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure |
---|
728 | */ |
---|
729 | |
---|
730 | Void |
---|
731 | TDecCu::xIntraRecQT(TComYuv* pcRecoYuv, |
---|
732 | TComYuv* pcPredYuv, |
---|
733 | TComYuv* pcResiYuv, |
---|
734 | const ChannelType chType, |
---|
735 | TComTU &rTu) |
---|
736 | { |
---|
737 | UInt uiTrDepth = rTu.GetTransformDepthRel(); |
---|
738 | TComDataCU *pcCU = rTu.getCU(); |
---|
739 | UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); |
---|
740 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
741 | if( uiTrMode == uiTrDepth ) |
---|
742 | { |
---|
743 | if (isLuma(chType)) |
---|
744 | xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, COMPONENT_Y, rTu ); |
---|
745 | else |
---|
746 | { |
---|
747 | const UInt numValidComp=getNumberValidComponents(rTu.GetChromaFormat()); |
---|
748 | for(UInt compID=COMPONENT_Cb; compID<numValidComp; compID++) |
---|
749 | { |
---|
750 | xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, ComponentID(compID), rTu ); |
---|
751 | } |
---|
752 | } |
---|
753 | } |
---|
754 | else |
---|
755 | { |
---|
756 | TComTURecurse tuRecurseChild(rTu, false); |
---|
757 | do |
---|
758 | { |
---|
759 | xIntraRecQT( pcRecoYuv, pcPredYuv, pcResiYuv, chType, tuRecurseChild ); |
---|
760 | } while (tuRecurseChild.nextSection(rTu)); |
---|
761 | } |
---|
762 | } |
---|
763 | |
---|
764 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
765 | { |
---|
766 | UInt uiCtuRsAddr = pcCU->getCtuRsAddr(); |
---|
767 | |
---|
768 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCtuRsAddr, uiZorderIdx ); |
---|
769 | |
---|
770 | return; |
---|
771 | } |
---|
772 | |
---|
773 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiDepth ) |
---|
774 | { |
---|
775 | |
---|
776 | TComTURecurse tuRecur(pcCU, 0, uiDepth); |
---|
777 | |
---|
778 | for(UInt ch=0; ch<pcCU->getPic()->getNumberValidComponents(); ch++) |
---|
779 | { |
---|
780 | const ComponentID compID=ComponentID(ch); |
---|
781 | DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[compID]) |
---|
782 | |
---|
783 | m_pcTrQuant->invRecurTransformNxN ( compID, m_ppcYuvResi[uiDepth], tuRecur ); |
---|
784 | } |
---|
785 | |
---|
786 | DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[MAX_NUM_COMPONENT]) |
---|
787 | } |
---|
788 | |
---|
789 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
---|
790 | * \param pcCU pointer to current CU |
---|
791 | * \param uiPartIdx part index |
---|
792 | * \param piPCM pointer to PCM code arrays |
---|
793 | * \param piReco pointer to reconstructed sample arrays |
---|
794 | * \param uiStride stride of reconstructed sample arrays |
---|
795 | * \param uiWidth CU width |
---|
796 | * \param uiHeight CU height |
---|
797 | * \param ttText texture component type |
---|
798 | * \returns Void |
---|
799 | */ |
---|
800 | 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) |
---|
801 | { |
---|
802 | Pel* piPicReco = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiPartIdx); |
---|
803 | const UInt uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(compID); |
---|
804 | const UInt uiPcmLeftShiftBit = g_bitDepth[toChannelType(compID)] - pcCU->getSlice()->getSPS()->getPCMBitDepth(toChannelType(compID)); |
---|
805 | |
---|
806 | for(UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
807 | { |
---|
808 | for(UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
809 | { |
---|
810 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
---|
811 | piPicReco[uiX] = piReco[uiX]; |
---|
812 | } |
---|
813 | piPCM += uiWidth; |
---|
814 | piReco += uiStride; |
---|
815 | piPicReco += uiPicStride; |
---|
816 | } |
---|
817 | } |
---|
818 | |
---|
819 | /** Function for reconstructing a PCM mode CU. |
---|
820 | * \param pcCU pointer to current CU |
---|
821 | * \param uiDepth CU Depth |
---|
822 | * \returns Void |
---|
823 | */ |
---|
824 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth ) |
---|
825 | { |
---|
826 | for (UInt ch=0; ch < pcCU->getPic()->getNumberValidComponents(); ch++) |
---|
827 | { |
---|
828 | const ComponentID compID = ComponentID(ch); |
---|
829 | const UInt width = (g_uiMaxCUWidth >>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleX(compID))); |
---|
830 | const UInt height = (g_uiMaxCUHeight>>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleY(compID))); |
---|
831 | const UInt stride = m_ppcYuvResi[uiDepth]->getStride(compID); |
---|
832 | Pel * pPCMChannel = pcCU->getPCMSample(compID); |
---|
833 | Pel * pRecChannel = m_ppcYuvReco[uiDepth]->getAddr(compID); |
---|
834 | xDecodePCMTexture( pcCU, 0, pPCMChannel, pRecChannel, stride, width, height, compID ); |
---|
835 | } |
---|
836 | } |
---|
837 | |
---|
838 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
---|
839 | * \param pcCU pointer to current CU |
---|
840 | * \param uiDepth CU Depth |
---|
841 | * \returns Void |
---|
842 | */ |
---|
843 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth) |
---|
844 | { |
---|
845 | const ChromaFormat format = pCU->getPic()->getChromaFormat(); |
---|
846 | const UInt numValidComp=getNumberValidComponents(format); |
---|
847 | |
---|
848 | for (UInt componentIndex = 0; componentIndex < numValidComp; componentIndex++) |
---|
849 | { |
---|
850 | const ComponentID component = ComponentID(componentIndex); |
---|
851 | |
---|
852 | const UInt width = g_uiMaxCUWidth >> (depth + getComponentScaleX(component, format)); |
---|
853 | const UInt height = g_uiMaxCUHeight >> (depth + getComponentScaleY(component, format)); |
---|
854 | |
---|
855 | Pel *source = m_ppcYuvReco[depth]->getAddr(component, 0, width); |
---|
856 | Pel *destination = pCU->getPCMSample(component); |
---|
857 | |
---|
858 | const UInt sourceStride = m_ppcYuvReco[depth]->getStride(component); |
---|
859 | |
---|
860 | for (Int line = 0; line < height; line++) |
---|
861 | { |
---|
862 | for (Int column = 0; column < width; column++) |
---|
863 | { |
---|
864 | destination[column] = source[column]; |
---|
865 | } |
---|
866 | |
---|
867 | source += sourceStride; |
---|
868 | destination += width; |
---|
869 | } |
---|
870 | } |
---|
871 | } |
---|
872 | |
---|
873 | //! \} |
---|