1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TDecCu.cpp |
---|
35 | \brief CU decoder class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "TDecCu.h" |
---|
39 | |
---|
40 | //! \ingroup TLibDecoder |
---|
41 | //! \{ |
---|
42 | |
---|
43 | // ==================================================================================================================== |
---|
44 | // Constructor / destructor / create / destroy |
---|
45 | // ==================================================================================================================== |
---|
46 | |
---|
47 | TDecCu::TDecCu() |
---|
48 | { |
---|
49 | m_ppcYuvResi = NULL; |
---|
50 | m_ppcYuvReco = NULL; |
---|
51 | m_ppcCU = NULL; |
---|
52 | #if H_3D_DBBP |
---|
53 | m_ppcYuvRecoDBBP = NULL; |
---|
54 | #endif |
---|
55 | } |
---|
56 | |
---|
57 | TDecCu::~TDecCu() |
---|
58 | { |
---|
59 | } |
---|
60 | |
---|
61 | Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction) |
---|
62 | { |
---|
63 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
64 | m_pcTrQuant = pcTrQuant; |
---|
65 | m_pcPrediction = pcPrediction; |
---|
66 | } |
---|
67 | |
---|
68 | /** |
---|
69 | \param uiMaxDepth total number of allowable depth |
---|
70 | \param uiMaxWidth largest CU width |
---|
71 | \param uiMaxHeight largest CU height |
---|
72 | */ |
---|
73 | Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight ) |
---|
74 | { |
---|
75 | m_uiMaxDepth = uiMaxDepth+1; |
---|
76 | |
---|
77 | m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1]; |
---|
78 | m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1]; |
---|
79 | m_ppcCU = new TComDataCU*[m_uiMaxDepth-1]; |
---|
80 | #if H_3D_DBBP |
---|
81 | m_ppcYuvRecoDBBP = new TComYuv*[m_uiMaxDepth-1]; |
---|
82 | #endif |
---|
83 | |
---|
84 | UInt uiNumPartitions; |
---|
85 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
86 | { |
---|
87 | uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 ); |
---|
88 | UInt uiWidth = uiMaxWidth >> ui; |
---|
89 | UInt uiHeight = uiMaxHeight >> ui; |
---|
90 | |
---|
91 | m_ppcYuvResi[ui] = new TComYuv; m_ppcYuvResi[ui]->create( uiWidth, uiHeight ); |
---|
92 | m_ppcYuvReco[ui] = new TComYuv; m_ppcYuvReco[ui]->create( uiWidth, uiHeight ); |
---|
93 | m_ppcCU [ui] = new TComDataCU; m_ppcCU [ui]->create( uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) ); |
---|
94 | #if H_3D_DBBP |
---|
95 | m_ppcYuvRecoDBBP[ui] = new TComYuv; m_ppcYuvRecoDBBP[ui]->create( uiWidth, uiHeight ); |
---|
96 | #endif |
---|
97 | } |
---|
98 | |
---|
99 | m_bDecodeDQP = false; |
---|
100 | |
---|
101 | // initialize partition order. |
---|
102 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
103 | initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp); |
---|
104 | initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
105 | |
---|
106 | // initialize conversion matrix from partition index to pel |
---|
107 | initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
108 | } |
---|
109 | |
---|
110 | Void TDecCu::destroy() |
---|
111 | { |
---|
112 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
113 | { |
---|
114 | m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL; |
---|
115 | m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL; |
---|
116 | m_ppcCU [ui]->destroy(); delete m_ppcCU [ui]; m_ppcCU [ui] = NULL; |
---|
117 | #if H_3D_DBBP |
---|
118 | m_ppcYuvRecoDBBP[ui]->destroy(); delete m_ppcYuvRecoDBBP[ui]; m_ppcYuvRecoDBBP[ui] = NULL; |
---|
119 | #endif |
---|
120 | } |
---|
121 | |
---|
122 | delete [] m_ppcYuvResi; m_ppcYuvResi = NULL; |
---|
123 | delete [] m_ppcYuvReco; m_ppcYuvReco = NULL; |
---|
124 | delete [] m_ppcCU ; m_ppcCU = NULL; |
---|
125 | #if H_3D_DBBP |
---|
126 | delete [] m_ppcYuvRecoDBBP; m_ppcYuvRecoDBBP = NULL; |
---|
127 | #endif |
---|
128 | } |
---|
129 | |
---|
130 | // ==================================================================================================================== |
---|
131 | // Public member functions |
---|
132 | // ==================================================================================================================== |
---|
133 | |
---|
134 | /** \param pcCU pointer of CU data |
---|
135 | \param ruiIsLast last data? |
---|
136 | */ |
---|
137 | Void TDecCu::decodeCU( TComDataCU* pcCU, UInt& ruiIsLast ) |
---|
138 | { |
---|
139 | if ( pcCU->getSlice()->getPPS()->getUseDQP() ) |
---|
140 | { |
---|
141 | setdQPFlag(true); |
---|
142 | } |
---|
143 | |
---|
144 | // start from the top level CU |
---|
145 | xDecodeCU( pcCU, 0, 0, ruiIsLast); |
---|
146 | } |
---|
147 | |
---|
148 | /** \param pcCU pointer of CU data |
---|
149 | */ |
---|
150 | Void TDecCu::decompressCU( TComDataCU* pcCU ) |
---|
151 | { |
---|
152 | #if !H_3D_IV_MERGE |
---|
153 | xDecompressCU( pcCU, 0, 0 ); |
---|
154 | #endif |
---|
155 | } |
---|
156 | |
---|
157 | // ==================================================================================================================== |
---|
158 | // Protected member functions |
---|
159 | // ==================================================================================================================== |
---|
160 | |
---|
161 | /**decode end-of-slice flag |
---|
162 | * \param pcCU |
---|
163 | * \param uiAbsPartIdx |
---|
164 | * \param uiDepth |
---|
165 | * \returns Bool |
---|
166 | */ |
---|
167 | Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth) |
---|
168 | { |
---|
169 | UInt uiIsLast; |
---|
170 | TComPic* pcPic = pcCU->getPic(); |
---|
171 | TComSlice * pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
172 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
173 | UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); |
---|
174 | UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); |
---|
175 | UInt uiGranularityWidth = g_uiMaxCUWidth; |
---|
176 | UInt uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
177 | UInt uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
178 | |
---|
179 | if(((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth)) |
---|
180 | &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight))) |
---|
181 | { |
---|
182 | m_pcEntropyDecoder->decodeTerminatingBit( uiIsLast ); |
---|
183 | } |
---|
184 | else |
---|
185 | { |
---|
186 | uiIsLast=0; |
---|
187 | } |
---|
188 | |
---|
189 | if(uiIsLast) |
---|
190 | { |
---|
191 | if(pcSlice->isNextSliceSegment()&&!pcSlice->isNextSlice()) |
---|
192 | { |
---|
193 | pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
194 | } |
---|
195 | else |
---|
196 | { |
---|
197 | pcSlice->setSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
198 | pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
199 | } |
---|
200 | } |
---|
201 | |
---|
202 | return uiIsLast>0; |
---|
203 | } |
---|
204 | |
---|
205 | /** decode CU block recursively |
---|
206 | * \param pcCU |
---|
207 | * \param uiAbsPartIdx |
---|
208 | * \param uiDepth |
---|
209 | * \returns Void |
---|
210 | */ |
---|
211 | |
---|
212 | Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast) |
---|
213 | { |
---|
214 | TComPic* pcPic = pcCU->getPic(); |
---|
215 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
216 | UInt uiQNumParts = uiCurNumParts>>2; |
---|
217 | |
---|
218 | Bool bBoundary = false; |
---|
219 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
220 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
221 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
222 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
223 | #if H_MV_ENC_DEC_TRAC |
---|
224 | DTRACE_CU_S("=========== coding_quadtree ===========\n") |
---|
225 | DTRACE_CU("x0", uiLPelX) |
---|
226 | DTRACE_CU("x1", uiTPelY) |
---|
227 | DTRACE_CU("log2CbSize", g_uiMaxCUWidth>>uiDepth) |
---|
228 | DTRACE_CU("cqtDepth" , uiDepth) |
---|
229 | #endif |
---|
230 | |
---|
231 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
232 | Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr(); |
---|
233 | if((!bStartInCU) && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
234 | { |
---|
235 | m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
236 | } |
---|
237 | else |
---|
238 | { |
---|
239 | bBoundary = true; |
---|
240 | } |
---|
241 | |
---|
242 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
243 | { |
---|
244 | UInt uiIdx = uiAbsPartIdx; |
---|
245 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
246 | { |
---|
247 | setdQPFlag(true); |
---|
248 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
249 | } |
---|
250 | |
---|
251 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
252 | { |
---|
253 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
254 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
255 | |
---|
256 | Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr(); |
---|
257 | if ( bSubInSlice ) |
---|
258 | { |
---|
259 | if ( !ruiIsLast && ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
260 | { |
---|
261 | xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast ); |
---|
262 | } |
---|
263 | else |
---|
264 | { |
---|
265 | pcCU->setOutsideCUPart( uiIdx, uiDepth+1 ); |
---|
266 | } |
---|
267 | } |
---|
268 | |
---|
269 | uiIdx += uiQNumParts; |
---|
270 | } |
---|
271 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
272 | { |
---|
273 | if ( getdQPFlag() ) |
---|
274 | { |
---|
275 | UInt uiQPSrcPartIdx; |
---|
276 | if ( pcPic->getCU( pcCU->getAddr() )->getSliceSegmentStartCU(uiAbsPartIdx) != pcSlice->getSliceSegmentCurStartCUAddr() ) |
---|
277 | { |
---|
278 | uiQPSrcPartIdx = pcSlice->getSliceSegmentCurStartCUAddr() % pcPic->getNumPartInCU(); |
---|
279 | } |
---|
280 | else |
---|
281 | { |
---|
282 | uiQPSrcPartIdx = uiAbsPartIdx; |
---|
283 | } |
---|
284 | pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
285 | } |
---|
286 | } |
---|
287 | return; |
---|
288 | } |
---|
289 | |
---|
290 | #if H_MV_ENC_DEC_TRAC |
---|
291 | DTRACE_CU_S("=========== coding_unit ===========\n") |
---|
292 | #endif |
---|
293 | |
---|
294 | |
---|
295 | #if MTK_DDD_G0063 |
---|
296 | pcCU->setUseDDD( false, uiAbsPartIdx, uiDepth ); |
---|
297 | #endif |
---|
298 | |
---|
299 | if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
300 | { |
---|
301 | setdQPFlag(true); |
---|
302 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
303 | } |
---|
304 | #if H_3D_NBDV |
---|
305 | DisInfo DvInfo; |
---|
306 | DvInfo.bDV = false; |
---|
307 | DvInfo.m_acNBDV.setZero(); |
---|
308 | DvInfo.m_aVIdxCan = 0; |
---|
309 | #if H_3D_NBDV_REF |
---|
310 | DvInfo.m_acDoNBDV.setZero(); |
---|
311 | #endif |
---|
312 | |
---|
313 | |
---|
314 | if(!pcCU->getSlice()->isIntra()) |
---|
315 | { |
---|
316 | #if H_3D_ARP && H_3D_IV_MERGE |
---|
317 | if( pcCU->getSlice()->getVPS()->getUseAdvRP( pcCU->getSlice()->getLayerId() ) || pcCU->getSlice()->getVPS()->getIvMvPredFlag( pcCU->getSlice()->getLayerId() )) |
---|
318 | #else |
---|
319 | #if H_3D_ARP |
---|
320 | if( pcCU->getSlice()->getVPS()->getUseAdvRP(pcCU->getSlice()->getLayerId()) ) |
---|
321 | #else |
---|
322 | #if H_3D_IV_MERGE |
---|
323 | if( pcCU->getSlice()->getVPS()->getIvMvPredFlag(pcCU->getSlice()->getLayerId()) ) |
---|
324 | #else |
---|
325 | if (0) |
---|
326 | #endif |
---|
327 | #endif |
---|
328 | #endif |
---|
329 | { |
---|
330 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true ); |
---|
331 | m_ppcCU[uiDepth]->copyDVInfoFrom( pcCU, uiAbsPartIdx); |
---|
332 | PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0); |
---|
333 | UChar cWidTemp = m_ppcCU[uiDepth]->getWidth(0); |
---|
334 | UChar cHeightTemp = m_ppcCU[uiDepth]->getHeight(0); |
---|
335 | m_ppcCU[uiDepth]->setWidth ( 0, pcCU->getSlice()->getSPS()->getMaxCUWidth ()/(1<<uiDepth) ); |
---|
336 | m_ppcCU[uiDepth]->setHeight ( 0, pcCU->getSlice()->getSPS()->getMaxCUHeight()/(1<<uiDepth) ); |
---|
337 | m_ppcCU[uiDepth]->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
338 | #if H_3D_IV_MERGE |
---|
339 | if( pcCU->getSlice()->getIsDepth()) |
---|
340 | { |
---|
341 | #if SEC_DEPTH_DV_DERIVAITON_G0074 |
---|
342 | DvInfo.bDV = m_ppcCU[uiDepth]->getDispforDepth(0, 0, &DvInfo); |
---|
343 | #else |
---|
344 | DvInfo.bDV = m_ppcCU[uiDepth]->getDispNeighBlocks(0, 0, &DvInfo); |
---|
345 | #endif |
---|
346 | } |
---|
347 | else |
---|
348 | { |
---|
349 | #endif |
---|
350 | #if H_3D_NBDV_REF |
---|
351 | if(pcCU->getSlice()->getVPS()->getDepthRefinementFlag( pcCU->getSlice()->getLayerIdInVps() )) //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done. |
---|
352 | { |
---|
353 | DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo, true); |
---|
354 | } |
---|
355 | else |
---|
356 | #endif |
---|
357 | { |
---|
358 | DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo); |
---|
359 | } |
---|
360 | #if H_3D_IV_MERGE |
---|
361 | } |
---|
362 | #endif |
---|
363 | #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC |
---|
364 | if ( g_decTraceDispDer ) |
---|
365 | { |
---|
366 | DTRACE_CU( "RefViewIdx", DvInfo.m_aVIdxCan ); |
---|
367 | DTRACE_CU( "MvDisp[x]", DvInfo.m_acNBDV.getHor() ); |
---|
368 | DTRACE_CU( "MvDisp[y]", DvInfo.m_acNBDV.getVer() ); |
---|
369 | DTRACE_CU( "MvRefinedDisp[x]", DvInfo.m_acDoNBDV.getHor() ); |
---|
370 | DTRACE_CU( "MvRefinedDisp[y]", DvInfo.m_acDoNBDV.getVer() ); |
---|
371 | } |
---|
372 | #endif |
---|
373 | |
---|
374 | pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth); |
---|
375 | m_ppcCU[uiDepth]->setPartSizeSubParts( ePartTemp, 0, uiDepth ); |
---|
376 | m_ppcCU[uiDepth]->setWidth ( 0, cWidTemp ); |
---|
377 | m_ppcCU[uiDepth]->setHeight ( 0, cHeightTemp ); |
---|
378 | } |
---|
379 | } |
---|
380 | #endif |
---|
381 | if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) |
---|
382 | { |
---|
383 | m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
384 | } |
---|
385 | |
---|
386 | // decode CU mode and the partition size |
---|
387 | if( !pcCU->getSlice()->isIntra()) |
---|
388 | { |
---|
389 | m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
390 | } |
---|
391 | |
---|
392 | if( pcCU->isSkipped(uiAbsPartIdx) ) |
---|
393 | { |
---|
394 | #if H_MV_ENC_DEC_TRAC |
---|
395 | DTRACE_PU_S("=========== prediction_unit ===========\n") |
---|
396 | DTRACE_PU("x0", uiLPelX) |
---|
397 | DTRACE_PU("x1", uiTPelY) |
---|
398 | #endif |
---|
399 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
400 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
401 | #if H_3D_IV_MERGE |
---|
402 | m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx); |
---|
403 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
---|
404 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
---|
405 | #else |
---|
406 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
407 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
408 | #endif |
---|
409 | Int numValidMergeCand = 0; |
---|
410 | for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
411 | { |
---|
412 | uhInterDirNeighbours[ui] = 0; |
---|
413 | } |
---|
414 | m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth ); |
---|
415 | UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx); |
---|
416 | |
---|
417 | #if !SEC_IC_ARP_SIG_G0072 |
---|
418 | #if H_3D_IC |
---|
419 | m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
420 | #endif |
---|
421 | #endif |
---|
422 | #if H_3D_ARP |
---|
423 | m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth ); |
---|
424 | #endif |
---|
425 | #if SEC_IC_ARP_SIG_G0072 |
---|
426 | #if H_3D_IC |
---|
427 | m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
428 | #endif |
---|
429 | #endif |
---|
430 | |
---|
431 | #if H_3D_VSP |
---|
432 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
433 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
---|
434 | InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM]; |
---|
435 | #if H_3D_SPIVMP |
---|
436 | Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
437 | memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); |
---|
438 | TComMvField* pcMvFieldSP; |
---|
439 | UChar* puhInterDirSP; |
---|
440 | pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; |
---|
441 | puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; |
---|
442 | #endif |
---|
443 | m_ppcCU[uiDepth]->initAvailableFlags(); |
---|
444 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
445 | m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo |
---|
446 | #if H_3D_SPIVMP |
---|
447 | , bSPIVMPFlag, pcMvFieldSP, puhInterDirSP |
---|
448 | #endif |
---|
449 | , numValidMergeCand, uiMergeIndex ); |
---|
450 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
451 | #else |
---|
452 | #if H_3D |
---|
453 | m_ppcCU[uiDepth]->initAvailableFlags(); |
---|
454 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
455 | m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
456 | #else |
---|
457 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
458 | #endif |
---|
459 | #endif |
---|
460 | #if H_3D_VSP |
---|
461 | if(vspFlag[uiMergeIndex]) |
---|
462 | { |
---|
463 | pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeIndex].m_acDvInfo, uiAbsPartIdx, 0, uiDepth); |
---|
464 | } |
---|
465 | #endif |
---|
466 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
467 | |
---|
468 | #if MTK_DDD_G0063 |
---|
469 | if( uiMergeIndex == m_ppcCU[uiDepth]->getUseDDDCandIdx() ) |
---|
470 | { |
---|
471 | assert( pcCU->getSlice()->getViewIndex() != 0 ); |
---|
472 | pcCU->setUseDDD( true, uiAbsPartIdx, 0, uiDepth ); |
---|
473 | pcCU->setDDDepthSubParts( m_ppcCU[uiDepth]->getDDTmpDepth(),uiAbsPartIdx, 0, uiDepth ); |
---|
474 | } |
---|
475 | #endif |
---|
476 | |
---|
477 | TComMv cTmpMv( 0, 0 ); |
---|
478 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
479 | { |
---|
480 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
481 | { |
---|
482 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
483 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
484 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
485 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
486 | #if NTT_STORE_SPDV_VSP_G0148 |
---|
487 | if( pcCU->getVSPFlag( uiAbsPartIdx ) != 0 ) |
---|
488 | { |
---|
489 | if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) ) |
---|
490 | { |
---|
491 | UInt dummy; |
---|
492 | Int vspSize; |
---|
493 | Int width, height; |
---|
494 | m_ppcCU[uiDepth]->getPartIndexAndSize( uiAbsPartIdx, dummy, width, height ); |
---|
495 | m_ppcCU[uiDepth]->setMvFieldPUForVSP( pcCU, uiAbsPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize ); |
---|
496 | pcCU->setVSPFlag( uiAbsPartIdx, vspSize ); |
---|
497 | } |
---|
498 | } |
---|
499 | #endif |
---|
500 | #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC |
---|
501 | if ( g_decTraceMvFromMerge ) |
---|
502 | { |
---|
503 | if ( uiRefListIdx == 0 ) |
---|
504 | { |
---|
505 | DTRACE_PU( "mvL0[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor()); |
---|
506 | DTRACE_PU( "mvL0[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer()); |
---|
507 | DTRACE_PU( "refIdxL0 ", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx()); |
---|
508 | } |
---|
509 | else |
---|
510 | { |
---|
511 | DTRACE_PU( "mvL1[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor()); |
---|
512 | DTRACE_PU( "mvL1[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer()); |
---|
513 | DTRACE_PU( "refIdxL1", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx()); |
---|
514 | } |
---|
515 | } |
---|
516 | #endif |
---|
517 | } |
---|
518 | } |
---|
519 | #if H_3D_SPIVMP |
---|
520 | pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
521 | if (bSPIVMPFlag[uiMergeIndex]) |
---|
522 | { |
---|
523 | UInt uiSPAddr; |
---|
524 | Int iWidth = pcCU->getWidth(uiAbsPartIdx); |
---|
525 | Int iHeight = pcCU->getHeight(uiAbsPartIdx); |
---|
526 | |
---|
527 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
---|
528 | |
---|
529 | pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
---|
530 | |
---|
531 | for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++) |
---|
532 | { |
---|
533 | pcCU->getSPAbsPartIdx(uiAbsPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr); |
---|
534 | pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight); |
---|
535 | pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight); |
---|
536 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight); |
---|
537 | } |
---|
538 | } |
---|
539 | delete[] pcMvFieldSP; |
---|
540 | delete[] puhInterDirSP; |
---|
541 | #endif |
---|
542 | |
---|
543 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
544 | #if H_3D_IV_MERGE |
---|
545 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
---|
546 | #endif |
---|
547 | return; |
---|
548 | } |
---|
549 | |
---|
550 | m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
551 | m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
552 | |
---|
553 | #if QC_SDC_UNIFY_G0130 |
---|
554 | m_pcEntropyDecoder->decodeSDCFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
555 | #endif |
---|
556 | if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
---|
557 | { |
---|
558 | m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
559 | |
---|
560 | if(pcCU->getIPCMFlag(uiAbsPartIdx)) |
---|
561 | { |
---|
562 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
563 | #if H_3D_IV_MERGE |
---|
564 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
---|
565 | #endif |
---|
566 | return; |
---|
567 | } |
---|
568 | } |
---|
569 | |
---|
570 | UInt uiCurrWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
571 | UInt uiCurrHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
572 | |
---|
573 | // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
574 | m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); |
---|
575 | #if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130 |
---|
576 | m_pcEntropyDecoder->decodeInterSDCFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
577 | #endif |
---|
578 | // Coefficient decoding |
---|
579 | Bool bCodeDQP = getdQPFlag(); |
---|
580 | m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP ); |
---|
581 | setdQPFlag( bCodeDQP ); |
---|
582 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
583 | #if H_3D_IV_MERGE |
---|
584 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
---|
585 | #endif |
---|
586 | } |
---|
587 | |
---|
588 | Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast) |
---|
589 | { |
---|
590 | if( pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
591 | { |
---|
592 | pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP |
---|
593 | } |
---|
594 | |
---|
595 | ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth); |
---|
596 | } |
---|
597 | |
---|
598 | Void TDecCu::xDecompressCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
599 | { |
---|
600 | TComPic* pcPic = pcCU->getPic(); |
---|
601 | #if !H_3D_IV_MERGE |
---|
602 | Bool bBoundary = false; |
---|
603 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
604 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
605 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
606 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
607 | |
---|
608 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
609 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
610 | Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr(); |
---|
611 | if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
612 | { |
---|
613 | bBoundary = true; |
---|
614 | } |
---|
615 | |
---|
616 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
617 | { |
---|
618 | UInt uiNextDepth = uiDepth + 1; |
---|
619 | UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1); |
---|
620 | UInt uiIdx = uiAbsPartIdx; |
---|
621 | for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ ) |
---|
622 | { |
---|
623 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
624 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
625 | |
---|
626 | Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getSliceSegmentCurEndCUAddr()); |
---|
627 | if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
628 | { |
---|
629 | xDecompressCU(pcCU, uiIdx, uiNextDepth ); |
---|
630 | } |
---|
631 | |
---|
632 | uiIdx += uiQNumParts; |
---|
633 | } |
---|
634 | return; |
---|
635 | } |
---|
636 | #endif |
---|
637 | // Residual reconstruction |
---|
638 | m_ppcYuvResi[uiDepth]->clear(); |
---|
639 | |
---|
640 | m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth ); |
---|
641 | |
---|
642 | #if H_MV_ENC_DEC_TRAC |
---|
643 | #if ENC_DEC_TRACE |
---|
644 | stopAtPos ( m_ppcCU[uiDepth]->getSlice()->getPOC(), |
---|
645 | m_ppcCU[uiDepth]->getSlice()->getLayerId(), |
---|
646 | m_ppcCU[uiDepth]->getCUPelX(), |
---|
647 | m_ppcCU[uiDepth]->getCUPelY(), |
---|
648 | m_ppcCU[uiDepth]->getWidth(0), |
---|
649 | m_ppcCU[uiDepth]->getHeight(0) ); |
---|
650 | #endif |
---|
651 | #endif |
---|
652 | |
---|
653 | switch( m_ppcCU[uiDepth]->getPredictionMode(0) ) |
---|
654 | { |
---|
655 | case MODE_INTER: |
---|
656 | #if H_3D_DBBP |
---|
657 | if( m_ppcCU[uiDepth]->getDBBPFlag(0) ) |
---|
658 | { |
---|
659 | xReconInterDBBP( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
660 | } |
---|
661 | else |
---|
662 | { |
---|
663 | #endif |
---|
664 | #if H_3D_INTER_SDC |
---|
665 | #if QC_SDC_UNIFY_G0130 |
---|
666 | if( m_ppcCU[uiDepth]->getSDCFlag( 0 ) ) |
---|
667 | #else |
---|
668 | if( m_ppcCU[uiDepth]->getInterSDCFlag( 0 ) ) |
---|
669 | #endif |
---|
670 | { |
---|
671 | xReconInterSDC( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
672 | } |
---|
673 | else |
---|
674 | { |
---|
675 | #endif |
---|
676 | xReconInter( m_ppcCU[uiDepth], uiDepth ); |
---|
677 | #if H_3D_INTER_SDC |
---|
678 | } |
---|
679 | #endif |
---|
680 | #if H_3D_DBBP |
---|
681 | } |
---|
682 | #endif |
---|
683 | break; |
---|
684 | case MODE_INTRA: |
---|
685 | #if H_3D_DIM_SDC |
---|
686 | if( m_ppcCU[uiDepth]->getSDCFlag(0) ) |
---|
687 | xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth ); |
---|
688 | else |
---|
689 | #endif |
---|
690 | xReconIntraQT( m_ppcCU[uiDepth], uiDepth ); |
---|
691 | break; |
---|
692 | default: |
---|
693 | assert(0); |
---|
694 | break; |
---|
695 | } |
---|
696 | if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false)) |
---|
697 | { |
---|
698 | xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth); |
---|
699 | } |
---|
700 | |
---|
701 | xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth ); |
---|
702 | } |
---|
703 | |
---|
704 | Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth ) |
---|
705 | { |
---|
706 | |
---|
707 | // inter prediction |
---|
708 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
709 | |
---|
710 | // inter recon |
---|
711 | xDecodeInterTexture( pcCU, 0, uiDepth ); |
---|
712 | |
---|
713 | // clip for only non-zero cbp case |
---|
714 | if ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) ) |
---|
715 | { |
---|
716 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
717 | } |
---|
718 | else |
---|
719 | { |
---|
720 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
721 | } |
---|
722 | } |
---|
723 | |
---|
724 | #if H_3D_INTER_SDC |
---|
725 | Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
726 | { |
---|
727 | // inter prediction |
---|
728 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
729 | |
---|
730 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
731 | UInt uiHeight = pcCU->getHeight( 0 ); |
---|
732 | #if !SEC_INTER_SDC_G0101 |
---|
733 | UChar* pMask = pcCU->getInterSDCMask(); |
---|
734 | |
---|
735 | memset( pMask, 0, uiWidth*uiHeight ); |
---|
736 | pcCU->xSetInterSDCCUMask( pcCU, pMask ); |
---|
737 | #endif |
---|
738 | |
---|
739 | Pel *pResi; |
---|
740 | UInt uiPelX, uiPelY; |
---|
741 | UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride(); |
---|
742 | |
---|
743 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr( 0 ); |
---|
744 | for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ ) |
---|
745 | { |
---|
746 | for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ ) |
---|
747 | { |
---|
748 | #if SEC_INTER_SDC_G0101 |
---|
749 | pResi[ uiPelX ] = pcCU->getSDCSegmentDCOffset( 0, 0 ); |
---|
750 | #else |
---|
751 | UChar uiSeg = pMask[ uiPelX + uiPelY*uiWidth ]; |
---|
752 | #if QC_SDC_UNIFY_G0130 |
---|
753 | pResi[ uiPelX ] = pcCU->getSDCSegmentDCOffset( uiSeg, 0 ); |
---|
754 | #else |
---|
755 | pResi[ uiPelX ] = pcCU->getInterSDCSegmentDCOffset( uiSeg, 0 ); |
---|
756 | #endif |
---|
757 | #endif |
---|
758 | } |
---|
759 | pResi += uiResiStride; |
---|
760 | } |
---|
761 | |
---|
762 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
763 | |
---|
764 | // clear UV |
---|
765 | UInt uiStrideC = m_ppcYuvReco[uiDepth]->getCStride(); |
---|
766 | Pel *pRecCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
---|
767 | Pel *pRecCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
---|
768 | |
---|
769 | for (Int y = 0; y < uiHeight/2; y++) |
---|
770 | { |
---|
771 | for (Int x = 0; x < uiWidth/2; x++) |
---|
772 | { |
---|
773 | pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) ); |
---|
774 | pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) ); |
---|
775 | } |
---|
776 | |
---|
777 | pRecCb += uiStrideC; |
---|
778 | pRecCr += uiStrideC; |
---|
779 | } |
---|
780 | } |
---|
781 | #endif |
---|
782 | |
---|
783 | #if H_3D_DBBP |
---|
784 | Void TDecCu::xReconInterDBBP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
785 | { |
---|
786 | AOF(!pcCU->getSlice()->getIsDepth()); |
---|
787 | AOF(!pcCU->getSlice()->isIntra()); |
---|
788 | PartSize ePartSize = pcCU->getPartitionSize( 0 ); |
---|
789 | |
---|
790 | // get collocated depth block |
---|
791 | UInt uiDepthStride = 0; |
---|
792 | Pel* pDepthPels = pcCU->getVirtualDepthBlock(0, pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride); |
---|
793 | AOF( pDepthPels != NULL ); |
---|
794 | AOF( uiDepthStride != 0 ); |
---|
795 | |
---|
796 | // compute mask by segmenting depth block |
---|
797 | Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE]; |
---|
798 | Bool bValidMask = m_pcPrediction->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(0), pcCU->getHeight(0), pMask); |
---|
799 | AOF(bValidMask); |
---|
800 | |
---|
801 | DBBPTmpData* pDBBPTmpData = pcCU->getDBBPTmpData(); |
---|
802 | TComYuv* apSegPredYuv[2] = { m_ppcYuvReco[uiDepth], m_ppcYuvRecoDBBP[uiDepth] }; |
---|
803 | |
---|
804 | // first, extract the two sets of motion parameters |
---|
805 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
806 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
807 | { |
---|
808 | UInt uiPartAddr = uiSegment*uiPUOffset; |
---|
809 | |
---|
810 | pDBBPTmpData->auhInterDir[uiSegment] = pcCU->getInterDir(uiPartAddr); |
---|
811 | |
---|
812 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
813 | { |
---|
814 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
815 | pcCU->getMvField(pcCU, uiPartAddr, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]); |
---|
816 | } |
---|
817 | |
---|
818 | pDBBPTmpData->ahVSPFlag[uiSegment] = pcCU->getVSPFlag( uiPartAddr ); |
---|
819 | pDBBPTmpData->acDvInfo[uiSegment] = pcCU->getDvInfo( uiPartAddr ); |
---|
820 | } |
---|
821 | |
---|
822 | // do motion compensation for each segment as 2Nx2N |
---|
823 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
824 | pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth ); |
---|
825 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
826 | { |
---|
827 | pcCU->setInterDirSubParts( pDBBPTmpData->auhInterDir[uiSegment], 0, 0, uiDepth ); |
---|
828 | |
---|
829 | pcCU->setVSPFlagSubParts( pDBBPTmpData->ahVSPFlag[uiSegment], 0, 0, uiDepth ); |
---|
830 | pcCU->setDvInfoSubParts( pDBBPTmpData->acDvInfo[uiSegment], 0, 0, uiDepth ); |
---|
831 | |
---|
832 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
833 | { |
---|
834 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
835 | |
---|
836 | pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], SIZE_2Nx2N, 0, 0 ); |
---|
837 | } |
---|
838 | |
---|
839 | // inter prediction |
---|
840 | m_pcPrediction->motionCompensation( pcCU, apSegPredYuv[uiSegment] ); |
---|
841 | } |
---|
842 | |
---|
843 | // restore motion information in both segments again |
---|
844 | pcCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); |
---|
845 | pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth ); |
---|
846 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
847 | { |
---|
848 | UInt uiPartAddr = uiSegment*uiPUOffset; |
---|
849 | |
---|
850 | pcCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uiDepth); |
---|
851 | |
---|
852 | pcCU->setVSPFlagSubParts( pDBBPTmpData->ahVSPFlag[uiSegment], uiPartAddr, uiSegment, uiDepth ); |
---|
853 | pcCU->setDvInfoSubParts( pDBBPTmpData->acDvInfo[uiSegment], uiPartAddr, uiSegment, uiDepth ); |
---|
854 | |
---|
855 | pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uiDepth); // interprets depth relative to LCU level |
---|
856 | |
---|
857 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
858 | { |
---|
859 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
860 | |
---|
861 | pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], ePartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level |
---|
862 | } |
---|
863 | } |
---|
864 | |
---|
865 | // reconstruct final prediction signal by combining both segments |
---|
866 | m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0)); |
---|
867 | |
---|
868 | // inter recon |
---|
869 | xDecodeInterTexture( pcCU, 0, uiDepth ); |
---|
870 | |
---|
871 | // clip for only non-zero cbp case |
---|
872 | if ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) ) |
---|
873 | { |
---|
874 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
875 | } |
---|
876 | else |
---|
877 | { |
---|
878 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
879 | } |
---|
880 | } |
---|
881 | #endif |
---|
882 | |
---|
883 | Void |
---|
884 | TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU, |
---|
885 | UInt uiTrDepth, |
---|
886 | UInt uiAbsPartIdx, |
---|
887 | TComYuv* pcRecoYuv, |
---|
888 | TComYuv* pcPredYuv, |
---|
889 | TComYuv* pcResiYuv ) |
---|
890 | { |
---|
891 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> uiTrDepth; |
---|
892 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> uiTrDepth; |
---|
893 | UInt uiStride = pcRecoYuv->getStride (); |
---|
894 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
895 | Pel* piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
896 | Pel* piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
897 | |
---|
898 | UInt uiNumCoeffInc = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ); |
---|
899 | TCoeff* pcCoeff = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
900 | |
---|
901 | UInt uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
902 | |
---|
903 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
904 | Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
905 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
906 | Bool useTransformSkip = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA); |
---|
907 | //===== init availability pattern ===== |
---|
908 | Bool bAboveAvail = false; |
---|
909 | Bool bLeftAvail = false; |
---|
910 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
911 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
912 | m_pcPrediction->getPredicBuf (), |
---|
913 | m_pcPrediction->getPredicBufWidth (), |
---|
914 | m_pcPrediction->getPredicBufHeight (), |
---|
915 | bAboveAvail, bLeftAvail ); |
---|
916 | |
---|
917 | //===== get prediction signal ===== |
---|
918 | #if H_3D_DIM |
---|
919 | if( isDimMode( uiLumaPredMode ) ) |
---|
920 | { |
---|
921 | m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight ); |
---|
922 | } |
---|
923 | else |
---|
924 | { |
---|
925 | #endif |
---|
926 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
927 | #if H_3D_DIM |
---|
928 | } |
---|
929 | #endif |
---|
930 | |
---|
931 | #if H_3D && UPDATE_HM13 |
---|
932 | Bool useDltFlag = (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()); |
---|
933 | |
---|
934 | if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) || useDltFlag ) |
---|
935 | #else |
---|
936 | if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) ) |
---|
937 | #endif |
---|
938 | { |
---|
939 | //===== inverse transform ===== |
---|
940 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
941 | |
---|
942 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA]; |
---|
943 | assert(scalingListType < SCALING_LIST_NUM); |
---|
944 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip ); |
---|
945 | |
---|
946 | |
---|
947 | //===== reconstruction ===== |
---|
948 | Pel* pPred = piPred; |
---|
949 | Pel* pResi = piResi; |
---|
950 | Pel* pReco = piReco; |
---|
951 | Pel* pRecIPred = piRecIPred; |
---|
952 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
953 | { |
---|
954 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
955 | { |
---|
956 | #if H_3D |
---|
957 | #if UPDATE_HM13 |
---|
958 | if ( useDltFlag ) |
---|
959 | #else |
---|
960 | if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) ) |
---|
961 | #endif |
---|
962 | { |
---|
963 | pReco [ uiX ] = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), Clip3( 0, pcCU->getSlice()->getPPS()->getDLT()->getNumDepthValues( pcCU->getSlice()->getLayerIdInVps() ) - 1, pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), pPred[ uiX ] ) + pResi[ uiX ] ) ); |
---|
964 | } |
---|
965 | else |
---|
966 | { |
---|
967 | pReco [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] ); |
---|
968 | } |
---|
969 | #else |
---|
970 | pReco [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] ); |
---|
971 | #endif |
---|
972 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
973 | } |
---|
974 | pPred += uiStride; |
---|
975 | pResi += uiStride; |
---|
976 | pReco += uiStride; |
---|
977 | pRecIPred += uiRecIPredStride; |
---|
978 | } |
---|
979 | } |
---|
980 | else |
---|
981 | { |
---|
982 | //===== reconstruction ===== |
---|
983 | Pel* pPred = piPred; |
---|
984 | Pel* pReco = piReco; |
---|
985 | Pel* pRecIPred = piRecIPred; |
---|
986 | for ( Int y = 0; y < uiHeight; y++ ) |
---|
987 | { |
---|
988 | for ( Int x = 0; x < uiWidth; x++ ) |
---|
989 | { |
---|
990 | pReco [ x ] = pPred[ x ]; |
---|
991 | pRecIPred[ x ] = pReco[ x ]; |
---|
992 | } |
---|
993 | pPred += uiStride; |
---|
994 | pReco += uiStride; |
---|
995 | pRecIPred += uiRecIPredStride; |
---|
996 | } |
---|
997 | } |
---|
998 | } |
---|
999 | |
---|
1000 | |
---|
1001 | Void |
---|
1002 | TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU, |
---|
1003 | UInt uiTrDepth, |
---|
1004 | UInt uiAbsPartIdx, |
---|
1005 | TComYuv* pcRecoYuv, |
---|
1006 | TComYuv* pcPredYuv, |
---|
1007 | TComYuv* pcResiYuv, |
---|
1008 | UInt uiChromaId ) |
---|
1009 | { |
---|
1010 | UInt uiFullDepth = pcCU->getDepth( 0 ) + uiTrDepth; |
---|
1011 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2; |
---|
1012 | |
---|
1013 | if( uiLog2TrSize == 2 ) |
---|
1014 | { |
---|
1015 | assert( uiTrDepth > 0 ); |
---|
1016 | uiTrDepth--; |
---|
1017 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 ); |
---|
1018 | Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 ); |
---|
1019 | if( !bFirstQ ) |
---|
1020 | { |
---|
1021 | return; |
---|
1022 | } |
---|
1023 | } |
---|
1024 | |
---|
1025 | TextType eText = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U ); |
---|
1026 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> ( uiTrDepth + 1 ); |
---|
1027 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> ( uiTrDepth + 1 ); |
---|
1028 | UInt uiStride = pcRecoYuv->getCStride (); |
---|
1029 | Pel* piReco = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
1030 | Pel* piPred = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
1031 | Pel* piResi = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
1032 | |
---|
1033 | UInt uiNumCoeffInc = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2; |
---|
1034 | TCoeff* pcCoeff = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
1035 | |
---|
1036 | UInt uiChromaPredMode = pcCU->getChromaIntraDir( 0 ); |
---|
1037 | |
---|
1038 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
1039 | Pel* piRecIPred = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) ); |
---|
1040 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
1041 | Bool useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText); |
---|
1042 | //===== init availability pattern ===== |
---|
1043 | Bool bAboveAvail = false; |
---|
1044 | Bool bLeftAvail = false; |
---|
1045 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
1046 | |
---|
1047 | pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
1048 | m_pcPrediction->getPredicBuf (), |
---|
1049 | m_pcPrediction->getPredicBufWidth (), |
---|
1050 | m_pcPrediction->getPredicBufHeight (), |
---|
1051 | bAboveAvail, bLeftAvail ); |
---|
1052 | Int* pPatChroma = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) ); |
---|
1053 | |
---|
1054 | //===== get prediction signal ===== |
---|
1055 | { |
---|
1056 | if( uiChromaPredMode == DM_CHROMA_IDX ) |
---|
1057 | { |
---|
1058 | uiChromaPredMode = pcCU->getLumaIntraDir( 0 ); |
---|
1059 | #if H_3D_DIM |
---|
1060 | mapDepthModeToIntraDir( uiChromaPredMode ); |
---|
1061 | #endif |
---|
1062 | } |
---|
1063 | m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
1064 | } |
---|
1065 | |
---|
1066 | if ( pcCU->getCbf( uiAbsPartIdx, eText, uiTrDepth ) ) |
---|
1067 | { |
---|
1068 | //===== inverse transform ===== |
---|
1069 | Int curChromaQpOffset; |
---|
1070 | if(eText == TEXT_CHROMA_U) |
---|
1071 | { |
---|
1072 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
---|
1073 | } |
---|
1074 | else |
---|
1075 | { |
---|
1076 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
---|
1077 | } |
---|
1078 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
1079 | |
---|
1080 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText]; |
---|
1081 | assert(scalingListType < SCALING_LIST_NUM); |
---|
1082 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma ); |
---|
1083 | |
---|
1084 | //===== reconstruction ===== |
---|
1085 | Pel* pPred = piPred; |
---|
1086 | Pel* pResi = piResi; |
---|
1087 | Pel* pReco = piReco; |
---|
1088 | Pel* pRecIPred = piRecIPred; |
---|
1089 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1090 | { |
---|
1091 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1092 | { |
---|
1093 | pReco [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] ); |
---|
1094 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
1095 | } |
---|
1096 | pPred += uiStride; |
---|
1097 | pResi += uiStride; |
---|
1098 | pReco += uiStride; |
---|
1099 | pRecIPred += uiRecIPredStride; |
---|
1100 | } |
---|
1101 | } |
---|
1102 | else |
---|
1103 | { |
---|
1104 | //===== reconstruction ===== |
---|
1105 | Pel* pPred = piPred; |
---|
1106 | Pel* pReco = piReco; |
---|
1107 | Pel* pRecIPred = piRecIPred; |
---|
1108 | for ( Int y = 0; y < uiHeight; y++ ) |
---|
1109 | { |
---|
1110 | for ( Int x = 0; x < uiWidth; x++ ) |
---|
1111 | { |
---|
1112 | pReco [ x ] = pPred[ x ]; |
---|
1113 | pRecIPred[ x ] = pReco[ x ]; |
---|
1114 | } |
---|
1115 | pPred += uiStride; |
---|
1116 | pReco += uiStride; |
---|
1117 | pRecIPred += uiRecIPredStride; |
---|
1118 | } |
---|
1119 | } |
---|
1120 | } |
---|
1121 | |
---|
1122 | |
---|
1123 | Void |
---|
1124 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth ) |
---|
1125 | { |
---|
1126 | UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 ); |
---|
1127 | UInt uiNumPart = pcCU->getNumPartInter(); |
---|
1128 | UInt uiNumQParts = pcCU->getTotalNumPart() >> 2; |
---|
1129 | |
---|
1130 | if (pcCU->getIPCMFlag(0)) |
---|
1131 | { |
---|
1132 | xReconPCM( pcCU, uiDepth ); |
---|
1133 | return; |
---|
1134 | } |
---|
1135 | |
---|
1136 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
1137 | { |
---|
1138 | xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
1139 | } |
---|
1140 | |
---|
1141 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
1142 | { |
---|
1143 | xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
1144 | } |
---|
1145 | |
---|
1146 | } |
---|
1147 | |
---|
1148 | #if H_3D_DIM_SDC |
---|
1149 | Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1150 | { |
---|
1151 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
1152 | UInt uiHeight = pcCU->getHeight ( 0 ); |
---|
1153 | #if QC_PKU_SDC_SPLIT_G0123 |
---|
1154 | #if HS_TSINGHUA_SDC_SPLIT_G0111 |
---|
1155 | #if QC_GENERIC_SDC_G0122 |
---|
1156 | TComWedgelet* dmm4SegmentationOrg = new TComWedgelet( uiWidth, uiHeight ); |
---|
1157 | #endif |
---|
1158 | #else |
---|
1159 | #if QC_GENERIC_SDC_G0122 |
---|
1160 | TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight ); |
---|
1161 | #endif |
---|
1162 | #endif |
---|
1163 | #endif |
---|
1164 | #if QC_PKU_SDC_SPLIT_G0123 |
---|
1165 | UInt numParts = 1; |
---|
1166 | UInt i = 0; |
---|
1167 | UInt sdcDepth = 0; |
---|
1168 | TComYuv* pcRecoYuv = m_ppcYuvReco[uiDepth]; |
---|
1169 | TComYuv* pcPredYuv = m_ppcYuvReco[uiDepth]; |
---|
1170 | TComYuv* pcResiYuv = m_ppcYuvResi[uiDepth]; |
---|
1171 | |
---|
1172 | UInt uiStride = 0; |
---|
1173 | Pel* piReco; |
---|
1174 | Pel* piPred; |
---|
1175 | Pel* piResi; |
---|
1176 | |
---|
1177 | UInt uiZOrder; |
---|
1178 | Pel* piRecIPred; |
---|
1179 | UInt uiRecIPredStride; |
---|
1180 | |
---|
1181 | UInt uiLumaPredMode = 0; |
---|
1182 | |
---|
1183 | #if HS_TSINGHUA_SDC_SPLIT_G0111 |
---|
1184 | if ((uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()) > 1) |
---|
1185 | { |
---|
1186 | numParts = uiWidth * uiWidth >> (2 * pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()); |
---|
1187 | sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize(); |
---|
1188 | uiWidth = uiHeight = (1 << pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()); |
---|
1189 | } |
---|
1190 | #else |
---|
1191 | if (uiWidth == 64) |
---|
1192 | { |
---|
1193 | numParts = 4; |
---|
1194 | sdcDepth = 1; |
---|
1195 | uiWidth = uiHeight = 32; |
---|
1196 | } |
---|
1197 | #endif |
---|
1198 | |
---|
1199 | for ( i = 0; i < numParts; i++ ) |
---|
1200 | { |
---|
1201 | uiStride = pcRecoYuv->getStride (); |
---|
1202 | piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
1203 | piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
1204 | piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
1205 | |
---|
1206 | uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
1207 | piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
1208 | uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
1209 | |
---|
1210 | uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
1211 | |
---|
1212 | AOF( uiWidth == uiHeight ); |
---|
1213 | #else |
---|
1214 | TComYuv* pcRecoYuv = m_ppcYuvReco[uiDepth]; |
---|
1215 | TComYuv* pcPredYuv = m_ppcYuvReco[uiDepth]; |
---|
1216 | TComYuv* pcResiYuv = m_ppcYuvResi[uiDepth]; |
---|
1217 | |
---|
1218 | UInt uiStride = pcRecoYuv->getStride (); |
---|
1219 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
1220 | Pel* piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
1221 | Pel* piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
1222 | |
---|
1223 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
1224 | Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
1225 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
1226 | |
---|
1227 | UInt uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
1228 | |
---|
1229 | AOF( uiWidth == uiHeight ); |
---|
1230 | AOF( uiAbsPartIdx == 0 ); |
---|
1231 | AOF( pcCU->getSDCAvailable(uiAbsPartIdx) ); |
---|
1232 | AOF( pcCU->getSDCFlag(uiAbsPartIdx) ); |
---|
1233 | #endif |
---|
1234 | |
---|
1235 | //===== init availability pattern ===== |
---|
1236 | Bool bAboveAvail = false; |
---|
1237 | Bool bLeftAvail = false; |
---|
1238 | #if QC_PKU_SDC_SPLIT_G0123 |
---|
1239 | pcCU->getPattern()->initPattern ( pcCU, sdcDepth, uiAbsPartIdx ); |
---|
1240 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, sdcDepth, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail ); |
---|
1241 | #else |
---|
1242 | pcCU->getPattern()->initPattern ( pcCU, 0, uiAbsPartIdx ); |
---|
1243 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail ); |
---|
1244 | #endif |
---|
1245 | #if !QC_PKU_SDC_SPLIT_G0123 |
---|
1246 | #if QC_GENERIC_SDC_G0122 |
---|
1247 | TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight ); |
---|
1248 | #endif |
---|
1249 | #endif |
---|
1250 | #if HS_TSINGHUA_SDC_SPLIT_G0111 |
---|
1251 | TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight ); |
---|
1252 | #endif |
---|
1253 | //===== get prediction signal ===== |
---|
1254 | #if H_3D_DIM |
---|
1255 | if( isDimMode( uiLumaPredMode ) ) |
---|
1256 | { |
---|
1257 | m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight |
---|
1258 | #if QC_GENERIC_SDC_G0122 |
---|
1259 | , false, dmm4Segmentation |
---|
1260 | #endif |
---|
1261 | ); |
---|
1262 | #if HS_TSINGHUA_SDC_SPLIT_G0111 |
---|
1263 | Bool* dmm4PatternSplit = dmm4Segmentation->getPattern(); |
---|
1264 | Bool* dmm4PatternOrg = dmm4SegmentationOrg->getPattern(); |
---|
1265 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
1266 | { |
---|
1267 | dmm4PatternOrg[k+(uiAbsPartIdx<<4)] = dmm4PatternSplit[k]; |
---|
1268 | } |
---|
1269 | #endif |
---|
1270 | } |
---|
1271 | else |
---|
1272 | { |
---|
1273 | #endif |
---|
1274 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
1275 | #if H_3D_DIM |
---|
1276 | } |
---|
1277 | #endif |
---|
1278 | #if QC_PKU_SDC_SPLIT_G0123 |
---|
1279 | if ( numParts > 1 ) |
---|
1280 | { |
---|
1281 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1282 | { |
---|
1283 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1284 | { |
---|
1285 | piReco [ uiX ] = ClipY( piPred[ uiX ] ); |
---|
1286 | piRecIPred [ uiX ] = piReco[ uiX ]; |
---|
1287 | } |
---|
1288 | piPred += uiStride; |
---|
1289 | piReco += uiStride; |
---|
1290 | piRecIPred += uiRecIPredStride; |
---|
1291 | } |
---|
1292 | } |
---|
1293 | uiAbsPartIdx += ( (uiWidth * uiWidth) >> 4 ); |
---|
1294 | #if HS_TSINGHUA_SDC_SPLIT_G0111 |
---|
1295 | dmm4Segmentation->destroy(); delete dmm4Segmentation; |
---|
1296 | #endif |
---|
1297 | } |
---|
1298 | uiAbsPartIdx = 0; |
---|
1299 | |
---|
1300 | if ( numParts > 1 ) |
---|
1301 | { |
---|
1302 | uiWidth = pcCU->getWidth( 0 ); |
---|
1303 | uiHeight = pcCU->getHeight( 0 ); |
---|
1304 | } |
---|
1305 | piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
1306 | piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
1307 | piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
1308 | uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
1309 | piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
1310 | uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
1311 | #endif |
---|
1312 | // number of segments depends on prediction mode |
---|
1313 | UInt uiNumSegments = 1; |
---|
1314 | Bool* pbMask = NULL; |
---|
1315 | UInt uiMaskStride = 0; |
---|
1316 | |
---|
1317 | if( getDimType( uiLumaPredMode ) == DMM1_IDX ) |
---|
1318 | { |
---|
1319 | Int uiTabIdx = pcCU->getDmmWedgeTabIdx(DMM1_IDX, uiAbsPartIdx); |
---|
1320 | |
---|
1321 | WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])]; |
---|
1322 | TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx )); |
---|
1323 | |
---|
1324 | uiNumSegments = 2; |
---|
1325 | pbMask = pcWedgelet->getPattern(); |
---|
1326 | uiMaskStride = pcWedgelet->getStride(); |
---|
1327 | } |
---|
1328 | #if QC_GENERIC_SDC_G0122 |
---|
1329 | if( getDimType( uiLumaPredMode ) == DMM4_IDX ) |
---|
1330 | { |
---|
1331 | uiNumSegments = 2; |
---|
1332 | #if HS_TSINGHUA_SDC_SPLIT_G0111 |
---|
1333 | pbMask = dmm4SegmentationOrg->getPattern(); |
---|
1334 | uiMaskStride = dmm4SegmentationOrg->getStride(); |
---|
1335 | #else |
---|
1336 | pbMask = dmm4Segmentation->getPattern(); |
---|
1337 | uiMaskStride = dmm4Segmentation->getStride(); |
---|
1338 | #endif |
---|
1339 | } |
---|
1340 | #endif |
---|
1341 | // get DC prediction for each segment |
---|
1342 | Pel apDCPredValues[2]; |
---|
1343 | m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode); |
---|
1344 | |
---|
1345 | // reconstruct residual based on mask + DC residuals |
---|
1346 | Pel apDCResiValues[2]; |
---|
1347 | for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ ) |
---|
1348 | { |
---|
1349 | #if H_3D_DIM_DLT |
---|
1350 | Pel pPredIdx = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] ); |
---|
1351 | Pel pResiIdx = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); |
---|
1352 | Pel pRecoValue = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx ); |
---|
1353 | |
---|
1354 | apDCResiValues[uiSegment] = pRecoValue - apDCPredValues[uiSegment]; |
---|
1355 | #else |
---|
1356 | apDCResiValues[uiSegment] = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); |
---|
1357 | #endif |
---|
1358 | } |
---|
1359 | |
---|
1360 | //===== reconstruction ===== |
---|
1361 | Bool*pMask = pbMask; |
---|
1362 | Pel* pPred = piPred; |
---|
1363 | Pel* pResi = piResi; |
---|
1364 | Pel* pReco = piReco; |
---|
1365 | Pel* pRecIPred = piRecIPred; |
---|
1366 | |
---|
1367 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1368 | { |
---|
1369 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1370 | { |
---|
1371 | UChar ucSegment = pMask?(UChar)pMask[uiX]:0; |
---|
1372 | assert( ucSegment < uiNumSegments ); |
---|
1373 | |
---|
1374 | Pel pResiDC = apDCResiValues[ucSegment]; |
---|
1375 | |
---|
1376 | pReco [ uiX ] = ClipY( pPred[ uiX ] + pResiDC ); |
---|
1377 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
1378 | } |
---|
1379 | pPred += uiStride; |
---|
1380 | pResi += uiStride; |
---|
1381 | pReco += uiStride; |
---|
1382 | pRecIPred += uiRecIPredStride; |
---|
1383 | pMask += uiMaskStride; |
---|
1384 | } |
---|
1385 | |
---|
1386 | // clear UV |
---|
1387 | UInt uiStrideC = pcPredYuv->getCStride(); |
---|
1388 | Pel *pRecCb = pcPredYuv->getCbAddr(); |
---|
1389 | Pel *pRecCr = pcPredYuv->getCrAddr(); |
---|
1390 | |
---|
1391 | for (Int y=0; y<uiHeight/2; y++) |
---|
1392 | { |
---|
1393 | for (Int x=0; x<uiWidth/2; x++) |
---|
1394 | { |
---|
1395 | pRecCb[x] = 128; |
---|
1396 | pRecCr[x] = 128; |
---|
1397 | } |
---|
1398 | |
---|
1399 | pRecCb += uiStrideC; |
---|
1400 | pRecCr += uiStrideC; |
---|
1401 | } |
---|
1402 | #if QC_GENERIC_SDC_G0122 |
---|
1403 | #if HS_TSINGHUA_SDC_SPLIT_G0111 |
---|
1404 | dmm4SegmentationOrg->destroy(); delete dmm4SegmentationOrg; |
---|
1405 | #else |
---|
1406 | dmm4Segmentation->destroy(); delete dmm4Segmentation; |
---|
1407 | #endif |
---|
1408 | #endif |
---|
1409 | } |
---|
1410 | #endif |
---|
1411 | |
---|
1412 | /** Function for deriving recontructed PU/CU Luma sample with QTree structure |
---|
1413 | * \param pcCU pointer of current CU |
---|
1414 | * \param uiTrDepth current tranform split depth |
---|
1415 | * \param uiAbsPartIdx part index |
---|
1416 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
1417 | * \param pcPredYuv pointer to prediction sample arrays |
---|
1418 | * \param pcResiYuv pointer to residue sample arrays |
---|
1419 | * |
---|
1420 | \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure |
---|
1421 | */ |
---|
1422 | Void |
---|
1423 | TDecCu::xIntraLumaRecQT( TComDataCU* pcCU, |
---|
1424 | UInt uiTrDepth, |
---|
1425 | UInt uiAbsPartIdx, |
---|
1426 | TComYuv* pcRecoYuv, |
---|
1427 | TComYuv* pcPredYuv, |
---|
1428 | TComYuv* pcResiYuv ) |
---|
1429 | { |
---|
1430 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
1431 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
1432 | if( uiTrMode == uiTrDepth ) |
---|
1433 | { |
---|
1434 | xIntraRecLumaBlk ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
1435 | } |
---|
1436 | else |
---|
1437 | { |
---|
1438 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
1439 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
1440 | { |
---|
1441 | xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
1442 | } |
---|
1443 | } |
---|
1444 | } |
---|
1445 | |
---|
1446 | /** Function for deriving recontructed PU/CU chroma samples with QTree structure |
---|
1447 | * \param pcCU pointer of current CU |
---|
1448 | * \param uiTrDepth current tranform split depth |
---|
1449 | * \param uiAbsPartIdx part index |
---|
1450 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
1451 | * \param pcPredYuv pointer to prediction sample arrays |
---|
1452 | * \param pcResiYuv pointer to residue sample arrays |
---|
1453 | * |
---|
1454 | \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure |
---|
1455 | */ |
---|
1456 | Void |
---|
1457 | TDecCu::xIntraChromaRecQT( TComDataCU* pcCU, |
---|
1458 | UInt uiTrDepth, |
---|
1459 | UInt uiAbsPartIdx, |
---|
1460 | TComYuv* pcRecoYuv, |
---|
1461 | TComYuv* pcPredYuv, |
---|
1462 | TComYuv* pcResiYuv ) |
---|
1463 | { |
---|
1464 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
1465 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
1466 | if( uiTrMode == uiTrDepth ) |
---|
1467 | { |
---|
1468 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 ); |
---|
1469 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 ); |
---|
1470 | } |
---|
1471 | else |
---|
1472 | { |
---|
1473 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
1474 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
1475 | { |
---|
1476 | xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
1477 | } |
---|
1478 | } |
---|
1479 | } |
---|
1480 | |
---|
1481 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
1482 | { |
---|
1483 | UInt uiCUAddr = pcCU->getAddr(); |
---|
1484 | |
---|
1485 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx ); |
---|
1486 | |
---|
1487 | return; |
---|
1488 | } |
---|
1489 | |
---|
1490 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1491 | { |
---|
1492 | UInt uiWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
1493 | UInt uiHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
1494 | TCoeff* piCoeff; |
---|
1495 | |
---|
1496 | Pel* pResi; |
---|
1497 | UInt trMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
1498 | |
---|
1499 | // Y |
---|
1500 | piCoeff = pcCU->getCoeffY(); |
---|
1501 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr(); |
---|
1502 | |
---|
1503 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
1504 | |
---|
1505 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
1506 | |
---|
1507 | // Cb and Cr |
---|
1508 | Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
---|
1509 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
1510 | |
---|
1511 | uiWidth >>= 1; |
---|
1512 | uiHeight >>= 1; |
---|
1513 | piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr(); |
---|
1514 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
1515 | |
---|
1516 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
---|
1517 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
1518 | |
---|
1519 | piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr(); |
---|
1520 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
1521 | } |
---|
1522 | |
---|
1523 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
---|
1524 | * \param pcCU pointer to current CU |
---|
1525 | * \param uiPartIdx part index |
---|
1526 | * \param piPCM pointer to PCM code arrays |
---|
1527 | * \param piReco pointer to reconstructed sample arrays |
---|
1528 | * \param uiStride stride of reconstructed sample arrays |
---|
1529 | * \param uiWidth CU width |
---|
1530 | * \param uiHeight CU height |
---|
1531 | * \param ttText texture component type |
---|
1532 | * \returns Void |
---|
1533 | */ |
---|
1534 | Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText) |
---|
1535 | { |
---|
1536 | UInt uiX, uiY; |
---|
1537 | Pel* piPicReco; |
---|
1538 | UInt uiPicStride; |
---|
1539 | UInt uiPcmLeftShiftBit; |
---|
1540 | |
---|
1541 | if( ttText == TEXT_LUMA ) |
---|
1542 | { |
---|
1543 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(); |
---|
1544 | piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
1545 | uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
1546 | } |
---|
1547 | else |
---|
1548 | { |
---|
1549 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
1550 | |
---|
1551 | if( ttText == TEXT_CHROMA_U ) |
---|
1552 | { |
---|
1553 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
1554 | } |
---|
1555 | else |
---|
1556 | { |
---|
1557 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
1558 | } |
---|
1559 | uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
1560 | } |
---|
1561 | |
---|
1562 | for( uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1563 | { |
---|
1564 | for( uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1565 | { |
---|
1566 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
---|
1567 | piPicReco[uiX] = piReco[uiX]; |
---|
1568 | } |
---|
1569 | piPCM += uiWidth; |
---|
1570 | piReco += uiStride; |
---|
1571 | piPicReco += uiPicStride; |
---|
1572 | } |
---|
1573 | } |
---|
1574 | |
---|
1575 | /** Function for reconstructing a PCM mode CU. |
---|
1576 | * \param pcCU pointer to current CU |
---|
1577 | * \param uiDepth CU Depth |
---|
1578 | * \returns Void |
---|
1579 | */ |
---|
1580 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth ) |
---|
1581 | { |
---|
1582 | // Luma |
---|
1583 | UInt uiWidth = (g_uiMaxCUWidth >> uiDepth); |
---|
1584 | UInt uiHeight = (g_uiMaxCUHeight >> uiDepth); |
---|
1585 | |
---|
1586 | Pel* piPcmY = pcCU->getPCMSampleY(); |
---|
1587 | Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth); |
---|
1588 | |
---|
1589 | UInt uiStride = m_ppcYuvResi[uiDepth]->getStride(); |
---|
1590 | |
---|
1591 | xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA); |
---|
1592 | |
---|
1593 | // Cb and Cr |
---|
1594 | UInt uiCWidth = (uiWidth>>1); |
---|
1595 | UInt uiCHeight = (uiHeight>>1); |
---|
1596 | |
---|
1597 | Pel* piPcmCb = pcCU->getPCMSampleCb(); |
---|
1598 | Pel* piPcmCr = pcCU->getPCMSampleCr(); |
---|
1599 | Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
---|
1600 | Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
---|
1601 | |
---|
1602 | UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride(); |
---|
1603 | |
---|
1604 | xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U); |
---|
1605 | xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V); |
---|
1606 | } |
---|
1607 | |
---|
1608 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
---|
1609 | * \param pcCU pointer to current CU |
---|
1610 | * \param uiDepth CU Depth |
---|
1611 | * \returns Void |
---|
1612 | */ |
---|
1613 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth) |
---|
1614 | { |
---|
1615 | // Luma |
---|
1616 | UInt width = (g_uiMaxCUWidth >> depth); |
---|
1617 | UInt height = (g_uiMaxCUHeight >> depth); |
---|
1618 | |
---|
1619 | Pel* pPcmY = pCU->getPCMSampleY(); |
---|
1620 | Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width); |
---|
1621 | |
---|
1622 | UInt stride = m_ppcYuvReco[depth]->getStride(); |
---|
1623 | |
---|
1624 | for(Int y = 0; y < height; y++ ) |
---|
1625 | { |
---|
1626 | for(Int x = 0; x < width; x++ ) |
---|
1627 | { |
---|
1628 | pPcmY[x] = pRecoY[x]; |
---|
1629 | } |
---|
1630 | pPcmY += width; |
---|
1631 | pRecoY += stride; |
---|
1632 | } |
---|
1633 | |
---|
1634 | // Cb and Cr |
---|
1635 | UInt widthC = (width>>1); |
---|
1636 | UInt heightC = (height>>1); |
---|
1637 | |
---|
1638 | Pel* pPcmCb = pCU->getPCMSampleCb(); |
---|
1639 | Pel* pPcmCr = pCU->getPCMSampleCr(); |
---|
1640 | Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr(); |
---|
1641 | Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr(); |
---|
1642 | |
---|
1643 | UInt strideC = m_ppcYuvReco[depth]->getCStride(); |
---|
1644 | |
---|
1645 | for(Int y = 0; y < heightC; y++ ) |
---|
1646 | { |
---|
1647 | for(Int x = 0; x < widthC; x++ ) |
---|
1648 | { |
---|
1649 | pPcmCb[x] = pRecoCb[x]; |
---|
1650 | pPcmCr[x] = pRecoCr[x]; |
---|
1651 | } |
---|
1652 | pPcmCr += widthC; |
---|
1653 | pPcmCb += widthC; |
---|
1654 | pRecoCb += strideC; |
---|
1655 | pRecoCr += strideC; |
---|
1656 | } |
---|
1657 | |
---|
1658 | } |
---|
1659 | |
---|
1660 | //! \} |
---|