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