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 | xDecompressCU( pcCU, 0, 0 ); |
---|
138 | } |
---|
139 | |
---|
140 | // ==================================================================================================================== |
---|
141 | // Protected member functions |
---|
142 | // ==================================================================================================================== |
---|
143 | |
---|
144 | /**decode end-of-slice flag |
---|
145 | * \param pcCU |
---|
146 | * \param uiAbsPartIdx |
---|
147 | * \param uiDepth |
---|
148 | * \returns Bool |
---|
149 | */ |
---|
150 | Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth) |
---|
151 | { |
---|
152 | UInt uiIsLast; |
---|
153 | TComPic* pcPic = pcCU->getPic(); |
---|
154 | TComSlice * pcSlice = pcPic->getSlice(pcPic->getCurrSliceIdx()); |
---|
155 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
156 | UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); |
---|
157 | UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); |
---|
158 | UInt uiGranularityWidth = g_uiMaxCUWidth; |
---|
159 | UInt uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
160 | UInt uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
161 | |
---|
162 | if(((uiPosX+pcCU->getWidth(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosX+pcCU->getWidth(uiAbsPartIdx)==uiWidth)) |
---|
163 | &&((uiPosY+pcCU->getHeight(uiAbsPartIdx))%uiGranularityWidth==0||(uiPosY+pcCU->getHeight(uiAbsPartIdx)==uiHeight))) |
---|
164 | { |
---|
165 | m_pcEntropyDecoder->decodeTerminatingBit( uiIsLast ); |
---|
166 | } |
---|
167 | else |
---|
168 | { |
---|
169 | uiIsLast=0; |
---|
170 | } |
---|
171 | |
---|
172 | if(uiIsLast) |
---|
173 | { |
---|
174 | if(pcSlice->isNextSliceSegment()&&!pcSlice->isNextSlice()) |
---|
175 | { |
---|
176 | pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
177 | } |
---|
178 | else |
---|
179 | { |
---|
180 | pcSlice->setSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
181 | pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts); |
---|
182 | } |
---|
183 | } |
---|
184 | |
---|
185 | return uiIsLast>0; |
---|
186 | } |
---|
187 | |
---|
188 | /** decode CU block recursively |
---|
189 | * \param pcCU |
---|
190 | * \param uiAbsPartIdx |
---|
191 | * \param uiDepth |
---|
192 | * \returns Void |
---|
193 | */ |
---|
194 | |
---|
195 | Void TDecCu::xDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast) |
---|
196 | { |
---|
197 | TComPic* pcPic = pcCU->getPic(); |
---|
198 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
199 | UInt uiQNumParts = uiCurNumParts>>2; |
---|
200 | |
---|
201 | Bool bBoundary = false; |
---|
202 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
203 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
204 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
205 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
206 | #if H_MV_ENC_DEC_TRAC |
---|
207 | DTRACE_CU_S("=========== coding_quadtree ===========\n") |
---|
208 | DTRACE_CU("x0", uiLPelX) |
---|
209 | DTRACE_CU("x1", uiTPelY) |
---|
210 | DTRACE_CU("log2CbSize", g_uiMaxCUWidth>>uiDepth) |
---|
211 | DTRACE_CU("cqtDepth" , uiDepth) |
---|
212 | #endif |
---|
213 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
214 | Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr(); |
---|
215 | if((!bStartInCU) && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
216 | { |
---|
217 | m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
218 | } |
---|
219 | else |
---|
220 | { |
---|
221 | bBoundary = true; |
---|
222 | } |
---|
223 | |
---|
224 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
225 | { |
---|
226 | UInt uiIdx = uiAbsPartIdx; |
---|
227 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
228 | { |
---|
229 | setdQPFlag(true); |
---|
230 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
231 | } |
---|
232 | |
---|
233 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
234 | { |
---|
235 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
236 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
237 | |
---|
238 | Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr(); |
---|
239 | if ( bSubInSlice ) |
---|
240 | { |
---|
241 | if ( !ruiIsLast && ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
242 | { |
---|
243 | xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast ); |
---|
244 | } |
---|
245 | else |
---|
246 | { |
---|
247 | pcCU->setOutsideCUPart( uiIdx, uiDepth+1 ); |
---|
248 | } |
---|
249 | } |
---|
250 | |
---|
251 | uiIdx += uiQNumParts; |
---|
252 | } |
---|
253 | if( (g_uiMaxCUWidth>>uiDepth) == pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
254 | { |
---|
255 | if ( getdQPFlag() ) |
---|
256 | { |
---|
257 | UInt uiQPSrcPartIdx; |
---|
258 | if ( pcPic->getCU( pcCU->getAddr() )->getSliceSegmentStartCU(uiAbsPartIdx) != pcSlice->getSliceSegmentCurStartCUAddr() ) |
---|
259 | { |
---|
260 | uiQPSrcPartIdx = pcSlice->getSliceSegmentCurStartCUAddr() % pcPic->getNumPartInCU(); |
---|
261 | } |
---|
262 | else |
---|
263 | { |
---|
264 | uiQPSrcPartIdx = uiAbsPartIdx; |
---|
265 | } |
---|
266 | pcCU->setQPSubParts( pcCU->getRefQP( uiQPSrcPartIdx ), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
267 | } |
---|
268 | } |
---|
269 | return; |
---|
270 | } |
---|
271 | |
---|
272 | #if H_MV_ENC_DEC_TRAC |
---|
273 | DTRACE_CU_S("=========== coding_unit ===========\n") |
---|
274 | #endif |
---|
275 | |
---|
276 | if( (g_uiMaxCUWidth>>uiDepth) >= pcCU->getSlice()->getPPS()->getMinCuDQPSize() && pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
277 | { |
---|
278 | setdQPFlag(true); |
---|
279 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
280 | } |
---|
281 | #if H_3D_NBDV |
---|
282 | DisInfo DvInfo; |
---|
283 | DvInfo.bDV = false; |
---|
284 | DvInfo.m_acNBDV.setZero(); |
---|
285 | DvInfo.m_aVIdxCan = 0; |
---|
286 | #if H_3D_NBDV_REF |
---|
287 | DvInfo.m_acDoNBDV.setZero(); |
---|
288 | #endif |
---|
289 | |
---|
290 | |
---|
291 | if(!pcCU->getSlice()->isIntra()) |
---|
292 | { |
---|
293 | #if H_3D_ARP && H_3D_IV_MERGE |
---|
294 | if( pcCU->getSlice()->getVPS()->getUseAdvRP( pcCU->getSlice()->getLayerId() ) || pcCU->getSlice()->getVPS()->getIvMvPredFlag( pcCU->getSlice()->getLayerId() )) |
---|
295 | #else |
---|
296 | #if H_3D_ARP |
---|
297 | if( pcCU->getSlice()->getVPS()->getUseAdvRP(pcCU->getSlice()->getLayerId()) ) |
---|
298 | #else |
---|
299 | #if H_3D_IV_MERGE |
---|
300 | if( pcCU->getSlice()->getVPS()->getIvMvPredFlag(pcCU->getSlice()->getLayerId()) ) |
---|
301 | #else |
---|
302 | if (0) |
---|
303 | #endif |
---|
304 | #endif |
---|
305 | #endif |
---|
306 | { |
---|
307 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true ); |
---|
308 | m_ppcCU[uiDepth]->copyDVInfoFrom( pcCU, uiAbsPartIdx); |
---|
309 | PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0); |
---|
310 | UChar cWidTemp = m_ppcCU[uiDepth]->getWidth(0); |
---|
311 | UChar cHeightTemp = m_ppcCU[uiDepth]->getHeight(0); |
---|
312 | m_ppcCU[uiDepth]->setWidth ( 0, pcCU->getSlice()->getSPS()->getMaxCUWidth ()/(1<<uiDepth) ); |
---|
313 | m_ppcCU[uiDepth]->setHeight ( 0, pcCU->getSlice()->getSPS()->getMaxCUHeight()/(1<<uiDepth) ); |
---|
314 | m_ppcCU[uiDepth]->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
315 | #if H_3D_NBDV_REF |
---|
316 | if(pcCU->getSlice()->getVPS()->getDepthRefinementFlag( pcCU->getSlice()->getLayerIdInVps() )) //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done. |
---|
317 | { |
---|
318 | DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo, true); |
---|
319 | } |
---|
320 | else |
---|
321 | #endif |
---|
322 | { |
---|
323 | DvInfo.bDV = m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo); |
---|
324 | } |
---|
325 | |
---|
326 | #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC |
---|
327 | if ( g_decTraceDispDer ) |
---|
328 | { |
---|
329 | DTRACE_CU( "RefViewIdx", DvInfo.m_aVIdxCan ); |
---|
330 | DTRACE_CU( "MvDisp[x]", DvInfo.m_acNBDV.getHor() ); |
---|
331 | DTRACE_CU( "MvDisp[y]", DvInfo.m_acNBDV.getVer() ); |
---|
332 | DTRACE_CU( "MvRefinedDisp[x]", DvInfo.m_acDoNBDV.getHor() ); |
---|
333 | DTRACE_CU( "MvRefinedDisp[y]", DvInfo.m_acDoNBDV.getVer() ); |
---|
334 | } |
---|
335 | #endif |
---|
336 | |
---|
337 | pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth); |
---|
338 | m_ppcCU[uiDepth]->setPartSizeSubParts( ePartTemp, 0, uiDepth ); |
---|
339 | m_ppcCU[uiDepth]->setWidth ( 0, cWidTemp ); |
---|
340 | m_ppcCU[uiDepth]->setHeight ( 0, cHeightTemp ); |
---|
341 | } |
---|
342 | } |
---|
343 | #endif |
---|
344 | if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag()) |
---|
345 | { |
---|
346 | m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
347 | } |
---|
348 | |
---|
349 | // decode CU mode and the partition size |
---|
350 | if( !pcCU->getSlice()->isIntra()) |
---|
351 | { |
---|
352 | m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
353 | } |
---|
354 | |
---|
355 | if( pcCU->isSkipped(uiAbsPartIdx) ) |
---|
356 | { |
---|
357 | #if H_MV_ENC_DEC_TRAC |
---|
358 | DTRACE_PU_S("=========== prediction_unit ===========\n") |
---|
359 | DTRACE_PU("x0", uiLPelX) |
---|
360 | DTRACE_PU("x1", uiTPelY) |
---|
361 | #endif |
---|
362 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
363 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
364 | #if H_3D_IV_MERGE |
---|
365 | m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx); |
---|
366 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
---|
367 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
---|
368 | #else |
---|
369 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
370 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
371 | #endif |
---|
372 | Int numValidMergeCand = 0; |
---|
373 | for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
374 | { |
---|
375 | uhInterDirNeighbours[ui] = 0; |
---|
376 | } |
---|
377 | m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth ); |
---|
378 | UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx); |
---|
379 | |
---|
380 | #if H_3D_VSP |
---|
381 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
382 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
---|
383 | InheritedVSPDisInfo inheritedVSPDisInfo[MRG_MAX_NUM_CANDS_MEM]; |
---|
384 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, vspFlag, inheritedVSPDisInfo, numValidMergeCand, uiMergeIndex ); |
---|
385 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
386 | #else |
---|
387 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
388 | #endif |
---|
389 | #if H_3D_VSP |
---|
390 | if(vspFlag[uiMergeIndex]) |
---|
391 | { |
---|
392 | pcCU->setDvInfoSubParts(inheritedVSPDisInfo[uiMergeIndex].m_acDvInfo, uiAbsPartIdx, 0, uiDepth); |
---|
393 | } |
---|
394 | #endif |
---|
395 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
396 | |
---|
397 | TComMv cTmpMv( 0, 0 ); |
---|
398 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
399 | { |
---|
400 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
401 | { |
---|
402 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
403 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
404 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
405 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
406 | #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC |
---|
407 | if ( g_decTraceMvFromMerge ) |
---|
408 | { |
---|
409 | if ( uiRefListIdx == 0 ) |
---|
410 | { |
---|
411 | DTRACE_PU( "mvL0[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor()); |
---|
412 | DTRACE_PU( "mvL0[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer()); |
---|
413 | DTRACE_PU( "refIdxL0 ", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx()); |
---|
414 | } |
---|
415 | else |
---|
416 | { |
---|
417 | DTRACE_PU( "mvL1[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor()); |
---|
418 | DTRACE_PU( "mvL1[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer()); |
---|
419 | DTRACE_PU( "refIdxL1", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx()); |
---|
420 | } |
---|
421 | } |
---|
422 | #endif |
---|
423 | } |
---|
424 | } |
---|
425 | #if H_3D_IC |
---|
426 | m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
427 | #endif |
---|
428 | #if H_3D_ARP |
---|
429 | m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth ); |
---|
430 | #endif |
---|
431 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
432 | return; |
---|
433 | } |
---|
434 | |
---|
435 | m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
436 | m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
437 | |
---|
438 | if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
---|
439 | { |
---|
440 | m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
441 | |
---|
442 | if(pcCU->getIPCMFlag(uiAbsPartIdx)) |
---|
443 | { |
---|
444 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
445 | return; |
---|
446 | } |
---|
447 | } |
---|
448 | |
---|
449 | UInt uiCurrWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
450 | UInt uiCurrHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
451 | |
---|
452 | // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
453 | m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); |
---|
454 | #if H_3D_IC |
---|
455 | m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
456 | #endif |
---|
457 | #if H_3D_ARP |
---|
458 | m_pcEntropyDecoder->decodeARPW ( pcCU , uiAbsPartIdx , uiDepth ); |
---|
459 | #endif |
---|
460 | #if LGE_INTER_SDC_E0156 |
---|
461 | m_pcEntropyDecoder->decodeInterSDCFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
462 | #endif |
---|
463 | // Coefficient decoding |
---|
464 | Bool bCodeDQP = getdQPFlag(); |
---|
465 | m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, uiCurrWidth, uiCurrHeight, bCodeDQP ); |
---|
466 | setdQPFlag( bCodeDQP ); |
---|
467 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, ruiIsLast ); |
---|
468 | } |
---|
469 | |
---|
470 | Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& ruiIsLast) |
---|
471 | { |
---|
472 | if( pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
473 | { |
---|
474 | pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP |
---|
475 | } |
---|
476 | |
---|
477 | ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth); |
---|
478 | } |
---|
479 | |
---|
480 | Void TDecCu::xDecompressCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
481 | { |
---|
482 | TComPic* pcPic = pcCU->getPic(); |
---|
483 | |
---|
484 | Bool bBoundary = false; |
---|
485 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
486 | UInt uiRPelX = uiLPelX + (g_uiMaxCUWidth>>uiDepth) - 1; |
---|
487 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
488 | UInt uiBPelY = uiTPelY + (g_uiMaxCUHeight>>uiDepth) - 1; |
---|
489 | |
---|
490 | UInt uiCurNumParts = pcPic->getNumPartInCU() >> (uiDepth<<1); |
---|
491 | TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx()); |
---|
492 | Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr(); |
---|
493 | if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
494 | { |
---|
495 | bBoundary = true; |
---|
496 | } |
---|
497 | |
---|
498 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) ) || bBoundary ) |
---|
499 | { |
---|
500 | UInt uiNextDepth = uiDepth + 1; |
---|
501 | UInt uiQNumParts = pcCU->getTotalNumPart() >> (uiNextDepth<<1); |
---|
502 | UInt uiIdx = uiAbsPartIdx; |
---|
503 | for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ ) |
---|
504 | { |
---|
505 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
506 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
507 | |
---|
508 | Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getSliceSegmentCurEndCUAddr()); |
---|
509 | if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) |
---|
510 | { |
---|
511 | xDecompressCU(pcCU, uiIdx, uiNextDepth ); |
---|
512 | } |
---|
513 | |
---|
514 | uiIdx += uiQNumParts; |
---|
515 | } |
---|
516 | return; |
---|
517 | } |
---|
518 | |
---|
519 | // Residual reconstruction |
---|
520 | m_ppcYuvResi[uiDepth]->clear(); |
---|
521 | |
---|
522 | m_ppcCU[uiDepth]->copySubCU( pcCU, uiAbsPartIdx, uiDepth ); |
---|
523 | |
---|
524 | switch( m_ppcCU[uiDepth]->getPredictionMode(0) ) |
---|
525 | { |
---|
526 | case MODE_INTER: |
---|
527 | #if LGE_INTER_SDC_E0156 |
---|
528 | if( m_ppcCU[uiDepth]->getInterSDCFlag( 0 ) ) |
---|
529 | { |
---|
530 | xReconInterSDC( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
531 | } |
---|
532 | else |
---|
533 | { |
---|
534 | #endif |
---|
535 | xReconInter( m_ppcCU[uiDepth], uiDepth ); |
---|
536 | #if LGE_INTER_SDC_E0156 |
---|
537 | } |
---|
538 | #endif |
---|
539 | break; |
---|
540 | case MODE_INTRA: |
---|
541 | #if H_3D_DIM_SDC |
---|
542 | if( m_ppcCU[uiDepth]->getSDCFlag(0) ) |
---|
543 | xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth ); |
---|
544 | else |
---|
545 | #endif |
---|
546 | xReconIntraQT( m_ppcCU[uiDepth], uiDepth ); |
---|
547 | break; |
---|
548 | default: |
---|
549 | assert(0); |
---|
550 | break; |
---|
551 | } |
---|
552 | if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false)) |
---|
553 | { |
---|
554 | xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth); |
---|
555 | } |
---|
556 | |
---|
557 | xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth ); |
---|
558 | } |
---|
559 | |
---|
560 | Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth ) |
---|
561 | { |
---|
562 | |
---|
563 | // inter prediction |
---|
564 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
565 | |
---|
566 | // inter recon |
---|
567 | xDecodeInterTexture( pcCU, 0, uiDepth ); |
---|
568 | |
---|
569 | // clip for only non-zero cbp case |
---|
570 | if ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) ) |
---|
571 | { |
---|
572 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
573 | } |
---|
574 | else |
---|
575 | { |
---|
576 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
577 | } |
---|
578 | } |
---|
579 | |
---|
580 | #if LGE_INTER_SDC_E0156 |
---|
581 | Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
582 | { |
---|
583 | // inter prediction |
---|
584 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
585 | |
---|
586 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
587 | UInt uiHeight = pcCU->getHeight( 0 ); |
---|
588 | UChar* pMask = pcCU->getInterSDCMask(); |
---|
589 | |
---|
590 | memset( pMask, 0, uiWidth*uiHeight ); |
---|
591 | pcCU->xSetInterSDCCUMask( pcCU, pMask ); |
---|
592 | |
---|
593 | Pel *pResi; |
---|
594 | UInt uiPelX, uiPelY; |
---|
595 | UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride(); |
---|
596 | |
---|
597 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr( 0 ); |
---|
598 | for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ ) |
---|
599 | { |
---|
600 | for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ ) |
---|
601 | { |
---|
602 | UChar uiSeg = pMask[ uiPelX + uiPelY*uiWidth ]; |
---|
603 | |
---|
604 | pResi[ uiPelX ] = pcCU->getInterSDCSegmentDCOffset( uiSeg, 0 );; |
---|
605 | } |
---|
606 | pResi += uiResiStride; |
---|
607 | } |
---|
608 | |
---|
609 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
610 | |
---|
611 | // clear UV |
---|
612 | UInt uiStrideC = m_ppcYuvReco[uiDepth]->getCStride(); |
---|
613 | Pel *pRecCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
---|
614 | Pel *pRecCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
---|
615 | |
---|
616 | for (Int y = 0; y < uiHeight/2; y++) |
---|
617 | { |
---|
618 | for (Int x = 0; x < uiWidth/2; x++) |
---|
619 | { |
---|
620 | pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) ); |
---|
621 | pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) ); |
---|
622 | } |
---|
623 | |
---|
624 | pRecCb += uiStrideC; |
---|
625 | pRecCr += uiStrideC; |
---|
626 | } |
---|
627 | } |
---|
628 | #endif |
---|
629 | |
---|
630 | Void |
---|
631 | TDecCu::xIntraRecLumaBlk( TComDataCU* pcCU, |
---|
632 | UInt uiTrDepth, |
---|
633 | UInt uiAbsPartIdx, |
---|
634 | TComYuv* pcRecoYuv, |
---|
635 | TComYuv* pcPredYuv, |
---|
636 | TComYuv* pcResiYuv ) |
---|
637 | { |
---|
638 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> uiTrDepth; |
---|
639 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> uiTrDepth; |
---|
640 | UInt uiStride = pcRecoYuv->getStride (); |
---|
641 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
642 | Pel* piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
643 | Pel* piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
644 | |
---|
645 | UInt uiNumCoeffInc = ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ); |
---|
646 | TCoeff* pcCoeff = pcCU->getCoeffY() + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
647 | |
---|
648 | UInt uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
649 | |
---|
650 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
651 | Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
652 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
653 | Bool useTransformSkip = pcCU->getTransformSkip(uiAbsPartIdx, TEXT_LUMA); |
---|
654 | //===== init availability pattern ===== |
---|
655 | Bool bAboveAvail = false; |
---|
656 | Bool bLeftAvail = false; |
---|
657 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
658 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
659 | m_pcPrediction->getPredicBuf (), |
---|
660 | m_pcPrediction->getPredicBufWidth (), |
---|
661 | m_pcPrediction->getPredicBufHeight (), |
---|
662 | bAboveAvail, bLeftAvail ); |
---|
663 | |
---|
664 | //===== get prediction signal ===== |
---|
665 | #if H_3D_DIM |
---|
666 | if( isDimMode( uiLumaPredMode ) ) |
---|
667 | { |
---|
668 | m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight ); |
---|
669 | } |
---|
670 | else |
---|
671 | { |
---|
672 | #endif |
---|
673 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
674 | #if H_3D_DIM |
---|
675 | } |
---|
676 | #endif |
---|
677 | |
---|
678 | //===== inverse transform ===== |
---|
679 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
680 | |
---|
681 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)TEXT_LUMA]; |
---|
682 | assert(scalingListType < 6); |
---|
683 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), TEXT_LUMA, pcCU->getLumaIntraDir( uiAbsPartIdx ), piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkip ); |
---|
684 | |
---|
685 | |
---|
686 | //===== reconstruction ===== |
---|
687 | Pel* pPred = piPred; |
---|
688 | Pel* pResi = piResi; |
---|
689 | Pel* pReco = piReco; |
---|
690 | Pel* pRecIPred = piRecIPred; |
---|
691 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
692 | { |
---|
693 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
694 | { |
---|
695 | pReco [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] ); |
---|
696 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
697 | } |
---|
698 | pPred += uiStride; |
---|
699 | pResi += uiStride; |
---|
700 | pReco += uiStride; |
---|
701 | pRecIPred += uiRecIPredStride; |
---|
702 | } |
---|
703 | } |
---|
704 | |
---|
705 | |
---|
706 | Void |
---|
707 | TDecCu::xIntraRecChromaBlk( TComDataCU* pcCU, |
---|
708 | UInt uiTrDepth, |
---|
709 | UInt uiAbsPartIdx, |
---|
710 | TComYuv* pcRecoYuv, |
---|
711 | TComYuv* pcPredYuv, |
---|
712 | TComYuv* pcResiYuv, |
---|
713 | UInt uiChromaId ) |
---|
714 | { |
---|
715 | UInt uiFullDepth = pcCU->getDepth( 0 ) + uiTrDepth; |
---|
716 | UInt uiLog2TrSize = g_aucConvertToBit[ pcCU->getSlice()->getSPS()->getMaxCUWidth() >> uiFullDepth ] + 2; |
---|
717 | |
---|
718 | if( uiLog2TrSize == 2 ) |
---|
719 | { |
---|
720 | assert( uiTrDepth > 0 ); |
---|
721 | uiTrDepth--; |
---|
722 | UInt uiQPDiv = pcCU->getPic()->getNumPartInCU() >> ( ( pcCU->getDepth( 0 ) + uiTrDepth ) << 1 ); |
---|
723 | Bool bFirstQ = ( ( uiAbsPartIdx % uiQPDiv ) == 0 ); |
---|
724 | if( !bFirstQ ) |
---|
725 | { |
---|
726 | return; |
---|
727 | } |
---|
728 | } |
---|
729 | |
---|
730 | TextType eText = ( uiChromaId > 0 ? TEXT_CHROMA_V : TEXT_CHROMA_U ); |
---|
731 | UInt uiWidth = pcCU ->getWidth ( 0 ) >> ( uiTrDepth + 1 ); |
---|
732 | UInt uiHeight = pcCU ->getHeight ( 0 ) >> ( uiTrDepth + 1 ); |
---|
733 | UInt uiStride = pcRecoYuv->getCStride (); |
---|
734 | Pel* piReco = ( uiChromaId > 0 ? pcRecoYuv->getCrAddr( uiAbsPartIdx ) : pcRecoYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
735 | Pel* piPred = ( uiChromaId > 0 ? pcPredYuv->getCrAddr( uiAbsPartIdx ) : pcPredYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
736 | Pel* piResi = ( uiChromaId > 0 ? pcResiYuv->getCrAddr( uiAbsPartIdx ) : pcResiYuv->getCbAddr( uiAbsPartIdx ) ); |
---|
737 | |
---|
738 | UInt uiNumCoeffInc = ( ( pcCU->getSlice()->getSPS()->getMaxCUWidth() * pcCU->getSlice()->getSPS()->getMaxCUHeight() ) >> ( pcCU->getSlice()->getSPS()->getMaxCUDepth() << 1 ) ) >> 2; |
---|
739 | TCoeff* pcCoeff = ( uiChromaId > 0 ? pcCU->getCoeffCr() : pcCU->getCoeffCb() ) + ( uiNumCoeffInc * uiAbsPartIdx ); |
---|
740 | |
---|
741 | UInt uiChromaPredMode = pcCU->getChromaIntraDir( 0 ); |
---|
742 | |
---|
743 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
744 | Pel* piRecIPred = ( uiChromaId > 0 ? pcCU->getPic()->getPicYuvRec()->getCrAddr( pcCU->getAddr(), uiZOrder ) : pcCU->getPic()->getPicYuvRec()->getCbAddr( pcCU->getAddr(), uiZOrder ) ); |
---|
745 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
746 | Bool useTransformSkipChroma = pcCU->getTransformSkip(uiAbsPartIdx,eText); |
---|
747 | //===== init availability pattern ===== |
---|
748 | Bool bAboveAvail = false; |
---|
749 | Bool bLeftAvail = false; |
---|
750 | pcCU->getPattern()->initPattern ( pcCU, uiTrDepth, uiAbsPartIdx ); |
---|
751 | |
---|
752 | pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth, |
---|
753 | m_pcPrediction->getPredicBuf (), |
---|
754 | m_pcPrediction->getPredicBufWidth (), |
---|
755 | m_pcPrediction->getPredicBufHeight (), |
---|
756 | bAboveAvail, bLeftAvail ); |
---|
757 | Int* pPatChroma = ( uiChromaId > 0 ? pcCU->getPattern()->getAdiCrBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) : pcCU->getPattern()->getAdiCbBuf( uiWidth, uiHeight, m_pcPrediction->getPredicBuf() ) ); |
---|
758 | |
---|
759 | //===== get prediction signal ===== |
---|
760 | { |
---|
761 | if( uiChromaPredMode == DM_CHROMA_IDX ) |
---|
762 | { |
---|
763 | uiChromaPredMode = pcCU->getLumaIntraDir( 0 ); |
---|
764 | #if H_3D_DIM |
---|
765 | mapDepthModeToIntraDir( uiChromaPredMode ); |
---|
766 | #endif |
---|
767 | } |
---|
768 | m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
769 | } |
---|
770 | |
---|
771 | //===== inverse transform ===== |
---|
772 | Int curChromaQpOffset; |
---|
773 | if(eText == TEXT_CHROMA_U) |
---|
774 | { |
---|
775 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
---|
776 | } |
---|
777 | else |
---|
778 | { |
---|
779 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
---|
780 | } |
---|
781 | m_pcTrQuant->setQPforQuant ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
782 | |
---|
783 | Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText]; |
---|
784 | assert(scalingListType < 6); |
---|
785 | m_pcTrQuant->invtransformNxN( pcCU->getCUTransquantBypass(uiAbsPartIdx), eText, REG_DCT, piResi, uiStride, pcCoeff, uiWidth, uiHeight, scalingListType, useTransformSkipChroma ); |
---|
786 | |
---|
787 | //===== reconstruction ===== |
---|
788 | Pel* pPred = piPred; |
---|
789 | Pel* pResi = piResi; |
---|
790 | Pel* pReco = piReco; |
---|
791 | Pel* pRecIPred = piRecIPred; |
---|
792 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
793 | { |
---|
794 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
795 | { |
---|
796 | pReco [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] ); |
---|
797 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
798 | } |
---|
799 | pPred += uiStride; |
---|
800 | pResi += uiStride; |
---|
801 | pReco += uiStride; |
---|
802 | pRecIPred += uiRecIPredStride; |
---|
803 | } |
---|
804 | } |
---|
805 | |
---|
806 | |
---|
807 | Void |
---|
808 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth ) |
---|
809 | { |
---|
810 | UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 ); |
---|
811 | UInt uiNumPart = pcCU->getNumPartInter(); |
---|
812 | UInt uiNumQParts = pcCU->getTotalNumPart() >> 2; |
---|
813 | |
---|
814 | if (pcCU->getIPCMFlag(0)) |
---|
815 | { |
---|
816 | xReconPCM( pcCU, uiDepth ); |
---|
817 | return; |
---|
818 | } |
---|
819 | |
---|
820 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
821 | { |
---|
822 | xIntraLumaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
823 | } |
---|
824 | |
---|
825 | for( UInt uiPU = 0; uiPU < uiNumPart; uiPU++ ) |
---|
826 | { |
---|
827 | xIntraChromaRecQT( pcCU, uiInitTrDepth, uiPU * uiNumQParts, m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth] ); |
---|
828 | } |
---|
829 | |
---|
830 | } |
---|
831 | |
---|
832 | #if H_3D_DIM_SDC |
---|
833 | Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
834 | { |
---|
835 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
836 | UInt uiHeight = pcCU->getHeight ( 0 ); |
---|
837 | |
---|
838 | TComYuv* pcRecoYuv = m_ppcYuvReco[uiDepth]; |
---|
839 | TComYuv* pcPredYuv = m_ppcYuvReco[uiDepth]; |
---|
840 | TComYuv* pcResiYuv = m_ppcYuvResi[uiDepth]; |
---|
841 | |
---|
842 | UInt uiStride = pcRecoYuv->getStride (); |
---|
843 | Pel* piReco = pcRecoYuv->getLumaAddr( uiAbsPartIdx ); |
---|
844 | Pel* piPred = pcPredYuv->getLumaAddr( uiAbsPartIdx ); |
---|
845 | Pel* piResi = pcResiYuv->getLumaAddr( uiAbsPartIdx ); |
---|
846 | |
---|
847 | UInt uiZOrder = pcCU->getZorderIdxInCU() + uiAbsPartIdx; |
---|
848 | Pel* piRecIPred = pcCU->getPic()->getPicYuvRec()->getLumaAddr( pcCU->getAddr(), uiZOrder ); |
---|
849 | UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride (); |
---|
850 | |
---|
851 | UInt uiLumaPredMode = pcCU->getLumaIntraDir ( uiAbsPartIdx ); |
---|
852 | |
---|
853 | AOF( uiWidth == uiHeight ); |
---|
854 | AOF( uiAbsPartIdx == 0 ); |
---|
855 | AOF( pcCU->getSDCAvailable(uiAbsPartIdx) ); |
---|
856 | AOF( pcCU->getSDCFlag(uiAbsPartIdx) ); |
---|
857 | |
---|
858 | //===== init availability pattern ===== |
---|
859 | Bool bAboveAvail = false; |
---|
860 | Bool bLeftAvail = false; |
---|
861 | pcCU->getPattern()->initPattern ( pcCU, 0, uiAbsPartIdx ); |
---|
862 | pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, 0, m_pcPrediction->getPredicBuf(), m_pcPrediction->getPredicBufWidth(), m_pcPrediction->getPredicBufHeight(), bAboveAvail, bLeftAvail ); |
---|
863 | |
---|
864 | //===== get prediction signal ===== |
---|
865 | #if H_3D_DIM |
---|
866 | if( isDimMode( uiLumaPredMode ) ) |
---|
867 | { |
---|
868 | m_pcPrediction->predIntraLumaDepth( pcCU, uiAbsPartIdx, uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight ); |
---|
869 | } |
---|
870 | else |
---|
871 | { |
---|
872 | #endif |
---|
873 | m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); |
---|
874 | #if H_3D_DIM |
---|
875 | } |
---|
876 | #endif |
---|
877 | |
---|
878 | // number of segments depends on prediction mode |
---|
879 | UInt uiNumSegments = 1; |
---|
880 | Bool* pbMask = NULL; |
---|
881 | UInt uiMaskStride = 0; |
---|
882 | |
---|
883 | if( getDimType( uiLumaPredMode ) == DMM1_IDX ) |
---|
884 | { |
---|
885 | Int uiTabIdx = pcCU->getDmmWedgeTabIdx(DMM1_IDX, uiAbsPartIdx); |
---|
886 | |
---|
887 | WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])]; |
---|
888 | TComWedgelet* pcWedgelet = &(pacWedgeList->at( uiTabIdx )); |
---|
889 | |
---|
890 | uiNumSegments = 2; |
---|
891 | pbMask = pcWedgelet->getPattern(); |
---|
892 | uiMaskStride = pcWedgelet->getStride(); |
---|
893 | } |
---|
894 | |
---|
895 | // get DC prediction for each segment |
---|
896 | Pel apDCPredValues[2]; |
---|
897 | #if KWU_SDC_SIMPLE_DC_E0117 |
---|
898 | m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode); |
---|
899 | #else |
---|
900 | m_pcPrediction->analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride); |
---|
901 | #endif |
---|
902 | |
---|
903 | // reconstruct residual based on mask + DC residuals |
---|
904 | Pel apDCResiValues[2]; |
---|
905 | for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ ) |
---|
906 | { |
---|
907 | #if H_3D_DIM_DLT |
---|
908 | Pel pPredIdx = pcCU->getSlice()->getVPS()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] ); |
---|
909 | Pel pResiIdx = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); |
---|
910 | Pel pRecoValue = pcCU->getSlice()->getVPS()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx ); |
---|
911 | |
---|
912 | apDCResiValues[uiSegment] = pRecoValue - apDCPredValues[uiSegment]; |
---|
913 | #else |
---|
914 | apDCResiValues[uiSegment] = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); |
---|
915 | #endif |
---|
916 | } |
---|
917 | |
---|
918 | //===== reconstruction ===== |
---|
919 | Bool*pMask = pbMask; |
---|
920 | Pel* pPred = piPred; |
---|
921 | Pel* pResi = piResi; |
---|
922 | Pel* pReco = piReco; |
---|
923 | Pel* pRecIPred = piRecIPred; |
---|
924 | |
---|
925 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
926 | { |
---|
927 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
928 | { |
---|
929 | UChar ucSegment = pMask?(UChar)pMask[uiX]:0; |
---|
930 | assert( ucSegment < uiNumSegments ); |
---|
931 | |
---|
932 | Pel pResiDC = apDCResiValues[ucSegment]; |
---|
933 | |
---|
934 | pReco [ uiX ] = ClipY( pPred[ uiX ] + pResiDC ); |
---|
935 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
936 | } |
---|
937 | pPred += uiStride; |
---|
938 | pResi += uiStride; |
---|
939 | pReco += uiStride; |
---|
940 | pRecIPred += uiRecIPredStride; |
---|
941 | pMask += uiMaskStride; |
---|
942 | } |
---|
943 | |
---|
944 | // clear UV |
---|
945 | UInt uiStrideC = pcPredYuv->getCStride(); |
---|
946 | Pel *pRecCb = pcPredYuv->getCbAddr(); |
---|
947 | Pel *pRecCr = pcPredYuv->getCrAddr(); |
---|
948 | |
---|
949 | for (Int y=0; y<uiHeight/2; y++) |
---|
950 | { |
---|
951 | for (Int x=0; x<uiWidth/2; x++) |
---|
952 | { |
---|
953 | pRecCb[x] = 128; |
---|
954 | pRecCr[x] = 128; |
---|
955 | } |
---|
956 | |
---|
957 | pRecCb += uiStrideC; |
---|
958 | pRecCr += uiStrideC; |
---|
959 | } |
---|
960 | } |
---|
961 | #endif |
---|
962 | |
---|
963 | /** Function for deriving recontructed PU/CU Luma sample with QTree structure |
---|
964 | * \param pcCU pointer of current CU |
---|
965 | * \param uiTrDepth current tranform split depth |
---|
966 | * \param uiAbsPartIdx part index |
---|
967 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
968 | * \param pcPredYuv pointer to prediction sample arrays |
---|
969 | * \param pcResiYuv pointer to residue sample arrays |
---|
970 | * |
---|
971 | \ This function dervies recontructed PU/CU Luma sample with recursive QTree structure |
---|
972 | */ |
---|
973 | Void |
---|
974 | TDecCu::xIntraLumaRecQT( TComDataCU* pcCU, |
---|
975 | UInt uiTrDepth, |
---|
976 | UInt uiAbsPartIdx, |
---|
977 | TComYuv* pcRecoYuv, |
---|
978 | TComYuv* pcPredYuv, |
---|
979 | TComYuv* pcResiYuv ) |
---|
980 | { |
---|
981 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
982 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
983 | if( uiTrMode == uiTrDepth ) |
---|
984 | { |
---|
985 | xIntraRecLumaBlk ( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
986 | } |
---|
987 | else |
---|
988 | { |
---|
989 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
990 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
991 | { |
---|
992 | xIntraLumaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
993 | } |
---|
994 | } |
---|
995 | } |
---|
996 | |
---|
997 | /** Function for deriving recontructed PU/CU chroma samples with QTree structure |
---|
998 | * \param pcCU pointer of current CU |
---|
999 | * \param uiTrDepth current tranform split depth |
---|
1000 | * \param uiAbsPartIdx part index |
---|
1001 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
1002 | * \param pcPredYuv pointer to prediction sample arrays |
---|
1003 | * \param pcResiYuv pointer to residue sample arrays |
---|
1004 | * |
---|
1005 | \ This function dervies recontructed PU/CU chroma samples with QTree recursive structure |
---|
1006 | */ |
---|
1007 | Void |
---|
1008 | TDecCu::xIntraChromaRecQT( TComDataCU* pcCU, |
---|
1009 | UInt uiTrDepth, |
---|
1010 | UInt uiAbsPartIdx, |
---|
1011 | TComYuv* pcRecoYuv, |
---|
1012 | TComYuv* pcPredYuv, |
---|
1013 | TComYuv* pcResiYuv ) |
---|
1014 | { |
---|
1015 | UInt uiFullDepth = pcCU->getDepth(0) + uiTrDepth; |
---|
1016 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
1017 | if( uiTrMode == uiTrDepth ) |
---|
1018 | { |
---|
1019 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 0 ); |
---|
1020 | xIntraRecChromaBlk( pcCU, uiTrDepth, uiAbsPartIdx, pcRecoYuv, pcPredYuv, pcResiYuv, 1 ); |
---|
1021 | } |
---|
1022 | else |
---|
1023 | { |
---|
1024 | UInt uiNumQPart = pcCU->getPic()->getNumPartInCU() >> ( ( uiFullDepth + 1 ) << 1 ); |
---|
1025 | for( UInt uiPart = 0; uiPart < 4; uiPart++ ) |
---|
1026 | { |
---|
1027 | xIntraChromaRecQT( pcCU, uiTrDepth + 1, uiAbsPartIdx + uiPart * uiNumQPart, pcRecoYuv, pcPredYuv, pcResiYuv ); |
---|
1028 | } |
---|
1029 | } |
---|
1030 | } |
---|
1031 | |
---|
1032 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
1033 | { |
---|
1034 | UInt uiCUAddr = pcCU->getAddr(); |
---|
1035 | |
---|
1036 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCUAddr, uiZorderIdx ); |
---|
1037 | |
---|
1038 | return; |
---|
1039 | } |
---|
1040 | |
---|
1041 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1042 | { |
---|
1043 | UInt uiWidth = pcCU->getWidth ( uiAbsPartIdx ); |
---|
1044 | UInt uiHeight = pcCU->getHeight( uiAbsPartIdx ); |
---|
1045 | TCoeff* piCoeff; |
---|
1046 | |
---|
1047 | Pel* pResi; |
---|
1048 | UInt trMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
1049 | |
---|
1050 | // Y |
---|
1051 | piCoeff = pcCU->getCoeffY(); |
---|
1052 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr(); |
---|
1053 | |
---|
1054 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); |
---|
1055 | |
---|
1056 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
1057 | |
---|
1058 | // Cb and Cr |
---|
1059 | Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb(); |
---|
1060 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
1061 | |
---|
1062 | uiWidth >>= 1; |
---|
1063 | uiHeight >>= 1; |
---|
1064 | piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr(); |
---|
1065 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
1066 | |
---|
1067 | curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); |
---|
1068 | m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset ); |
---|
1069 | |
---|
1070 | piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr(); |
---|
1071 | m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff ); |
---|
1072 | } |
---|
1073 | |
---|
1074 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
---|
1075 | * \param pcCU pointer to current CU |
---|
1076 | * \param uiPartIdx part index |
---|
1077 | * \param piPCM pointer to PCM code arrays |
---|
1078 | * \param piReco pointer to reconstructed sample arrays |
---|
1079 | * \param uiStride stride of reconstructed sample arrays |
---|
1080 | * \param uiWidth CU width |
---|
1081 | * \param uiHeight CU height |
---|
1082 | * \param ttText texture component type |
---|
1083 | * \returns Void |
---|
1084 | */ |
---|
1085 | Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, UInt uiPartIdx, Pel *piPCM, Pel* piReco, UInt uiStride, UInt uiWidth, UInt uiHeight, TextType ttText) |
---|
1086 | { |
---|
1087 | UInt uiX, uiY; |
---|
1088 | Pel* piPicReco; |
---|
1089 | UInt uiPicStride; |
---|
1090 | UInt uiPcmLeftShiftBit; |
---|
1091 | |
---|
1092 | if( ttText == TEXT_LUMA ) |
---|
1093 | { |
---|
1094 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(); |
---|
1095 | piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
1096 | uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma(); |
---|
1097 | } |
---|
1098 | else |
---|
1099 | { |
---|
1100 | uiPicStride = pcCU->getPic()->getPicYuvRec()->getCStride(); |
---|
1101 | |
---|
1102 | if( ttText == TEXT_CHROMA_U ) |
---|
1103 | { |
---|
1104 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCbAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
1105 | } |
---|
1106 | else |
---|
1107 | { |
---|
1108 | piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx); |
---|
1109 | } |
---|
1110 | uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma(); |
---|
1111 | } |
---|
1112 | |
---|
1113 | for( uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1114 | { |
---|
1115 | for( uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1116 | { |
---|
1117 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
---|
1118 | piPicReco[uiX] = piReco[uiX]; |
---|
1119 | } |
---|
1120 | piPCM += uiWidth; |
---|
1121 | piReco += uiStride; |
---|
1122 | piPicReco += uiPicStride; |
---|
1123 | } |
---|
1124 | } |
---|
1125 | |
---|
1126 | /** Function for reconstructing a PCM mode CU. |
---|
1127 | * \param pcCU pointer to current CU |
---|
1128 | * \param uiDepth CU Depth |
---|
1129 | * \returns Void |
---|
1130 | */ |
---|
1131 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth ) |
---|
1132 | { |
---|
1133 | // Luma |
---|
1134 | UInt uiWidth = (g_uiMaxCUWidth >> uiDepth); |
---|
1135 | UInt uiHeight = (g_uiMaxCUHeight >> uiDepth); |
---|
1136 | |
---|
1137 | Pel* piPcmY = pcCU->getPCMSampleY(); |
---|
1138 | Pel* piRecoY = m_ppcYuvReco[uiDepth]->getLumaAddr(0, uiWidth); |
---|
1139 | |
---|
1140 | UInt uiStride = m_ppcYuvResi[uiDepth]->getStride(); |
---|
1141 | |
---|
1142 | xDecodePCMTexture( pcCU, 0, piPcmY, piRecoY, uiStride, uiWidth, uiHeight, TEXT_LUMA); |
---|
1143 | |
---|
1144 | // Cb and Cr |
---|
1145 | UInt uiCWidth = (uiWidth>>1); |
---|
1146 | UInt uiCHeight = (uiHeight>>1); |
---|
1147 | |
---|
1148 | Pel* piPcmCb = pcCU->getPCMSampleCb(); |
---|
1149 | Pel* piPcmCr = pcCU->getPCMSampleCr(); |
---|
1150 | Pel* pRecoCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
---|
1151 | Pel* pRecoCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
---|
1152 | |
---|
1153 | UInt uiCStride = m_ppcYuvReco[uiDepth]->getCStride(); |
---|
1154 | |
---|
1155 | xDecodePCMTexture( pcCU, 0, piPcmCb, pRecoCb, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_U); |
---|
1156 | xDecodePCMTexture( pcCU, 0, piPcmCr, pRecoCr, uiCStride, uiCWidth, uiCHeight, TEXT_CHROMA_V); |
---|
1157 | } |
---|
1158 | |
---|
1159 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
---|
1160 | * \param pcCU pointer to current CU |
---|
1161 | * \param uiDepth CU Depth |
---|
1162 | * \returns Void |
---|
1163 | */ |
---|
1164 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth) |
---|
1165 | { |
---|
1166 | // Luma |
---|
1167 | UInt width = (g_uiMaxCUWidth >> depth); |
---|
1168 | UInt height = (g_uiMaxCUHeight >> depth); |
---|
1169 | |
---|
1170 | Pel* pPcmY = pCU->getPCMSampleY(); |
---|
1171 | Pel* pRecoY = m_ppcYuvReco[depth]->getLumaAddr(0, width); |
---|
1172 | |
---|
1173 | UInt stride = m_ppcYuvReco[depth]->getStride(); |
---|
1174 | |
---|
1175 | for(Int y = 0; y < height; y++ ) |
---|
1176 | { |
---|
1177 | for(Int x = 0; x < width; x++ ) |
---|
1178 | { |
---|
1179 | pPcmY[x] = pRecoY[x]; |
---|
1180 | } |
---|
1181 | pPcmY += width; |
---|
1182 | pRecoY += stride; |
---|
1183 | } |
---|
1184 | |
---|
1185 | // Cb and Cr |
---|
1186 | UInt widthC = (width>>1); |
---|
1187 | UInt heightC = (height>>1); |
---|
1188 | |
---|
1189 | Pel* pPcmCb = pCU->getPCMSampleCb(); |
---|
1190 | Pel* pPcmCr = pCU->getPCMSampleCr(); |
---|
1191 | Pel* pRecoCb = m_ppcYuvReco[depth]->getCbAddr(); |
---|
1192 | Pel* pRecoCr = m_ppcYuvReco[depth]->getCrAddr(); |
---|
1193 | |
---|
1194 | UInt strideC = m_ppcYuvReco[depth]->getCStride(); |
---|
1195 | |
---|
1196 | for(Int y = 0; y < heightC; y++ ) |
---|
1197 | { |
---|
1198 | for(Int x = 0; x < widthC; x++ ) |
---|
1199 | { |
---|
1200 | pPcmCb[x] = pRecoCb[x]; |
---|
1201 | pPcmCr[x] = pRecoCr[x]; |
---|
1202 | } |
---|
1203 | pPcmCr += widthC; |
---|
1204 | pPcmCb += widthC; |
---|
1205 | pRecoCb += strideC; |
---|
1206 | pRecoCr += strideC; |
---|
1207 | } |
---|
1208 | |
---|
1209 | } |
---|
1210 | |
---|
1211 | //! \} |
---|