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