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