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