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