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