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-2015, 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 | #include "TLibCommon/TComTU.h" |
---|
40 | #include "TLibCommon/TComPrediction.h" |
---|
41 | |
---|
42 | //! \ingroup TLibDecoder |
---|
43 | //! \{ |
---|
44 | |
---|
45 | // ==================================================================================================================== |
---|
46 | // Constructor / destructor / create / destroy |
---|
47 | // ==================================================================================================================== |
---|
48 | |
---|
49 | TDecCu::TDecCu() |
---|
50 | { |
---|
51 | m_ppcYuvResi = NULL; |
---|
52 | m_ppcYuvReco = NULL; |
---|
53 | m_ppcCU = NULL; |
---|
54 | #if NH_3D_DBBP |
---|
55 | m_ppcYuvRecoDBBP = NULL; |
---|
56 | #endif |
---|
57 | } |
---|
58 | |
---|
59 | TDecCu::~TDecCu() |
---|
60 | { |
---|
61 | } |
---|
62 | |
---|
63 | Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction) |
---|
64 | { |
---|
65 | m_pcEntropyDecoder = pcEntropyDecoder; |
---|
66 | m_pcTrQuant = pcTrQuant; |
---|
67 | m_pcPrediction = pcPrediction; |
---|
68 | } |
---|
69 | |
---|
70 | /** |
---|
71 | \param uiMaxDepth total number of allowable depth |
---|
72 | \param uiMaxWidth largest CU width |
---|
73 | \param uiMaxHeight largest CU height |
---|
74 | \param chromaFormatIDC chroma format |
---|
75 | */ |
---|
76 | Void TDecCu::create( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight, ChromaFormat chromaFormatIDC ) |
---|
77 | { |
---|
78 | m_uiMaxDepth = uiMaxDepth+1; |
---|
79 | |
---|
80 | m_ppcYuvResi = new TComYuv*[m_uiMaxDepth-1]; |
---|
81 | m_ppcYuvReco = new TComYuv*[m_uiMaxDepth-1]; |
---|
82 | m_ppcCU = new TComDataCU*[m_uiMaxDepth-1]; |
---|
83 | #if NH_3D_DBBP |
---|
84 | m_ppcYuvRecoDBBP = new TComYuv*[m_uiMaxDepth-1]; |
---|
85 | #endif |
---|
86 | |
---|
87 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
88 | { |
---|
89 | UInt uiNumPartitions = 1<<( ( m_uiMaxDepth - ui - 1 )<<1 ); |
---|
90 | UInt uiWidth = uiMaxWidth >> ui; |
---|
91 | UInt uiHeight = uiMaxHeight >> ui; |
---|
92 | |
---|
93 | // The following arrays (m_ppcYuvResi, m_ppcYuvReco and m_ppcCU) are only required for CU depths |
---|
94 | // although data is allocated for all possible depths of the CU/TU tree except the last. |
---|
95 | // Since the TU tree will always include at least one additional depth greater than the CU tree, |
---|
96 | // there will be enough entries for these arrays. |
---|
97 | // (Section 7.4.3.2: "The CVS shall not contain data that result in (Log2MinTrafoSize) MinTbLog2SizeY |
---|
98 | // greater than or equal to MinCbLog2SizeY") |
---|
99 | // TODO: tidy the array allocation given the above comment. |
---|
100 | |
---|
101 | m_ppcYuvResi[ui] = new TComYuv; m_ppcYuvResi[ui]->create( uiWidth, uiHeight, chromaFormatIDC ); |
---|
102 | m_ppcYuvReco[ui] = new TComYuv; m_ppcYuvReco[ui]->create( uiWidth, uiHeight, chromaFormatIDC ); |
---|
103 | m_ppcCU [ui] = new TComDataCU; m_ppcCU [ui]->create( chromaFormatIDC, uiNumPartitions, uiWidth, uiHeight, true, uiMaxWidth >> (m_uiMaxDepth - 1) ); |
---|
104 | #if NH_3D_DBBP |
---|
105 | m_ppcYuvRecoDBBP[ui] = new TComYuv; m_ppcYuvRecoDBBP[ui]->create( uiWidth, uiHeight, chromaFormatIDC ); |
---|
106 | #endif |
---|
107 | } |
---|
108 | |
---|
109 | m_bDecodeDQP = false; |
---|
110 | m_IsChromaQpAdjCoded = false; |
---|
111 | |
---|
112 | // initialize partition order. |
---|
113 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
114 | initZscanToRaster(m_uiMaxDepth, 1, 0, piTmp); |
---|
115 | initRasterToZscan( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
116 | |
---|
117 | // initialize conversion matrix from partition index to pel |
---|
118 | initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth ); |
---|
119 | } |
---|
120 | |
---|
121 | Void TDecCu::destroy() |
---|
122 | { |
---|
123 | for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) |
---|
124 | { |
---|
125 | m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL; |
---|
126 | m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL; |
---|
127 | m_ppcCU [ui]->destroy(); delete m_ppcCU [ui]; m_ppcCU [ui] = NULL; |
---|
128 | #if NH_3D_DBBP |
---|
129 | m_ppcYuvRecoDBBP[ui]->destroy(); delete m_ppcYuvRecoDBBP[ui]; m_ppcYuvRecoDBBP[ui] = NULL; |
---|
130 | #endif |
---|
131 | } |
---|
132 | |
---|
133 | delete [] m_ppcYuvResi; m_ppcYuvResi = NULL; |
---|
134 | delete [] m_ppcYuvReco; m_ppcYuvReco = NULL; |
---|
135 | delete [] m_ppcCU ; m_ppcCU = NULL; |
---|
136 | #if NH_3D_DBBP |
---|
137 | delete [] m_ppcYuvRecoDBBP; m_ppcYuvRecoDBBP = NULL; |
---|
138 | #endif |
---|
139 | } |
---|
140 | |
---|
141 | // ==================================================================================================================== |
---|
142 | // Public member functions |
---|
143 | // ==================================================================================================================== |
---|
144 | |
---|
145 | /** |
---|
146 | Parse a CTU. |
---|
147 | \param pCtu [in/out] pointer to CTU data structure |
---|
148 | \param isLastCtuOfSliceSegment [out] true, if last CTU of the slice segment |
---|
149 | */ |
---|
150 | Void TDecCu::decodeCtu( TComDataCU* pCtu, Bool& isLastCtuOfSliceSegment ) |
---|
151 | { |
---|
152 | if ( pCtu->getSlice()->getPPS()->getUseDQP() ) |
---|
153 | { |
---|
154 | setdQPFlag(true); |
---|
155 | } |
---|
156 | |
---|
157 | if ( pCtu->getSlice()->getUseChromaQpAdj() ) |
---|
158 | { |
---|
159 | setIsChromaQpAdjCoded(true); |
---|
160 | } |
---|
161 | |
---|
162 | // start from the top level CU |
---|
163 | xDecodeCU( pCtu, 0, 0, isLastCtuOfSliceSegment); |
---|
164 | } |
---|
165 | |
---|
166 | /** |
---|
167 | Decoding process for a CTU. |
---|
168 | \param pCtu [in/out] pointer to CTU data structure |
---|
169 | */ |
---|
170 | Void TDecCu::decompressCtu( TComDataCU* pCtu ) |
---|
171 | { |
---|
172 | #if !NH_3D_IV_MERGE |
---|
173 | xDecompressCU( pCtu, 0, 0 ); |
---|
174 | #endif |
---|
175 | } |
---|
176 | |
---|
177 | // ==================================================================================================================== |
---|
178 | // Protected member functions |
---|
179 | // ==================================================================================================================== |
---|
180 | |
---|
181 | //! decode end-of-slice flag |
---|
182 | Bool TDecCu::xDecodeSliceEnd( TComDataCU* pcCU, UInt uiAbsPartIdx ) |
---|
183 | { |
---|
184 | UInt uiIsLastCtuOfSliceSegment; |
---|
185 | |
---|
186 | if (pcCU->isLastSubCUOfCtu(uiAbsPartIdx)) |
---|
187 | { |
---|
188 | m_pcEntropyDecoder->decodeTerminatingBit( uiIsLastCtuOfSliceSegment ); |
---|
189 | } |
---|
190 | else |
---|
191 | { |
---|
192 | uiIsLastCtuOfSliceSegment=0; |
---|
193 | } |
---|
194 | |
---|
195 | return uiIsLastCtuOfSliceSegment>0; |
---|
196 | } |
---|
197 | |
---|
198 | //! decode CU block recursively |
---|
199 | Void TDecCu::xDecodeCU( TComDataCU*const pcCU, const UInt uiAbsPartIdx, const UInt uiDepth, Bool &isLastCtuOfSliceSegment) |
---|
200 | { |
---|
201 | TComPic* pcPic = pcCU->getPic(); |
---|
202 | const TComSPS &sps = pcPic->getPicSym()->getSPS(); |
---|
203 | const TComPPS &pps = pcPic->getPicSym()->getPPS(); |
---|
204 | const UInt maxCuWidth = sps.getMaxCUWidth(); |
---|
205 | const UInt maxCuHeight= sps.getMaxCUHeight(); |
---|
206 | UInt uiCurNumParts = pcPic->getNumPartitionsInCtu() >> (uiDepth<<1); |
---|
207 | UInt uiQNumParts = uiCurNumParts>>2; |
---|
208 | |
---|
209 | |
---|
210 | Bool bBoundary = false; |
---|
211 | UInt uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
212 | UInt uiRPelX = uiLPelX + (maxCuWidth>>uiDepth) - 1; |
---|
213 | UInt uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
214 | UInt uiBPelY = uiTPelY + (maxCuHeight>>uiDepth) - 1; |
---|
215 | #if H_MV_ENC_DEC_TRAC |
---|
216 | DTRACE_CU_S("=========== coding_quadtree ===========\n") |
---|
217 | DTRACE_CU("x0", uiLPelX) |
---|
218 | DTRACE_CU("x1", uiTPelY) |
---|
219 | DTRACE_CU("log2CbSize", maxCuWidth>>uiDepth) |
---|
220 | DTRACE_CU("cqtDepth" , uiDepth) |
---|
221 | #endif |
---|
222 | |
---|
223 | if( ( uiRPelX < sps.getPicWidthInLumaSamples() ) && ( uiBPelY < sps.getPicHeightInLumaSamples() ) ) |
---|
224 | { |
---|
225 | m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
226 | } |
---|
227 | else |
---|
228 | { |
---|
229 | bBoundary = true; |
---|
230 | } |
---|
231 | if( ( ( uiDepth < pcCU->getDepth( uiAbsPartIdx ) ) && ( uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) ) || bBoundary ) |
---|
232 | { |
---|
233 | UInt uiIdx = uiAbsPartIdx; |
---|
234 | if( uiDepth == pps.getMaxCuDQPDepth() && pps.getUseDQP()) |
---|
235 | { |
---|
236 | setdQPFlag(true); |
---|
237 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
238 | } |
---|
239 | |
---|
240 | if( uiDepth == pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcCU->getSlice()->getUseChromaQpAdj() ) |
---|
241 | { |
---|
242 | setIsChromaQpAdjCoded(true); |
---|
243 | } |
---|
244 | |
---|
245 | for ( UInt uiPartUnitIdx = 0; uiPartUnitIdx < 4; uiPartUnitIdx++ ) |
---|
246 | { |
---|
247 | uiLPelX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
248 | uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
249 | |
---|
250 | if ( !isLastCtuOfSliceSegment && ( uiLPelX < sps.getPicWidthInLumaSamples() ) && ( uiTPelY < sps.getPicHeightInLumaSamples() ) ) |
---|
251 | { |
---|
252 | xDecodeCU( pcCU, uiIdx, uiDepth+1, isLastCtuOfSliceSegment ); |
---|
253 | } |
---|
254 | else |
---|
255 | { |
---|
256 | pcCU->setOutsideCUPart( uiIdx, uiDepth+1 ); |
---|
257 | } |
---|
258 | |
---|
259 | uiIdx += uiQNumParts; |
---|
260 | } |
---|
261 | if( uiDepth == pps.getMaxCuDQPDepth() && pps.getUseDQP()) |
---|
262 | { |
---|
263 | if ( getdQPFlag() ) |
---|
264 | { |
---|
265 | UInt uiQPSrcPartIdx = uiAbsPartIdx; |
---|
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 | #if H_MV_ENC_DEC_TRAC |
---|
275 | #if ENC_DEC_TRACE |
---|
276 | stopAtPos ( pcCU->getSlice()->getPOC(), |
---|
277 | pcCU->getSlice()->getLayerId(), |
---|
278 | uiLPelX, |
---|
279 | uiTPelY, |
---|
280 | uiRPelX-uiLPelX+1, |
---|
281 | uiBPelY-uiTPelY+1); |
---|
282 | #endif |
---|
283 | #endif |
---|
284 | |
---|
285 | #endif |
---|
286 | |
---|
287 | if( uiDepth <= pps.getMaxCuDQPDepth() && pps.getUseDQP()) |
---|
288 | { |
---|
289 | setdQPFlag(true); |
---|
290 | pcCU->setQPSubParts( pcCU->getRefQP(uiAbsPartIdx), uiAbsPartIdx, uiDepth ); // set QP to default QP |
---|
291 | } |
---|
292 | #if NH_3D_NBDV |
---|
293 | DisInfo DvInfo; |
---|
294 | DvInfo.m_acNBDV.setZero(); |
---|
295 | DvInfo.m_aVIdxCan = 0; |
---|
296 | #if NH_3D_NBDV_REF |
---|
297 | DvInfo.m_acDoNBDV.setZero(); |
---|
298 | #endif |
---|
299 | |
---|
300 | if(!pcCU->getSlice()->isIntra()) |
---|
301 | { |
---|
302 | #if NH_3D_ARP && NH_3D_IV_MERGE && NH_3D_VSP |
---|
303 | if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getIvMvPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() ) |
---|
304 | #else |
---|
305 | #if NH_3D_IV_MERGE && NH_3D_VSP |
---|
306 | if( pcCU->getSlice()->getIvMvPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() ) |
---|
307 | #else |
---|
308 | #if NH_3D_ARP && NH_3D_VSP |
---|
309 | if( pcCU->getSlice()->getIvResPredFlag() || pcCU->getSlice()->getViewSynthesisPredFlag() ) |
---|
310 | #else |
---|
311 | #if NH_3D_VSP |
---|
312 | if( pcCU->getSlice()->getViewSynthesisPredFlag() ) |
---|
313 | #else |
---|
314 | #if H_3D_ARP |
---|
315 | if( pcCU->getSlice()->getIvResPredFlag( ) ) |
---|
316 | #else |
---|
317 | #if H_3D_IV_MERGE |
---|
318 | if( pcCU->getSlice()->getVPS()->getIvMvPredFlag(pcCU->getSlice()->getLayerId()) ) |
---|
319 | #else |
---|
320 | #if NH_3D_DBBP |
---|
321 | if( pcCU->getSlice()->getDepthBasedBlkPartFlag() ) |
---|
322 | #else |
---|
323 | if (0) |
---|
324 | #endif |
---|
325 | #endif |
---|
326 | #endif |
---|
327 | #endif |
---|
328 | #endif |
---|
329 | #endif |
---|
330 | #endif |
---|
331 | { |
---|
332 | m_ppcCU[uiDepth]->copyInterPredInfoFrom(pcCU, uiAbsPartIdx, REF_PIC_LIST_0, true); |
---|
333 | m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx); |
---|
334 | PartSize ePartTemp = m_ppcCU[uiDepth]->getPartitionSize(0); |
---|
335 | UChar cWidTemp = m_ppcCU[uiDepth]->getWidth(0); |
---|
336 | UChar cHeightTemp = m_ppcCU[uiDepth]->getHeight(0); |
---|
337 | m_ppcCU[uiDepth]->setWidth (0, pcCU->getSlice()->getSPS()->getMaxCUWidth () / (1 << uiDepth)); |
---|
338 | m_ppcCU[uiDepth]->setHeight(0, pcCU->getSlice()->getSPS()->getMaxCUHeight() / (1 << uiDepth)); |
---|
339 | m_ppcCU[uiDepth]->setPartSizeSubParts(SIZE_2Nx2N, 0, uiDepth); |
---|
340 | #if NH_3D_IV_MERGE |
---|
341 | if( pcCU->getSlice()->getIsDepth()) |
---|
342 | { |
---|
343 | m_ppcCU[uiDepth]->getDispforDepth(0, 0, &DvInfo); |
---|
344 | } |
---|
345 | else |
---|
346 | { |
---|
347 | #endif |
---|
348 | #if NH_3D_NBDV_REF |
---|
349 | if( pcCU->getSlice()->getDepthBasedBlkPartFlag() ) //Notes from QC: please check the condition for DoNBDV. Remove this comment once it is done. |
---|
350 | { |
---|
351 | m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo, true); |
---|
352 | } |
---|
353 | else |
---|
354 | #endif |
---|
355 | { |
---|
356 | m_ppcCU[uiDepth]->getDisMvpCandNBDV(&DvInfo); |
---|
357 | } |
---|
358 | #if NH_3D_IV_MERGE |
---|
359 | } |
---|
360 | #endif |
---|
361 | #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC |
---|
362 | if ( g_decTraceDispDer ) |
---|
363 | { |
---|
364 | DTRACE_CU( "RefViewIdx", DvInfo.m_aVIdxCan ); |
---|
365 | DTRACE_CU( "MvDisp[x]", DvInfo.m_acNBDV.getHor() ); |
---|
366 | DTRACE_CU( "MvDisp[y]", DvInfo.m_acNBDV.getVer() ); |
---|
367 | DTRACE_CU( "MvRefinedDisp[x]", DvInfo.m_acDoNBDV.getHor() ); |
---|
368 | DTRACE_CU( "MvRefinedDisp[y]", DvInfo.m_acDoNBDV.getVer() ); |
---|
369 | } |
---|
370 | #endif |
---|
371 | pcCU->setDvInfoSubParts(DvInfo, uiAbsPartIdx, uiDepth); |
---|
372 | m_ppcCU[uiDepth]->setPartSizeSubParts(ePartTemp, 0, uiDepth); |
---|
373 | m_ppcCU[uiDepth]->setWidth(0, cWidTemp); |
---|
374 | m_ppcCU[uiDepth]->setHeight(0, cHeightTemp); |
---|
375 | } |
---|
376 | } |
---|
377 | #endif |
---|
378 | |
---|
379 | if( uiDepth <= pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() && pcCU->getSlice()->getUseChromaQpAdj() ) |
---|
380 | { |
---|
381 | setIsChromaQpAdjCoded(true); |
---|
382 | } |
---|
383 | |
---|
384 | if (pps.getTransquantBypassEnableFlag()) |
---|
385 | { |
---|
386 | m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
387 | } |
---|
388 | |
---|
389 | // decode CU mode and the partition size |
---|
390 | if( !pcCU->getSlice()->isIntra()) |
---|
391 | { |
---|
392 | m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
393 | } |
---|
394 | |
---|
395 | |
---|
396 | if( pcCU->isSkipped(uiAbsPartIdx) ) |
---|
397 | { |
---|
398 | #if H_MV_ENC_DEC_TRAC |
---|
399 | DTRACE_PU_S("=========== prediction_unit ===========\n") |
---|
400 | DTRACE_PU("x0", uiLPelX) |
---|
401 | DTRACE_PU("x1", uiTPelY) |
---|
402 | #endif |
---|
403 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 ); |
---|
404 | m_ppcCU[uiDepth]->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_1 ); |
---|
405 | #if NH_3D_IV_MERGE |
---|
406 | m_ppcCU[uiDepth]->copyDVInfoFrom(pcCU, uiAbsPartIdx); |
---|
407 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
---|
408 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
---|
409 | #else |
---|
410 | #if NH_3D_MLC |
---|
411 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS_MEM << 1]; // double length for mv of both lists |
---|
412 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS_MEM]; |
---|
413 | #else |
---|
414 | TComMvField cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists |
---|
415 | UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; |
---|
416 | #endif |
---|
417 | #endif |
---|
418 | Int numValidMergeCand = 0; |
---|
419 | for( UInt ui = 0; ui < m_ppcCU[uiDepth]->getSlice()->getMaxNumMergeCand(); ++ui ) |
---|
420 | { |
---|
421 | uhInterDirNeighbours[ui] = 0; |
---|
422 | } |
---|
423 | m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth ); |
---|
424 | UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx); |
---|
425 | #if NH_3D_ARP |
---|
426 | m_pcEntropyDecoder->decodeARPW( pcCU , uiAbsPartIdx , uiDepth ); |
---|
427 | #endif |
---|
428 | #if NH_3D_IC |
---|
429 | m_pcEntropyDecoder->decodeICFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
430 | #endif |
---|
431 | |
---|
432 | |
---|
433 | #if NH_3D_VSP |
---|
434 | Int vspFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
435 | memset(vspFlag, 0, sizeof(Int)*MRG_MAX_NUM_CANDS_MEM); |
---|
436 | #endif |
---|
437 | #if NH_3D_SPIVMP |
---|
438 | Bool bSPIVMPFlag[MRG_MAX_NUM_CANDS_MEM]; |
---|
439 | memset(bSPIVMPFlag, false, sizeof(Bool)*MRG_MAX_NUM_CANDS_MEM); |
---|
440 | TComMvField* pcMvFieldSP; |
---|
441 | UChar* puhInterDirSP; |
---|
442 | pcMvFieldSP = new TComMvField[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()*2]; |
---|
443 | puhInterDirSP = new UChar[pcCU->getPic()->getPicSym()->getNumPartitionsInCtu()]; |
---|
444 | #endif |
---|
445 | |
---|
446 | #if NH_3D_MLC |
---|
447 | m_ppcCU[uiDepth]->initAvailableFlags(); |
---|
448 | #endif |
---|
449 | m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex ); |
---|
450 | #if NH_3D_MLC |
---|
451 | m_ppcCU[uiDepth]->xGetInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours |
---|
452 | #if NH_3D_SPIVMP |
---|
453 | , pcMvFieldSP, puhInterDirSP |
---|
454 | #endif |
---|
455 | , numValidMergeCand, uiMergeIndex ); |
---|
456 | |
---|
457 | m_ppcCU[uiDepth]->buildMCL( cMvFieldNeighbours, uhInterDirNeighbours |
---|
458 | #if NH_3D_VSP |
---|
459 | , vspFlag |
---|
460 | #endif |
---|
461 | #if NH_3D_SPIVMP |
---|
462 | , bSPIVMPFlag |
---|
463 | #endif |
---|
464 | , numValidMergeCand ); |
---|
465 | #endif |
---|
466 | #if NH_3D_VSP |
---|
467 | pcCU->setVSPFlagSubParts( vspFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
468 | #endif |
---|
469 | |
---|
470 | pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
471 | |
---|
472 | TComMv cTmpMv( 0, 0 ); |
---|
473 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
474 | { |
---|
475 | if ( pcCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > 0 ) |
---|
476 | { |
---|
477 | pcCU->setMVPIdxSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
478 | pcCU->setMVPNumSubParts( 0, RefPicList( uiRefListIdx ), uiAbsPartIdx, 0, uiDepth); |
---|
479 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvd( cTmpMv, SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
480 | pcCU->getCUMvField( RefPicList( uiRefListIdx ) )->setAllMvField( cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ], SIZE_2Nx2N, uiAbsPartIdx, uiDepth ); |
---|
481 | #if NH_3D_VSP |
---|
482 | if( pcCU->getVSPFlag( uiAbsPartIdx ) != 0 ) |
---|
483 | { |
---|
484 | if ( uhInterDirNeighbours[ uiMergeIndex ] & (1<<uiRefListIdx) ) |
---|
485 | { |
---|
486 | UInt dummy; |
---|
487 | Int vspSize; |
---|
488 | Int width, height; |
---|
489 | m_ppcCU[uiDepth]->getPartIndexAndSize( uiAbsPartIdx, dummy, width, height ); |
---|
490 | m_ppcCU[uiDepth]->setMvFieldPUForVSP( pcCU, uiAbsPartIdx, width, height, RefPicList( uiRefListIdx ), cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx(), vspSize ); |
---|
491 | pcCU->setVSPFlag( uiAbsPartIdx, vspSize ); |
---|
492 | } |
---|
493 | } |
---|
494 | #endif |
---|
495 | #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC |
---|
496 | if ( g_decTraceMvFromMerge ) |
---|
497 | { |
---|
498 | if ( uiRefListIdx == 0 ) |
---|
499 | { |
---|
500 | DTRACE_PU( "mvL0[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor()); |
---|
501 | DTRACE_PU( "mvL0[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer()); |
---|
502 | DTRACE_PU( "refIdxL0 ", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx()); |
---|
503 | } |
---|
504 | else |
---|
505 | { |
---|
506 | DTRACE_PU( "mvL1[0]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getHor()); |
---|
507 | DTRACE_PU( "mvL1[1]", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getVer()); |
---|
508 | DTRACE_PU( "refIdxL1", cMvFieldNeighbours[ 2*uiMergeIndex + uiRefListIdx ].getRefIdx()); |
---|
509 | } |
---|
510 | } |
---|
511 | #endif |
---|
512 | } |
---|
513 | } |
---|
514 | #if NH_3D_SPIVMP |
---|
515 | pcCU->setSPIVMPFlagSubParts(bSPIVMPFlag[uiMergeIndex], uiAbsPartIdx, 0, uiDepth ); |
---|
516 | if (bSPIVMPFlag[uiMergeIndex]) |
---|
517 | { |
---|
518 | UInt uiSPAddr; |
---|
519 | Int iWidth = pcCU->getWidth(uiAbsPartIdx); |
---|
520 | Int iHeight = pcCU->getHeight(uiAbsPartIdx); |
---|
521 | |
---|
522 | Int iNumSPInOneLine, iNumSP, iSPWidth, iSPHeight; |
---|
523 | |
---|
524 | pcCU->getSPPara(iWidth, iHeight, iNumSP, iNumSPInOneLine, iSPWidth, iSPHeight); |
---|
525 | |
---|
526 | for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++) |
---|
527 | { |
---|
528 | pcCU->getSPAbsPartIdx(uiAbsPartIdx, iSPWidth, iSPHeight, iPartitionIdx, iNumSPInOneLine, uiSPAddr); |
---|
529 | pcCU->setInterDirSP(puhInterDirSP[iPartitionIdx], uiSPAddr, iSPWidth, iSPHeight); |
---|
530 | pcCU->getCUMvField( REF_PIC_LIST_0 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx], iSPWidth, iSPHeight); |
---|
531 | pcCU->getCUMvField( REF_PIC_LIST_1 )->setMvFieldSP(pcCU, uiSPAddr, pcMvFieldSP[2*iPartitionIdx + 1], iSPWidth, iSPHeight); |
---|
532 | } |
---|
533 | } |
---|
534 | delete[] pcMvFieldSP; |
---|
535 | delete[] puhInterDirSP; |
---|
536 | #endif |
---|
537 | |
---|
538 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
---|
539 | #if NH_3D_IV_MERGE |
---|
540 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
---|
541 | #endif |
---|
542 | |
---|
543 | return; |
---|
544 | } |
---|
545 | #if NH_3D_DIS |
---|
546 | m_pcEntropyDecoder->decodeDIS( pcCU, uiAbsPartIdx, uiDepth ); |
---|
547 | if(!pcCU->getDISFlag(uiAbsPartIdx)) |
---|
548 | { |
---|
549 | #endif |
---|
550 | |
---|
551 | m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
552 | m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
553 | |
---|
554 | if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
---|
555 | { |
---|
556 | m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
557 | |
---|
558 | if(pcCU->getIPCMFlag(uiAbsPartIdx)) |
---|
559 | { |
---|
560 | #if NH_3D_SDC_INTRA |
---|
561 | m_pcEntropyDecoder->decodeSDCFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
562 | #endif |
---|
563 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
---|
564 | #if NH_3D_IV_MERGE |
---|
565 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
---|
566 | #endif |
---|
567 | return; |
---|
568 | } |
---|
569 | } |
---|
570 | |
---|
571 | // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
572 | m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); |
---|
573 | |
---|
574 | // Coefficient decoding |
---|
575 | Bool bCodeDQP = getdQPFlag(); |
---|
576 | Bool isChromaQpAdjCoded = getIsChromaQpAdjCoded(); |
---|
577 | m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, bCodeDQP, isChromaQpAdjCoded ); |
---|
578 | setIsChromaQpAdjCoded( isChromaQpAdjCoded ); |
---|
579 | setdQPFlag( bCodeDQP ); |
---|
580 | #if NH_3D_DIS |
---|
581 | } |
---|
582 | #endif |
---|
583 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
---|
584 | #if NH_3D_IV_MERGE |
---|
585 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
---|
586 | #endif |
---|
587 | } |
---|
588 | |
---|
589 | Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &isLastCtuOfSliceSegment) |
---|
590 | { |
---|
591 | if( pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
592 | { |
---|
593 | pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP |
---|
594 | } |
---|
595 | |
---|
596 | if (pcCU->getSlice()->getUseChromaQpAdj() && !getIsChromaQpAdjCoded()) |
---|
597 | { |
---|
598 | pcCU->setChromaQpAdjSubParts( pcCU->getCodedChromaQpAdj(), uiAbsPartIdx, uiDepth ); // set QP |
---|
599 | } |
---|
600 | |
---|
601 | isLastCtuOfSliceSegment = xDecodeSliceEnd( pcCU, uiAbsPartIdx ); |
---|
602 | } |
---|
603 | |
---|
604 | Void TDecCu::xDecompressCU( TComDataCU* pCtu, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
605 | { |
---|
606 | TComPic* pcPic = pCtu->getPic(); |
---|
607 | #if !NH_3D_IV_MERGE |
---|
608 | TComSlice * pcSlice = pCtu->getSlice(); |
---|
609 | const TComSPS &sps=*(pcSlice->getSPS()); |
---|
610 | |
---|
611 | Bool bBoundary = false; |
---|
612 | UInt uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
613 | UInt uiRPelX = uiLPelX + (sps.getMaxCUWidth()>>uiDepth) - 1; |
---|
614 | UInt uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
615 | UInt uiBPelY = uiTPelY + (sps.getMaxCUHeight()>>uiDepth) - 1; |
---|
616 | |
---|
617 | if( ( uiRPelX >= sps.getPicWidthInLumaSamples() ) || ( uiBPelY >= sps.getPicHeightInLumaSamples() ) ) |
---|
618 | { |
---|
619 | bBoundary = true; |
---|
620 | } |
---|
621 | |
---|
622 | if( ( ( uiDepth < pCtu->getDepth( uiAbsPartIdx ) ) && ( uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) ) || bBoundary ) |
---|
623 | { |
---|
624 | UInt uiNextDepth = uiDepth + 1; |
---|
625 | UInt uiQNumParts = pCtu->getTotalNumPart() >> (uiNextDepth<<1); |
---|
626 | UInt uiIdx = uiAbsPartIdx; |
---|
627 | for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ ) |
---|
628 | { |
---|
629 | uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
630 | uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
631 | |
---|
632 | if( ( uiLPelX < sps.getPicWidthInLumaSamples() ) && ( uiTPelY < sps.getPicHeightInLumaSamples() ) ) |
---|
633 | { |
---|
634 | xDecompressCU(pCtu, uiIdx, uiNextDepth ); |
---|
635 | } |
---|
636 | |
---|
637 | uiIdx += uiQNumParts; |
---|
638 | } |
---|
639 | return; |
---|
640 | } |
---|
641 | #endif |
---|
642 | // Residual reconstruction |
---|
643 | m_ppcYuvResi[uiDepth]->clear(); |
---|
644 | |
---|
645 | m_ppcCU[uiDepth]->copySubCU( pCtu, uiAbsPartIdx ); |
---|
646 | |
---|
647 | switch( m_ppcCU[uiDepth]->getPredictionMode(0) ) |
---|
648 | { |
---|
649 | case MODE_INTER: |
---|
650 | #if NH_3D_DBBP |
---|
651 | if( m_ppcCU[uiDepth]->getDBBPFlag(0) ) |
---|
652 | { |
---|
653 | xReconInterDBBP( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
654 | } |
---|
655 | else |
---|
656 | { |
---|
657 | #endif |
---|
658 | #if H_3D_INTER_SDC |
---|
659 | if( m_ppcCU[uiDepth]->getSDCFlag( 0 ) ) |
---|
660 | { |
---|
661 | xReconInterSDC( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
662 | } |
---|
663 | else |
---|
664 | { |
---|
665 | #endif |
---|
666 | xReconInter( m_ppcCU[uiDepth], uiDepth ); |
---|
667 | #if H_3D_INTER_SDC |
---|
668 | } |
---|
669 | #endif |
---|
670 | #if NH_3D_DBBP |
---|
671 | } |
---|
672 | #endif |
---|
673 | break; |
---|
674 | case MODE_INTRA: |
---|
675 | #if NH_3D |
---|
676 | #if NH_3D_DIS |
---|
677 | if( m_ppcCU[uiDepth]->getDISFlag(0) ) |
---|
678 | { |
---|
679 | xReconDIS( m_ppcCU[uiDepth], 0, uiDepth ); |
---|
680 | } |
---|
681 | #else |
---|
682 | if(false ) |
---|
683 | { |
---|
684 | // xReconDIS( m_ppcCU[uiDepth], 0, uiDepth ); |
---|
685 | } |
---|
686 | #endif |
---|
687 | #if NH_3D_SDC_INTRA |
---|
688 | else if( m_ppcCU[uiDepth]->getSDCFlag(0) ) |
---|
689 | { |
---|
690 | xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth ); |
---|
691 | } |
---|
692 | #endif |
---|
693 | else |
---|
694 | #endif |
---|
695 | xReconIntraQT( m_ppcCU[uiDepth], uiDepth ); |
---|
696 | break; |
---|
697 | default: |
---|
698 | assert(0); |
---|
699 | break; |
---|
700 | } |
---|
701 | |
---|
702 | #if DEBUG_STRING |
---|
703 | const PredMode predMode=m_ppcCU[uiDepth]->getPredictionMode(0); |
---|
704 | if (DebugOptionList::DebugString_Structure.getInt()&DebugStringGetPredModeMask(predMode)) |
---|
705 | { |
---|
706 | PartSize eSize=m_ppcCU[uiDepth]->getPartitionSize(0); |
---|
707 | std::ostream &ss(std::cout); |
---|
708 | |
---|
709 | ss <<"###: " << (predMode==MODE_INTRA?"Intra ":"Inter ") << partSizeToString[eSize] << " CU at " << m_ppcCU[uiDepth]->getCUPelX() << ", " << m_ppcCU[uiDepth]->getCUPelY() << " width=" << UInt(m_ppcCU[uiDepth]->getWidth(0)) << std::endl; |
---|
710 | } |
---|
711 | #endif |
---|
712 | |
---|
713 | if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false)) |
---|
714 | { |
---|
715 | xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth); |
---|
716 | } |
---|
717 | |
---|
718 | xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth ); |
---|
719 | } |
---|
720 | |
---|
721 | Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth ) |
---|
722 | { |
---|
723 | |
---|
724 | // inter prediction |
---|
725 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
726 | |
---|
727 | #if DEBUG_STRING |
---|
728 | const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTER); |
---|
729 | if (DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) |
---|
730 | { |
---|
731 | printBlockToStream(std::cout, "###inter-pred: ", *(m_ppcYuvReco[uiDepth])); |
---|
732 | } |
---|
733 | #endif |
---|
734 | |
---|
735 | // inter recon |
---|
736 | xDecodeInterTexture( pcCU, uiDepth ); |
---|
737 | |
---|
738 | #if DEBUG_STRING |
---|
739 | if (DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) |
---|
740 | { |
---|
741 | printBlockToStream(std::cout, "###inter-resi: ", *(m_ppcYuvResi[uiDepth])); |
---|
742 | } |
---|
743 | #endif |
---|
744 | |
---|
745 | // clip for only non-zero cbp case |
---|
746 | if ( pcCU->getQtRootCbf( 0) ) |
---|
747 | { |
---|
748 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() ); |
---|
749 | } |
---|
750 | else |
---|
751 | { |
---|
752 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
753 | } |
---|
754 | #if DEBUG_STRING |
---|
755 | if (DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) |
---|
756 | { |
---|
757 | printBlockToStream(std::cout, "###inter-reco: ", *(m_ppcYuvReco[uiDepth])); |
---|
758 | } |
---|
759 | #endif |
---|
760 | |
---|
761 | } |
---|
762 | |
---|
763 | #if NH_3D_DIS |
---|
764 | Void TDecCu::xReconDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
765 | { |
---|
766 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
767 | UInt uiHeight = pcCU->getHeight ( 0 ); |
---|
768 | |
---|
769 | TComYuv* pcRecoYuv = m_ppcYuvReco[uiDepth]; |
---|
770 | |
---|
771 | UInt uiStride = pcRecoYuv->getStride (COMPONENT_Y); |
---|
772 | Pel* piReco = pcRecoYuv->getAddr( COMPONENT_Y, uiAbsPartIdx ); |
---|
773 | |
---|
774 | |
---|
775 | AOF( uiWidth == uiHeight ); |
---|
776 | AOF( uiAbsPartIdx == 0 ); |
---|
777 | |
---|
778 | TComTURecurse rTu(pcCU, 0); |
---|
779 | const ChromaFormat chFmt = rTu.GetChromaFormat(); |
---|
780 | |
---|
781 | if ( pcCU->getDISType(uiAbsPartIdx) == 0 ) |
---|
782 | { |
---|
783 | const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, VER_IDX, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag()); |
---|
784 | m_pcPrediction->initIntraPatternChType( rTu, COMPONENT_Y, bUseFilteredPredictions DEBUG_STRING_PASS_INTO(sTemp) ); |
---|
785 | m_pcPrediction->predIntraAng( COMPONENT_Y, VER_IDX, 0 /* Decoder does not have an original image */, 0, piReco, uiStride, rTu, bUseFilteredPredictions ); |
---|
786 | } |
---|
787 | else if ( pcCU->getDISType(uiAbsPartIdx) == 1 ) |
---|
788 | { |
---|
789 | const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, HOR_IDX, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag()); |
---|
790 | m_pcPrediction->initIntraPatternChType( rTu, COMPONENT_Y, bUseFilteredPredictions DEBUG_STRING_PASS_INTO(sTemp) ); |
---|
791 | m_pcPrediction->predIntraAng( COMPONENT_Y, HOR_IDX, 0 /* Decoder does not have an original image */, 0, piReco, uiStride, rTu, bUseFilteredPredictions ); |
---|
792 | } |
---|
793 | else if ( pcCU->getDISType(uiAbsPartIdx) == 2 ) |
---|
794 | { |
---|
795 | Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 ); |
---|
796 | pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 0 ); |
---|
797 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
798 | { |
---|
799 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
800 | { |
---|
801 | piReco[ uiX ] = pSingleDepth; |
---|
802 | } |
---|
803 | piReco+= uiStride; |
---|
804 | } |
---|
805 | } |
---|
806 | else if ( pcCU->getDISType(uiAbsPartIdx) == 3 ) |
---|
807 | { |
---|
808 | Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 ); |
---|
809 | pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 1 ); |
---|
810 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
811 | { |
---|
812 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
813 | { |
---|
814 | piReco[ uiX ] = pSingleDepth; |
---|
815 | } |
---|
816 | piReco+= uiStride; |
---|
817 | } |
---|
818 | } |
---|
819 | |
---|
820 | // clear UV |
---|
821 | UInt uiStrideC = pcRecoYuv->getStride(COMPONENT_Cb); |
---|
822 | Pel *pRecCb = pcRecoYuv->getAddr(COMPONENT_Cb); |
---|
823 | Pel *pRecCr = pcRecoYuv->getAddr(COMPONENT_Cr); |
---|
824 | |
---|
825 | for (Int y=0; y<uiHeight/2; y++) |
---|
826 | { |
---|
827 | for (Int x=0; x<uiWidth/2; x++) |
---|
828 | { |
---|
829 | pRecCb[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1); |
---|
830 | pRecCr[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1); |
---|
831 | } |
---|
832 | |
---|
833 | pRecCb += uiStrideC; |
---|
834 | pRecCr += uiStrideC; |
---|
835 | } |
---|
836 | } |
---|
837 | #endif |
---|
838 | #if H_3D_INTER_SDC |
---|
839 | Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
840 | { |
---|
841 | // inter prediction |
---|
842 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
843 | |
---|
844 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
845 | UInt uiHeight = pcCU->getHeight( 0 ); |
---|
846 | |
---|
847 | Pel *pResi; |
---|
848 | UInt uiPelX, uiPelY; |
---|
849 | UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride(); |
---|
850 | |
---|
851 | pResi = m_ppcYuvResi[uiDepth]->getLumaAddr( 0 ); |
---|
852 | for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ ) |
---|
853 | { |
---|
854 | for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ ) |
---|
855 | { |
---|
856 | pResi[ uiPelX ] = pcCU->getSDCSegmentDCOffset( 0, 0 ); |
---|
857 | } |
---|
858 | pResi += uiResiStride; |
---|
859 | } |
---|
860 | |
---|
861 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) ); |
---|
862 | |
---|
863 | // clear UV |
---|
864 | UInt uiStrideC = m_ppcYuvReco[uiDepth]->getCStride(); |
---|
865 | Pel *pRecCb = m_ppcYuvReco[uiDepth]->getCbAddr(); |
---|
866 | Pel *pRecCr = m_ppcYuvReco[uiDepth]->getCrAddr(); |
---|
867 | |
---|
868 | for (Int y = 0; y < uiHeight/2; y++) |
---|
869 | { |
---|
870 | for (Int x = 0; x < uiWidth/2; x++) |
---|
871 | { |
---|
872 | pRecCb[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) ); |
---|
873 | pRecCr[x] = (Pel)( 1 << ( g_bitDepthC - 1 ) ); |
---|
874 | } |
---|
875 | |
---|
876 | pRecCb += uiStrideC; |
---|
877 | pRecCr += uiStrideC; |
---|
878 | } |
---|
879 | } |
---|
880 | #endif |
---|
881 | |
---|
882 | #if NH_3D_DBBP |
---|
883 | Void TDecCu::xReconInterDBBP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
884 | { |
---|
885 | AOF(!pcCU->getSlice()->getIsDepth()); |
---|
886 | AOF(!pcCU->getSlice()->isIntra()); |
---|
887 | PartSize ePartSize = pcCU->getPartitionSize( 0 ); |
---|
888 | |
---|
889 | Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA); |
---|
890 | |
---|
891 | // get collocated depth block |
---|
892 | UInt uiDepthStride = 0; |
---|
893 | #if H_3D_FCO |
---|
894 | Pel* pDepthPels = pcCU->getVirtualDepthBlock(pcCU->getZorderIdxInCU(), pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride); |
---|
895 | #else |
---|
896 | Pel* pDepthPels = pcCU->getVirtualDepthBlock(0, pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride); |
---|
897 | #endif |
---|
898 | AOF( pDepthPels != NULL ); |
---|
899 | AOF( uiDepthStride != 0 ); |
---|
900 | |
---|
901 | // compute mask by segmenting depth block |
---|
902 | Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE]; |
---|
903 | Bool bValidMask = m_pcPrediction->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(0), pcCU->getHeight(0), pMask, pcCU); |
---|
904 | AOF(bValidMask); |
---|
905 | |
---|
906 | DbbpTmpData* pDBBPTmpData = pcCU->getDBBPTmpData(); |
---|
907 | TComYuv* apSegPredYuv[2] = { m_ppcYuvReco[uiDepth], m_ppcYuvRecoDBBP[uiDepth] }; |
---|
908 | |
---|
909 | // first, extract the two sets of motion parameters |
---|
910 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
911 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
912 | { |
---|
913 | UInt uiPartAddr = uiSegment*uiPUOffset; |
---|
914 | |
---|
915 | pDBBPTmpData->auhInterDir[uiSegment] = pcCU->getInterDir(uiPartAddr); |
---|
916 | assert( pDBBPTmpData->auhInterDir[uiSegment] == 1 || pDBBPTmpData->auhInterDir[uiSegment] == 2 ); // only uni-prediction allowed |
---|
917 | |
---|
918 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
919 | { |
---|
920 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
921 | pcCU->getMvField(pcCU, uiPartAddr, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]); |
---|
922 | } |
---|
923 | |
---|
924 | #if H_3D |
---|
925 | AOF( pcCU->getARPW(uiPartAddr) == 0 ); |
---|
926 | AOF( pcCU->getICFlag(uiPartAddr) == false ); |
---|
927 | AOF( pcCU->getSPIVMPFlag(uiPartAddr) == false ); |
---|
928 | AOF( pcCU->getVSPFlag(uiPartAddr) == 0 ); |
---|
929 | #endif |
---|
930 | } |
---|
931 | |
---|
932 | // do motion compensation for each segment as 2Nx2N |
---|
933 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
934 | pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth ); |
---|
935 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
936 | { |
---|
937 | pcCU->setInterDirSubParts( pDBBPTmpData->auhInterDir[uiSegment], 0, 0, uiDepth ); |
---|
938 | |
---|
939 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
940 | { |
---|
941 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
942 | |
---|
943 | pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], SIZE_2Nx2N, 0, 0 ); |
---|
944 | } |
---|
945 | |
---|
946 | // inter prediction |
---|
947 | m_pcPrediction->motionCompensation( pcCU, apSegPredYuv[uiSegment] ); |
---|
948 | } |
---|
949 | |
---|
950 | // restore motion information in both segments again |
---|
951 | pcCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); |
---|
952 | pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth ); |
---|
953 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
954 | { |
---|
955 | UInt uiPartAddr = uiSegment*uiPUOffset; |
---|
956 | |
---|
957 | pcCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uiDepth); |
---|
958 | pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uiDepth); // interprets depth relative to LCU level |
---|
959 | |
---|
960 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
961 | { |
---|
962 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
963 | |
---|
964 | pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], ePartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level |
---|
965 | } |
---|
966 | } |
---|
967 | |
---|
968 | // reconstruct final prediction signal by combining both segments |
---|
969 | m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0), 0, ePartSize, bitDepthY); |
---|
970 | |
---|
971 | // inter recon |
---|
972 | xDecodeInterTexture( pcCU, uiDepth ); |
---|
973 | |
---|
974 | // clip for only non-zero cbp case |
---|
975 | if ( ( pcCU->getCbf( 0, COMPONENT_Y ) ) || ( pcCU->getCbf( 0, COMPONENT_Cb ) ) || ( pcCU->getCbf(0, COMPONENT_Cr ) ) ) |
---|
976 | { |
---|
977 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() ); |
---|
978 | } |
---|
979 | else |
---|
980 | { |
---|
981 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
982 | } |
---|
983 | } |
---|
984 | #endif |
---|
985 | |
---|
986 | |
---|
987 | Void |
---|
988 | TDecCu::xIntraRecBlk( TComYuv* pcRecoYuv, |
---|
989 | TComYuv* pcPredYuv, |
---|
990 | TComYuv* pcResiYuv, |
---|
991 | const ComponentID compID, |
---|
992 | TComTU &rTu) |
---|
993 | { |
---|
994 | if (!rTu.ProcessComponentSection(compID)) |
---|
995 | { |
---|
996 | return; |
---|
997 | } |
---|
998 | const Bool bIsLuma = isLuma(compID); |
---|
999 | |
---|
1000 | |
---|
1001 | TComDataCU *pcCU = rTu.getCU(); |
---|
1002 | const TComSPS &sps=*(pcCU->getSlice()->getSPS()); |
---|
1003 | const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU(); |
---|
1004 | |
---|
1005 | const TComRectangle &tuRect =rTu.getRect(compID); |
---|
1006 | const UInt uiWidth = tuRect.width; |
---|
1007 | const UInt uiHeight = tuRect.height; |
---|
1008 | const UInt uiStride = pcRecoYuv->getStride (compID); |
---|
1009 | Pel* piPred = pcPredYuv->getAddr( compID, uiAbsPartIdx ); |
---|
1010 | const ChromaFormat chFmt = rTu.GetChromaFormat(); |
---|
1011 | |
---|
1012 | if (uiWidth != uiHeight) |
---|
1013 | { |
---|
1014 | //------------------------------------------------ |
---|
1015 | |
---|
1016 | //split at current level if dividing into square sub-TUs |
---|
1017 | |
---|
1018 | TComTURecurse subTURecurse(rTu, false, TComTU::VERTICAL_SPLIT, true, compID); |
---|
1019 | |
---|
1020 | //recurse further |
---|
1021 | do |
---|
1022 | { |
---|
1023 | xIntraRecBlk(pcRecoYuv, pcPredYuv, pcResiYuv, compID, subTURecurse); |
---|
1024 | } while (subTURecurse.nextSection(rTu)); |
---|
1025 | |
---|
1026 | //------------------------------------------------ |
---|
1027 | |
---|
1028 | return; |
---|
1029 | } |
---|
1030 | |
---|
1031 | const UInt uiChPredMode = pcCU->getIntraDir( toChannelType(compID), uiAbsPartIdx ); |
---|
1032 | const UInt partsPerMinCU = 1<<(2*(sps.getMaxTotalCUDepth() - sps.getLog2DiffMaxMinCodingBlockSize())); |
---|
1033 | const UInt uiChCodedMode = (uiChPredMode==DM_CHROMA_IDX && !bIsLuma) ? pcCU->getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, chFmt, partsPerMinCU)) : uiChPredMode; |
---|
1034 | const UInt uiChFinalMode = ((chFmt == CHROMA_422) && !bIsLuma) ? g_chroma422IntraAngleMappingTable[uiChCodedMode] : uiChCodedMode; |
---|
1035 | |
---|
1036 | //===== init availability pattern ===== |
---|
1037 | const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(compID, uiChFinalMode, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag()); |
---|
1038 | |
---|
1039 | #if DEBUG_STRING |
---|
1040 | std::ostream &ss(std::cout); |
---|
1041 | #endif |
---|
1042 | |
---|
1043 | DEBUG_STRING_NEW(sTemp) |
---|
1044 | m_pcPrediction->initIntraPatternChType( rTu, compID, bUseFilteredPredictions DEBUG_STRING_PASS_INTO(sTemp) ); |
---|
1045 | |
---|
1046 | |
---|
1047 | //===== get prediction signal ===== |
---|
1048 | #if NH_3D_DMM |
---|
1049 | if( bIsLuma && isDmmMode( uiChFinalMode ) ) |
---|
1050 | { |
---|
1051 | m_pcPrediction->predIntraLumaDmm( pcCU, uiAbsPartIdx, getDmmType( uiChFinalMode ), piPred, uiStride, uiWidth, uiHeight ); |
---|
1052 | } |
---|
1053 | else |
---|
1054 | { |
---|
1055 | #endif |
---|
1056 | m_pcPrediction->predIntraAng( compID, uiChFinalMode, 0 /* Decoder does not have an original image */, 0, piPred, uiStride, rTu, bUseFilteredPredictions ); |
---|
1057 | #if NH_3D_DMM |
---|
1058 | } |
---|
1059 | #endif |
---|
1060 | |
---|
1061 | #if DEBUG_STRING |
---|
1062 | ss << sTemp; |
---|
1063 | #endif |
---|
1064 | |
---|
1065 | //===== inverse transform ===== |
---|
1066 | Pel* piResi = pcResiYuv->getAddr( compID, uiAbsPartIdx ); |
---|
1067 | TCoeff* pcCoeff = pcCU->getCoeff(compID) + rTu.getCoefficientOffset(compID);//( uiNumCoeffInc * uiAbsPartIdx ); |
---|
1068 | |
---|
1069 | const QpParam cQP(*pcCU, compID); |
---|
1070 | |
---|
1071 | |
---|
1072 | DEBUG_STRING_NEW(sDebug); |
---|
1073 | #if DEBUG_STRING |
---|
1074 | const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTRA); |
---|
1075 | std::string *psDebug=(DebugOptionList::DebugString_InvTran.getInt()&debugPredModeMask) ? &sDebug : 0; |
---|
1076 | #endif |
---|
1077 | #if H_3D |
---|
1078 | Bool useDltFlag = (isDmmMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()); |
---|
1079 | |
---|
1080 | if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) || useDltFlag ) |
---|
1081 | #else |
---|
1082 | if (pcCU->getCbf(uiAbsPartIdx, compID, rTu.GetTransformDepthRel()) != 0) |
---|
1083 | #endif |
---|
1084 | { |
---|
1085 | m_pcTrQuant->invTransformNxN( rTu, compID, piResi, uiStride, pcCoeff, cQP DEBUG_STRING_PASS_INTO(psDebug) ); |
---|
1086 | } |
---|
1087 | else |
---|
1088 | { |
---|
1089 | for (UInt y = 0; y < uiHeight; y++) |
---|
1090 | { |
---|
1091 | for (UInt x = 0; x < uiWidth; x++) |
---|
1092 | { |
---|
1093 | piResi[(y * uiStride) + x] = 0; |
---|
1094 | } |
---|
1095 | } |
---|
1096 | } |
---|
1097 | |
---|
1098 | #if DEBUG_STRING |
---|
1099 | if (psDebug) |
---|
1100 | { |
---|
1101 | ss << (*psDebug); |
---|
1102 | } |
---|
1103 | #endif |
---|
1104 | |
---|
1105 | //===== reconstruction ===== |
---|
1106 | const UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride(compID); |
---|
1107 | |
---|
1108 | const Bool useCrossComponentPrediction = isChroma(compID) && (pcCU->getCrossComponentPredictionAlpha(uiAbsPartIdx, compID) != 0); |
---|
1109 | const Pel* pResiLuma = pcResiYuv->getAddr( COMPONENT_Y, uiAbsPartIdx ); |
---|
1110 | const Int strideLuma = pcResiYuv->getStride( COMPONENT_Y ); |
---|
1111 | |
---|
1112 | Pel* pPred = piPred; |
---|
1113 | Pel* pResi = piResi; |
---|
1114 | Pel* pReco = pcRecoYuv->getAddr( compID, uiAbsPartIdx ); |
---|
1115 | Pel* pRecIPred = pcCU->getPic()->getPicYuvRec()->getAddr( compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx ); |
---|
1116 | |
---|
1117 | |
---|
1118 | #if DEBUG_STRING |
---|
1119 | const Bool bDebugPred=((DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
1120 | const Bool bDebugResi=((DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
1121 | const Bool bDebugReco=((DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
1122 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
1123 | { |
---|
1124 | ss << "###: " << "CompID: " << compID << " pred mode (ch/fin): " << uiChPredMode << "/" << uiChFinalMode << " absPartIdx: " << rTu.GetAbsPartIdxTU() << std::endl; |
---|
1125 | } |
---|
1126 | #endif |
---|
1127 | |
---|
1128 | const Int clipbd = sps.getBitDepth(toChannelType(compID)); |
---|
1129 | #if O0043_BEST_EFFORT_DECODING |
---|
1130 | const Int bitDepthDelta = sps.getStreamBitDepth(toChannelType(compID)) - clipbd; |
---|
1131 | #endif |
---|
1132 | |
---|
1133 | if( useCrossComponentPrediction ) |
---|
1134 | { |
---|
1135 | TComTrQuant::crossComponentPrediction( rTu, compID, pResiLuma, piResi, piResi, uiWidth, uiHeight, strideLuma, uiStride, uiStride, true ); |
---|
1136 | } |
---|
1137 | |
---|
1138 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1139 | { |
---|
1140 | #if DEBUG_STRING |
---|
1141 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
1142 | { |
---|
1143 | ss << "###: "; |
---|
1144 | } |
---|
1145 | |
---|
1146 | if (bDebugPred) |
---|
1147 | { |
---|
1148 | ss << " - pred: "; |
---|
1149 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1150 | { |
---|
1151 | ss << pPred[ uiX ] << ", "; |
---|
1152 | } |
---|
1153 | } |
---|
1154 | if (bDebugResi) |
---|
1155 | { |
---|
1156 | ss << " - resi: "; |
---|
1157 | } |
---|
1158 | #endif |
---|
1159 | |
---|
1160 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1161 | { |
---|
1162 | #if DEBUG_STRING |
---|
1163 | if (bDebugResi) |
---|
1164 | { |
---|
1165 | ss << pResi[ uiX ] << ", "; |
---|
1166 | } |
---|
1167 | #endif |
---|
1168 | #if O0043_BEST_EFFORT_DECODING |
---|
1169 | pReco [ uiX ] = ClipBD( rightShiftEvenRounding<Pel>(pPred[ uiX ] + pResi[ uiX ], bitDepthDelta), clipbd ); |
---|
1170 | #else |
---|
1171 | pReco [ uiX ] = ClipBD( pPred[ uiX ] + pResi[ uiX ], clipbd ); |
---|
1172 | #endif |
---|
1173 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
1174 | } |
---|
1175 | #if DEBUG_STRING |
---|
1176 | if (bDebugReco) |
---|
1177 | { |
---|
1178 | ss << " - reco: "; |
---|
1179 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1180 | { |
---|
1181 | ss << pReco[ uiX ] << ", "; |
---|
1182 | } |
---|
1183 | } |
---|
1184 | |
---|
1185 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
1186 | { |
---|
1187 | ss << "\n"; |
---|
1188 | } |
---|
1189 | #endif |
---|
1190 | pPred += uiStride; |
---|
1191 | pResi += uiStride; |
---|
1192 | pReco += uiStride; |
---|
1193 | pRecIPred += uiRecIPredStride; |
---|
1194 | } |
---|
1195 | } |
---|
1196 | |
---|
1197 | Void |
---|
1198 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth ) |
---|
1199 | { |
---|
1200 | if (pcCU->getIPCMFlag(0)) |
---|
1201 | { |
---|
1202 | xReconPCM( pcCU, uiDepth ); |
---|
1203 | return; |
---|
1204 | } |
---|
1205 | const UInt numChType = pcCU->getPic()->getChromaFormat()!=CHROMA_400 ? 2 : 1; |
---|
1206 | for (UInt chType=CHANNEL_TYPE_LUMA; chType<numChType; chType++) |
---|
1207 | { |
---|
1208 | const ChannelType chanType=ChannelType(chType); |
---|
1209 | const Bool NxNPUHas4Parts = ::isChroma(chanType) ? enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) : true; |
---|
1210 | const UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) != SIZE_2Nx2N && NxNPUHas4Parts ? 1 : 0 ); |
---|
1211 | |
---|
1212 | TComTURecurse tuRecurseCU(pcCU, 0); |
---|
1213 | TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (uiInitTrDepth==0)?TComTU::DONT_SPLIT : TComTU::QUAD_SPLIT); |
---|
1214 | |
---|
1215 | do |
---|
1216 | { |
---|
1217 | xIntraRecQT( m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], chanType, tuRecurseWithPU ); |
---|
1218 | } while (tuRecurseWithPU.nextSection(tuRecurseCU)); |
---|
1219 | } |
---|
1220 | } |
---|
1221 | |
---|
1222 | #if NH_3D_SDC_INTRA |
---|
1223 | Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1224 | { |
---|
1225 | TComYuv* pcRecoYuv = m_ppcYuvReco[uiDepth]; |
---|
1226 | TComYuv* pcPredYuv = m_ppcYuvReco[uiDepth]; |
---|
1227 | TComYuv* pcResiYuv = m_ppcYuvResi[uiDepth]; |
---|
1228 | |
---|
1229 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
1230 | UInt uiHeight = pcCU->getHeight( 0 ); |
---|
1231 | UInt uiLumaPredMode = pcCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx ); |
---|
1232 | const Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA); |
---|
1233 | const TComSPS &sps = *(pcCU->getSlice()->getSPS()); |
---|
1234 | const ChromaFormat chFmt = pcCU->getPic()->getChromaFormat(); |
---|
1235 | |
---|
1236 | UInt sdcDepth = 0; |
---|
1237 | UInt uiStride; |
---|
1238 | Pel* piReco; |
---|
1239 | Pel* piPred; |
---|
1240 | Pel* piResi; |
---|
1241 | |
---|
1242 | Pel* piRecIPred; |
---|
1243 | UInt uiRecIPredStride; |
---|
1244 | |
---|
1245 | Pel apDCPredValues[2]; |
---|
1246 | UInt uiNumSegments; |
---|
1247 | |
---|
1248 | Bool* pbMask = NULL; |
---|
1249 | UInt uiMaskStride = 0; |
---|
1250 | |
---|
1251 | #if NH_3D_DMM |
---|
1252 | if( isDmmMode( uiLumaPredMode ) ) |
---|
1253 | { |
---|
1254 | assert( uiWidth == uiHeight ); |
---|
1255 | assert( uiWidth >= DMM_MIN_SIZE && uiWidth <= DMM_MAX_SIZE ); |
---|
1256 | assert( !((uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()) > 1) ); |
---|
1257 | |
---|
1258 | uiNumSegments = 2; |
---|
1259 | |
---|
1260 | uiStride = pcRecoYuv->getStride( COMPONENT_Y ); |
---|
1261 | piReco = pcRecoYuv->getAddr ( COMPONENT_Y, uiAbsPartIdx ); |
---|
1262 | piPred = pcPredYuv->getAddr ( COMPONENT_Y, uiAbsPartIdx ); |
---|
1263 | piResi = pcResiYuv->getAddr ( COMPONENT_Y, uiAbsPartIdx ); |
---|
1264 | |
---|
1265 | piRecIPred = pcCU->getPic()->getPicYuvRec()->getAddr ( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx ); |
---|
1266 | uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride( COMPONENT_Y ); |
---|
1267 | |
---|
1268 | //===== init availability pattern ===== |
---|
1269 | TComTURecurse tuRecurseCU(pcCU, 0); |
---|
1270 | TComTURecurse tuRecurseWithPU(tuRecurseCU, false, TComTU::DONT_SPLIT); |
---|
1271 | |
---|
1272 | m_pcPrediction->initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, false DEBUG_STRING_PASS_INTO(sTemp) ); |
---|
1273 | |
---|
1274 | // get partition |
---|
1275 | pbMask = new Bool[ uiWidth*uiHeight ]; |
---|
1276 | uiMaskStride = uiWidth; |
---|
1277 | switch( getDmmType( uiLumaPredMode ) ) |
---|
1278 | { |
---|
1279 | case( DMM1_IDX ): { (getWedgeListScaled( uiWidth )->at( pcCU->getDmm1WedgeTabIdx( uiAbsPartIdx ) )).getPatternScaledCopy( uiWidth, pbMask ); } break; |
---|
1280 | case( DMM4_IDX ): { m_pcPrediction->predContourFromTex( pcCU, uiAbsPartIdx, uiWidth, uiHeight, pbMask ); } break; |
---|
1281 | default: assert(0); |
---|
1282 | } |
---|
1283 | |
---|
1284 | // get predicted partition values |
---|
1285 | Pel predDC1 = 0, predDC2 = 0; |
---|
1286 | m_pcPrediction->predBiSegDCs( pcCU, uiAbsPartIdx, uiWidth, uiHeight, pbMask, uiMaskStride, predDC1, predDC2 ); |
---|
1287 | |
---|
1288 | // set prediction signal |
---|
1289 | Pel* pDst = piPred; |
---|
1290 | m_pcPrediction->assignBiSegDCs( pDst, uiStride, pbMask, uiMaskStride, predDC1, predDC2 ); |
---|
1291 | apDCPredValues[0] = predDC1; |
---|
1292 | apDCPredValues[1] = predDC2; |
---|
1293 | } |
---|
1294 | else // regular HEVC intra modes |
---|
1295 | { |
---|
1296 | #endif |
---|
1297 | uiNumSegments = 1; |
---|
1298 | |
---|
1299 | if( ( uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) > 1 ) |
---|
1300 | { |
---|
1301 | sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize(); |
---|
1302 | } |
---|
1303 | |
---|
1304 | //===== loop over partitions ===== |
---|
1305 | TComTURecurse tuRecurseCU(pcCU, 0); |
---|
1306 | TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (sdcDepth==0)?TComTU::DONT_SPLIT:TComTU::QUAD_SPLIT); |
---|
1307 | |
---|
1308 | do |
---|
1309 | { |
---|
1310 | const TComRectangle &puRect = tuRecurseWithPU.getRect(COMPONENT_Y); |
---|
1311 | const UInt uiAbsPartIdxTU = tuRecurseWithPU.GetAbsPartIdxTU(); |
---|
1312 | |
---|
1313 | Pel* piPredTU = pcPredYuv->getAddr ( COMPONENT_Y, uiAbsPartIdxTU ); |
---|
1314 | UInt uiStrideTU = pcPredYuv->getStride( COMPONENT_Y ); |
---|
1315 | |
---|
1316 | Pel* piRecIPredTU = pcCU->getPic()->getPicYuvRec()->getAddr( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdxTU ); |
---|
1317 | UInt uiRecIPredStrideTU = pcCU->getPic()->getPicYuvRec()->getStride(COMPONENT_Y); |
---|
1318 | |
---|
1319 | const Bool bUseFilter = TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, uiLumaPredMode, puRect.width, puRect.height, chFmt, sps.getSpsRangeExtension().getIntraSmoothingDisabledFlag()); |
---|
1320 | |
---|
1321 | //===== init pattern for luma prediction ===== |
---|
1322 | |
---|
1323 | m_pcPrediction->initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, bUseFilter DEBUG_STRING_PASS_INTO(sTemp) ); |
---|
1324 | |
---|
1325 | m_pcPrediction->predIntraAng( COMPONENT_Y, uiLumaPredMode, NULL, uiStrideTU, piPredTU, uiStrideTU, tuRecurseWithPU, bUseFilter ); |
---|
1326 | |
---|
1327 | // copy for prediction of next part |
---|
1328 | for( UInt uiY = 0; uiY < puRect.height; uiY++ ) |
---|
1329 | { |
---|
1330 | for( UInt uiX = 0; uiX < puRect.width; uiX++ ) |
---|
1331 | { |
---|
1332 | piPredTU [ uiX ] = ClipBD( piPredTU[ uiX ], bitDepthY ); |
---|
1333 | piRecIPredTU [ uiX ] = piPredTU[ uiX ]; |
---|
1334 | } |
---|
1335 | piPredTU += uiStrideTU; |
---|
1336 | piRecIPredTU += uiRecIPredStrideTU; |
---|
1337 | } |
---|
1338 | |
---|
1339 | |
---|
1340 | } while (tuRecurseWithPU.nextSection(tuRecurseCU)); |
---|
1341 | |
---|
1342 | // reset to full block |
---|
1343 | uiWidth = pcCU->getWidth( 0 ); |
---|
1344 | uiHeight = pcCU->getHeight( 0 ); |
---|
1345 | |
---|
1346 | uiStride = pcRecoYuv->getStride( COMPONENT_Y ); |
---|
1347 | piReco = pcRecoYuv->getAddr ( COMPONENT_Y, uiAbsPartIdx ); |
---|
1348 | piPred = pcPredYuv->getAddr ( COMPONENT_Y, uiAbsPartIdx ); |
---|
1349 | piResi = pcResiYuv->getAddr ( COMPONENT_Y, uiAbsPartIdx ); |
---|
1350 | |
---|
1351 | piRecIPred = pcCU->getPic()->getPicYuvRec()->getAddr ( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx ); |
---|
1352 | uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride( COMPONENT_Y ); |
---|
1353 | |
---|
1354 | m_pcPrediction->predConstantSDC( piPred, uiStride, uiWidth, apDCPredValues[0] ); apDCPredValues[1] = 0; |
---|
1355 | #if NH_3D_DMM |
---|
1356 | } |
---|
1357 | #endif |
---|
1358 | |
---|
1359 | // reconstruct residual based on mask + DC residuals |
---|
1360 | Pel apDCResiValues[2]; |
---|
1361 | for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ ) |
---|
1362 | { |
---|
1363 | #if NH_3D_DLT |
---|
1364 | Pel pPredIdx = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] ); |
---|
1365 | Pel pResiIdx = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); |
---|
1366 | Pel pRecoValue = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx ); |
---|
1367 | |
---|
1368 | apDCResiValues[uiSegment] = pRecoValue - apDCPredValues[uiSegment]; |
---|
1369 | #else |
---|
1370 | apDCResiValues[uiSegment] = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); |
---|
1371 | #endif |
---|
1372 | } |
---|
1373 | |
---|
1374 | //===== reconstruction ===== |
---|
1375 | Bool*pMask = pbMask; |
---|
1376 | Pel* pPred = piPred; |
---|
1377 | Pel* pResi = piResi; |
---|
1378 | Pel* pReco = piReco; |
---|
1379 | Pel* pRecIPred = piRecIPred; |
---|
1380 | |
---|
1381 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1382 | { |
---|
1383 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1384 | { |
---|
1385 | UChar ucSegment = pMask?(UChar)pMask[uiX]:0; |
---|
1386 | assert( ucSegment < uiNumSegments ); |
---|
1387 | |
---|
1388 | Pel pResiDC = apDCResiValues[ucSegment]; |
---|
1389 | |
---|
1390 | pReco [ uiX ] = ClipBD( pPred[ uiX ] + pResiDC, bitDepthY ); |
---|
1391 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
1392 | } |
---|
1393 | pPred += uiStride; |
---|
1394 | pResi += uiStride; |
---|
1395 | pReco += uiStride; |
---|
1396 | pRecIPred += uiRecIPredStride; |
---|
1397 | pMask += uiMaskStride; |
---|
1398 | } |
---|
1399 | |
---|
1400 | // clear chroma |
---|
1401 | UInt uiStrideC = pcPredYuv->getStride( COMPONENT_Cb ); |
---|
1402 | Pel *pRecCb = pcPredYuv->getAddr ( COMPONENT_Cb, uiAbsPartIdx ); |
---|
1403 | Pel *pRecCr = pcPredYuv->getAddr ( COMPONENT_Cr, uiAbsPartIdx ); |
---|
1404 | |
---|
1405 | for (Int y=0; y<uiHeight/2; y++) |
---|
1406 | { |
---|
1407 | for (Int x=0; x<uiWidth/2; x++) |
---|
1408 | { |
---|
1409 | pRecCb[x] = 128; |
---|
1410 | pRecCr[x] = 128; |
---|
1411 | } |
---|
1412 | |
---|
1413 | pRecCb += uiStrideC; |
---|
1414 | pRecCr += uiStrideC; |
---|
1415 | } |
---|
1416 | #if NH_3D_DMM |
---|
1417 | if( pbMask ) { delete[] pbMask; } |
---|
1418 | #endif |
---|
1419 | } |
---|
1420 | #endif |
---|
1421 | |
---|
1422 | |
---|
1423 | /** Function for deriving reconstructed PU/CU chroma samples with QTree structure |
---|
1424 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
1425 | * \param pcPredYuv pointer to prediction sample arrays |
---|
1426 | * \param pcResiYuv pointer to residue sample arrays |
---|
1427 | * \param chType texture channel type (luma/chroma) |
---|
1428 | * \param rTu reference to transform data |
---|
1429 | * |
---|
1430 | \ This function derives reconstructed PU/CU chroma samples with QTree recursive structure |
---|
1431 | */ |
---|
1432 | |
---|
1433 | Void |
---|
1434 | TDecCu::xIntraRecQT(TComYuv* pcRecoYuv, |
---|
1435 | TComYuv* pcPredYuv, |
---|
1436 | TComYuv* pcResiYuv, |
---|
1437 | const ChannelType chType, |
---|
1438 | TComTU &rTu) |
---|
1439 | { |
---|
1440 | UInt uiTrDepth = rTu.GetTransformDepthRel(); |
---|
1441 | TComDataCU *pcCU = rTu.getCU(); |
---|
1442 | UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); |
---|
1443 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
1444 | if( uiTrMode == uiTrDepth ) |
---|
1445 | { |
---|
1446 | if (isLuma(chType)) |
---|
1447 | { |
---|
1448 | xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, COMPONENT_Y, rTu ); |
---|
1449 | } |
---|
1450 | else |
---|
1451 | { |
---|
1452 | const UInt numValidComp=getNumberValidComponents(rTu.GetChromaFormat()); |
---|
1453 | for(UInt compID=COMPONENT_Cb; compID<numValidComp; compID++) |
---|
1454 | { |
---|
1455 | xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, ComponentID(compID), rTu ); |
---|
1456 | } |
---|
1457 | } |
---|
1458 | } |
---|
1459 | else |
---|
1460 | { |
---|
1461 | TComTURecurse tuRecurseChild(rTu, false); |
---|
1462 | do |
---|
1463 | { |
---|
1464 | xIntraRecQT( pcRecoYuv, pcPredYuv, pcResiYuv, chType, tuRecurseChild ); |
---|
1465 | } while (tuRecurseChild.nextSection(rTu)); |
---|
1466 | } |
---|
1467 | } |
---|
1468 | |
---|
1469 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
1470 | { |
---|
1471 | UInt uiCtuRsAddr = pcCU->getCtuRsAddr(); |
---|
1472 | |
---|
1473 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCtuRsAddr, uiZorderIdx ); |
---|
1474 | |
---|
1475 | return; |
---|
1476 | } |
---|
1477 | |
---|
1478 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiDepth ) |
---|
1479 | { |
---|
1480 | |
---|
1481 | TComTURecurse tuRecur(pcCU, 0, uiDepth); |
---|
1482 | |
---|
1483 | for(UInt ch=0; ch<pcCU->getPic()->getNumberValidComponents(); ch++) |
---|
1484 | { |
---|
1485 | const ComponentID compID=ComponentID(ch); |
---|
1486 | DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[compID]) |
---|
1487 | |
---|
1488 | m_pcTrQuant->invRecurTransformNxN ( compID, m_ppcYuvResi[uiDepth], tuRecur ); |
---|
1489 | } |
---|
1490 | |
---|
1491 | DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[MAX_NUM_COMPONENT]) |
---|
1492 | } |
---|
1493 | |
---|
1494 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
---|
1495 | * \param pcCU pointer to current CU |
---|
1496 | * \param uiPartIdx part index |
---|
1497 | * \param piPCM pointer to PCM code arrays |
---|
1498 | * \param piReco pointer to reconstructed sample arrays |
---|
1499 | * \param uiStride stride of reconstructed sample arrays |
---|
1500 | * \param uiWidth CU width |
---|
1501 | * \param uiHeight CU height |
---|
1502 | * \param compID colour component ID |
---|
1503 | * \returns Void |
---|
1504 | */ |
---|
1505 | Void TDecCu::xDecodePCMTexture( TComDataCU* pcCU, const UInt uiPartIdx, const Pel *piPCM, Pel* piReco, const UInt uiStride, const UInt uiWidth, const UInt uiHeight, const ComponentID compID) |
---|
1506 | { |
---|
1507 | Pel* piPicReco = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiPartIdx); |
---|
1508 | const UInt uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(compID); |
---|
1509 | const TComSPS &sps = *(pcCU->getSlice()->getSPS()); |
---|
1510 | const UInt uiPcmLeftShiftBit = sps.getBitDepth(toChannelType(compID)) - sps.getPCMBitDepth(toChannelType(compID)); |
---|
1511 | |
---|
1512 | for(UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1513 | { |
---|
1514 | for(UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1515 | { |
---|
1516 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
---|
1517 | piPicReco[uiX] = piReco[uiX]; |
---|
1518 | } |
---|
1519 | piPCM += uiWidth; |
---|
1520 | piReco += uiStride; |
---|
1521 | piPicReco += uiPicStride; |
---|
1522 | } |
---|
1523 | } |
---|
1524 | |
---|
1525 | /** Function for reconstructing a PCM mode CU. |
---|
1526 | * \param pcCU pointer to current CU |
---|
1527 | * \param uiDepth CU Depth |
---|
1528 | * \returns Void |
---|
1529 | */ |
---|
1530 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth ) |
---|
1531 | { |
---|
1532 | const UInt maxCuWidth = pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
1533 | const UInt maxCuHeight = pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
1534 | for (UInt ch=0; ch < pcCU->getPic()->getNumberValidComponents(); ch++) |
---|
1535 | { |
---|
1536 | const ComponentID compID = ComponentID(ch); |
---|
1537 | const UInt width = (maxCuWidth >>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleX(compID))); |
---|
1538 | const UInt height = (maxCuHeight>>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleY(compID))); |
---|
1539 | const UInt stride = m_ppcYuvResi[uiDepth]->getStride(compID); |
---|
1540 | Pel * pPCMChannel = pcCU->getPCMSample(compID); |
---|
1541 | Pel * pRecChannel = m_ppcYuvReco[uiDepth]->getAddr(compID); |
---|
1542 | xDecodePCMTexture( pcCU, 0, pPCMChannel, pRecChannel, stride, width, height, compID ); |
---|
1543 | } |
---|
1544 | } |
---|
1545 | |
---|
1546 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
---|
1547 | * \param pCU pointer to current CU |
---|
1548 | * \param depth CU Depth |
---|
1549 | */ |
---|
1550 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth) |
---|
1551 | { |
---|
1552 | const ChromaFormat format = pCU->getPic()->getChromaFormat(); |
---|
1553 | const UInt numValidComp = getNumberValidComponents(format); |
---|
1554 | const UInt maxCuWidth = pCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
1555 | const UInt maxCuHeight = pCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
1556 | |
---|
1557 | for (UInt componentIndex = 0; componentIndex < numValidComp; componentIndex++) |
---|
1558 | { |
---|
1559 | const ComponentID component = ComponentID(componentIndex); |
---|
1560 | |
---|
1561 | const UInt width = maxCuWidth >> (depth + getComponentScaleX(component, format)); |
---|
1562 | const UInt height = maxCuHeight >> (depth + getComponentScaleY(component, format)); |
---|
1563 | |
---|
1564 | Pel *source = m_ppcYuvReco[depth]->getAddr(component, 0, width); |
---|
1565 | Pel *destination = pCU->getPCMSample(component); |
---|
1566 | |
---|
1567 | const UInt sourceStride = m_ppcYuvReco[depth]->getStride(component); |
---|
1568 | |
---|
1569 | for (Int line = 0; line < height; line++) |
---|
1570 | { |
---|
1571 | for (Int column = 0; column < width; column++) |
---|
1572 | { |
---|
1573 | destination[column] = source[column]; |
---|
1574 | } |
---|
1575 | |
---|
1576 | source += sourceStride; |
---|
1577 | destination += width; |
---|
1578 | } |
---|
1579 | } |
---|
1580 | } |
---|
1581 | |
---|
1582 | //! \} |
---|