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-2013, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TDecCu.cpp |
---|
35 | \brief CU decoder class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "TDecCu.h" |
---|
39 | #if SVC_EXTENSION |
---|
40 | #include "TDecTop.h" |
---|
41 | #endif |
---|
42 | |
---|
43 | |
---|
44 | //! \ingroup TLibDecoder |
---|
45 | //! \{ |
---|
46 | |
---|
47 | // ==================================================================================================================== |
---|
48 | // Constructor / destructor / create / destroy |
---|
49 | // ==================================================================================================================== |
---|
50 | |
---|
51 | TDecCu::TDecCu() |
---|
52 | { |
---|
53 | m_ppcYuvResi = NULL; |
---|
54 | m_ppcYuvReco = NULL; |
---|
55 | m_ppcCU = NULL; |
---|
56 | } |
---|
57 | |
---|
58 | TDecCu::~TDecCu() |
---|
59 | { |
---|
60 | } |
---|
61 | |
---|
62 | #if SVC_EXTENSION |
---|
63 | Void TDecCu::init(TDecTop** ppcDecTop, TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction, UInt layerId) |
---|
64 | { |
---|
65 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
66 | m_pcTrQuant = pcTrQuant; |
---|
67 | m_pcPrediction = pcPrediction; |
---|
68 | m_ppcTDecTop = ppcDecTop; |
---|
69 | m_layerId = layerId; |
---|
70 | |
---|
71 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
72 | { |
---|
73 | m_ppcCU [ui]->setLayerId(layerId); |
---|
74 | } |
---|
75 | } |
---|
76 | #else |
---|
77 | Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction) |
---|
78 | { |
---|
79 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
80 | m_pcTrQuant = pcTrQuant; |
---|
81 | m_pcPrediction = pcPrediction; |
---|
82 | } |
---|
83 | #endif |
---|
84 | |
---|
85 | /** |
---|
86 | \param uiMaxDepth total number of allowable depth |
---|
87 | \param uiMaxWidth largest CU width |
---|
88 | \param uiMaxHeight largest CU height |
---|
89 | */ |
---|
90 | Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight ) |
---|
91 | { |
---|
92 | m_uiMaxDepth = uiMaxDepth+1; |
---|
93 | |
---|
94 | m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1]; |
---|
95 | m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1]; |
---|
96 | m_ppcCU = new TComDataCU*[m_uiMaxDepth-1]; |
---|
97 | |
---|
98 | UInt uiNumPartitions; |
---|
99 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
100 | { |
---|
101 | uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 ); |
---|
102 | UInt uiWidth = uiMaxWidth >> ui; |
---|
103 | UInt uiHeight = uiMaxHeight >> ui; |
---|
104 | |
---|
105 | m_ppcYuvResi[ui] = new TComYuv; m_ppcYuvResi[ui]->create( uiWidth, uiHeight ); |
---|
106 | m_ppcYuvReco[ui] = new TComYuv; m_ppcYuvReco[ui]->create( uiWidth, uiHeight ); |
---|
107 | m_ppcCU [ui] = new TComDataCU; m_ppcCU [ui]->create( uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) ); |
---|
108 | } |
---|
109 | |
---|
110 | m_bDecodeDQP = false; |
---|
111 | |
---|
112 | // initialize partition order. |
---|
113 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
114 | initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp); |
---|
115 | initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
116 | |
---|
117 | // initialize conversion matrix from partition index to pel |
---|
118 | initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
119 | } |
---|
120 | |
---|
121 | Void TDecCu::destroy() |
---|
122 | { |
---|
123 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
124 | { |
---|
125 | m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL; |
---|
126 | m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL; |
---|
127 | m_ppcCU [ui]->destroy(); delete m_ppcCU [ui]; m_ppcCU [ui] = NULL; |
---|
128 | } |
---|
129 | |
---|
130 | delete [] m_ppcYuvResi; m_ppcYuvResi = NULL; |
---|
131 | delete [] m_ppcYuvReco; m_ppcYuvReco = NULL; |
---|
132 | delete [] m_ppcCU ; m_ppcCU = NULL; |
---|
133 | } |
---|
134 | |
---|
135 | // ==================================================================================================================== |
---|
136 | // Public member functions |
---|
137 | // ==================================================================================================================== |
---|
138 | |
---|
139 | /** \param pcCU pointer of CU data |
---|
140 | \param ruiIsLast last data? |
---|
141 | */ |
---|
142 | Void TDecCu::decodeCU( TComDataCU* pcCU, UInt& ruiIsLast ) |
---|
143 | { |
---|
144 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
145 | { |
---|
146 | setdQPFlag(true); |
---|
147 | } |
---|
148 | |
---|
149 | // start from the top level CU |
---|
150 | #if SVC_EXTENSION |
---|
151 | pcCU->setLayerId(m_layerId); |
---|
152 | #endif |
---|
153 | xDecodeCU( pcCU, 0, 0, ruiIsLast); |
---|
154 | } |
---|
155 | |
---|
156 | /** \param pcCU pointer of CU data |
---|
157 | */ |
---|
158 | Void TDecCu::decompressCU( TComDataCU* pcCU ) |
---|
159 | { |
---|
160 | xDecompressCU( pcCU, 0, 0 ); |
---|
161 | } |
---|
162 | |
---|
163 | // ==================================================================================================================== |
---|
164 | // Protected member functions |
---|
165 | // ==================================================================================================================== |
---|
166 | |
---|
167 | /**decode end-of-slice flag |
---|
168 | * \param pcCU |
---|
169 | * \param uiAbsPartIdx |
---|
170 | * \param uiDepth |
---|
171 | * \returns Bool |
---|
172 | */ |
---|
173 | Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth) |
---|
174 | { |
---|
175 | UInt uiIsLast; |
---|
176 | TComPic* pcPic = pcCU->getPic(); |
---|
177 | TComSlice * pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
178 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
179 | UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); |
---|
180 | UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); |
---|
181 | UInt uiGranularityWidth = g_uiMaxCUWidth; |
---|
182 | UInt uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
183 | UInt uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
184 | |
---|
185 | if(((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth)) |
---|
186 | &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight))) |
---|
187 | { |
---|
188 | m_pcEntropyDecoder->decodeTerminatingBit( uiIsLast ); |
---|
189 | } |
---|
190 | else |
---|
191 | { |
---|
192 | uiIsLast=0; |
---|
193 | } |
---|
194 | |
---|
195 | if(uiIsLast) |
---|
196 | { |
---|
197 | if(pcSlice->isNextSliceSegment()&&!pcSlice->isNextSlice()) |
---|
198 | { |
---|
199 | pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
200 | } |
---|
201 | else |
---|
202 | { |
---|
203 | pcSlice->setSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
204 | pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
205 | } |
---|
206 | } |
---|
207 | |
---|
208 | return uiIsLast>0; |
---|
209 | } |
---|
210 | |
---|
211 | /** decode CU block recursively |
---|
212 | * \param pcCU |
---|
213 | * \param uiAbsPartIdx |
---|
214 | * \param uiDepth |
---|
215 | * \returns Void |
---|
216 | */ |
---|
217 | |
---|
218 | Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast) |
---|
219 | { |
---|
220 | TComPic* pcPic = pcCU->getPic(); |
---|
221 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
222 | UInt uiQNumParts = uiCurNumParts>>2; |
---|
223 | |
---|
224 | Bool bBoundary = false; |
---|
225 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
226 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
227 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
228 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
229 | |
---|
230 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
231 | Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr(); |
---|
232 | if((!bStartInCU) && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
233 | { |
---|
234 | m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
235 | } |
---|
236 | else |
---|
237 | { |
---|
238 | bBoundary = true; |
---|
239 | } |
---|
240 | |
---|
241 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
242 | { |
---|
243 | UInt uiIdx = uiAbsPartIdx; |
---|
244 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
245 | { |
---|
246 | setdQPFlag(true); |
---|
247 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
248 | } |
---|
249 | |
---|
250 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
251 | { |
---|
252 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
253 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
254 | |
---|
255 | Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr(); |
---|
256 | if ( bSubInSlice ) |
---|
257 | { |
---|
258 | if ( !ruiIsLast && ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
259 | { |
---|
260 | xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast ); |
---|
261 | } |
---|
262 | else |
---|
263 | { |
---|
264 | pcCU->setOutsideCUPart( uiIdx, uiDepth+1 ); |
---|
265 | } |
---|
266 | } |
---|
267 | |
---|
268 | uiIdx += uiQNumParts; |
---|
269 | } |
---|
270 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
271 | { |
---|
272 | if ( getdQPFlag() ) |
---|
273 | { |
---|
274 | UInt uiQPSrcPartIdx; |
---|
275 | if ( pcPic->getCU( pcCU->getAddr() )->getSliceSegmentStartCU(uiAbsPartIdx) != pcSlice->getSliceSegmentCurStartCUAddr() ) |
---|
276 | { |
---|
277 | uiQPSrcPartIdx = pcSlice->getSliceSegmentCurStartCUAddr() % pcPic->getNumPartInCU(); |
---|
278 | } |
---|
279 | else |
---|
280 | { |
---|
281 | uiQPSrcPartIdx = uiAbsPartIdx; |
---|
282 | } |
---|
283 | pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
284 | } |
---|
285 | } |
---|
286 | return; |
---|
287 | } |
---|
288 | |
---|
289 | if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
290 | { |
---|
291 | setdQPFlag(true); |
---|
292 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
293 | } |
---|
294 | |
---|
295 | if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) |
---|
296 | { |
---|
297 | m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
298 | } |
---|
299 | |
---|
300 | // decode CU mode and the partition size |
---|
301 | if( !pcCU->getSlice()->isIntra()) |
---|
302 | { |
---|
303 | m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
304 | } |
---|
305 | |
---|
306 | if( pcCU->isSkipped(uiAbsPartIdx) ) |
---|
307 | { |
---|
308 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
309 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
310 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
311 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
312 | Int numValidMergeCand = 0; |
---|
313 | for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
314 | { |
---|
315 | uhInterDirNeighbours[ui] = 0; |
---|
316 | } |
---|
317 | m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth ); |
---|
318 | UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx); |
---|
319 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
320 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
321 | |
---|
322 | TComMv cTmpMv( 0, 0 ); |
---|
323 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
324 | { |
---|
325 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
326 | { |
---|
327 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
328 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
329 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
330 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
331 | } |
---|
332 | } |
---|
333 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
334 | return; |
---|
335 | } |
---|
336 | |
---|
337 | m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
338 | m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
339 | |
---|
340 | if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
---|
341 | { |
---|
342 | m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
343 | |
---|
344 | if(pcCU->getIPCMFlag(uiAbsPartIdx)) |
---|
345 | { |
---|
346 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
347 | return; |
---|
348 | } |
---|
349 | } |
---|
350 | |
---|
351 | UInt uiCurrWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
352 | UInt uiCurrHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
353 | |
---|
354 | // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
355 | m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); |
---|
356 | |
---|
357 | // Coefficient decoding |
---|
358 | Bool bCodeDQP = getdQPFlag(); |
---|
359 | m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP ); |
---|
360 | setdQPFlag( bCodeDQP ); |
---|
361 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
362 | } |
---|
363 | |
---|
364 | Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast) |
---|
365 | { |
---|
366 | if( pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
367 | { |
---|
368 | pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP |
---|
369 | } |
---|
370 | |
---|
371 | ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth); |
---|
372 | } |
---|
373 | |
---|
374 | Void TDecCu::xDecompressCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
375 | { |
---|
376 | TComPic* pcPic = pcCU->getPic(); |
---|
377 | |
---|
378 | Bool bBoundary = false; |
---|
379 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
380 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
381 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
382 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
383 | |
---|
384 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
385 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
386 | Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr(); |
---|
387 | if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
388 | { |
---|
389 | bBoundary = true; |
---|
390 | } |
---|
391 | |
---|
392 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
393 | { |
---|
394 | UInt uiNextDepth = uiDepth + 1; |
---|
395 | UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1); |
---|
396 | UInt uiIdx = uiAbsPartIdx; |
---|
397 | for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ ) |
---|
398 | { |
---|
399 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
400 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
401 | |
---|
402 | Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getSliceSegmentCurEndCUAddr()); |
---|
403 | if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
404 | { |
---|
405 | xDecompressCU(pcCU, uiIdx, uiNextDepth ); |
---|
406 | } |
---|
407 | |
---|
408 | uiIdx += uiQNumParts; |
---|
409 | } |
---|
410 | return; |
---|
411 | } |
---|
412 | |
---|
413 | // Residual reconstruction |
---|
414 | m_ppcYuvResi[uiDepth]->clear(); |
---|
415 | |
---|
416 | m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth ); |
---|
417 | |
---|
418 | switch( m_ppcCU[uiDepth]->getPredictionMode(0) ) |
---|
419 | { |
---|
420 | case MODE_INTER: |
---|
421 | xReconInter( m_ppcCU[uiDepth], uiDepth ); |
---|
422 | break; |
---|
423 | case MODE_INTRA: |
---|
424 | xReconIntraQT( m_ppcCU[uiDepth], uiDepth ); |
---|
425 | break; |
---|
426 | default: |
---|
427 | assert(0); |
---|
428 | break; |
---|
429 | } |
---|
430 | if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false)) |
---|
431 | { |
---|
432 | xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth); |
---|
433 | } |
---|
434 | |
---|
435 | xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth ); |
---|
436 | } |
---|
437 | |
---|
438 | Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth ) |
---|
439 | { |
---|
440 | |
---|
441 | // inter prediction |
---|
442 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
443 | |
---|
444 | // inter recon |
---|
445 | xDecodeInterTexture( pcCU, 0, uiDepth ); |
---|
446 | |
---|
447 | // clip for only non-zero cbp case |
---|
448 | if ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) ) |
---|
449 | { |
---|
450 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
451 | } |
---|
452 | else |
---|
453 | { |
---|
454 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
455 | } |
---|
456 | } |
---|
457 | |
---|
458 | Void |
---|
459 | TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU, |
---|
460 | UInt uiTrDepth, |
---|
461 | UInt uiAbsPartIdx, |
---|
462 | TComYuv* pcRecoYuv, |
---|
463 | TComYuv* pcPredYuv, |
---|
464 | TComYuv* pcResiYuv ) |
---|
465 | { |
---|
466 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> uiTrDepth; |
---|
467 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> uiTrDepth; |
---|
468 | UInt uiStride = pcRecoYuv->getStride (); |
---|
469 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
470 | Pel* piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
471 | Pel* piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
472 | |
---|
473 | UInt uiNumCoeffInc = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ); |
---|
474 | TCoeff* pcCoeff = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
475 | |
---|
476 | UInt uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
477 | |
---|
478 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
479 | Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
480 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
481 | Bool useTransformSkip = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA); |
---|
482 | //===== init availability pattern ===== |
---|
483 | Bool bAboveAvail = false; |
---|
484 | Bool bLeftAvail = false; |
---|
485 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
486 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
487 | m_pcPrediction->getPredicBuf (), |
---|
488 | m_pcPrediction->getPredicBufWidth (), |
---|
489 | m_pcPrediction->getPredicBufHeight (), |
---|
490 | bAboveAvail, bLeftAvail ); |
---|
491 | |
---|
492 | //===== get prediction signal ===== |
---|
493 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
494 | |
---|
495 | //===== inverse transform ===== |
---|
496 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
497 | |
---|
498 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA]; |
---|
499 | assert(scalingListType < 6); |
---|
500 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip ); |
---|
501 | |
---|
502 | |
---|
503 | //===== reconstruction ===== |
---|
504 | Pel* pPred = piPred; |
---|
505 | Pel* pResi = piResi; |
---|
506 | Pel* pReco = piReco; |
---|
507 | Pel* pRecIPred = piRecIPred; |
---|
508 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
509 | { |
---|
510 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
511 | { |
---|
512 | pReco [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] ); |
---|
513 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
514 | } |
---|
515 | pPred += uiStride; |
---|
516 | pResi += uiStride; |
---|
517 | pReco += uiStride; |
---|
518 | pRecIPred += uiRecIPredStride; |
---|
519 | } |
---|
520 | } |
---|
521 | |
---|
522 | |
---|
523 | Void |
---|
524 | TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU, |
---|
525 | UInt uiTrDepth, |
---|
526 | UInt uiAbsPartIdx, |
---|
527 | TComYuv* pcRecoYuv, |
---|
528 | TComYuv* pcPredYuv, |
---|
529 | TComYuv* pcResiYuv, |
---|
530 | UInt uiChromaId ) |
---|
531 | { |
---|
532 | UInt uiFullDepth = pcCU->getDepth( 0 ) + uiTrDepth; |
---|
533 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2; |
---|
534 | |
---|
535 | if( uiLog2TrSize == 2 ) |
---|
536 | { |
---|
537 | assert( uiTrDepth > 0 ); |
---|
538 | uiTrDepth--; |
---|
539 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 ); |
---|
540 | Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 ); |
---|
541 | if( !bFirstQ ) |
---|
542 | { |
---|
543 | return; |
---|
544 | } |
---|
545 | } |
---|
546 | |
---|
547 | TextType eText = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U ); |
---|
548 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> ( uiTrDepth + 1 ); |
---|
549 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> ( uiTrDepth + 1 ); |
---|
550 | UInt uiStride = pcRecoYuv->getCStride (); |
---|
551 | Pel* piReco = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
552 | Pel* piPred = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
553 | Pel* piResi = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
554 | |
---|
555 | UInt uiNumCoeffInc = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2; |
---|
556 | TCoeff* pcCoeff = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
557 | |
---|
558 | UInt uiChromaPredMode = pcCU->getChromaIntraDir( 0 ); |
---|
559 | |
---|
560 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
561 | Pel* piRecIPred = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) ); |
---|
562 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
563 | Bool useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText); |
---|
564 | //===== init availability pattern ===== |
---|
565 | Bool bAboveAvail = false; |
---|
566 | Bool bLeftAvail = false; |
---|
567 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
568 | |
---|
569 | pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
570 | m_pcPrediction->getPredicBuf (), |
---|
571 | m_pcPrediction->getPredicBufWidth (), |
---|
572 | m_pcPrediction->getPredicBufHeight (), |
---|
573 | bAboveAvail, bLeftAvail ); |
---|
574 | Int* pPatChroma = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) ); |
---|
575 | |
---|
576 | //===== get prediction signal ===== |
---|
577 | if( uiChromaPredMode == DM_CHROMA_IDX ) |
---|
578 | { |
---|
579 | uiChromaPredMode = pcCU->getLumaIntraDir( 0 ); |
---|
580 | } |
---|
581 | m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
582 | |
---|
583 | //===== inverse transform ===== |
---|
584 | Int curChromaQpOffset; |
---|
585 | if(eText == TEXT_CHROMA_U) |
---|
586 | { |
---|
587 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
---|
588 | } |
---|
589 | else |
---|
590 | { |
---|
591 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
---|
592 | } |
---|
593 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
594 | |
---|
595 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText]; |
---|
596 | assert(scalingListType < 6); |
---|
597 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma ); |
---|
598 | |
---|
599 | //===== reconstruction ===== |
---|
600 | Pel* pPred = piPred; |
---|
601 | Pel* pResi = piResi; |
---|
602 | Pel* pReco = piReco; |
---|
603 | Pel* pRecIPred = piRecIPred; |
---|
604 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
605 | { |
---|
606 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
607 | { |
---|
608 | pReco [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] ); |
---|
609 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
610 | } |
---|
611 | pPred += uiStride; |
---|
612 | pResi += uiStride; |
---|
613 | pReco += uiStride; |
---|
614 | pRecIPred += uiRecIPredStride; |
---|
615 | } |
---|
616 | } |
---|
617 | |
---|
618 | |
---|
619 | Void |
---|
620 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth ) |
---|
621 | { |
---|
622 | UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 ); |
---|
623 | UInt uiNumPart = pcCU->getNumPartInter(); |
---|
624 | UInt uiNumQParts = pcCU->getTotalNumPart() >> 2; |
---|
625 | |
---|
626 | if (pcCU->getIPCMFlag(0)) |
---|
627 | { |
---|
628 | xReconPCM( pcCU, uiDepth ); |
---|
629 | return; |
---|
630 | } |
---|
631 | |
---|
632 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
633 | { |
---|
634 | xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
635 | } |
---|
636 | |
---|
637 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
638 | { |
---|
639 | xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
640 | } |
---|
641 | |
---|
642 | } |
---|
643 | |
---|
644 | /** Function for deriving recontructed PU/CU Luma sample with QTree structure |
---|
645 | * \param pcCU pointer of current CU |
---|
646 | * \param uiTrDepth current tranform split depth |
---|
647 | * \param uiAbsPartIdx part index |
---|
648 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
649 | * \param pcPredYuv pointer to prediction sample arrays |
---|
650 | * \param pcResiYuv pointer to residue sample arrays |
---|
651 | * |
---|
652 | \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure |
---|
653 | */ |
---|
654 | Void |
---|
655 | TDecCu::xIntraLumaRecQT( TComDataCU* pcCU, |
---|
656 | UInt uiTrDepth, |
---|
657 | UInt uiAbsPartIdx, |
---|
658 | TComYuv* pcRecoYuv, |
---|
659 | TComYuv* pcPredYuv, |
---|
660 | TComYuv* pcResiYuv ) |
---|
661 | { |
---|
662 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
663 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
664 | if( uiTrMode == uiTrDepth ) |
---|
665 | { |
---|
666 | xIntraRecLumaBlk ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
667 | } |
---|
668 | else |
---|
669 | { |
---|
670 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
671 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
672 | { |
---|
673 | xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
674 | } |
---|
675 | } |
---|
676 | } |
---|
677 | |
---|
678 | /** Function for deriving recontructed PU/CU chroma samples with QTree structure |
---|
679 | * \param pcCU pointer of current CU |
---|
680 | * \param uiTrDepth current tranform split depth |
---|
681 | * \param uiAbsPartIdx part index |
---|
682 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
683 | * \param pcPredYuv pointer to prediction sample arrays |
---|
684 | * \param pcResiYuv pointer to residue sample arrays |
---|
685 | * |
---|
686 | \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure |
---|
687 | */ |
---|
688 | Void |
---|
689 | TDecCu::xIntraChromaRecQT( TComDataCU* pcCU, |
---|
690 | UInt uiTrDepth, |
---|
691 | UInt uiAbsPartIdx, |
---|
692 | TComYuv* pcRecoYuv, |
---|
693 | TComYuv* pcPredYuv, |
---|
694 | TComYuv* pcResiYuv ) |
---|
695 | { |
---|
696 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
697 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
698 | if( uiTrMode == uiTrDepth ) |
---|
699 | { |
---|
700 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 ); |
---|
701 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 ); |
---|
702 | } |
---|
703 | else |
---|
704 | { |
---|
705 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
706 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
707 | { |
---|
708 | xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
709 | } |
---|
710 | } |
---|
711 | } |
---|
712 | |
---|
713 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
714 | { |
---|
715 | UInt uiCUAddr = pcCU->getAddr(); |
---|
716 | |
---|
717 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx ); |
---|
718 | |
---|
719 | return; |
---|
720 | } |
---|
721 | |
---|
722 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
723 | { |
---|
724 | UInt uiWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
725 | UInt uiHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
726 | TCoeff* piCoeff; |
---|
727 | |
---|
728 | Pel* pResi; |
---|
729 | UInt trMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
730 | |
---|
731 | // Y |
---|
732 | piCoeff = pcCU->getCoeffY(); |
---|
733 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr(); |
---|
734 | |
---|
735 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
736 | |
---|
737 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
738 | |
---|
739 | // Cb and Cr |
---|
740 | Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
---|
741 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
742 | |
---|
743 | uiWidth >>= 1; |
---|
744 | uiHeight >>= 1; |
---|
745 | piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr(); |
---|
746 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
747 | |
---|
748 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
---|
749 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
750 | |
---|
751 | piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr(); |
---|
752 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
753 | } |
---|
754 | |
---|
755 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
---|
756 | * \param pcCU pointer to current CU |
---|
757 | * \param uiPartIdx part index |
---|
758 | * \param piPCM pointer to PCM code arrays |
---|
759 | * \param piReco pointer to reconstructed sample arrays |
---|
760 | * \param uiStride stride of reconstructed sample arrays |
---|
761 | * \param uiWidth CU width |
---|
762 | * \param uiHeight CU height |
---|
763 | * \param ttText texture component type |
---|
764 | * \returns Void |
---|
765 | */ |
---|
766 | Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText) |
---|
767 | { |
---|
768 | UInt uiX, uiY; |
---|
769 | Pel* piPicReco; |
---|
770 | UInt uiPicStride; |
---|
771 | UInt uiPcmLeftShiftBit; |
---|
772 | |
---|
773 | if( ttText == TEXT_LUMA ) |
---|
774 | { |
---|
775 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(); |
---|
776 | piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
777 | uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
778 | } |
---|
779 | else |
---|
780 | { |
---|
781 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
782 | |
---|
783 | if( ttText == TEXT_CHROMA_U ) |
---|
784 | { |
---|
785 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
786 | } |
---|
787 | else |
---|
788 | { |
---|
789 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
790 | } |
---|
791 | uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
792 | } |
---|
793 | |
---|
794 | for( uiY = 0; uiY < uiHeight; uiY++ ) |
---|
795 | { |
---|
796 | for( uiX = 0; uiX < uiWidth; uiX++ ) |
---|
797 | { |
---|
798 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
---|
799 | piPicReco[uiX] = piReco[uiX]; |
---|
800 | } |
---|
801 | piPCM += uiWidth; |
---|
802 | piReco += uiStride; |
---|
803 | piPicReco += uiPicStride; |
---|
804 | } |
---|
805 | } |
---|
806 | |
---|
807 | /** Function for reconstructing a PCM mode CU. |
---|
808 | * \param pcCU pointer to current CU |
---|
809 | * \param uiDepth CU Depth |
---|
810 | * \returns Void |
---|
811 | */ |
---|
812 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth ) |
---|
813 | { |
---|
814 | // Luma |
---|
815 | UInt uiWidth = (g_uiMaxCUWidth >> uiDepth); |
---|
816 | UInt uiHeight = (g_uiMaxCUHeight >> uiDepth); |
---|
817 | |
---|
818 | Pel* piPcmY = pcCU->getPCMSampleY(); |
---|
819 | Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth); |
---|
820 | |
---|
821 | UInt uiStride = m_ppcYuvResi[uiDepth]->getStride(); |
---|
822 | |
---|
823 | xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA); |
---|
824 | |
---|
825 | // Cb and Cr |
---|
826 | UInt uiCWidth = (uiWidth>>1); |
---|
827 | UInt uiCHeight = (uiHeight>>1); |
---|
828 | |
---|
829 | Pel* piPcmCb = pcCU->getPCMSampleCb(); |
---|
830 | Pel* piPcmCr = pcCU->getPCMSampleCr(); |
---|
831 | Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
---|
832 | Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
---|
833 | |
---|
834 | UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride(); |
---|
835 | |
---|
836 | xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U); |
---|
837 | xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V); |
---|
838 | } |
---|
839 | |
---|
840 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
---|
841 | * \param pcCU pointer to current CU |
---|
842 | * \param uiDepth CU Depth |
---|
843 | * \returns Void |
---|
844 | */ |
---|
845 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth) |
---|
846 | { |
---|
847 | // Luma |
---|
848 | UInt width = (g_uiMaxCUWidth >> depth); |
---|
849 | UInt height = (g_uiMaxCUHeight >> depth); |
---|
850 | |
---|
851 | Pel* pPcmY = pCU->getPCMSampleY(); |
---|
852 | Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width); |
---|
853 | |
---|
854 | UInt stride = m_ppcYuvReco[depth]->getStride(); |
---|
855 | |
---|
856 | for(Int y = 0; y < height; y++ ) |
---|
857 | { |
---|
858 | for(Int x = 0; x < width; x++ ) |
---|
859 | { |
---|
860 | pPcmY[x] = pRecoY[x]; |
---|
861 | } |
---|
862 | pPcmY += width; |
---|
863 | pRecoY += stride; |
---|
864 | } |
---|
865 | |
---|
866 | // Cb and Cr |
---|
867 | UInt widthC = (width>>1); |
---|
868 | UInt heightC = (height>>1); |
---|
869 | |
---|
870 | Pel* pPcmCb = pCU->getPCMSampleCb(); |
---|
871 | Pel* pPcmCr = pCU->getPCMSampleCr(); |
---|
872 | Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr(); |
---|
873 | Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr(); |
---|
874 | |
---|
875 | UInt strideC = m_ppcYuvReco[depth]->getCStride(); |
---|
876 | |
---|
877 | for(Int y = 0; y < heightC; y++ ) |
---|
878 | { |
---|
879 | for(Int x = 0; x < widthC; x++ ) |
---|
880 | { |
---|
881 | pPcmCb[x] = pRecoCb[x]; |
---|
882 | pPcmCr[x] = pRecoCr[x]; |
---|
883 | } |
---|
884 | pPcmCr += widthC; |
---|
885 | pPcmCb += widthC; |
---|
886 | pRecoCb += strideC; |
---|
887 | pRecoCr += strideC; |
---|
888 | } |
---|
889 | |
---|
890 | } |
---|
891 | //! \} |
---|