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