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 | #if ENC_DEC_TRACE && H_MV_ENC_DEC_TRAC |
---|
534 | if ( g_traceSubPBMotion ) |
---|
535 | { |
---|
536 | std::cout << std::setfill(' ') << std::setw( 15 ) |
---|
537 | << "Num" << std::setw( 15 ) |
---|
538 | << "Dir " << std::setw( 15 ) |
---|
539 | << "L0 RefIdx" << std::setw( 15 ) |
---|
540 | << "L0 Hor" << std::setw( 15 ) |
---|
541 | << "L0 Ver" << std::setw( 15 ) |
---|
542 | << "L1 RefIdx" << std::setw( 15 ) |
---|
543 | << "L1 Hor" << std::setw( 15 ) |
---|
544 | << "L1 Ver" << std::setw( 15 ) |
---|
545 | << std::endl; |
---|
546 | |
---|
547 | for (Int iPartitionIdx = 0; iPartitionIdx < iNumSP; iPartitionIdx++) |
---|
548 | { |
---|
549 | UChar dir = puhInterDirSP[iPartitionIdx]; |
---|
550 | TComMvField& mv0 = pcMvFieldSP [2*iPartitionIdx]; |
---|
551 | TComMvField& mv1 = pcMvFieldSP [2*iPartitionIdx+1]; |
---|
552 | |
---|
553 | std::cout << std::setfill(' ') << std::setw( 15 ) |
---|
554 | << iPartitionIdx << std::setw( 15 ) |
---|
555 | << (UInt) dir << std::setw( 15 ) |
---|
556 | << ((dir & 1) ? mv0.getRefIdx() : MIN_INT) << std::setw( 15 ) |
---|
557 | << ((dir & 1) ? mv0.getMv().getHor() : MIN_INT) << std::setw( 15 ) |
---|
558 | << ((dir & 1) ? mv0.getMv().getVer() : MIN_INT) << std::setw( 15 ) |
---|
559 | << ((dir & 2) ? mv1.getRefIdx() : MIN_INT) << std::setw( 15 ) |
---|
560 | << ((dir & 2) ? mv1.getMv().getHor() : MIN_INT) << std::setw( 15 ) |
---|
561 | << ((dir & 2) ? mv1.getMv().getVer() : MIN_INT) << std::setw( 15 ) |
---|
562 | << std::endl; |
---|
563 | } |
---|
564 | } |
---|
565 | #endif |
---|
566 | } |
---|
567 | delete[] pcMvFieldSP; |
---|
568 | delete[] puhInterDirSP; |
---|
569 | #endif |
---|
570 | |
---|
571 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
---|
572 | #if NH_3D_IV_MERGE |
---|
573 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
---|
574 | #endif |
---|
575 | |
---|
576 | return; |
---|
577 | } |
---|
578 | #if NH_3D_DIS |
---|
579 | m_pcEntropyDecoder->decodeDIS( pcCU, uiAbsPartIdx, uiDepth ); |
---|
580 | if(!pcCU->getDISFlag(uiAbsPartIdx)) |
---|
581 | { |
---|
582 | #endif |
---|
583 | |
---|
584 | m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth ); |
---|
585 | m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth ); |
---|
586 | |
---|
587 | if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N ) |
---|
588 | { |
---|
589 | m_pcEntropyDecoder->decodeIPCMInfo( pcCU, uiAbsPartIdx, uiDepth ); |
---|
590 | |
---|
591 | if(pcCU->getIPCMFlag(uiAbsPartIdx)) |
---|
592 | { |
---|
593 | #if NH_3D_SDC_INTRA |
---|
594 | m_pcEntropyDecoder->decodeSDCFlag( pcCU, uiAbsPartIdx, uiDepth ); |
---|
595 | #endif |
---|
596 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
---|
597 | #if NH_3D_IV_MERGE |
---|
598 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
---|
599 | #endif |
---|
600 | return; |
---|
601 | } |
---|
602 | } |
---|
603 | |
---|
604 | // prediction mode ( Intra : direction mode, Inter : Mv, reference idx ) |
---|
605 | m_pcEntropyDecoder->decodePredInfo( pcCU, uiAbsPartIdx, uiDepth, m_ppcCU[uiDepth]); |
---|
606 | |
---|
607 | // Coefficient decoding |
---|
608 | Bool bCodeDQP = getdQPFlag(); |
---|
609 | Bool isChromaQpAdjCoded = getIsChromaQpAdjCoded(); |
---|
610 | m_pcEntropyDecoder->decodeCoeff( pcCU, uiAbsPartIdx, uiDepth, bCodeDQP, isChromaQpAdjCoded ); |
---|
611 | setIsChromaQpAdjCoded( isChromaQpAdjCoded ); |
---|
612 | setdQPFlag( bCodeDQP ); |
---|
613 | #if NH_3D_DIS |
---|
614 | } |
---|
615 | #endif |
---|
616 | xFinishDecodeCU( pcCU, uiAbsPartIdx, uiDepth, isLastCtuOfSliceSegment ); |
---|
617 | #if NH_3D_IV_MERGE |
---|
618 | xDecompressCU(pcCU, uiAbsPartIdx, uiDepth ); |
---|
619 | #endif |
---|
620 | } |
---|
621 | |
---|
622 | Void TDecCu::xFinishDecodeCU( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool &isLastCtuOfSliceSegment) |
---|
623 | { |
---|
624 | if( pcCU->getSlice()->getPPS()->getUseDQP()) |
---|
625 | { |
---|
626 | pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP |
---|
627 | } |
---|
628 | |
---|
629 | if (pcCU->getSlice()->getUseChromaQpAdj() && !getIsChromaQpAdjCoded()) |
---|
630 | { |
---|
631 | pcCU->setChromaQpAdjSubParts( pcCU->getCodedChromaQpAdj(), uiAbsPartIdx, uiDepth ); // set QP |
---|
632 | } |
---|
633 | |
---|
634 | isLastCtuOfSliceSegment = xDecodeSliceEnd( pcCU, uiAbsPartIdx ); |
---|
635 | } |
---|
636 | |
---|
637 | Void TDecCu::xDecompressCU( TComDataCU* pCtu, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
638 | { |
---|
639 | TComPic* pcPic = pCtu->getPic(); |
---|
640 | #if !NH_3D_IV_MERGE |
---|
641 | TComSlice * pcSlice = pCtu->getSlice(); |
---|
642 | const TComSPS &sps=*(pcSlice->getSPS()); |
---|
643 | |
---|
644 | Bool bBoundary = false; |
---|
645 | UInt uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
646 | UInt uiRPelX = uiLPelX + (sps.getMaxCUWidth()>>uiDepth) - 1; |
---|
647 | UInt uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; |
---|
648 | UInt uiBPelY = uiTPelY + (sps.getMaxCUHeight()>>uiDepth) - 1; |
---|
649 | |
---|
650 | if( ( uiRPelX >= sps.getPicWidthInLumaSamples() ) || ( uiBPelY >= sps.getPicHeightInLumaSamples() ) ) |
---|
651 | { |
---|
652 | bBoundary = true; |
---|
653 | } |
---|
654 | |
---|
655 | if( ( ( uiDepth < pCtu->getDepth( uiAbsPartIdx ) ) && ( uiDepth < sps.getLog2DiffMaxMinCodingBlockSize() ) ) || bBoundary ) |
---|
656 | { |
---|
657 | UInt uiNextDepth = uiDepth + 1; |
---|
658 | UInt uiQNumParts = pCtu->getTotalNumPart() >> (uiNextDepth<<1); |
---|
659 | UInt uiIdx = uiAbsPartIdx; |
---|
660 | for ( UInt uiPartIdx = 0; uiPartIdx < 4; uiPartIdx++ ) |
---|
661 | { |
---|
662 | uiLPelX = pCtu->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiIdx] ]; |
---|
663 | uiTPelY = pCtu->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ]; |
---|
664 | |
---|
665 | if( ( uiLPelX < sps.getPicWidthInLumaSamples() ) && ( uiTPelY < sps.getPicHeightInLumaSamples() ) ) |
---|
666 | { |
---|
667 | xDecompressCU(pCtu, uiIdx, uiNextDepth ); |
---|
668 | } |
---|
669 | |
---|
670 | uiIdx += uiQNumParts; |
---|
671 | } |
---|
672 | return; |
---|
673 | } |
---|
674 | #endif |
---|
675 | // Residual reconstruction |
---|
676 | m_ppcYuvResi[uiDepth]->clear(); |
---|
677 | |
---|
678 | m_ppcCU[uiDepth]->copySubCU( pCtu, uiAbsPartIdx ); |
---|
679 | |
---|
680 | switch( m_ppcCU[uiDepth]->getPredictionMode(0) ) |
---|
681 | { |
---|
682 | case MODE_INTER: |
---|
683 | #if NH_3D_DBBP |
---|
684 | if( m_ppcCU[uiDepth]->getDBBPFlag(0) ) |
---|
685 | { |
---|
686 | xReconInterDBBP( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
687 | } |
---|
688 | else |
---|
689 | { |
---|
690 | #endif |
---|
691 | #if NH_3D_SDC_INTER |
---|
692 | if( m_ppcCU[uiDepth]->getSDCFlag( 0 ) ) |
---|
693 | { |
---|
694 | xReconInterSDC( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth ); |
---|
695 | } |
---|
696 | else |
---|
697 | { |
---|
698 | #endif |
---|
699 | xReconInter( m_ppcCU[uiDepth], uiDepth ); |
---|
700 | #if NH_3D_SDC_INTER |
---|
701 | } |
---|
702 | #endif |
---|
703 | #if NH_3D_DBBP |
---|
704 | } |
---|
705 | #endif |
---|
706 | break; |
---|
707 | case MODE_INTRA: |
---|
708 | #if NH_3D |
---|
709 | #if NH_3D_DIS |
---|
710 | if( m_ppcCU[uiDepth]->getDISFlag(0) ) |
---|
711 | { |
---|
712 | xReconDIS( m_ppcCU[uiDepth], 0, uiDepth ); |
---|
713 | } |
---|
714 | #else |
---|
715 | if(false ) |
---|
716 | { |
---|
717 | // xReconDIS( m_ppcCU[uiDepth], 0, uiDepth ); |
---|
718 | } |
---|
719 | #endif |
---|
720 | #if NH_3D_SDC_INTRA |
---|
721 | else if( m_ppcCU[uiDepth]->getSDCFlag(0) ) |
---|
722 | { |
---|
723 | xReconIntraSDC( m_ppcCU[uiDepth], 0, uiDepth ); |
---|
724 | } |
---|
725 | #endif |
---|
726 | else |
---|
727 | #endif |
---|
728 | xReconIntraQT( m_ppcCU[uiDepth], uiDepth ); |
---|
729 | break; |
---|
730 | default: |
---|
731 | assert(0); |
---|
732 | break; |
---|
733 | } |
---|
734 | |
---|
735 | #if DEBUG_STRING |
---|
736 | const PredMode predMode=m_ppcCU[uiDepth]->getPredictionMode(0); |
---|
737 | if (DebugOptionList::DebugString_Structure.getInt()&DebugStringGetPredModeMask(predMode)) |
---|
738 | { |
---|
739 | PartSize eSize=m_ppcCU[uiDepth]->getPartitionSize(0); |
---|
740 | std::ostream &ss(std::cout); |
---|
741 | |
---|
742 | 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; |
---|
743 | } |
---|
744 | #endif |
---|
745 | |
---|
746 | if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false)) |
---|
747 | { |
---|
748 | xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth); |
---|
749 | } |
---|
750 | |
---|
751 | xCopyToPic( m_ppcCU[uiDepth], pcPic, uiAbsPartIdx, uiDepth ); |
---|
752 | } |
---|
753 | |
---|
754 | Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth ) |
---|
755 | { |
---|
756 | |
---|
757 | // inter prediction |
---|
758 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
759 | |
---|
760 | #if DEBUG_STRING |
---|
761 | const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTER); |
---|
762 | if (DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) |
---|
763 | { |
---|
764 | printBlockToStream(std::cout, "###inter-pred: ", *(m_ppcYuvReco[uiDepth])); |
---|
765 | } |
---|
766 | #endif |
---|
767 | |
---|
768 | // inter recon |
---|
769 | xDecodeInterTexture( pcCU, uiDepth ); |
---|
770 | |
---|
771 | #if DEBUG_STRING |
---|
772 | if (DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) |
---|
773 | { |
---|
774 | printBlockToStream(std::cout, "###inter-resi: ", *(m_ppcYuvResi[uiDepth])); |
---|
775 | } |
---|
776 | #endif |
---|
777 | |
---|
778 | // clip for only non-zero cbp case |
---|
779 | if ( pcCU->getQtRootCbf( 0) ) |
---|
780 | { |
---|
781 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() ); |
---|
782 | } |
---|
783 | else |
---|
784 | { |
---|
785 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
786 | } |
---|
787 | #if DEBUG_STRING |
---|
788 | if (DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) |
---|
789 | { |
---|
790 | printBlockToStream(std::cout, "###inter-reco: ", *(m_ppcYuvReco[uiDepth])); |
---|
791 | } |
---|
792 | #endif |
---|
793 | |
---|
794 | } |
---|
795 | |
---|
796 | #if NH_3D_DIS |
---|
797 | Void TDecCu::xReconDIS( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
798 | { |
---|
799 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
800 | UInt uiHeight = pcCU->getHeight ( 0 ); |
---|
801 | |
---|
802 | TComYuv* pcRecoYuv = m_ppcYuvReco[uiDepth]; |
---|
803 | |
---|
804 | UInt uiStride = pcRecoYuv->getStride (COMPONENT_Y); |
---|
805 | Pel* piReco = pcRecoYuv->getAddr( COMPONENT_Y, uiAbsPartIdx ); |
---|
806 | |
---|
807 | |
---|
808 | AOF( uiWidth == uiHeight ); |
---|
809 | AOF( uiAbsPartIdx == 0 ); |
---|
810 | |
---|
811 | TComTURecurse rTu(pcCU, 0); |
---|
812 | const ChromaFormat chFmt = rTu.GetChromaFormat(); |
---|
813 | |
---|
814 | DEBUG_STRING_NEW(sTemp) |
---|
815 | if ( pcCU->getDISType(uiAbsPartIdx) == 0 ) |
---|
816 | { |
---|
817 | const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, VER_IDX, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag()); |
---|
818 | m_pcPrediction->initIntraPatternChType( rTu, COMPONENT_Y, bUseFilteredPredictions DEBUG_STRING_PASS_INTO(sTemp) ); |
---|
819 | m_pcPrediction->predIntraAng( COMPONENT_Y, VER_IDX, 0 /* Decoder does not have an original image */, 0, piReco, uiStride, rTu, bUseFilteredPredictions ); |
---|
820 | } |
---|
821 | else if ( pcCU->getDISType(uiAbsPartIdx) == 1 ) |
---|
822 | { |
---|
823 | const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, HOR_IDX, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag()); |
---|
824 | m_pcPrediction->initIntraPatternChType( rTu, COMPONENT_Y, bUseFilteredPredictions DEBUG_STRING_PASS_INTO(sTemp) ); |
---|
825 | m_pcPrediction->predIntraAng( COMPONENT_Y, HOR_IDX, 0 /* Decoder does not have an original image */, 0, piReco, uiStride, rTu, bUseFilteredPredictions ); |
---|
826 | } |
---|
827 | else if ( pcCU->getDISType(uiAbsPartIdx) == 2 ) |
---|
828 | { |
---|
829 | Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 ); |
---|
830 | pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 0 ); |
---|
831 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
832 | { |
---|
833 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
834 | { |
---|
835 | piReco[ uiX ] = pSingleDepth; |
---|
836 | } |
---|
837 | piReco+= uiStride; |
---|
838 | } |
---|
839 | } |
---|
840 | else if ( pcCU->getDISType(uiAbsPartIdx) == 3 ) |
---|
841 | { |
---|
842 | Pel pSingleDepth = 1 << ( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 1 ); |
---|
843 | pcCU->getNeighDepth ( 0, 0, &pSingleDepth, 1 ); |
---|
844 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
845 | { |
---|
846 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
847 | { |
---|
848 | piReco[ uiX ] = pSingleDepth; |
---|
849 | } |
---|
850 | piReco+= uiStride; |
---|
851 | } |
---|
852 | } |
---|
853 | |
---|
854 | // clear UV |
---|
855 | UInt uiStrideC = pcRecoYuv->getStride(COMPONENT_Cb); |
---|
856 | Pel *pRecCb = pcRecoYuv->getAddr(COMPONENT_Cb); |
---|
857 | Pel *pRecCr = pcRecoYuv->getAddr(COMPONENT_Cr); |
---|
858 | |
---|
859 | for (Int y=0; y<uiHeight/2; y++) |
---|
860 | { |
---|
861 | for (Int x=0; x<uiWidth/2; x++) |
---|
862 | { |
---|
863 | pRecCb[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1); |
---|
864 | pRecCr[x] = 1<<(pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-1); |
---|
865 | } |
---|
866 | |
---|
867 | pRecCb += uiStrideC; |
---|
868 | pRecCr += uiStrideC; |
---|
869 | } |
---|
870 | } |
---|
871 | #endif |
---|
872 | #if NH_3D_SDC_INTER |
---|
873 | Void TDecCu::xReconInterSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
874 | { |
---|
875 | // inter prediction |
---|
876 | m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] ); |
---|
877 | |
---|
878 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
879 | UInt uiHeight = pcCU->getHeight( 0 ); |
---|
880 | |
---|
881 | Pel *pResi; |
---|
882 | UInt uiPelX, uiPelY; |
---|
883 | UInt uiResiStride = m_ppcYuvResi[uiDepth]->getStride( COMPONENT_Y ); |
---|
884 | Int bitDepthC = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA); |
---|
885 | |
---|
886 | pResi = m_ppcYuvResi[uiDepth]->getAddr( COMPONENT_Y ); |
---|
887 | for( uiPelY = 0; uiPelY < uiHeight; uiPelY++ ) |
---|
888 | { |
---|
889 | for( uiPelX = 0; uiPelX < uiWidth; uiPelX++ ) |
---|
890 | { |
---|
891 | pResi[ uiPelX ] = pcCU->getSDCSegmentDCOffset( 0, 0 ); |
---|
892 | } |
---|
893 | pResi += uiResiStride; |
---|
894 | } |
---|
895 | |
---|
896 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() ); |
---|
897 | |
---|
898 | // clear UV |
---|
899 | UInt uiStrideC = m_ppcYuvReco[uiDepth]->getStride( COMPONENT_Cb ); |
---|
900 | Pel *pRecCb = m_ppcYuvReco[uiDepth]->getAddr( COMPONENT_Cb ); |
---|
901 | Pel *pRecCr = m_ppcYuvReco[uiDepth]->getAddr( COMPONENT_Cr ); |
---|
902 | |
---|
903 | for (Int y = 0; y < uiHeight/2; y++) |
---|
904 | { |
---|
905 | for (Int x = 0; x < uiWidth/2; x++) |
---|
906 | { |
---|
907 | pRecCb[x] = (Pel)( 1 << ( bitDepthC - 1 ) ); |
---|
908 | pRecCr[x] = (Pel)( 1 << ( bitDepthC - 1 ) ); |
---|
909 | } |
---|
910 | |
---|
911 | pRecCb += uiStrideC; |
---|
912 | pRecCr += uiStrideC; |
---|
913 | } |
---|
914 | } |
---|
915 | #endif |
---|
916 | |
---|
917 | #if NH_3D_DBBP |
---|
918 | Void TDecCu::xReconInterDBBP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
919 | { |
---|
920 | AOF(!pcCU->getSlice()->getIsDepth()); |
---|
921 | AOF(!pcCU->getSlice()->isIntra()); |
---|
922 | PartSize ePartSize = pcCU->getPartitionSize( 0 ); |
---|
923 | |
---|
924 | Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA); |
---|
925 | |
---|
926 | // get collocated depth block |
---|
927 | UInt uiDepthStride = 0; |
---|
928 | #if H_3D_FCO |
---|
929 | Pel* pDepthPels = pcCU->getVirtualDepthBlock(pcCU->getZorderIdxInCU(), pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride); |
---|
930 | #else |
---|
931 | Pel* pDepthPels = pcCU->getVirtualDepthBlock(0, pcCU->getWidth(0), pcCU->getHeight(0), uiDepthStride); |
---|
932 | #endif |
---|
933 | AOF( pDepthPels != NULL ); |
---|
934 | AOF( uiDepthStride != 0 ); |
---|
935 | |
---|
936 | // compute mask by segmenting depth block |
---|
937 | Bool pMask[MAX_CU_SIZE*MAX_CU_SIZE]; |
---|
938 | Bool bValidMask = m_pcPrediction->getSegmentMaskFromDepth(pDepthPels, uiDepthStride, pcCU->getWidth(0), pcCU->getHeight(0), pMask, pcCU); |
---|
939 | AOF(bValidMask); |
---|
940 | |
---|
941 | DbbpTmpData* pDBBPTmpData = pcCU->getDBBPTmpData(); |
---|
942 | TComYuv* apSegPredYuv[2] = { m_ppcYuvReco[uiDepth], m_ppcYuvRecoDBBP[uiDepth] }; |
---|
943 | |
---|
944 | // first, extract the two sets of motion parameters |
---|
945 | UInt uiPUOffset = ( g_auiPUOffset[UInt( ePartSize )] << ( ( pcCU->getSlice()->getSPS()->getMaxTotalCUDepth() - uiDepth ) << 1 ) ) >> 4; |
---|
946 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
947 | { |
---|
948 | UInt uiPartAddr = uiSegment*uiPUOffset; |
---|
949 | |
---|
950 | pDBBPTmpData->auhInterDir[uiSegment] = pcCU->getInterDir(uiPartAddr); |
---|
951 | assert( pDBBPTmpData->auhInterDir[uiSegment] == 1 || pDBBPTmpData->auhInterDir[uiSegment] == 2 ); // only uni-prediction allowed |
---|
952 | |
---|
953 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
954 | { |
---|
955 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
956 | pcCU->getMvField(pcCU, uiPartAddr, eRefList, pDBBPTmpData->acMvField[uiSegment][eRefList]); |
---|
957 | } |
---|
958 | |
---|
959 | #if NH_3D |
---|
960 | AOF( pcCU->getARPW(uiPartAddr) == 0 ); |
---|
961 | AOF( pcCU->getICFlag(uiPartAddr) == false ); |
---|
962 | AOF( pcCU->getSPIVMPFlag(uiPartAddr) == false ); |
---|
963 | AOF( pcCU->getVSPFlag(uiPartAddr) == 0 ); |
---|
964 | #endif |
---|
965 | } |
---|
966 | |
---|
967 | // do motion compensation for each segment as 2Nx2N |
---|
968 | pcCU->setPartSizeSubParts( SIZE_2Nx2N, 0, uiDepth ); |
---|
969 | pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth ); |
---|
970 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
971 | { |
---|
972 | pcCU->setInterDirSubParts( pDBBPTmpData->auhInterDir[uiSegment], 0, 0, uiDepth ); |
---|
973 | |
---|
974 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
975 | { |
---|
976 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
977 | |
---|
978 | pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], SIZE_2Nx2N, 0, 0 ); |
---|
979 | } |
---|
980 | |
---|
981 | // inter prediction |
---|
982 | m_pcPrediction->motionCompensation( pcCU, apSegPredYuv[uiSegment] ); |
---|
983 | } |
---|
984 | |
---|
985 | // restore motion information in both segments again |
---|
986 | pcCU->setPartSizeSubParts( ePartSize, 0, uiDepth ); |
---|
987 | pcCU->setPredModeSubParts( MODE_INTER, 0, uiDepth ); |
---|
988 | for( UInt uiSegment = 0; uiSegment < 2; uiSegment++ ) |
---|
989 | { |
---|
990 | UInt uiPartAddr = uiSegment*uiPUOffset; |
---|
991 | |
---|
992 | pcCU->setDBBPFlagSubParts(true, uiPartAddr, uiSegment, uiDepth); |
---|
993 | pcCU->setInterDirSubParts(pDBBPTmpData->auhInterDir[uiSegment], uiPartAddr, uiSegment, uiDepth); // interprets depth relative to LCU level |
---|
994 | |
---|
995 | for ( UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++ ) |
---|
996 | { |
---|
997 | RefPicList eRefList = (RefPicList)uiRefListIdx; |
---|
998 | |
---|
999 | pcCU->getCUMvField( eRefList )->setAllMvField( pDBBPTmpData->acMvField[uiSegment][eRefList], ePartSize, uiPartAddr, 0, uiSegment ); // interprets depth relative to rpcTempCU level |
---|
1000 | } |
---|
1001 | } |
---|
1002 | |
---|
1003 | // reconstruct final prediction signal by combining both segments |
---|
1004 | m_pcPrediction->combineSegmentsWithMask(apSegPredYuv, m_ppcYuvReco[uiDepth], pMask, pcCU->getWidth(0), pcCU->getHeight(0), 0, ePartSize, bitDepthY); |
---|
1005 | |
---|
1006 | // inter recon |
---|
1007 | xDecodeInterTexture( pcCU, uiDepth ); |
---|
1008 | |
---|
1009 | // clip for only non-zero cbp case |
---|
1010 | if ( ( pcCU->getCbf( 0, COMPONENT_Y ) ) || ( pcCU->getCbf( 0, COMPONENT_Cb ) ) || ( pcCU->getCbf(0, COMPONENT_Cr ) ) ) |
---|
1011 | { |
---|
1012 | m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() ); |
---|
1013 | } |
---|
1014 | else |
---|
1015 | { |
---|
1016 | m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 )); |
---|
1017 | } |
---|
1018 | } |
---|
1019 | #endif |
---|
1020 | |
---|
1021 | |
---|
1022 | Void |
---|
1023 | TDecCu::xIntraRecBlk( TComYuv* pcRecoYuv, |
---|
1024 | TComYuv* pcPredYuv, |
---|
1025 | TComYuv* pcResiYuv, |
---|
1026 | const ComponentID compID, |
---|
1027 | TComTU &rTu) |
---|
1028 | { |
---|
1029 | if (!rTu.ProcessComponentSection(compID)) |
---|
1030 | { |
---|
1031 | return; |
---|
1032 | } |
---|
1033 | const Bool bIsLuma = isLuma(compID); |
---|
1034 | |
---|
1035 | |
---|
1036 | TComDataCU *pcCU = rTu.getCU(); |
---|
1037 | const TComSPS &sps=*(pcCU->getSlice()->getSPS()); |
---|
1038 | const UInt uiAbsPartIdx=rTu.GetAbsPartIdxTU(); |
---|
1039 | |
---|
1040 | const TComRectangle &tuRect =rTu.getRect(compID); |
---|
1041 | const UInt uiWidth = tuRect.width; |
---|
1042 | const UInt uiHeight = tuRect.height; |
---|
1043 | const UInt uiStride = pcRecoYuv->getStride (compID); |
---|
1044 | Pel* piPred = pcPredYuv->getAddr( compID, uiAbsPartIdx ); |
---|
1045 | const ChromaFormat chFmt = rTu.GetChromaFormat(); |
---|
1046 | |
---|
1047 | if (uiWidth != uiHeight) |
---|
1048 | { |
---|
1049 | //------------------------------------------------ |
---|
1050 | |
---|
1051 | //split at current level if dividing into square sub-TUs |
---|
1052 | |
---|
1053 | TComTURecurse subTURecurse(rTu, false, TComTU::VERTICAL_SPLIT, true, compID); |
---|
1054 | |
---|
1055 | //recurse further |
---|
1056 | do |
---|
1057 | { |
---|
1058 | xIntraRecBlk(pcRecoYuv, pcPredYuv, pcResiYuv, compID, subTURecurse); |
---|
1059 | } while (subTURecurse.nextSection(rTu)); |
---|
1060 | |
---|
1061 | //------------------------------------------------ |
---|
1062 | |
---|
1063 | return; |
---|
1064 | } |
---|
1065 | |
---|
1066 | const UInt uiChPredMode = pcCU->getIntraDir( toChannelType(compID), uiAbsPartIdx ); |
---|
1067 | const UInt partsPerMinCU = 1<<(2*(sps.getMaxTotalCUDepth() - sps.getLog2DiffMaxMinCodingBlockSize())); |
---|
1068 | const UInt uiChCodedMode = (uiChPredMode==DM_CHROMA_IDX && !bIsLuma) ? pcCU->getIntraDir(CHANNEL_TYPE_LUMA, getChromasCorrespondingPULumaIdx(uiAbsPartIdx, chFmt, partsPerMinCU)) : uiChPredMode; |
---|
1069 | const UInt uiChFinalMode = ((chFmt == CHROMA_422) && !bIsLuma) ? g_chroma422IntraAngleMappingTable[uiChCodedMode] : uiChCodedMode; |
---|
1070 | |
---|
1071 | //===== init availability pattern ===== |
---|
1072 | const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(compID, uiChFinalMode, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag()); |
---|
1073 | |
---|
1074 | #if DEBUG_STRING |
---|
1075 | std::ostream &ss(std::cout); |
---|
1076 | #endif |
---|
1077 | |
---|
1078 | DEBUG_STRING_NEW(sTemp) |
---|
1079 | m_pcPrediction->initIntraPatternChType( rTu, compID, bUseFilteredPredictions DEBUG_STRING_PASS_INTO(sTemp) ); |
---|
1080 | |
---|
1081 | |
---|
1082 | //===== get prediction signal ===== |
---|
1083 | #if NH_3D_DMM |
---|
1084 | if( bIsLuma && isDmmMode( uiChFinalMode ) ) |
---|
1085 | { |
---|
1086 | m_pcPrediction->predIntraLumaDmm( pcCU, uiAbsPartIdx, getDmmType( uiChFinalMode ), piPred, uiStride, uiWidth, uiHeight ); |
---|
1087 | } |
---|
1088 | else |
---|
1089 | { |
---|
1090 | #endif |
---|
1091 | m_pcPrediction->predIntraAng( compID, uiChFinalMode, 0 /* Decoder does not have an original image */, 0, piPred, uiStride, rTu, bUseFilteredPredictions ); |
---|
1092 | #if NH_3D_DMM |
---|
1093 | } |
---|
1094 | #endif |
---|
1095 | |
---|
1096 | #if DEBUG_STRING |
---|
1097 | ss << sTemp; |
---|
1098 | #endif |
---|
1099 | |
---|
1100 | //===== inverse transform ===== |
---|
1101 | Pel* piResi = pcResiYuv->getAddr( compID, uiAbsPartIdx ); |
---|
1102 | TCoeff* pcCoeff = pcCU->getCoeff(compID) + rTu.getCoefficientOffset(compID);//( uiNumCoeffInc * uiAbsPartIdx ); |
---|
1103 | |
---|
1104 | const QpParam cQP(*pcCU, compID); |
---|
1105 | |
---|
1106 | |
---|
1107 | DEBUG_STRING_NEW(sDebug); |
---|
1108 | #if DEBUG_STRING |
---|
1109 | const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTRA); |
---|
1110 | std::string *psDebug=(DebugOptionList::DebugString_InvTran.getInt()&debugPredModeMask) ? &sDebug : 0; |
---|
1111 | #endif |
---|
1112 | #if H_3D |
---|
1113 | Bool useDltFlag = (isDmmMode( uiLumaPredMode ) || uiLumaPredMode == HOR_IDX || uiLumaPredMode == VER_IDX || uiLumaPredMode == DC_IDX) && pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getPPS()->getDLT()->getUseDLTFlag(pcCU->getSlice()->getLayerIdInVps()); |
---|
1114 | |
---|
1115 | if ( pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth ) || useDltFlag ) |
---|
1116 | #else |
---|
1117 | if (pcCU->getCbf(uiAbsPartIdx, compID, rTu.GetTransformDepthRel()) != 0) |
---|
1118 | #endif |
---|
1119 | { |
---|
1120 | m_pcTrQuant->invTransformNxN( rTu, compID, piResi, uiStride, pcCoeff, cQP DEBUG_STRING_PASS_INTO(psDebug) ); |
---|
1121 | } |
---|
1122 | else |
---|
1123 | { |
---|
1124 | for (UInt y = 0; y < uiHeight; y++) |
---|
1125 | { |
---|
1126 | for (UInt x = 0; x < uiWidth; x++) |
---|
1127 | { |
---|
1128 | piResi[(y * uiStride) + x] = 0; |
---|
1129 | } |
---|
1130 | } |
---|
1131 | } |
---|
1132 | |
---|
1133 | #if DEBUG_STRING |
---|
1134 | if (psDebug) |
---|
1135 | { |
---|
1136 | ss << (*psDebug); |
---|
1137 | } |
---|
1138 | #endif |
---|
1139 | |
---|
1140 | //===== reconstruction ===== |
---|
1141 | const UInt uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride(compID); |
---|
1142 | |
---|
1143 | const Bool useCrossComponentPrediction = isChroma(compID) && (pcCU->getCrossComponentPredictionAlpha(uiAbsPartIdx, compID) != 0); |
---|
1144 | const Pel* pResiLuma = pcResiYuv->getAddr( COMPONENT_Y, uiAbsPartIdx ); |
---|
1145 | const Int strideLuma = pcResiYuv->getStride( COMPONENT_Y ); |
---|
1146 | |
---|
1147 | Pel* pPred = piPred; |
---|
1148 | Pel* pResi = piResi; |
---|
1149 | Pel* pReco = pcRecoYuv->getAddr( compID, uiAbsPartIdx ); |
---|
1150 | Pel* pRecIPred = pcCU->getPic()->getPicYuvRec()->getAddr( compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx ); |
---|
1151 | |
---|
1152 | |
---|
1153 | #if DEBUG_STRING |
---|
1154 | const Bool bDebugPred=((DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
1155 | const Bool bDebugResi=((DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
1156 | const Bool bDebugReco=((DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID)); |
---|
1157 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
1158 | { |
---|
1159 | ss << "###: " << "CompID: " << compID << " pred mode (ch/fin): " << uiChPredMode << "/" << uiChFinalMode << " absPartIdx: " << rTu.GetAbsPartIdxTU() << std::endl; |
---|
1160 | } |
---|
1161 | #endif |
---|
1162 | |
---|
1163 | const Int clipbd = sps.getBitDepth(toChannelType(compID)); |
---|
1164 | #if O0043_BEST_EFFORT_DECODING |
---|
1165 | const Int bitDepthDelta = sps.getStreamBitDepth(toChannelType(compID)) - clipbd; |
---|
1166 | #endif |
---|
1167 | |
---|
1168 | if( useCrossComponentPrediction ) |
---|
1169 | { |
---|
1170 | TComTrQuant::crossComponentPrediction( rTu, compID, pResiLuma, piResi, piResi, uiWidth, uiHeight, strideLuma, uiStride, uiStride, true ); |
---|
1171 | } |
---|
1172 | |
---|
1173 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1174 | { |
---|
1175 | #if DEBUG_STRING |
---|
1176 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
1177 | { |
---|
1178 | ss << "###: "; |
---|
1179 | } |
---|
1180 | |
---|
1181 | if (bDebugPred) |
---|
1182 | { |
---|
1183 | ss << " - pred: "; |
---|
1184 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1185 | { |
---|
1186 | ss << pPred[ uiX ] << ", "; |
---|
1187 | } |
---|
1188 | } |
---|
1189 | if (bDebugResi) |
---|
1190 | { |
---|
1191 | ss << " - resi: "; |
---|
1192 | } |
---|
1193 | #endif |
---|
1194 | |
---|
1195 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1196 | { |
---|
1197 | #if DEBUG_STRING |
---|
1198 | if (bDebugResi) |
---|
1199 | { |
---|
1200 | ss << pResi[ uiX ] << ", "; |
---|
1201 | } |
---|
1202 | #endif |
---|
1203 | #if O0043_BEST_EFFORT_DECODING |
---|
1204 | pReco [ uiX ] = ClipBD( rightShiftEvenRounding<Pel>(pPred[ uiX ] + pResi[ uiX ], bitDepthDelta), clipbd ); |
---|
1205 | #else |
---|
1206 | pReco [ uiX ] = ClipBD( pPred[ uiX ] + pResi[ uiX ], clipbd ); |
---|
1207 | #endif |
---|
1208 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
1209 | } |
---|
1210 | #if DEBUG_STRING |
---|
1211 | if (bDebugReco) |
---|
1212 | { |
---|
1213 | ss << " - reco: "; |
---|
1214 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1215 | { |
---|
1216 | ss << pReco[ uiX ] << ", "; |
---|
1217 | } |
---|
1218 | } |
---|
1219 | |
---|
1220 | if (bDebugPred || bDebugResi || bDebugReco) |
---|
1221 | { |
---|
1222 | ss << "\n"; |
---|
1223 | } |
---|
1224 | #endif |
---|
1225 | pPred += uiStride; |
---|
1226 | pResi += uiStride; |
---|
1227 | pReco += uiStride; |
---|
1228 | pRecIPred += uiRecIPredStride; |
---|
1229 | } |
---|
1230 | } |
---|
1231 | |
---|
1232 | Void |
---|
1233 | TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth ) |
---|
1234 | { |
---|
1235 | if (pcCU->getIPCMFlag(0)) |
---|
1236 | { |
---|
1237 | xReconPCM( pcCU, uiDepth ); |
---|
1238 | return; |
---|
1239 | } |
---|
1240 | const UInt numChType = pcCU->getPic()->getChromaFormat()!=CHROMA_400 ? 2 : 1; |
---|
1241 | for (UInt chType=CHANNEL_TYPE_LUMA; chType<numChType; chType++) |
---|
1242 | { |
---|
1243 | const ChannelType chanType=ChannelType(chType); |
---|
1244 | const Bool NxNPUHas4Parts = ::isChroma(chanType) ? enable4ChromaPUsInIntraNxNCU(pcCU->getPic()->getChromaFormat()) : true; |
---|
1245 | const UInt uiInitTrDepth = ( pcCU->getPartitionSize(0) != SIZE_2Nx2N && NxNPUHas4Parts ? 1 : 0 ); |
---|
1246 | |
---|
1247 | TComTURecurse tuRecurseCU(pcCU, 0); |
---|
1248 | TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (uiInitTrDepth==0)?TComTU::DONT_SPLIT : TComTU::QUAD_SPLIT); |
---|
1249 | |
---|
1250 | do |
---|
1251 | { |
---|
1252 | xIntraRecQT( m_ppcYuvReco[uiDepth], m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], chanType, tuRecurseWithPU ); |
---|
1253 | } while (tuRecurseWithPU.nextSection(tuRecurseCU)); |
---|
1254 | } |
---|
1255 | } |
---|
1256 | |
---|
1257 | #if NH_3D_SDC_INTRA |
---|
1258 | Void TDecCu::xReconIntraSDC( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1259 | { |
---|
1260 | TComYuv* pcRecoYuv = m_ppcYuvReco[uiDepth]; |
---|
1261 | TComYuv* pcPredYuv = m_ppcYuvReco[uiDepth]; |
---|
1262 | TComYuv* pcResiYuv = m_ppcYuvResi[uiDepth]; |
---|
1263 | |
---|
1264 | UInt uiWidth = pcCU->getWidth ( 0 ); |
---|
1265 | UInt uiHeight = pcCU->getHeight( 0 ); |
---|
1266 | UInt uiLumaPredMode = pcCU->getIntraDir( CHANNEL_TYPE_LUMA, uiAbsPartIdx ); |
---|
1267 | const Int bitDepthY = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA); |
---|
1268 | const TComSPS &sps = *(pcCU->getSlice()->getSPS()); |
---|
1269 | const ChromaFormat chFmt = pcCU->getPic()->getChromaFormat(); |
---|
1270 | |
---|
1271 | UInt sdcDepth = 0; |
---|
1272 | UInt uiStride; |
---|
1273 | Pel* piReco; |
---|
1274 | Pel* piPred; |
---|
1275 | Pel* piResi; |
---|
1276 | |
---|
1277 | Pel* piRecIPred; |
---|
1278 | UInt uiRecIPredStride; |
---|
1279 | |
---|
1280 | Pel apDCPredValues[2]; |
---|
1281 | UInt uiNumSegments; |
---|
1282 | |
---|
1283 | Bool* pbMask = NULL; |
---|
1284 | UInt uiMaskStride = 0; |
---|
1285 | |
---|
1286 | #if NH_3D_DMM |
---|
1287 | if( isDmmMode( uiLumaPredMode ) ) |
---|
1288 | { |
---|
1289 | assert( uiWidth == uiHeight ); |
---|
1290 | assert( uiWidth >= DMM_MIN_SIZE && uiWidth <= DMM_MAX_SIZE ); |
---|
1291 | assert( !((uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize()) > 1) ); |
---|
1292 | |
---|
1293 | uiNumSegments = 2; |
---|
1294 | |
---|
1295 | uiStride = pcRecoYuv->getStride( COMPONENT_Y ); |
---|
1296 | piReco = pcRecoYuv->getAddr ( COMPONENT_Y, uiAbsPartIdx ); |
---|
1297 | piPred = pcPredYuv->getAddr ( COMPONENT_Y, uiAbsPartIdx ); |
---|
1298 | piResi = pcResiYuv->getAddr ( COMPONENT_Y, uiAbsPartIdx ); |
---|
1299 | |
---|
1300 | piRecIPred = pcCU->getPic()->getPicYuvRec()->getAddr ( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx ); |
---|
1301 | uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride( COMPONENT_Y ); |
---|
1302 | |
---|
1303 | //===== init availability pattern ===== |
---|
1304 | TComTURecurse tuRecurseCU(pcCU, 0); |
---|
1305 | TComTURecurse tuRecurseWithPU(tuRecurseCU, false, TComTU::DONT_SPLIT); |
---|
1306 | |
---|
1307 | DEBUG_STRING_NEW(sTemp) |
---|
1308 | m_pcPrediction->initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, false DEBUG_STRING_PASS_INTO(sTemp) ); |
---|
1309 | |
---|
1310 | // get partition |
---|
1311 | pbMask = new Bool[ uiWidth*uiHeight ]; |
---|
1312 | uiMaskStride = uiWidth; |
---|
1313 | switch( getDmmType( uiLumaPredMode ) ) |
---|
1314 | { |
---|
1315 | case( DMM1_IDX ): { (getWedgeListScaled( uiWidth )->at( pcCU->getDmm1WedgeTabIdx( uiAbsPartIdx ) )).getPatternScaledCopy( uiWidth, pbMask ); } break; |
---|
1316 | case( DMM4_IDX ): { m_pcPrediction->predContourFromTex( pcCU, uiAbsPartIdx, uiWidth, uiHeight, pbMask ); } break; |
---|
1317 | default: assert(0); |
---|
1318 | } |
---|
1319 | |
---|
1320 | // get predicted partition values |
---|
1321 | Pel predDC1 = 0, predDC2 = 0; |
---|
1322 | m_pcPrediction->predBiSegDCs( pcCU, uiAbsPartIdx, uiWidth, uiHeight, pbMask, uiMaskStride, predDC1, predDC2 ); |
---|
1323 | |
---|
1324 | // set prediction signal |
---|
1325 | Pel* pDst = piPred; |
---|
1326 | m_pcPrediction->assignBiSegDCs( pDst, uiStride, pbMask, uiMaskStride, predDC1, predDC2 ); |
---|
1327 | apDCPredValues[0] = predDC1; |
---|
1328 | apDCPredValues[1] = predDC2; |
---|
1329 | } |
---|
1330 | else // regular HEVC intra modes |
---|
1331 | { |
---|
1332 | #endif |
---|
1333 | uiNumSegments = 1; |
---|
1334 | |
---|
1335 | if( ( uiWidth >> pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() ) > 1 ) |
---|
1336 | { |
---|
1337 | sdcDepth = g_aucConvertToBit[uiWidth] + 2 - pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize(); |
---|
1338 | } |
---|
1339 | |
---|
1340 | //===== loop over partitions ===== |
---|
1341 | TComTURecurse tuRecurseCU(pcCU, 0); |
---|
1342 | TComTURecurse tuRecurseWithPU(tuRecurseCU, false, (sdcDepth==0)?TComTU::DONT_SPLIT:TComTU::QUAD_SPLIT); |
---|
1343 | |
---|
1344 | do |
---|
1345 | { |
---|
1346 | const TComRectangle &puRect = tuRecurseWithPU.getRect(COMPONENT_Y); |
---|
1347 | const UInt uiAbsPartIdxTU = tuRecurseWithPU.GetAbsPartIdxTU(); |
---|
1348 | |
---|
1349 | Pel* piPredTU = pcPredYuv->getAddr ( COMPONENT_Y, uiAbsPartIdxTU ); |
---|
1350 | UInt uiStrideTU = pcPredYuv->getStride( COMPONENT_Y ); |
---|
1351 | |
---|
1352 | Pel* piRecIPredTU = pcCU->getPic()->getPicYuvRec()->getAddr( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdxTU ); |
---|
1353 | UInt uiRecIPredStrideTU = pcCU->getPic()->getPicYuvRec()->getStride(COMPONENT_Y); |
---|
1354 | |
---|
1355 | const Bool bUseFilter = TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, uiLumaPredMode, puRect.width, puRect.height, chFmt, sps.getSpsRangeExtension().getIntraSmoothingDisabledFlag()); |
---|
1356 | |
---|
1357 | //===== init pattern for luma prediction ===== |
---|
1358 | DEBUG_STRING_NEW(sTemp) |
---|
1359 | m_pcPrediction->initIntraPatternChType( tuRecurseWithPU, COMPONENT_Y, bUseFilter DEBUG_STRING_PASS_INTO(sTemp) ); |
---|
1360 | |
---|
1361 | m_pcPrediction->predIntraAng( COMPONENT_Y, uiLumaPredMode, NULL, uiStrideTU, piPredTU, uiStrideTU, tuRecurseWithPU, bUseFilter ); |
---|
1362 | |
---|
1363 | // copy for prediction of next part |
---|
1364 | for( UInt uiY = 0; uiY < puRect.height; uiY++ ) |
---|
1365 | { |
---|
1366 | for( UInt uiX = 0; uiX < puRect.width; uiX++ ) |
---|
1367 | { |
---|
1368 | piPredTU [ uiX ] = ClipBD( piPredTU[ uiX ], bitDepthY ); |
---|
1369 | piRecIPredTU [ uiX ] = piPredTU[ uiX ]; |
---|
1370 | } |
---|
1371 | piPredTU += uiStrideTU; |
---|
1372 | piRecIPredTU += uiRecIPredStrideTU; |
---|
1373 | } |
---|
1374 | |
---|
1375 | |
---|
1376 | } while (tuRecurseWithPU.nextSection(tuRecurseCU)); |
---|
1377 | |
---|
1378 | // reset to full block |
---|
1379 | uiWidth = pcCU->getWidth( 0 ); |
---|
1380 | uiHeight = pcCU->getHeight( 0 ); |
---|
1381 | |
---|
1382 | uiStride = pcRecoYuv->getStride( COMPONENT_Y ); |
---|
1383 | piReco = pcRecoYuv->getAddr ( COMPONENT_Y, uiAbsPartIdx ); |
---|
1384 | piPred = pcPredYuv->getAddr ( COMPONENT_Y, uiAbsPartIdx ); |
---|
1385 | piResi = pcResiYuv->getAddr ( COMPONENT_Y, uiAbsPartIdx ); |
---|
1386 | |
---|
1387 | piRecIPred = pcCU->getPic()->getPicYuvRec()->getAddr ( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiAbsPartIdx ); |
---|
1388 | uiRecIPredStride = pcCU->getPic()->getPicYuvRec()->getStride( COMPONENT_Y ); |
---|
1389 | |
---|
1390 | m_pcPrediction->predConstantSDC( piPred, uiStride, uiWidth, apDCPredValues[0] ); apDCPredValues[1] = 0; |
---|
1391 | #if NH_3D_DMM |
---|
1392 | } |
---|
1393 | #endif |
---|
1394 | |
---|
1395 | // reconstruct residual based on mask + DC residuals |
---|
1396 | Pel apDCResiValues[2]; |
---|
1397 | for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ ) |
---|
1398 | { |
---|
1399 | #if NH_3D_DLT |
---|
1400 | Pel pPredIdx = pcCU->getSlice()->getPPS()->getDLT()->depthValue2idx( pcCU->getSlice()->getLayerIdInVps(), apDCPredValues[uiSegment] ); |
---|
1401 | Pel pResiIdx = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); |
---|
1402 | Pel pRecoValue = pcCU->getSlice()->getPPS()->getDLT()->idx2DepthValue( pcCU->getSlice()->getLayerIdInVps(), pPredIdx + pResiIdx ); |
---|
1403 | |
---|
1404 | apDCResiValues[uiSegment] = pRecoValue - apDCPredValues[uiSegment]; |
---|
1405 | #else |
---|
1406 | apDCResiValues[uiSegment] = pcCU->getSDCSegmentDCOffset(uiSegment, uiAbsPartIdx); |
---|
1407 | #endif |
---|
1408 | } |
---|
1409 | |
---|
1410 | //===== reconstruction ===== |
---|
1411 | Bool*pMask = pbMask; |
---|
1412 | Pel* pPred = piPred; |
---|
1413 | Pel* pResi = piResi; |
---|
1414 | Pel* pReco = piReco; |
---|
1415 | Pel* pRecIPred = piRecIPred; |
---|
1416 | |
---|
1417 | for( UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1418 | { |
---|
1419 | for( UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1420 | { |
---|
1421 | UChar ucSegment = pMask?(UChar)pMask[uiX]:0; |
---|
1422 | assert( ucSegment < uiNumSegments ); |
---|
1423 | |
---|
1424 | Pel pResiDC = apDCResiValues[ucSegment]; |
---|
1425 | |
---|
1426 | pReco [ uiX ] = ClipBD( pPred[ uiX ] + pResiDC, bitDepthY ); |
---|
1427 | pRecIPred[ uiX ] = pReco[ uiX ]; |
---|
1428 | } |
---|
1429 | pPred += uiStride; |
---|
1430 | pResi += uiStride; |
---|
1431 | pReco += uiStride; |
---|
1432 | pRecIPred += uiRecIPredStride; |
---|
1433 | pMask += uiMaskStride; |
---|
1434 | } |
---|
1435 | |
---|
1436 | // clear chroma |
---|
1437 | UInt uiStrideC = pcPredYuv->getStride( COMPONENT_Cb ); |
---|
1438 | Pel *pRecCb = pcPredYuv->getAddr ( COMPONENT_Cb, uiAbsPartIdx ); |
---|
1439 | Pel *pRecCr = pcPredYuv->getAddr ( COMPONENT_Cr, uiAbsPartIdx ); |
---|
1440 | |
---|
1441 | for (Int y=0; y<uiHeight/2; y++) |
---|
1442 | { |
---|
1443 | for (Int x=0; x<uiWidth/2; x++) |
---|
1444 | { |
---|
1445 | pRecCb[x] = 128; |
---|
1446 | pRecCr[x] = 128; |
---|
1447 | } |
---|
1448 | |
---|
1449 | pRecCb += uiStrideC; |
---|
1450 | pRecCr += uiStrideC; |
---|
1451 | } |
---|
1452 | #if NH_3D_DMM |
---|
1453 | if( pbMask ) { delete[] pbMask; } |
---|
1454 | #endif |
---|
1455 | } |
---|
1456 | #endif |
---|
1457 | |
---|
1458 | |
---|
1459 | /** Function for deriving reconstructed PU/CU chroma samples with QTree structure |
---|
1460 | * \param pcRecoYuv pointer to reconstructed sample arrays |
---|
1461 | * \param pcPredYuv pointer to prediction sample arrays |
---|
1462 | * \param pcResiYuv pointer to residue sample arrays |
---|
1463 | * \param chType texture channel type (luma/chroma) |
---|
1464 | * \param rTu reference to transform data |
---|
1465 | * |
---|
1466 | \ This function derives reconstructed PU/CU chroma samples with QTree recursive structure |
---|
1467 | */ |
---|
1468 | |
---|
1469 | Void |
---|
1470 | TDecCu::xIntraRecQT(TComYuv* pcRecoYuv, |
---|
1471 | TComYuv* pcPredYuv, |
---|
1472 | TComYuv* pcResiYuv, |
---|
1473 | const ChannelType chType, |
---|
1474 | TComTU &rTu) |
---|
1475 | { |
---|
1476 | UInt uiTrDepth = rTu.GetTransformDepthRel(); |
---|
1477 | TComDataCU *pcCU = rTu.getCU(); |
---|
1478 | UInt uiAbsPartIdx = rTu.GetAbsPartIdxTU(); |
---|
1479 | UInt uiTrMode = pcCU->getTransformIdx( uiAbsPartIdx ); |
---|
1480 | if( uiTrMode == uiTrDepth ) |
---|
1481 | { |
---|
1482 | if (isLuma(chType)) |
---|
1483 | { |
---|
1484 | xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, COMPONENT_Y, rTu ); |
---|
1485 | } |
---|
1486 | else |
---|
1487 | { |
---|
1488 | const UInt numValidComp=getNumberValidComponents(rTu.GetChromaFormat()); |
---|
1489 | for(UInt compID=COMPONENT_Cb; compID<numValidComp; compID++) |
---|
1490 | { |
---|
1491 | xIntraRecBlk( pcRecoYuv, pcPredYuv, pcResiYuv, ComponentID(compID), rTu ); |
---|
1492 | } |
---|
1493 | } |
---|
1494 | } |
---|
1495 | else |
---|
1496 | { |
---|
1497 | TComTURecurse tuRecurseChild(rTu, false); |
---|
1498 | do |
---|
1499 | { |
---|
1500 | xIntraRecQT( pcRecoYuv, pcPredYuv, pcResiYuv, chType, tuRecurseChild ); |
---|
1501 | } while (tuRecurseChild.nextSection(rTu)); |
---|
1502 | } |
---|
1503 | } |
---|
1504 | |
---|
1505 | Void TDecCu::xCopyToPic( TComDataCU* pcCU, TComPic* pcPic, UInt uiZorderIdx, UInt uiDepth ) |
---|
1506 | { |
---|
1507 | UInt uiCtuRsAddr = pcCU->getCtuRsAddr(); |
---|
1508 | |
---|
1509 | m_ppcYuvReco[uiDepth]->copyToPicYuv ( pcPic->getPicYuvRec (), uiCtuRsAddr, uiZorderIdx ); |
---|
1510 | |
---|
1511 | return; |
---|
1512 | } |
---|
1513 | |
---|
1514 | Void TDecCu::xDecodeInterTexture ( TComDataCU* pcCU, UInt uiDepth ) |
---|
1515 | { |
---|
1516 | |
---|
1517 | TComTURecurse tuRecur(pcCU, 0, uiDepth); |
---|
1518 | |
---|
1519 | for(UInt ch=0; ch<pcCU->getPic()->getNumberValidComponents(); ch++) |
---|
1520 | { |
---|
1521 | const ComponentID compID=ComponentID(ch); |
---|
1522 | DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[compID]) |
---|
1523 | |
---|
1524 | m_pcTrQuant->invRecurTransformNxN ( compID, m_ppcYuvResi[uiDepth], tuRecur ); |
---|
1525 | } |
---|
1526 | |
---|
1527 | DEBUG_STRING_OUTPUT(std::cout, debug_reorder_data_inter_token[MAX_NUM_COMPONENT]) |
---|
1528 | } |
---|
1529 | |
---|
1530 | /** Function for deriving reconstructed luma/chroma samples of a PCM mode CU. |
---|
1531 | * \param pcCU pointer to current CU |
---|
1532 | * \param uiPartIdx part index |
---|
1533 | * \param piPCM pointer to PCM code arrays |
---|
1534 | * \param piReco pointer to reconstructed sample arrays |
---|
1535 | * \param uiStride stride of reconstructed sample arrays |
---|
1536 | * \param uiWidth CU width |
---|
1537 | * \param uiHeight CU height |
---|
1538 | * \param compID colour component ID |
---|
1539 | * \returns Void |
---|
1540 | */ |
---|
1541 | 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) |
---|
1542 | { |
---|
1543 | Pel* piPicReco = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiPartIdx); |
---|
1544 | const UInt uiPicStride = pcCU->getPic()->getPicYuvRec()->getStride(compID); |
---|
1545 | const TComSPS &sps = *(pcCU->getSlice()->getSPS()); |
---|
1546 | const UInt uiPcmLeftShiftBit = sps.getBitDepth(toChannelType(compID)) - sps.getPCMBitDepth(toChannelType(compID)); |
---|
1547 | |
---|
1548 | for(UInt uiY = 0; uiY < uiHeight; uiY++ ) |
---|
1549 | { |
---|
1550 | for(UInt uiX = 0; uiX < uiWidth; uiX++ ) |
---|
1551 | { |
---|
1552 | piReco[uiX] = (piPCM[uiX] << uiPcmLeftShiftBit); |
---|
1553 | piPicReco[uiX] = piReco[uiX]; |
---|
1554 | } |
---|
1555 | piPCM += uiWidth; |
---|
1556 | piReco += uiStride; |
---|
1557 | piPicReco += uiPicStride; |
---|
1558 | } |
---|
1559 | } |
---|
1560 | |
---|
1561 | /** Function for reconstructing a PCM mode CU. |
---|
1562 | * \param pcCU pointer to current CU |
---|
1563 | * \param uiDepth CU Depth |
---|
1564 | * \returns Void |
---|
1565 | */ |
---|
1566 | Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth ) |
---|
1567 | { |
---|
1568 | const UInt maxCuWidth = pcCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
1569 | const UInt maxCuHeight = pcCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
1570 | for (UInt ch=0; ch < pcCU->getPic()->getNumberValidComponents(); ch++) |
---|
1571 | { |
---|
1572 | const ComponentID compID = ComponentID(ch); |
---|
1573 | const UInt width = (maxCuWidth >>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleX(compID))); |
---|
1574 | const UInt height = (maxCuHeight>>(uiDepth+m_ppcYuvResi[uiDepth]->getComponentScaleY(compID))); |
---|
1575 | const UInt stride = m_ppcYuvResi[uiDepth]->getStride(compID); |
---|
1576 | Pel * pPCMChannel = pcCU->getPCMSample(compID); |
---|
1577 | Pel * pRecChannel = m_ppcYuvReco[uiDepth]->getAddr(compID); |
---|
1578 | xDecodePCMTexture( pcCU, 0, pPCMChannel, pRecChannel, stride, width, height, compID ); |
---|
1579 | } |
---|
1580 | } |
---|
1581 | |
---|
1582 | /** Function for filling the PCM buffer of a CU using its reconstructed sample array |
---|
1583 | * \param pCU pointer to current CU |
---|
1584 | * \param depth CU Depth |
---|
1585 | */ |
---|
1586 | Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth) |
---|
1587 | { |
---|
1588 | const ChromaFormat format = pCU->getPic()->getChromaFormat(); |
---|
1589 | const UInt numValidComp = getNumberValidComponents(format); |
---|
1590 | const UInt maxCuWidth = pCU->getSlice()->getSPS()->getMaxCUWidth(); |
---|
1591 | const UInt maxCuHeight = pCU->getSlice()->getSPS()->getMaxCUHeight(); |
---|
1592 | |
---|
1593 | for (UInt componentIndex = 0; componentIndex < numValidComp; componentIndex++) |
---|
1594 | { |
---|
1595 | const ComponentID component = ComponentID(componentIndex); |
---|
1596 | |
---|
1597 | const UInt width = maxCuWidth >> (depth + getComponentScaleX(component, format)); |
---|
1598 | const UInt height = maxCuHeight >> (depth + getComponentScaleY(component, format)); |
---|
1599 | |
---|
1600 | Pel *source = m_ppcYuvReco[depth]->getAddr(component, 0, width); |
---|
1601 | Pel *destination = pCU->getPCMSample(component); |
---|
1602 | |
---|
1603 | const UInt sourceStride = m_ppcYuvReco[depth]->getStride(component); |
---|
1604 | |
---|
1605 | for (Int line = 0; line < height; line++) |
---|
1606 | { |
---|
1607 | for (Int column = 0; column < width; column++) |
---|
1608 | { |
---|
1609 | destination[column] = source[column]; |
---|
1610 | } |
---|
1611 | |
---|
1612 | source += sourceStride; |
---|
1613 | destination += width; |
---|
1614 | } |
---|
1615 | } |
---|
1616 | } |
---|
1617 | |
---|
1618 | //! \} |
---|