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 | if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
295 | { |
---|
296 | setdQPFlag(true); |
---|
297 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
298 | } |
---|
299 | #if H_3D_NBDV |
---|
300 | DisInfo DvInfo; |
---|
301 | DvInfo.bDV = false; |
---|
302 | DvInfo.m_acNBDV.setZero(); |
---|
303 | DvInfo.m_aVIdxCan = 0; |
---|
304 | #if H_3D_NBDV_REF |
---|
305 | DvInfo.m_acDoNBDV.setZero(); |
---|
306 | #endif |
---|
307 | |
---|
308 | |
---|
309 | if(!pcCU->getSlice()->isIntra()) |
---|
310 | { |
---|
311 | #if H_3D_ARP && H_3D_IV_MERGE |
---|
312 | if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getIvMvPredFlag() ) |
---|
313 | #else |
---|
314 | #if H_3D_ARP |
---|
315 | if( pcCU->getSlice()->getVPS()->getUseAdvRP(pcCU->getSlice()->getLayerId()) ) |
---|
316 | #else |
---|
317 | #if H_3D_IV_MERGE |
---|
318 | if( pcCU->getSlice()->getVPS()->getIvMvPredFlag(pcCU->getSlice()->getLayerId()) ) |
---|
319 | #else |
---|
320 | if (0) |
---|
321 | #endif |
---|
322 | #endif |
---|
323 | #endif |
---|
324 | { |
---|
325 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true ); |
---|
326 | m_ppcCU[uiDepth]->copyDVInfoFrom( pcCU, uiAbsPartIdx); |
---|
327 | PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0); |
---|
328 | UChar cWidTemp = m_ppcCU[uiDepth]->getWidth(0); |
---|
329 | UChar cHeightTemp = m_ppcCU[uiDepth]->getHeight(0); |
---|
330 | m_ppcCU[uiDepth]->setWidth ( 0, pcCU->getSlice()->getSPS()->getMaxCUWidth ()/(1<<uiDepth) ); |
---|
331 | m_ppcCU[uiDepth]->setHeight ( 0, pcCU->getSlice()->getSPS()->getMaxCUHeight()/(1<<uiDepth) ); |
---|
332 | m_ppcCU[uiDepth]->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
333 | #if H_3D_IV_MERGE |
---|
334 | if( pcCU->getSlice()->getIsDepth()) |
---|
335 | { |
---|
336 | DvInfo.bDV = m_ppcCU[uiDepth]->getDispforDepth(0, 0, &DvInfo); |
---|
337 | } |
---|
338 | else |
---|
339 | { |
---|
340 | #endif |
---|
341 | #if H_3D_NBDV_REF |
---|
342 | if( pcCU->getSlice()->getDepthBasedBlkPartFlag() ) //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done. |
---|
343 | { |
---|
344 | DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo, true); |
---|
345 | } |
---|
346 | else |
---|
347 | #endif |
---|
348 | { |
---|
349 | DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo); |
---|
350 | } |
---|
351 | #if H_3D_IV_MERGE |
---|
352 | } |
---|
353 | #endif |
---|
354 | #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC |
---|
355 | if ( g_decTraceDispDer ) |
---|
356 | { |
---|
357 | DTRACE_CU( "RefViewIdx", DvInfo.m_aVIdxCan ); |
---|
358 | DTRACE_CU( "MvDisp[x]", DvInfo.m_acNBDV.getHor() ); |
---|
359 | DTRACE_CU( "MvDisp[y]", DvInfo.m_acNBDV.getVer() ); |
---|
360 | DTRACE_CU( "MvRefinedDisp[x]", DvInfo.m_acDoNBDV.getHor() ); |
---|
361 | DTRACE_CU( "MvRefinedDisp[y]", DvInfo.m_acDoNBDV.getVer() ); |
---|
362 | } |
---|
363 | #endif |
---|
364 | |
---|
365 | pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth); |
---|
366 | m_ppcCU[uiDepth]->setPartSizeSubParts( ePartTemp, 0, uiDepth ); |
---|
367 | m_ppcCU[uiDepth]->setWidth ( 0, cWidTemp ); |
---|
368 | m_ppcCU[uiDepth]->setHeight ( 0, cHeightTemp ); |
---|
369 | } |
---|
370 | } |
---|
371 | #endif |
---|
372 | if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) |
---|
373 | { |
---|
374 | m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
375 | } |
---|
376 | |
---|
377 | // decode CU mode and the partition size |
---|
378 | if( !pcCU->getSlice()->isIntra()) |
---|
379 | { |
---|
380 | m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
381 | } |
---|
382 | |
---|
383 | if( pcCU->isSkipped(uiAbsPartIdx) ) |
---|
384 | { |
---|
385 | #if H_MV_ENC_DEC_TRAC |
---|
386 | DTRACE_PU_S("=========== prediction_unit ===========\n") |
---|
387 | DTRACE_PU("x0", uiLPelX) |
---|
388 | DTRACE_PU("x1", uiTPelY) |
---|
389 | #endif |
---|
390 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
391 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
392 | #if H_3D_IV_MERGE |
---|
393 | m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx); |
---|
394 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
---|
395 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
---|
396 | #else |
---|
397 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
398 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
399 | #endif |
---|
400 | Int numValidMergeCand = 0; |
---|
401 | for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
402 | { |
---|
403 | uhInterDirNeighbours[ui] = 0; |
---|
404 | } |
---|
405 | m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth ); |
---|
406 | UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx); |
---|
407 | #if H_3D_ARP |
---|
408 | m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth ); |
---|
409 | #endif |
---|
410 | #if H_3D_IC |
---|
411 | m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
412 | #endif |
---|
413 | |
---|
414 | #if H_3D_VSP |
---|
415 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
416 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
---|
417 | #if H_3D_SPIVMP |
---|
418 | Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
419 | memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); |
---|
420 | TComMvField* pcMvFieldSP; |
---|
421 | UChar* puhInterDirSP; |
---|
422 | pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartition()*2]; |
---|
423 | puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartition()]; |
---|
424 | #endif |
---|
425 | m_ppcCU[uiDepth]->initAvailableFlags(); |
---|
426 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
427 | m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours |
---|
428 | #if H_3D_SPIVMP |
---|
429 | , pcMvFieldSP, puhInterDirSP |
---|
430 | #endif |
---|
431 | , numValidMergeCand, uiMergeIndex ); |
---|
432 | |
---|
433 | m_ppcCU[uiDepth]->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours, vspFlag |
---|
434 | #if H_3D_SPIVMP |
---|
435 | , bSPIVMPFlag |
---|
436 | #endif |
---|
437 | , numValidMergeCand ); |
---|
438 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
439 | #else |
---|
440 | #if H_3D |
---|
441 | m_ppcCU[uiDepth]->initAvailableFlags(); |
---|
442 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
443 | m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
444 | #else |
---|
445 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
446 | #endif |
---|
447 | #endif |
---|
448 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
449 | |
---|
450 | TComMv cTmpMv( 0, 0 ); |
---|
451 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
452 | { |
---|
453 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
454 | { |
---|
455 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
456 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
457 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
458 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
459 | #if H_3D_VSP |
---|
460 | if( pcCU->getVSPFlag( uiAbsPartIdx ) != 0 ) |
---|
461 | { |
---|
462 | if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) ) |
---|
463 | { |
---|
464 | UInt dummy; |
---|
465 | Int vspSize; |
---|
466 | Int width, height; |
---|
467 | m_ppcCU[uiDepth]->getPartIndexAndSize( uiAbsPartIdx, dummy, width, height ); |
---|
468 | m_ppcCU[uiDepth]->setMvFieldPUForVSP( pcCU, uiAbsPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize ); |
---|
469 | pcCU->setVSPFlag( uiAbsPartIdx, vspSize ); |
---|
470 | } |
---|
471 | } |
---|
472 | #endif |
---|
473 | #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC |
---|
474 | if ( g_decTraceMvFromMerge ) |
---|
475 | { |
---|
476 | if ( uiRefListIdx == 0 ) |
---|
477 | { |
---|
478 | DTRACE_PU( "mvL0[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor()); |
---|
479 | DTRACE_PU( "mvL0[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer()); |
---|
480 | DTRACE_PU( "refIdxL0 ", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx()); |
---|
481 | } |
---|
482 | else |
---|
483 | { |
---|
484 | DTRACE_PU( "mvL1[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor()); |
---|
485 | DTRACE_PU( "mvL1[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer()); |
---|
486 | DTRACE_PU( "refIdxL1", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx()); |
---|
487 | } |
---|
488 | } |
---|
489 | #endif |
---|
490 | } |
---|
491 | } |
---|
492 | #if H_3D_SPIVMP |
---|
493 | pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
494 | if (bSPIVMPFlag[uiMergeIndex]) |
---|
495 | { |
---|
496 | UInt uiSPAddr; |
---|
497 | Int iWidth = pcCU->getWidth(uiAbsPartIdx); |
---|
498 | Int iHeight = pcCU->getHeight(uiAbsPartIdx); |
---|
499 | |
---|
500 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
---|
501 | |
---|
502 | pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
---|
503 | |
---|
504 | for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++) |
---|
505 | { |
---|
506 | pcCU->getSPAbsPartIdx(uiAbsPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr); |
---|
507 | pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight); |
---|
508 | pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight); |
---|
509 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight); |
---|
510 | } |
---|
511 | } |
---|
512 | delete[] pcMvFieldSP; |
---|
513 | delete[] puhInterDirSP; |
---|
514 | #endif |
---|
515 | |
---|
516 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
517 | #if H_3D_IV_MERGE |
---|
518 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
---|
519 | #endif |
---|
520 | return; |
---|
521 | } |
---|
522 | #if H_3D_SINGLE_DEPTH |
---|
523 | m_pcEntropyDecoder->decodeSingleDepthMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
524 | if(!pcCU->getSingleDepthFlag(uiAbsPartIdx)) |
---|
525 | { |
---|
526 | #endif |
---|
527 | m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
528 | m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
529 | |
---|
530 | #if H_3D_DIM_SDC |
---|
531 | m_pcEntropyDecoder->decodeSDCFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
532 | #endif |
---|
533 | if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
---|
534 | { |
---|
535 | m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
536 | |
---|
537 | if(pcCU->getIPCMFlag(uiAbsPartIdx)) |
---|
538 | { |
---|
539 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
540 | #if H_3D_IV_MERGE |
---|
541 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
---|
542 | #endif |
---|
543 | return; |
---|
544 | } |
---|
545 | } |
---|
546 | |
---|
547 | UInt uiCurrWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
548 | UInt uiCurrHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
549 | |
---|
550 | // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
551 | m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); |
---|
552 | // Coefficient decoding |
---|
553 | Bool bCodeDQP = getdQPFlag(); |
---|
554 | m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP ); |
---|
555 | setdQPFlag( bCodeDQP ); |
---|
556 | #if H_3D_SINGLE_DEPTH |
---|
557 | } |
---|
558 | #endif |
---|
559 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
560 | #if H_3D_IV_MERGE |
---|
561 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
---|
562 | #endif |
---|
563 | } |
---|
564 | |
---|
565 | Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast) |
---|
566 | { |
---|
567 | if( pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
568 | { |
---|
569 | pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP |
---|
570 | } |
---|
571 | |
---|
572 | ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth); |
---|
573 | } |
---|
574 | |
---|
575 | Void TDecCu::xDecompressCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
576 | { |
---|
577 | TComPic* pcPic = pcCU->getPic(); |
---|
578 | #if !H_3D_IV_MERGE |
---|
579 | Bool bBoundary = false; |
---|
580 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
581 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
582 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
583 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
584 | |
---|
585 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
586 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
587 | Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr(); |
---|
588 | if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
589 | { |
---|
590 | bBoundary = true; |
---|
591 | } |
---|
592 | |
---|
593 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
594 | { |
---|
595 | UInt uiNextDepth = uiDepth + 1; |
---|
596 | UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1); |
---|
597 | UInt uiIdx = uiAbsPartIdx; |
---|
598 | for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ ) |
---|
599 | { |
---|
600 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
601 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
602 | |
---|
603 | Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getSliceSegmentCurEndCUAddr()); |
---|
604 | if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
605 | { |
---|
606 | xDecompressCU(pcCU, uiIdx, uiNextDepth ); |
---|
607 | } |
---|
608 | |
---|
609 | uiIdx += uiQNumParts; |
---|
610 | } |
---|
611 | return; |
---|
612 | } |
---|
613 | #endif |
---|
614 | // Residual reconstruction |
---|
615 | m_ppcYuvResi[uiDepth]->clear(); |
---|
616 | |
---|
617 | m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth ); |
---|
618 | |
---|
619 | #if H_MV_ENC_DEC_TRAC |
---|
620 | #if ENC_DEC_TRACE |
---|
621 | stopAtPos ( m_ppcCU[uiDepth]->getSlice()->getPOC(), |
---|
622 | m_ppcCU[uiDepth]->getSlice()->getLayerId(), |
---|
623 | m_ppcCU[uiDepth]->getCUPelX(), |
---|
624 | m_ppcCU[uiDepth]->getCUPelY(), |
---|
625 | m_ppcCU[uiDepth]->getWidth(0), |
---|
626 | m_ppcCU[uiDepth]->getHeight(0) ); |
---|
627 | #endif |
---|
628 | #endif |
---|
629 | |
---|
630 | switch( m_ppcCU[uiDepth]->getPredictionMode(0) ) |
---|
631 | { |
---|
632 | case MODE_INTER: |
---|
633 | #if H_3D_DBBP |
---|
634 | if( m_ppcCU[uiDepth]->getDBBPFlag(0) ) |
---|
635 | { |
---|
636 | xReconInterDBBP( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
637 | } |
---|
638 | else |
---|
639 | { |
---|
640 | #endif |
---|
641 | #if H_3D_INTER_SDC |
---|
642 | if( m_ppcCU[uiDepth]->getSDCFlag( 0 ) ) |
---|
643 | { |
---|
644 | xReconInterSDC( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
645 | } |
---|
646 | else |
---|
647 | { |
---|
648 | #endif |
---|
649 | xReconInter( m_ppcCU[uiDepth], uiDepth ); |
---|
650 | #if H_3D_INTER_SDC |
---|
651 | } |
---|
652 | #endif |
---|
653 | #if H_3D_DBBP |
---|
654 | } |
---|
655 | #endif |
---|
656 | break; |
---|
657 | case MODE_INTRA: |
---|
658 | #if H_3D_SINGLE_DEPTH |
---|
659 | if( m_ppcCU[uiDepth]->getSingleDepthFlag(0) ) |
---|
660 | xReconIntraSingleDepth( m_ppcCU[uiDepth], 0, uiDepth ); |
---|
661 | #if H_3D_DIM_SDC |
---|
662 | else if( m_ppcCU[uiDepth]->getSDCFlag(0) ) |
---|
663 | xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth ); |
---|
664 | #endif |
---|
665 | else |
---|
666 | #else |
---|
667 | #if H_3D_DIM_SDC |
---|
668 | if( m_ppcCU[uiDepth]->getSDCFlag(0) ) |
---|
669 | xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth ); |
---|
670 | else |
---|
671 | #endif |
---|
672 | #endif |
---|
673 | xReconIntraQT( m_ppcCU[uiDepth], uiDepth ); |
---|
674 | break; |
---|
675 | default: |
---|
676 | assert(0); |
---|
677 | break; |
---|
678 | } |
---|
679 | if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false)) |
---|
680 | { |
---|
681 | xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth); |
---|
682 | } |
---|
683 | |
---|
684 | xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth ); |
---|
685 | } |
---|
686 | |
---|
687 | Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth ) |
---|
688 | { |
---|
689 | |
---|
690 | // inter prediction |
---|
691 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
692 | |
---|
693 | // inter recon |
---|
694 | xDecodeInterTexture( pcCU, 0, uiDepth ); |
---|
695 | |
---|
696 | // clip for only non-zero cbp case |
---|
697 | if ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) ) |
---|
698 | { |
---|
699 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
700 | } |
---|
701 | else |
---|
702 | { |
---|
703 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
704 | } |
---|
705 | } |
---|
706 | #if H_3D_SINGLE_DEPTH |
---|
707 | Void TDecCu::xReconIntraSingleDepth( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
708 | { |
---|
709 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
710 | UInt uiHeight = pcCU->getHeight ( 0 ); |
---|
711 | |
---|
712 | TComYuv* pcRecoYuv = m_ppcYuvReco[uiDepth]; |
---|
713 | |
---|
714 | UInt uiStride = pcRecoYuv->getStride (); |
---|
715 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
716 | |
---|
717 | |
---|
718 | AOF( uiWidth == uiHeight ); |
---|
719 | AOF( uiAbsPartIdx == 0 ); |
---|
720 | |
---|
721 | //construction of depth candidates |
---|
722 | Pel testDepth; |
---|
723 | Pel DepthNeighbours[2]; |
---|
724 | Int index =0; |
---|
725 | for( Int i = 0; (i < 2) && (index<SINGLE_DEPTH_MODE_CAND_LIST_SIZE) ; i++ ) |
---|
726 | { |
---|
727 | if(!pcCU->getNeighDepth (0, uiAbsPartIdx, &testDepth, i)) |
---|
728 | { |
---|
729 | continue; |
---|
730 | } |
---|
731 | DepthNeighbours[index]=testDepth; |
---|
732 | index++; |
---|
733 | } |
---|
734 | |
---|
735 | if(index==0) |
---|
736 | { |
---|
737 | DepthNeighbours[index]=1<<(g_bitDepthY-1); |
---|
738 | index++; |
---|
739 | } |
---|
740 | |
---|
741 | if(index==1) |
---|
742 | { |
---|
743 | DepthNeighbours[index]=ClipY(DepthNeighbours[0] + 1 ); |
---|
744 | index++; |
---|
745 | } |
---|
746 | |
---|
747 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
748 | { |
---|
749 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
750 | { |
---|
751 | piReco[ uiX ] =DepthNeighbours[(Int)pcCU->getSingleDepthValue(uiAbsPartIdx)]; |
---|
752 | } |
---|
753 | piReco += uiStride; |
---|
754 | } |
---|
755 | |
---|
756 | // clear UV |
---|
757 | UInt uiStrideC = pcRecoYuv->getCStride(); |
---|
758 | Pel *pRecCb = pcRecoYuv->getCbAddr(); |
---|
759 | Pel *pRecCr = pcRecoYuv->getCrAddr(); |
---|
760 | |
---|
761 | for (Int y=0; y<uiHeight/2; y++) |
---|
762 | { |
---|
763 | for (Int x=0; x<uiWidth/2; x++) |
---|
764 | { |
---|
765 | pRecCb[x] = 1<<(g_bitDepthC-1); |
---|
766 | pRecCr[x] = 1<<(g_bitDepthC-1); |
---|
767 | } |
---|
768 | |
---|
769 | pRecCb += uiStrideC; |
---|
770 | pRecCr += uiStrideC; |
---|
771 | } |
---|
772 | } |
---|
773 | #endif |
---|
774 | #if H_3D_INTER_SDC |
---|
775 | Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
776 | { |
---|
777 | // inter prediction |
---|
778 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
779 | |
---|
780 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
781 | UInt uiHeight = pcCU->getHeight( 0 ); |
---|
782 | |
---|
783 | Pel *pResi; |
---|
784 | UInt uiPelX, uiPelY; |
---|
785 | UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride(); |
---|
786 | |
---|
787 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr( 0 ); |
---|
788 | for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ ) |
---|
789 | { |
---|
790 | for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ ) |
---|
791 | { |
---|
792 | pResi[ uiPelX ] = pcCU->getSDCSegmentDCOffset( 0, 0 ); |
---|
793 | } |
---|
794 | pResi += uiResiStride; |
---|
795 | } |
---|
796 | |
---|
797 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
798 | |
---|
799 | // clear UV |
---|
800 | UInt uiStrideC = m_ppcYuvReco[uiDepth]->getCStride(); |
---|
801 | Pel *pRecCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
---|
802 | Pel *pRecCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
---|
803 | |
---|
804 | for (Int y = 0; y < uiHeight/2; y++) |
---|
805 | { |
---|
806 | for (Int x = 0; x < uiWidth/2; x++) |
---|
807 | { |
---|
808 | pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) ); |
---|
809 | pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) ); |
---|
810 | } |
---|
811 | |
---|
812 | pRecCb += uiStrideC; |
---|
813 | pRecCr += uiStrideC; |
---|
814 | } |
---|
815 | } |
---|
816 | #endif |
---|
817 | |
---|
818 | #if H_3D_DBBP |
---|
819 | Void TDecCu::xReconInterDBBP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
820 | { |
---|
821 | AOF(!pcCU->getSlice()->getIsDepth()); |
---|
822 | AOF(!pcCU->getSlice()->isIntra()); |
---|
823 | PartSize ePartSize = pcCU->getPartitionSize( 0 ); |
---|
824 | |
---|
825 | // get collocated depth block |
---|
826 | UInt uiDepthStride = 0; |
---|
827 | #if H_3D_FCO |
---|
828 | Pel* pDepthPels = pcCU->getVirtualDepthBlock(pcCU->getZorderIdxInCU(), pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride); |
---|
829 | #else |
---|
830 | Pel* pDepthPels = pcCU->getVirtualDepthBlock(0, pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride); |
---|
831 | #endif |
---|
832 | AOF( pDepthPels != NULL ); |
---|
833 | AOF( uiDepthStride != 0 ); |
---|
834 | |
---|
835 | // compute mask by segmenting depth block |
---|
836 | Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE]; |
---|
837 | Bool bValidMask = m_pcPrediction->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(0), pcCU->getHeight(0), pMask); |
---|
838 | AOF(bValidMask); |
---|
839 | |
---|
840 | DBBPTmpData* pDBBPTmpData = pcCU->getDBBPTmpData(); |
---|
841 | TComYuv* apSegPredYuv[2] = { m_ppcYuvReco[uiDepth], m_ppcYuvRecoDBBP[uiDepth] }; |
---|
842 | |
---|
843 | // first, extract the two sets of motion parameters |
---|
844 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
845 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
846 | { |
---|
847 | UInt uiPartAddr = uiSegment*uiPUOffset; |
---|
848 | |
---|
849 | pDBBPTmpData->auhInterDir[uiSegment] = pcCU->getInterDir(uiPartAddr); |
---|
850 | |
---|
851 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
852 | { |
---|
853 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
854 | pcCU->getMvField(pcCU, uiPartAddr, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]); |
---|
855 | } |
---|
856 | |
---|
857 | AOF( pcCU->getARPW(uiPartAddr) == 0 ); |
---|
858 | AOF( pcCU->getICFlag(uiPartAddr) == false ); |
---|
859 | AOF( pcCU->getSPIVMPFlag(uiPartAddr) == false ); |
---|
860 | AOF( pcCU->getVSPFlag(uiPartAddr) == 0 ); |
---|
861 | } |
---|
862 | |
---|
863 | // do motion compensation for each segment as 2Nx2N |
---|
864 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
865 | pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth ); |
---|
866 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
867 | { |
---|
868 | pcCU->setInterDirSubParts( pDBBPTmpData->auhInterDir[uiSegment], 0, 0, uiDepth ); |
---|
869 | |
---|
870 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
871 | { |
---|
872 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
873 | |
---|
874 | pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], SIZE_2Nx2N, 0, 0 ); |
---|
875 | } |
---|
876 | |
---|
877 | // inter prediction |
---|
878 | m_pcPrediction->motionCompensation( pcCU, apSegPredYuv[uiSegment] ); |
---|
879 | } |
---|
880 | |
---|
881 | // restore motion information in both segments again |
---|
882 | pcCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); |
---|
883 | pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth ); |
---|
884 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
885 | { |
---|
886 | UInt uiPartAddr = uiSegment*uiPUOffset; |
---|
887 | |
---|
888 | pcCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uiDepth); |
---|
889 | pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uiDepth); // interprets depth relative to LCU level |
---|
890 | |
---|
891 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
892 | { |
---|
893 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
894 | |
---|
895 | pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], ePartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level |
---|
896 | } |
---|
897 | } |
---|
898 | |
---|
899 | // reconstruct final prediction signal by combining both segments |
---|
900 | m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0), 0, ePartSize); |
---|
901 | |
---|
902 | // inter recon |
---|
903 | xDecodeInterTexture( pcCU, 0, uiDepth ); |
---|
904 | |
---|
905 | // clip for only non-zero cbp case |
---|
906 | if ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) ) |
---|
907 | { |
---|
908 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
909 | } |
---|
910 | else |
---|
911 | { |
---|
912 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
913 | } |
---|
914 | } |
---|
915 | #endif |
---|
916 | |
---|
917 | Void |
---|
918 | TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU, |
---|
919 | UInt uiTrDepth, |
---|
920 | UInt uiAbsPartIdx, |
---|
921 | TComYuv* pcRecoYuv, |
---|
922 | TComYuv* pcPredYuv, |
---|
923 | TComYuv* pcResiYuv ) |
---|
924 | { |
---|
925 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> uiTrDepth; |
---|
926 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> uiTrDepth; |
---|
927 | UInt uiStride = pcRecoYuv->getStride (); |
---|
928 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
929 | Pel* piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
930 | Pel* piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
931 | |
---|
932 | UInt uiNumCoeffInc = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ); |
---|
933 | TCoeff* pcCoeff = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
934 | |
---|
935 | UInt uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
936 | |
---|
937 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
938 | Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
939 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
940 | Bool useTransformSkip = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA); |
---|
941 | //===== init availability pattern ===== |
---|
942 | Bool bAboveAvail = false; |
---|
943 | Bool bLeftAvail = false; |
---|
944 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
945 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
946 | m_pcPrediction->getPredicBuf (), |
---|
947 | m_pcPrediction->getPredicBufWidth (), |
---|
948 | m_pcPrediction->getPredicBufHeight (), |
---|
949 | bAboveAvail, bLeftAvail ); |
---|
950 | |
---|
951 | //===== get prediction signal ===== |
---|
952 | #if H_3D_DIM |
---|
953 | if( isDimMode( uiLumaPredMode ) ) |
---|
954 | { |
---|
955 | m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight ); |
---|
956 | } |
---|
957 | else |
---|
958 | { |
---|
959 | #endif |
---|
960 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
961 | #if H_3D_DIM |
---|
962 | } |
---|
963 | #endif |
---|
964 | |
---|
965 | #if H_3D |
---|
966 | Bool useDltFlag = (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()); |
---|
967 | |
---|
968 | if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) || useDltFlag ) |
---|
969 | #else |
---|
970 | if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) ) |
---|
971 | #endif |
---|
972 | { |
---|
973 | //===== inverse transform ===== |
---|
974 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
975 | |
---|
976 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA]; |
---|
977 | assert(scalingListType < SCALING_LIST_NUM); |
---|
978 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip ); |
---|
979 | |
---|
980 | |
---|
981 | //===== reconstruction ===== |
---|
982 | Pel* pPred = piPred; |
---|
983 | Pel* pResi = piResi; |
---|
984 | Pel* pReco = piReco; |
---|
985 | Pel* pRecIPred = piRecIPred; |
---|
986 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
987 | { |
---|
988 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
989 | { |
---|
990 | pReco [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] ); |
---|
991 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
992 | } |
---|
993 | pPred += uiStride; |
---|
994 | pResi += uiStride; |
---|
995 | pReco += uiStride; |
---|
996 | pRecIPred += uiRecIPredStride; |
---|
997 | } |
---|
998 | } |
---|
999 | else |
---|
1000 | { |
---|
1001 | //===== reconstruction ===== |
---|
1002 | Pel* pPred = piPred; |
---|
1003 | Pel* pReco = piReco; |
---|
1004 | Pel* pRecIPred = piRecIPred; |
---|
1005 | for ( Int y = 0; y < uiHeight; y++ ) |
---|
1006 | { |
---|
1007 | for ( Int x = 0; x < uiWidth; x++ ) |
---|
1008 | { |
---|
1009 | pReco [ x ] = pPred[ x ]; |
---|
1010 | pRecIPred[ x ] = pReco[ x ]; |
---|
1011 | } |
---|
1012 | pPred += uiStride; |
---|
1013 | pReco += uiStride; |
---|
1014 | pRecIPred += uiRecIPredStride; |
---|
1015 | } |
---|
1016 | } |
---|
1017 | } |
---|
1018 | |
---|
1019 | |
---|
1020 | Void |
---|
1021 | TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU, |
---|
1022 | UInt uiTrDepth, |
---|
1023 | UInt uiAbsPartIdx, |
---|
1024 | TComYuv* pcRecoYuv, |
---|
1025 | TComYuv* pcPredYuv, |
---|
1026 | TComYuv* pcResiYuv, |
---|
1027 | UInt uiChromaId ) |
---|
1028 | { |
---|
1029 | UInt uiFullDepth = pcCU->getDepth( 0 ) + uiTrDepth; |
---|
1030 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2; |
---|
1031 | |
---|
1032 | if( uiLog2TrSize == 2 ) |
---|
1033 | { |
---|
1034 | assert( uiTrDepth > 0 ); |
---|
1035 | uiTrDepth--; |
---|
1036 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 ); |
---|
1037 | Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 ); |
---|
1038 | if( !bFirstQ ) |
---|
1039 | { |
---|
1040 | return; |
---|
1041 | } |
---|
1042 | } |
---|
1043 | |
---|
1044 | TextType eText = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U ); |
---|
1045 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> ( uiTrDepth + 1 ); |
---|
1046 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> ( uiTrDepth + 1 ); |
---|
1047 | UInt uiStride = pcRecoYuv->getCStride (); |
---|
1048 | Pel* piReco = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
1049 | Pel* piPred = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
1050 | Pel* piResi = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
1051 | |
---|
1052 | UInt uiNumCoeffInc = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2; |
---|
1053 | TCoeff* pcCoeff = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
1054 | |
---|
1055 | UInt uiChromaPredMode = pcCU->getChromaIntraDir( 0 ); |
---|
1056 | |
---|
1057 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
1058 | Pel* piRecIPred = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) ); |
---|
1059 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
1060 | Bool useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText); |
---|
1061 | //===== init availability pattern ===== |
---|
1062 | Bool bAboveAvail = false; |
---|
1063 | Bool bLeftAvail = false; |
---|
1064 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
1065 | |
---|
1066 | pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
1067 | m_pcPrediction->getPredicBuf (), |
---|
1068 | m_pcPrediction->getPredicBufWidth (), |
---|
1069 | m_pcPrediction->getPredicBufHeight (), |
---|
1070 | bAboveAvail, bLeftAvail ); |
---|
1071 | Int* pPatChroma = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) ); |
---|
1072 | |
---|
1073 | //===== get prediction signal ===== |
---|
1074 | { |
---|
1075 | if( uiChromaPredMode == DM_CHROMA_IDX ) |
---|
1076 | { |
---|
1077 | uiChromaPredMode = pcCU->getLumaIntraDir( 0 ); |
---|
1078 | #if H_3D_DIM |
---|
1079 | mapDepthModeToIntraDir( uiChromaPredMode ); |
---|
1080 | #endif |
---|
1081 | } |
---|
1082 | m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
1083 | } |
---|
1084 | |
---|
1085 | if ( pcCU->getCbf( uiAbsPartIdx, eText, uiTrDepth ) ) |
---|
1086 | { |
---|
1087 | //===== inverse transform ===== |
---|
1088 | Int curChromaQpOffset; |
---|
1089 | if(eText == TEXT_CHROMA_U) |
---|
1090 | { |
---|
1091 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
---|
1092 | } |
---|
1093 | else |
---|
1094 | { |
---|
1095 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
---|
1096 | } |
---|
1097 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
1098 | |
---|
1099 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText]; |
---|
1100 | assert(scalingListType < SCALING_LIST_NUM); |
---|
1101 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma ); |
---|
1102 | |
---|
1103 | //===== reconstruction ===== |
---|
1104 | Pel* pPred = piPred; |
---|
1105 | Pel* pResi = piResi; |
---|
1106 | Pel* pReco = piReco; |
---|
1107 | Pel* pRecIPred = piRecIPred; |
---|
1108 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1109 | { |
---|
1110 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1111 | { |
---|
1112 | pReco [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] ); |
---|
1113 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
1114 | } |
---|
1115 | pPred += uiStride; |
---|
1116 | pResi += uiStride; |
---|
1117 | pReco += uiStride; |
---|
1118 | pRecIPred += uiRecIPredStride; |
---|
1119 | } |
---|
1120 | } |
---|
1121 | else |
---|
1122 | { |
---|
1123 | //===== reconstruction ===== |
---|
1124 | Pel* pPred = piPred; |
---|
1125 | Pel* pReco = piReco; |
---|
1126 | Pel* pRecIPred = piRecIPred; |
---|
1127 | for ( Int y = 0; y < uiHeight; y++ ) |
---|
1128 | { |
---|
1129 | for ( Int x = 0; x < uiWidth; x++ ) |
---|
1130 | { |
---|
1131 | pReco [ x ] = pPred[ x ]; |
---|
1132 | pRecIPred[ x ] = pReco[ x ]; |
---|
1133 | } |
---|
1134 | pPred += uiStride; |
---|
1135 | pReco += uiStride; |
---|
1136 | pRecIPred += uiRecIPredStride; |
---|
1137 | } |
---|
1138 | } |
---|
1139 | } |
---|
1140 | |
---|
1141 | |
---|
1142 | Void |
---|
1143 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth ) |
---|
1144 | { |
---|
1145 | UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 ); |
---|
1146 | UInt uiNumPart = pcCU->getNumPartitions(); |
---|
1147 | UInt uiNumQParts = pcCU->getTotalNumPart() >> 2; |
---|
1148 | |
---|
1149 | if (pcCU->getIPCMFlag(0)) |
---|
1150 | { |
---|
1151 | xReconPCM( pcCU, uiDepth ); |
---|
1152 | return; |
---|
1153 | } |
---|
1154 | |
---|
1155 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
1156 | { |
---|
1157 | xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
1158 | } |
---|
1159 | |
---|
1160 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
1161 | { |
---|
1162 | xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
1163 | } |
---|
1164 | |
---|
1165 | } |
---|
1166 | |
---|
1167 | #if H_3D_DIM_SDC |
---|
1168 | Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1169 | { |
---|
1170 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
1171 | UInt uiHeight = pcCU->getHeight ( 0 ); |
---|
1172 | TComWedgelet* dmm4SegmentationOrg = new TComWedgelet( uiWidth, uiHeight ); |
---|
1173 | UInt numParts = 1; |
---|
1174 | UInt sdcDepth = 0; |
---|
1175 | TComYuv* pcRecoYuv = m_ppcYuvReco[uiDepth]; |
---|
1176 | TComYuv* pcPredYuv = m_ppcYuvReco[uiDepth]; |
---|
1177 | TComYuv* pcResiYuv = m_ppcYuvResi[uiDepth]; |
---|
1178 | |
---|
1179 | UInt uiStride = 0; |
---|
1180 | Pel* piReco; |
---|
1181 | Pel* piPred; |
---|
1182 | Pel* piResi; |
---|
1183 | |
---|
1184 | UInt uiZOrder; |
---|
1185 | Pel* piRecIPred; |
---|
1186 | UInt uiRecIPredStride; |
---|
1187 | |
---|
1188 | UInt uiLumaPredMode = 0; |
---|
1189 | |
---|
1190 | if ((uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()) > 1) |
---|
1191 | { |
---|
1192 | numParts = uiWidth * uiWidth >> (2 * pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()); |
---|
1193 | sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize(); |
---|
1194 | uiWidth = uiHeight = (1 << pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()); |
---|
1195 | } |
---|
1196 | |
---|
1197 | for ( Int i = 0; i < numParts; i++ ) |
---|
1198 | { |
---|
1199 | uiStride = pcRecoYuv->getStride (); |
---|
1200 | piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
1201 | piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
1202 | piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
1203 | |
---|
1204 | uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
1205 | piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
1206 | uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
1207 | |
---|
1208 | uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
1209 | |
---|
1210 | AOF( uiWidth == uiHeight ); |
---|
1211 | |
---|
1212 | //===== init availability pattern ===== |
---|
1213 | Bool bAboveAvail = false; |
---|
1214 | Bool bLeftAvail = false; |
---|
1215 | |
---|
1216 | pcCU->getPattern()->initPattern ( pcCU, sdcDepth, uiAbsPartIdx ); |
---|
1217 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, sdcDepth, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail ); |
---|
1218 | |
---|
1219 | TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight ); |
---|
1220 | //===== get prediction signal ===== |
---|
1221 | if( isDimMode( uiLumaPredMode ) ) |
---|
1222 | { |
---|
1223 | m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, false, dmm4Segmentation ); |
---|
1224 | Bool* dmm4PatternSplit = dmm4Segmentation->getPattern(); |
---|
1225 | Bool* dmm4PatternOrg = dmm4SegmentationOrg->getPattern(); |
---|
1226 | for( UInt k = 0; k < (uiWidth*uiHeight); k++ ) |
---|
1227 | { |
---|
1228 | dmm4PatternOrg[k+(uiAbsPartIdx<<4)] = dmm4PatternSplit[k]; |
---|
1229 | } |
---|
1230 | } |
---|
1231 | else |
---|
1232 | { |
---|
1233 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
1234 | } |
---|
1235 | |
---|
1236 | if ( numParts > 1 ) |
---|
1237 | { |
---|
1238 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1239 | { |
---|
1240 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1241 | { |
---|
1242 | piReco [ uiX ] = ClipY( piPred[ uiX ] ); |
---|
1243 | piRecIPred [ uiX ] = piReco[ uiX ]; |
---|
1244 | } |
---|
1245 | piPred += uiStride; |
---|
1246 | piReco += uiStride; |
---|
1247 | piRecIPred += uiRecIPredStride; |
---|
1248 | } |
---|
1249 | } |
---|
1250 | uiAbsPartIdx += ( (uiWidth * uiWidth) >> 4 ); |
---|
1251 | dmm4Segmentation->destroy(); delete dmm4Segmentation; |
---|
1252 | } |
---|
1253 | uiAbsPartIdx = 0; |
---|
1254 | |
---|
1255 | if ( numParts > 1 ) |
---|
1256 | { |
---|
1257 | uiWidth = pcCU->getWidth( 0 ); |
---|
1258 | uiHeight = pcCU->getHeight( 0 ); |
---|
1259 | } |
---|
1260 | piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
1261 | piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
1262 | piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
1263 | uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
1264 | piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
1265 | uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
1266 | // number of segments depends on prediction mode |
---|
1267 | UInt uiNumSegments = 1; |
---|
1268 | Bool* pbMask = NULL; |
---|
1269 | UInt uiMaskStride = 0; |
---|
1270 | |
---|
1271 | if( getDimType( uiLumaPredMode ) == DMM1_IDX ) |
---|
1272 | { |
---|
1273 | Int uiTabIdx = pcCU->getDmmWedgeTabIdx(DMM1_IDX, uiAbsPartIdx); |
---|
1274 | |
---|
1275 | WedgeList* pacWedgeList = pcCU->isDMM1UpscaleMode(uiWidth) ? &g_dmmWedgeLists[(g_aucConvertToBit[pcCU->getDMM1BasePatternWidth(uiWidth)])] : &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])]; |
---|
1276 | TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx )); |
---|
1277 | |
---|
1278 | uiNumSegments = 2; |
---|
1279 | |
---|
1280 | pbMask = pcCU->isDMM1UpscaleMode( uiWidth ) ? pcWedgelet->getScaledPattern(uiWidth) : pcWedgelet->getPattern(); |
---|
1281 | uiMaskStride = pcCU->isDMM1UpscaleMode( uiWidth ) ? uiWidth : pcWedgelet->getStride(); |
---|
1282 | } |
---|
1283 | if( getDimType( uiLumaPredMode ) == DMM4_IDX ) |
---|
1284 | { |
---|
1285 | uiNumSegments = 2; |
---|
1286 | pbMask = dmm4SegmentationOrg->getPattern(); |
---|
1287 | uiMaskStride = dmm4SegmentationOrg->getStride(); |
---|
1288 | } |
---|
1289 | // get DC prediction for each segment |
---|
1290 | Pel apDCPredValues[2]; |
---|
1291 | if ( getDimType( uiLumaPredMode ) == DMM1_IDX || getDimType( uiLumaPredMode ) == DMM4_IDX ) |
---|
1292 | { |
---|
1293 | apDCPredValues[0] = pcCU->getDmmPredictor( 0 ); |
---|
1294 | apDCPredValues[1] = pcCU->getDmmPredictor( 1 ); |
---|
1295 | } |
---|
1296 | else |
---|
1297 | { |
---|
1298 | m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode); |
---|
1299 | } |
---|
1300 | |
---|
1301 | // reconstruct residual based on mask + DC residuals |
---|
1302 | Pel apDCResiValues[2]; |
---|
1303 | for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ ) |
---|
1304 | { |
---|
1305 | #if H_3D_DIM_DLT |
---|
1306 | Pel pPredIdx = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] ); |
---|
1307 | Pel pResiIdx = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); |
---|
1308 | Pel pRecoValue = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx ); |
---|
1309 | |
---|
1310 | apDCResiValues[uiSegment] = pRecoValue - apDCPredValues[uiSegment]; |
---|
1311 | #else |
---|
1312 | apDCResiValues[uiSegment] = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); |
---|
1313 | #endif |
---|
1314 | } |
---|
1315 | |
---|
1316 | //===== reconstruction ===== |
---|
1317 | Bool*pMask = pbMask; |
---|
1318 | Pel* pPred = piPred; |
---|
1319 | Pel* pResi = piResi; |
---|
1320 | Pel* pReco = piReco; |
---|
1321 | Pel* pRecIPred = piRecIPred; |
---|
1322 | |
---|
1323 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1324 | { |
---|
1325 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1326 | { |
---|
1327 | UChar ucSegment = pMask?(UChar)pMask[uiX]:0; |
---|
1328 | assert( ucSegment < uiNumSegments ); |
---|
1329 | |
---|
1330 | Pel pResiDC = apDCResiValues[ucSegment]; |
---|
1331 | |
---|
1332 | pReco [ uiX ] = ClipY( pPred[ uiX ] + pResiDC ); |
---|
1333 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
1334 | } |
---|
1335 | pPred += uiStride; |
---|
1336 | pResi += uiStride; |
---|
1337 | pReco += uiStride; |
---|
1338 | pRecIPred += uiRecIPredStride; |
---|
1339 | pMask += uiMaskStride; |
---|
1340 | } |
---|
1341 | |
---|
1342 | // clear UV |
---|
1343 | UInt uiStrideC = pcPredYuv->getCStride(); |
---|
1344 | Pel *pRecCb = pcPredYuv->getCbAddr(); |
---|
1345 | Pel *pRecCr = pcPredYuv->getCrAddr(); |
---|
1346 | |
---|
1347 | for (Int y=0; y<uiHeight/2; y++) |
---|
1348 | { |
---|
1349 | for (Int x=0; x<uiWidth/2; x++) |
---|
1350 | { |
---|
1351 | pRecCb[x] = 128; |
---|
1352 | pRecCr[x] = 128; |
---|
1353 | } |
---|
1354 | |
---|
1355 | pRecCb += uiStrideC; |
---|
1356 | pRecCr += uiStrideC; |
---|
1357 | } |
---|
1358 | dmm4SegmentationOrg->destroy(); delete dmm4SegmentationOrg; |
---|
1359 | } |
---|
1360 | #endif |
---|
1361 | |
---|
1362 | /** Function for deriving recontructed PU/CU Luma sample with QTree structure |
---|
1363 | * \param pcCU pointer of current CU |
---|
1364 | * \param uiTrDepth current tranform split depth |
---|
1365 | * \param uiAbsPartIdx part index |
---|
1366 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
1367 | * \param pcPredYuv pointer to prediction sample arrays |
---|
1368 | * \param pcResiYuv pointer to residue sample arrays |
---|
1369 | * |
---|
1370 | \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure |
---|
1371 | */ |
---|
1372 | Void |
---|
1373 | TDecCu::xIntraLumaRecQT( TComDataCU* pcCU, |
---|
1374 | UInt uiTrDepth, |
---|
1375 | UInt uiAbsPartIdx, |
---|
1376 | TComYuv* pcRecoYuv, |
---|
1377 | TComYuv* pcPredYuv, |
---|
1378 | TComYuv* pcResiYuv ) |
---|
1379 | { |
---|
1380 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
1381 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
1382 | if( uiTrMode == uiTrDepth ) |
---|
1383 | { |
---|
1384 | xIntraRecLumaBlk ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
1385 | } |
---|
1386 | else |
---|
1387 | { |
---|
1388 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
1389 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
1390 | { |
---|
1391 | xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
1392 | } |
---|
1393 | } |
---|
1394 | } |
---|
1395 | |
---|
1396 | /** Function for deriving recontructed PU/CU chroma samples with QTree structure |
---|
1397 | * \param pcCU pointer of current CU |
---|
1398 | * \param uiTrDepth current tranform split depth |
---|
1399 | * \param uiAbsPartIdx part index |
---|
1400 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
1401 | * \param pcPredYuv pointer to prediction sample arrays |
---|
1402 | * \param pcResiYuv pointer to residue sample arrays |
---|
1403 | * |
---|
1404 | \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure |
---|
1405 | */ |
---|
1406 | Void |
---|
1407 | TDecCu::xIntraChromaRecQT( TComDataCU* pcCU, |
---|
1408 | UInt uiTrDepth, |
---|
1409 | UInt uiAbsPartIdx, |
---|
1410 | TComYuv* pcRecoYuv, |
---|
1411 | TComYuv* pcPredYuv, |
---|
1412 | TComYuv* pcResiYuv ) |
---|
1413 | { |
---|
1414 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
1415 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
1416 | if( uiTrMode == uiTrDepth ) |
---|
1417 | { |
---|
1418 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 ); |
---|
1419 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 ); |
---|
1420 | } |
---|
1421 | else |
---|
1422 | { |
---|
1423 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
1424 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
1425 | { |
---|
1426 | xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
1427 | } |
---|
1428 | } |
---|
1429 | } |
---|
1430 | |
---|
1431 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
1432 | { |
---|
1433 | UInt uiCUAddr = pcCU->getAddr(); |
---|
1434 | |
---|
1435 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx ); |
---|
1436 | |
---|
1437 | return; |
---|
1438 | } |
---|
1439 | |
---|
1440 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1441 | { |
---|
1442 | UInt uiWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
1443 | UInt uiHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
1444 | TCoeff* piCoeff; |
---|
1445 | |
---|
1446 | Pel* pResi; |
---|
1447 | UInt trMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
1448 | |
---|
1449 | // Y |
---|
1450 | piCoeff = pcCU->getCoeffY(); |
---|
1451 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr(); |
---|
1452 | |
---|
1453 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
1454 | |
---|
1455 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
1456 | |
---|
1457 | // Cb and Cr |
---|
1458 | Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
---|
1459 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
1460 | |
---|
1461 | uiWidth >>= 1; |
---|
1462 | uiHeight >>= 1; |
---|
1463 | piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr(); |
---|
1464 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
1465 | |
---|
1466 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
---|
1467 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
1468 | |
---|
1469 | piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr(); |
---|
1470 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
1471 | } |
---|
1472 | |
---|
1473 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
---|
1474 | * \param pcCU pointer to current CU |
---|
1475 | * \param uiPartIdx part index |
---|
1476 | * \param piPCM pointer to PCM code arrays |
---|
1477 | * \param piReco pointer to reconstructed sample arrays |
---|
1478 | * \param uiStride stride of reconstructed sample arrays |
---|
1479 | * \param uiWidth CU width |
---|
1480 | * \param uiHeight CU height |
---|
1481 | * \param ttText texture component type |
---|
1482 | * \returns Void |
---|
1483 | */ |
---|
1484 | Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText) |
---|
1485 | { |
---|
1486 | UInt uiX, uiY; |
---|
1487 | Pel* piPicReco; |
---|
1488 | UInt uiPicStride; |
---|
1489 | UInt uiPcmLeftShiftBit; |
---|
1490 | |
---|
1491 | if( ttText == TEXT_LUMA ) |
---|
1492 | { |
---|
1493 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(); |
---|
1494 | piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
1495 | uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
1496 | } |
---|
1497 | else |
---|
1498 | { |
---|
1499 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
1500 | |
---|
1501 | if( ttText == TEXT_CHROMA_U ) |
---|
1502 | { |
---|
1503 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
1504 | } |
---|
1505 | else |
---|
1506 | { |
---|
1507 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
1508 | } |
---|
1509 | uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
1510 | } |
---|
1511 | |
---|
1512 | for( uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1513 | { |
---|
1514 | for( uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1515 | { |
---|
1516 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
---|
1517 | piPicReco[uiX] = piReco[uiX]; |
---|
1518 | } |
---|
1519 | piPCM += uiWidth; |
---|
1520 | piReco += uiStride; |
---|
1521 | piPicReco += uiPicStride; |
---|
1522 | } |
---|
1523 | } |
---|
1524 | |
---|
1525 | /** Function for reconstructing a PCM mode CU. |
---|
1526 | * \param pcCU pointer to current CU |
---|
1527 | * \param uiDepth CU Depth |
---|
1528 | * \returns Void |
---|
1529 | */ |
---|
1530 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth ) |
---|
1531 | { |
---|
1532 | // Luma |
---|
1533 | UInt uiWidth = (g_uiMaxCUWidth >> uiDepth); |
---|
1534 | UInt uiHeight = (g_uiMaxCUHeight >> uiDepth); |
---|
1535 | |
---|
1536 | Pel* piPcmY = pcCU->getPCMSampleY(); |
---|
1537 | Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth); |
---|
1538 | |
---|
1539 | UInt uiStride = m_ppcYuvResi[uiDepth]->getStride(); |
---|
1540 | |
---|
1541 | xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA); |
---|
1542 | |
---|
1543 | // Cb and Cr |
---|
1544 | UInt uiCWidth = (uiWidth>>1); |
---|
1545 | UInt uiCHeight = (uiHeight>>1); |
---|
1546 | |
---|
1547 | Pel* piPcmCb = pcCU->getPCMSampleCb(); |
---|
1548 | Pel* piPcmCr = pcCU->getPCMSampleCr(); |
---|
1549 | Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
---|
1550 | Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
---|
1551 | |
---|
1552 | UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride(); |
---|
1553 | |
---|
1554 | xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U); |
---|
1555 | xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V); |
---|
1556 | } |
---|
1557 | |
---|
1558 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
---|
1559 | * \param pcCU pointer to current CU |
---|
1560 | * \param uiDepth CU Depth |
---|
1561 | * \returns Void |
---|
1562 | */ |
---|
1563 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth) |
---|
1564 | { |
---|
1565 | // Luma |
---|
1566 | UInt width = (g_uiMaxCUWidth >> depth); |
---|
1567 | UInt height = (g_uiMaxCUHeight >> depth); |
---|
1568 | |
---|
1569 | Pel* pPcmY = pCU->getPCMSampleY(); |
---|
1570 | Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width); |
---|
1571 | |
---|
1572 | UInt stride = m_ppcYuvReco[depth]->getStride(); |
---|
1573 | |
---|
1574 | for(Int y = 0; y < height; y++ ) |
---|
1575 | { |
---|
1576 | for(Int x = 0; x < width; x++ ) |
---|
1577 | { |
---|
1578 | pPcmY[x] = pRecoY[x]; |
---|
1579 | } |
---|
1580 | pPcmY += width; |
---|
1581 | pRecoY += stride; |
---|
1582 | } |
---|
1583 | |
---|
1584 | // Cb and Cr |
---|
1585 | UInt widthC = (width>>1); |
---|
1586 | UInt heightC = (height>>1); |
---|
1587 | |
---|
1588 | Pel* pPcmCb = pCU->getPCMSampleCb(); |
---|
1589 | Pel* pPcmCr = pCU->getPCMSampleCr(); |
---|
1590 | Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr(); |
---|
1591 | Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr(); |
---|
1592 | |
---|
1593 | UInt strideC = m_ppcYuvReco[depth]->getCStride(); |
---|
1594 | |
---|
1595 | for(Int y = 0; y < heightC; y++ ) |
---|
1596 | { |
---|
1597 | for(Int x = 0; x < widthC; x++ ) |
---|
1598 | { |
---|
1599 | pPcmCb[x] = pRecoCb[x]; |
---|
1600 | pPcmCr[x] = pRecoCr[x]; |
---|
1601 | } |
---|
1602 | pPcmCr += widthC; |
---|
1603 | pPcmCb += widthC; |
---|
1604 | pRecoCb += strideC; |
---|
1605 | pRecoCr += strideC; |
---|
1606 | } |
---|
1607 | |
---|
1608 | } |
---|
1609 | |
---|
1610 | //! \} |
---|