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 NH_3D_SDC_INTER |
---|
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 NH_3D_SDC_INTER |
---|
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 NH_3D_SDC_INTER |
---|
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( COMPONENT_Y ); |
---|
850 | Int bitDepthC = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA); |
---|
851 | |
---|
852 | pResi = m_ppcYuvResi[uiDepth]->getAddr( COMPONENT_Y ); |
---|
853 | for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ ) |
---|
854 | { |
---|
855 | for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ ) |
---|
856 | { |
---|
857 | pResi[ uiPelX ] = pcCU->getSDCSegmentDCOffset( 0, 0 ); |
---|
858 | } |
---|
859 | pResi += uiResiStride; |
---|
860 | } |
---|
861 | |
---|
862 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() ); |
---|
863 | |
---|
864 | // clear UV |
---|
865 | UInt uiStrideC = m_ppcYuvReco[uiDepth]->getStride( COMPONENT_Cb ); |
---|
866 | Pel *pRecCb = m_ppcYuvReco[uiDepth]->getAddr( COMPONENT_Cb ); |
---|
867 | Pel *pRecCr = m_ppcYuvReco[uiDepth]->getAddr( COMPONENT_Cr ); |
---|
868 | |
---|
869 | for (Int y = 0; y < uiHeight/2; y++) |
---|
870 | { |
---|
871 | for (Int x = 0; x < uiWidth/2; x++) |
---|
872 | { |
---|
873 | pRecCb[x] = (Pel)( 1 << ( bitDepthC - 1 ) ); |
---|
874 | pRecCr[x] = (Pel)( 1 << ( bitDepthC - 1 ) ); |
---|
875 | } |
---|
876 | |
---|
877 | pRecCb += uiStrideC; |
---|
878 | pRecCr += uiStrideC; |
---|
879 | } |
---|
880 | } |
---|
881 | #endif |
---|
882 | |
---|
883 | #if NH_3D_DBBP |
---|
884 | Void TDecCu::xReconInterDBBP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
885 | { |
---|
886 | AOF(!pcCU->getSlice()->getIsDepth()); |
---|
887 | AOF(!pcCU->getSlice()->isIntra()); |
---|
888 | PartSize ePartSize = pcCU->getPartitionSize( 0 ); |
---|
889 | |
---|
890 | Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA); |
---|
891 | |
---|
892 | // get collocated depth block |
---|
893 | UInt uiDepthStride = 0; |
---|
894 | #if H_3D_FCO |
---|
895 | Pel* pDepthPels = pcCU->getVirtualDepthBlock(pcCU->getZorderIdxInCU(), pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride); |
---|
896 | #else |
---|
897 | Pel* pDepthPels = pcCU->getVirtualDepthBlock(0, pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride); |
---|
898 | #endif |
---|
899 | AOF( pDepthPels != NULL ); |
---|
900 | AOF( uiDepthStride != 0 ); |
---|
901 | |
---|
902 | // compute mask by segmenting depth block |
---|
903 | Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE]; |
---|
904 | Bool bValidMask = m_pcPrediction->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(0), pcCU->getHeight(0), pMask, pcCU); |
---|
905 | AOF(bValidMask); |
---|
906 | |
---|
907 | DbbpTmpData* pDBBPTmpData = pcCU->getDBBPTmpData(); |
---|
908 | TComYuv* apSegPredYuv[2] = { m_ppcYuvReco[uiDepth], m_ppcYuvRecoDBBP[uiDepth] }; |
---|
909 | |
---|
910 | // first, extract the two sets of motion parameters |
---|
911 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
912 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
913 | { |
---|
914 | UInt uiPartAddr = uiSegment*uiPUOffset; |
---|
915 | |
---|
916 | pDBBPTmpData->auhInterDir[uiSegment] = pcCU->getInterDir(uiPartAddr); |
---|
917 | assert( pDBBPTmpData->auhInterDir[uiSegment] == 1 || pDBBPTmpData->auhInterDir[uiSegment] == 2 ); // only uni-prediction allowed |
---|
918 | |
---|
919 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
920 | { |
---|
921 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
922 | pcCU->getMvField(pcCU, uiPartAddr, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]); |
---|
923 | } |
---|
924 | |
---|
925 | #if H_3D |
---|
926 | AOF( pcCU->getARPW(uiPartAddr) == 0 ); |
---|
927 | AOF( pcCU->getICFlag(uiPartAddr) == false ); |
---|
928 | AOF( pcCU->getSPIVMPFlag(uiPartAddr) == false ); |
---|
929 | AOF( pcCU->getVSPFlag(uiPartAddr) == 0 ); |
---|
930 | #endif |
---|
931 | } |
---|
932 | |
---|
933 | // do motion compensation for each segment as 2Nx2N |
---|
934 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
935 | pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth ); |
---|
936 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
937 | { |
---|
938 | pcCU->setInterDirSubParts( pDBBPTmpData->auhInterDir[uiSegment], 0, 0, uiDepth ); |
---|
939 | |
---|
940 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
941 | { |
---|
942 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
943 | |
---|
944 | pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], SIZE_2Nx2N, 0, 0 ); |
---|
945 | } |
---|
946 | |
---|
947 | // inter prediction |
---|
948 | m_pcPrediction->motionCompensation( pcCU, apSegPredYuv[uiSegment] ); |
---|
949 | } |
---|
950 | |
---|
951 | // restore motion information in both segments again |
---|
952 | pcCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); |
---|
953 | pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth ); |
---|
954 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
955 | { |
---|
956 | UInt uiPartAddr = uiSegment*uiPUOffset; |
---|
957 | |
---|
958 | pcCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uiDepth); |
---|
959 | pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uiDepth); // interprets depth relative to LCU level |
---|
960 | |
---|
961 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
962 | { |
---|
963 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
964 | |
---|
965 | pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], ePartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level |
---|
966 | } |
---|
967 | } |
---|
968 | |
---|
969 | // reconstruct final prediction signal by combining both segments |
---|
970 | m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0), 0, ePartSize, bitDepthY); |
---|
971 | |
---|
972 | // inter recon |
---|
973 | xDecodeInterTexture( pcCU, uiDepth ); |
---|
974 | |
---|
975 | // clip for only non-zero cbp case |
---|
976 | if ( ( pcCU->getCbf( 0, COMPONENT_Y ) ) || ( pcCU->getCbf( 0, COMPONENT_Cb ) ) || ( pcCU->getCbf(0, COMPONENT_Cr ) ) ) |
---|
977 | { |
---|
978 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() ); |
---|
979 | } |
---|
980 | else |
---|
981 | { |
---|
982 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
983 | } |
---|
984 | } |
---|
985 | #endif |
---|
986 | |
---|
987 | |
---|
988 | Void |
---|
989 | TDecCu::xIntraRecBlk( TComYuv* pcRecoYuv, |
---|
990 | TComYuv* pcPredYuv, |
---|
991 | TComYuv* pcResiYuv, |
---|
992 | const ComponentID compID, |
---|
993 | TComTU &rTu) |
---|
994 | { |
---|
995 | if (!rTu.ProcessComponentSection(compID)) |
---|
996 | { |
---|
997 | return; |
---|
998 | } |
---|
999 | const Bool bIsLuma = isLuma(compID); |
---|
1000 | |
---|
1001 | |
---|
1002 | TComDataCU *pcCU = rTu.getCU(); |
---|
1003 | const TComSPS &sps=*(pcCU->getSlice()->getSPS()); |
---|
1004 | const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU(); |
---|
1005 | |
---|
1006 | const TComRectangle &tuRect =rTu.getRect(compID); |
---|
1007 | const UInt uiWidth = tuRect.width; |
---|
1008 | const UInt uiHeight = tuRect.height; |
---|
1009 | const UInt uiStride = pcRecoYuv->getStride (compID); |
---|
1010 | Pel* piPred = pcPredYuv->getAddr( compID, uiAbsPartIdx ); |
---|
1011 | const ChromaFormat chFmt = rTu.GetChromaFormat(); |
---|
1012 | |
---|
1013 | if (uiWidth != uiHeight) |
---|
1014 | { |
---|
1015 | //------------------------------------------------ |
---|
1016 | |
---|
1017 | //split at current level if dividing into square sub-TUs |
---|
1018 | |
---|
1019 | TComTURecurse subTURecurse(rTu, false, TComTU::VERTICAL_SPLIT, true, compID); |
---|
1020 | |
---|
1021 | //recurse further |
---|
1022 | do |
---|
1023 | { |
---|
1024 | xIntraRecBlk(pcRecoYuv, pcPredYuv, pcResiYuv, compID, subTURecurse); |
---|
1025 | } while (subTURecurse.nextSection(rTu)); |
---|
1026 | |
---|
1027 | //------------------------------------------------ |
---|
1028 | |
---|
1029 | return; |
---|
1030 | } |
---|
1031 | |
---|
1032 | const UInt uiChPredMode = pcCU->getIntraDir( toChannelType(compID), uiAbsPartIdx ); |
---|
1033 | const UInt partsPerMinCU = 1<<(2*(sps.getMaxTotalCUDepth() - sps.getLog2DiffMaxMinCodingBlockSize())); |
---|
1034 | const UInt uiChCodedMode = (uiChPredMode==DM_CHROMA_IDX && !bIsLuma) ? pcCU->getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, chFmt, partsPerMinCU)) : uiChPredMode; |
---|
1035 | const UInt uiChFinalMode = ((chFmt == CHROMA_422) && !bIsLuma) ? g_chroma422IntraAngleMappingTable[uiChCodedMode] : uiChCodedMode; |
---|
1036 | |
---|
1037 | //===== init availability pattern ===== |
---|
1038 | const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(compID, uiChFinalMode, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag()); |
---|
1039 | |
---|
1040 | #if DEBUG_STRING |
---|
1041 | std::ostream &ss(std::cout); |
---|
1042 | #endif |
---|
1043 | |
---|
1044 | DEBUG_STRING_NEW(sTemp) |
---|
1045 | m_pcPrediction->initIntraPatternChType( rTu, compID, bUseFilteredPredictions DEBUG_STRING_PASS_INTO(sTemp) ); |
---|
1046 | |
---|
1047 | |
---|
1048 | //===== get prediction signal ===== |
---|
1049 | #if NH_3D_DMM |
---|
1050 | if( bIsLuma && isDmmMode( uiChFinalMode ) ) |
---|
1051 | { |
---|
1052 | m_pcPrediction->predIntraLumaDmm( pcCU, uiAbsPartIdx, getDmmType( uiChFinalMode ), piPred, uiStride, uiWidth, uiHeight ); |
---|
1053 | } |
---|
1054 | else |
---|
1055 | { |
---|
1056 | #endif |
---|
1057 | m_pcPrediction->predIntraAng( compID, uiChFinalMode, 0 /* Decoder does not have an original image */, 0, piPred, uiStride, rTu, bUseFilteredPredictions ); |
---|
1058 | #if NH_3D_DMM |
---|
1059 | } |
---|
1060 | #endif |
---|
1061 | |
---|
1062 | #if DEBUG_STRING |
---|
1063 | ss << sTemp; |
---|
1064 | #endif |
---|
1065 | |
---|
1066 | //===== inverse transform ===== |
---|
1067 | Pel* piResi = pcResiYuv->getAddr( compID, uiAbsPartIdx ); |
---|
1068 | TCoeff* pcCoeff = pcCU->getCoeff(compID) + rTu.getCoefficientOffset(compID);//( uiNumCoeffInc * uiAbsPartIdx ); |
---|
1069 | |
---|
1070 | const QpParam cQP(*pcCU, compID); |
---|
1071 | |
---|
1072 | |
---|
1073 | DEBUG_STRING_NEW(sDebug); |
---|
1074 | #if DEBUG_STRING |
---|
1075 | const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTRA); |
---|
1076 | std::string *psDebug=(DebugOptionList::DebugString_InvTran.getInt()&debugPredModeMask) ? &sDebug : 0; |
---|
1077 | #endif |
---|
1078 | #if H_3D |
---|
1079 | Bool useDltFlag = (isDmmMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()); |
---|
1080 | |
---|
1081 | if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) || useDltFlag ) |
---|
1082 | #else |
---|
1083 | if (pcCU->getCbf(uiAbsPartIdx, compID, rTu.GetTransformDepthRel()) != 0) |
---|
1084 | #endif |
---|
1085 | { |
---|
1086 | m_pcTrQuant->invTransformNxN( rTu, compID, piResi, uiStride, pcCoeff, cQP DEBUG_STRING_PASS_INTO(psDebug) ); |
---|
1087 | } |
---|
1088 | else |
---|
1089 | { |
---|
1090 | for (UInt y = 0; y < uiHeight; y++) |
---|
1091 | { |
---|
1092 | for (UInt x = 0; x < uiWidth; x++) |
---|
1093 | { |
---|
1094 | piResi[(y * uiStride) + x] = 0; |
---|
1095 | } |
---|
1096 | } |
---|
1097 | } |
---|
1098 | |
---|
1099 | #if DEBUG_STRING |
---|
1100 | if (psDebug) |
---|
1101 | { |
---|
1102 | ss << (*psDebug); |
---|
1103 | } |
---|
1104 | #endif |
---|
1105 | |
---|
1106 | //===== reconstruction ===== |
---|
1107 | const UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride(compID); |
---|
1108 | |
---|
1109 | const Bool useCrossComponentPrediction = isChroma(compID) && (pcCU->getCrossComponentPredictionAlpha(uiAbsPartIdx, compID) != 0); |
---|
1110 | const Pel* pResiLuma = pcResiYuv->getAddr( COMPONENT_Y, uiAbsPartIdx ); |
---|
1111 | const Int strideLuma = pcResiYuv->getStride( COMPONENT_Y ); |
---|
1112 | |
---|
1113 | Pel* pPred = piPred; |
---|
1114 | Pel* pResi = piResi; |
---|
1115 | Pel* pReco = pcRecoYuv->getAddr( compID, uiAbsPartIdx ); |
---|
1116 | Pel* pRecIPred = pcCU->getPic()->getPicYuvRec()->getAddr( compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx ); |
---|
1117 | |
---|
1118 | |
---|
1119 | #if DEBUG_STRING |
---|
1120 | const Bool bDebugPred=((DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
1121 | const Bool bDebugResi=((DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
1122 | const Bool bDebugReco=((DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
1123 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
1124 | { |
---|
1125 | ss << "###: " << "CompID: " << compID << " pred mode (ch/fin): " << uiChPredMode << "/" << uiChFinalMode << " absPartIdx: " << rTu.GetAbsPartIdxTU() << std::endl; |
---|
1126 | } |
---|
1127 | #endif |
---|
1128 | |
---|
1129 | const Int clipbd = sps.getBitDepth(toChannelType(compID)); |
---|
1130 | #if O0043_BEST_EFFORT_DECODING |
---|
1131 | const Int bitDepthDelta = sps.getStreamBitDepth(toChannelType(compID)) - clipbd; |
---|
1132 | #endif |
---|
1133 | |
---|
1134 | if( useCrossComponentPrediction ) |
---|
1135 | { |
---|
1136 | TComTrQuant::crossComponentPrediction( rTu, compID, pResiLuma, piResi, piResi, uiWidth, uiHeight, strideLuma, uiStride, uiStride, true ); |
---|
1137 | } |
---|
1138 | |
---|
1139 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1140 | { |
---|
1141 | #if DEBUG_STRING |
---|
1142 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
1143 | { |
---|
1144 | ss << "###: "; |
---|
1145 | } |
---|
1146 | |
---|
1147 | if (bDebugPred) |
---|
1148 | { |
---|
1149 | ss << " - pred: "; |
---|
1150 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1151 | { |
---|
1152 | ss << pPred[ uiX ] << ", "; |
---|
1153 | } |
---|
1154 | } |
---|
1155 | if (bDebugResi) |
---|
1156 | { |
---|
1157 | ss << " - resi: "; |
---|
1158 | } |
---|
1159 | #endif |
---|
1160 | |
---|
1161 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1162 | { |
---|
1163 | #if DEBUG_STRING |
---|
1164 | if (bDebugResi) |
---|
1165 | { |
---|
1166 | ss << pResi[ uiX ] << ", "; |
---|
1167 | } |
---|
1168 | #endif |
---|
1169 | #if O0043_BEST_EFFORT_DECODING |
---|
1170 | pReco [ uiX ] = ClipBD( rightShiftEvenRounding<Pel>(pPred[ uiX ] + pResi[ uiX ], bitDepthDelta), clipbd ); |
---|
1171 | #else |
---|
1172 | pReco [ uiX ] = ClipBD( pPred[ uiX ] + pResi[ uiX ], clipbd ); |
---|
1173 | #endif |
---|
1174 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
1175 | } |
---|
1176 | #if DEBUG_STRING |
---|
1177 | if (bDebugReco) |
---|
1178 | { |
---|
1179 | ss << " - reco: "; |
---|
1180 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1181 | { |
---|
1182 | ss << pReco[ uiX ] << ", "; |
---|
1183 | } |
---|
1184 | } |
---|
1185 | |
---|
1186 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
1187 | { |
---|
1188 | ss << "\n"; |
---|
1189 | } |
---|
1190 | #endif |
---|
1191 | pPred += uiStride; |
---|
1192 | pResi += uiStride; |
---|
1193 | pReco += uiStride; |
---|
1194 | pRecIPred += uiRecIPredStride; |
---|
1195 | } |
---|
1196 | } |
---|
1197 | |
---|
1198 | Void |
---|
1199 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth ) |
---|
1200 | { |
---|
1201 | if (pcCU->getIPCMFlag(0)) |
---|
1202 | { |
---|
1203 | xReconPCM( pcCU, uiDepth ); |
---|
1204 | return; |
---|
1205 | } |
---|
1206 | const UInt numChType = pcCU->getPic()->getChromaFormat()!=CHROMA_400 ? 2 : 1; |
---|
1207 | for (UInt chType=CHANNEL_TYPE_LUMA; chType<numChType; chType++) |
---|
1208 | { |
---|
1209 | const ChannelType chanType=ChannelType(chType); |
---|
1210 | const Bool NxNPUHas4Parts = ::isChroma(chanType) ? enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) : true; |
---|
1211 | const UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) != SIZE_2Nx2N && NxNPUHas4Parts ? 1 : 0 ); |
---|
1212 | |
---|
1213 | TComTURecurse tuRecurseCU(pcCU, 0); |
---|
1214 | TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (uiInitTrDepth==0)?TComTU::DONT_SPLIT : TComTU::QUAD_SPLIT); |
---|
1215 | |
---|
1216 | do |
---|
1217 | { |
---|
1218 | xIntraRecQT( m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], chanType, tuRecurseWithPU ); |
---|
1219 | } while (tuRecurseWithPU.nextSection(tuRecurseCU)); |
---|
1220 | } |
---|
1221 | } |
---|
1222 | |
---|
1223 | #if NH_3D_SDC_INTRA |
---|
1224 | Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1225 | { |
---|
1226 | TComYuv* pcRecoYuv = m_ppcYuvReco[uiDepth]; |
---|
1227 | TComYuv* pcPredYuv = m_ppcYuvReco[uiDepth]; |
---|
1228 | TComYuv* pcResiYuv = m_ppcYuvResi[uiDepth]; |
---|
1229 | |
---|
1230 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
1231 | UInt uiHeight = pcCU->getHeight( 0 ); |
---|
1232 | UInt uiLumaPredMode = pcCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx ); |
---|
1233 | const Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA); |
---|
1234 | const TComSPS &sps = *(pcCU->getSlice()->getSPS()); |
---|
1235 | const ChromaFormat chFmt = pcCU->getPic()->getChromaFormat(); |
---|
1236 | |
---|
1237 | UInt sdcDepth = 0; |
---|
1238 | UInt uiStride; |
---|
1239 | Pel* piReco; |
---|
1240 | Pel* piPred; |
---|
1241 | Pel* piResi; |
---|
1242 | |
---|
1243 | Pel* piRecIPred; |
---|
1244 | UInt uiRecIPredStride; |
---|
1245 | |
---|
1246 | Pel apDCPredValues[2]; |
---|
1247 | UInt uiNumSegments; |
---|
1248 | |
---|
1249 | Bool* pbMask = NULL; |
---|
1250 | UInt uiMaskStride = 0; |
---|
1251 | |
---|
1252 | #if NH_3D_DMM |
---|
1253 | if( isDmmMode( uiLumaPredMode ) ) |
---|
1254 | { |
---|
1255 | assert( uiWidth == uiHeight ); |
---|
1256 | assert( uiWidth >= DMM_MIN_SIZE && uiWidth <= DMM_MAX_SIZE ); |
---|
1257 | assert( !((uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()) > 1) ); |
---|
1258 | |
---|
1259 | uiNumSegments = 2; |
---|
1260 | |
---|
1261 | uiStride = pcRecoYuv->getStride( COMPONENT_Y ); |
---|
1262 | piReco = pcRecoYuv->getAddr ( COMPONENT_Y, uiAbsPartIdx ); |
---|
1263 | piPred = pcPredYuv->getAddr ( COMPONENT_Y, uiAbsPartIdx ); |
---|
1264 | piResi = pcResiYuv->getAddr ( COMPONENT_Y, uiAbsPartIdx ); |
---|
1265 | |
---|
1266 | piRecIPred = pcCU->getPic()->getPicYuvRec()->getAddr ( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx ); |
---|
1267 | uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride( COMPONENT_Y ); |
---|
1268 | |
---|
1269 | //===== init availability pattern ===== |
---|
1270 | TComTURecurse tuRecurseCU(pcCU, 0); |
---|
1271 | TComTURecurse tuRecurseWithPU(tuRecurseCU, false, TComTU::DONT_SPLIT); |
---|
1272 | |
---|
1273 | m_pcPrediction->initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, false DEBUG_STRING_PASS_INTO(sTemp) ); |
---|
1274 | |
---|
1275 | // get partition |
---|
1276 | pbMask = new Bool[ uiWidth*uiHeight ]; |
---|
1277 | uiMaskStride = uiWidth; |
---|
1278 | switch( getDmmType( uiLumaPredMode ) ) |
---|
1279 | { |
---|
1280 | case( DMM1_IDX ): { (getWedgeListScaled( uiWidth )->at( pcCU->getDmm1WedgeTabIdx( uiAbsPartIdx ) )).getPatternScaledCopy( uiWidth, pbMask ); } break; |
---|
1281 | case( DMM4_IDX ): { m_pcPrediction->predContourFromTex( pcCU, uiAbsPartIdx, uiWidth, uiHeight, pbMask ); } break; |
---|
1282 | default: assert(0); |
---|
1283 | } |
---|
1284 | |
---|
1285 | // get predicted partition values |
---|
1286 | Pel predDC1 = 0, predDC2 = 0; |
---|
1287 | m_pcPrediction->predBiSegDCs( pcCU, uiAbsPartIdx, uiWidth, uiHeight, pbMask, uiMaskStride, predDC1, predDC2 ); |
---|
1288 | |
---|
1289 | // set prediction signal |
---|
1290 | Pel* pDst = piPred; |
---|
1291 | m_pcPrediction->assignBiSegDCs( pDst, uiStride, pbMask, uiMaskStride, predDC1, predDC2 ); |
---|
1292 | apDCPredValues[0] = predDC1; |
---|
1293 | apDCPredValues[1] = predDC2; |
---|
1294 | } |
---|
1295 | else // regular HEVC intra modes |
---|
1296 | { |
---|
1297 | #endif |
---|
1298 | uiNumSegments = 1; |
---|
1299 | |
---|
1300 | if( ( uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) > 1 ) |
---|
1301 | { |
---|
1302 | sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize(); |
---|
1303 | } |
---|
1304 | |
---|
1305 | //===== loop over partitions ===== |
---|
1306 | TComTURecurse tuRecurseCU(pcCU, 0); |
---|
1307 | TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (sdcDepth==0)?TComTU::DONT_SPLIT:TComTU::QUAD_SPLIT); |
---|
1308 | |
---|
1309 | do |
---|
1310 | { |
---|
1311 | const TComRectangle &puRect = tuRecurseWithPU.getRect(COMPONENT_Y); |
---|
1312 | const UInt uiAbsPartIdxTU = tuRecurseWithPU.GetAbsPartIdxTU(); |
---|
1313 | |
---|
1314 | Pel* piPredTU = pcPredYuv->getAddr ( COMPONENT_Y, uiAbsPartIdxTU ); |
---|
1315 | UInt uiStrideTU = pcPredYuv->getStride( COMPONENT_Y ); |
---|
1316 | |
---|
1317 | Pel* piRecIPredTU = pcCU->getPic()->getPicYuvRec()->getAddr( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdxTU ); |
---|
1318 | UInt uiRecIPredStrideTU = pcCU->getPic()->getPicYuvRec()->getStride(COMPONENT_Y); |
---|
1319 | |
---|
1320 | const Bool bUseFilter = TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, uiLumaPredMode, puRect.width, puRect.height, chFmt, sps.getSpsRangeExtension().getIntraSmoothingDisabledFlag()); |
---|
1321 | |
---|
1322 | //===== init pattern for luma prediction ===== |
---|
1323 | |
---|
1324 | m_pcPrediction->initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, bUseFilter DEBUG_STRING_PASS_INTO(sTemp) ); |
---|
1325 | |
---|
1326 | m_pcPrediction->predIntraAng( COMPONENT_Y, uiLumaPredMode, NULL, uiStrideTU, piPredTU, uiStrideTU, tuRecurseWithPU, bUseFilter ); |
---|
1327 | |
---|
1328 | // copy for prediction of next part |
---|
1329 | for( UInt uiY = 0; uiY < puRect.height; uiY++ ) |
---|
1330 | { |
---|
1331 | for( UInt uiX = 0; uiX < puRect.width; uiX++ ) |
---|
1332 | { |
---|
1333 | piPredTU [ uiX ] = ClipBD( piPredTU[ uiX ], bitDepthY ); |
---|
1334 | piRecIPredTU [ uiX ] = piPredTU[ uiX ]; |
---|
1335 | } |
---|
1336 | piPredTU += uiStrideTU; |
---|
1337 | piRecIPredTU += uiRecIPredStrideTU; |
---|
1338 | } |
---|
1339 | |
---|
1340 | |
---|
1341 | } while (tuRecurseWithPU.nextSection(tuRecurseCU)); |
---|
1342 | |
---|
1343 | // reset to full block |
---|
1344 | uiWidth = pcCU->getWidth( 0 ); |
---|
1345 | uiHeight = pcCU->getHeight( 0 ); |
---|
1346 | |
---|
1347 | uiStride = pcRecoYuv->getStride( COMPONENT_Y ); |
---|
1348 | piReco = pcRecoYuv->getAddr ( COMPONENT_Y, uiAbsPartIdx ); |
---|
1349 | piPred = pcPredYuv->getAddr ( COMPONENT_Y, uiAbsPartIdx ); |
---|
1350 | piResi = pcResiYuv->getAddr ( COMPONENT_Y, uiAbsPartIdx ); |
---|
1351 | |
---|
1352 | piRecIPred = pcCU->getPic()->getPicYuvRec()->getAddr ( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx ); |
---|
1353 | uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride( COMPONENT_Y ); |
---|
1354 | |
---|
1355 | m_pcPrediction->predConstantSDC( piPred, uiStride, uiWidth, apDCPredValues[0] ); apDCPredValues[1] = 0; |
---|
1356 | #if NH_3D_DMM |
---|
1357 | } |
---|
1358 | #endif |
---|
1359 | |
---|
1360 | // reconstruct residual based on mask + DC residuals |
---|
1361 | Pel apDCResiValues[2]; |
---|
1362 | for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ ) |
---|
1363 | { |
---|
1364 | #if NH_3D_DLT |
---|
1365 | Pel pPredIdx = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] ); |
---|
1366 | Pel pResiIdx = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); |
---|
1367 | Pel pRecoValue = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx ); |
---|
1368 | |
---|
1369 | apDCResiValues[uiSegment] = pRecoValue - apDCPredValues[uiSegment]; |
---|
1370 | #else |
---|
1371 | apDCResiValues[uiSegment] = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); |
---|
1372 | #endif |
---|
1373 | } |
---|
1374 | |
---|
1375 | //===== reconstruction ===== |
---|
1376 | Bool*pMask = pbMask; |
---|
1377 | Pel* pPred = piPred; |
---|
1378 | Pel* pResi = piResi; |
---|
1379 | Pel* pReco = piReco; |
---|
1380 | Pel* pRecIPred = piRecIPred; |
---|
1381 | |
---|
1382 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1383 | { |
---|
1384 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1385 | { |
---|
1386 | UChar ucSegment = pMask?(UChar)pMask[uiX]:0; |
---|
1387 | assert( ucSegment < uiNumSegments ); |
---|
1388 | |
---|
1389 | Pel pResiDC = apDCResiValues[ucSegment]; |
---|
1390 | |
---|
1391 | pReco [ uiX ] = ClipBD( pPred[ uiX ] + pResiDC, bitDepthY ); |
---|
1392 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
1393 | } |
---|
1394 | pPred += uiStride; |
---|
1395 | pResi += uiStride; |
---|
1396 | pReco += uiStride; |
---|
1397 | pRecIPred += uiRecIPredStride; |
---|
1398 | pMask += uiMaskStride; |
---|
1399 | } |
---|
1400 | |
---|
1401 | // clear chroma |
---|
1402 | UInt uiStrideC = pcPredYuv->getStride( COMPONENT_Cb ); |
---|
1403 | Pel *pRecCb = pcPredYuv->getAddr ( COMPONENT_Cb, uiAbsPartIdx ); |
---|
1404 | Pel *pRecCr = pcPredYuv->getAddr ( COMPONENT_Cr, uiAbsPartIdx ); |
---|
1405 | |
---|
1406 | for (Int y=0; y<uiHeight/2; y++) |
---|
1407 | { |
---|
1408 | for (Int x=0; x<uiWidth/2; x++) |
---|
1409 | { |
---|
1410 | pRecCb[x] = 128; |
---|
1411 | pRecCr[x] = 128; |
---|
1412 | } |
---|
1413 | |
---|
1414 | pRecCb += uiStrideC; |
---|
1415 | pRecCr += uiStrideC; |
---|
1416 | } |
---|
1417 | #if NH_3D_DMM |
---|
1418 | if( pbMask ) { delete[] pbMask; } |
---|
1419 | #endif |
---|
1420 | } |
---|
1421 | #endif |
---|
1422 | |
---|
1423 | |
---|
1424 | /** Function for deriving reconstructed PU/CU chroma samples with QTree structure |
---|
1425 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
1426 | * \param pcPredYuv pointer to prediction sample arrays |
---|
1427 | * \param pcResiYuv pointer to residue sample arrays |
---|
1428 | * \param chType texture channel type (luma/chroma) |
---|
1429 | * \param rTu reference to transform data |
---|
1430 | * |
---|
1431 | \ This function derives reconstructed PU/CU chroma samples with QTree recursive structure |
---|
1432 | */ |
---|
1433 | |
---|
1434 | Void |
---|
1435 | TDecCu::xIntraRecQT(TComYuv* pcRecoYuv, |
---|
1436 | TComYuv* pcPredYuv, |
---|
1437 | TComYuv* pcResiYuv, |
---|
1438 | const ChannelType chType, |
---|
1439 | TComTU &rTu) |
---|
1440 | { |
---|
1441 | UInt uiTrDepth = rTu.GetTransformDepthRel(); |
---|
1442 | TComDataCU *pcCU = rTu.getCU(); |
---|
1443 | UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); |
---|
1444 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
1445 | if( uiTrMode == uiTrDepth ) |
---|
1446 | { |
---|
1447 | if (isLuma(chType)) |
---|
1448 | { |
---|
1449 | xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, COMPONENT_Y, rTu ); |
---|
1450 | } |
---|
1451 | else |
---|
1452 | { |
---|
1453 | const UInt numValidComp=getNumberValidComponents(rTu.GetChromaFormat()); |
---|
1454 | for(UInt compID=COMPONENT_Cb; compID<numValidComp; compID++) |
---|
1455 | { |
---|
1456 | xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, ComponentID(compID), rTu ); |
---|
1457 | } |
---|
1458 | } |
---|
1459 | } |
---|
1460 | else |
---|
1461 | { |
---|
1462 | TComTURecurse tuRecurseChild(rTu, false); |
---|
1463 | do |
---|
1464 | { |
---|
1465 | xIntraRecQT( pcRecoYuv, pcPredYuv, pcResiYuv, chType, tuRecurseChild ); |
---|
1466 | } while (tuRecurseChild.nextSection(rTu)); |
---|
1467 | } |
---|
1468 | } |
---|
1469 | |
---|
1470 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
1471 | { |
---|
1472 | UInt uiCtuRsAddr = pcCU->getCtuRsAddr(); |
---|
1473 | |
---|
1474 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCtuRsAddr, uiZorderIdx ); |
---|
1475 | |
---|
1476 | return; |
---|
1477 | } |
---|
1478 | |
---|
1479 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiDepth ) |
---|
1480 | { |
---|
1481 | |
---|
1482 | TComTURecurse tuRecur(pcCU, 0, uiDepth); |
---|
1483 | |
---|
1484 | for(UInt ch=0; ch<pcCU->getPic()->getNumberValidComponents(); ch++) |
---|
1485 | { |
---|
1486 | const ComponentID compID=ComponentID(ch); |
---|
1487 | DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[compID]) |
---|
1488 | |
---|
1489 | m_pcTrQuant->invRecurTransformNxN ( compID, m_ppcYuvResi[uiDepth], tuRecur ); |
---|
1490 | } |
---|
1491 | |
---|
1492 | DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[MAX_NUM_COMPONENT]) |
---|
1493 | } |
---|
1494 | |
---|
1495 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
---|
1496 | * \param pcCU pointer to current CU |
---|
1497 | * \param uiPartIdx part index |
---|
1498 | * \param piPCM pointer to PCM code arrays |
---|
1499 | * \param piReco pointer to reconstructed sample arrays |
---|
1500 | * \param uiStride stride of reconstructed sample arrays |
---|
1501 | * \param uiWidth CU width |
---|
1502 | * \param uiHeight CU height |
---|
1503 | * \param compID colour component ID |
---|
1504 | * \returns Void |
---|
1505 | */ |
---|
1506 | 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) |
---|
1507 | { |
---|
1508 | Pel* piPicReco = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiPartIdx); |
---|
1509 | const UInt uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(compID); |
---|
1510 | const TComSPS &sps = *(pcCU->getSlice()->getSPS()); |
---|
1511 | const UInt uiPcmLeftShiftBit = sps.getBitDepth(toChannelType(compID)) - sps.getPCMBitDepth(toChannelType(compID)); |
---|
1512 | |
---|
1513 | for(UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1514 | { |
---|
1515 | for(UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1516 | { |
---|
1517 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
---|
1518 | piPicReco[uiX] = piReco[uiX]; |
---|
1519 | } |
---|
1520 | piPCM += uiWidth; |
---|
1521 | piReco += uiStride; |
---|
1522 | piPicReco += uiPicStride; |
---|
1523 | } |
---|
1524 | } |
---|
1525 | |
---|
1526 | /** Function for reconstructing a PCM mode CU. |
---|
1527 | * \param pcCU pointer to current CU |
---|
1528 | * \param uiDepth CU Depth |
---|
1529 | * \returns Void |
---|
1530 | */ |
---|
1531 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth ) |
---|
1532 | { |
---|
1533 | const UInt maxCuWidth = pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
1534 | const UInt maxCuHeight = pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
1535 | for (UInt ch=0; ch < pcCU->getPic()->getNumberValidComponents(); ch++) |
---|
1536 | { |
---|
1537 | const ComponentID compID = ComponentID(ch); |
---|
1538 | const UInt width = (maxCuWidth >>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleX(compID))); |
---|
1539 | const UInt height = (maxCuHeight>>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleY(compID))); |
---|
1540 | const UInt stride = m_ppcYuvResi[uiDepth]->getStride(compID); |
---|
1541 | Pel * pPCMChannel = pcCU->getPCMSample(compID); |
---|
1542 | Pel * pRecChannel = m_ppcYuvReco[uiDepth]->getAddr(compID); |
---|
1543 | xDecodePCMTexture( pcCU, 0, pPCMChannel, pRecChannel, stride, width, height, compID ); |
---|
1544 | } |
---|
1545 | } |
---|
1546 | |
---|
1547 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
---|
1548 | * \param pCU pointer to current CU |
---|
1549 | * \param depth CU Depth |
---|
1550 | */ |
---|
1551 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth) |
---|
1552 | { |
---|
1553 | const ChromaFormat format = pCU->getPic()->getChromaFormat(); |
---|
1554 | const UInt numValidComp = getNumberValidComponents(format); |
---|
1555 | const UInt maxCuWidth = pCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
1556 | const UInt maxCuHeight = pCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
1557 | |
---|
1558 | for (UInt componentIndex = 0; componentIndex < numValidComp; componentIndex++) |
---|
1559 | { |
---|
1560 | const ComponentID component = ComponentID(componentIndex); |
---|
1561 | |
---|
1562 | const UInt width = maxCuWidth >> (depth + getComponentScaleX(component, format)); |
---|
1563 | const UInt height = maxCuHeight >> (depth + getComponentScaleY(component, format)); |
---|
1564 | |
---|
1565 | Pel *source = m_ppcYuvReco[depth]->getAddr(component, 0, width); |
---|
1566 | Pel *destination = pCU->getPCMSample(component); |
---|
1567 | |
---|
1568 | const UInt sourceStride = m_ppcYuvReco[depth]->getStride(component); |
---|
1569 | |
---|
1570 | for (Int line = 0; line < height; line++) |
---|
1571 | { |
---|
1572 | for (Int column = 0; column < width; column++) |
---|
1573 | { |
---|
1574 | destination[column] = source[column]; |
---|
1575 | } |
---|
1576 | |
---|
1577 | source += sourceStride; |
---|
1578 | destination += width; |
---|
1579 | } |
---|
1580 | } |
---|
1581 | } |
---|
1582 | |
---|
1583 | //! \} |
---|