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-2014, 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 TDecTop.cpp |
---|
35 | \brief decoder class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "NALread.h" |
---|
39 | #include "TDecTop.h" |
---|
40 | |
---|
41 | #if SVC_EXTENSION |
---|
42 | UInt TDecTop::m_prevPOC = MAX_UINT; |
---|
43 | UInt TDecTop::m_uiPrevLayerId = MAX_UINT; |
---|
44 | Bool TDecTop::m_bFirstSliceInSequence = true; |
---|
45 | #endif |
---|
46 | |
---|
47 | //! \ingroup TLibDecoder |
---|
48 | //! \{ |
---|
49 | |
---|
50 | TDecTop::TDecTop() |
---|
51 | { |
---|
52 | m_pcPic = 0; |
---|
53 | m_iMaxRefPicNum = 0; |
---|
54 | #if ENC_DEC_TRACE |
---|
55 | g_hTrace = fopen( "TraceDec.txt", "wb" ); |
---|
56 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
57 | g_nSymbolCounter = 0; |
---|
58 | #endif |
---|
59 | m_associatedIRAPType = NAL_UNIT_INVALID; |
---|
60 | m_pocCRA = 0; |
---|
61 | m_pocRandomAccess = MAX_INT; |
---|
62 | #if !SVC_EXTENSION |
---|
63 | m_prevPOC = MAX_INT; |
---|
64 | #endif |
---|
65 | m_bFirstSliceInPicture = true; |
---|
66 | #if !SVC_EXTENSION |
---|
67 | m_bFirstSliceInSequence = true; |
---|
68 | #endif |
---|
69 | #if SVC_EXTENSION |
---|
70 | m_layerId = 0; |
---|
71 | #if AVC_BASE |
---|
72 | m_pBLReconFile = NULL; |
---|
73 | #endif |
---|
74 | memset(m_cIlpPic, 0, sizeof(m_cIlpPic)); |
---|
75 | #endif |
---|
76 | #if AVC_SYNTAX || SYNTAX_OUTPUT |
---|
77 | m_pBLSyntaxFile = NULL; |
---|
78 | #endif |
---|
79 | m_prevSliceSkipped = false; |
---|
80 | m_skippedPOC = 0; |
---|
81 | #if SETTING_NO_OUT_PIC_PRIOR |
---|
82 | m_bFirstSliceInBitstream = true; |
---|
83 | m_lastPOCNoOutputPriorPics = -1; |
---|
84 | m_craNoRaslOutputFlag = false; |
---|
85 | m_isNoOutputPriorPics = false; |
---|
86 | #endif |
---|
87 | #if NO_CLRAS_OUTPUT_FLAG |
---|
88 | m_noClrasOutputFlag = false; |
---|
89 | m_layerInitializedFlag = false; |
---|
90 | m_firstPicInLayerDecodedFlag = false; |
---|
91 | #endif |
---|
92 | #if RESOLUTION_BASED_DPB |
---|
93 | m_subDpbIdx = -1; |
---|
94 | #endif |
---|
95 | #if Q0048_CGS_3D_ASYMLUT |
---|
96 | m_pColorMappedPic = NULL; |
---|
97 | #endif |
---|
98 | |
---|
99 | #if Q0074_SEI_COLOR_MAPPING |
---|
100 | m_ColorMapping = new TDecColorMapping(); |
---|
101 | #endif |
---|
102 | } |
---|
103 | |
---|
104 | TDecTop::~TDecTop() |
---|
105 | { |
---|
106 | #if ENC_DEC_TRACE |
---|
107 | fclose( g_hTrace ); |
---|
108 | #endif |
---|
109 | #if Q0048_CGS_3D_ASYMLUT |
---|
110 | if(m_pColorMappedPic) |
---|
111 | { |
---|
112 | m_pColorMappedPic->destroy(); |
---|
113 | delete m_pColorMappedPic; |
---|
114 | m_pColorMappedPic = NULL; |
---|
115 | } |
---|
116 | #endif |
---|
117 | #if Q0074_SEI_COLOR_MAPPING |
---|
118 | if ( m_ColorMapping ) delete m_ColorMapping; |
---|
119 | #endif |
---|
120 | } |
---|
121 | |
---|
122 | Void TDecTop::create() |
---|
123 | { |
---|
124 | #if SVC_EXTENSION |
---|
125 | m_cGopDecoder.create( m_layerId ); |
---|
126 | #else |
---|
127 | m_cGopDecoder.create(); |
---|
128 | #endif |
---|
129 | m_apcSlicePilot = new TComSlice; |
---|
130 | m_uiSliceIdx = 0; |
---|
131 | } |
---|
132 | |
---|
133 | Void TDecTop::destroy() |
---|
134 | { |
---|
135 | m_cGopDecoder.destroy(); |
---|
136 | |
---|
137 | delete m_apcSlicePilot; |
---|
138 | m_apcSlicePilot = NULL; |
---|
139 | |
---|
140 | m_cSliceDecoder.destroy(); |
---|
141 | #if SVC_EXTENSION |
---|
142 | for(Int i=0; i<MAX_NUM_REF; i++) |
---|
143 | { |
---|
144 | if(m_cIlpPic[i]) |
---|
145 | { |
---|
146 | m_cIlpPic[i]->destroy(); |
---|
147 | delete m_cIlpPic[i]; |
---|
148 | m_cIlpPic[i] = NULL; |
---|
149 | } |
---|
150 | } |
---|
151 | #endif |
---|
152 | } |
---|
153 | |
---|
154 | Void TDecTop::init() |
---|
155 | { |
---|
156 | #if !SVC_EXTENSION |
---|
157 | // initialize ROM |
---|
158 | initROM(); |
---|
159 | #endif |
---|
160 | #if SVC_EXTENSION |
---|
161 | m_cGopDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
---|
162 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder, m_cSAO.getSaoMaxOffsetQVal() ); |
---|
163 | #else |
---|
164 | m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
---|
165 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder ); |
---|
166 | #endif |
---|
167 | m_cEntropyDecoder.init(&m_cPrediction); |
---|
168 | } |
---|
169 | |
---|
170 | #if SVC_EXTENSION |
---|
171 | #if !REPN_FORMAT_IN_VPS |
---|
172 | Void TDecTop::xInitILRP(TComSPS *pcSPS) |
---|
173 | #else |
---|
174 | Void TDecTop::xInitILRP(TComSlice *slice) |
---|
175 | #endif |
---|
176 | { |
---|
177 | #if REPN_FORMAT_IN_VPS |
---|
178 | TComSPS* pcSPS = slice->getSPS(); |
---|
179 | Int bitDepthY = slice->getBitDepthY(); |
---|
180 | Int bitDepthC = slice->getBitDepthC(); |
---|
181 | Int picWidth = slice->getPicWidthInLumaSamples(); |
---|
182 | Int picHeight = slice->getPicHeightInLumaSamples(); |
---|
183 | #endif |
---|
184 | if(m_layerId>0) |
---|
185 | { |
---|
186 | #if REPN_FORMAT_IN_VPS |
---|
187 | g_bitDepthY = bitDepthY; |
---|
188 | g_bitDepthC = bitDepthC; |
---|
189 | #else |
---|
190 | g_bitDepthY = pcSPS->getBitDepthY(); |
---|
191 | g_bitDepthC = pcSPS->getBitDepthC(); |
---|
192 | #endif |
---|
193 | g_uiMaxCUWidth = pcSPS->getMaxCUWidth(); |
---|
194 | g_uiMaxCUHeight = pcSPS->getMaxCUHeight(); |
---|
195 | g_uiMaxCUDepth = pcSPS->getMaxCUDepth(); |
---|
196 | g_uiAddCUDepth = max (0, pcSPS->getLog2MinCodingBlockSize() - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
197 | |
---|
198 | Int numReorderPics[MAX_TLAYER]; |
---|
199 | Window &conformanceWindow = pcSPS->getConformanceWindow(); |
---|
200 | Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
201 | |
---|
202 | for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) |
---|
203 | { |
---|
204 | #if USE_DPB_SIZE_TABLE |
---|
205 | if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 ) |
---|
206 | { |
---|
207 | assert( this->getLayerId() == 0 ); |
---|
208 | numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer); |
---|
209 | } |
---|
210 | else |
---|
211 | { |
---|
212 | TComVPS *vps = slice->getVPS(); |
---|
213 | // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures. |
---|
214 | numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer); |
---|
215 | } |
---|
216 | #else |
---|
217 | numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer); |
---|
218 | #endif |
---|
219 | } |
---|
220 | |
---|
221 | if (m_cIlpPic[0] == NULL) |
---|
222 | { |
---|
223 | for (Int j=0; j < m_numDirectRefLayers; j++) |
---|
224 | { |
---|
225 | |
---|
226 | m_cIlpPic[j] = new TComPic; |
---|
227 | #if AUXILIARY_PICTURES |
---|
228 | #if REPN_FORMAT_IN_VPS |
---|
229 | #if SVC_UPSAMPLING |
---|
230 | m_cIlpPic[j]->create(picWidth, picHeight, slice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); |
---|
231 | #else |
---|
232 | m_cIlpPic[j]->create(picWidth, picHeight, slice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
233 | #endif |
---|
234 | #else |
---|
235 | #if SVC_UPSAMPLING |
---|
236 | m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), pcSPS->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); |
---|
237 | #else |
---|
238 | m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), pcSPS->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
239 | #endif |
---|
240 | #endif |
---|
241 | #else |
---|
242 | #if REPN_FORMAT_IN_VPS |
---|
243 | #if SVC_UPSAMPLING |
---|
244 | m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); |
---|
245 | #else |
---|
246 | m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
247 | #endif |
---|
248 | #else |
---|
249 | #if SVC_UPSAMPLING |
---|
250 | m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true); |
---|
251 | #else |
---|
252 | m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
253 | #endif |
---|
254 | #endif |
---|
255 | #endif |
---|
256 | for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++) |
---|
257 | { |
---|
258 | m_cIlpPic[j]->getPicSym()->getCU(i)->initCU(m_cIlpPic[j], i); |
---|
259 | } |
---|
260 | } |
---|
261 | } |
---|
262 | } |
---|
263 | } |
---|
264 | #endif |
---|
265 | |
---|
266 | Void TDecTop::deletePicBuffer ( ) |
---|
267 | { |
---|
268 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
269 | Int iSize = Int( m_cListPic.size() ); |
---|
270 | |
---|
271 | for (Int i = 0; i < iSize; i++ ) |
---|
272 | { |
---|
273 | TComPic* pcPic = *(iterPic++); |
---|
274 | #if SVC_EXTENSION |
---|
275 | if( pcPic ) |
---|
276 | { |
---|
277 | pcPic->destroy(); |
---|
278 | |
---|
279 | delete pcPic; |
---|
280 | pcPic = NULL; |
---|
281 | } |
---|
282 | #else |
---|
283 | pcPic->destroy(); |
---|
284 | |
---|
285 | delete pcPic; |
---|
286 | pcPic = NULL; |
---|
287 | #endif |
---|
288 | } |
---|
289 | |
---|
290 | m_cSAO.destroy(); |
---|
291 | |
---|
292 | m_cLoopFilter. destroy(); |
---|
293 | |
---|
294 | #if !SVC_EXTENSION |
---|
295 | // destroy ROM |
---|
296 | destroyROM(); |
---|
297 | #endif |
---|
298 | } |
---|
299 | |
---|
300 | Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic ) |
---|
301 | { |
---|
302 | Int numReorderPics[MAX_TLAYER]; |
---|
303 | Window &conformanceWindow = pcSlice->getSPS()->getConformanceWindow(); |
---|
304 | Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window(); |
---|
305 | |
---|
306 | for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++) |
---|
307 | { |
---|
308 | #if USE_DPB_SIZE_TABLE |
---|
309 | if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 ) |
---|
310 | { |
---|
311 | assert( this->getLayerId() == 0 ); |
---|
312 | numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer); |
---|
313 | } |
---|
314 | else |
---|
315 | { |
---|
316 | TComVPS *vps = pcSlice->getVPS(); |
---|
317 | // SHM decoders will use DPB size table in the VPS to determine the number of reorder pictures. |
---|
318 | numReorderPics[temporalLayer] = vps->getMaxVpsNumReorderPics( getCommonDecoderParams()->getTargetOutputLayerSetIdx() , temporalLayer); |
---|
319 | } |
---|
320 | #else |
---|
321 | numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer); |
---|
322 | #endif |
---|
323 | } |
---|
324 | |
---|
325 | #if USE_DPB_SIZE_TABLE |
---|
326 | if( getCommonDecoderParams()->getTargetOutputLayerSetIdx() == 0 ) |
---|
327 | { |
---|
328 | assert( this->getLayerId() == 0 ); |
---|
329 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer()); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
330 | } |
---|
331 | else |
---|
332 | { |
---|
333 | #if RESOLUTION_BASED_DPB |
---|
334 | Int layerSetIdxForOutputLayerSet = pcSlice->getVPS()->getOutputLayerSetIdx( getCommonDecoderParams()->getTargetOutputLayerSetIdx() ); |
---|
335 | Int layerIdx = pcSlice->getVPS()->findLayerIdxInLayerSet( layerSetIdxForOutputLayerSet, pcSlice->getLayerId() ); assert( layerIdx != -1 ); |
---|
336 | m_iMaxRefPicNum = pcSlice->getVPS()->getMaxVpsLayerDecPicBuffMinus1( getCommonDecoderParams()->getTargetOutputLayerSetIdx(), layerIdx, pcSlice->getTLayer() ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
337 | #else |
---|
338 | m_iMaxRefPicNum = pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1( getCommonDecoderParams()->getTargetOutputLayerSetIdx(), pcSlice->getLayerId(), pcSlice->getTLayer() ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
339 | #endif |
---|
340 | } |
---|
341 | #else |
---|
342 | m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer()); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
343 | #endif |
---|
344 | |
---|
345 | #if SVC_EXTENSION |
---|
346 | m_iMaxRefPicNum += 1; // it should be updated if more than 1 resampling picture is used |
---|
347 | #endif |
---|
348 | |
---|
349 | if (m_cListPic.size() < (UInt)m_iMaxRefPicNum) |
---|
350 | { |
---|
351 | rpcPic = new TComPic(); |
---|
352 | |
---|
353 | #if SVC_EXTENSION //Temporal solution, should be modified |
---|
354 | if(m_layerId > 0) |
---|
355 | { |
---|
356 | for(UInt i = 0; i < pcSlice->getVPS()->getNumDirectRefLayers( m_layerId ); i++ ) |
---|
357 | { |
---|
358 | #if O0098_SCALED_REF_LAYER_ID |
---|
359 | const Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, i)); |
---|
360 | #else |
---|
361 | const Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(i); |
---|
362 | #endif |
---|
363 | Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); |
---|
364 | |
---|
365 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
366 | TDecTop *pcTDecTopBase = (TDecTop *)getRefLayerDec( i ); |
---|
367 | #else |
---|
368 | TDecTop *pcTDecTopBase = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
369 | #endif |
---|
370 | //TComPic* pcPic = *(pcTDecTopBase->getListPic()->begin()); |
---|
371 | TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec(); |
---|
372 | #if REPN_FORMAT_IN_VPS |
---|
373 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
374 | UInt refLayerId = pcSlice->getVPS()->getRefLayerId(m_layerId, i); |
---|
375 | Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] ); |
---|
376 | |
---|
377 | if( pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !zeroOffsets || !sameBitDepths |
---|
378 | #if Q0048_CGS_3D_ASYMLUT |
---|
379 | || pcSlice->getPPS()->getCGSFlag() > 0 |
---|
380 | #endif |
---|
381 | #if LAYER_CTB |
---|
382 | || pcTDecTopBase->getActiveSPS()->getMaxCUWidth() != m_ppcTDecTop[m_layerId]->getActiveSPS()->getMaxCUWidth() || pcTDecTopBase->getActiveSPS()->getMaxCUHeight() != m_ppcTDecTop[m_layerId]->getActiveSPS()->getMaxCUHeight() || pcTDecTopBase->getActiveSPS()->getMaxCUDepth() != m_ppcTDecTop[m_layerId]->getActiveSPS()->getMaxCUDepth() |
---|
383 | #endif |
---|
384 | ) |
---|
385 | #else |
---|
386 | if(pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !zeroOffsets ) |
---|
387 | #endif |
---|
388 | #else |
---|
389 | if(pcPicYuvRecBase->getWidth() != pcSlice->getSPS()->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getSPS()->getPicHeightInLumaSamples() || !zeroOffsets ) |
---|
390 | #endif |
---|
391 | { |
---|
392 | rpcPic->setSpatialEnhLayerFlag( i, true ); |
---|
393 | |
---|
394 | //only for scalable extension |
---|
395 | #if SCALABILITY_MASK_E0104 |
---|
396 | assert( pcSlice->getVPS()->getScalabilityMask(2) == true ); |
---|
397 | #else |
---|
398 | assert( pcSlice->getVPS()->getScalabilityMask(1) == true ); |
---|
399 | #endif |
---|
400 | } |
---|
401 | } |
---|
402 | } |
---|
403 | #endif |
---|
404 | |
---|
405 | #if AUXILIARY_PICTURES |
---|
406 | #if REPN_FORMAT_IN_VPS |
---|
407 | #if SVC_UPSAMPLING |
---|
408 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
409 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
410 | #else |
---|
411 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
412 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
413 | #endif |
---|
414 | #else |
---|
415 | #if SVC_UPSAMPLING |
---|
416 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
417 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
418 | #else |
---|
419 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
420 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
421 | #endif |
---|
422 | #endif |
---|
423 | #else |
---|
424 | #if REPN_FORMAT_IN_VPS |
---|
425 | #if SVC_UPSAMPLING |
---|
426 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
427 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
428 | #else |
---|
429 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
430 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
431 | #endif |
---|
432 | #else |
---|
433 | #if SVC_UPSAMPLING |
---|
434 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
435 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
436 | #else |
---|
437 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
438 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
439 | #endif |
---|
440 | #endif |
---|
441 | #endif |
---|
442 | m_cListPic.pushBack( rpcPic ); |
---|
443 | |
---|
444 | return; |
---|
445 | } |
---|
446 | |
---|
447 | Bool bBufferIsAvailable = false; |
---|
448 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
449 | while (iterPic != m_cListPic.end()) |
---|
450 | { |
---|
451 | rpcPic = *(iterPic++); |
---|
452 | if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false) |
---|
453 | { |
---|
454 | rpcPic->setOutputMark(false); |
---|
455 | bBufferIsAvailable = true; |
---|
456 | break; |
---|
457 | } |
---|
458 | |
---|
459 | if ( rpcPic->getSlice( 0 )->isReferenced() == false && rpcPic->getOutputMark() == false) |
---|
460 | { |
---|
461 | #if !SVC_EXTENSION |
---|
462 | rpcPic->setOutputMark(false); |
---|
463 | #endif |
---|
464 | rpcPic->setReconMark( false ); |
---|
465 | rpcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
466 | bBufferIsAvailable = true; |
---|
467 | break; |
---|
468 | } |
---|
469 | } |
---|
470 | |
---|
471 | if ( !bBufferIsAvailable ) |
---|
472 | { |
---|
473 | //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer. |
---|
474 | m_iMaxRefPicNum++; |
---|
475 | rpcPic = new TComPic(); |
---|
476 | m_cListPic.pushBack( rpcPic ); |
---|
477 | } |
---|
478 | rpcPic->destroy(); |
---|
479 | |
---|
480 | #if AUXILIARY_PICTURES |
---|
481 | #if REPN_FORMAT_IN_VPS |
---|
482 | #if SVC_UPSAMPLING |
---|
483 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
484 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
485 | |
---|
486 | #else |
---|
487 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), pcSlice->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
488 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
489 | #endif |
---|
490 | #else |
---|
491 | #if SVC_UPSAMPLING |
---|
492 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
493 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
494 | |
---|
495 | #else |
---|
496 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), pcSlice->getSPS()->getChromaFormatIdc(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
497 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
498 | #endif |
---|
499 | #endif |
---|
500 | #else |
---|
501 | #if REPN_FORMAT_IN_VPS |
---|
502 | #if SVC_UPSAMPLING |
---|
503 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
504 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
505 | |
---|
506 | #else |
---|
507 | rpcPic->create ( pcSlice->getPicWidthInLumaSamples(), pcSlice->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
508 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
509 | #endif |
---|
510 | #else |
---|
511 | #if SVC_UPSAMPLING |
---|
512 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
513 | conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true); |
---|
514 | |
---|
515 | #else |
---|
516 | rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, |
---|
517 | conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
518 | #endif |
---|
519 | #endif |
---|
520 | #endif |
---|
521 | } |
---|
522 | |
---|
523 | Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic) |
---|
524 | { |
---|
525 | if (!m_pcPic) |
---|
526 | { |
---|
527 | /* nothing to deblock */ |
---|
528 | return; |
---|
529 | } |
---|
530 | |
---|
531 | TComPic*& pcPic = m_pcPic; |
---|
532 | |
---|
533 | // Execute Deblock + Cleanup |
---|
534 | m_cGopDecoder.filterPicture(pcPic); |
---|
535 | |
---|
536 | #if SYNTAX_OUTPUT |
---|
537 | pcPic->wrireBLSyntax( getBLSyntaxFile(), SYNTAX_BYTES ); |
---|
538 | #endif |
---|
539 | TComSlice::sortPicList( m_cListPic ); // sorting for application output |
---|
540 | poc = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); |
---|
541 | rpcListPic = &m_cListPic; |
---|
542 | m_cCuDecoder.destroy(); |
---|
543 | m_bFirstSliceInPicture = true; |
---|
544 | |
---|
545 | return; |
---|
546 | } |
---|
547 | |
---|
548 | #if SETTING_NO_OUT_PIC_PRIOR |
---|
549 | Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>*& rpcListPic) |
---|
550 | { |
---|
551 | if (!rpcListPic || !m_isNoOutputPriorPics) return; |
---|
552 | |
---|
553 | TComList<TComPic*>::iterator iterPic = rpcListPic->begin(); |
---|
554 | |
---|
555 | while (iterPic != rpcListPic->end()) |
---|
556 | { |
---|
557 | TComPic*& pcPicTmp = *(iterPic++); |
---|
558 | if (m_lastPOCNoOutputPriorPics != pcPicTmp->getPOC()) |
---|
559 | { |
---|
560 | pcPicTmp->setOutputMark(false); |
---|
561 | } |
---|
562 | } |
---|
563 | } |
---|
564 | #endif |
---|
565 | |
---|
566 | #if EARLY_REF_PIC_MARKING |
---|
567 | Void TDecTop::earlyPicMarking(Int maxTemporalLayer, std::vector<Int>& targetDecLayerIdSet) |
---|
568 | { |
---|
569 | UInt currTid = m_pcPic->getTLayer(); |
---|
570 | UInt highestTid = (maxTemporalLayer >= 0) ? maxTemporalLayer : (m_pcPic->getSlice(0)->getSPS()->getMaxTLayers() - 1); |
---|
571 | UInt latestDecLayerId = m_layerId; |
---|
572 | UInt numTargetDecLayers = 0; |
---|
573 | Int targetDecLayerIdList[MAX_LAYERS]; |
---|
574 | UInt latestDecIdx = 0; |
---|
575 | TComSlice* pcSlice = m_pcPic->getSlice(0); |
---|
576 | |
---|
577 | if ( currTid != highestTid ) // Marking process is only applicaple for highest decoded TLayer |
---|
578 | { |
---|
579 | return; |
---|
580 | } |
---|
581 | |
---|
582 | // currPic must be marked as "used for reference" and must be a sub-layer non-reference picture |
---|
583 | if ( !((pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
584 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
585 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
586 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
587 | pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
588 | pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N10 || |
---|
589 | pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N12 || |
---|
590 | pcSlice->getNalUnitType() == NAL_UNIT_RESERVED_VCL_N14) && pcSlice->isReferenced())) |
---|
591 | { |
---|
592 | return; |
---|
593 | } |
---|
594 | |
---|
595 | if ( targetDecLayerIdSet.size() == 0 ) // Cannot mark if we don't know the number of scalable layers |
---|
596 | { |
---|
597 | return; |
---|
598 | } |
---|
599 | |
---|
600 | for (std::vector<Int>::iterator it = targetDecLayerIdSet.begin(); it != targetDecLayerIdSet.end(); it++) |
---|
601 | { |
---|
602 | if ( latestDecLayerId == (*it) ) |
---|
603 | { |
---|
604 | latestDecIdx = numTargetDecLayers; |
---|
605 | } |
---|
606 | targetDecLayerIdList[numTargetDecLayers++] = (*it); |
---|
607 | } |
---|
608 | |
---|
609 | Int remainingInterLayerReferencesFlag = 0; |
---|
610 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
611 | for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ ) |
---|
612 | { |
---|
613 | Int jLidx = pcSlice->getVPS()->getLayerIdInVps(targetDecLayerIdList[j]); |
---|
614 | if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId,jLidx) - 1 ) |
---|
615 | { |
---|
616 | #else |
---|
617 | if ( currTid <= pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(latestDecLayerId) - 1 ) |
---|
618 | { |
---|
619 | for ( Int j = latestDecIdx + 1; j < numTargetDecLayers; j++ ) |
---|
620 | { |
---|
621 | #endif |
---|
622 | for ( Int k = 0; k < m_ppcTDecTop[targetDecLayerIdList[j]]->getNumDirectRefLayers(); k++ ) |
---|
623 | { |
---|
624 | if ( latestDecIdx == m_ppcTDecTop[targetDecLayerIdList[j]]->getRefLayerId(k) ) |
---|
625 | { |
---|
626 | remainingInterLayerReferencesFlag = 1; |
---|
627 | } |
---|
628 | } |
---|
629 | } |
---|
630 | } |
---|
631 | |
---|
632 | if ( remainingInterLayerReferencesFlag == 0 ) |
---|
633 | { |
---|
634 | pcSlice->setReferenced(false); |
---|
635 | } |
---|
636 | } |
---|
637 | #endif |
---|
638 | |
---|
639 | Void TDecTop::xCreateLostPicture(Int iLostPoc) |
---|
640 | { |
---|
641 | printf("\ninserting lost poc : %d\n",iLostPoc); |
---|
642 | TComSlice cFillSlice; |
---|
643 | cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
644 | cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
645 | #if SVC_EXTENSION |
---|
646 | cFillSlice.setVPS( m_parameterSetManagerDecoder.getFirstVPS() ); |
---|
647 | cFillSlice.initSlice( m_layerId ); |
---|
648 | #else |
---|
649 | cFillSlice.initSlice(); |
---|
650 | #endif |
---|
651 | TComPic *cFillPic; |
---|
652 | xGetNewPicBuffer(&cFillSlice,cFillPic); |
---|
653 | cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() ); |
---|
654 | cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() ); |
---|
655 | #if SVC_EXTENSION |
---|
656 | cFillPic->getSlice(0)->setVPS( m_parameterSetManagerDecoder.getFirstVPS() ); |
---|
657 | cFillPic->getSlice(0)->initSlice( m_layerId ); |
---|
658 | #else |
---|
659 | cFillPic->getSlice(0)->initSlice(); |
---|
660 | #endif |
---|
661 | |
---|
662 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
663 | Int closestPoc = 1000000; |
---|
664 | while ( iterPic != m_cListPic.end()) |
---|
665 | { |
---|
666 | TComPic * rpcPic = *(iterPic++); |
---|
667 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)<closestPoc&&abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)!=0&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
---|
668 | { |
---|
669 | closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc); |
---|
670 | } |
---|
671 | } |
---|
672 | iterPic = m_cListPic.begin(); |
---|
673 | while ( iterPic != m_cListPic.end()) |
---|
674 | { |
---|
675 | TComPic *rpcPic = *(iterPic++); |
---|
676 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
---|
677 | { |
---|
678 | printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC()); |
---|
679 | rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec()); |
---|
680 | break; |
---|
681 | } |
---|
682 | } |
---|
683 | cFillPic->setCurrSliceIdx(0); |
---|
684 | for(Int i=0; i<cFillPic->getNumCUsInFrame(); i++) |
---|
685 | { |
---|
686 | cFillPic->getCU(i)->initCU(cFillPic,i); |
---|
687 | } |
---|
688 | cFillPic->getSlice(0)->setReferenced(true); |
---|
689 | cFillPic->getSlice(0)->setPOC(iLostPoc); |
---|
690 | cFillPic->setReconMark(true); |
---|
691 | cFillPic->setOutputMark(true); |
---|
692 | if(m_pocRandomAccess == MAX_INT) |
---|
693 | { |
---|
694 | m_pocRandomAccess = iLostPoc; |
---|
695 | } |
---|
696 | } |
---|
697 | |
---|
698 | |
---|
699 | Void TDecTop::xActivateParameterSets() |
---|
700 | { |
---|
701 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
702 | |
---|
703 | TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId()); |
---|
704 | assert (pps != 0); |
---|
705 | |
---|
706 | TComSPS *sps = m_parameterSetManagerDecoder.getSPS(pps->getSPSId()); |
---|
707 | assert (sps != 0); |
---|
708 | |
---|
709 | if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP())) |
---|
710 | { |
---|
711 | printf ("Parameter set activation failed!"); |
---|
712 | assert (0); |
---|
713 | } |
---|
714 | |
---|
715 | #if SCALINGLIST_INFERRING |
---|
716 | // scaling list settings and checks |
---|
717 | TComVPS *activeVPS = m_parameterSetManagerDecoder.getActiveVPS(); |
---|
718 | TComSPS *activeSPS = m_parameterSetManagerDecoder.getActiveSPS(); |
---|
719 | TComPPS *activePPS = m_parameterSetManagerDecoder.getActivePPS(); |
---|
720 | |
---|
721 | if( activeSPS->getInferScalingListFlag() ) |
---|
722 | { |
---|
723 | UInt refLayerId = activeSPS->getScalingListRefLayerId(); |
---|
724 | TComSPS *refSps = m_ppcTDecTop[refLayerId]->getParameterSetManager()->getActiveSPS(); assert( refSps != NULL ); |
---|
725 | |
---|
726 | // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0 |
---|
727 | if( activeVPS->getAvcBaseLayerFlag() ) |
---|
728 | { |
---|
729 | assert( refLayerId > 0 ); |
---|
730 | } |
---|
731 | |
---|
732 | // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and |
---|
733 | // sps_infer_scaling_list_flag in the SPS is equal to 1, sps_infer_scaling_list_flag shall be equal to 0 for the SPS that is active for the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id |
---|
734 | assert( refSps->getInferScalingListFlag() == false ); |
---|
735 | |
---|
736 | // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB, |
---|
737 | // the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB |
---|
738 | assert( activeVPS->getRecursiveRefLayerFlag( activeSPS->getLayerId(), refLayerId ) == true ); |
---|
739 | |
---|
740 | if( activeSPS->getScalingList() != refSps->getScalingList() ) |
---|
741 | { |
---|
742 | // delete created instance of scaling list since it will be inferred |
---|
743 | delete activeSPS->getScalingList(); |
---|
744 | |
---|
745 | // infer scaling list |
---|
746 | activeSPS->setScalingList( refSps->getScalingList() ); |
---|
747 | } |
---|
748 | } |
---|
749 | |
---|
750 | if( activePPS->getInferScalingListFlag() ) |
---|
751 | { |
---|
752 | UInt refLayerId = activePPS->getScalingListRefLayerId(); |
---|
753 | TComPPS *refPps = m_ppcTDecTop[refLayerId]->getParameterSetManager()->getActivePPS(); assert( refPps != NULL ); |
---|
754 | |
---|
755 | // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0 |
---|
756 | if( activeVPS->getAvcBaseLayerFlag() ) |
---|
757 | { |
---|
758 | assert( refLayerId > 0 ); |
---|
759 | } |
---|
760 | |
---|
761 | // It is a requirement of bitstream conformance that, when an PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and |
---|
762 | // pps_infer_scaling_list_flag in the PPS is equal to 1, pps_infer_scaling_list_flag shall be equal to 0 for the PPS that is active for the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id |
---|
763 | assert( refPps->getInferScalingListFlag() == false ); |
---|
764 | |
---|
765 | // It is a requirement of bitstream conformance that, when an PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB, |
---|
766 | // the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB |
---|
767 | assert( activeVPS->getRecursiveRefLayerFlag( activePPS->getLayerId(), refLayerId ) == true ); |
---|
768 | |
---|
769 | if( activePPS->getScalingList() != refPps->getScalingList() ) |
---|
770 | { |
---|
771 | // delete created instance of scaling list since it will be inferred |
---|
772 | delete activePPS->getScalingList(); |
---|
773 | |
---|
774 | // infer scaling list |
---|
775 | activePPS->setScalingList( refPps->getScalingList() ); |
---|
776 | } |
---|
777 | |
---|
778 | } |
---|
779 | #endif |
---|
780 | |
---|
781 | #if AVC_BASE |
---|
782 | if( activeVPS->getAvcBaseLayerFlag() ) |
---|
783 | { |
---|
784 | TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); |
---|
785 | if( m_layerId == 1 && pBLPic->getPicYuvRec() == NULL ) |
---|
786 | { |
---|
787 | UInt refLayerId = 0; |
---|
788 | RepFormat* repFormat = activeVPS->getVpsRepFormat( activeVPS->getVpsRepFormatIdx(refLayerId) ); |
---|
789 | |
---|
790 | Int numReorderPics[MAX_TLAYER]; |
---|
791 | Window conformanceWindow; |
---|
792 | Window defaultDisplayWindow; |
---|
793 | |
---|
794 | #if AUXILIARY_PICTURES |
---|
795 | #if SVC_UPSAMPLING |
---|
796 | #if AVC_SYNTAX |
---|
797 | pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, activeSPS, true); |
---|
798 | #else |
---|
799 | pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true); |
---|
800 | #endif |
---|
801 | #else |
---|
802 | pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
803 | #endif |
---|
804 | #else |
---|
805 | #if SVC_UPSAMPLING |
---|
806 | #if AVC_SYNTAX |
---|
807 | pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, activeSPS, true); |
---|
808 | #else |
---|
809 | pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true); |
---|
810 | #endif |
---|
811 | #else |
---|
812 | pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), onformanceWindow, defaultDisplayWindow, numReorderPics, true); |
---|
813 | #endif |
---|
814 | #endif |
---|
815 | // it is needed where the VPS is accessed through the slice |
---|
816 | pBLPic->getSlice(0)->setVPS( activeVPS ); |
---|
817 | |
---|
818 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
819 | g_bitDepthYLayer[0] = repFormat->getBitDepthVpsLuma(); |
---|
820 | g_bitDepthCLayer[0] = repFormat->getBitDepthVpsChroma(); |
---|
821 | #endif |
---|
822 | } |
---|
823 | } |
---|
824 | #endif |
---|
825 | |
---|
826 | #if P0312_VERT_PHASE_ADJ |
---|
827 | if( activeVPS->getVpsVuiVertPhaseInUseFlag() == 0 ) |
---|
828 | { |
---|
829 | for(Int i = 0; i < activeSPS->getNumScaledRefLayerOffsets(); i++) |
---|
830 | { |
---|
831 | UInt scaledRefLayerId = activeSPS->getScaledRefLayerId(i); |
---|
832 | if( activeSPS->getVertPhasePositionEnableFlag( scaledRefLayerId ) ) |
---|
833 | { |
---|
834 | printf("\nWarning: LayerId = %d: vert_phase_position_enable_flag[%d] = 1, however indication vert_phase_position_in_use_flag = 0\n", m_layerId, scaledRefLayerId ); |
---|
835 | break; |
---|
836 | } |
---|
837 | } |
---|
838 | } |
---|
839 | #endif |
---|
840 | |
---|
841 | #if SPS_DPB_PARAMS |
---|
842 | if( m_layerId > 0 ) |
---|
843 | { |
---|
844 | // When not present sps_max_sub_layers_minus1 is inferred to be equal to vps_max_sub_layers_minus1. |
---|
845 | sps->setMaxTLayers( activeVPS->getMaxTLayers() ); |
---|
846 | |
---|
847 | // When not present sps_temporal_id_nesting_flag is inferred to be equal to vps_temporal_id_nesting_flag |
---|
848 | sps->setTemporalIdNestingFlag( activeVPS->getTemporalNestingFlag() ); |
---|
849 | |
---|
850 | // When sps_max_dec_pic_buffering_minus1[ i ] is not present for i in the range of 0 to sps_max_sub_layers_minus1, inclusive, due to nuh_layer_id being greater than 0, |
---|
851 | // it is inferred to be equal to max_vps_dec_pic_buffering_minus1[ TargetOptLayerSetIdx ][ currLayerId ][ i ] of the active VPS, where currLayerId is the nuh_layer_id of the layer that refers to the SPS. |
---|
852 | for(UInt i=0; i < sps->getMaxTLayers(); i++) |
---|
853 | { |
---|
854 | // to avoid compiler warning "array subscript is above array bounds" |
---|
855 | assert( i < MAX_TLAYER ); |
---|
856 | |
---|
857 | sps->setMaxDecPicBuffering( activeVPS->getMaxVpsDecPicBufferingMinus1( getCommonDecoderParams()->getTargetOutputLayerSetIdx(), sps->getLayerId(), i) + 1, i); |
---|
858 | } |
---|
859 | } |
---|
860 | #endif |
---|
861 | |
---|
862 | if( pps->getDependentSliceSegmentsEnabledFlag() ) |
---|
863 | { |
---|
864 | Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1; |
---|
865 | |
---|
866 | if (m_cSliceDecoder.getCtxMemSize() != NumCtx) |
---|
867 | { |
---|
868 | m_cSliceDecoder.initCtxMem(NumCtx); |
---|
869 | for ( UInt st = 0; st < NumCtx; st++ ) |
---|
870 | { |
---|
871 | TDecSbac* ctx = NULL; |
---|
872 | ctx = new TDecSbac; |
---|
873 | ctx->init( &m_cBinCABAC ); |
---|
874 | m_cSliceDecoder.setCtxMem( ctx, st ); |
---|
875 | } |
---|
876 | } |
---|
877 | } |
---|
878 | |
---|
879 | m_apcSlicePilot->setPPS(pps); |
---|
880 | m_apcSlicePilot->setSPS(sps); |
---|
881 | pps->setSPS(sps); |
---|
882 | #if REPN_FORMAT_IN_VPS |
---|
883 | pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1); |
---|
884 | #else |
---|
885 | pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1); |
---|
886 | #endif |
---|
887 | pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) ); |
---|
888 | |
---|
889 | #if REPN_FORMAT_IN_VPS |
---|
890 | g_bitDepthY = m_apcSlicePilot->getBitDepthY(); |
---|
891 | g_bitDepthC = m_apcSlicePilot->getBitDepthC(); |
---|
892 | #else |
---|
893 | g_bitDepthY = sps->getBitDepthY(); |
---|
894 | g_bitDepthC = sps->getBitDepthC(); |
---|
895 | #endif |
---|
896 | g_uiMaxCUWidth = sps->getMaxCUWidth(); |
---|
897 | g_uiMaxCUHeight = sps->getMaxCUHeight(); |
---|
898 | g_uiMaxCUDepth = sps->getMaxCUDepth(); |
---|
899 | g_uiAddCUDepth = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() ); |
---|
900 | |
---|
901 | #if Q0074_SEI_COLOR_MAPPING |
---|
902 | for(Int compID=0; compID<3; compID++) |
---|
903 | { |
---|
904 | m_ColorMapping->setColorMapping( compID ? g_bitDepthC : g_bitDepthY, compID ); |
---|
905 | } |
---|
906 | #endif |
---|
907 | |
---|
908 | for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++) |
---|
909 | { |
---|
910 | sps->setAMPAcc( i, sps->getUseAMP() ); |
---|
911 | } |
---|
912 | |
---|
913 | for (Int i = sps->getLog2DiffMaxMinCodingBlockSize(); i < sps->getMaxCUDepth(); i++) |
---|
914 | { |
---|
915 | sps->setAMPAcc( i, 0 ); |
---|
916 | } |
---|
917 | |
---|
918 | m_cSAO.destroy(); |
---|
919 | #if REPN_FORMAT_IN_VPS |
---|
920 | #if AUXILIARY_PICTURES |
---|
921 | m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); |
---|
922 | #else |
---|
923 | m_cSAO.create( m_apcSlicePilot->getPicWidthInLumaSamples(), m_apcSlicePilot->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); |
---|
924 | #endif |
---|
925 | #else |
---|
926 | m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCUDepth() ); |
---|
927 | #endif |
---|
928 | m_cLoopFilter.create( sps->getMaxCUDepth() ); |
---|
929 | } |
---|
930 | |
---|
931 | #if SVC_EXTENSION |
---|
932 | #if POC_RESET_FLAG |
---|
933 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int &iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC ) |
---|
934 | #else |
---|
935 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC ) |
---|
936 | #endif |
---|
937 | #else |
---|
938 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay ) |
---|
939 | #endif |
---|
940 | { |
---|
941 | TComPic*& pcPic = m_pcPic; |
---|
942 | #if SVC_EXTENSION |
---|
943 | m_apcSlicePilot->setVPS( m_parameterSetManagerDecoder.getPrefetchedVPS(0) ); |
---|
944 | #if OUTPUT_LAYER_SET_INDEX |
---|
945 | // Following check should go wherever the VPS is activated |
---|
946 | checkValueOfTargetOutputLayerSetIdx( m_apcSlicePilot->getVPS()); |
---|
947 | #endif |
---|
948 | #if RESOLUTION_BASED_DPB |
---|
949 | // Following assignment should go wherever a new VPS is activated |
---|
950 | assignSubDpbs(m_apcSlicePilot->getVPS()); |
---|
951 | #endif |
---|
952 | m_apcSlicePilot->initSlice( nalu.m_layerId ); |
---|
953 | #else //SVC_EXTENSION |
---|
954 | m_apcSlicePilot->initSlice(); |
---|
955 | #endif |
---|
956 | |
---|
957 | if (m_bFirstSliceInPicture) |
---|
958 | { |
---|
959 | m_uiSliceIdx = 0; |
---|
960 | } |
---|
961 | else |
---|
962 | { |
---|
963 | m_apcSlicePilot->copySliceInfo( pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); |
---|
964 | } |
---|
965 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
---|
966 | |
---|
967 | m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); |
---|
968 | Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
969 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
970 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
971 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
972 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N); |
---|
973 | m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag); |
---|
974 | |
---|
975 | m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS |
---|
976 | m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); |
---|
977 | |
---|
978 | #if SVC_EXTENSION |
---|
979 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
980 | setRefLayerParams(m_apcSlicePilot->getVPS()); |
---|
981 | #endif |
---|
982 | m_apcSlicePilot->setNumMotionPredRefLayers(m_numMotionPredRefLayers); |
---|
983 | #endif |
---|
984 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder); |
---|
985 | |
---|
986 | // set POC for dependent slices in skipped pictures |
---|
987 | if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) |
---|
988 | { |
---|
989 | m_apcSlicePilot->setPOC(m_skippedPOC); |
---|
990 | } |
---|
991 | |
---|
992 | m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA); |
---|
993 | m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType); |
---|
994 | |
---|
995 | #if SETTING_NO_OUT_PIC_PRIOR |
---|
996 | //For inference of NoOutputOfPriorPicsFlag |
---|
997 | if (m_apcSlicePilot->getRapPicFlag()) |
---|
998 | { |
---|
999 | if ((m_apcSlicePilot->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_apcSlicePilot->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP) || |
---|
1000 | (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_bFirstSliceInSequence) || |
---|
1001 | (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getHandleCraAsBlaFlag())) |
---|
1002 | { |
---|
1003 | m_apcSlicePilot->setNoRaslOutputFlag(true); |
---|
1004 | } |
---|
1005 | //the inference for NoOutputPriorPicsFlag |
---|
1006 | if (!m_bFirstSliceInBitstream && m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag()) |
---|
1007 | { |
---|
1008 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
1009 | { |
---|
1010 | m_apcSlicePilot->setNoOutputPriorPicsFlag(true); |
---|
1011 | } |
---|
1012 | } |
---|
1013 | else |
---|
1014 | { |
---|
1015 | m_apcSlicePilot->setNoOutputPriorPicsFlag(false); |
---|
1016 | } |
---|
1017 | |
---|
1018 | if(m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
1019 | { |
---|
1020 | m_craNoRaslOutputFlag = m_apcSlicePilot->getNoRaslOutputFlag(); |
---|
1021 | } |
---|
1022 | } |
---|
1023 | if (m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoOutputPriorPicsFlag()) |
---|
1024 | { |
---|
1025 | m_lastPOCNoOutputPriorPics = m_apcSlicePilot->getPOC(); |
---|
1026 | m_isNoOutputPriorPics = true; |
---|
1027 | } |
---|
1028 | else |
---|
1029 | { |
---|
1030 | m_isNoOutputPriorPics = false; |
---|
1031 | } |
---|
1032 | |
---|
1033 | //For inference of PicOutputFlag |
---|
1034 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1035 | { |
---|
1036 | if ( m_craNoRaslOutputFlag ) |
---|
1037 | { |
---|
1038 | m_apcSlicePilot->setPicOutputFlag(false); |
---|
1039 | } |
---|
1040 | } |
---|
1041 | #endif |
---|
1042 | |
---|
1043 | #if FIX_POC_CRA_NORASL_OUTPUT |
---|
1044 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1 |
---|
1045 | { |
---|
1046 | Int iMaxPOClsb = 1 << m_apcSlicePilot->getSPS()->getBitsForPOC(); |
---|
1047 | m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) ); |
---|
1048 | } |
---|
1049 | #endif |
---|
1050 | |
---|
1051 | // Skip pictures due to random access |
---|
1052 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) |
---|
1053 | { |
---|
1054 | m_prevSliceSkipped = true; |
---|
1055 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
1056 | return false; |
---|
1057 | } |
---|
1058 | // Skip TFD pictures associated with BLA/BLANT pictures |
---|
1059 | if (isSkipPictureForBLA(iPOCLastDisplay)) |
---|
1060 | { |
---|
1061 | m_prevSliceSkipped = true; |
---|
1062 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
1063 | return false; |
---|
1064 | } |
---|
1065 | |
---|
1066 | // clear previous slice skipped flag |
---|
1067 | m_prevSliceSkipped = false; |
---|
1068 | |
---|
1069 | // exit when a new picture is found |
---|
1070 | #if SVC_EXTENSION |
---|
1071 | bNewPOC = (m_apcSlicePilot->getPOC()!= m_prevPOC); |
---|
1072 | |
---|
1073 | #if NO_OUTPUT_OF_PRIOR_PICS |
---|
1074 | #if NO_CLRAS_OUTPUT_FLAG |
---|
1075 | if (m_layerId == 0 && m_apcSlicePilot->getRapPicFlag() ) |
---|
1076 | { |
---|
1077 | if (m_bFirstSliceInSequence) |
---|
1078 | { |
---|
1079 | setNoClrasOutputFlag(true); |
---|
1080 | } |
---|
1081 | else if ( m_apcSlicePilot->getBlaPicFlag() ) |
---|
1082 | { |
---|
1083 | setNoClrasOutputFlag(true); |
---|
1084 | } |
---|
1085 | #if O0149_CROSS_LAYER_BLA_FLAG |
---|
1086 | else if (m_apcSlicePilot->getIdrPicFlag() && m_apcSlicePilot->getCrossLayerBLAFlag()) |
---|
1087 | { |
---|
1088 | setNoClrasOutputFlag(true); |
---|
1089 | } |
---|
1090 | #endif |
---|
1091 | else |
---|
1092 | { |
---|
1093 | setNoClrasOutputFlag(false); |
---|
1094 | } |
---|
1095 | } |
---|
1096 | else |
---|
1097 | { |
---|
1098 | setNoClrasOutputFlag(false); |
---|
1099 | } |
---|
1100 | |
---|
1101 | m_apcSlicePilot->decodingRefreshMarking( m_cListPic, m_noClrasOutputFlag ); |
---|
1102 | #endif |
---|
1103 | |
---|
1104 | // Derive the value of NoOutputOfPriorPicsFlag |
---|
1105 | if( bNewPOC || m_layerId!=m_uiPrevLayerId ) // i.e. new coded picture |
---|
1106 | { |
---|
1107 | if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getNoRaslOutputFlag() ) |
---|
1108 | { |
---|
1109 | this->setNoOutputPriorPicsFlag( true ); |
---|
1110 | } |
---|
1111 | else if( m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag() ) |
---|
1112 | { |
---|
1113 | this->setNoOutputPriorPicsFlag( m_apcSlicePilot->getNoOutputPriorPicsFlag() ); |
---|
1114 | } |
---|
1115 | else |
---|
1116 | { |
---|
1117 | if( this->m_ppcTDecTop[0]->getNoClrasOutputFlag() ) |
---|
1118 | { |
---|
1119 | this->setNoOutputPriorPicsFlag( true ); |
---|
1120 | } |
---|
1121 | } |
---|
1122 | } |
---|
1123 | #endif |
---|
1124 | |
---|
1125 | #if ALIGNED_BUMPING |
---|
1126 | if (bNewPOC || m_layerId!=m_uiPrevLayerId) |
---|
1127 | { |
---|
1128 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
1129 | } |
---|
1130 | #endif |
---|
1131 | if (m_apcSlicePilot->isNextSlice() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence ) |
---|
1132 | { |
---|
1133 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
1134 | curLayerId = m_uiPrevLayerId; |
---|
1135 | m_uiPrevLayerId = m_layerId; |
---|
1136 | return true; |
---|
1137 | } |
---|
1138 | #else |
---|
1139 | //we should only get a different poc for a new picture (with CTU address==0) |
---|
1140 | if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCUAddr()!=0)) |
---|
1141 | { |
---|
1142 | printf ("Warning, the first slice of a picture might have been lost!\n"); |
---|
1143 | } |
---|
1144 | // exit when a new picture is found |
---|
1145 | if (m_apcSlicePilot->isNextSlice() && (m_apcSlicePilot->getSliceCurStartCUAddr() == 0 && !m_bFirstSliceInPicture) && !m_bFirstSliceInSequence ) |
---|
1146 | { |
---|
1147 | if (m_prevPOC >= m_pocRandomAccess) |
---|
1148 | { |
---|
1149 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
1150 | return true; |
---|
1151 | } |
---|
1152 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
1153 | } |
---|
1154 | #endif |
---|
1155 | // actual decoding starts here |
---|
1156 | xActivateParameterSets(); |
---|
1157 | #if !O0223_O0139_IRAP_ALIGN_NO_CONTRAINTS && N0147_IRAP_ALIGN_FLAG |
---|
1158 | //Note setting O0223_O0139_IRAP_ALIGN_NO_CONTRAINTS to 0 may cause decoder to crash. |
---|
1159 | //When cross_layer_irap_aligned_flag is equal to 0, num_extra_slice_header_bits >=1 |
---|
1160 | if(!m_apcSlicePilot->getVPS()->getCrossLayerIrapAlignFlag() ) |
---|
1161 | { |
---|
1162 | assert( m_apcSlicePilot->getPPS()->getNumExtraSliceHeaderBits() > 0); |
---|
1163 | } |
---|
1164 | //When cross_layer_irap_aligned_flag is equal to 1, the value of poc_reset_flag shall be equal to 0 |
---|
1165 | if( m_apcSlicePilot->getVPS()->getCrossLayerIrapAlignFlag() ) |
---|
1166 | { |
---|
1167 | assert( m_apcSlicePilot->getPocResetFlag() == 0); |
---|
1168 | } |
---|
1169 | #endif |
---|
1170 | #if REPN_FORMAT_IN_VPS |
---|
1171 | // Initialize ILRP if needed, only for the current layer |
---|
1172 | // ILRP intialization should go along with activation of parameters sets, |
---|
1173 | // although activation of parameter sets itself need not be done for each and every slice!!! |
---|
1174 | xInitILRP(m_apcSlicePilot); |
---|
1175 | #endif |
---|
1176 | if (m_apcSlicePilot->isNextSlice()) |
---|
1177 | { |
---|
1178 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
1179 | #if SVC_EXTENSION |
---|
1180 | curLayerId = m_layerId; |
---|
1181 | m_uiPrevLayerId = m_layerId; |
---|
1182 | #endif |
---|
1183 | } |
---|
1184 | m_bFirstSliceInSequence = false; |
---|
1185 | #if SETTING_NO_OUT_PIC_PRIOR |
---|
1186 | m_bFirstSliceInBitstream = false; |
---|
1187 | #endif |
---|
1188 | #if POC_RESET_FLAG |
---|
1189 | // This operation would do the following: |
---|
1190 | // 1. Update the other picture in the DPB. This should be done only for the first slice of the picture. |
---|
1191 | // 2. Update the value of m_pocCRA. |
---|
1192 | // 3. Reset the POC values at the decoder for the current picture to be zero. |
---|
1193 | // 4. update value of POCLastDisplay |
---|
1194 | if( m_apcSlicePilot->getPocResetFlag() ) |
---|
1195 | { |
---|
1196 | if( m_apcSlicePilot->getSliceIdx() == 0 ) |
---|
1197 | { |
---|
1198 | Int pocAdjustValue = m_apcSlicePilot->getPOC(); |
---|
1199 | |
---|
1200 | #if PREVTID0_POC_RESET |
---|
1201 | m_apcSlicePilot->adjustPrevTid0POC(pocAdjustValue); |
---|
1202 | #endif |
---|
1203 | // If poc reset flag is set to 1, reset all POC for DPB -> basically do it for each slice in the picutre |
---|
1204 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
1205 | |
---|
1206 | // Iterate through all picture in DPB |
---|
1207 | while( iterPic != m_cListPic.end() ) |
---|
1208 | { |
---|
1209 | TComPic *dpbPic = *iterPic; |
---|
1210 | // Check if the picture pointed to by iterPic is either used for reference or |
---|
1211 | // needed for output, are in the same layer, and not the current picture. |
---|
1212 | if( /* ( ( dpbPic->getSlice(0)->isReferenced() ) || ( dpbPic->getOutputMark() ) ) |
---|
1213 | &&*/ ( dpbPic->getLayerId() == m_apcSlicePilot->getLayerId() ) |
---|
1214 | && ( dpbPic->getReconMark() ) |
---|
1215 | ) |
---|
1216 | { |
---|
1217 | for(Int i = dpbPic->getNumAllocatedSlice()-1; i >= 0; i--) |
---|
1218 | { |
---|
1219 | |
---|
1220 | TComSlice *slice = dpbPic->getSlice(i); |
---|
1221 | TComReferencePictureSet *rps = slice->getRPS(); |
---|
1222 | slice->setPOC( slice->getPOC() - pocAdjustValue ); |
---|
1223 | |
---|
1224 | // Also adjust the POC value stored in the RPS of each such slice |
---|
1225 | for(Int j = rps->getNumberOfPictures(); j >= 0; j--) |
---|
1226 | { |
---|
1227 | rps->setPOC( j, rps->getPOC(j) - pocAdjustValue ); |
---|
1228 | } |
---|
1229 | // Also adjust the value of refPOC |
---|
1230 | for(Int k = 0; k < 2; k++) // For List 0 and List 1 |
---|
1231 | { |
---|
1232 | RefPicList list = (k == 1) ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
1233 | for(Int j = 0; j < slice->getNumRefIdx(list); j++) |
---|
1234 | { |
---|
1235 | slice->setRefPOC( slice->getRefPOC(list, j) - pocAdjustValue, list, j); |
---|
1236 | } |
---|
1237 | } |
---|
1238 | } |
---|
1239 | } |
---|
1240 | iterPic++; |
---|
1241 | } |
---|
1242 | // Update the value of pocCRA |
---|
1243 | m_pocCRA -= pocAdjustValue; |
---|
1244 | // Update value of POCLastDisplay |
---|
1245 | iPOCLastDisplay -= pocAdjustValue; |
---|
1246 | } |
---|
1247 | // Reset current poc for current slice and RPS |
---|
1248 | m_apcSlicePilot->setPOC( 0 ); |
---|
1249 | } |
---|
1250 | #endif |
---|
1251 | #if ALIGN_TSA_STSA_PICS |
---|
1252 | if( m_apcSlicePilot->getLayerId() > 0 ) |
---|
1253 | { |
---|
1254 | // Check for TSA alignment |
---|
1255 | if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
1256 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R |
---|
1257 | ) |
---|
1258 | { |
---|
1259 | for(Int dependentLayerIdx = 0; dependentLayerIdx < m_apcSlicePilot->getVPS()->getNumDirectRefLayers(m_layerId); dependentLayerIdx++) |
---|
1260 | { |
---|
1261 | TComList<TComPic*> *cListPic = getRefLayerDec( dependentLayerIdx )->getListPic(); |
---|
1262 | TComPic* refpicLayer = m_apcSlicePilot->getRefPic(*cListPic, m_apcSlicePilot->getPOC() ); |
---|
1263 | if( refpicLayer ) |
---|
1264 | { |
---|
1265 | assert( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
1266 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R ); // TSA pictures should be aligned among depenedent layers |
---|
1267 | } |
---|
1268 | } |
---|
1269 | } |
---|
1270 | // Check for STSA alignment |
---|
1271 | if( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
1272 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_R |
---|
1273 | ) |
---|
1274 | { |
---|
1275 | for(Int dependentLayerIdx = 0; dependentLayerIdx < m_apcSlicePilot->getVPS()->getNumDirectRefLayers(m_layerId); dependentLayerIdx++) |
---|
1276 | { |
---|
1277 | TComList<TComPic*> *cListPic = getRefLayerDec( dependentLayerIdx )->getListPic(); |
---|
1278 | TComPic* refpicLayer = m_apcSlicePilot->getRefPic(*cListPic, m_apcSlicePilot->getPOC() ); // STSA pictures should be aligned among dependent layers |
---|
1279 | if( refpicLayer ) |
---|
1280 | |
---|
1281 | { |
---|
1282 | assert( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
1283 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_R ); |
---|
1284 | } |
---|
1285 | } |
---|
1286 | } |
---|
1287 | } |
---|
1288 | #endif |
---|
1289 | //detect lost reference picture and insert copy of earlier frame. |
---|
1290 | Int lostPoc; |
---|
1291 | while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0) |
---|
1292 | { |
---|
1293 | xCreateLostPicture(lostPoc-1); |
---|
1294 | } |
---|
1295 | if (m_bFirstSliceInPicture) |
---|
1296 | { |
---|
1297 | #if AVC_BASE |
---|
1298 | if( m_layerId == 1 && m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
1299 | { |
---|
1300 | TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); |
---|
1301 | pBLPic->getSlice(0)->setReferenced(true); |
---|
1302 | fstream* pFile = m_ppcTDecTop[0]->getBLReconFile(); |
---|
1303 | UInt uiWidth = pBLPic->getPicYuvRec()->getWidth(); |
---|
1304 | UInt uiHeight = pBLPic->getPicYuvRec()->getHeight(); |
---|
1305 | |
---|
1306 | if( pFile->good() ) |
---|
1307 | { |
---|
1308 | UInt64 uiPos = (UInt64) m_apcSlicePilot->getPOC() * uiWidth * uiHeight * 3 / 2; |
---|
1309 | |
---|
1310 | pFile->seekg((UInt)uiPos, ios::beg ); |
---|
1311 | |
---|
1312 | Pel* pPel = pBLPic->getPicYuvRec()->getLumaAddr(); |
---|
1313 | UInt uiStride = pBLPic->getPicYuvRec()->getStride(); |
---|
1314 | for( Int i = 0; i < uiHeight; i++ ) |
---|
1315 | { |
---|
1316 | for( Int j = 0; j < uiWidth; j++ ) |
---|
1317 | { |
---|
1318 | pPel[j] = pFile->get(); |
---|
1319 | } |
---|
1320 | pPel += uiStride; |
---|
1321 | } |
---|
1322 | |
---|
1323 | pPel = pBLPic->getPicYuvRec()->getCbAddr(); |
---|
1324 | uiStride = pBLPic->getPicYuvRec()->getCStride(); |
---|
1325 | for( Int i = 0; i < uiHeight/2; i++ ) |
---|
1326 | { |
---|
1327 | for( Int j = 0; j < uiWidth/2; j++ ) |
---|
1328 | { |
---|
1329 | pPel[j] = pFile->get(); |
---|
1330 | } |
---|
1331 | pPel += uiStride; |
---|
1332 | } |
---|
1333 | |
---|
1334 | pPel = pBLPic->getPicYuvRec()->getCrAddr(); |
---|
1335 | uiStride = pBLPic->getPicYuvRec()->getCStride(); |
---|
1336 | for( Int i = 0; i < uiHeight/2; i++ ) |
---|
1337 | { |
---|
1338 | for( Int j = 0; j < uiWidth/2; j++ ) |
---|
1339 | { |
---|
1340 | pPel[j] = pFile->get(); |
---|
1341 | } |
---|
1342 | pPel += uiStride; |
---|
1343 | } |
---|
1344 | } |
---|
1345 | } |
---|
1346 | #endif |
---|
1347 | |
---|
1348 | #if NO_OUTPUT_OF_PRIOR_PICS |
---|
1349 | if ( m_layerId == 0 && m_apcSlicePilot->getRapPicFlag() && getNoClrasOutputFlag() ) |
---|
1350 | { |
---|
1351 | for (UInt i = 0; i < m_apcSlicePilot->getVPS()->getMaxLayers(); i++) |
---|
1352 | { |
---|
1353 | m_ppcTDecTop[i]->setLayerInitializedFlag(false); |
---|
1354 | m_ppcTDecTop[i]->setFirstPicInLayerDecodedFlag(false); |
---|
1355 | } |
---|
1356 | } |
---|
1357 | #endif |
---|
1358 | // Buffer initialize for prediction. |
---|
1359 | m_cPrediction.initTempBuff(); |
---|
1360 | #if ALIGNED_BUMPING |
---|
1361 | m_apcSlicePilot->checkLeadingPictureRestrictions(m_cListPic); |
---|
1362 | #else |
---|
1363 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
1364 | #endif |
---|
1365 | // Get a new picture buffer |
---|
1366 | xGetNewPicBuffer (m_apcSlicePilot, pcPic); |
---|
1367 | |
---|
1368 | Bool isField = false; |
---|
1369 | Bool isTff = false; |
---|
1370 | |
---|
1371 | if(!m_SEIs.empty()) |
---|
1372 | { |
---|
1373 | // Check if any new Picture Timing SEI has arrived |
---|
1374 | SEIMessages pictureTimingSEIs = extractSeisByType (m_SEIs, SEI::PICTURE_TIMING); |
---|
1375 | if (pictureTimingSEIs.size()>0) |
---|
1376 | { |
---|
1377 | SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin()); |
---|
1378 | isField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 2); |
---|
1379 | isTff = (pictureTiming->m_picStruct == 1); |
---|
1380 | } |
---|
1381 | } |
---|
1382 | |
---|
1383 | //Set Field/Frame coding mode |
---|
1384 | m_pcPic->setField(isField); |
---|
1385 | m_pcPic->setTopField(isTff); |
---|
1386 | |
---|
1387 | // transfer any SEI messages that have been received to the picture |
---|
1388 | pcPic->setSEIs(m_SEIs); |
---|
1389 | m_SEIs.clear(); |
---|
1390 | |
---|
1391 | // Recursive structure |
---|
1392 | m_cCuDecoder.create ( g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight ); |
---|
1393 | #if SVC_EXTENSION |
---|
1394 | m_cCuDecoder.init ( m_ppcTDecTop,&m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction, curLayerId ); |
---|
1395 | #else |
---|
1396 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction ); |
---|
1397 | #endif |
---|
1398 | m_cTrQuant.init ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize()); |
---|
1399 | |
---|
1400 | m_cSliceDecoder.create(); |
---|
1401 | } |
---|
1402 | else |
---|
1403 | { |
---|
1404 | // Check if any new SEI has arrived |
---|
1405 | if(!m_SEIs.empty()) |
---|
1406 | { |
---|
1407 | // Currently only decoding Unit SEI message occurring between VCL NALUs copied |
---|
1408 | SEIMessages &picSEI = pcPic->getSEIs(); |
---|
1409 | SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO); |
---|
1410 | picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end()); |
---|
1411 | deleteSEIs(m_SEIs); |
---|
1412 | } |
---|
1413 | } |
---|
1414 | |
---|
1415 | // Set picture slice pointer |
---|
1416 | TComSlice* pcSlice = m_apcSlicePilot; |
---|
1417 | Bool bNextSlice = pcSlice->isNextSlice(); |
---|
1418 | |
---|
1419 | UInt uiCummulativeTileWidth; |
---|
1420 | UInt uiCummulativeTileHeight; |
---|
1421 | UInt i, j, p; |
---|
1422 | |
---|
1423 | //set NumColumnsMins1 and NumRowsMinus1 |
---|
1424 | pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() ); |
---|
1425 | pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() ); |
---|
1426 | |
---|
1427 | //create the TComTileArray |
---|
1428 | pcPic->getPicSym()->xCreateTComTileArray(); |
---|
1429 | |
---|
1430 | if( pcSlice->getPPS()->getUniformSpacingFlag() ) |
---|
1431 | { |
---|
1432 | //set the width for each tile |
---|
1433 | for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) |
---|
1434 | { |
---|
1435 | for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) |
---|
1436 | { |
---|
1437 | pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> |
---|
1438 | setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) |
---|
1439 | - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); |
---|
1440 | } |
---|
1441 | } |
---|
1442 | |
---|
1443 | //set the height for each tile |
---|
1444 | for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) |
---|
1445 | { |
---|
1446 | for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) |
---|
1447 | { |
---|
1448 | pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> |
---|
1449 | setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) |
---|
1450 | - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); |
---|
1451 | } |
---|
1452 | } |
---|
1453 | } |
---|
1454 | else |
---|
1455 | { |
---|
1456 | //set the width for each tile |
---|
1457 | for(j=0; j < pcSlice->getPPS()->getNumRowsMinus1()+1; j++) |
---|
1458 | { |
---|
1459 | uiCummulativeTileWidth = 0; |
---|
1460 | for(i=0; i < pcSlice->getPPS()->getNumColumnsMinus1(); i++) |
---|
1461 | { |
---|
1462 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getPPS()->getColumnWidth(i) ); |
---|
1463 | uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(i); |
---|
1464 | } |
---|
1465 | pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); |
---|
1466 | } |
---|
1467 | |
---|
1468 | //set the height for each tile |
---|
1469 | for(j=0; j < pcSlice->getPPS()->getNumColumnsMinus1()+1; j++) |
---|
1470 | { |
---|
1471 | uiCummulativeTileHeight = 0; |
---|
1472 | for(i=0; i < pcSlice->getPPS()->getNumRowsMinus1(); i++) |
---|
1473 | { |
---|
1474 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getPPS()->getRowHeight(i) ); |
---|
1475 | uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(i); |
---|
1476 | } |
---|
1477 | pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); |
---|
1478 | } |
---|
1479 | } |
---|
1480 | |
---|
1481 | pcPic->getPicSym()->xInitTiles(); |
---|
1482 | |
---|
1483 | //generate the Coding Order Map and Inverse Coding Order Map |
---|
1484 | UInt uiEncCUAddr; |
---|
1485 | for(i=0, uiEncCUAddr=0; i<pcPic->getPicSym()->getNumberOfCUsInFrame(); i++, uiEncCUAddr = pcPic->getPicSym()->xCalculateNxtCUAddr(uiEncCUAddr)) |
---|
1486 | { |
---|
1487 | pcPic->getPicSym()->setCUOrderMap(i, uiEncCUAddr); |
---|
1488 | pcPic->getPicSym()->setInverseCUOrderMap(uiEncCUAddr, i); |
---|
1489 | } |
---|
1490 | pcPic->getPicSym()->setCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
1491 | pcPic->getPicSym()->setInverseCUOrderMap(pcPic->getPicSym()->getNumberOfCUsInFrame(), pcPic->getPicSym()->getNumberOfCUsInFrame()); |
---|
1492 | |
---|
1493 | //convert the start and end CU addresses of the slice and dependent slice into encoding order |
---|
1494 | pcSlice->setSliceSegmentCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurStartCUAddr()) ); |
---|
1495 | pcSlice->setSliceSegmentCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurEndCUAddr()) ); |
---|
1496 | if(pcSlice->isNextSlice()) |
---|
1497 | { |
---|
1498 | pcSlice->setSliceCurStartCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurStartCUAddr())); |
---|
1499 | pcSlice->setSliceCurEndCUAddr(pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceCurEndCUAddr())); |
---|
1500 | } |
---|
1501 | |
---|
1502 | if (m_bFirstSliceInPicture) |
---|
1503 | { |
---|
1504 | if(pcPic->getNumAllocatedSlice() != 1) |
---|
1505 | { |
---|
1506 | pcPic->clearSliceBuffer(); |
---|
1507 | } |
---|
1508 | } |
---|
1509 | else |
---|
1510 | { |
---|
1511 | pcPic->allocateNewSlice(); |
---|
1512 | } |
---|
1513 | assert(pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
1514 | m_apcSlicePilot = pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
1515 | pcPic->getPicSym()->setSlice(pcSlice, m_uiSliceIdx); |
---|
1516 | |
---|
1517 | pcPic->setTLayer(nalu.m_temporalId); |
---|
1518 | |
---|
1519 | #if SVC_EXTENSION |
---|
1520 | pcPic->setLayerId(nalu.m_layerId); |
---|
1521 | pcSlice->setLayerId(nalu.m_layerId); |
---|
1522 | pcSlice->setPic(pcPic); |
---|
1523 | #endif |
---|
1524 | |
---|
1525 | if (bNextSlice) |
---|
1526 | { |
---|
1527 | pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic ); |
---|
1528 | // Set reference list |
---|
1529 | #if SVC_EXTENSION |
---|
1530 | if (m_layerId == 0) |
---|
1531 | #endif |
---|
1532 | pcSlice->setRefPicList( m_cListPic, true ); |
---|
1533 | |
---|
1534 | #if SVC_EXTENSION |
---|
1535 | // Create upsampling reference layer pictures for all possible dependent layers and do it only once for the first slice. |
---|
1536 | // Other slices might choose which reference pictures to be used for inter-layer prediction |
---|
1537 | if( m_layerId > 0 && m_uiSliceIdx == 0 ) |
---|
1538 | { |
---|
1539 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
1540 | if( !pcSlice->getVPS()->getSingleLayerForNonIrapFlag() || ( pcSlice->getVPS()->getSingleLayerForNonIrapFlag() && pcSlice->isIRAP() ) ) |
---|
1541 | #endif |
---|
1542 | for( i = 0; i < pcSlice->getNumILRRefIdx(); i++ ) |
---|
1543 | { |
---|
1544 | UInt refLayerIdc = i; |
---|
1545 | #if AVC_BASE |
---|
1546 | if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getAvcBaseLayerFlag() ) |
---|
1547 | { |
---|
1548 | TComPic* pic = *m_ppcTDecTop[0]->getListPic()->begin(); |
---|
1549 | |
---|
1550 | if( pic ) |
---|
1551 | { |
---|
1552 | pcSlice->setBaseColPic ( refLayerIdc, pic ); |
---|
1553 | } |
---|
1554 | else |
---|
1555 | { |
---|
1556 | continue; |
---|
1557 | } |
---|
1558 | #if AVC_SYNTAX |
---|
1559 | TComPic* pBLPic = pcSlice->getBaseColPic(refLayerIdc); |
---|
1560 | if( pcSlice->getPOC() == 0 ) |
---|
1561 | { |
---|
1562 | // initialize partition order. |
---|
1563 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
1564 | initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp ); |
---|
1565 | initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 ); |
---|
1566 | } |
---|
1567 | pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice ); |
---|
1568 | pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES ); |
---|
1569 | #endif |
---|
1570 | } |
---|
1571 | else |
---|
1572 | { |
---|
1573 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1574 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
---|
1575 | #else |
---|
1576 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
1577 | #endif |
---|
1578 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
1579 | if( !pcSlice->setBaseColPic ( *cListPic, refLayerIdc ) ) |
---|
1580 | { |
---|
1581 | continue; |
---|
1582 | } |
---|
1583 | } |
---|
1584 | #else |
---|
1585 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1586 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
---|
1587 | #else |
---|
1588 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
1589 | #endif |
---|
1590 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
1591 | pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); |
---|
1592 | #endif |
---|
1593 | |
---|
1594 | #if O0098_SCALED_REF_LAYER_ID |
---|
1595 | const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc)); |
---|
1596 | #else |
---|
1597 | const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc); |
---|
1598 | #endif |
---|
1599 | |
---|
1600 | Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(); |
---|
1601 | Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(); |
---|
1602 | #if Q0200_CONFORMANCE_BL_SIZE |
---|
1603 | Int chromaFormatIdc = pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getChromaFormatIdc(); |
---|
1604 | const Window &confBL = pcSlice->getBaseColPic(refLayerIdc)->getConformanceWindow(); |
---|
1605 | widthBL -= ( confBL.getWindowLeftOffset() + confBL.getWindowRightOffset() ) * TComSPS::getWinUnitX( chromaFormatIdc ); |
---|
1606 | heightBL -= ( confBL.getWindowTopOffset() + confBL.getWindowBottomOffset() ) * TComSPS::getWinUnitY( chromaFormatIdc ); |
---|
1607 | #endif |
---|
1608 | Int widthEL = pcPic->getPicYuvRec()->getWidth() - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset(); |
---|
1609 | Int heightEL = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset(); |
---|
1610 | |
---|
1611 | g_mvScalingFactor[refLayerIdc][0] = widthEL == widthBL ? 4096 : Clip3(-4096, 4095, ((widthEL << 8) + (widthBL >> 1)) / widthBL); |
---|
1612 | g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL); |
---|
1613 | |
---|
1614 | g_posScalingFactor[refLayerIdc][0] = ((widthBL << 16) + (widthEL >> 1)) / widthEL; |
---|
1615 | g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL; |
---|
1616 | |
---|
1617 | #if Q0048_CGS_3D_ASYMLUT |
---|
1618 | TComPicYuv* pBaseColRec = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(); |
---|
1619 | if( pcSlice->getPPS()->getCGSFlag() ) |
---|
1620 | { |
---|
1621 | if(!m_pColorMappedPic) |
---|
1622 | { |
---|
1623 | initAsymLut(pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)); |
---|
1624 | } |
---|
1625 | m_c3DAsymLUTPPS.colorMapping( pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pColorMappedPic ); |
---|
1626 | pBaseColRec = m_pColorMappedPic; |
---|
1627 | } |
---|
1628 | #endif |
---|
1629 | #if SVC_UPSAMPLING |
---|
1630 | if( pcPic->isSpatialEnhLayer(refLayerIdc) ) |
---|
1631 | { |
---|
1632 | #if O0215_PHASE_ALIGNMENT |
---|
1633 | #if O0194_JOINT_US_BITSHIFT |
---|
1634 | #if Q0048_CGS_3D_ASYMLUT |
---|
1635 | m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() ); |
---|
1636 | #else |
---|
1637 | m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() ); |
---|
1638 | #endif |
---|
1639 | #else |
---|
1640 | #if Q0048_CGS_3D_ASYMLUT |
---|
1641 | m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() ); |
---|
1642 | #else |
---|
1643 | m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() ); |
---|
1644 | #endif |
---|
1645 | #endif |
---|
1646 | #else |
---|
1647 | #if O0194_JOINT_US_BITSHIFT |
---|
1648 | #if Q0048_CGS_3D_ASYMLUT |
---|
1649 | m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL ); |
---|
1650 | #else |
---|
1651 | m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL ); |
---|
1652 | #endif |
---|
1653 | #else |
---|
1654 | #if Q0048_CGS_3D_ASYMLUT |
---|
1655 | m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL ); |
---|
1656 | #else |
---|
1657 | m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL ); |
---|
1658 | #endif |
---|
1659 | #endif |
---|
1660 | #endif |
---|
1661 | } |
---|
1662 | else |
---|
1663 | { |
---|
1664 | pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() ); |
---|
1665 | } |
---|
1666 | pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) ); |
---|
1667 | #endif |
---|
1668 | } |
---|
1669 | } |
---|
1670 | |
---|
1671 | if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() ) |
---|
1672 | { |
---|
1673 | for( i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1674 | { |
---|
1675 | UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); |
---|
1676 | #if AVC_BASE |
---|
1677 | if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getAvcBaseLayerFlag() ) |
---|
1678 | { |
---|
1679 | pcSlice->setBaseColPic ( refLayerIdc, *m_ppcTDecTop[0]->getListPic()->begin() ); |
---|
1680 | #if AVC_SYNTAX |
---|
1681 | TComPic* pBLPic = pcSlice->getBaseColPic(refLayerIdc); |
---|
1682 | if( pcSlice->getPOC() == 0 ) |
---|
1683 | { |
---|
1684 | // initialize partition order. |
---|
1685 | UInt* piTmp = &g_auiZscanToRaster[0]; |
---|
1686 | initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp ); |
---|
1687 | initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 ); |
---|
1688 | } |
---|
1689 | pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice ); |
---|
1690 | pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES ); |
---|
1691 | #endif |
---|
1692 | } |
---|
1693 | else |
---|
1694 | { |
---|
1695 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1696 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
---|
1697 | #else |
---|
1698 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
1699 | #endif |
---|
1700 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
1701 | pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); |
---|
1702 | } |
---|
1703 | #else |
---|
1704 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1705 | TDecTop *pcTDecTop = (TDecTop *)getRefLayerDec( refLayerIdc ); |
---|
1706 | #else |
---|
1707 | TDecTop *pcTDecTop = (TDecTop *)getLayerDec( m_layerId-1 ); |
---|
1708 | #endif |
---|
1709 | TComList<TComPic*> *cListPic = pcTDecTop->getListPic(); |
---|
1710 | pcSlice->setBaseColPic ( *cListPic, refLayerIdc ); |
---|
1711 | #endif |
---|
1712 | |
---|
1713 | pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) ); |
---|
1714 | } |
---|
1715 | |
---|
1716 | pcSlice->setILRPic( m_cIlpPic ); |
---|
1717 | |
---|
1718 | #if REF_IDX_MFM |
---|
1719 | if( pcSlice->getMFMEnabledFlag() ) |
---|
1720 | { |
---|
1721 | pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic()); |
---|
1722 | } |
---|
1723 | pcSlice->setRefPicList( m_cListPic, false, m_cIlpPic); |
---|
1724 | } |
---|
1725 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
1726 | else if ( m_layerId > 0 ) |
---|
1727 | { |
---|
1728 | pcSlice->setRefPicList( m_cListPic, false, NULL); |
---|
1729 | } |
---|
1730 | #endif |
---|
1731 | #if MFM_ENCCONSTRAINT |
---|
1732 | if( pcSlice->getMFMEnabledFlag() ) |
---|
1733 | { |
---|
1734 | Int refLayerId = pcSlice->getRefPic( pcSlice->getSliceType() == B_SLICE ? ( RefPicList )( 1 - pcSlice->getColFromL0Flag() ) : REF_PIC_LIST_0 , pcSlice->getColRefIdx() )->getLayerId(); |
---|
1735 | if( refLayerId != pcSlice->getLayerId() ) |
---|
1736 | { |
---|
1737 | TComPic* pColBasePic = pcSlice->getBaseColPic( *m_ppcTDecTop[refLayerId]->getListPic() ); |
---|
1738 | assert( pColBasePic->checkSameRefInfo() == true ); |
---|
1739 | } |
---|
1740 | } |
---|
1741 | #endif |
---|
1742 | #endif |
---|
1743 | |
---|
1744 | #if N0147_IRAP_ALIGN_FLAG |
---|
1745 | if( m_layerId > 0 && pcSlice->getVPS()->getCrossLayerIrapAlignFlag() ) |
---|
1746 | { |
---|
1747 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
1748 | if( !pcSlice->getVPS()->getSingleLayerForNonIrapFlag() || ( pcSlice->getVPS()->getSingleLayerForNonIrapFlag() && pcSlice->isIRAP() ) ) |
---|
1749 | #endif |
---|
1750 | for(Int dependentLayerIdx = 0; dependentLayerIdx < pcSlice->getVPS()->getNumDirectRefLayers(m_layerId); dependentLayerIdx++) |
---|
1751 | { |
---|
1752 | TComList<TComPic*> *cListPic = getRefLayerDec( dependentLayerIdx )->getListPic(); |
---|
1753 | TComPic* refpicLayer = pcSlice->getRefPic(*cListPic, pcSlice->getPOC() ); |
---|
1754 | if(refpicLayer && pcSlice->isIRAP()) |
---|
1755 | { |
---|
1756 | assert(pcSlice->getNalUnitType() == refpicLayer->getSlice(0)->getNalUnitType()); |
---|
1757 | } |
---|
1758 | } |
---|
1759 | } |
---|
1760 | #endif |
---|
1761 | #endif //SVC_EXTENSION |
---|
1762 | |
---|
1763 | // For generalized B |
---|
1764 | // note: maybe not existed case (always L0 is copied to L1 if L1 is empty) |
---|
1765 | if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0) |
---|
1766 | { |
---|
1767 | Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
---|
1768 | pcSlice->setNumRefIdx ( REF_PIC_LIST_1, iNumRefIdx ); |
---|
1769 | |
---|
1770 | for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++) |
---|
1771 | { |
---|
1772 | pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx); |
---|
1773 | } |
---|
1774 | } |
---|
1775 | if (!pcSlice->isIntra()) |
---|
1776 | { |
---|
1777 | Bool bLowDelay = true; |
---|
1778 | Int iCurrPOC = pcSlice->getPOC(); |
---|
1779 | Int iRefIdx = 0; |
---|
1780 | |
---|
1781 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++) |
---|
1782 | { |
---|
1783 | if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC ) |
---|
1784 | { |
---|
1785 | bLowDelay = false; |
---|
1786 | } |
---|
1787 | } |
---|
1788 | if (pcSlice->isInterB()) |
---|
1789 | { |
---|
1790 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++) |
---|
1791 | { |
---|
1792 | if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC ) |
---|
1793 | { |
---|
1794 | bLowDelay = false; |
---|
1795 | } |
---|
1796 | } |
---|
1797 | } |
---|
1798 | |
---|
1799 | pcSlice->setCheckLDC(bLowDelay); |
---|
1800 | } |
---|
1801 | |
---|
1802 | //--------------- |
---|
1803 | pcSlice->setRefPOCList(); |
---|
1804 | } |
---|
1805 | |
---|
1806 | pcPic->setCurrSliceIdx(m_uiSliceIdx); |
---|
1807 | if(pcSlice->getSPS()->getScalingListFlag()) |
---|
1808 | { |
---|
1809 | pcSlice->setScalingList ( pcSlice->getSPS()->getScalingList() ); |
---|
1810 | if(pcSlice->getPPS()->getScalingListPresentFlag()) |
---|
1811 | { |
---|
1812 | pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList() ); |
---|
1813 | } |
---|
1814 | #if SCALINGLIST_INFERRING |
---|
1815 | if( m_layerId == 0 || ( m_layerId > 0 && !pcSlice->getPPS()->getInferScalingListFlag() && !pcSlice->getSPS()->getInferScalingListFlag() ) ) |
---|
1816 | #endif |
---|
1817 | if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag()) |
---|
1818 | { |
---|
1819 | pcSlice->setDefaultScalingList(); |
---|
1820 | } |
---|
1821 | m_cTrQuant.setScalingListDec(pcSlice->getScalingList()); |
---|
1822 | m_cTrQuant.setUseScalingList(true); |
---|
1823 | } |
---|
1824 | else |
---|
1825 | { |
---|
1826 | m_cTrQuant.setFlatScalingList(); |
---|
1827 | m_cTrQuant.setUseScalingList(false); |
---|
1828 | } |
---|
1829 | |
---|
1830 | // Decode a picture |
---|
1831 | m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic); |
---|
1832 | |
---|
1833 | m_bFirstSliceInPicture = false; |
---|
1834 | m_uiSliceIdx++; |
---|
1835 | |
---|
1836 | return false; |
---|
1837 | } |
---|
1838 | |
---|
1839 | Void TDecTop::xDecodeVPS() |
---|
1840 | { |
---|
1841 | TComVPS* vps = new TComVPS(); |
---|
1842 | |
---|
1843 | m_cEntropyDecoder.decodeVPS( vps ); |
---|
1844 | m_parameterSetManagerDecoder.storePrefetchedVPS(vps); |
---|
1845 | } |
---|
1846 | |
---|
1847 | Void TDecTop::xDecodeSPS() |
---|
1848 | { |
---|
1849 | TComSPS* sps = new TComSPS(); |
---|
1850 | #if SVC_EXTENSION |
---|
1851 | sps->setLayerId(m_layerId); |
---|
1852 | #if SPS_DPB_PARAMS |
---|
1853 | m_cEntropyDecoder.decodeSPS( sps ); // it should be removed after macro clean up |
---|
1854 | #else |
---|
1855 | m_cEntropyDecoder.decodeSPS( sps, &m_parameterSetManagerDecoder ); |
---|
1856 | #endif |
---|
1857 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
---|
1858 | #if !REPN_FORMAT_IN_VPS // ILRP can only be initialized at activation |
---|
1859 | if(m_numLayer>0) |
---|
1860 | { |
---|
1861 | xInitILRP(sps); |
---|
1862 | } |
---|
1863 | #endif |
---|
1864 | #else //SVC_EXTENSION |
---|
1865 | m_cEntropyDecoder.decodeSPS( sps ); |
---|
1866 | m_parameterSetManagerDecoder.storePrefetchedSPS(sps); |
---|
1867 | #endif //SVC_EXTENSION |
---|
1868 | } |
---|
1869 | |
---|
1870 | Void TDecTop::xDecodePPS( |
---|
1871 | #if Q0048_CGS_3D_ASYMLUT |
---|
1872 | TCom3DAsymLUT * pc3DAsymLUT |
---|
1873 | #endif |
---|
1874 | ) |
---|
1875 | { |
---|
1876 | TComPPS* pps = new TComPPS(); |
---|
1877 | |
---|
1878 | #if SCALINGLIST_INFERRING |
---|
1879 | pps->setLayerId( m_layerId ); |
---|
1880 | #endif |
---|
1881 | |
---|
1882 | m_cEntropyDecoder.decodePPS( pps |
---|
1883 | #if Q0048_CGS_3D_ASYMLUT |
---|
1884 | , pc3DAsymLUT , m_layerId |
---|
1885 | #endif |
---|
1886 | ); |
---|
1887 | m_parameterSetManagerDecoder.storePrefetchedPPS( pps ); |
---|
1888 | |
---|
1889 | if( pps->getDependentSliceSegmentsEnabledFlag() ) |
---|
1890 | { |
---|
1891 | Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1; |
---|
1892 | m_cSliceDecoder.initCtxMem(NumCtx); |
---|
1893 | for ( UInt st = 0; st < NumCtx; st++ ) |
---|
1894 | { |
---|
1895 | TDecSbac* ctx = NULL; |
---|
1896 | ctx = new TDecSbac; |
---|
1897 | ctx->init( &m_cBinCABAC ); |
---|
1898 | m_cSliceDecoder.setCtxMem( ctx, st ); |
---|
1899 | } |
---|
1900 | } |
---|
1901 | } |
---|
1902 | |
---|
1903 | Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ) |
---|
1904 | { |
---|
1905 | #if SVC_EXTENSION |
---|
1906 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
---|
1907 | { |
---|
1908 | #if RANDOM_ACCESS_SEI_FIX |
---|
1909 | if (m_prevSliceSkipped) // No need to decode SEI messages of a skipped access unit |
---|
1910 | { |
---|
1911 | return; |
---|
1912 | } |
---|
1913 | #endif |
---|
1914 | #if LAYERS_NOT_PRESENT_SEI |
---|
1915 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
1916 | #else |
---|
1917 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
1918 | #endif |
---|
1919 | } |
---|
1920 | else |
---|
1921 | { |
---|
1922 | #if LAYERS_NOT_PRESENT_SEI |
---|
1923 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
1924 | #else |
---|
1925 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
1926 | #endif |
---|
1927 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
---|
1928 | if (activeParamSets.size()>0) |
---|
1929 | { |
---|
1930 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
---|
1931 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
1932 | assert(seiAps->activeSeqParameterSetId.size()>0); |
---|
1933 | if( !m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParameterSetId[0] ) ) |
---|
1934 | { |
---|
1935 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
1936 | } |
---|
1937 | } |
---|
1938 | #if Q0074_SEI_COLOR_MAPPING |
---|
1939 | m_ColorMapping->setColorMapping( m_SEIs ); |
---|
1940 | #endif |
---|
1941 | } |
---|
1942 | #else |
---|
1943 | if(nalUnitType == NAL_UNIT_SUFFIX_SEI) |
---|
1944 | { |
---|
1945 | #if LAYERS_NOT_PRESENT_SEI |
---|
1946 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
1947 | #else |
---|
1948 | m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
1949 | #endif |
---|
1950 | } |
---|
1951 | else |
---|
1952 | { |
---|
1953 | #if LAYERS_NOT_PRESENT_SEI |
---|
1954 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveVPS(), m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
1955 | #else |
---|
1956 | m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); |
---|
1957 | #endif |
---|
1958 | SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS); |
---|
1959 | if (activeParamSets.size()>0) |
---|
1960 | { |
---|
1961 | SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); |
---|
1962 | m_parameterSetManagerDecoder.applyPrefetchedPS(); |
---|
1963 | assert(seiAps->activeSeqParameterSetId.size()>0); |
---|
1964 | if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParameterSetId[0] )) |
---|
1965 | { |
---|
1966 | printf ("Warning SPS activation with Active parameter set SEI failed"); |
---|
1967 | } |
---|
1968 | } |
---|
1969 | } |
---|
1970 | #endif |
---|
1971 | } |
---|
1972 | |
---|
1973 | #if SVC_EXTENSION |
---|
1974 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, UInt& curLayerId, Bool& bNewPOC) |
---|
1975 | #else |
---|
1976 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
1977 | #endif |
---|
1978 | { |
---|
1979 | // Initialize entropy decoder |
---|
1980 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
1981 | m_cEntropyDecoder.setBitstream (nalu.m_Bitstream); |
---|
1982 | |
---|
1983 | #if O0137_MAX_LAYERID |
---|
1984 | // ignore any NAL units with nuh_layer_id == 63 |
---|
1985 | if (nalu.m_layerId == 63 ) |
---|
1986 | { |
---|
1987 | return false; |
---|
1988 | } |
---|
1989 | #endif |
---|
1990 | switch (nalu.m_nalUnitType) |
---|
1991 | { |
---|
1992 | case NAL_UNIT_VPS: |
---|
1993 | #if VPS_NUH_LAYER_ID |
---|
1994 | assert( nalu.m_layerId == 0 ); // Non-conforming bitstream. The value of nuh_layer_id of VPS NAL unit shall be equal to 0. |
---|
1995 | #endif |
---|
1996 | xDecodeVPS(); |
---|
1997 | #if AVC_BASE |
---|
1998 | if( m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) |
---|
1999 | { |
---|
2000 | if( !m_ppcTDecTop[0]->getBLReconFile()->good() ) |
---|
2001 | { |
---|
2002 | printf( "Base layer YUV input reading error\n" ); |
---|
2003 | exit(EXIT_FAILURE); |
---|
2004 | } |
---|
2005 | #if AVC_SYNTAX |
---|
2006 | if( !m_ppcTDecTop[0]->getBLSyntaxFile()->good() ) |
---|
2007 | { |
---|
2008 | printf( "Base layer syntax input reading error\n" ); |
---|
2009 | exit(EXIT_FAILURE); |
---|
2010 | } |
---|
2011 | #endif |
---|
2012 | } |
---|
2013 | else |
---|
2014 | { |
---|
2015 | TComList<TComPic*> *cListPic = m_ppcTDecTop[0]->getListPic(); |
---|
2016 | cListPic->clear(); |
---|
2017 | } |
---|
2018 | #endif |
---|
2019 | return false; |
---|
2020 | |
---|
2021 | case NAL_UNIT_SPS: |
---|
2022 | xDecodeSPS(); |
---|
2023 | return false; |
---|
2024 | |
---|
2025 | case NAL_UNIT_PPS: |
---|
2026 | xDecodePPS( |
---|
2027 | #if Q0048_CGS_3D_ASYMLUT |
---|
2028 | &m_c3DAsymLUTPPS |
---|
2029 | #endif |
---|
2030 | ); |
---|
2031 | return false; |
---|
2032 | |
---|
2033 | case NAL_UNIT_PREFIX_SEI: |
---|
2034 | case NAL_UNIT_SUFFIX_SEI: |
---|
2035 | xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType ); |
---|
2036 | return false; |
---|
2037 | |
---|
2038 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
2039 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
2040 | case NAL_UNIT_CODED_SLICE_TSA_R: |
---|
2041 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
2042 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
2043 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
2044 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
2045 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
2046 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
2047 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
2048 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
2049 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
2050 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
2051 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
2052 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
2053 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
2054 | #if SVC_EXTENSION |
---|
2055 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, curLayerId, bNewPOC); |
---|
2056 | #else |
---|
2057 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay); |
---|
2058 | #endif |
---|
2059 | break; |
---|
2060 | |
---|
2061 | case NAL_UNIT_EOS: |
---|
2062 | m_associatedIRAPType = NAL_UNIT_INVALID; |
---|
2063 | m_pocCRA = 0; |
---|
2064 | m_pocRandomAccess = MAX_INT; |
---|
2065 | m_prevPOC = MAX_INT; |
---|
2066 | m_bFirstSliceInPicture = true; |
---|
2067 | m_bFirstSliceInSequence = true; |
---|
2068 | m_prevSliceSkipped = false; |
---|
2069 | m_skippedPOC = 0; |
---|
2070 | return false; |
---|
2071 | |
---|
2072 | case NAL_UNIT_ACCESS_UNIT_DELIMITER: |
---|
2073 | // TODO: process AU delimiter |
---|
2074 | return false; |
---|
2075 | |
---|
2076 | case NAL_UNIT_EOB: |
---|
2077 | #if P0130_EOB |
---|
2078 | //Check layer id of the nalu. if it is not 0, give a warning message. |
---|
2079 | if (nalu.m_layerId > 0) |
---|
2080 | { |
---|
2081 | printf( "\n\nThis bitstream is ended with EOB NALU that has layer id greater than 0\n" ); |
---|
2082 | } |
---|
2083 | #endif |
---|
2084 | return false; |
---|
2085 | |
---|
2086 | case NAL_UNIT_FILLER_DATA: |
---|
2087 | return false; |
---|
2088 | |
---|
2089 | case NAL_UNIT_RESERVED_VCL_N10: |
---|
2090 | case NAL_UNIT_RESERVED_VCL_R11: |
---|
2091 | case NAL_UNIT_RESERVED_VCL_N12: |
---|
2092 | case NAL_UNIT_RESERVED_VCL_R13: |
---|
2093 | case NAL_UNIT_RESERVED_VCL_N14: |
---|
2094 | case NAL_UNIT_RESERVED_VCL_R15: |
---|
2095 | |
---|
2096 | case NAL_UNIT_RESERVED_IRAP_VCL22: |
---|
2097 | case NAL_UNIT_RESERVED_IRAP_VCL23: |
---|
2098 | |
---|
2099 | case NAL_UNIT_RESERVED_VCL24: |
---|
2100 | case NAL_UNIT_RESERVED_VCL25: |
---|
2101 | case NAL_UNIT_RESERVED_VCL26: |
---|
2102 | case NAL_UNIT_RESERVED_VCL27: |
---|
2103 | case NAL_UNIT_RESERVED_VCL28: |
---|
2104 | case NAL_UNIT_RESERVED_VCL29: |
---|
2105 | case NAL_UNIT_RESERVED_VCL30: |
---|
2106 | case NAL_UNIT_RESERVED_VCL31: |
---|
2107 | |
---|
2108 | case NAL_UNIT_RESERVED_NVCL41: |
---|
2109 | case NAL_UNIT_RESERVED_NVCL42: |
---|
2110 | case NAL_UNIT_RESERVED_NVCL43: |
---|
2111 | case NAL_UNIT_RESERVED_NVCL44: |
---|
2112 | case NAL_UNIT_RESERVED_NVCL45: |
---|
2113 | case NAL_UNIT_RESERVED_NVCL46: |
---|
2114 | case NAL_UNIT_RESERVED_NVCL47: |
---|
2115 | case NAL_UNIT_UNSPECIFIED_48: |
---|
2116 | case NAL_UNIT_UNSPECIFIED_49: |
---|
2117 | case NAL_UNIT_UNSPECIFIED_50: |
---|
2118 | case NAL_UNIT_UNSPECIFIED_51: |
---|
2119 | case NAL_UNIT_UNSPECIFIED_52: |
---|
2120 | case NAL_UNIT_UNSPECIFIED_53: |
---|
2121 | case NAL_UNIT_UNSPECIFIED_54: |
---|
2122 | case NAL_UNIT_UNSPECIFIED_55: |
---|
2123 | case NAL_UNIT_UNSPECIFIED_56: |
---|
2124 | case NAL_UNIT_UNSPECIFIED_57: |
---|
2125 | case NAL_UNIT_UNSPECIFIED_58: |
---|
2126 | case NAL_UNIT_UNSPECIFIED_59: |
---|
2127 | case NAL_UNIT_UNSPECIFIED_60: |
---|
2128 | case NAL_UNIT_UNSPECIFIED_61: |
---|
2129 | case NAL_UNIT_UNSPECIFIED_62: |
---|
2130 | case NAL_UNIT_UNSPECIFIED_63: |
---|
2131 | |
---|
2132 | default: |
---|
2133 | assert (0); |
---|
2134 | } |
---|
2135 | |
---|
2136 | return false; |
---|
2137 | } |
---|
2138 | |
---|
2139 | /** Function for checking if picture should be skipped because of association with a previous BLA picture |
---|
2140 | * \param iPOCLastDisplay POC of last picture displayed |
---|
2141 | * \returns true if the picture should be skipped |
---|
2142 | * This function skips all TFD pictures that follow a BLA picture |
---|
2143 | * in decoding order and precede it in output order. |
---|
2144 | */ |
---|
2145 | Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) |
---|
2146 | { |
---|
2147 | if ((m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_N_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_RADL) && |
---|
2148 | m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) |
---|
2149 | { |
---|
2150 | iPOCLastDisplay++; |
---|
2151 | return true; |
---|
2152 | } |
---|
2153 | return false; |
---|
2154 | } |
---|
2155 | |
---|
2156 | /** Function for checking if picture should be skipped because of random access |
---|
2157 | * \param iSkipFrame skip frame counter |
---|
2158 | * \param iPOCLastDisplay POC of last picture displayed |
---|
2159 | * \returns true if the picture shold be skipped in the random access. |
---|
2160 | * This function checks the skipping of pictures in the case of -s option random access. |
---|
2161 | * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped. |
---|
2162 | * It also checks the type of Nal unit type at the random access point. |
---|
2163 | * If the random access point is CRA/CRANT/BLA/BLANT, TFD pictures with POC less than the POC of the random access point are skipped. |
---|
2164 | * If the random access point is IDR all pictures after the random access point are decoded. |
---|
2165 | * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC |
---|
2166 | * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random |
---|
2167 | * access point there is no guarantee that the decoder will not crash. |
---|
2168 | */ |
---|
2169 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
2170 | { |
---|
2171 | if (iSkipFrame) |
---|
2172 | { |
---|
2173 | iSkipFrame--; // decrement the counter |
---|
2174 | return true; |
---|
2175 | } |
---|
2176 | else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
2177 | { |
---|
2178 | if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA |
---|
2179 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
2180 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
2181 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ) |
---|
2182 | { |
---|
2183 | // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT. |
---|
2184 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); |
---|
2185 | } |
---|
2186 | else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
2187 | { |
---|
2188 | m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
2189 | } |
---|
2190 | else |
---|
2191 | { |
---|
2192 | static Bool warningMessage = false; |
---|
2193 | if(!warningMessage) |
---|
2194 | { |
---|
2195 | printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture"); |
---|
2196 | warningMessage = true; |
---|
2197 | } |
---|
2198 | return true; |
---|
2199 | } |
---|
2200 | } |
---|
2201 | // skip the reordered pictures, if necessary |
---|
2202 | else if (m_apcSlicePilot->getPOC() < m_pocRandomAccess && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) |
---|
2203 | { |
---|
2204 | iPOCLastDisplay++; |
---|
2205 | return true; |
---|
2206 | } |
---|
2207 | // if we reach here, then the picture is not skipped. |
---|
2208 | return false; |
---|
2209 | } |
---|
2210 | |
---|
2211 | #if SVC_EXTENSION |
---|
2212 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
2213 | TDecTop* TDecTop::getRefLayerDec( UInt refLayerIdc ) |
---|
2214 | { |
---|
2215 | TComVPS* vps = m_parameterSetManagerDecoder.getActiveVPS(); |
---|
2216 | if( vps->getNumDirectRefLayers( m_layerId ) <= 0 ) |
---|
2217 | { |
---|
2218 | return (TDecTop *)getLayerDec( 0 ); |
---|
2219 | } |
---|
2220 | |
---|
2221 | return (TDecTop *)getLayerDec( vps->getRefLayerId( m_layerId, refLayerIdc ) ); |
---|
2222 | } |
---|
2223 | #endif |
---|
2224 | |
---|
2225 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
2226 | Void TDecTop::setRefLayerParams( TComVPS* vps ) |
---|
2227 | { |
---|
2228 | for(UInt layer = 0; layer < m_numLayer; layer++) |
---|
2229 | { |
---|
2230 | TDecTop *decTop = (TDecTop *)getLayerDec(layer); |
---|
2231 | decTop->setNumSamplePredRefLayers(0); |
---|
2232 | decTop->setNumMotionPredRefLayers(0); |
---|
2233 | decTop->setNumDirectRefLayers(0); |
---|
2234 | for(Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1; i++) |
---|
2235 | { |
---|
2236 | decTop->setSamplePredEnabledFlag(i, false); |
---|
2237 | decTop->setMotionPredEnabledFlag(i, false); |
---|
2238 | decTop->setSamplePredRefLayerId(i, 0); |
---|
2239 | decTop->setMotionPredRefLayerId(i, 0); |
---|
2240 | } |
---|
2241 | for(Int j = 0; j < layer; j++) |
---|
2242 | { |
---|
2243 | if (vps->getDirectDependencyFlag(layer, j)) |
---|
2244 | { |
---|
2245 | decTop->setRefLayerId(decTop->getNumDirectRefLayers(), vps->getLayerIdInNuh(layer)); |
---|
2246 | decTop->setNumDirectRefLayers(decTop->getNumDirectRefLayers() + 1); |
---|
2247 | |
---|
2248 | Int samplePredEnabledFlag = (vps->getDirectDependencyType(layer, j) + 1) & 1; |
---|
2249 | decTop->setSamplePredEnabledFlag(j, samplePredEnabledFlag == 1 ? true : false); |
---|
2250 | decTop->setNumSamplePredRefLayers(decTop->getNumSamplePredRefLayers() + samplePredEnabledFlag); |
---|
2251 | |
---|
2252 | Int motionPredEnabledFlag = ((vps->getDirectDependencyType(layer, j) + 1) & 2) >> 1; |
---|
2253 | decTop->setMotionPredEnabledFlag(j, motionPredEnabledFlag == 1 ? true : false); |
---|
2254 | decTop->setNumMotionPredRefLayers(decTop->getNumMotionPredRefLayers() + motionPredEnabledFlag); |
---|
2255 | } |
---|
2256 | } |
---|
2257 | } |
---|
2258 | for ( Int i = 1, mIdx = 0, sIdx = 0; i < m_numLayer; i++ ) |
---|
2259 | { |
---|
2260 | Int iNuhLId = vps->getLayerIdInNuh(i); |
---|
2261 | TDecTop *decTop = (TDecTop *)getLayerDec(iNuhLId); |
---|
2262 | for ( Int j = 0; j < i; j++ ) |
---|
2263 | { |
---|
2264 | if (decTop->getMotionPredEnabledFlag(j)) |
---|
2265 | { |
---|
2266 | decTop->setMotionPredRefLayerId(mIdx++, vps->getLayerIdInNuh(j)); |
---|
2267 | } |
---|
2268 | if (decTop->getSamplePredEnabledFlag(j)) |
---|
2269 | { |
---|
2270 | decTop->setSamplePredRefLayerId(sIdx++, vps->getLayerIdInNuh(j)); |
---|
2271 | } |
---|
2272 | } |
---|
2273 | } |
---|
2274 | } |
---|
2275 | |
---|
2276 | #endif |
---|
2277 | |
---|
2278 | #if OUTPUT_LAYER_SET_INDEX |
---|
2279 | Void TDecTop::checkValueOfTargetOutputLayerSetIdx(TComVPS *vps) |
---|
2280 | { |
---|
2281 | CommonDecoderParams* params = this->getCommonDecoderParams(); |
---|
2282 | |
---|
2283 | assert( params->getTargetLayerId() < vps->getMaxLayers() ); |
---|
2284 | |
---|
2285 | if( params->getValueCheckedFlag() ) |
---|
2286 | { |
---|
2287 | return; // Already checked |
---|
2288 | } |
---|
2289 | if( params->getTargetOutputLayerSetIdx() == -1 ) // Output layer set index not specified |
---|
2290 | { |
---|
2291 | Bool layerSetMatchFound = false; |
---|
2292 | // Output layer set index not assigned. |
---|
2293 | // Based on the value of targetLayerId, check if any of the output layer matches |
---|
2294 | // Currently, the target layer ID in the encoder assumes that all the layers are decoded |
---|
2295 | // Check if any of the output layer sets match this description |
---|
2296 | for(Int i = 0; i < vps->getNumOutputLayerSets(); i++) |
---|
2297 | { |
---|
2298 | Bool layerSetMatchFlag = true; |
---|
2299 | Int layerSetIdx = vps->getOutputLayerSetIdx( i ); |
---|
2300 | if( vps->getNumLayersInIdList( layerSetIdx ) == params->getTargetLayerId() + 1 ) |
---|
2301 | { |
---|
2302 | for(Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++) |
---|
2303 | { |
---|
2304 | if( vps->getLayerSetLayerIdList( layerSetIdx, j ) != j ) |
---|
2305 | { |
---|
2306 | layerSetMatchFlag = false; |
---|
2307 | break; |
---|
2308 | } |
---|
2309 | } |
---|
2310 | } |
---|
2311 | else |
---|
2312 | { |
---|
2313 | layerSetMatchFlag = false; |
---|
2314 | } |
---|
2315 | |
---|
2316 | if( layerSetMatchFlag ) // Potential output layer set candidate found |
---|
2317 | { |
---|
2318 | // If target dec layer ID list is also included - check if they match |
---|
2319 | if( params->getTargetDecLayerIdSet() ) |
---|
2320 | { |
---|
2321 | if( params->getTargetDecLayerIdSet()->size() ) |
---|
2322 | { |
---|
2323 | for(Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++) |
---|
2324 | { |
---|
2325 | if( *(params->getTargetDecLayerIdSet()->begin() + j) != vps->getLayerIdInNuh(vps->getLayerSetLayerIdList( layerSetIdx, j ))) |
---|
2326 | { |
---|
2327 | layerSetMatchFlag = false; |
---|
2328 | } |
---|
2329 | } |
---|
2330 | } |
---|
2331 | } |
---|
2332 | if( layerSetMatchFlag ) // The target dec layer ID list also matches, if present |
---|
2333 | { |
---|
2334 | // Match found |
---|
2335 | layerSetMatchFound = true; |
---|
2336 | params->setTargetOutputLayerSetIdx( i ); |
---|
2337 | params->setValueCheckedFlag( true ); |
---|
2338 | break; |
---|
2339 | } |
---|
2340 | } |
---|
2341 | } |
---|
2342 | assert( layerSetMatchFound ); // No output layer set matched the value of either targetLayerId or targetdeclayerIdlist |
---|
2343 | } |
---|
2344 | else // Output layer set index is assigned - check if the values match |
---|
2345 | { |
---|
2346 | // Check if the target decoded layer is the highest layer in the list |
---|
2347 | assert( params->getTargetOutputLayerSetIdx() < vps->getNumLayerSets() ); |
---|
2348 | Int layerSetIdx = vps->getOutputLayerSetIdx( params->getTargetOutputLayerSetIdx() ); // Index to the layer set |
---|
2349 | assert( params->getTargetLayerId() == vps->getNumLayersInIdList( layerSetIdx ) - 1); |
---|
2350 | |
---|
2351 | Bool layerSetMatchFlag = true; |
---|
2352 | for(Int j = 0; j < vps->getNumLayersInIdList( layerSetIdx ); j++) |
---|
2353 | { |
---|
2354 | if( vps->getLayerSetLayerIdList( layerSetIdx, j ) != j ) |
---|
2355 | { |
---|
2356 | layerSetMatchFlag = false; |
---|
2357 | break; |
---|
2358 | } |
---|
2359 | } |
---|
2360 | |
---|
2361 | assert(layerSetMatchFlag); // Signaled output layer set index does not match targetOutputLayerId. |
---|
2362 | |
---|
2363 | // Check if the targetdeclayerIdlist matches the output layer set |
---|
2364 | if( params->getTargetDecLayerIdSet() ) |
---|
2365 | { |
---|
2366 | if( params->getTargetDecLayerIdSet()->size() ) |
---|
2367 | { |
---|
2368 | for(Int i = 0; i < vps->getNumLayersInIdList( layerSetIdx ); i++) |
---|
2369 | { |
---|
2370 | assert( *(params->getTargetDecLayerIdSet()->begin() + i) == vps->getLayerIdInNuh(vps->getLayerSetLayerIdList( layerSetIdx, i ))); |
---|
2371 | } |
---|
2372 | } |
---|
2373 | } |
---|
2374 | params->setValueCheckedFlag( true ); |
---|
2375 | |
---|
2376 | } |
---|
2377 | } |
---|
2378 | #endif |
---|
2379 | #if RESOLUTION_BASED_DPB |
---|
2380 | Void TDecTop::assignSubDpbs(TComVPS *vps) |
---|
2381 | { |
---|
2382 | if( m_subDpbIdx == -1 ) // Sub-DPB index is not already assigned |
---|
2383 | { |
---|
2384 | Int lsIdx = vps->getOutputLayerSetIdx( getCommonDecoderParams()->getTargetOutputLayerSetIdx() ); |
---|
2385 | |
---|
2386 | Int layerIdx = vps->findLayerIdxInLayerSet( lsIdx, getLayerId() ); |
---|
2387 | assert( layerIdx != -1 ); // Current layer should be found in the layer set. |
---|
2388 | |
---|
2389 | // Copy from the active VPS based on the layer ID. |
---|
2390 | m_subDpbIdx = vps->getSubDpbAssigned( lsIdx, layerIdx ); |
---|
2391 | } |
---|
2392 | } |
---|
2393 | #endif |
---|
2394 | |
---|
2395 | #if Q0048_CGS_3D_ASYMLUT |
---|
2396 | Void TDecTop::initAsymLut(TComSlice *pcSlice) |
---|
2397 | { |
---|
2398 | if(m_layerId>0) |
---|
2399 | { |
---|
2400 | if(!m_pColorMappedPic) |
---|
2401 | { |
---|
2402 | Int picWidth = pcSlice->getPicWidthInLumaSamples(); |
---|
2403 | Int picHeight = pcSlice->getPicHeightInLumaSamples(); |
---|
2404 | m_pColorMappedPic = new TComPicYuv; |
---|
2405 | m_pColorMappedPic->create( picWidth, picHeight, pcSlice->getChromaFormatIdc()/*CHROMA_420*/, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL ); |
---|
2406 | } |
---|
2407 | } |
---|
2408 | } |
---|
2409 | #endif |
---|
2410 | |
---|
2411 | #endif //SVC_EXTENSION |
---|
2412 | |
---|
2413 | #if Q0074_SEI_COLOR_MAPPING |
---|
2414 | TDecColorMapping::TDecColorMapping() |
---|
2415 | { |
---|
2416 | m_pcColorMappingPic[0] = NULL; |
---|
2417 | m_pcColorMappingPic[1] = NULL; |
---|
2418 | |
---|
2419 | m_colorMapCancelFlag = true; |
---|
2420 | |
---|
2421 | for( Int i=0 ; i<3 ; i++ ) |
---|
2422 | { |
---|
2423 | m_lut1d_computed[i] = false; |
---|
2424 | m_lut1d_input[i] = NULL; |
---|
2425 | m_coded_input_pivot_value[i] = NULL; |
---|
2426 | m_target_input_pivot_value[i] = NULL; |
---|
2427 | } |
---|
2428 | for( Int i=0 ; i<3 ; i++ ) |
---|
2429 | { |
---|
2430 | m_lut1d_output[i] = NULL; |
---|
2431 | m_coded_output_pivot_value[i] = NULL; |
---|
2432 | m_target_output_pivot_value[i] = NULL; |
---|
2433 | } |
---|
2434 | } |
---|
2435 | |
---|
2436 | TDecColorMapping::~TDecColorMapping() |
---|
2437 | { |
---|
2438 | if ( m_pcColorMappingPic[0] ) delete m_pcColorMappingPic[0]; |
---|
2439 | if ( m_pcColorMappingPic[1] ) delete m_pcColorMappingPic[1]; |
---|
2440 | |
---|
2441 | for( Int i=0 ; i<3 ; i++ ) |
---|
2442 | { |
---|
2443 | if ( m_lut1d_input[i] ) delete m_lut1d_input[i]; |
---|
2444 | if ( m_coded_input_pivot_value[i] ) delete m_coded_input_pivot_value[i]; |
---|
2445 | if ( m_target_input_pivot_value[i] ) delete m_target_input_pivot_value[i]; |
---|
2446 | } |
---|
2447 | for( Int i=0 ; i<3 ; i++ ) |
---|
2448 | { |
---|
2449 | if ( m_lut1d_output[i] ) delete m_lut1d_output[i]; |
---|
2450 | if ( m_coded_output_pivot_value[i] ) delete m_coded_output_pivot_value[i]; |
---|
2451 | if ( m_target_output_pivot_value[i] ) delete m_target_output_pivot_value[i]; |
---|
2452 | } |
---|
2453 | } |
---|
2454 | |
---|
2455 | Void TDecColorMapping::setColorMapping( SEIMessages m_SEIs ) |
---|
2456 | { |
---|
2457 | SEIMessages colorMappingInfo = getSeisByType(m_SEIs, SEI::COLOR_MAPPING_INFO) ; |
---|
2458 | SEIColorMappingInfo *seiColorMappingInfo = NULL; |
---|
2459 | if (colorMappingInfo.size() !=0) |
---|
2460 | { |
---|
2461 | seiColorMappingInfo = (SEIColorMappingInfo*)(*colorMappingInfo.begin()); |
---|
2462 | |
---|
2463 | m_colorMapId = seiColorMappingInfo->m_colorMapId; |
---|
2464 | m_colorMapCancelFlag = seiColorMappingInfo->m_colorMapCancelFlag; |
---|
2465 | if( !m_colorMapCancelFlag ) |
---|
2466 | { |
---|
2467 | m_colorMapPersistenceFlag = seiColorMappingInfo->m_colorMapPersistenceFlag; |
---|
2468 | m_colorMap_video_signal_type_present_flag = seiColorMappingInfo->m_colorMap_video_signal_type_present_flag; |
---|
2469 | m_colorMap_video_full_range_flag = seiColorMappingInfo->m_colorMap_video_full_range_flag; |
---|
2470 | m_colorMap_primaries = seiColorMappingInfo->m_colorMap_primaries; |
---|
2471 | m_colorMap_transfer_characteristics = seiColorMappingInfo->m_colorMap_transfer_characteristics; |
---|
2472 | m_colorMap_matrix_coeffs = seiColorMappingInfo->m_colorMap_matrix_coeffs; |
---|
2473 | m_colorMapModelId = seiColorMappingInfo->m_colorMapModelId; |
---|
2474 | |
---|
2475 | m_colour_map_coded_data_bit_depth = seiColorMappingInfo->m_colour_map_coded_data_bit_depth; |
---|
2476 | m_colour_map_target_bit_depth = seiColorMappingInfo->m_colour_map_target_bit_depth; |
---|
2477 | |
---|
2478 | for( Int i=0 ; i<3 ; i++ ) |
---|
2479 | { |
---|
2480 | m_num_input_pivots[i] = seiColorMappingInfo->m_num_input_pivots[i]; |
---|
2481 | if ( m_coded_input_pivot_value[i] ) delete m_coded_input_pivot_value[i]; |
---|
2482 | if ( m_target_input_pivot_value[i] ) delete m_target_input_pivot_value[i]; |
---|
2483 | m_coded_input_pivot_value[i] = new Int[ m_num_input_pivots[i] ]; |
---|
2484 | m_target_input_pivot_value[i] = new Int[ m_num_input_pivots[i] ]; |
---|
2485 | for( Int j=0 ; j<m_num_input_pivots[i] ; j++ ) |
---|
2486 | { |
---|
2487 | m_coded_input_pivot_value[i][j] = seiColorMappingInfo->m_coded_input_pivot_value[i][j]; |
---|
2488 | m_target_input_pivot_value[i][j] = seiColorMappingInfo->m_target_input_pivot_value[i][j]; |
---|
2489 | } |
---|
2490 | } |
---|
2491 | |
---|
2492 | m_matrix_flag = seiColorMappingInfo->m_matrix_flag; |
---|
2493 | m_log2_matrix_denom = m_matrix_flag ? (seiColorMappingInfo->m_log2_matrix_denom) : (0) ; |
---|
2494 | for( Int i=0 ; i<3 ; i++ ) |
---|
2495 | { |
---|
2496 | for( Int j=0 ; j<3 ; j++ ) |
---|
2497 | { |
---|
2498 | m_matrix_coef[i][j] = seiColorMappingInfo->m_matrix_coef[i][j]; |
---|
2499 | } |
---|
2500 | } |
---|
2501 | |
---|
2502 | for( Int i=0 ; i<3 ; i++ ) |
---|
2503 | { |
---|
2504 | m_num_output_pivots[i] = seiColorMappingInfo->m_num_output_pivots[i]; |
---|
2505 | if ( m_coded_output_pivot_value[i] ) delete m_coded_output_pivot_value[i]; |
---|
2506 | if ( m_target_output_pivot_value[i] ) delete m_target_output_pivot_value[i]; |
---|
2507 | m_coded_output_pivot_value[i] = new Int[ m_num_output_pivots[i] ]; |
---|
2508 | m_target_output_pivot_value[i] = new Int[ m_num_output_pivots[i] ]; |
---|
2509 | for( Int j=0 ; j<m_num_output_pivots[i] ; j++ ) |
---|
2510 | { |
---|
2511 | m_coded_output_pivot_value[i][j] = seiColorMappingInfo->m_coded_output_pivot_value[i][j]; |
---|
2512 | m_target_output_pivot_value[i][j] = seiColorMappingInfo->m_target_output_pivot_value[i][j]; |
---|
2513 | } |
---|
2514 | } |
---|
2515 | |
---|
2516 | memset( m_lut1d_computed, 0, sizeof( m_lut1d_computed ) ); |
---|
2517 | } |
---|
2518 | } |
---|
2519 | |
---|
2520 | } |
---|
2521 | |
---|
2522 | Void TDecColorMapping::setColorMapping( Int bitDepth, Int iComp ) |
---|
2523 | { |
---|
2524 | if( !m_colorMapCancelFlag && !m_lut1d_computed[iComp] ) |
---|
2525 | { |
---|
2526 | |
---|
2527 | if ( m_lut1d_input[iComp] ) delete m_lut1d_input[iComp]; |
---|
2528 | if ( m_lut1d_output[iComp] ) delete m_lut1d_output[iComp]; |
---|
2529 | |
---|
2530 | m_lut1d_input[iComp] = new Int[ 1 << bitDepth ]; |
---|
2531 | m_lut1d_output[iComp] = new Int[ 1 << bitDepth ]; |
---|
2532 | |
---|
2533 | Int iShift = (m_colour_map_coded_data_bit_depth >= bitDepth) ? (m_colour_map_coded_data_bit_depth - bitDepth) : (0); |
---|
2534 | Int iShiftPivot = (m_colour_map_coded_data_bit_depth >= bitDepth) ? (0) : (bitDepth - m_colour_map_coded_data_bit_depth); |
---|
2535 | |
---|
2536 | for( Int k=0 ; k<(1<<bitDepth) ; k++ ) |
---|
2537 | { |
---|
2538 | Int iSample = k << iShift ; |
---|
2539 | if( m_num_input_pivots[iComp] > 1 ) |
---|
2540 | { |
---|
2541 | for( Int iPivot=0 ; iPivot<m_num_input_pivots[iComp] ; iPivot++ ) |
---|
2542 | { |
---|
2543 | Int iCodedPrev = m_coded_input_pivot_value[iComp][iPivot] << iShiftPivot; |
---|
2544 | Int iCodedNext = m_coded_input_pivot_value[iComp][iPivot+1] << iShiftPivot; |
---|
2545 | Int iTargetPrev = m_target_input_pivot_value[iComp][iPivot] << iShiftPivot; |
---|
2546 | Int iTargetNext = m_target_input_pivot_value[iComp][iPivot+1] << iShiftPivot; |
---|
2547 | if ( iCodedPrev <= iSample && iSample < iCodedNext ) |
---|
2548 | { |
---|
2549 | Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) / (Float)(iCodedNext - iCodedPrev) ; |
---|
2550 | m_lut1d_input[iComp][k] = (Int)( 0.5 + fInterpol ); |
---|
2551 | iPivot = m_num_input_pivots[iComp]; // stop |
---|
2552 | } |
---|
2553 | } |
---|
2554 | } |
---|
2555 | else |
---|
2556 | { |
---|
2557 | m_lut1d_input[iComp][k] = k; |
---|
2558 | } |
---|
2559 | } |
---|
2560 | |
---|
2561 | iShift = ( (m_colour_map_coded_data_bit_depth >= bitDepth) ? (m_colour_map_coded_data_bit_depth - bitDepth) : (0) ); |
---|
2562 | Int iOffset = iShift ? (1 << (iShift - 1)) : (0) ; |
---|
2563 | iShiftPivot = (m_colour_map_target_bit_depth >= bitDepth) ? (0) : (bitDepth - m_colour_map_target_bit_depth) ; |
---|
2564 | for( Int k=0 ; k<(1<<bitDepth) ; k++ ) |
---|
2565 | { |
---|
2566 | Int iSample = k << iShift; |
---|
2567 | if ( m_num_output_pivots[iComp]>1 ) |
---|
2568 | { |
---|
2569 | for( Int iPivot=0 ; iPivot<m_num_output_pivots[iComp] ; iPivot++ ) |
---|
2570 | { |
---|
2571 | Int iCodedPrev = m_coded_output_pivot_value[iComp][iPivot] << iShiftPivot; |
---|
2572 | Int iCodedNext = m_coded_output_pivot_value[iComp][iPivot+1] << iShiftPivot; |
---|
2573 | Int iTargetPrev = m_target_output_pivot_value[iComp][iPivot] << iShiftPivot; |
---|
2574 | Int iTargetNext = m_target_output_pivot_value[iComp][iPivot+1] << iShiftPivot; |
---|
2575 | if ( iCodedPrev <= iSample && iSample < iCodedNext ) |
---|
2576 | { |
---|
2577 | Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) / (Float)(iCodedNext - iCodedPrev) ; |
---|
2578 | m_lut1d_output[iComp][k] = ( (Int)(0.5 + fInterpol) + iOffset ) >> iShift ; |
---|
2579 | iPivot = m_num_output_pivots[iComp]; // stop |
---|
2580 | } |
---|
2581 | } |
---|
2582 | } |
---|
2583 | else |
---|
2584 | { |
---|
2585 | m_lut1d_output[iComp][k] = k; |
---|
2586 | } |
---|
2587 | } |
---|
2588 | |
---|
2589 | m_lut1d_computed[iComp] = true; |
---|
2590 | } |
---|
2591 | |
---|
2592 | } |
---|
2593 | |
---|
2594 | TComPicYuv* TDecColorMapping::getColorMapping( TComPicYuv* pPicYuvRec, Int iTop, Int curlayerId ) |
---|
2595 | { |
---|
2596 | if( !m_colorMapCancelFlag ) |
---|
2597 | { |
---|
2598 | if( !m_pcColorMappingPic[iTop] ) |
---|
2599 | { |
---|
2600 | m_pcColorMappingPic[iTop] = new TComPicYuv; |
---|
2601 | #if SVC_EXTENSION |
---|
2602 | m_pcColorMappingPic[iTop]->create( pPicYuvRec->getWidth(), pPicYuvRec->getHeight(), pPicYuvRec->getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
2603 | #else |
---|
2604 | m_pcColorMappingPic[iTop]->create( pPicYuvRec->getWidth(), pPicYuvRec->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); |
---|
2605 | #endif |
---|
2606 | } |
---|
2607 | |
---|
2608 | Int iHeight = pPicYuvRec->getHeight(); |
---|
2609 | Int iWidth = pPicYuvRec->getWidth(); |
---|
2610 | Int iStride = pPicYuvRec->getStride(); |
---|
2611 | Int iCStride = pPicYuvRec->getCStride(); |
---|
2612 | |
---|
2613 | Pel* Lum0 = pPicYuvRec->getLumaAddr(); |
---|
2614 | Pel* Cb0 = pPicYuvRec->getCbAddr(); |
---|
2615 | Pel* Cr0 = pPicYuvRec->getCrAddr(); |
---|
2616 | Pel* Lum1 = m_pcColorMappingPic[iTop]->getLumaAddr(); |
---|
2617 | Pel* Cb1 = m_pcColorMappingPic[iTop]->getCbAddr(); |
---|
2618 | Pel* Cr1 = m_pcColorMappingPic[iTop]->getCrAddr(); |
---|
2619 | |
---|
2620 | #if SVC_EXTENSION |
---|
2621 | Int bitDepthY = g_bitDepthYLayer[curlayerId]; |
---|
2622 | Int bitDepthC = g_bitDepthCLayer[curlayerId]; |
---|
2623 | |
---|
2624 | assert( g_bitDepthY == bitDepthY ); |
---|
2625 | assert( g_bitDepthC == bitDepthC ); |
---|
2626 | #else |
---|
2627 | Int bitDepthY = g_bitDepthY; |
---|
2628 | Int bitDepthC = g_bitDepthC; |
---|
2629 | #endif |
---|
2630 | |
---|
2631 | Int iYShift = (m_colour_map_target_bit_depth >= bitDepthY) ? (m_colour_map_target_bit_depth - bitDepthY) : (0) ; |
---|
2632 | Int iCShift = (m_colour_map_target_bit_depth >= bitDepthC) ? (m_colour_map_target_bit_depth - bitDepthC) : (0) ; |
---|
2633 | Int offsetY = (1 << (m_log2_matrix_denom+iYShift - 1)); |
---|
2634 | Int offsetC = (1 << (m_log2_matrix_denom+iCShift - 1)); |
---|
2635 | |
---|
2636 | Int cShift = 1 ; |
---|
2637 | |
---|
2638 | //Pel* LumPrev0 = Lum0; |
---|
2639 | for( Int y = 0; y < iHeight ; y++ ) |
---|
2640 | { |
---|
2641 | Bool bDoChroma = (y % 2); |
---|
2642 | for( Int x = 0; x < iWidth ; x++ ) |
---|
2643 | { |
---|
2644 | Int s1Y = m_lut1d_input[0][ Lum0[x] ]; |
---|
2645 | Int s1U = m_lut1d_input[1][ Cb0[x>>1] ]; |
---|
2646 | Int s1V = m_lut1d_input[2][ Cr0[x>>1] ]; |
---|
2647 | |
---|
2648 | Int s2Y, s2U, s2V; |
---|
2649 | if( m_matrix_flag ) |
---|
2650 | { |
---|
2651 | s2Y = ( m_matrix_coef[0][0]*s1Y + m_matrix_coef[0][1]*s1U + m_matrix_coef[0][2]*s1V + offsetY ) >> ( m_log2_matrix_denom + iYShift ); |
---|
2652 | //s2Y = ClipBD( s2Y , bitDepthY ); |
---|
2653 | s2Y = ClipY( s2Y ); |
---|
2654 | Lum1[x] = m_lut1d_output[0][ s2Y ]; |
---|
2655 | } |
---|
2656 | else |
---|
2657 | { |
---|
2658 | s1Y = ( s1Y + offsetY ) >> iYShift ; |
---|
2659 | //s1Y = ClipBD( s1Y , bitDepthY ); |
---|
2660 | s1Y = ClipY( s1Y ); |
---|
2661 | Lum1[x] = m_lut1d_output[0][ s1Y ]; |
---|
2662 | } |
---|
2663 | |
---|
2664 | if( bDoChroma && (x%2) ) |
---|
2665 | { |
---|
2666 | if( m_matrix_flag ) |
---|
2667 | { |
---|
2668 | //s1Y = ( m_lut1d_input[0][ Lum0[x] ] + m_lut1d_input[0][ Lum0[x+1] ] + m_lut1d_input[0][ LumPrev0[x] ] + m_lut1d_input[0][ LumPrev0[x+1] ] + 2 ) >> 2 ; |
---|
2669 | //s1Y = m_lut1d_input[0][ (Lum0[x] + Lum0[x+1] + LumPrev0[x] + LumPrev0[x+1] + 2)>>2 ] ; |
---|
2670 | s1Y = m_lut1d_input[0][ Lum0[x] ]; |
---|
2671 | |
---|
2672 | s2U = ( m_matrix_coef[1][0]*s1Y + m_matrix_coef[1][1]*s1U + m_matrix_coef[1][2]*s1V + offsetC ) >> ( m_log2_matrix_denom + iCShift ) ; |
---|
2673 | s2V = ( m_matrix_coef[2][0]*s1Y + m_matrix_coef[2][1]*s1U + m_matrix_coef[2][2]*s1V + offsetC ) >> ( m_log2_matrix_denom + iCShift ) ; |
---|
2674 | //s2U = ClipBD( s2U , bitDepthC ); |
---|
2675 | //s2V = ClipBD( s2V , bitDepthC ); |
---|
2676 | s2U = ClipC( s2U ); |
---|
2677 | s2V = ClipC( s2V ); |
---|
2678 | Cb1[x>>cShift] = m_lut1d_output[1][ s2U ]; |
---|
2679 | Cr1[x>>cShift] = m_lut1d_output[2][ s2V ]; |
---|
2680 | } |
---|
2681 | else |
---|
2682 | { |
---|
2683 | s1U = ( s1U + offsetC ) >> iCShift ; |
---|
2684 | s1V = ( s1V + offsetC ) >> iCShift ; |
---|
2685 | //s1U = ClipBD( s1U , bitDepthC ); |
---|
2686 | //s1V = ClipBD( s1V , bitDepthC ); |
---|
2687 | s1U = ClipC( s1U ); |
---|
2688 | s1V = ClipC( s1V ); |
---|
2689 | Cb1[x>>cShift] = m_lut1d_output[1][ s1U ]; |
---|
2690 | Cr1[x>>cShift] = m_lut1d_output[2][ s1V ]; |
---|
2691 | } |
---|
2692 | } |
---|
2693 | |
---|
2694 | } |
---|
2695 | |
---|
2696 | //LumPrev0 = Lum0; |
---|
2697 | Lum0 += iStride; |
---|
2698 | Lum1 += iStride; |
---|
2699 | if( bDoChroma ) |
---|
2700 | { |
---|
2701 | Cb0 += iCStride; |
---|
2702 | Cr0 += iCStride; |
---|
2703 | Cb1 += iCStride; |
---|
2704 | Cr1 += iCStride; |
---|
2705 | } |
---|
2706 | } |
---|
2707 | |
---|
2708 | return m_pcColorMappingPic[iTop]; |
---|
2709 | } |
---|
2710 | |
---|
2711 | return pPicYuvRec; |
---|
2712 | } |
---|
2713 | #endif |
---|
2714 | |
---|
2715 | //! \} |
---|