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-2012, 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 | #if RWTH_SDC_DLT_B0036 |
---|
41 | #define GetDepthValue2Idx(val) (pcCU->getSlice()->getSPS()->depthValue2idx(val)) |
---|
42 | #define GetIdx2DepthValue(val) (pcCU->getSlice()->getSPS()->idx2DepthValue(val)) |
---|
43 | #endif |
---|
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 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
57 | m_ppcYuvResPred = NULL; |
---|
58 | #endif |
---|
59 | m_ppcCU = NULL; |
---|
60 | } |
---|
61 | |
---|
62 | TDecCu::~TDecCu() |
---|
63 | { |
---|
64 | } |
---|
65 | |
---|
66 | Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction) |
---|
67 | { |
---|
68 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
69 | m_pcTrQuant = pcTrQuant; |
---|
70 | m_pcPrediction = pcPrediction; |
---|
71 | } |
---|
72 | |
---|
73 | /** |
---|
74 | \param uiMaxDepth total number of allowable depth |
---|
75 | \param uiMaxWidth largest CU width |
---|
76 | \param uiMaxHeight largest CU height |
---|
77 | */ |
---|
78 | Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight ) |
---|
79 | { |
---|
80 | m_uiMaxDepth = uiMaxDepth+1; |
---|
81 | |
---|
82 | m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1]; |
---|
83 | m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1]; |
---|
84 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
85 | m_ppcYuvResPred = new TComYuv* [m_uiMaxDepth-1]; |
---|
86 | #endif |
---|
87 | m_ppcCU = new TComDataCU*[m_uiMaxDepth-1]; |
---|
88 | |
---|
89 | UInt uiNumPartitions; |
---|
90 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
91 | { |
---|
92 | uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 ); |
---|
93 | UInt uiWidth = uiMaxWidth >> ui; |
---|
94 | UInt uiHeight = uiMaxHeight >> ui; |
---|
95 | |
---|
96 | m_ppcYuvResi[ui] = new TComYuv; m_ppcYuvResi[ui]->create( uiWidth, uiHeight ); |
---|
97 | m_ppcYuvReco[ui] = new TComYuv; m_ppcYuvReco[ui]->create( uiWidth, uiHeight ); |
---|
98 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
99 | m_ppcYuvResPred[ui] = new TComYuv; m_ppcYuvResPred[ui]->create( uiWidth, uiHeight ); |
---|
100 | #endif |
---|
101 | m_ppcCU [ui] = new TComDataCU; m_ppcCU [ui]->create( uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) ); |
---|
102 | } |
---|
103 | |
---|
104 | m_bDecodeDQP = false; |
---|
105 | |
---|
106 | // initialize partition order. |
---|
107 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
108 | initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp); |
---|
109 | initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
110 | |
---|
111 | // initialize conversion matrix from partition index to pel |
---|
112 | initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
113 | initMotionReferIdx ( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
114 | } |
---|
115 | |
---|
116 | Void TDecCu::destroy() |
---|
117 | { |
---|
118 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
119 | { |
---|
120 | m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL; |
---|
121 | m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL; |
---|
122 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
123 | m_ppcYuvResPred[ui]->destroy(); delete m_ppcYuvResPred[ui]; m_ppcYuvResPred[ui] = NULL; |
---|
124 | #endif |
---|
125 | m_ppcCU [ui]->destroy(); delete m_ppcCU [ui]; m_ppcCU [ui] = NULL; |
---|
126 | } |
---|
127 | |
---|
128 | delete [] m_ppcYuvResi; m_ppcYuvResi = NULL; |
---|
129 | delete [] m_ppcYuvReco; m_ppcYuvReco = NULL; |
---|
130 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
131 | delete [] m_ppcYuvResPred; m_ppcYuvResPred = NULL; |
---|
132 | #endif |
---|
133 | delete [] m_ppcCU ; m_ppcCU = NULL; |
---|
134 | } |
---|
135 | |
---|
136 | // ==================================================================================================================== |
---|
137 | // Public member functions |
---|
138 | // ==================================================================================================================== |
---|
139 | |
---|
140 | /** \param pcCU pointer of CU data |
---|
141 | \param ruiIsLast last data? |
---|
142 | */ |
---|
143 | Void TDecCu::decodeCU( TComDataCU* pcCU, UInt& ruiIsLast ) |
---|
144 | { |
---|
145 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
146 | { |
---|
147 | setdQPFlag(true); |
---|
148 | } |
---|
149 | |
---|
150 | #if BURST_IPCM |
---|
151 | pcCU->setNumSucIPCM(0); |
---|
152 | #endif |
---|
153 | |
---|
154 | // start from the top level CU |
---|
155 | xDecodeCU( pcCU, 0, 0, ruiIsLast); |
---|
156 | } |
---|
157 | |
---|
158 | /** \param pcCU pointer of CU data |
---|
159 | */ |
---|
160 | Void TDecCu::decompressCU( TComDataCU* pcCU ) |
---|
161 | { |
---|
162 | xDecompressCU( pcCU, pcCU, 0, 0 ); |
---|
163 | } |
---|
164 | |
---|
165 | // ==================================================================================================================== |
---|
166 | // Protected member functions |
---|
167 | // ==================================================================================================================== |
---|
168 | |
---|
169 | /**decode end-of-slice flag |
---|
170 | * \param pcCU |
---|
171 | * \param uiAbsPartIdx |
---|
172 | * \param uiDepth |
---|
173 | * \returns Bool |
---|
174 | */ |
---|
175 | Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth) { |
---|
176 | UInt uiIsLast; |
---|
177 | TComPic* pcPic = pcCU->getPic(); |
---|
178 | TComSlice * pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
179 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
180 | UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); |
---|
181 | UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); |
---|
182 | UInt uiGranularityWidth = g_uiMaxCUWidth>>(pcSlice->getPPS()->getSliceGranularity()); |
---|
183 | UInt uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
184 | UInt uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
185 | |
---|
186 | #if HHI_MPI |
---|
187 | const UInt uiCUWidth = pcCU->getTextureModeDepth( uiAbsPartIdx ) != -1 ? g_uiMaxCUWidth>>uiDepth : pcCU->getWidth (uiAbsPartIdx); |
---|
188 | const UInt uiCUHeight = pcCU->getTextureModeDepth( uiAbsPartIdx ) != -1 ? g_uiMaxCUHeight>>uiDepth : pcCU->getHeight(uiAbsPartIdx); |
---|
189 | if(((uiPosX+uiCUWidth)%uiGranularityWidth==0||(uiPosX+uiCUWidth==uiWidth)) |
---|
190 | &&((uiPosY+uiCUHeight)%uiGranularityWidth==0||(uiPosY+uiCUHeight==uiHeight))) |
---|
191 | #else |
---|
192 | if(((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth)) |
---|
193 | &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight))) |
---|
194 | #endif |
---|
195 | { |
---|
196 | m_pcEntropyDecoder->decodeTerminatingBit( uiIsLast ); |
---|
197 | } |
---|
198 | else |
---|
199 | { |
---|
200 | uiIsLast=0; |
---|
201 | } |
---|
202 | |
---|
203 | if(uiIsLast) |
---|
204 | { |
---|
205 | if(pcSlice->isNextEntropySlice()&&!pcSlice->isNextSlice()) |
---|
206 | { |
---|
207 | pcSlice->setEntropySliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
208 | } |
---|
209 | else |
---|
210 | { |
---|
211 | pcSlice->setSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
212 | pcSlice->setEntropySliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
213 | } |
---|
214 | } |
---|
215 | |
---|
216 | return uiIsLast>0; |
---|
217 | } |
---|
218 | |
---|
219 | /** decode CU block recursively |
---|
220 | * \param pcCU |
---|
221 | * \param uiAbsPartIdx |
---|
222 | * \param uiDepth |
---|
223 | * \returns Void |
---|
224 | */ |
---|
225 | |
---|
226 | Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast) |
---|
227 | { |
---|
228 | TComPic* pcPic = pcCU->getPic(); |
---|
229 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
230 | UInt uiQNumParts = uiCurNumParts>>2; |
---|
231 | |
---|
232 | Bool bBoundary = false; |
---|
233 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
234 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
235 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
236 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
237 | |
---|
238 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
239 | Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getEntropySliceCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getEntropySliceCurStartCUAddr(); |
---|
240 | if((!bStartInCU) && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
241 | { |
---|
242 | #if BURST_IPCM |
---|
243 | if(pcCU->getNumSucIPCM() == 0) |
---|
244 | { |
---|
245 | #if HHI_MPI |
---|
246 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth < pcCU->getTextureModeDepth( uiAbsPartIdx ) ) |
---|
247 | #endif |
---|
248 | m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
249 | } |
---|
250 | else |
---|
251 | { |
---|
252 | pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx ); |
---|
253 | } |
---|
254 | #else |
---|
255 | #if HHI_MPI |
---|
256 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 || uiDepth < pcCU->getTextureModeDepth( uiAbsPartIdx ) ) |
---|
257 | #endif |
---|
258 | m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
259 | #endif |
---|
260 | } |
---|
261 | else |
---|
262 | { |
---|
263 | bBoundary = true; |
---|
264 | } |
---|
265 | |
---|
266 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
267 | { |
---|
268 | UInt uiIdx = uiAbsPartIdx; |
---|
269 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
270 | { |
---|
271 | setdQPFlag(true); |
---|
272 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
273 | } |
---|
274 | |
---|
275 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
276 | { |
---|
277 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
278 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
279 | |
---|
280 | Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getEntropySliceCurStartCUAddr(); |
---|
281 | if ( bSubInSlice ) |
---|
282 | { |
---|
283 | if ( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
284 | { |
---|
285 | xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast ); |
---|
286 | } |
---|
287 | else |
---|
288 | { |
---|
289 | pcCU->setOutsideCUPart( uiIdx, uiDepth+1 ); |
---|
290 | } |
---|
291 | } |
---|
292 | if(ruiIsLast) |
---|
293 | { |
---|
294 | break; |
---|
295 | } |
---|
296 | |
---|
297 | uiIdx += uiQNumParts; |
---|
298 | } |
---|
299 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
300 | { |
---|
301 | if ( getdQPFlag() ) |
---|
302 | { |
---|
303 | UInt uiQPSrcPartIdx; |
---|
304 | if ( pcPic->getCU( pcCU->getAddr() )->getEntropySliceStartCU(uiAbsPartIdx) != pcSlice->getEntropySliceCurStartCUAddr() ) |
---|
305 | { |
---|
306 | uiQPSrcPartIdx = pcSlice->getEntropySliceCurStartCUAddr() % pcPic->getNumPartInCU(); |
---|
307 | } |
---|
308 | else |
---|
309 | { |
---|
310 | uiQPSrcPartIdx = uiAbsPartIdx; |
---|
311 | } |
---|
312 | pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
313 | } |
---|
314 | } |
---|
315 | return; |
---|
316 | } |
---|
317 | |
---|
318 | if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
319 | { |
---|
320 | setdQPFlag(true); |
---|
321 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
322 | } |
---|
323 | |
---|
324 | // decode CU mode and the partition size |
---|
325 | #if BURST_IPCM |
---|
326 | if( !pcCU->getSlice()->isIntra() && pcCU->getNumSucIPCM() == 0 ) |
---|
327 | #else |
---|
328 | if( !pcCU->getSlice()->isIntra() ) |
---|
329 | #endif |
---|
330 | #if HHI_MPI |
---|
331 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 ) |
---|
332 | #endif |
---|
333 | { |
---|
334 | m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
335 | } |
---|
336 | |
---|
337 | if( pcCU->isSkipped(uiAbsPartIdx) ) |
---|
338 | { |
---|
339 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
340 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
341 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
342 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
---|
343 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
---|
344 | Int numValidMergeCand = 0; |
---|
345 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS_MEM; ++ui ) |
---|
346 | #else |
---|
347 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
348 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
349 | Int numValidMergeCand = 0; |
---|
350 | for( UInt ui = 0; ui < MRG_MAX_NUM_CANDS; ++ui ) |
---|
351 | #endif |
---|
352 | { |
---|
353 | uhInterDirNeighbours[ui] = 0; |
---|
354 | } |
---|
355 | m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, SIZE_2Nx2N, uhInterDirNeighbours, cMvFieldNeighbours, uiDepth ); |
---|
356 | #if HHI_MPI |
---|
357 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == uiDepth ) |
---|
358 | { |
---|
359 | TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() ); |
---|
360 | pcCU->copyTextureMotionDataFrom( pcTextureCU, uiDepth, pcCU->getZorderIdxInCU() + uiAbsPartIdx, uiAbsPartIdx ); |
---|
361 | |
---|
362 | UInt uiCurrPartNumb = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
363 | for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
364 | { |
---|
365 | const UChar uhNewDepth = max<UInt>( uiDepth, pcTextureCU->getDepth( uiAbsPartIdx + ui ) ); |
---|
366 | pcCU->setPredictionMode( uiAbsPartIdx + ui, MODE_SKIP ); |
---|
367 | pcCU->setPartitionSize( uiAbsPartIdx + ui, SIZE_2Nx2N ); |
---|
368 | pcCU->setDepth( uiAbsPartIdx + ui, uhNewDepth ); |
---|
369 | pcCU->setWidth( uiAbsPartIdx + ui, g_uiMaxCUWidth>>uhNewDepth ); |
---|
370 | pcCU->setHeight( uiAbsPartIdx + ui, g_uiMaxCUHeight>>uhNewDepth ); |
---|
371 | } |
---|
372 | } |
---|
373 | else |
---|
374 | { |
---|
375 | #endif |
---|
376 | #if SIMP_MRG_PRUN |
---|
377 | UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx); |
---|
378 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
379 | #else |
---|
380 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand ); |
---|
381 | UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx); |
---|
382 | #endif |
---|
383 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
384 | |
---|
385 | TComMv cTmpMv( 0, 0 ); |
---|
386 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
387 | { |
---|
388 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
389 | { |
---|
390 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
391 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
392 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
393 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
394 | } |
---|
395 | } |
---|
396 | #if LGE_ILLUCOMP_B0045 |
---|
397 | m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
398 | #endif |
---|
399 | #if HHI_MPI |
---|
400 | } |
---|
401 | #endif |
---|
402 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
403 | m_pcEntropyDecoder->decodeResPredFlag( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth], 0 ); |
---|
404 | #endif |
---|
405 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
406 | return; |
---|
407 | } |
---|
408 | |
---|
409 | #if HHI_MPI |
---|
410 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == -1 ) |
---|
411 | { |
---|
412 | #endif |
---|
413 | #if BURST_IPCM |
---|
414 | if( pcCU->getNumSucIPCM() == 0 ) |
---|
415 | { |
---|
416 | m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
417 | m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
418 | } |
---|
419 | else |
---|
420 | { |
---|
421 | pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth ); |
---|
422 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
423 | pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth ); |
---|
424 | pcCU->setTrIdxSubParts( 0, uiAbsPartIdx, uiDepth ); |
---|
425 | } |
---|
426 | #else |
---|
427 | m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
428 | m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
429 | #endif |
---|
430 | |
---|
431 | if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
---|
432 | { |
---|
433 | m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
434 | |
---|
435 | if(pcCU->getIPCMFlag(uiAbsPartIdx)) |
---|
436 | { |
---|
437 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
438 | return; |
---|
439 | } |
---|
440 | } |
---|
441 | |
---|
442 | #if ! HHI_MPI |
---|
443 | UInt uiCurrWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
444 | UInt uiCurrHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
445 | #endif |
---|
446 | |
---|
447 | // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
448 | m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); |
---|
449 | |
---|
450 | #if LGE_ILLUCOMP_B0045 |
---|
451 | m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
452 | #endif |
---|
453 | |
---|
454 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
455 | if( !pcCU->isIntra( uiAbsPartIdx ) ) |
---|
456 | { |
---|
457 | m_pcEntropyDecoder->decodeResPredFlag ( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth], 0 ); |
---|
458 | } |
---|
459 | #endif |
---|
460 | |
---|
461 | #if HHI_MPI |
---|
462 | if( pcCU->getTextureModeDepth( uiAbsPartIdx ) == uiDepth ) |
---|
463 | { |
---|
464 | assert( pcCU->getZorderIdxInCU() == 0 ); |
---|
465 | TComDataCU *pcTextureCU = pcCU->getSlice()->getTexturePic()->getCU( pcCU->getAddr() ); |
---|
466 | pcCU->copyTextureMotionDataFrom( pcTextureCU, uiDepth, pcCU->getZorderIdxInCU() + uiAbsPartIdx, uiAbsPartIdx ); |
---|
467 | |
---|
468 | UInt uiCurrPartNumb = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1); |
---|
469 | for( UInt ui = 0; ui < uiCurrPartNumb; ui++ ) |
---|
470 | { |
---|
471 | const UChar uhNewDepth = max<UInt>( uiDepth, pcTextureCU->getDepth( uiAbsPartIdx + ui ) ); |
---|
472 | pcCU->setPredictionMode( uiAbsPartIdx + ui, MODE_INTER ); |
---|
473 | pcCU->setPartitionSize( uiAbsPartIdx + ui, SIZE_2Nx2N ); |
---|
474 | pcCU->setDepth( uiAbsPartIdx + ui, uhNewDepth ); |
---|
475 | pcCU->setWidth( uiAbsPartIdx + ui, g_uiMaxCUWidth>>uhNewDepth ); |
---|
476 | pcCU->setHeight( uiAbsPartIdx + ui, g_uiMaxCUHeight>>uhNewDepth ); |
---|
477 | } |
---|
478 | |
---|
479 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
480 | { |
---|
481 | UInt uiIdx = uiAbsPartIdx; |
---|
482 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
483 | { |
---|
484 | setdQPFlag(true); |
---|
485 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
486 | } |
---|
487 | |
---|
488 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
489 | { |
---|
490 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
491 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
492 | |
---|
493 | Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getEntropySliceCurStartCUAddr(); |
---|
494 | if ( bSubInSlice ) |
---|
495 | { |
---|
496 | if ( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
497 | { |
---|
498 | xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast ); |
---|
499 | } |
---|
500 | else |
---|
501 | { |
---|
502 | pcCU->setOutsideCUPart( uiIdx, uiDepth+1 ); |
---|
503 | } |
---|
504 | } |
---|
505 | if(ruiIsLast) |
---|
506 | { |
---|
507 | break; |
---|
508 | } |
---|
509 | uiIdx += uiQNumParts; |
---|
510 | } |
---|
511 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
512 | { |
---|
513 | if ( getdQPFlag() ) |
---|
514 | { |
---|
515 | UInt uiQPSrcPartIdx; |
---|
516 | if ( pcPic->getCU( pcCU->getAddr() )->getEntropySliceStartCU(uiAbsPartIdx) != pcSlice->getEntropySliceCurStartCUAddr() ) |
---|
517 | { |
---|
518 | uiQPSrcPartIdx = pcSlice->getEntropySliceCurStartCUAddr() % pcPic->getNumPartInCU(); |
---|
519 | } |
---|
520 | else |
---|
521 | { |
---|
522 | uiQPSrcPartIdx = uiAbsPartIdx; |
---|
523 | } |
---|
524 | pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
525 | } |
---|
526 | } |
---|
527 | return; |
---|
528 | } |
---|
529 | } |
---|
530 | } |
---|
531 | |
---|
532 | UInt uiCurrWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
533 | UInt uiCurrHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
534 | #endif |
---|
535 | |
---|
536 | // Coefficient decoding |
---|
537 | Bool bCodeDQP = getdQPFlag(); |
---|
538 | m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP ); |
---|
539 | setdQPFlag( bCodeDQP ); |
---|
540 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
541 | } |
---|
542 | |
---|
543 | Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast) |
---|
544 | { |
---|
545 | if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
546 | { |
---|
547 | if( getdQPFlag() ) |
---|
548 | { |
---|
549 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
550 | } |
---|
551 | } |
---|
552 | |
---|
553 | #if BURST_IPCM |
---|
554 | if( pcCU->getNumSucIPCM() > 0 ) |
---|
555 | { |
---|
556 | ruiIsLast = 0; |
---|
557 | return; |
---|
558 | } |
---|
559 | #endif |
---|
560 | |
---|
561 | ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth); |
---|
562 | } |
---|
563 | |
---|
564 | Void TDecCu::xDecompressCU( TComDataCU* pcCU, TComDataCU* pcCUCur, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
565 | { |
---|
566 | TComPic* pcPic = pcCU->getPic(); |
---|
567 | |
---|
568 | Bool bBoundary = false; |
---|
569 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
570 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
571 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
572 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
573 | |
---|
574 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
575 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
576 | Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getEntropySliceCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getEntropySliceCurStartCUAddr(); |
---|
577 | if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
578 | { |
---|
579 | bBoundary = true; |
---|
580 | } |
---|
581 | |
---|
582 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
583 | { |
---|
584 | UInt uiNextDepth = uiDepth + 1; |
---|
585 | UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1); |
---|
586 | UInt uiIdx = uiAbsPartIdx; |
---|
587 | for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ ) |
---|
588 | { |
---|
589 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
590 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
591 | |
---|
592 | Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getEntropySliceCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getEntropySliceCurEndCUAddr()); |
---|
593 | if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
594 | { |
---|
595 | xDecompressCU(pcCU, m_ppcCU[uiNextDepth], uiIdx, uiNextDepth ); |
---|
596 | } |
---|
597 | |
---|
598 | uiIdx += uiQNumParts; |
---|
599 | } |
---|
600 | return; |
---|
601 | } |
---|
602 | |
---|
603 | // Residual reconstruction |
---|
604 | m_ppcYuvResi[uiDepth]->clear(); |
---|
605 | |
---|
606 | m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth ); |
---|
607 | |
---|
608 | switch( m_ppcCU[uiDepth]->getPredictionMode(0) ) |
---|
609 | { |
---|
610 | case MODE_SKIP: |
---|
611 | case MODE_INTER: |
---|
612 | xReconInter( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
613 | break; |
---|
614 | case MODE_INTRA: |
---|
615 | #if RWTH_SDC_DLT_B0036 |
---|
616 | if( m_ppcCU[uiDepth]->getSDCFlag(0) ) |
---|
617 | xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth ); |
---|
618 | else |
---|
619 | #endif |
---|
620 | xReconIntraQT( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
621 | break; |
---|
622 | default: |
---|
623 | assert(0); |
---|
624 | break; |
---|
625 | } |
---|
626 | #if LOSSLESS_CODING |
---|
627 | if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false)) |
---|
628 | { |
---|
629 | xFillPCMBuffer(m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth); |
---|
630 | } |
---|
631 | #endif |
---|
632 | |
---|
633 | xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth ); |
---|
634 | } |
---|
635 | |
---|
636 | Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
637 | { |
---|
638 | #if HHI_MPI |
---|
639 | if( pcCU->getTextureModeDepth( 0 ) != -1 ) |
---|
640 | pcCU->setPartSizeSubParts( SIZE_NxN, 0, uiDepth ); |
---|
641 | #endif |
---|
642 | |
---|
643 | // inter prediction |
---|
644 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
645 | |
---|
646 | #if HHI_MPI |
---|
647 | if( pcCU->getTextureModeDepth( 0 ) != -1 ) |
---|
648 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
649 | #endif |
---|
650 | |
---|
651 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
652 | if( pcCU->getResPredFlag( 0 ) ) |
---|
653 | { |
---|
654 | AOF( pcCU->getResPredAvail( 0 ) ); |
---|
655 | Bool bOK = pcCU->getResidualSamples( 0, |
---|
656 | #if QC_SIMPLIFIEDIVRP_M24938 |
---|
657 | true, |
---|
658 | #endif |
---|
659 | m_ppcYuvResPred[uiDepth] ); |
---|
660 | AOF( bOK ); |
---|
661 | #if LG_RESTRICTEDRESPRED_M24766 |
---|
662 | Int iPUResiPredShift[4]; |
---|
663 | pcCU->getPUResiPredShift(iPUResiPredShift, 0); |
---|
664 | m_ppcYuvReco[uiDepth]->add(iPUResiPredShift, pcCU->getPartitionSize(0), m_ppcYuvResPred[uiDepth], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) ); |
---|
665 | #else |
---|
666 | m_ppcYuvReco[uiDepth]->add( m_ppcYuvResPred[uiDepth], pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) ); |
---|
667 | #endif |
---|
668 | } |
---|
669 | #endif |
---|
670 | |
---|
671 | // inter recon |
---|
672 | xDecodeInterTexture( pcCU, 0, uiDepth ); |
---|
673 | |
---|
674 | // clip for only non-zero cbp case |
---|
675 | if ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) ) |
---|
676 | { |
---|
677 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
678 | } |
---|
679 | else |
---|
680 | { |
---|
681 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
682 | if( pcCU->getResPredFlag( 0 ) ) |
---|
683 | { |
---|
684 | m_ppcYuvReco[uiDepth]->clip( pcCU->getWidth( 0 ), pcCU->getHeight( 0 ) ); |
---|
685 | } |
---|
686 | #endif |
---|
687 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
688 | } |
---|
689 | } |
---|
690 | |
---|
691 | Void |
---|
692 | TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU, |
---|
693 | UInt uiTrDepth, |
---|
694 | UInt uiAbsPartIdx, |
---|
695 | TComYuv* pcRecoYuv, |
---|
696 | TComYuv* pcPredYuv, |
---|
697 | TComYuv* pcResiYuv ) |
---|
698 | { |
---|
699 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> uiTrDepth; |
---|
700 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> uiTrDepth; |
---|
701 | UInt uiStride = pcRecoYuv->getStride (); |
---|
702 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
703 | Pel* piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
704 | Pel* piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
705 | |
---|
706 | UInt uiNumCoeffInc = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ); |
---|
707 | TCoeff* pcCoeff = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
708 | |
---|
709 | UInt uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
710 | |
---|
711 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
712 | Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
713 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
714 | |
---|
715 | //===== init availability pattern ===== |
---|
716 | Bool bAboveAvail = false; |
---|
717 | Bool bLeftAvail = false; |
---|
718 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
719 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
720 | m_pcPrediction->getPredicBuf (), |
---|
721 | m_pcPrediction->getPredicBufWidth (), |
---|
722 | m_pcPrediction->getPredicBufHeight (), |
---|
723 | bAboveAvail, bLeftAvail ); |
---|
724 | #if LGE_EDGE_INTRA |
---|
725 | if( uiLumaPredMode >= EDGE_INTRA_IDX ) |
---|
726 | { |
---|
727 | m_pcPrediction->predIntraLumaEdge( pcCU, pcCU->getPattern(), uiAbsPartIdx, uiWidth, uiHeight, piPred, uiStride |
---|
728 | #if LGE_EDGE_INTRA_DELTA_DC |
---|
729 | , uiLumaPredMode == EDGE_INTRA_DELTA_IDX |
---|
730 | #endif |
---|
731 | ); |
---|
732 | } |
---|
733 | else |
---|
734 | #endif |
---|
735 | |
---|
736 | //===== get prediction signal ===== |
---|
737 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
738 | if( uiLumaPredMode >= NUM_INTRA_MODE ) |
---|
739 | { |
---|
740 | m_pcPrediction->predIntraLumaDMM( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail, false ); |
---|
741 | } |
---|
742 | else |
---|
743 | { |
---|
744 | #endif |
---|
745 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); |
---|
746 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
747 | } |
---|
748 | #endif |
---|
749 | |
---|
750 | //===== inverse transform ===== |
---|
751 | #if H0736_AVC_STYLE_QP_RANGE |
---|
752 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
753 | #else |
---|
754 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, 0 ); |
---|
755 | #endif |
---|
756 | |
---|
757 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA]; |
---|
758 | assert(scalingListType < 6); |
---|
759 | #if LOSSLESS_CODING |
---|
760 | m_pcTrQuant->invtransformNxN( pcCU, TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType ); |
---|
761 | #else |
---|
762 | m_pcTrQuant->invtransformNxN( TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType ); |
---|
763 | #endif |
---|
764 | |
---|
765 | |
---|
766 | //===== reconstruction ===== |
---|
767 | Pel* pPred = piPred; |
---|
768 | Pel* pResi = piResi; |
---|
769 | Pel* pReco = piReco; |
---|
770 | Pel* pRecIPred = piRecIPred; |
---|
771 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
772 | { |
---|
773 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
774 | { |
---|
775 | pReco [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] ); |
---|
776 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
777 | } |
---|
778 | pPred += uiStride; |
---|
779 | pResi += uiStride; |
---|
780 | pReco += uiStride; |
---|
781 | pRecIPred += uiRecIPredStride; |
---|
782 | } |
---|
783 | } |
---|
784 | |
---|
785 | |
---|
786 | Void |
---|
787 | TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU, |
---|
788 | UInt uiTrDepth, |
---|
789 | UInt uiAbsPartIdx, |
---|
790 | TComYuv* pcRecoYuv, |
---|
791 | TComYuv* pcPredYuv, |
---|
792 | TComYuv* pcResiYuv, |
---|
793 | UInt uiChromaId ) |
---|
794 | { |
---|
795 | UInt uiFullDepth = pcCU->getDepth( 0 ) + uiTrDepth; |
---|
796 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2; |
---|
797 | |
---|
798 | if( uiLog2TrSize == 2 ) |
---|
799 | { |
---|
800 | assert( uiTrDepth > 0 ); |
---|
801 | uiTrDepth--; |
---|
802 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 ); |
---|
803 | Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 ); |
---|
804 | if( !bFirstQ ) |
---|
805 | { |
---|
806 | return; |
---|
807 | } |
---|
808 | } |
---|
809 | |
---|
810 | TextType eText = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U ); |
---|
811 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> ( uiTrDepth + 1 ); |
---|
812 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> ( uiTrDepth + 1 ); |
---|
813 | UInt uiStride = pcRecoYuv->getCStride (); |
---|
814 | Pel* piReco = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
815 | Pel* piPred = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
816 | Pel* piResi = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
817 | |
---|
818 | UInt uiNumCoeffInc = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2; |
---|
819 | TCoeff* pcCoeff = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
820 | |
---|
821 | UInt uiChromaPredMode = pcCU->getChromaIntraDir( 0 ); |
---|
822 | |
---|
823 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
824 | Pel* piRecIPred = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) ); |
---|
825 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
826 | |
---|
827 | //===== init availability pattern ===== |
---|
828 | Bool bAboveAvail = false; |
---|
829 | Bool bLeftAvail = false; |
---|
830 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
831 | |
---|
832 | if( uiChromaPredMode == LM_CHROMA_IDX && uiChromaId == 0 ) |
---|
833 | { |
---|
834 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
835 | m_pcPrediction->getPredicBuf (), |
---|
836 | m_pcPrediction->getPredicBufWidth (), |
---|
837 | m_pcPrediction->getPredicBufHeight (), |
---|
838 | bAboveAvail, bLeftAvail, |
---|
839 | true ); |
---|
840 | |
---|
841 | m_pcPrediction->getLumaRecPixels( pcCU->getPattern(), uiWidth, uiHeight ); |
---|
842 | } |
---|
843 | |
---|
844 | pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
845 | m_pcPrediction->getPredicBuf (), |
---|
846 | m_pcPrediction->getPredicBufWidth (), |
---|
847 | m_pcPrediction->getPredicBufHeight (), |
---|
848 | bAboveAvail, bLeftAvail ); |
---|
849 | Int* pPatChroma = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) ); |
---|
850 | |
---|
851 | //===== get prediction signal ===== |
---|
852 | if( uiChromaPredMode == LM_CHROMA_IDX ) |
---|
853 | { |
---|
854 | m_pcPrediction->predLMIntraChroma( pcCU->getPattern(), pPatChroma, piPred, uiStride, uiWidth, uiHeight, uiChromaId ); |
---|
855 | } |
---|
856 | else |
---|
857 | { |
---|
858 | if( uiChromaPredMode == DM_CHROMA_IDX ) |
---|
859 | { |
---|
860 | uiChromaPredMode = pcCU->getLumaIntraDir( 0 ); |
---|
861 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
862 | mapDMMtoIntraMode( uiChromaPredMode ); |
---|
863 | #endif |
---|
864 | } |
---|
865 | m_pcPrediction->predIntraChromaAng( pcCU->getPattern(), pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); |
---|
866 | } |
---|
867 | |
---|
868 | //===== inverse transform ===== |
---|
869 | if(eText == TEXT_CHROMA_U) |
---|
870 | { |
---|
871 | #if H0736_AVC_STYLE_QP_RANGE |
---|
872 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset() ); |
---|
873 | #else |
---|
874 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText, pcCU->getSlice()->getPPS()->getChromaQpOffset() ); |
---|
875 | #endif |
---|
876 | } |
---|
877 | else |
---|
878 | { |
---|
879 | #if H0736_AVC_STYLE_QP_RANGE |
---|
880 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() ); |
---|
881 | #else |
---|
882 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), eText, pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() ); |
---|
883 | #endif |
---|
884 | } |
---|
885 | |
---|
886 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText]; |
---|
887 | assert(scalingListType < 6); |
---|
888 | #if LOSSLESS_CODING |
---|
889 | m_pcTrQuant->invtransformNxN( pcCU, eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType ); |
---|
890 | #else |
---|
891 | m_pcTrQuant->invtransformNxN( eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType ); |
---|
892 | #endif |
---|
893 | |
---|
894 | //===== reconstruction ===== |
---|
895 | Pel* pPred = piPred; |
---|
896 | Pel* pResi = piResi; |
---|
897 | Pel* pReco = piReco; |
---|
898 | Pel* pRecIPred = piRecIPred; |
---|
899 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
900 | { |
---|
901 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
902 | { |
---|
903 | pReco [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] ); |
---|
904 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
905 | } |
---|
906 | pPred += uiStride; |
---|
907 | pResi += uiStride; |
---|
908 | pReco += uiStride; |
---|
909 | pRecIPred += uiRecIPredStride; |
---|
910 | } |
---|
911 | } |
---|
912 | |
---|
913 | Void |
---|
914 | TDecCu::xIntraRecQT( TComDataCU* pcCU, |
---|
915 | UInt uiTrDepth, |
---|
916 | UInt uiAbsPartIdx, |
---|
917 | TComYuv* pcRecoYuv, |
---|
918 | TComYuv* pcPredYuv, |
---|
919 | TComYuv* pcResiYuv ) |
---|
920 | { |
---|
921 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
922 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
923 | if( uiTrMode == uiTrDepth ) |
---|
924 | { |
---|
925 | xIntraRecLumaBlk ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
926 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 ); |
---|
927 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 ); |
---|
928 | } |
---|
929 | else |
---|
930 | { |
---|
931 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
932 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
933 | { |
---|
934 | xIntraRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
935 | } |
---|
936 | } |
---|
937 | } |
---|
938 | |
---|
939 | Void |
---|
940 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
941 | { |
---|
942 | UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 ); |
---|
943 | UInt uiNumPart = pcCU->getNumPartInter(); |
---|
944 | UInt uiNumQParts = pcCU->getTotalNumPart() >> 2; |
---|
945 | |
---|
946 | if (pcCU->getIPCMFlag(0)) |
---|
947 | { |
---|
948 | xReconPCM( pcCU, uiAbsPartIdx, uiDepth ); |
---|
949 | return; |
---|
950 | } |
---|
951 | |
---|
952 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
953 | { |
---|
954 | xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
955 | } |
---|
956 | |
---|
957 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
958 | { |
---|
959 | xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
960 | } |
---|
961 | |
---|
962 | } |
---|
963 | |
---|
964 | #if RWTH_SDC_DLT_B0036 |
---|
965 | Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
966 | { |
---|
967 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
968 | UInt uiHeight = pcCU->getHeight ( 0 ); |
---|
969 | |
---|
970 | TComYuv* pcRecoYuv = m_ppcYuvReco[uiDepth]; |
---|
971 | TComYuv* pcPredYuv = m_ppcYuvReco[uiDepth]; |
---|
972 | TComYuv* pcResiYuv = m_ppcYuvResi[uiDepth]; |
---|
973 | |
---|
974 | UInt uiStride = pcRecoYuv->getStride (); |
---|
975 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
976 | Pel* piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
977 | Pel* piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
978 | |
---|
979 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
980 | Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
981 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
982 | |
---|
983 | UInt uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
984 | |
---|
985 | AOF( uiWidth == uiHeight ); |
---|
986 | AOF( uiAbsPartIdx == 0 ); |
---|
987 | AOF( pcCU->getSDCAvailable(uiAbsPartIdx) ); |
---|
988 | AOF( pcCU->getSDCFlag(uiAbsPartIdx) ); |
---|
989 | |
---|
990 | //===== init availability pattern ===== |
---|
991 | Bool bAboveAvail = false; |
---|
992 | Bool bLeftAvail = false; |
---|
993 | pcCU->getPattern()->initPattern ( pcCU, 0, uiAbsPartIdx ); |
---|
994 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail ); |
---|
995 | |
---|
996 | //===== get prediction signal ===== |
---|
997 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
998 | if( uiLumaPredMode >= NUM_INTRA_MODE ) |
---|
999 | { |
---|
1000 | m_pcPrediction->predIntraLumaDMM( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail, false ); |
---|
1001 | } |
---|
1002 | else |
---|
1003 | { |
---|
1004 | #endif |
---|
1005 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); |
---|
1006 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1007 | } |
---|
1008 | #endif |
---|
1009 | |
---|
1010 | // number of segments depends on prediction mode |
---|
1011 | UInt uiNumSegments = 1; |
---|
1012 | Bool* pbMask = NULL; |
---|
1013 | UInt uiMaskStride = 0; |
---|
1014 | |
---|
1015 | if( uiLumaPredMode == DMM_WEDGE_FULL_IDX || uiLumaPredMode == DMM_WEDGE_PREDDIR_IDX ) |
---|
1016 | { |
---|
1017 | Int uiTabIdx = (uiLumaPredMode == DMM_WEDGE_FULL_IDX)?pcCU->getWedgeFullTabIdx(uiAbsPartIdx):pcCU->getWedgePredDirTabIdx(uiAbsPartIdx); |
---|
1018 | |
---|
1019 | WedgeList* pacWedgeList = &g_aacWedgeLists[(g_aucConvertToBit[uiWidth])]; |
---|
1020 | TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx )); |
---|
1021 | |
---|
1022 | uiNumSegments = 2; |
---|
1023 | pbMask = pcWedgelet->getPattern(); |
---|
1024 | uiMaskStride = pcWedgelet->getStride(); |
---|
1025 | } |
---|
1026 | |
---|
1027 | // get DC prediction for each segment |
---|
1028 | Pel apDCPredValues[2]; |
---|
1029 | xAnalyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride); |
---|
1030 | |
---|
1031 | // reconstruct residual based on mask + DC residuals |
---|
1032 | Pel apDCResiValues[2]; |
---|
1033 | Pel apDCRecoValues[2]; |
---|
1034 | for( UInt ui = 0; ui < uiNumSegments; ui++ ) |
---|
1035 | { |
---|
1036 | Pel pPredIdx = GetDepthValue2Idx( apDCPredValues[ui] ); |
---|
1037 | Pel pResiIdx = pcCU->getSDCSegmentDCOffset(ui, uiAbsPartIdx); |
---|
1038 | Pel pRecoValue = GetIdx2DepthValue( pPredIdx + pResiIdx ); |
---|
1039 | |
---|
1040 | apDCRecoValues[ui] = pRecoValue; |
---|
1041 | apDCResiValues[ui] = pRecoValue - apDCPredValues[ui]; |
---|
1042 | } |
---|
1043 | |
---|
1044 | //===== reconstruction ===== |
---|
1045 | Bool*pMask = pbMask; |
---|
1046 | Pel* pPred = piPred; |
---|
1047 | Pel* pResi = piResi; |
---|
1048 | Pel* pReco = piReco; |
---|
1049 | Pel* pRecIPred = piRecIPred; |
---|
1050 | |
---|
1051 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1052 | { |
---|
1053 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1054 | { |
---|
1055 | UChar ucSegment = pMask?(UChar)pMask[uiX]:0; |
---|
1056 | assert( ucSegment < uiNumSegments ); |
---|
1057 | |
---|
1058 | Pel pPredVal= apDCPredValues[ucSegment]; |
---|
1059 | Pel pResiDC = apDCResiValues[ucSegment]; |
---|
1060 | |
---|
1061 | pReco [ uiX ] = Clip( pPredVal + pResiDC ); |
---|
1062 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
1063 | } |
---|
1064 | pPred += uiStride; |
---|
1065 | pResi += uiStride; |
---|
1066 | pReco += uiStride; |
---|
1067 | pRecIPred += uiRecIPredStride; |
---|
1068 | pMask += uiMaskStride; |
---|
1069 | } |
---|
1070 | |
---|
1071 | // clear UV |
---|
1072 | UInt uiStrideC = pcPredYuv->getCStride(); |
---|
1073 | Pel *pRecCb = pcPredYuv->getCbAddr(); |
---|
1074 | Pel *pRecCr = pcPredYuv->getCrAddr(); |
---|
1075 | |
---|
1076 | for (Int y=0; y<uiHeight/2; y++) |
---|
1077 | { |
---|
1078 | for (Int x=0; x<uiWidth/2; x++) |
---|
1079 | { |
---|
1080 | pRecCb[x] = (Pel)(128<<g_uiBitIncrement); |
---|
1081 | pRecCr[x] = (Pel)(128<<g_uiBitIncrement); |
---|
1082 | } |
---|
1083 | |
---|
1084 | pRecCb += uiStrideC; |
---|
1085 | pRecCr += uiStrideC; |
---|
1086 | } |
---|
1087 | } |
---|
1088 | #endif |
---|
1089 | |
---|
1090 | /** Function for deriving recontructed PU/CU Luma sample with QTree structure |
---|
1091 | * \param pcCU pointer of current CU |
---|
1092 | * \param uiTrDepth current tranform split depth |
---|
1093 | * \param uiAbsPartIdx part index |
---|
1094 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
1095 | * \param pcPredYuv pointer to prediction sample arrays |
---|
1096 | * \param pcResiYuv pointer to residue sample arrays |
---|
1097 | * |
---|
1098 | \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure |
---|
1099 | */ |
---|
1100 | Void |
---|
1101 | TDecCu::xIntraLumaRecQT( TComDataCU* pcCU, |
---|
1102 | UInt uiTrDepth, |
---|
1103 | UInt uiAbsPartIdx, |
---|
1104 | TComYuv* pcRecoYuv, |
---|
1105 | TComYuv* pcPredYuv, |
---|
1106 | TComYuv* pcResiYuv ) |
---|
1107 | { |
---|
1108 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
1109 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
1110 | if( uiTrMode == uiTrDepth ) |
---|
1111 | { |
---|
1112 | xIntraRecLumaBlk ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
1113 | } |
---|
1114 | else |
---|
1115 | { |
---|
1116 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
1117 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
1118 | { |
---|
1119 | xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
1120 | } |
---|
1121 | } |
---|
1122 | } |
---|
1123 | |
---|
1124 | /** Function for deriving recontructed PU/CU chroma samples with QTree structure |
---|
1125 | * \param pcCU pointer of current CU |
---|
1126 | * \param uiTrDepth current tranform split depth |
---|
1127 | * \param uiAbsPartIdx part index |
---|
1128 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
1129 | * \param pcPredYuv pointer to prediction sample arrays |
---|
1130 | * \param pcResiYuv pointer to residue sample arrays |
---|
1131 | * |
---|
1132 | \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure |
---|
1133 | */ |
---|
1134 | Void |
---|
1135 | TDecCu::xIntraChromaRecQT( TComDataCU* pcCU, |
---|
1136 | UInt uiTrDepth, |
---|
1137 | UInt uiAbsPartIdx, |
---|
1138 | TComYuv* pcRecoYuv, |
---|
1139 | TComYuv* pcPredYuv, |
---|
1140 | TComYuv* pcResiYuv ) |
---|
1141 | { |
---|
1142 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
1143 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
1144 | if( uiTrMode == uiTrDepth ) |
---|
1145 | { |
---|
1146 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 ); |
---|
1147 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 ); |
---|
1148 | } |
---|
1149 | else |
---|
1150 | { |
---|
1151 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
1152 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
1153 | { |
---|
1154 | xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
1155 | } |
---|
1156 | } |
---|
1157 | } |
---|
1158 | |
---|
1159 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
1160 | { |
---|
1161 | UInt uiCUAddr = pcCU->getAddr(); |
---|
1162 | |
---|
1163 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx ); |
---|
1164 | |
---|
1165 | return; |
---|
1166 | } |
---|
1167 | |
---|
1168 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1169 | { |
---|
1170 | UInt uiWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
1171 | UInt uiHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
1172 | TCoeff* piCoeff; |
---|
1173 | |
---|
1174 | Pel* pResi; |
---|
1175 | UInt uiLumaTrMode, uiChromaTrMode; |
---|
1176 | |
---|
1177 | pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode ); |
---|
1178 | |
---|
1179 | // Y |
---|
1180 | piCoeff = pcCU->getCoeffY(); |
---|
1181 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr(); |
---|
1182 | |
---|
1183 | #if H0736_AVC_STYLE_QP_RANGE |
---|
1184 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
1185 | #else |
---|
1186 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_LUMA, 0 ); |
---|
1187 | #endif |
---|
1188 | |
---|
1189 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, uiLumaTrMode, 0, piCoeff ); |
---|
1190 | |
---|
1191 | // Cb and Cr |
---|
1192 | #if H0736_AVC_STYLE_QP_RANGE |
---|
1193 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset() ); |
---|
1194 | #else |
---|
1195 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getPPS()->getChromaQpOffset() ); |
---|
1196 | #endif |
---|
1197 | |
---|
1198 | uiWidth >>= 1; |
---|
1199 | uiHeight >>= 1; |
---|
1200 | piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr(); |
---|
1201 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff ); |
---|
1202 | |
---|
1203 | #if H0736_AVC_STYLE_QP_RANGE |
---|
1204 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() ); |
---|
1205 | #else |
---|
1206 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), !pcCU->getSlice()->getDepth(), pcCU->getSlice()->getSliceType(), TEXT_CHROMA, pcCU->getSlice()->getPPS()->getChromaQpOffset2nd() ); |
---|
1207 | #endif |
---|
1208 | |
---|
1209 | piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr(); |
---|
1210 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff ); |
---|
1211 | } |
---|
1212 | |
---|
1213 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
---|
1214 | * \param pcCU pointer to current CU |
---|
1215 | * \param uiPartIdx part index |
---|
1216 | * \param piPCM pointer to PCM code arrays |
---|
1217 | * \param piReco pointer to reconstructed sample arrays |
---|
1218 | * \param uiStride stride of reconstructed sample arrays |
---|
1219 | * \param uiWidth CU width |
---|
1220 | * \param uiHeight CU height |
---|
1221 | * \param ttText texture component type |
---|
1222 | * \returns Void |
---|
1223 | */ |
---|
1224 | Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText) |
---|
1225 | { |
---|
1226 | UInt uiX, uiY; |
---|
1227 | Pel* piPicReco; |
---|
1228 | UInt uiPicStride; |
---|
1229 | UInt uiPcmLeftShiftBit; |
---|
1230 | |
---|
1231 | if( ttText == TEXT_LUMA ) |
---|
1232 | { |
---|
1233 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(); |
---|
1234 | piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
1235 | uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
1236 | } |
---|
1237 | else |
---|
1238 | { |
---|
1239 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
1240 | |
---|
1241 | if( ttText == TEXT_CHROMA_U ) |
---|
1242 | { |
---|
1243 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
1244 | } |
---|
1245 | else |
---|
1246 | { |
---|
1247 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
1248 | } |
---|
1249 | uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
1250 | } |
---|
1251 | |
---|
1252 | for( uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1253 | { |
---|
1254 | for( uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1255 | { |
---|
1256 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
---|
1257 | piPicReco[uiX] = piReco[uiX]; |
---|
1258 | } |
---|
1259 | piPCM += uiWidth; |
---|
1260 | piReco += uiStride; |
---|
1261 | piPicReco += uiPicStride; |
---|
1262 | } |
---|
1263 | } |
---|
1264 | |
---|
1265 | /** Function for reconstructing a PCM mode CU. |
---|
1266 | * \param pcCU pointer to current CU |
---|
1267 | * \param uiAbsPartIdx CU index |
---|
1268 | * \param uiDepth CU Depth |
---|
1269 | * \returns Void |
---|
1270 | */ |
---|
1271 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1272 | { |
---|
1273 | // Luma |
---|
1274 | UInt uiWidth = (g_uiMaxCUWidth >> uiDepth); |
---|
1275 | UInt uiHeight = (g_uiMaxCUHeight >> uiDepth); |
---|
1276 | |
---|
1277 | Pel* piPcmY = pcCU->getPCMSampleY(); |
---|
1278 | Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth); |
---|
1279 | |
---|
1280 | UInt uiStride = m_ppcYuvResi[uiDepth]->getStride(); |
---|
1281 | |
---|
1282 | xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA); |
---|
1283 | |
---|
1284 | // Cb and Cr |
---|
1285 | UInt uiCWidth = (uiWidth>>1); |
---|
1286 | UInt uiCHeight = (uiHeight>>1); |
---|
1287 | |
---|
1288 | Pel* piPcmCb = pcCU->getPCMSampleCb(); |
---|
1289 | Pel* piPcmCr = pcCU->getPCMSampleCr(); |
---|
1290 | Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
---|
1291 | Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
---|
1292 | |
---|
1293 | UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride(); |
---|
1294 | |
---|
1295 | xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U); |
---|
1296 | xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V); |
---|
1297 | } |
---|
1298 | |
---|
1299 | #if LOSSLESS_CODING |
---|
1300 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
---|
1301 | * \param pcCU pointer to current CU |
---|
1302 | * \param uiAbsPartIdx CU index |
---|
1303 | * \param uiDepth CU Depth |
---|
1304 | * \returns Void |
---|
1305 | */ |
---|
1306 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt absPartIdx, UInt depth) |
---|
1307 | { |
---|
1308 | // Luma |
---|
1309 | UInt width = (g_uiMaxCUWidth >> depth); |
---|
1310 | UInt height = (g_uiMaxCUHeight >> depth); |
---|
1311 | |
---|
1312 | Pel* pPcmY = pCU->getPCMSampleY(); |
---|
1313 | Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width); |
---|
1314 | |
---|
1315 | UInt stride = m_ppcYuvReco[depth]->getStride(); |
---|
1316 | |
---|
1317 | for(Int y = 0; y < height; y++ ) |
---|
1318 | { |
---|
1319 | for(Int x = 0; x < width; x++ ) |
---|
1320 | { |
---|
1321 | pPcmY[x] = pRecoY[x]; |
---|
1322 | } |
---|
1323 | pPcmY += width; |
---|
1324 | pRecoY += stride; |
---|
1325 | } |
---|
1326 | |
---|
1327 | // Cb and Cr |
---|
1328 | UInt widthC = (width>>1); |
---|
1329 | UInt heightC = (height>>1); |
---|
1330 | |
---|
1331 | Pel* pPcmCb = pCU->getPCMSampleCb(); |
---|
1332 | Pel* pPcmCr = pCU->getPCMSampleCr(); |
---|
1333 | Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr(); |
---|
1334 | Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr(); |
---|
1335 | |
---|
1336 | UInt strideC = m_ppcYuvReco[depth]->getCStride(); |
---|
1337 | |
---|
1338 | for(Int y = 0; y < heightC; y++ ) |
---|
1339 | { |
---|
1340 | for(Int x = 0; x < widthC; x++ ) |
---|
1341 | { |
---|
1342 | pPcmCb[x] = pRecoCb[x]; |
---|
1343 | pPcmCr[x] = pRecoCr[x]; |
---|
1344 | } |
---|
1345 | pPcmCr += widthC; |
---|
1346 | pPcmCb += widthC; |
---|
1347 | pRecoCb += strideC; |
---|
1348 | pRecoCr += strideC; |
---|
1349 | } |
---|
1350 | |
---|
1351 | } |
---|
1352 | #endif |
---|
1353 | |
---|
1354 | #if RWTH_SDC_DLT_B0036 |
---|
1355 | Void TDecCu::xAnalyzeSegmentsSDC( Pel* pOrig, UInt uiStride, UInt uiSize, Pel* rpSegMeans, UInt uiNumSegments, Bool* pMask, UInt uiMaskStride ) |
---|
1356 | { |
---|
1357 | Int iSumDepth[2]; |
---|
1358 | memset(iSumDepth, 0, sizeof(Int)*2); |
---|
1359 | Int iSumPix[2]; |
---|
1360 | memset(iSumPix, 0, sizeof(Int)*2); |
---|
1361 | |
---|
1362 | for (Int y=0; y<uiSize; y++) |
---|
1363 | { |
---|
1364 | for (Int x=0; x<uiSize; x++) |
---|
1365 | { |
---|
1366 | UChar ucSegment = pMask?(UChar)pMask[x]:0; |
---|
1367 | assert( ucSegment < uiNumSegments ); |
---|
1368 | |
---|
1369 | iSumDepth[ucSegment] += pOrig[x]; |
---|
1370 | iSumPix[ucSegment] += 1; |
---|
1371 | } |
---|
1372 | |
---|
1373 | pOrig += uiStride; |
---|
1374 | pMask += uiMaskStride; |
---|
1375 | } |
---|
1376 | |
---|
1377 | // compute mean for each segment |
---|
1378 | for( UChar ucSeg = 0; ucSeg < uiNumSegments; ucSeg++ ) |
---|
1379 | { |
---|
1380 | if( iSumPix[ucSeg] > 0 ) |
---|
1381 | rpSegMeans[ucSeg] = iSumDepth[ucSeg] / iSumPix[ucSeg]; |
---|
1382 | else |
---|
1383 | rpSegMeans[ucSeg] = 0; // this happens for zero-segments |
---|
1384 | } |
---|
1385 | } |
---|
1386 | #endif |
---|
1387 | |
---|
1388 | //! \} |
---|