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 | UChar* pMask = pcCU->getInterSDCMask(); |
---|
655 | |
---|
656 | memset( pMask, 0, uiWidth*uiHeight ); |
---|
657 | pcCU->xSetInterSDCCUMask( pcCU, pMask ); |
---|
658 | |
---|
659 | Pel *pResi; |
---|
660 | UInt uiPelX, uiPelY; |
---|
661 | UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride(); |
---|
662 | |
---|
663 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr( 0 ); |
---|
664 | for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ ) |
---|
665 | { |
---|
666 | for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ ) |
---|
667 | { |
---|
668 | UChar uiSeg = pMask[ uiPelX + uiPelY*uiWidth ]; |
---|
669 | #if QC_SDC_UNIFY_G0130 |
---|
670 | pResi[ uiPelX ] = pcCU->getSDCSegmentDCOffset( uiSeg, 0 ); |
---|
671 | #else |
---|
672 | pResi[ uiPelX ] = pcCU->getInterSDCSegmentDCOffset( uiSeg, 0 ); |
---|
673 | #endif |
---|
674 | } |
---|
675 | pResi += uiResiStride; |
---|
676 | } |
---|
677 | |
---|
678 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
679 | |
---|
680 | // clear UV |
---|
681 | UInt uiStrideC = m_ppcYuvReco[uiDepth]->getCStride(); |
---|
682 | Pel *pRecCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
---|
683 | Pel *pRecCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
---|
684 | |
---|
685 | for (Int y = 0; y < uiHeight/2; y++) |
---|
686 | { |
---|
687 | for (Int x = 0; x < uiWidth/2; x++) |
---|
688 | { |
---|
689 | pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) ); |
---|
690 | pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) ); |
---|
691 | } |
---|
692 | |
---|
693 | pRecCb += uiStrideC; |
---|
694 | pRecCr += uiStrideC; |
---|
695 | } |
---|
696 | } |
---|
697 | #endif |
---|
698 | |
---|
699 | Void |
---|
700 | TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU, |
---|
701 | UInt uiTrDepth, |
---|
702 | UInt uiAbsPartIdx, |
---|
703 | TComYuv* pcRecoYuv, |
---|
704 | TComYuv* pcPredYuv, |
---|
705 | TComYuv* pcResiYuv ) |
---|
706 | { |
---|
707 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> uiTrDepth; |
---|
708 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> uiTrDepth; |
---|
709 | UInt uiStride = pcRecoYuv->getStride (); |
---|
710 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
711 | Pel* piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
712 | Pel* piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
713 | |
---|
714 | UInt uiNumCoeffInc = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ); |
---|
715 | TCoeff* pcCoeff = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
716 | |
---|
717 | UInt uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
718 | |
---|
719 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
720 | Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
721 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
722 | Bool useTransformSkip = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA); |
---|
723 | //===== init availability pattern ===== |
---|
724 | Bool bAboveAvail = false; |
---|
725 | Bool bLeftAvail = false; |
---|
726 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
727 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
728 | m_pcPrediction->getPredicBuf (), |
---|
729 | m_pcPrediction->getPredicBufWidth (), |
---|
730 | m_pcPrediction->getPredicBufHeight (), |
---|
731 | bAboveAvail, bLeftAvail ); |
---|
732 | |
---|
733 | //===== get prediction signal ===== |
---|
734 | #if H_3D_DIM |
---|
735 | if( isDimMode( uiLumaPredMode ) ) |
---|
736 | { |
---|
737 | m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight ); |
---|
738 | } |
---|
739 | else |
---|
740 | { |
---|
741 | #endif |
---|
742 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
743 | #if H_3D_DIM |
---|
744 | } |
---|
745 | #endif |
---|
746 | |
---|
747 | //===== inverse transform ===== |
---|
748 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
749 | |
---|
750 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA]; |
---|
751 | assert(scalingListType < 6); |
---|
752 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip ); |
---|
753 | |
---|
754 | |
---|
755 | //===== reconstruction ===== |
---|
756 | Pel* pPred = piPred; |
---|
757 | Pel* pResi = piResi; |
---|
758 | Pel* pReco = piReco; |
---|
759 | Pel* pRecIPred = piRecIPred; |
---|
760 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
761 | { |
---|
762 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
763 | { |
---|
764 | #if H_3D |
---|
765 | if( (isDimMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()) ) |
---|
766 | { |
---|
767 | 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 ] ) ); |
---|
768 | } |
---|
769 | else |
---|
770 | { |
---|
771 | pReco [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] ); |
---|
772 | } |
---|
773 | #else |
---|
774 | pReco [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] ); |
---|
775 | #endif |
---|
776 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
777 | } |
---|
778 | pPred += uiStride; |
---|
779 | pResi += uiStride; |
---|
780 | pReco += uiStride; |
---|
781 | pRecIPred += uiRecIPredStride; |
---|
782 | } |
---|
783 | } |
---|
784 | |
---|
785 | |
---|
786 | Void |
---|
787 | TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU, |
---|
788 | UInt uiTrDepth, |
---|
789 | UInt uiAbsPartIdx, |
---|
790 | TComYuv* pcRecoYuv, |
---|
791 | TComYuv* pcPredYuv, |
---|
792 | TComYuv* pcResiYuv, |
---|
793 | UInt uiChromaId ) |
---|
794 | { |
---|
795 | UInt uiFullDepth = pcCU->getDepth( 0 ) + uiTrDepth; |
---|
796 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2; |
---|
797 | |
---|
798 | if( uiLog2TrSize == 2 ) |
---|
799 | { |
---|
800 | assert( uiTrDepth > 0 ); |
---|
801 | uiTrDepth--; |
---|
802 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 ); |
---|
803 | Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 ); |
---|
804 | if( !bFirstQ ) |
---|
805 | { |
---|
806 | return; |
---|
807 | } |
---|
808 | } |
---|
809 | |
---|
810 | TextType eText = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U ); |
---|
811 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> ( uiTrDepth + 1 ); |
---|
812 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> ( uiTrDepth + 1 ); |
---|
813 | UInt uiStride = pcRecoYuv->getCStride (); |
---|
814 | Pel* piReco = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
815 | Pel* piPred = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
816 | Pel* piResi = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
817 | |
---|
818 | UInt uiNumCoeffInc = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2; |
---|
819 | TCoeff* pcCoeff = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
820 | |
---|
821 | UInt uiChromaPredMode = pcCU->getChromaIntraDir( 0 ); |
---|
822 | |
---|
823 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
824 | Pel* piRecIPred = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) ); |
---|
825 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
826 | Bool useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText); |
---|
827 | //===== init availability pattern ===== |
---|
828 | Bool bAboveAvail = false; |
---|
829 | Bool bLeftAvail = false; |
---|
830 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
831 | |
---|
832 | pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
833 | m_pcPrediction->getPredicBuf (), |
---|
834 | m_pcPrediction->getPredicBufWidth (), |
---|
835 | m_pcPrediction->getPredicBufHeight (), |
---|
836 | bAboveAvail, bLeftAvail ); |
---|
837 | Int* pPatChroma = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) ); |
---|
838 | |
---|
839 | //===== get prediction signal ===== |
---|
840 | { |
---|
841 | if( uiChromaPredMode == DM_CHROMA_IDX ) |
---|
842 | { |
---|
843 | uiChromaPredMode = pcCU->getLumaIntraDir( 0 ); |
---|
844 | #if H_3D_DIM |
---|
845 | mapDepthModeToIntraDir( uiChromaPredMode ); |
---|
846 | #endif |
---|
847 | } |
---|
848 | m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
849 | } |
---|
850 | |
---|
851 | //===== inverse transform ===== |
---|
852 | Int curChromaQpOffset; |
---|
853 | if(eText == TEXT_CHROMA_U) |
---|
854 | { |
---|
855 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
---|
856 | } |
---|
857 | else |
---|
858 | { |
---|
859 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
---|
860 | } |
---|
861 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
862 | |
---|
863 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText]; |
---|
864 | assert(scalingListType < 6); |
---|
865 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma ); |
---|
866 | |
---|
867 | //===== reconstruction ===== |
---|
868 | Pel* pPred = piPred; |
---|
869 | Pel* pResi = piResi; |
---|
870 | Pel* pReco = piReco; |
---|
871 | Pel* pRecIPred = piRecIPred; |
---|
872 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
873 | { |
---|
874 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
875 | { |
---|
876 | pReco [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] ); |
---|
877 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
878 | } |
---|
879 | pPred += uiStride; |
---|
880 | pResi += uiStride; |
---|
881 | pReco += uiStride; |
---|
882 | pRecIPred += uiRecIPredStride; |
---|
883 | } |
---|
884 | } |
---|
885 | |
---|
886 | |
---|
887 | Void |
---|
888 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth ) |
---|
889 | { |
---|
890 | UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 ); |
---|
891 | UInt uiNumPart = pcCU->getNumPartInter(); |
---|
892 | UInt uiNumQParts = pcCU->getTotalNumPart() >> 2; |
---|
893 | |
---|
894 | if (pcCU->getIPCMFlag(0)) |
---|
895 | { |
---|
896 | xReconPCM( pcCU, uiDepth ); |
---|
897 | return; |
---|
898 | } |
---|
899 | |
---|
900 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
901 | { |
---|
902 | xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
903 | } |
---|
904 | |
---|
905 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
906 | { |
---|
907 | xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
908 | } |
---|
909 | |
---|
910 | } |
---|
911 | |
---|
912 | #if H_3D_DIM_SDC |
---|
913 | Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
914 | { |
---|
915 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
916 | UInt uiHeight = pcCU->getHeight ( 0 ); |
---|
917 | |
---|
918 | TComYuv* pcRecoYuv = m_ppcYuvReco[uiDepth]; |
---|
919 | TComYuv* pcPredYuv = m_ppcYuvReco[uiDepth]; |
---|
920 | TComYuv* pcResiYuv = m_ppcYuvResi[uiDepth]; |
---|
921 | |
---|
922 | UInt uiStride = pcRecoYuv->getStride (); |
---|
923 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
924 | Pel* piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
925 | Pel* piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
926 | |
---|
927 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
928 | Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
929 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
930 | |
---|
931 | UInt uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
932 | |
---|
933 | AOF( uiWidth == uiHeight ); |
---|
934 | AOF( uiAbsPartIdx == 0 ); |
---|
935 | AOF( pcCU->getSDCAvailable(uiAbsPartIdx) ); |
---|
936 | AOF( pcCU->getSDCFlag(uiAbsPartIdx) ); |
---|
937 | |
---|
938 | //===== init availability pattern ===== |
---|
939 | Bool bAboveAvail = false; |
---|
940 | Bool bLeftAvail = false; |
---|
941 | pcCU->getPattern()->initPattern ( pcCU, 0, uiAbsPartIdx ); |
---|
942 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail ); |
---|
943 | #if QC_GENERIC_SDC_G0122 |
---|
944 | TComWedgelet* dmm4Segmentation = new TComWedgelet( uiWidth, uiHeight ); |
---|
945 | #endif |
---|
946 | //===== get prediction signal ===== |
---|
947 | #if H_3D_DIM |
---|
948 | if( isDimMode( uiLumaPredMode ) ) |
---|
949 | { |
---|
950 | m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight |
---|
951 | #if QC_GENERIC_SDC_G0122 |
---|
952 | , false, dmm4Segmentation |
---|
953 | #endif |
---|
954 | ); |
---|
955 | } |
---|
956 | else |
---|
957 | { |
---|
958 | #endif |
---|
959 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
960 | #if H_3D_DIM |
---|
961 | } |
---|
962 | #endif |
---|
963 | |
---|
964 | // number of segments depends on prediction mode |
---|
965 | UInt uiNumSegments = 1; |
---|
966 | Bool* pbMask = NULL; |
---|
967 | UInt uiMaskStride = 0; |
---|
968 | |
---|
969 | if( getDimType( uiLumaPredMode ) == DMM1_IDX ) |
---|
970 | { |
---|
971 | Int uiTabIdx = pcCU->getDmmWedgeTabIdx(DMM1_IDX, uiAbsPartIdx); |
---|
972 | |
---|
973 | WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])]; |
---|
974 | TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx )); |
---|
975 | |
---|
976 | uiNumSegments = 2; |
---|
977 | pbMask = pcWedgelet->getPattern(); |
---|
978 | uiMaskStride = pcWedgelet->getStride(); |
---|
979 | } |
---|
980 | #if QC_GENERIC_SDC_G0122 |
---|
981 | if( getDimType( uiLumaPredMode ) == DMM4_IDX ) |
---|
982 | { |
---|
983 | uiNumSegments = 2; |
---|
984 | pbMask = dmm4Segmentation->getPattern(); |
---|
985 | uiMaskStride = dmm4Segmentation->getStride(); |
---|
986 | } |
---|
987 | #endif |
---|
988 | // get DC prediction for each segment |
---|
989 | Pel apDCPredValues[2]; |
---|
990 | m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode); |
---|
991 | |
---|
992 | // reconstruct residual based on mask + DC residuals |
---|
993 | Pel apDCResiValues[2]; |
---|
994 | for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ ) |
---|
995 | { |
---|
996 | #if H_3D_DIM_DLT |
---|
997 | Pel pPredIdx = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] ); |
---|
998 | Pel pResiIdx = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); |
---|
999 | Pel pRecoValue = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx ); |
---|
1000 | |
---|
1001 | apDCResiValues[uiSegment] = pRecoValue - apDCPredValues[uiSegment]; |
---|
1002 | #else |
---|
1003 | apDCResiValues[uiSegment] = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); |
---|
1004 | #endif |
---|
1005 | } |
---|
1006 | |
---|
1007 | //===== reconstruction ===== |
---|
1008 | Bool*pMask = pbMask; |
---|
1009 | Pel* pPred = piPred; |
---|
1010 | Pel* pResi = piResi; |
---|
1011 | Pel* pReco = piReco; |
---|
1012 | Pel* pRecIPred = piRecIPred; |
---|
1013 | |
---|
1014 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1015 | { |
---|
1016 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1017 | { |
---|
1018 | UChar ucSegment = pMask?(UChar)pMask[uiX]:0; |
---|
1019 | assert( ucSegment < uiNumSegments ); |
---|
1020 | |
---|
1021 | Pel pResiDC = apDCResiValues[ucSegment]; |
---|
1022 | |
---|
1023 | pReco [ uiX ] = ClipY( pPred[ uiX ] + pResiDC ); |
---|
1024 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
1025 | } |
---|
1026 | pPred += uiStride; |
---|
1027 | pResi += uiStride; |
---|
1028 | pReco += uiStride; |
---|
1029 | pRecIPred += uiRecIPredStride; |
---|
1030 | pMask += uiMaskStride; |
---|
1031 | } |
---|
1032 | |
---|
1033 | // clear UV |
---|
1034 | UInt uiStrideC = pcPredYuv->getCStride(); |
---|
1035 | Pel *pRecCb = pcPredYuv->getCbAddr(); |
---|
1036 | Pel *pRecCr = pcPredYuv->getCrAddr(); |
---|
1037 | |
---|
1038 | for (Int y=0; y<uiHeight/2; y++) |
---|
1039 | { |
---|
1040 | for (Int x=0; x<uiWidth/2; x++) |
---|
1041 | { |
---|
1042 | pRecCb[x] = 128; |
---|
1043 | pRecCr[x] = 128; |
---|
1044 | } |
---|
1045 | |
---|
1046 | pRecCb += uiStrideC; |
---|
1047 | pRecCr += uiStrideC; |
---|
1048 | } |
---|
1049 | #if QC_GENERIC_SDC_G0122 |
---|
1050 | dmm4Segmentation->destroy(); delete dmm4Segmentation; |
---|
1051 | #endif |
---|
1052 | } |
---|
1053 | #endif |
---|
1054 | |
---|
1055 | /** Function for deriving recontructed PU/CU Luma sample with QTree structure |
---|
1056 | * \param pcCU pointer of current CU |
---|
1057 | * \param uiTrDepth current tranform split depth |
---|
1058 | * \param uiAbsPartIdx part index |
---|
1059 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
1060 | * \param pcPredYuv pointer to prediction sample arrays |
---|
1061 | * \param pcResiYuv pointer to residue sample arrays |
---|
1062 | * |
---|
1063 | \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure |
---|
1064 | */ |
---|
1065 | Void |
---|
1066 | TDecCu::xIntraLumaRecQT( TComDataCU* pcCU, |
---|
1067 | UInt uiTrDepth, |
---|
1068 | UInt uiAbsPartIdx, |
---|
1069 | TComYuv* pcRecoYuv, |
---|
1070 | TComYuv* pcPredYuv, |
---|
1071 | TComYuv* pcResiYuv ) |
---|
1072 | { |
---|
1073 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
1074 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
1075 | if( uiTrMode == uiTrDepth ) |
---|
1076 | { |
---|
1077 | xIntraRecLumaBlk ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
1078 | } |
---|
1079 | else |
---|
1080 | { |
---|
1081 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
1082 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
1083 | { |
---|
1084 | xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
1085 | } |
---|
1086 | } |
---|
1087 | } |
---|
1088 | |
---|
1089 | /** Function for deriving recontructed PU/CU chroma samples with QTree structure |
---|
1090 | * \param pcCU pointer of current CU |
---|
1091 | * \param uiTrDepth current tranform split depth |
---|
1092 | * \param uiAbsPartIdx part index |
---|
1093 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
1094 | * \param pcPredYuv pointer to prediction sample arrays |
---|
1095 | * \param pcResiYuv pointer to residue sample arrays |
---|
1096 | * |
---|
1097 | \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure |
---|
1098 | */ |
---|
1099 | Void |
---|
1100 | TDecCu::xIntraChromaRecQT( TComDataCU* pcCU, |
---|
1101 | UInt uiTrDepth, |
---|
1102 | UInt uiAbsPartIdx, |
---|
1103 | TComYuv* pcRecoYuv, |
---|
1104 | TComYuv* pcPredYuv, |
---|
1105 | TComYuv* pcResiYuv ) |
---|
1106 | { |
---|
1107 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
1108 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
1109 | if( uiTrMode == uiTrDepth ) |
---|
1110 | { |
---|
1111 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 ); |
---|
1112 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 ); |
---|
1113 | } |
---|
1114 | else |
---|
1115 | { |
---|
1116 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
1117 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
1118 | { |
---|
1119 | xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
1120 | } |
---|
1121 | } |
---|
1122 | } |
---|
1123 | |
---|
1124 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
1125 | { |
---|
1126 | UInt uiCUAddr = pcCU->getAddr(); |
---|
1127 | |
---|
1128 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx ); |
---|
1129 | |
---|
1130 | return; |
---|
1131 | } |
---|
1132 | |
---|
1133 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1134 | { |
---|
1135 | UInt uiWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
1136 | UInt uiHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
1137 | TCoeff* piCoeff; |
---|
1138 | |
---|
1139 | Pel* pResi; |
---|
1140 | UInt trMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
1141 | |
---|
1142 | // Y |
---|
1143 | piCoeff = pcCU->getCoeffY(); |
---|
1144 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr(); |
---|
1145 | |
---|
1146 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
1147 | |
---|
1148 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
1149 | |
---|
1150 | // Cb and Cr |
---|
1151 | Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
---|
1152 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
1153 | |
---|
1154 | uiWidth >>= 1; |
---|
1155 | uiHeight >>= 1; |
---|
1156 | piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr(); |
---|
1157 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
1158 | |
---|
1159 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
---|
1160 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
1161 | |
---|
1162 | piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr(); |
---|
1163 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
1164 | } |
---|
1165 | |
---|
1166 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
---|
1167 | * \param pcCU pointer to current CU |
---|
1168 | * \param uiPartIdx part index |
---|
1169 | * \param piPCM pointer to PCM code arrays |
---|
1170 | * \param piReco pointer to reconstructed sample arrays |
---|
1171 | * \param uiStride stride of reconstructed sample arrays |
---|
1172 | * \param uiWidth CU width |
---|
1173 | * \param uiHeight CU height |
---|
1174 | * \param ttText texture component type |
---|
1175 | * \returns Void |
---|
1176 | */ |
---|
1177 | Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText) |
---|
1178 | { |
---|
1179 | UInt uiX, uiY; |
---|
1180 | Pel* piPicReco; |
---|
1181 | UInt uiPicStride; |
---|
1182 | UInt uiPcmLeftShiftBit; |
---|
1183 | |
---|
1184 | if( ttText == TEXT_LUMA ) |
---|
1185 | { |
---|
1186 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(); |
---|
1187 | piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
1188 | uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
1189 | } |
---|
1190 | else |
---|
1191 | { |
---|
1192 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
1193 | |
---|
1194 | if( ttText == TEXT_CHROMA_U ) |
---|
1195 | { |
---|
1196 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
1197 | } |
---|
1198 | else |
---|
1199 | { |
---|
1200 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
1201 | } |
---|
1202 | uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
1203 | } |
---|
1204 | |
---|
1205 | for( uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1206 | { |
---|
1207 | for( uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1208 | { |
---|
1209 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
---|
1210 | piPicReco[uiX] = piReco[uiX]; |
---|
1211 | } |
---|
1212 | piPCM += uiWidth; |
---|
1213 | piReco += uiStride; |
---|
1214 | piPicReco += uiPicStride; |
---|
1215 | } |
---|
1216 | } |
---|
1217 | |
---|
1218 | /** Function for reconstructing a PCM mode CU. |
---|
1219 | * \param pcCU pointer to current CU |
---|
1220 | * \param uiDepth CU Depth |
---|
1221 | * \returns Void |
---|
1222 | */ |
---|
1223 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth ) |
---|
1224 | { |
---|
1225 | // Luma |
---|
1226 | UInt uiWidth = (g_uiMaxCUWidth >> uiDepth); |
---|
1227 | UInt uiHeight = (g_uiMaxCUHeight >> uiDepth); |
---|
1228 | |
---|
1229 | Pel* piPcmY = pcCU->getPCMSampleY(); |
---|
1230 | Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth); |
---|
1231 | |
---|
1232 | UInt uiStride = m_ppcYuvResi[uiDepth]->getStride(); |
---|
1233 | |
---|
1234 | xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA); |
---|
1235 | |
---|
1236 | // Cb and Cr |
---|
1237 | UInt uiCWidth = (uiWidth>>1); |
---|
1238 | UInt uiCHeight = (uiHeight>>1); |
---|
1239 | |
---|
1240 | Pel* piPcmCb = pcCU->getPCMSampleCb(); |
---|
1241 | Pel* piPcmCr = pcCU->getPCMSampleCr(); |
---|
1242 | Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
---|
1243 | Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
---|
1244 | |
---|
1245 | UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride(); |
---|
1246 | |
---|
1247 | xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U); |
---|
1248 | xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V); |
---|
1249 | } |
---|
1250 | |
---|
1251 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
---|
1252 | * \param pcCU pointer to current CU |
---|
1253 | * \param uiDepth CU Depth |
---|
1254 | * \returns Void |
---|
1255 | */ |
---|
1256 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth) |
---|
1257 | { |
---|
1258 | // Luma |
---|
1259 | UInt width = (g_uiMaxCUWidth >> depth); |
---|
1260 | UInt height = (g_uiMaxCUHeight >> depth); |
---|
1261 | |
---|
1262 | Pel* pPcmY = pCU->getPCMSampleY(); |
---|
1263 | Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width); |
---|
1264 | |
---|
1265 | UInt stride = m_ppcYuvReco[depth]->getStride(); |
---|
1266 | |
---|
1267 | for(Int y = 0; y < height; y++ ) |
---|
1268 | { |
---|
1269 | for(Int x = 0; x < width; x++ ) |
---|
1270 | { |
---|
1271 | pPcmY[x] = pRecoY[x]; |
---|
1272 | } |
---|
1273 | pPcmY += width; |
---|
1274 | pRecoY += stride; |
---|
1275 | } |
---|
1276 | |
---|
1277 | // Cb and Cr |
---|
1278 | UInt widthC = (width>>1); |
---|
1279 | UInt heightC = (height>>1); |
---|
1280 | |
---|
1281 | Pel* pPcmCb = pCU->getPCMSampleCb(); |
---|
1282 | Pel* pPcmCr = pCU->getPCMSampleCr(); |
---|
1283 | Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr(); |
---|
1284 | Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr(); |
---|
1285 | |
---|
1286 | UInt strideC = m_ppcYuvReco[depth]->getCStride(); |
---|
1287 | |
---|
1288 | for(Int y = 0; y < heightC; y++ ) |
---|
1289 | { |
---|
1290 | for(Int x = 0; x < widthC; x++ ) |
---|
1291 | { |
---|
1292 | pPcmCb[x] = pRecoCb[x]; |
---|
1293 | pPcmCr[x] = pRecoCr[x]; |
---|
1294 | } |
---|
1295 | pPcmCr += widthC; |
---|
1296 | pPcmCb += widthC; |
---|
1297 | pRecoCb += strideC; |
---|
1298 | pRecoCr += strideC; |
---|
1299 | } |
---|
1300 | |
---|
1301 | } |
---|
1302 | |
---|
1303 | //! \} |
---|