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