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-2017, 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 | #include "NALread.h" |
---|
38 | #include "TDecTop.h" |
---|
39 | #include "TDecConformance.h" |
---|
40 | |
---|
41 | #if NH_MV |
---|
42 | ParameterSetManager TDecTop::m_parameterSetManager; |
---|
43 | #endif |
---|
44 | |
---|
45 | //! \ingroup TLibDecoder |
---|
46 | //! \{ |
---|
47 | |
---|
48 | #if NH_3D |
---|
49 | CamParsCollector::CamParsCollector() |
---|
50 | : m_bInitialized( false ) |
---|
51 | { |
---|
52 | m_aaiCodedOffset = new Int* [ MAX_NUM_LAYERS ]; |
---|
53 | m_aaiCodedScale = new Int* [ MAX_NUM_LAYERS ]; |
---|
54 | for( UInt uiId = 0; uiId < MAX_NUM_LAYERS; uiId++ ) |
---|
55 | { |
---|
56 | m_aaiCodedOffset [ uiId ] = new Int [ MAX_NUM_LAYERS ]; |
---|
57 | m_aaiCodedScale [ uiId ] = new Int [ MAX_NUM_LAYERS ]; |
---|
58 | } |
---|
59 | |
---|
60 | xCreateLUTs( (UInt)MAX_NUM_LAYERS, (UInt)MAX_NUM_LAYERS, m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT ); |
---|
61 | m_iLog2Precision = LOG2_DISP_PREC_LUT; |
---|
62 | m_uiBitDepthForLUT = 8; // fixed |
---|
63 | m_receivedIdc = NULL; |
---|
64 | m_vps = NULL; |
---|
65 | } |
---|
66 | |
---|
67 | CamParsCollector::~CamParsCollector() |
---|
68 | { |
---|
69 | for( UInt uiId = 0; uiId < MAX_NUM_LAYERS; uiId++ ) |
---|
70 | { |
---|
71 | delete [] m_aaiCodedOffset [ uiId ]; |
---|
72 | delete [] m_aaiCodedScale [ uiId ]; |
---|
73 | } |
---|
74 | delete [] m_aaiCodedOffset; |
---|
75 | delete [] m_aaiCodedScale; |
---|
76 | |
---|
77 | xDeleteArray( m_adBaseViewShiftLUT, MAX_NUM_LAYERS, MAX_NUM_LAYERS, 2 ); |
---|
78 | xDeleteArray( m_aiBaseViewShiftLUT, MAX_NUM_LAYERS, MAX_NUM_LAYERS, 2 ); |
---|
79 | if ( m_receivedIdc != NULL ) |
---|
80 | { |
---|
81 | xDeleteArray( m_receivedIdc, m_vps->getNumViews() ); |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | |
---|
86 | Void |
---|
87 | CamParsCollector::init( const TComVPS* vps) |
---|
88 | { |
---|
89 | assert( !isInitialized() ); // Only one initialization currently supported |
---|
90 | m_bInitialized = true; |
---|
91 | m_vps = vps; |
---|
92 | m_bCamParsVaryOverTime = false; |
---|
93 | m_lastPoc = -1; |
---|
94 | m_firstReceivedPoc = -2; |
---|
95 | |
---|
96 | for (Int i = 0; i <= vps->getMaxLayersMinus1(); i++) |
---|
97 | { |
---|
98 | Int curViewIdxInVps = m_vps->getVoiInVps( m_vps->getViewIndex( m_vps->getLayerIdInNuh( i ) ) ) ; |
---|
99 | m_bCamParsVaryOverTime = m_bCamParsVaryOverTime || vps->getCpInSliceSegmentHeaderFlag( curViewIdxInVps ); |
---|
100 | } |
---|
101 | |
---|
102 | assert( m_receivedIdc == NULL ); |
---|
103 | m_receivedIdc = new Int*[ m_vps->getNumViews() ]; |
---|
104 | for (Int i = 0; i < m_vps->getNumViews(); i++) |
---|
105 | { |
---|
106 | m_receivedIdc[i] = new Int[ m_vps->getNumViews() ]; |
---|
107 | } |
---|
108 | |
---|
109 | xResetReceivedIdc( true ); |
---|
110 | |
---|
111 | for (Int voiInVps = 0; voiInVps < m_vps->getNumViews(); voiInVps++ ) |
---|
112 | { |
---|
113 | if( !m_vps->getCpInSliceSegmentHeaderFlag( voiInVps ) ) |
---|
114 | { |
---|
115 | for (Int baseVoiInVps = 0; baseVoiInVps < m_vps->getNumViews(); baseVoiInVps++ ) |
---|
116 | { |
---|
117 | if( m_vps->getCpPresentFlag( voiInVps, baseVoiInVps ) ) |
---|
118 | { |
---|
119 | m_receivedIdc [ baseVoiInVps ][ voiInVps ] = -1; |
---|
120 | m_aaiCodedScale [ baseVoiInVps ][ voiInVps ] = m_vps->getCodedScale (voiInVps) [ baseVoiInVps ]; |
---|
121 | m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ] = m_vps->getCodedOffset (voiInVps) [ baseVoiInVps ]; |
---|
122 | |
---|
123 | m_receivedIdc [ voiInVps ][ baseVoiInVps ] = -1; |
---|
124 | m_aaiCodedScale [ voiInVps ][ baseVoiInVps ] = m_vps->getInvCodedScale (voiInVps) [ baseVoiInVps ]; |
---|
125 | m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ] = m_vps->getInvCodedOffset(voiInVps) [ baseVoiInVps ]; |
---|
126 | xInitLUTs( baseVoiInVps, voiInVps, m_aaiCodedScale[ baseVoiInVps ][ voiInVps ], m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT ); |
---|
127 | xInitLUTs( voiInVps, baseVoiInVps, m_aaiCodedScale[ voiInVps ][ baseVoiInVps ], m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT ); |
---|
128 | } |
---|
129 | } |
---|
130 | } |
---|
131 | } |
---|
132 | } |
---|
133 | |
---|
134 | Void |
---|
135 | CamParsCollector::xResetReceivedIdc( Bool overWriteFlag ) |
---|
136 | { |
---|
137 | for (Int i = 0; i < m_vps->getNumViews(); i++) |
---|
138 | { |
---|
139 | for (Int j = 0; j < m_vps->getNumViews(); j++) |
---|
140 | { |
---|
141 | if ( overWriteFlag || ( m_receivedIdc[i][j] != -1 ) ) |
---|
142 | { |
---|
143 | m_receivedIdc[i][j] = 0; |
---|
144 | } |
---|
145 | } |
---|
146 | } |
---|
147 | } |
---|
148 | |
---|
149 | |
---|
150 | Void |
---|
151 | CamParsCollector::xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT) |
---|
152 | { |
---|
153 | |
---|
154 | uiNumberSourceViews = std::max( (UInt) 1, uiNumberSourceViews ); |
---|
155 | uiNumberTargetViews = std::max( (UInt) 1, uiNumberTargetViews ); |
---|
156 | |
---|
157 | radLUT = new Double***[ uiNumberSourceViews ]; |
---|
158 | raiLUT = new Int ***[ uiNumberSourceViews ]; |
---|
159 | |
---|
160 | for( UInt uiSourceView = 0; uiSourceView < uiNumberSourceViews; uiSourceView++ ) |
---|
161 | { |
---|
162 | radLUT [ uiSourceView ] = new Double**[ uiNumberTargetViews ]; |
---|
163 | raiLUT [ uiSourceView ] = new Int **[ uiNumberTargetViews ]; |
---|
164 | |
---|
165 | for( UInt uiTargetView = 0; uiTargetView < uiNumberTargetViews; uiTargetView++ ) |
---|
166 | { |
---|
167 | radLUT [ uiSourceView ][ uiTargetView ] = new Double*[ 2 ]; |
---|
168 | radLUT [ uiSourceView ][ uiTargetView ][ 0 ] = new Double [ 257 ]; |
---|
169 | radLUT [ uiSourceView ][ uiTargetView ][ 1 ] = new Double [ 257 ]; |
---|
170 | |
---|
171 | raiLUT [ uiSourceView ][ uiTargetView ] = new Int* [ 2 ]; |
---|
172 | raiLUT [ uiSourceView ][ uiTargetView ][ 0 ] = new Int [ 257 ]; |
---|
173 | raiLUT [ uiSourceView ][ uiTargetView ][ 1 ] = new Int [ 257 ]; |
---|
174 | } |
---|
175 | } |
---|
176 | } |
---|
177 | |
---|
178 | Void |
---|
179 | CamParsCollector::xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT) |
---|
180 | { |
---|
181 | Int iLog2DivLuma = m_uiBitDepthForLUT + m_vps->getCpPrecision() + 1 - m_iLog2Precision; AOF( iLog2DivLuma > 0 ); |
---|
182 | Int iLog2DivChroma = iLog2DivLuma + 1; |
---|
183 | |
---|
184 | iOffset <<= m_uiBitDepthForLUT; |
---|
185 | |
---|
186 | Double dScale = (Double) iScale / (( Double ) ( 1 << iLog2DivLuma )); |
---|
187 | Double dOffset = (Double) iOffset / (( Double ) ( 1 << iLog2DivLuma )); |
---|
188 | |
---|
189 | // offsets including rounding offsets |
---|
190 | Int64 iOffsetLuma = iOffset + ( ( 1 << iLog2DivLuma ) >> 1 ); |
---|
191 | Int64 iOffsetChroma = iOffset + ( ( 1 << iLog2DivChroma ) >> 1 ); |
---|
192 | |
---|
193 | |
---|
194 | for( UInt uiDepthValue = 0; uiDepthValue < 256; uiDepthValue++ ) |
---|
195 | { |
---|
196 | |
---|
197 | // real-valued look-up tables |
---|
198 | Double dShiftLuma = ( (Double)uiDepthValue * dScale + dOffset ) * Double( 1 << m_iLog2Precision ); |
---|
199 | Double dShiftChroma = dShiftLuma / 2; |
---|
200 | radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = dShiftLuma; |
---|
201 | radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = dShiftChroma; |
---|
202 | |
---|
203 | // integer-valued look-up tables |
---|
204 | Int64 iTempScale = (Int64)uiDepthValue * iScale; |
---|
205 | Int64 iShiftLuma = ( iTempScale + iOffsetLuma ) >> iLog2DivLuma; |
---|
206 | Int64 iShiftChroma = ( iTempScale + iOffsetChroma ) >> iLog2DivChroma; |
---|
207 | raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = (Int)iShiftLuma; |
---|
208 | raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = (Int)iShiftChroma; |
---|
209 | } |
---|
210 | |
---|
211 | radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ]; |
---|
212 | radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ]; |
---|
213 | raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ]; |
---|
214 | raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ]; |
---|
215 | } |
---|
216 | |
---|
217 | Void |
---|
218 | CamParsCollector::uninit() |
---|
219 | { |
---|
220 | m_bInitialized = false; |
---|
221 | } |
---|
222 | |
---|
223 | Void CamParsCollector::setSlice( const TComSlice* pcSlice ) |
---|
224 | { |
---|
225 | if( pcSlice == 0 ) |
---|
226 | { |
---|
227 | xOutput( m_lastPoc ); |
---|
228 | return; |
---|
229 | } |
---|
230 | |
---|
231 | if ( pcSlice->getIsDepth()) |
---|
232 | { |
---|
233 | return; |
---|
234 | } |
---|
235 | |
---|
236 | Int curPoc = pcSlice->getPOC(); |
---|
237 | if( m_firstReceivedPoc == -2 ) |
---|
238 | { |
---|
239 | m_firstReceivedPoc = curPoc; |
---|
240 | } |
---|
241 | |
---|
242 | Bool newPocFlag = ( m_lastPoc != curPoc ); |
---|
243 | |
---|
244 | if ( newPocFlag ) |
---|
245 | { |
---|
246 | if( m_lastPoc != -1 ) |
---|
247 | { |
---|
248 | xOutput( m_lastPoc ); |
---|
249 | } |
---|
250 | |
---|
251 | xResetReceivedIdc( false ); |
---|
252 | m_lastPoc = pcSlice->getPOC(); |
---|
253 | } |
---|
254 | |
---|
255 | UInt voiInVps = m_vps->getVoiInVps(pcSlice->getViewIndex()); |
---|
256 | if( m_vps->getCpInSliceSegmentHeaderFlag( voiInVps ) ) // check consistency of slice parameters here |
---|
257 | { |
---|
258 | for( Int baseVoiInVps = 0; baseVoiInVps < m_vps->getNumViews(); baseVoiInVps++ ) |
---|
259 | { |
---|
260 | if ( m_vps->getCpPresentFlag( voiInVps, baseVoiInVps ) ) |
---|
261 | { |
---|
262 | if ( m_receivedIdc[ voiInVps ][ baseVoiInVps ] != 0 ) |
---|
263 | { |
---|
264 | AOF( m_aaiCodedScale [ voiInVps ][ baseVoiInVps ] == pcSlice->getInvCodedScale () [ baseVoiInVps ] ); |
---|
265 | AOF( m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ] == pcSlice->getInvCodedOffset() [ baseVoiInVps ] ); |
---|
266 | } |
---|
267 | else |
---|
268 | { |
---|
269 | m_receivedIdc [ voiInVps ][ baseVoiInVps ] = 1; |
---|
270 | m_aaiCodedScale [ voiInVps ][ baseVoiInVps ] = pcSlice->getInvCodedScale () [ baseVoiInVps ]; |
---|
271 | m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ] = pcSlice->getInvCodedOffset() [ baseVoiInVps ]; |
---|
272 | xInitLUTs( voiInVps, baseVoiInVps, m_aaiCodedScale[ voiInVps ][ baseVoiInVps ], m_aaiCodedOffset[ voiInVps ][ baseVoiInVps ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT); |
---|
273 | } |
---|
274 | if ( m_receivedIdc[ baseVoiInVps ][ voiInVps ] != 0 ) |
---|
275 | { |
---|
276 | AOF( m_aaiCodedScale [ baseVoiInVps ][ voiInVps ] == pcSlice->getCodedScale () [ baseVoiInVps ] ); |
---|
277 | AOF( m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ] == pcSlice->getCodedOffset () [ baseVoiInVps ] ); |
---|
278 | } |
---|
279 | else |
---|
280 | { |
---|
281 | m_receivedIdc [ baseVoiInVps ][ voiInVps ] = 1; |
---|
282 | m_aaiCodedScale [ baseVoiInVps ][ voiInVps ] = pcSlice->getCodedScale () [ baseVoiInVps ]; |
---|
283 | m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ] = pcSlice->getCodedOffset () [ baseVoiInVps ]; |
---|
284 | xInitLUTs( baseVoiInVps, voiInVps, m_aaiCodedScale[ baseVoiInVps ][ voiInVps ], m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT); |
---|
285 | } |
---|
286 | } |
---|
287 | } |
---|
288 | } |
---|
289 | } |
---|
290 | |
---|
291 | Void |
---|
292 | CamParsCollector::xOutput( Int iPOC ) |
---|
293 | { |
---|
294 | if( m_pCodedScaleOffsetFile ) |
---|
295 | { |
---|
296 | if( iPOC == m_firstReceivedPoc ) |
---|
297 | { |
---|
298 | fprintf( m_pCodedScaleOffsetFile, "#ViewOrderIdx ViewIdVal\n" ); |
---|
299 | fprintf( m_pCodedScaleOffsetFile, "#------------ -------------\n" ); |
---|
300 | |
---|
301 | for( UInt voiInVps = 0; voiInVps < m_vps->getNumViews(); voiInVps++ ) |
---|
302 | { |
---|
303 | fprintf( m_pCodedScaleOffsetFile, "%13d %13d\n", m_vps->getViewOIdxList( voiInVps ), m_vps->getViewIdVal( m_vps->getViewOIdxList( voiInVps ) ) ); |
---|
304 | } |
---|
305 | fprintf( m_pCodedScaleOffsetFile, "\n\n"); |
---|
306 | fprintf( m_pCodedScaleOffsetFile, "# StartFrame EndFrame TargetVOI BaseVOI CodedScale CodedOffset Precision\n" ); |
---|
307 | fprintf( m_pCodedScaleOffsetFile, "#----------- ------------ ------------ ------------ ------------ ------------ ------------\n" ); |
---|
308 | } |
---|
309 | if( iPOC == m_firstReceivedPoc || m_bCamParsVaryOverTime ) |
---|
310 | { |
---|
311 | Int iS = iPOC; |
---|
312 | Int iE = ( m_bCamParsVaryOverTime ? iPOC : ~( 1 << 31 ) ); |
---|
313 | for( UInt voiInVps = 0; voiInVps < m_vps->getNumViews(); voiInVps++ ) |
---|
314 | { |
---|
315 | for( UInt baseVoiInVps = 0; baseVoiInVps < m_vps->getNumViews(); baseVoiInVps++ ) |
---|
316 | { |
---|
317 | if( voiInVps != baseVoiInVps ) |
---|
318 | { |
---|
319 | if ( m_receivedIdc[baseVoiInVps][voiInVps] != 0 ) |
---|
320 | { |
---|
321 | fprintf( m_pCodedScaleOffsetFile, "%12d %12d %12d %12d %12d %12d %12d\n", |
---|
322 | iS, iE, m_vps->getViewOIdxList( voiInVps ), m_vps->getViewOIdxList( baseVoiInVps ), |
---|
323 | m_aaiCodedScale [ baseVoiInVps ][ voiInVps ], |
---|
324 | m_aaiCodedOffset[ baseVoiInVps ][ voiInVps ], m_vps->getCpPrecision() ); |
---|
325 | } |
---|
326 | } |
---|
327 | } |
---|
328 | } |
---|
329 | } |
---|
330 | } |
---|
331 | } |
---|
332 | #endif |
---|
333 | |
---|
334 | |
---|
335 | TDecTop::TDecTop() |
---|
336 | : m_iMaxRefPicNum(0) |
---|
337 | #if !NH_MV |
---|
338 | , m_associatedIRAPType(NAL_UNIT_INVALID) |
---|
339 | , m_pocCRA(0) |
---|
340 | , m_pocRandomAccess(MAX_INT) |
---|
341 | , m_cListPic() |
---|
342 | , m_parameterSetManager() |
---|
343 | #endif |
---|
344 | , m_apcSlicePilot(NULL) |
---|
345 | , m_SEIs() |
---|
346 | , m_cPrediction() |
---|
347 | , m_cTrQuant() |
---|
348 | , m_cGopDecoder() |
---|
349 | , m_cSliceDecoder() |
---|
350 | , m_cCuDecoder() |
---|
351 | , m_cEntropyDecoder() |
---|
352 | , m_cCavlcDecoder() |
---|
353 | , m_cSbacDecoder() |
---|
354 | , m_cBinCABAC() |
---|
355 | , m_seiReader() |
---|
356 | , m_cLoopFilter() |
---|
357 | , m_cSAO() |
---|
358 | , m_pcPic(NULL) |
---|
359 | #if !NH_MV |
---|
360 | , m_prevPOC(MAX_INT) |
---|
361 | , m_prevTid0POC(0) |
---|
362 | , m_bFirstSliceInPicture(true) |
---|
363 | , m_bFirstSliceInSequence(true) |
---|
364 | , m_prevSliceSkipped(false) |
---|
365 | , m_skippedPOC(0) |
---|
366 | , m_bFirstSliceInBitstream(true) |
---|
367 | , m_lastPOCNoOutputPriorPics(-1) |
---|
368 | , m_isNoOutputPriorPics(false) |
---|
369 | , m_craNoRaslOutputFlag(false) |
---|
370 | #endif |
---|
371 | #if O0043_BEST_EFFORT_DECODING |
---|
372 | , m_forceDecodeBitDepth(8) |
---|
373 | #endif |
---|
374 | , m_pDecodedSEIOutputStream(NULL) |
---|
375 | #if !NH_MV |
---|
376 | , m_warningMessageSkipPicture(false) |
---|
377 | #endif |
---|
378 | #if MCTS_ENC_CHECK |
---|
379 | , m_tmctsCheckEnabled(false) |
---|
380 | #endif |
---|
381 | , m_prefixSEINALUs() |
---|
382 | { |
---|
383 | #if !NH_MV |
---|
384 | #if ENC_DEC_TRACE |
---|
385 | if (g_hTrace == NULL) |
---|
386 | { |
---|
387 | g_hTrace = fopen( "TraceDec.txt", "wb" ); |
---|
388 | } |
---|
389 | g_bJustDoIt = g_bEncDecTraceDisable; |
---|
390 | g_nSymbolCounter = 0; |
---|
391 | #endif |
---|
392 | #endif |
---|
393 | |
---|
394 | #if NH_MV |
---|
395 | m_layerId = 0; |
---|
396 | m_viewId = 0; |
---|
397 | |
---|
398 | #if NH_3D |
---|
399 | m_viewIndex = 0; |
---|
400 | m_isDepth = false; |
---|
401 | m_pcCamParsCollector = 0; |
---|
402 | #endif |
---|
403 | |
---|
404 | m_decodingProcess = CLAUSE_8; |
---|
405 | m_targetOlsIdx = -1; |
---|
406 | m_smallestLayerId = -1; |
---|
407 | m_isInOwnTargetDecLayerIdList = 0; |
---|
408 | m_prevPicOrderCnt = 0; |
---|
409 | m_pocDecrementedInDpbFlag = NULL; |
---|
410 | m_firstPicInLayerDecodedFlag = NULL; |
---|
411 | m_lastPresentPocResetIdc = NULL; |
---|
412 | |
---|
413 | m_prevIrapPoc = MIN_INT; |
---|
414 | m_prevIrapDecodingOrder = MIN_INT; |
---|
415 | m_prevStsaDecOrder = MIN_INT; |
---|
416 | m_prevStsaTemporalId = MIN_INT; |
---|
417 | #endif |
---|
418 | } |
---|
419 | |
---|
420 | TDecTop::~TDecTop() |
---|
421 | { |
---|
422 | #if ENC_DEC_TRACE |
---|
423 | #if NH_MV |
---|
424 | if (g_hTrace != stdout && g_hTrace != NULL) |
---|
425 | { |
---|
426 | fclose( g_hTrace ); |
---|
427 | g_hTrace = NULL; |
---|
428 | } |
---|
429 | #else |
---|
430 | if (g_hTrace != stdout) |
---|
431 | { |
---|
432 | fclose( g_hTrace ); |
---|
433 | } |
---|
434 | #endif |
---|
435 | #endif |
---|
436 | while (!m_prefixSEINALUs.empty()) |
---|
437 | { |
---|
438 | delete m_prefixSEINALUs.front(); |
---|
439 | m_prefixSEINALUs.pop_front(); |
---|
440 | } |
---|
441 | } |
---|
442 | |
---|
443 | Void TDecTop::create() |
---|
444 | { |
---|
445 | m_cGopDecoder.create(); |
---|
446 | m_apcSlicePilot = new TComSlice; |
---|
447 | m_uiSliceIdx = 0; |
---|
448 | } |
---|
449 | |
---|
450 | Void TDecTop::destroy() |
---|
451 | { |
---|
452 | |
---|
453 | #if NH_MV |
---|
454 | m_cSAO.destroy(); |
---|
455 | m_cLoopFilter. destroy(); |
---|
456 | #endif |
---|
457 | |
---|
458 | m_cGopDecoder.destroy(); |
---|
459 | |
---|
460 | delete m_apcSlicePilot; |
---|
461 | m_apcSlicePilot = NULL; |
---|
462 | |
---|
463 | m_cSliceDecoder.destroy(); |
---|
464 | } |
---|
465 | |
---|
466 | Void TDecTop::init() |
---|
467 | { |
---|
468 | // initialize ROM |
---|
469 | #if !NH_MV |
---|
470 | initROM(); |
---|
471 | #endif |
---|
472 | #if NH_MV |
---|
473 | m_cCavlcDecoder.setDecTop( this ); |
---|
474 | #endif |
---|
475 | m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO); |
---|
476 | m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder, &m_conformanceCheck ); |
---|
477 | #if MCTS_ENC_CHECK |
---|
478 | m_cEntropyDecoder.init(&m_cPrediction, &m_conformanceCheck ); |
---|
479 | #else |
---|
480 | m_cEntropyDecoder.init(&m_cPrediction); |
---|
481 | #endif |
---|
482 | } |
---|
483 | |
---|
484 | #if !NH_MV |
---|
485 | Void TDecTop::deletePicBuffer ( ) |
---|
486 | { |
---|
487 | |
---|
488 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
489 | Int iSize = Int( m_cListPic.size() ); |
---|
490 | |
---|
491 | for (Int i = 0; i < iSize; i++ ) |
---|
492 | { |
---|
493 | TComPic* pcPic = *(iterPic++); |
---|
494 | pcPic->destroy(); |
---|
495 | |
---|
496 | delete pcPic; |
---|
497 | pcPic = NULL; |
---|
498 | } |
---|
499 | |
---|
500 | m_cSAO.destroy(); |
---|
501 | |
---|
502 | m_cLoopFilter. destroy(); |
---|
503 | |
---|
504 | // destroy ROM |
---|
505 | destroyROM(); |
---|
506 | } |
---|
507 | |
---|
508 | Void TDecTop::xGetNewPicBuffer ( const TComSPS &sps, const TComPPS &pps, TComPic*& rpcPic, const UInt temporalLayer ) |
---|
509 | { |
---|
510 | m_iMaxRefPicNum = sps.getMaxDecPicBuffering(temporalLayer); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded |
---|
511 | if (m_cListPic.size() < (UInt)m_iMaxRefPicNum) |
---|
512 | { |
---|
513 | rpcPic = new TComPic(); |
---|
514 | |
---|
515 | #if REDUCED_ENCODER_MEMORY |
---|
516 | rpcPic->create ( sps, pps, false, true); |
---|
517 | #else |
---|
518 | rpcPic->create ( sps, pps, true); |
---|
519 | #endif |
---|
520 | |
---|
521 | m_cListPic.pushBack( rpcPic ); |
---|
522 | |
---|
523 | return; |
---|
524 | } |
---|
525 | |
---|
526 | Bool bBufferIsAvailable = false; |
---|
527 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
528 | while (iterPic != m_cListPic.end()) |
---|
529 | { |
---|
530 | rpcPic = *(iterPic++); |
---|
531 | if ( rpcPic->getReconMark() == false && rpcPic->getOutputMark() == false) |
---|
532 | { |
---|
533 | rpcPic->setOutputMark(false); |
---|
534 | bBufferIsAvailable = true; |
---|
535 | break; |
---|
536 | } |
---|
537 | |
---|
538 | if ( rpcPic->getSlice( 0 )->isReferenced() == false && rpcPic->getOutputMark() == false) |
---|
539 | { |
---|
540 | rpcPic->setOutputMark(false); |
---|
541 | rpcPic->setReconMark( false ); |
---|
542 | rpcPic->getPicYuvRec()->setBorderExtension( false ); |
---|
543 | bBufferIsAvailable = true; |
---|
544 | break; |
---|
545 | } |
---|
546 | } |
---|
547 | |
---|
548 | if ( !bBufferIsAvailable ) |
---|
549 | { |
---|
550 | //There is no room for this picture, either because of faulty encoder or dropped NAL. Extend the buffer. |
---|
551 | m_iMaxRefPicNum++; |
---|
552 | rpcPic = new TComPic(); |
---|
553 | m_cListPic.pushBack( rpcPic ); |
---|
554 | } |
---|
555 | rpcPic->destroy(); |
---|
556 | #if REDUCED_ENCODER_MEMORY |
---|
557 | rpcPic->create ( sps, pps, false, true); |
---|
558 | #else |
---|
559 | rpcPic->create ( sps, pps, true); |
---|
560 | #endif |
---|
561 | } |
---|
562 | |
---|
563 | Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic) |
---|
564 | { |
---|
565 | if (!m_pcPic) |
---|
566 | { |
---|
567 | /* nothing to deblock */ |
---|
568 | return; |
---|
569 | } |
---|
570 | |
---|
571 | TComPic* pcPic = m_pcPic; |
---|
572 | |
---|
573 | // Execute Deblock + Cleanup |
---|
574 | |
---|
575 | m_cGopDecoder.filterPicture(pcPic); |
---|
576 | |
---|
577 | TComSlice::sortPicList( m_cListPic ); // sorting for application output |
---|
578 | poc = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); |
---|
579 | rpcListPic = &m_cListPic; |
---|
580 | m_cCuDecoder.destroy(); |
---|
581 | m_bFirstSliceInPicture = true; |
---|
582 | return; |
---|
583 | } |
---|
584 | |
---|
585 | Void TDecTop::checkNoOutputPriorPics (TComList<TComPic*>* pcListPic) |
---|
586 | { |
---|
587 | if (!pcListPic || !m_isNoOutputPriorPics) |
---|
588 | { |
---|
589 | return; |
---|
590 | } |
---|
591 | |
---|
592 | TComList<TComPic*>::iterator iterPic = pcListPic->begin(); |
---|
593 | |
---|
594 | while (iterPic != pcListPic->end()) |
---|
595 | { |
---|
596 | TComPic* pcPicTmp = *(iterPic++); |
---|
597 | if (m_lastPOCNoOutputPriorPics != pcPicTmp->getPOC()) |
---|
598 | { |
---|
599 | pcPicTmp->setOutputMark(false); |
---|
600 | } |
---|
601 | } |
---|
602 | } |
---|
603 | |
---|
604 | Void TDecTop::xCreateLostPicture(Int iLostPoc) |
---|
605 | { |
---|
606 | printf("\ninserting lost poc : %d\n",iLostPoc); |
---|
607 | TComPic *cFillPic; |
---|
608 | xGetNewPicBuffer(*(m_parameterSetManager.getFirstSPS()), *(m_parameterSetManager.getFirstPPS()), cFillPic, 0); |
---|
609 | cFillPic->getSlice(0)->initSlice(); |
---|
610 | |
---|
611 | TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); |
---|
612 | Int closestPoc = 1000000; |
---|
613 | while ( iterPic != m_cListPic.end()) |
---|
614 | { |
---|
615 | TComPic * rpcPic = *(iterPic++); |
---|
616 | 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()) |
---|
617 | { |
---|
618 | closestPoc=abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc); |
---|
619 | } |
---|
620 | } |
---|
621 | iterPic = m_cListPic.begin(); |
---|
622 | while ( iterPic != m_cListPic.end()) |
---|
623 | { |
---|
624 | TComPic *rpcPic = *(iterPic++); |
---|
625 | if(abs(rpcPic->getPicSym()->getSlice(0)->getPOC() -iLostPoc)==closestPoc&&rpcPic->getPicSym()->getSlice(0)->getPOC()!=m_apcSlicePilot->getPOC()) |
---|
626 | { |
---|
627 | printf("copying picture %d to %d (%d)\n",rpcPic->getPicSym()->getSlice(0)->getPOC() ,iLostPoc,m_apcSlicePilot->getPOC()); |
---|
628 | rpcPic->getPicYuvRec()->copyToPic(cFillPic->getPicYuvRec()); |
---|
629 | break; |
---|
630 | } |
---|
631 | } |
---|
632 | cFillPic->setCurrSliceIdx(0); |
---|
633 | for(Int ctuRsAddr=0; ctuRsAddr<cFillPic->getNumberOfCtusInFrame(); ctuRsAddr++) |
---|
634 | { |
---|
635 | cFillPic->getCtu(ctuRsAddr)->initCtu(cFillPic, ctuRsAddr); |
---|
636 | } |
---|
637 | cFillPic->getSlice(0)->setReferenced(true); |
---|
638 | cFillPic->getSlice(0)->setPOC(iLostPoc); |
---|
639 | xUpdatePreviousTid0POC(cFillPic->getSlice(0)); |
---|
640 | cFillPic->setReconMark(true); |
---|
641 | cFillPic->setOutputMark(true); |
---|
642 | if(m_pocRandomAccess == MAX_INT) |
---|
643 | { |
---|
644 | m_pocRandomAccess = iLostPoc; |
---|
645 | } |
---|
646 | } |
---|
647 | #endif |
---|
648 | |
---|
649 | |
---|
650 | #if NH_MV |
---|
651 | Void TDecTop::activatePSsAndInitPicOrSlice( TComPic* newPic ) |
---|
652 | { |
---|
653 | if ( m_apcSlicePilot->getFirstSliceSegementInPicFlag() ) |
---|
654 | { |
---|
655 | assert( newPic != NULL ); |
---|
656 | |
---|
657 | #else |
---|
658 | Void TDecTop::xActivateParameterSets() |
---|
659 | { |
---|
660 | if (m_bFirstSliceInPicture) |
---|
661 | { |
---|
662 | #endif |
---|
663 | const TComPPS *pps = m_parameterSetManager.getPPS(m_apcSlicePilot->getPPSId()); // this is a temporary PPS object. Do not store this value |
---|
664 | assert (pps != 0); |
---|
665 | |
---|
666 | const TComSPS *sps = m_parameterSetManager.getSPS(pps->getSPSId()); // this is a temporary SPS object. Do not store this value |
---|
667 | assert (sps != 0); |
---|
668 | |
---|
669 | m_parameterSetManager.clearSPSChangedFlag(sps->getSPSId()); |
---|
670 | m_parameterSetManager.clearPPSChangedFlag(pps->getPPSId()); |
---|
671 | #if NH_MV |
---|
672 | const TComVPS* vps = m_parameterSetManager.getVPS(sps->getVPSId()); |
---|
673 | assert (vps != 0); |
---|
674 | // TBD: check the condition on m_firstPicInLayerDecodedFlag |
---|
675 | if (!m_parameterSetManager.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP() || !m_firstPicInLayerDecodedFlag[m_layerId] , m_layerId ) ) |
---|
676 | #else |
---|
677 | if (false == m_parameterSetManager.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->isIRAP())) |
---|
678 | #endif |
---|
679 | { |
---|
680 | printf ("Parameter set activation failed!"); |
---|
681 | assert (0); |
---|
682 | } |
---|
683 | |
---|
684 | #if NH_MV |
---|
685 | if ( decProcAnnexG() ) |
---|
686 | { |
---|
687 | // When the value of vps_num_rep_formats_minus1 in the active VPS is equal to 0 |
---|
688 | if ( vps->getVpsNumRepFormatsMinus1() == 0 ) |
---|
689 | { |
---|
690 | //, it is a requirement of bitstream conformance that the value of update_rep_format_flag shall be equal to 0. |
---|
691 | assert( sps->getUpdateRepFormatFlag() == false ); |
---|
692 | } |
---|
693 | sps->checkRpsMaxNumPics( vps, getLayerId() ); |
---|
694 | |
---|
695 | // It is a requirement of bitstream conformance that, when the SPS is referred to by |
---|
696 | // any current picture that belongs to an independent non-base layer, the value of |
---|
697 | // MultiLayerExtSpsFlag derived from the SPS shall be equal to 0. |
---|
698 | |
---|
699 | if ( m_layerId > 0 && vps->getNumRefLayers( m_layerId ) == 0 ) |
---|
700 | { |
---|
701 | assert( sps->getMultiLayerExtSpsFlag() == 0 ); |
---|
702 | } |
---|
703 | } |
---|
704 | m_seiReader.setLayerId ( newPic->getLayerId ( ) ); |
---|
705 | m_seiReader.setDecOrder( newPic->getDecodingOrder( ) ); |
---|
706 | #endif |
---|
707 | |
---|
708 | xParsePrefixSEImessages(); |
---|
709 | #if MCTS_ENC_CHECK |
---|
710 | xAnalysePrefixSEImessages(); |
---|
711 | #endif |
---|
712 | |
---|
713 | #if RExt__HIGH_BIT_DEPTH_SUPPORT==0 |
---|
714 | if (sps->getSpsRangeExtension().getExtendedPrecisionProcessingFlag() || sps->getBitDepth(CHANNEL_TYPE_LUMA)>12 || sps->getBitDepth(CHANNEL_TYPE_CHROMA)>12 ) |
---|
715 | { |
---|
716 | printf("High bit depth support must be enabled at compile-time in order to decode this bitstream\n"); |
---|
717 | assert (0); |
---|
718 | exit(1); |
---|
719 | } |
---|
720 | #endif |
---|
721 | |
---|
722 | // NOTE: globals were set up here originally. You can now use: |
---|
723 | // g_uiMaxCUDepth = sps->getMaxTotalCUDepth(); |
---|
724 | // g_uiAddCUDepth = sps->getMaxTotalCUDepth() - sps->getLog2DiffMaxMinCodingBlockSize() |
---|
725 | |
---|
726 | // Get a new picture buffer. This will also set up m_pcPic, and therefore give us a SPS and PPS pointer that we can use. |
---|
727 | #if !NH_MV |
---|
728 | xGetNewPicBuffer (*(sps), *(pps), m_pcPic, m_apcSlicePilot->getTLayer()); |
---|
729 | |
---|
730 | m_apcSlicePilot->applyReferencePictureSet(m_cListPic, m_apcSlicePilot->getRPS()); |
---|
731 | #else |
---|
732 | m_pcPic = newPic; |
---|
733 | #endif |
---|
734 | |
---|
735 | // make the slice-pilot a real slice, and set up the slice-pilot for the next slice |
---|
736 | assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
737 | m_apcSlicePilot = m_pcPic->getPicSym()->swapSliceObject(m_apcSlicePilot, m_uiSliceIdx); |
---|
738 | |
---|
739 | // we now have a real slice: |
---|
740 | TComSlice *pSlice = m_pcPic->getSlice(m_uiSliceIdx); |
---|
741 | |
---|
742 | // Update the PPS and SPS pointers with the ones of the picture. |
---|
743 | pps=pSlice->getPPS(); |
---|
744 | sps=pSlice->getSPS(); |
---|
745 | |
---|
746 | #if NH_MV |
---|
747 | pSlice->setPic( m_pcPic ); |
---|
748 | vps=pSlice->getVPS(); |
---|
749 | // The nuh_layer_id value of the NAL unit containing the PPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA. |
---|
750 | assert( pps->getLayerId() == m_layerId || pps->getLayerId( ) == 0 || vps->getDependencyFlag( m_layerId, pps->getLayerId() ) ); |
---|
751 | // The nuh_layer_id value of the NAL unit containing the SPS that is activated for a layer layerA with nuh_layer_id equal to nuhLayerIdA shall be equal to 0, or nuhLayerIdA, or the nuh_layer_id of a direct or indirect reference layer of layerA. |
---|
752 | assert( sps->getLayerId() == m_layerId || sps->getLayerId( ) == 0 || vps->getDependencyFlag( m_layerId, sps->getLayerId() ) ); |
---|
753 | #endif |
---|
754 | |
---|
755 | #if NH_3D |
---|
756 | if ( !m_pcCamParsCollector->isInitialized() ) |
---|
757 | { |
---|
758 | m_pcCamParsCollector->init( vps ); |
---|
759 | } |
---|
760 | #endif |
---|
761 | // Initialise the various objects for the new set of settings |
---|
762 | m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxTotalCUDepth(), pps->getPpsRangeExtension().getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA), pps->getPpsRangeExtension().getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA) ); |
---|
763 | m_cLoopFilter.create( sps->getMaxTotalCUDepth() ); |
---|
764 | m_cPrediction.initTempBuff(sps->getChromaFormatIdc()); |
---|
765 | |
---|
766 | |
---|
767 | Bool isField = false; |
---|
768 | Bool isTopField = false; |
---|
769 | |
---|
770 | if(!m_SEIs.empty()) |
---|
771 | { |
---|
772 | // Check if any new Picture Timing SEI has arrived |
---|
773 | SEIMessages pictureTimingSEIs = getSeisByType(m_SEIs, SEI::PICTURE_TIMING); |
---|
774 | if (pictureTimingSEIs.size()>0) |
---|
775 | { |
---|
776 | SEIPictureTiming* pictureTiming = (SEIPictureTiming*) *(pictureTimingSEIs.begin()); |
---|
777 | isField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 2) || (pictureTiming->m_picStruct == 9) || (pictureTiming->m_picStruct == 10) || (pictureTiming->m_picStruct == 11) || (pictureTiming->m_picStruct == 12); |
---|
778 | isTopField = (pictureTiming->m_picStruct == 1) || (pictureTiming->m_picStruct == 9) || (pictureTiming->m_picStruct == 11); |
---|
779 | } |
---|
780 | } |
---|
781 | |
---|
782 | //Set Field/Frame coding mode |
---|
783 | m_pcPic->setField(isField); |
---|
784 | m_pcPic->setTopField(isTopField); |
---|
785 | |
---|
786 | // transfer any SEI messages that have been received to the picture |
---|
787 | m_pcPic->setSEIs(m_SEIs); |
---|
788 | m_SEIs.clear(); |
---|
789 | |
---|
790 | // Recursive structure |
---|
791 | m_cCuDecoder.create ( sps->getMaxTotalCUDepth(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getChromaFormatIdc() ); |
---|
792 | #if MCTS_ENC_CHECK |
---|
793 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction, &m_conformanceCheck ); |
---|
794 | #else |
---|
795 | m_cCuDecoder.init ( &m_cEntropyDecoder, &m_cTrQuant, &m_cPrediction ); |
---|
796 | #endif |
---|
797 | m_cTrQuant.init ( sps->getMaxTrSize() ); |
---|
798 | |
---|
799 | m_cSliceDecoder.create(); |
---|
800 | } |
---|
801 | else |
---|
802 | { |
---|
803 | #if NH_MV |
---|
804 | assert( m_pcPic != NULL ); |
---|
805 | assert( newPic == NULL ); |
---|
806 | #endif |
---|
807 | // make the slice-pilot a real slice, and set up the slice-pilot for the next slice |
---|
808 | m_pcPic->allocateNewSlice(); |
---|
809 | assert(m_pcPic->getNumAllocatedSlice() == (m_uiSliceIdx + 1)); |
---|
810 | m_apcSlicePilot = m_pcPic->getPicSym()->swapSliceObject(m_apcSlicePilot, m_uiSliceIdx); |
---|
811 | |
---|
812 | TComSlice *pSlice = m_pcPic->getSlice(m_uiSliceIdx); // we now have a real slice. |
---|
813 | |
---|
814 | const TComSPS *sps = pSlice->getSPS(); |
---|
815 | const TComPPS *pps = pSlice->getPPS(); |
---|
816 | |
---|
817 | // check that the current active PPS has not changed... |
---|
818 | if (m_parameterSetManager.getSPSChangedFlag(sps->getSPSId()) ) |
---|
819 | { |
---|
820 | printf("Error - a new SPS has been decoded while processing a picture\n"); |
---|
821 | exit(1); |
---|
822 | } |
---|
823 | if (m_parameterSetManager.getPPSChangedFlag(pps->getPPSId()) ) |
---|
824 | { |
---|
825 | printf("Error - a new PPS has been decoded while processing a picture\n"); |
---|
826 | exit(1); |
---|
827 | } |
---|
828 | |
---|
829 | xParsePrefixSEImessages(); |
---|
830 | |
---|
831 | #if MCTS_ENC_CHECK |
---|
832 | xAnalysePrefixSEImessages(); |
---|
833 | #endif |
---|
834 | // Check if any new SEI has arrived |
---|
835 | if(!m_SEIs.empty()) |
---|
836 | { |
---|
837 | // Currently only decoding Unit SEI message occurring between VCL NALUs copied |
---|
838 | SEIMessages &picSEI = m_pcPic->getSEIs(); |
---|
839 | SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO); |
---|
840 | picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end()); |
---|
841 | deleteSEIs(m_SEIs); |
---|
842 | } |
---|
843 | } |
---|
844 | } |
---|
845 | |
---|
846 | Void TDecTop::xParsePrefixSEIsForUnknownVCLNal() |
---|
847 | { |
---|
848 | while (!m_prefixSEINALUs.empty()) |
---|
849 | { |
---|
850 | // do nothing? |
---|
851 | printf("Discarding Prefix SEI associated with unknown VCL NAL unit.\n"); |
---|
852 | delete m_prefixSEINALUs.front(); |
---|
853 | } |
---|
854 | // TODO: discard following suffix SEIs as well? |
---|
855 | } |
---|
856 | |
---|
857 | |
---|
858 | Void TDecTop::xParsePrefixSEImessages() |
---|
859 | { |
---|
860 | while (!m_prefixSEINALUs.empty()) |
---|
861 | { |
---|
862 | InputNALUnit &nalu=*m_prefixSEINALUs.front(); |
---|
863 | #if NH_MV |
---|
864 | m_seiReader.parseSEImessage(&(nalu.getBitstream()), m_SEIs, nalu.m_nalUnitType, m_parameterSetManager.getActiveVPS(), m_parameterSetManager.getActiveSPS(getLayerId()), m_pDecodedSEIOutputStream); |
---|
865 | #else |
---|
866 | m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_SEIs, nalu.m_nalUnitType, m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream ); |
---|
867 | #endif |
---|
868 | delete m_prefixSEINALUs.front(); |
---|
869 | m_prefixSEINALUs.pop_front(); |
---|
870 | } |
---|
871 | } |
---|
872 | |
---|
873 | #if MCTS_ENC_CHECK |
---|
874 | Void TDecTop::xAnalysePrefixSEImessages() |
---|
875 | { |
---|
876 | if (m_tmctsCheckEnabled) |
---|
877 | { |
---|
878 | SEIMessages mctsSEIs = getSeisByType(m_SEIs, SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS); |
---|
879 | for (SEIMessages::iterator it = mctsSEIs.begin(); it != mctsSEIs.end(); it++) |
---|
880 | { |
---|
881 | SEITempMotionConstrainedTileSets *mcts = (SEITempMotionConstrainedTileSets*)(*it); |
---|
882 | if (!mcts->m_each_tile_one_tile_set_flag) |
---|
883 | { |
---|
884 | printf("cannot (yet) check Temporal constrained MCTS if each_tile_one_tile_set_flag is not enabled\n"); |
---|
885 | exit(1); |
---|
886 | } |
---|
887 | else |
---|
888 | { |
---|
889 | printf("MCTS check enabled!\n"); |
---|
890 | m_conformanceCheck.enableTMctsCheck(true); |
---|
891 | } |
---|
892 | } |
---|
893 | } |
---|
894 | } |
---|
895 | #endif |
---|
896 | |
---|
897 | |
---|
898 | #if !NH_MV |
---|
899 | Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay ) |
---|
900 | { |
---|
901 | m_apcSlicePilot->initSlice(); // the slice pilot is an object to prepare for a new slice |
---|
902 | // it is not associated with picture, sps or pps structures. |
---|
903 | if (m_bFirstSliceInPicture) |
---|
904 | { |
---|
905 | #else |
---|
906 | Void TDecTop::decodeSliceHeader(InputNALUnit &nalu ) |
---|
907 | { |
---|
908 | // Initialize entropy decoder |
---|
909 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
910 | m_cEntropyDecoder.setBitstream (&(nalu.getBitstream())); |
---|
911 | |
---|
912 | assert( nalu.m_nuhLayerId == m_layerId ); |
---|
913 | m_apcSlicePilot->initSlice(); // the slice pilot is an object to prepare for a new slice |
---|
914 | // it is not associated with picture, sps or pps structures. |
---|
915 | m_apcSlicePilot->setLayerId( nalu.m_nuhLayerId ); |
---|
916 | m_cEntropyDecoder.decodeFirstSliceSegmentInPicFlag( m_apcSlicePilot ); |
---|
917 | if ( m_apcSlicePilot->getFirstSliceSegementInPicFlag() ) |
---|
918 | { |
---|
919 | #endif |
---|
920 | m_uiSliceIdx = 0; |
---|
921 | } |
---|
922 | else |
---|
923 | { |
---|
924 | m_apcSlicePilot->copySliceInfo( m_pcPic->getPicSym()->getSlice(m_uiSliceIdx-1) ); |
---|
925 | } |
---|
926 | m_apcSlicePilot->setSliceIdx(m_uiSliceIdx); |
---|
927 | |
---|
928 | m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); |
---|
929 | Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || |
---|
930 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || |
---|
931 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N || |
---|
932 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
933 | m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N); |
---|
934 | m_apcSlicePilot->setTemporalLayerNonReferenceFlag(nonReferenceFlag); |
---|
935 | #if !NH_MV |
---|
936 | m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS |
---|
937 | #endif |
---|
938 | m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId); |
---|
939 | #if NH_MV |
---|
940 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManager ); |
---|
941 | #else |
---|
942 | #if ENC_DEC_TRACE |
---|
943 | const UInt64 originalSymbolCount = g_nSymbolCounter; |
---|
944 | #endif |
---|
945 | m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManager, m_prevTid0POC); |
---|
946 | #endif |
---|
947 | |
---|
948 | #if NH_MV |
---|
949 | } |
---|
950 | #else |
---|
951 | // set POC for dependent slices in skipped pictures |
---|
952 | if(m_apcSlicePilot->getDependentSliceSegmentFlag() && m_prevSliceSkipped) |
---|
953 | { |
---|
954 | m_apcSlicePilot->setPOC(m_skippedPOC); |
---|
955 | } |
---|
956 | |
---|
957 | xUpdatePreviousTid0POC(m_apcSlicePilot); |
---|
958 | m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA); |
---|
959 | m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType); |
---|
960 | |
---|
961 | |
---|
962 | //For inference of NoOutputOfPriorPicsFlag |
---|
963 | if (m_apcSlicePilot->getRapPicFlag()) |
---|
964 | { |
---|
965 | if ((m_apcSlicePilot->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_apcSlicePilot->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP) || |
---|
966 | (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_bFirstSliceInSequence) || |
---|
967 | (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getHandleCraAsBlaFlag())) |
---|
968 | { |
---|
969 | m_apcSlicePilot->setNoRaslOutputFlag(true); |
---|
970 | } |
---|
971 | //the inference for NoOutputPriorPicsFlag |
---|
972 | if (!m_bFirstSliceInBitstream && m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoRaslOutputFlag()) |
---|
973 | { |
---|
974 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
975 | { |
---|
976 | m_apcSlicePilot->setNoOutputPriorPicsFlag(true); |
---|
977 | } |
---|
978 | } |
---|
979 | else |
---|
980 | { |
---|
981 | m_apcSlicePilot->setNoOutputPriorPicsFlag(false); |
---|
982 | } |
---|
983 | |
---|
984 | if(m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
985 | { |
---|
986 | m_craNoRaslOutputFlag = m_apcSlicePilot->getNoRaslOutputFlag(); |
---|
987 | } |
---|
988 | } |
---|
989 | if (m_apcSlicePilot->getRapPicFlag() && m_apcSlicePilot->getNoOutputPriorPicsFlag()) |
---|
990 | { |
---|
991 | m_lastPOCNoOutputPriorPics = m_apcSlicePilot->getPOC(); |
---|
992 | m_isNoOutputPriorPics = true; |
---|
993 | } |
---|
994 | else |
---|
995 | { |
---|
996 | m_isNoOutputPriorPics = false; |
---|
997 | } |
---|
998 | |
---|
999 | //For inference of PicOutputFlag |
---|
1000 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1001 | { |
---|
1002 | if ( m_craNoRaslOutputFlag ) |
---|
1003 | { |
---|
1004 | m_apcSlicePilot->setPicOutputFlag(false); |
---|
1005 | } |
---|
1006 | } |
---|
1007 | |
---|
1008 | if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_craNoRaslOutputFlag) //Reset POC MSB when CRA has NoRaslOutputFlag equal to 1 |
---|
1009 | { |
---|
1010 | TComPPS *pps = m_parameterSetManager.getPPS(m_apcSlicePilot->getPPSId()); |
---|
1011 | assert (pps != 0); |
---|
1012 | TComSPS *sps = m_parameterSetManager.getSPS(pps->getSPSId()); |
---|
1013 | assert (sps != 0); |
---|
1014 | Int iMaxPOClsb = 1 << sps->getBitsForPOC(); |
---|
1015 | m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) ); |
---|
1016 | xUpdatePreviousTid0POC(m_apcSlicePilot); |
---|
1017 | } |
---|
1018 | |
---|
1019 | // Skip pictures due to random access |
---|
1020 | if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) |
---|
1021 | { |
---|
1022 | m_prevSliceSkipped = true; |
---|
1023 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
1024 | return false; |
---|
1025 | } |
---|
1026 | // Skip TFD pictures associated with BLA/BLANT pictures |
---|
1027 | if (isSkipPictureForBLA(iPOCLastDisplay)) |
---|
1028 | { |
---|
1029 | m_prevSliceSkipped = true; |
---|
1030 | m_skippedPOC = m_apcSlicePilot->getPOC(); |
---|
1031 | return false; |
---|
1032 | } |
---|
1033 | |
---|
1034 | // clear previous slice skipped flag |
---|
1035 | m_prevSliceSkipped = false; |
---|
1036 | |
---|
1037 | //we should only get a different poc for a new picture (with CTU address==0) |
---|
1038 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() != 0)) |
---|
1039 | { |
---|
1040 | printf ("Warning, the first slice of a picture might have been lost!\n"); |
---|
1041 | } |
---|
1042 | |
---|
1043 | // exit when a new picture is found |
---|
1044 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag() && (m_apcSlicePilot->getSliceCurStartCtuTsAddr() == 0 && !m_bFirstSliceInPicture) ) |
---|
1045 | { |
---|
1046 | if (m_prevPOC >= m_pocRandomAccess) |
---|
1047 | { |
---|
1048 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
1049 | |
---|
1050 | #if ENC_DEC_TRACE |
---|
1051 | //rewind the trace counter since we didn't actually decode the slice |
---|
1052 | g_nSymbolCounter = originalSymbolCount; |
---|
1053 | #endif |
---|
1054 | return true; |
---|
1055 | } |
---|
1056 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
1057 | } |
---|
1058 | |
---|
1059 | //detect lost reference picture and insert copy of earlier frame. |
---|
1060 | { |
---|
1061 | Int lostPoc; |
---|
1062 | while((lostPoc=m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess)) > 0) |
---|
1063 | { |
---|
1064 | xCreateLostPicture(lostPoc-1); |
---|
1065 | } |
---|
1066 | } |
---|
1067 | |
---|
1068 | if (!m_apcSlicePilot->getDependentSliceSegmentFlag()) |
---|
1069 | { |
---|
1070 | m_prevPOC = m_apcSlicePilot->getPOC(); |
---|
1071 | } |
---|
1072 | // actual decoding starts here |
---|
1073 | xActivateParameterSets(); |
---|
1074 | |
---|
1075 | |
---|
1076 | |
---|
1077 | TComSlice* pcSlice = m_pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
1078 | |
---|
1079 | if (TDecConformanceCheck::doChecking()) |
---|
1080 | { |
---|
1081 | m_conformanceCheck.checkSliceActivation(*pcSlice, nalu, *m_pcPic, m_bFirstSliceInBitstream, m_bFirstSliceInSequence, m_bFirstSliceInPicture); |
---|
1082 | } |
---|
1083 | |
---|
1084 | m_bFirstSliceInSequence = false; |
---|
1085 | m_bFirstSliceInBitstream = false; |
---|
1086 | |
---|
1087 | #endif |
---|
1088 | |
---|
1089 | #if NH_MV |
---|
1090 | Void TDecTop::decodeSliceSegment(InputNALUnit &nalu ) |
---|
1091 | { |
---|
1092 | TComSlice* pcSlice = m_pcPic->getPicSym()->getSlice(m_uiSliceIdx); |
---|
1093 | |
---|
1094 | if ( m_pcPic->getHasGeneratedRefPics() ) |
---|
1095 | { |
---|
1096 | if ( pcSlice->getFirstSliceSegementInPicFlag() ) |
---|
1097 | { |
---|
1098 | std::cout << std:: setfill(' ') |
---|
1099 | << "Layer " << std::setw(2) << m_pcPic->getLayerId() |
---|
1100 | << " POC " << std::setw(4) << m_pcPic->getPOC() |
---|
1101 | << " Reference pictures missing. Skipping picture." << std::endl; |
---|
1102 | } |
---|
1103 | } |
---|
1104 | else |
---|
1105 | { |
---|
1106 | //Check Multiview Main profile constraint in G.11.1.1 |
---|
1107 | // When ViewOrderIdx[ i ] derived according to any active VPS is equal to 1 |
---|
1108 | // for the layer with nuh_layer_id equal to i in subBitstream, |
---|
1109 | // inter_view_mv_vert_constraint_flag shall be equal to 1 |
---|
1110 | // in the sps_multilayer_extension( ) syntax structure in each active SPS for that layer. |
---|
1111 | if( pcSlice->getSPS()->getPTL()->getGeneralPTL()->getProfileIdc()==Profile::MULTIVIEWMAIN |
---|
1112 | && |
---|
1113 | pcSlice->getVPS()->getViewOrderIdx(pcSlice->getVPS()->getLayerIdInNuh(getLayerId()))==1 |
---|
1114 | ) |
---|
1115 | { |
---|
1116 | assert( pcSlice->getSPS()->getInterViewMvVertConstraintFlag()==1 ); |
---|
1117 | } |
---|
1118 | |
---|
1119 | m_pcPic->setLayerId( nalu.m_nuhLayerId ); |
---|
1120 | m_pcPic->setViewId ( getViewId() ); |
---|
1121 | #if NH_3D || NH_3D_VSO |
---|
1122 | m_pcPic->setViewIndex( getViewIndex() ); |
---|
1123 | m_pcPic->setIsDepth ( getIsDepth () ); |
---|
1124 | pcSlice->setIvPicLists( m_dpb ); |
---|
1125 | #endif |
---|
1126 | #endif |
---|
1127 | |
---|
1128 | // When decoding the slice header, the stored start and end addresses were actually RS addresses, not TS addresses. |
---|
1129 | // Now, having set up the maps, convert them to the correct form. |
---|
1130 | pcSlice->setSliceSegmentCurStartCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurStartCtuTsAddr()) ); |
---|
1131 | pcSlice->setSliceSegmentCurEndCtuTsAddr( m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceSegmentCurEndCtuTsAddr()) ); |
---|
1132 | if(!pcSlice->getDependentSliceSegmentFlag()) |
---|
1133 | { |
---|
1134 | pcSlice->setSliceCurStartCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurStartCtuTsAddr())); |
---|
1135 | pcSlice->setSliceCurEndCtuTsAddr(m_pcPic->getPicSym()->getCtuRsToTsAddrMap(pcSlice->getSliceCurEndCtuTsAddr())); |
---|
1136 | } |
---|
1137 | |
---|
1138 | m_pcPic->setTLayer(nalu.m_temporalId); |
---|
1139 | |
---|
1140 | |
---|
1141 | if (!pcSlice->getDependentSliceSegmentFlag()) |
---|
1142 | { |
---|
1143 | #if !NH_MV |
---|
1144 | pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic ); |
---|
1145 | // Set reference list |
---|
1146 | pcSlice->setRefPicList( m_cListPic, true ); |
---|
1147 | #else |
---|
1148 | if (pcSlice->getSliceType() != I_SLICE ) |
---|
1149 | { |
---|
1150 | if( m_decProcPocAndRps == ANNEX_F ) |
---|
1151 | { |
---|
1152 | pcSlice->f834decProcForRefPicListConst(); |
---|
1153 | } |
---|
1154 | else if ( m_decProcPocAndRps == CLAUSE_8 ) |
---|
1155 | { |
---|
1156 | pcSlice->cl834DecProcForRefPicListConst(); |
---|
1157 | } |
---|
1158 | else |
---|
1159 | { |
---|
1160 | assert( false ); |
---|
1161 | } |
---|
1162 | } |
---|
1163 | #if NH_3D |
---|
1164 | pcSlice->setDefaultRefView(); |
---|
1165 | pcSlice->setPocsInCurrRPSs(); |
---|
1166 | pcSlice->setARPStepNum(m_dpb); |
---|
1167 | #endif |
---|
1168 | #endif |
---|
1169 | |
---|
1170 | // For generalized B |
---|
1171 | // note: maybe not existed case (always L0 is copied to L1 if L1 is empty) |
---|
1172 | if (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0) |
---|
1173 | { |
---|
1174 | Int iNumRefIdx = pcSlice->getNumRefIdx(REF_PIC_LIST_0); |
---|
1175 | pcSlice->setNumRefIdx ( REF_PIC_LIST_1, iNumRefIdx ); |
---|
1176 | |
---|
1177 | for (Int iRefIdx = 0; iRefIdx < iNumRefIdx; iRefIdx++) |
---|
1178 | { |
---|
1179 | pcSlice->setRefPic(pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx), REF_PIC_LIST_1, iRefIdx); |
---|
1180 | } |
---|
1181 | } |
---|
1182 | if (!pcSlice->isIntra()) |
---|
1183 | { |
---|
1184 | Bool bLowDelay = true; |
---|
1185 | Int iCurrPOC = pcSlice->getPOC(); |
---|
1186 | Int iRefIdx = 0; |
---|
1187 | |
---|
1188 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_0) && bLowDelay; iRefIdx++) |
---|
1189 | { |
---|
1190 | if ( pcSlice->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() > iCurrPOC ) |
---|
1191 | { |
---|
1192 | bLowDelay = false; |
---|
1193 | } |
---|
1194 | } |
---|
1195 | if (pcSlice->isInterB()) |
---|
1196 | { |
---|
1197 | for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++) |
---|
1198 | { |
---|
1199 | if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC ) |
---|
1200 | { |
---|
1201 | bLowDelay = false; |
---|
1202 | } |
---|
1203 | } |
---|
1204 | } |
---|
1205 | |
---|
1206 | pcSlice->setCheckLDC(bLowDelay); |
---|
1207 | } |
---|
1208 | |
---|
1209 | //--------------- |
---|
1210 | pcSlice->setRefPOCList(); |
---|
1211 | #if NH_3D |
---|
1212 | if(pcSlice->getLayerId()) |
---|
1213 | { |
---|
1214 | pcSlice->generateAlterRefforTMVP(); |
---|
1215 | } |
---|
1216 | #endif |
---|
1217 | } |
---|
1218 | |
---|
1219 | m_pcPic->setCurrSliceIdx(m_uiSliceIdx); |
---|
1220 | if(pcSlice->getSPS()->getScalingListFlag()) |
---|
1221 | { |
---|
1222 | TComScalingList scalingList; |
---|
1223 | if(pcSlice->getPPS()->getScalingListPresentFlag()) |
---|
1224 | { |
---|
1225 | scalingList = pcSlice->getPPS()->getScalingList(); |
---|
1226 | } |
---|
1227 | else if (pcSlice->getSPS()->getScalingListPresentFlag()) |
---|
1228 | { |
---|
1229 | scalingList = pcSlice->getSPS()->getScalingList(); |
---|
1230 | } |
---|
1231 | else |
---|
1232 | { |
---|
1233 | scalingList.setDefaultScalingList(); |
---|
1234 | } |
---|
1235 | m_cTrQuant.setScalingListDec(scalingList); |
---|
1236 | m_cTrQuant.setUseScalingList(true); |
---|
1237 | } |
---|
1238 | else |
---|
1239 | { |
---|
1240 | const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE] = |
---|
1241 | { |
---|
1242 | pcSlice->getSPS()->getMaxLog2TrDynamicRange(CHANNEL_TYPE_LUMA), |
---|
1243 | pcSlice->getSPS()->getMaxLog2TrDynamicRange(CHANNEL_TYPE_CHROMA) |
---|
1244 | }; |
---|
1245 | m_cTrQuant.setFlatScalingList(maxLog2TrDynamicRange, pcSlice->getSPS()->getBitDepths()); |
---|
1246 | m_cTrQuant.setUseScalingList(false); |
---|
1247 | } |
---|
1248 | |
---|
1249 | #if NH_3D |
---|
1250 | if ( decProcAnnexI() ) |
---|
1251 | { |
---|
1252 | pcSlice->checkInCompPredRefLayers(); |
---|
1253 | } |
---|
1254 | #endif |
---|
1255 | |
---|
1256 | // Decode a picture |
---|
1257 | m_cGopDecoder.decompressSlice(&(nalu.getBitstream()), m_pcPic); |
---|
1258 | |
---|
1259 | #if NH_3D |
---|
1260 | if( m_pcCamParsCollector ) |
---|
1261 | { |
---|
1262 | m_pcCamParsCollector->setSlice( pcSlice ); |
---|
1263 | } |
---|
1264 | #endif |
---|
1265 | |
---|
1266 | #if !NH_MV |
---|
1267 | m_bFirstSliceInPicture = false; |
---|
1268 | #else |
---|
1269 | } |
---|
1270 | #endif |
---|
1271 | m_uiSliceIdx++; |
---|
1272 | |
---|
1273 | #if !NH_MV |
---|
1274 | return false; |
---|
1275 | #endif |
---|
1276 | } |
---|
1277 | |
---|
1278 | |
---|
1279 | Void TDecTop::xDecodeVPS(const std::vector<UChar> &naluData) |
---|
1280 | { |
---|
1281 | TComVPS* vps = new TComVPS(); |
---|
1282 | |
---|
1283 | m_cEntropyDecoder.decodeVPS( vps ); |
---|
1284 | m_parameterSetManager.storeVPS(vps, naluData); |
---|
1285 | } |
---|
1286 | |
---|
1287 | Void TDecTop::xDecodeSPS(const std::vector<UChar> &naluData) |
---|
1288 | { |
---|
1289 | TComSPS* sps = new TComSPS(); |
---|
1290 | #if NH_MV |
---|
1291 | sps->setLayerId( getLayerId() ); |
---|
1292 | #endif |
---|
1293 | #if O0043_BEST_EFFORT_DECODING |
---|
1294 | sps->setForceDecodeBitDepth(m_forceDecodeBitDepth); |
---|
1295 | #endif |
---|
1296 | #if NH_3D |
---|
1297 | // GT: Please don't add parsing dependency of SPS from VPS here again!!! |
---|
1298 | #endif |
---|
1299 | m_cEntropyDecoder.decodeSPS( sps ); |
---|
1300 | m_parameterSetManager.storeSPS(sps, naluData); |
---|
1301 | } |
---|
1302 | |
---|
1303 | Void TDecTop::xDecodePPS(const std::vector<UChar> &naluData) |
---|
1304 | { |
---|
1305 | TComPPS* pps = new TComPPS(); |
---|
1306 | #if NH_MV |
---|
1307 | pps->setLayerId( getLayerId() ); |
---|
1308 | #endif |
---|
1309 | #if NH_3D |
---|
1310 | // create mapping from depth layer indexes to layer ids |
---|
1311 | Int j=0; |
---|
1312 | for( Int i=0; i<=m_parameterSetManager.getFirstVPS()->getMaxLayersMinus1(); i++ ) |
---|
1313 | { |
---|
1314 | Int layerId = m_parameterSetManager.getFirstVPS()->getLayerIdInNuh(i); |
---|
1315 | if( m_parameterSetManager.getFirstVPS()->getDepthId(layerId) ) |
---|
1316 | pps->getDLT()->setDepthIdxToLayerId(j++, layerId); |
---|
1317 | } |
---|
1318 | #endif |
---|
1319 | m_cEntropyDecoder.decodePPS( pps ); |
---|
1320 | |
---|
1321 | m_parameterSetManager.storePPS( pps, naluData); |
---|
1322 | } |
---|
1323 | |
---|
1324 | #if NH_MV |
---|
1325 | Bool TDecTop::decodeNonVclNalu(InputNALUnit& nalu ) |
---|
1326 | #else |
---|
1327 | Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay) |
---|
1328 | #endif |
---|
1329 | { |
---|
1330 | #if !NH_MV |
---|
1331 | // ignore all NAL units of layers > 0 |
---|
1332 | if (nalu.m_nuhLayerId > 0) |
---|
1333 | { |
---|
1334 | fprintf (stderr, "Warning: found NAL unit with nuh_layer_id equal to %d. Ignoring.\n", nalu.m_nuhLayerId); |
---|
1335 | return false; |
---|
1336 | } |
---|
1337 | #endif |
---|
1338 | // Initialize entropy decoder |
---|
1339 | m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); |
---|
1340 | m_cEntropyDecoder.setBitstream (&(nalu.getBitstream())); |
---|
1341 | |
---|
1342 | switch (nalu.m_nalUnitType) |
---|
1343 | { |
---|
1344 | case NAL_UNIT_VPS: |
---|
1345 | xDecodeVPS(nalu.getBitstream().getFifo()); |
---|
1346 | return false; |
---|
1347 | |
---|
1348 | case NAL_UNIT_SPS: |
---|
1349 | xDecodeSPS(nalu.getBitstream().getFifo()); |
---|
1350 | return false; |
---|
1351 | |
---|
1352 | case NAL_UNIT_PPS: |
---|
1353 | xDecodePPS(nalu.getBitstream().getFifo()); |
---|
1354 | return false; |
---|
1355 | |
---|
1356 | case NAL_UNIT_PREFIX_SEI: |
---|
1357 | // Buffer up prefix SEI messages until SPS of associated VCL is known. |
---|
1358 | m_prefixSEINALUs.push_back(new InputNALUnit(nalu)); |
---|
1359 | return false; |
---|
1360 | |
---|
1361 | case NAL_UNIT_SUFFIX_SEI: |
---|
1362 | if (m_pcPic) |
---|
1363 | { |
---|
1364 | #if NH_MV |
---|
1365 | m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_pcPic->getSEIs(), nalu.m_nalUnitType, m_parameterSetManager.getActiveVPS(), m_parameterSetManager.getActiveSPS(getLayerId()), m_pDecodedSEIOutputStream); |
---|
1366 | #else |
---|
1367 | m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_pcPic->getSEIs(), nalu.m_nalUnitType, m_parameterSetManager.getActiveSPS(), m_pDecodedSEIOutputStream ); |
---|
1368 | #endif |
---|
1369 | } |
---|
1370 | else |
---|
1371 | { |
---|
1372 | printf ("Note: received suffix SEI but no picture currently active.\n"); |
---|
1373 | } |
---|
1374 | return false; |
---|
1375 | |
---|
1376 | case NAL_UNIT_CODED_SLICE_TRAIL_R: |
---|
1377 | case NAL_UNIT_CODED_SLICE_TRAIL_N: |
---|
1378 | case NAL_UNIT_CODED_SLICE_TSA_R: |
---|
1379 | case NAL_UNIT_CODED_SLICE_TSA_N: |
---|
1380 | case NAL_UNIT_CODED_SLICE_STSA_R: |
---|
1381 | case NAL_UNIT_CODED_SLICE_STSA_N: |
---|
1382 | case NAL_UNIT_CODED_SLICE_BLA_W_LP: |
---|
1383 | case NAL_UNIT_CODED_SLICE_BLA_W_RADL: |
---|
1384 | case NAL_UNIT_CODED_SLICE_BLA_N_LP: |
---|
1385 | case NAL_UNIT_CODED_SLICE_IDR_W_RADL: |
---|
1386 | case NAL_UNIT_CODED_SLICE_IDR_N_LP: |
---|
1387 | case NAL_UNIT_CODED_SLICE_CRA: |
---|
1388 | case NAL_UNIT_CODED_SLICE_RADL_N: |
---|
1389 | case NAL_UNIT_CODED_SLICE_RADL_R: |
---|
1390 | case NAL_UNIT_CODED_SLICE_RASL_N: |
---|
1391 | case NAL_UNIT_CODED_SLICE_RASL_R: |
---|
1392 | #if NH_MV |
---|
1393 | assert( false ); |
---|
1394 | return 1; |
---|
1395 | #else |
---|
1396 | return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay); |
---|
1397 | #endif |
---|
1398 | break; |
---|
1399 | |
---|
1400 | case NAL_UNIT_EOS: |
---|
1401 | #if !NH_MV |
---|
1402 | m_associatedIRAPType = NAL_UNIT_INVALID; |
---|
1403 | m_pocCRA = 0; |
---|
1404 | m_pocRandomAccess = MAX_INT; |
---|
1405 | m_prevPOC = MAX_INT; |
---|
1406 | m_prevSliceSkipped = false; |
---|
1407 | m_skippedPOC = 0; |
---|
1408 | #endif |
---|
1409 | return false; |
---|
1410 | |
---|
1411 | case NAL_UNIT_ACCESS_UNIT_DELIMITER: |
---|
1412 | { |
---|
1413 | AUDReader audReader; |
---|
1414 | UInt picType; |
---|
1415 | audReader.parseAccessUnitDelimiter(&(nalu.getBitstream()),picType); |
---|
1416 | printf ("Note: found NAL_UNIT_ACCESS_UNIT_DELIMITER\n"); |
---|
1417 | return false; |
---|
1418 | } |
---|
1419 | |
---|
1420 | case NAL_UNIT_EOB: |
---|
1421 | return false; |
---|
1422 | |
---|
1423 | case NAL_UNIT_FILLER_DATA: |
---|
1424 | { |
---|
1425 | FDReader fdReader; |
---|
1426 | UInt size; |
---|
1427 | fdReader.parseFillerData(&(nalu.getBitstream()),size); |
---|
1428 | printf ("Note: found NAL_UNIT_FILLER_DATA with %u bytes payload.\n", size); |
---|
1429 | return false; |
---|
1430 | } |
---|
1431 | |
---|
1432 | case NAL_UNIT_RESERVED_VCL_N10: |
---|
1433 | case NAL_UNIT_RESERVED_VCL_R11: |
---|
1434 | case NAL_UNIT_RESERVED_VCL_N12: |
---|
1435 | case NAL_UNIT_RESERVED_VCL_R13: |
---|
1436 | case NAL_UNIT_RESERVED_VCL_N14: |
---|
1437 | case NAL_UNIT_RESERVED_VCL_R15: |
---|
1438 | |
---|
1439 | case NAL_UNIT_RESERVED_IRAP_VCL22: |
---|
1440 | case NAL_UNIT_RESERVED_IRAP_VCL23: |
---|
1441 | |
---|
1442 | case NAL_UNIT_RESERVED_VCL24: |
---|
1443 | case NAL_UNIT_RESERVED_VCL25: |
---|
1444 | case NAL_UNIT_RESERVED_VCL26: |
---|
1445 | case NAL_UNIT_RESERVED_VCL27: |
---|
1446 | case NAL_UNIT_RESERVED_VCL28: |
---|
1447 | case NAL_UNIT_RESERVED_VCL29: |
---|
1448 | case NAL_UNIT_RESERVED_VCL30: |
---|
1449 | case NAL_UNIT_RESERVED_VCL31: |
---|
1450 | printf ("Note: found reserved VCL NAL unit.\n"); |
---|
1451 | xParsePrefixSEIsForUnknownVCLNal(); |
---|
1452 | return false; |
---|
1453 | |
---|
1454 | case NAL_UNIT_RESERVED_NVCL41: |
---|
1455 | case NAL_UNIT_RESERVED_NVCL42: |
---|
1456 | case NAL_UNIT_RESERVED_NVCL43: |
---|
1457 | case NAL_UNIT_RESERVED_NVCL44: |
---|
1458 | case NAL_UNIT_RESERVED_NVCL45: |
---|
1459 | case NAL_UNIT_RESERVED_NVCL46: |
---|
1460 | case NAL_UNIT_RESERVED_NVCL47: |
---|
1461 | printf ("Note: found reserved NAL unit.\n"); |
---|
1462 | return false; |
---|
1463 | case NAL_UNIT_UNSPECIFIED_48: |
---|
1464 | case NAL_UNIT_UNSPECIFIED_49: |
---|
1465 | case NAL_UNIT_UNSPECIFIED_50: |
---|
1466 | case NAL_UNIT_UNSPECIFIED_51: |
---|
1467 | case NAL_UNIT_UNSPECIFIED_52: |
---|
1468 | case NAL_UNIT_UNSPECIFIED_53: |
---|
1469 | case NAL_UNIT_UNSPECIFIED_54: |
---|
1470 | case NAL_UNIT_UNSPECIFIED_55: |
---|
1471 | case NAL_UNIT_UNSPECIFIED_56: |
---|
1472 | case NAL_UNIT_UNSPECIFIED_57: |
---|
1473 | case NAL_UNIT_UNSPECIFIED_58: |
---|
1474 | case NAL_UNIT_UNSPECIFIED_59: |
---|
1475 | case NAL_UNIT_UNSPECIFIED_60: |
---|
1476 | case NAL_UNIT_UNSPECIFIED_61: |
---|
1477 | case NAL_UNIT_UNSPECIFIED_62: |
---|
1478 | case NAL_UNIT_UNSPECIFIED_63: |
---|
1479 | printf ("Note: found unspecified NAL unit.\n"); |
---|
1480 | return false; |
---|
1481 | default: |
---|
1482 | assert (0); |
---|
1483 | break; |
---|
1484 | } |
---|
1485 | |
---|
1486 | return false; |
---|
1487 | } |
---|
1488 | |
---|
1489 | #if !NH_MV |
---|
1490 | /** Function for checking if picture should be skipped because of association with a previous BLA picture |
---|
1491 | * \param iPOCLastDisplay POC of last picture displayed |
---|
1492 | * \returns true if the picture should be skipped |
---|
1493 | * This function skips all TFD pictures that follow a BLA picture |
---|
1494 | * in decoding order and precede it in output order. |
---|
1495 | */ |
---|
1496 | Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) |
---|
1497 | { |
---|
1498 | 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) && |
---|
1499 | m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) |
---|
1500 | { |
---|
1501 | iPOCLastDisplay++; |
---|
1502 | return true; |
---|
1503 | } |
---|
1504 | return false; |
---|
1505 | } |
---|
1506 | |
---|
1507 | /** Function for checking if picture should be skipped because of random access |
---|
1508 | * \param iSkipFrame skip frame counter |
---|
1509 | * \param iPOCLastDisplay POC of last picture displayed |
---|
1510 | * \returns true if the picture shold be skipped in the random access. |
---|
1511 | * This function checks the skipping of pictures in the case of -s option random access. |
---|
1512 | * All pictures prior to the random access point indicated by the counter iSkipFrame are skipped. |
---|
1513 | * It also checks the type of Nal unit type at the random access point. |
---|
1514 | * 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. |
---|
1515 | * If the random access point is IDR all pictures after the random access point are decoded. |
---|
1516 | * If the random access point is none of the above, a warning is issues, and decoding of pictures with POC |
---|
1517 | * equal to or greater than the random access point POC is attempted. For non IDR/CRA/BLA random |
---|
1518 | * access point there is no guarantee that the decoder will not crash. |
---|
1519 | */ |
---|
1520 | Bool TDecTop::isRandomAccessSkipPicture(Int& iSkipFrame, Int& iPOCLastDisplay ) |
---|
1521 | { |
---|
1522 | if (iSkipFrame) |
---|
1523 | { |
---|
1524 | iSkipFrame--; // decrement the counter |
---|
1525 | return true; |
---|
1526 | } |
---|
1527 | else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet. |
---|
1528 | { |
---|
1529 | if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA |
---|
1530 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1531 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
1532 | || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ) |
---|
1533 | { |
---|
1534 | |
---|
1535 | // set the POC random access since we need to skip the reordered pictures in the case of CRA/CRANT/BLA/BLANT. |
---|
1536 | m_pocRandomAccess = m_apcSlicePilot->getPOC(); |
---|
1537 | } |
---|
1538 | else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) |
---|
1539 | { |
---|
1540 | m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable. |
---|
1541 | } |
---|
1542 | else |
---|
1543 | { |
---|
1544 | if(!m_warningMessageSkipPicture) |
---|
1545 | { |
---|
1546 | printf("\nWarning: this is not a valid random access point and the data is discarded until the first CRA picture"); |
---|
1547 | m_warningMessageSkipPicture = true; |
---|
1548 | } |
---|
1549 | return true; |
---|
1550 | } |
---|
1551 | } |
---|
1552 | // skip the reordered pictures, if necessary |
---|
1553 | 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)) |
---|
1554 | { |
---|
1555 | iPOCLastDisplay++; |
---|
1556 | return true; |
---|
1557 | } |
---|
1558 | // if we reach here, then the picture is not skipped. |
---|
1559 | return false; |
---|
1560 | } |
---|
1561 | |
---|
1562 | #else |
---|
1563 | |
---|
1564 | Int TDecTop::preDecodePoc( Bool firstPicInLayerDecodedFlag, Bool isFstPicOfAllLayOfPocResetPer, Bool isPocResettingPicture ) |
---|
1565 | { |
---|
1566 | //Output of this process is PicOrderCntVal, the picture order count of the current picture. |
---|
1567 | // Picture order counts are used to identify pictures, for deriving motion parameters in merge mode and |
---|
1568 | // motion vector prediction and for decoder conformance checking (see clause F.13.5). |
---|
1569 | |
---|
1570 | // Each coded picture is associated with a picture order count variable, denoted as PicOrderCntVal. |
---|
1571 | |
---|
1572 | TComSlice* slice = m_apcSlicePilot; |
---|
1573 | const Int nuhLayerId = slice->getLayerId(); |
---|
1574 | const TComVPS* vps = slice->getVPS(); |
---|
1575 | const TComSPS* sps = slice->getSPS(); |
---|
1576 | |
---|
1577 | Int pocDecrementedInDpbFlag = m_pocDecrementedInDpbFlag[ nuhLayerId ]; |
---|
1578 | |
---|
1579 | if ( isFstPicOfAllLayOfPocResetPer ) |
---|
1580 | { |
---|
1581 | // When the current picture is the first picture among all layers of a POC resetting period, |
---|
1582 | // the variable PocDecrementedInDPBFlag[ i ] is set equal to 0 for each value of i in the range of 0 to 62, inclusive. |
---|
1583 | pocDecrementedInDpbFlag = false; |
---|
1584 | } |
---|
1585 | |
---|
1586 | // The variable pocResettingFlag is derived as follows: |
---|
1587 | Bool pocResettingFlag; |
---|
1588 | if ( isPocResettingPicture ) |
---|
1589 | { |
---|
1590 | //- If the current picture is a POC resetting picture, the following applies: |
---|
1591 | if( vps->getVpsPocLsbAlignedFlag() ) |
---|
1592 | { |
---|
1593 | // - If vps_poc_lsb_aligned_flag is equal to 0, pocResettingFlag is set equal to 1. |
---|
1594 | pocResettingFlag = true; |
---|
1595 | } |
---|
1596 | else if ( pocDecrementedInDpbFlag ) |
---|
1597 | { |
---|
1598 | // - Otherwise, if PocDecrementedInDPBFlag[ nuh_layer_id ] is equal to 1, pocResettingFlag is set equal to 0. |
---|
1599 | pocResettingFlag = false; |
---|
1600 | } |
---|
1601 | else |
---|
1602 | { |
---|
1603 | // - Otherwise, pocResettingFlag is set equal to 1. |
---|
1604 | pocResettingFlag = true; |
---|
1605 | } |
---|
1606 | } |
---|
1607 | else |
---|
1608 | { |
---|
1609 | // - Otherwise, pocResettingFlag is set equal to 0. |
---|
1610 | pocResettingFlag = false; |
---|
1611 | } |
---|
1612 | |
---|
1613 | Int picOrderCntMsb; |
---|
1614 | Int picOrderCntVal; |
---|
1615 | |
---|
1616 | // Depending on pocResettingFlag, the following applies: |
---|
1617 | if ( pocResettingFlag ) |
---|
1618 | { |
---|
1619 | //- The PicOrderCntVal of the current picture is derived as follows: |
---|
1620 | if( slice->getPocResetIdc() == 1 ) |
---|
1621 | { |
---|
1622 | picOrderCntVal = slice->getSlicePicOrderCntLsb(); |
---|
1623 | } |
---|
1624 | else if (slice->getPocResetIdc() == 2 ) |
---|
1625 | { |
---|
1626 | picOrderCntVal = 0; |
---|
1627 | } |
---|
1628 | else |
---|
1629 | { |
---|
1630 | picOrderCntMsb = xGetCurrMsb( slice->getSlicePicOrderCntLsb(), slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal(), 0, sps->getMaxPicOrderCntLsb() ); |
---|
1631 | picOrderCntVal = picOrderCntMsb + slice->getSlicePicOrderCntLsb(); |
---|
1632 | } |
---|
1633 | } |
---|
1634 | else |
---|
1635 | { |
---|
1636 | //- Otherwise (pocResettingFlag is equal to 0), the following applies: |
---|
1637 | //- The PicOrderCntVal of the current picture is derived as follows: |
---|
1638 | |
---|
1639 | if( slice->getPocMsbCycleValPresentFlag() ) |
---|
1640 | { |
---|
1641 | picOrderCntMsb = slice->getPocMsbCycleVal() * sps->getMaxPicOrderCntLsb(); |
---|
1642 | } |
---|
1643 | else if( !firstPicInLayerDecodedFlag || |
---|
1644 | slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL ) |
---|
1645 | { |
---|
1646 | picOrderCntMsb = 0; // (F 62) |
---|
1647 | } |
---|
1648 | else |
---|
1649 | { |
---|
1650 | Int prevPicOrderCntLsb = m_prevPicOrderCnt & ( sps->getMaxPicOrderCntLsb() - 1 ); |
---|
1651 | Int prevPicOrderCntMsb = m_prevPicOrderCnt - prevPicOrderCntLsb; |
---|
1652 | picOrderCntMsb = xGetCurrMsb( slice->getSlicePicOrderCntLsb(), prevPicOrderCntLsb, prevPicOrderCntMsb, sps->getMaxPicOrderCntLsb() ); |
---|
1653 | } |
---|
1654 | picOrderCntVal = picOrderCntMsb + slice->getSlicePicOrderCntLsb(); |
---|
1655 | } |
---|
1656 | return picOrderCntVal; |
---|
1657 | } |
---|
1658 | |
---|
1659 | Void TDecTop::inferPocResetPeriodId() |
---|
1660 | { |
---|
1661 | // Infer PocResetPeriodId |
---|
1662 | // When not present, the value of poc_reset_period_id is inferred as follows: |
---|
1663 | |
---|
1664 | if ( !m_apcSlicePilot->getHasPocResetPeriodIdPresent() ) |
---|
1665 | { |
---|
1666 | if ( m_lastPresentPocResetIdc[ m_apcSlicePilot->getLayerId() ] != MIN_INT ) |
---|
1667 | { |
---|
1668 | // - If the previous picture picA that has poc_reset_period_id present in the slice segment header is present in the same layer |
---|
1669 | // of the bitstream as the current picture, the value of poc_reset_period_id is inferred to be equal to the value of the |
---|
1670 | // poc_reset_period_id of picA. |
---|
1671 | |
---|
1672 | m_apcSlicePilot->setPocResetPeriodId( m_lastPresentPocResetIdc[ m_apcSlicePilot->getLayerId() ] ); |
---|
1673 | } |
---|
1674 | else |
---|
1675 | { |
---|
1676 | //- Otherwise, the value of poc_reset_period_id is inferred to be equal to 0. |
---|
1677 | m_apcSlicePilot->setPocResetPeriodId( 0 ); |
---|
1678 | } |
---|
1679 | } |
---|
1680 | else |
---|
1681 | { |
---|
1682 | m_lastPresentPocResetIdc[ m_apcSlicePilot->getLayerId() ] = m_apcSlicePilot->getPocResetPeriodId(); |
---|
1683 | } |
---|
1684 | } |
---|
1685 | |
---|
1686 | |
---|
1687 | Void TDecTop::decodePocAndRps( ) |
---|
1688 | { |
---|
1689 | assert( m_uiSliceIdx == 0 ); |
---|
1690 | Int nuhLayerId = m_pcPic->getLayerId(); |
---|
1691 | if ( m_decProcPocAndRps == CLAUSE_8 ) |
---|
1692 | { |
---|
1693 | // 8.1.3 Decoding process for a coded picture with nuh_layer_id equal to 0 |
---|
1694 | |
---|
1695 | // Variables and functions relating to picture order count are derived as |
---|
1696 | // specified in clause 8.3.1. This needs to be invoked only for the first slice |
---|
1697 | // segment of a picture. |
---|
1698 | x831DecProcForPicOrderCount( ); |
---|
1699 | |
---|
1700 | // The decoding process for RPS in clause 8.3.2 is invoked, wherein reference |
---|
1701 | // pictures may be marked as "unused for reference" or "used for long-term |
---|
1702 | // reference". This needs to be invoked only for the first slice segment of a |
---|
1703 | // picture. |
---|
1704 | x832DecProcForRefPicSet ( false ); |
---|
1705 | } |
---|
1706 | else if( m_decProcPocAndRps == ANNEX_F ) |
---|
1707 | { |
---|
1708 | // F.8.1.3 Common decoding process for a coded picture |
---|
1709 | |
---|
1710 | if (nuhLayerId == 0 ) |
---|
1711 | { |
---|
1712 | // F.8.1.4 Decoding process for a coded picture with nuh_layer_id equal to |
---|
1713 | // --> Clause 8.1.3 is invoked with replacments of 8.3.1, 8.3.2, and 8.3.3 by F.8.3.1, 8.3.2, and 8.3.3 |
---|
1714 | |
---|
1715 | // Variables and functions relating to picture order count are derived as |
---|
1716 | // specified in clause 8.3.1. This needs to be invoked only for the first slice |
---|
1717 | // segment of a picture. |
---|
1718 | xF831DecProcForPicOrderCount( ); |
---|
1719 | |
---|
1720 | // The decoding process for RPS in clause 8.3.2 is invoked, wherein reference |
---|
1721 | // pictures may be marked as "unused for reference" or "used for long-term |
---|
1722 | // reference". This needs to be invoked only for the first slice segment of a |
---|
1723 | // picture. |
---|
1724 | xF832DecProcForRefPicSet( ); |
---|
1725 | } |
---|
1726 | else |
---|
1727 | { |
---|
1728 | // F.8.1.5 Decoding process for starting the decoding of a coded picture with |
---|
1729 | // nuh_layer_id greater than 0 |
---|
1730 | |
---|
1731 | // Variables and functions relating to picture order count are derived in clause F.8.3.1. |
---|
1732 | // This needs to be invoked only for the first slice segment of a picture. It is a requirement |
---|
1733 | // of bitstream conformance that PicOrderCntVal of each picture in an access unit shall have the |
---|
1734 | // same value during and at the end of decoding of the access unit |
---|
1735 | xF831DecProcForPicOrderCount( ); |
---|
1736 | |
---|
1737 | // The decoding process for RPS in clause F.8.3.2 is invoked, wherein only reference pictures with |
---|
1738 | // nuh_layer_id equal to that of CurrPic may be marked as "unused for reference" or "used for |
---|
1739 | // long-term reference" and any picture with a different value of nuh_layer_id is not marked. |
---|
1740 | // This needs to be invoked only for the first slice segment of a picture. |
---|
1741 | xF832DecProcForRefPicSet( ); |
---|
1742 | } |
---|
1743 | } |
---|
1744 | else |
---|
1745 | { |
---|
1746 | assert( false ); |
---|
1747 | } |
---|
1748 | } |
---|
1749 | |
---|
1750 | Void TDecTop::genUnavailableRefPics( ) |
---|
1751 | { |
---|
1752 | assert( m_uiSliceIdx == 0 ); |
---|
1753 | Int nuhLayerId = m_pcPic->getLayerId(); |
---|
1754 | if ( m_decProcPocAndRps == CLAUSE_8 ) |
---|
1755 | { |
---|
1756 | // 8.1.3 Decoding process for a coded picture with nuh_layer_id equal to 0 |
---|
1757 | |
---|
1758 | if ( m_pcPic->isBla() || ( m_pcPic->isCra() && m_pcPic->getNoRaslOutputFlag() ) ) |
---|
1759 | { |
---|
1760 | // When the current picture is a BLA picture or is a CRA picture |
---|
1761 | // with NoRaslOutputFlag equal to 1, the decoding process for generating |
---|
1762 | // unavailable reference pictures specified in clause 8.3.3 is invoked, |
---|
1763 | // which needs to be invoked only for the first slice segment of a picture. |
---|
1764 | x8331GenDecProcForGenUnavilRefPics(); |
---|
1765 | } |
---|
1766 | } |
---|
1767 | else if( m_decProcPocAndRps == ANNEX_F ) |
---|
1768 | { |
---|
1769 | // F.8.1.3 Common decoding process for a coded picture |
---|
1770 | |
---|
1771 | if (nuhLayerId == 0 ) |
---|
1772 | { |
---|
1773 | // F.8.1.4 Decoding process for a coded picture with nuh_layer_id equal to |
---|
1774 | // --> Clause 8.1.3 is invoked with replacments of 8.3.1, 8.3.2, and 8.3.3 by F.8.3.1, 8.3.2, and 8.3.3 |
---|
1775 | |
---|
1776 | if ( m_pcPic->isBla() || ( m_pcPic->isCra() && m_pcPic->getNoRaslOutputFlag() ) ) |
---|
1777 | { |
---|
1778 | // When the current picture is a BLA picture or is a CRA picture |
---|
1779 | // with NoRaslOutputFlag equal to 1, the decoding process for generating |
---|
1780 | // unavailable reference pictures specified in clause 8.3.3 is invoked, |
---|
1781 | // which needs to be invoked only for the first slice segment of a picture. |
---|
1782 | xF833DecProcForGenUnavRefPics(); |
---|
1783 | } |
---|
1784 | #if NH_MV_FIX_INIT_NUM_ACTIVE_REF_LAYER_PICS |
---|
1785 | TComDecodedRps* decRps = m_pcPic->getDecodedRps(); |
---|
1786 | decRps->m_numActiveRefLayerPics0 = 0; |
---|
1787 | decRps->m_numActiveRefLayerPics1 = 0; |
---|
1788 | #endif |
---|
1789 | } |
---|
1790 | else |
---|
1791 | { |
---|
1792 | // F.8.1.5 Decoding process for starting the decoding of a coded picture with |
---|
1793 | // nuh_layer_id greater than 0 |
---|
1794 | |
---|
1795 | if ( !m_firstPicInLayerDecodedFlag[ nuhLayerId ] ) |
---|
1796 | { |
---|
1797 | // When FirstPicInLayerDecodedFlag[ nuh_layer_id ] is equal to 0, the decoding process for generating |
---|
1798 | // unavailable reference pictures for pictures first in decoding order within a layer specified in |
---|
1799 | // clause F.8.1.7 is invoked, which needs to be invoked only for the first slice segment of a picture. |
---|
1800 | xF817DecProcForGenUnavRefPicForPicsFrstInDecOrderInLay(); |
---|
1801 | } |
---|
1802 | |
---|
1803 | if ( m_firstPicInLayerDecodedFlag[ nuhLayerId ] && ( m_pcPic->isIrap() && m_pcPic->getNoRaslOutputFlag() ) ) |
---|
1804 | { |
---|
1805 | // When FirstPicInLayerDecodedFlag[ nuh_layer_id ] is equal to 1 and the current picture is an IRAP |
---|
1806 | // picture with NoRaslOutputFlag equal to 1, the decoding process for generating unavailable reference |
---|
1807 | // pictures specified in clause F.8.3.3 is invoked, which needs to be invoked only for the first slice |
---|
1808 | // segment of a picture. |
---|
1809 | xF833DecProcForGenUnavRefPics(); |
---|
1810 | } |
---|
1811 | |
---|
1812 | if ( decProcAnnexG() ) |
---|
1813 | { |
---|
1814 | // G.1.2 --> G.1.3 |
---|
1815 | xG813DecProcForInterLayerRefPicSet(); |
---|
1816 | } |
---|
1817 | else |
---|
1818 | { |
---|
1819 | #if NH_MV_FIX_INIT_NUM_ACTIVE_REF_LAYER_PICS |
---|
1820 | TComDecodedRps* decRps = m_pcPic->getDecodedRps(); |
---|
1821 | decRps->m_numActiveRefLayerPics0 = 0; |
---|
1822 | decRps->m_numActiveRefLayerPics1 = 0; |
---|
1823 | #endif |
---|
1824 | } |
---|
1825 | } |
---|
1826 | } |
---|
1827 | else |
---|
1828 | { |
---|
1829 | assert( false ); |
---|
1830 | } |
---|
1831 | |
---|
1832 | xCheckUnavailableRefPics(); |
---|
1833 | } |
---|
1834 | Void TDecTop::executeLoopFilters( ) |
---|
1835 | { |
---|
1836 | assert( m_pcPic != NULL ); |
---|
1837 | if ( !m_pcPic->getHasGeneratedRefPics() && !m_pcPic->getIsGenerated() ) |
---|
1838 | { |
---|
1839 | m_cGopDecoder.filterPicture( m_pcPic ); |
---|
1840 | } |
---|
1841 | m_cCuDecoder.destroy(); |
---|
1842 | } |
---|
1843 | |
---|
1844 | Void TDecTop::finalizePic() |
---|
1845 | { |
---|
1846 | if( m_pcPic->isIrap() ) |
---|
1847 | { |
---|
1848 | m_prevIrapPoc = m_pcPic->getPOC(); |
---|
1849 | m_prevIrapDecodingOrder = m_pcPic->getDecodingOrder(); |
---|
1850 | } |
---|
1851 | if( m_pcPic->isStsa() ) |
---|
1852 | { |
---|
1853 | m_prevStsaDecOrder = m_pcPic->getDecodingOrder(); |
---|
1854 | m_prevStsaTemporalId = m_pcPic->getTemporalId() ; |
---|
1855 | } |
---|
1856 | } |
---|
1857 | |
---|
1858 | |
---|
1859 | Void TDecTop::initFromActiveVps( const TComVPS* vps ) |
---|
1860 | { |
---|
1861 | setViewId ( vps->getViewId ( getLayerId() ) ); |
---|
1862 | #if NH_3D |
---|
1863 | setViewIndex( vps->getViewIndex( getLayerId() ) ); |
---|
1864 | setIsDepth ( vps->getDepthId ( getLayerId() ) == 1 ); |
---|
1865 | #endif |
---|
1866 | |
---|
1867 | if ( !vps->getVpsExtensionFlag() ) |
---|
1868 | { |
---|
1869 | m_decodingProcess = CLAUSE_8; |
---|
1870 | m_isInOwnTargetDecLayerIdList = ( getLayerId() == 0 ); |
---|
1871 | } |
---|
1872 | else |
---|
1873 | { |
---|
1874 | if ( m_targetOlsIdx == -1 ) |
---|
1875 | { |
---|
1876 | // Corresponds to specification by "External Means". (Should be set equal to 0, when no external means available. ) |
---|
1877 | m_targetOlsIdx = vps->getVpsNumLayerSetsMinus1(); |
---|
1878 | } |
---|
1879 | |
---|
1880 | Int targetDecLayerSetIdx = vps->olsIdxToLsIdx( m_targetOlsIdx ); |
---|
1881 | |
---|
1882 | if ( targetDecLayerSetIdx <= vps->getVpsNumLayerSetsMinus1() && vps->getVpsBaseLayerInternalFlag() ) |
---|
1883 | { |
---|
1884 | m_smallestLayerId = 0; |
---|
1885 | } |
---|
1886 | else if ( targetDecLayerSetIdx <= vps->getVpsNumLayerSetsMinus1() && !vps->getVpsBaseLayerInternalFlag() ) |
---|
1887 | { |
---|
1888 | m_smallestLayerId = 0; |
---|
1889 | } |
---|
1890 | else if ( targetDecLayerSetIdx > vps->getVpsNumLayerSetsMinus1() && vps->getNumLayersInIdList( targetDecLayerSetIdx) == 1 ) |
---|
1891 | { |
---|
1892 | |
---|
1893 | // m_smallestLayerId = 0; |
---|
1894 | // For now don't do change of layer id here. |
---|
1895 | m_smallestLayerId = vps->getTargetDecLayerIdList( targetDecLayerSetIdx )[ 0 ]; |
---|
1896 | } |
---|
1897 | else |
---|
1898 | { |
---|
1899 | m_smallestLayerId = vps->getTargetDecLayerIdList( targetDecLayerSetIdx )[ 0 ]; |
---|
1900 | } |
---|
1901 | |
---|
1902 | |
---|
1903 | // Set profile |
---|
1904 | Int lsIdx = vps->olsIdxToLsIdx( m_targetOlsIdx ); |
---|
1905 | Int lIdx = -1; |
---|
1906 | for (Int j = 0; j < vps->getNumLayersInIdList( lsIdx ) ; j++ ) |
---|
1907 | { |
---|
1908 | if ( vps->getLayerSetLayerIdList( lsIdx, j ) == getLayerId() ) |
---|
1909 | { |
---|
1910 | lIdx = j; |
---|
1911 | break; |
---|
1912 | } |
---|
1913 | } |
---|
1914 | m_isInOwnTargetDecLayerIdList = (lIdx != -1); |
---|
1915 | |
---|
1916 | if ( m_isInOwnTargetDecLayerIdList ) |
---|
1917 | { |
---|
1918 | Int profileIdc = vps->getPTL( vps->getProfileTierLevelIdx( m_targetOlsIdx, lIdx ) )->getGeneralPTL()->getProfileIdc(); |
---|
1919 | |
---|
1920 | #if !NH_MV_ALLOW_NON_CONFORMING |
---|
1921 | assert( profileIdc == Profile::MAIN || profileIdc == Profile::MULTIVIEWMAIN|| profileIdc == Profile::MAIN3D ); |
---|
1922 | #else |
---|
1923 | assert( profileIdc == Profile::MAIN || profileIdc == Profile::MAIN10 || profileIdc == Profile::MULTIVIEWMAIN|| profileIdc == Profile::MAIN3D || profileIdc == Profile::NONE || profileIdc == Profile::MULTIVIEWMAIN_NONCONFORMING || profileIdc == Profile::MAIN3D_NONCONFORMING ); |
---|
1924 | #endif |
---|
1925 | |
---|
1926 | if ( profileIdc == Profile::MULTIVIEWMAIN |
---|
1927 | #if NH_MV_ALLOW_NON_CONFORMING |
---|
1928 | || profileIdc == Profile::MULTIVIEWMAIN_NONCONFORMING |
---|
1929 | #endif |
---|
1930 | ) |
---|
1931 | { |
---|
1932 | m_decodingProcess = ANNEX_G; |
---|
1933 | } |
---|
1934 | else if (profileIdc == 7 ) |
---|
1935 | { |
---|
1936 | m_decodingProcess = ANNEX_H; |
---|
1937 | } |
---|
1938 | else if (profileIdc == Profile::MAIN3D |
---|
1939 | #if NH_MV_ALLOW_NON_CONFORMING |
---|
1940 | || profileIdc == Profile::MAIN3D_NONCONFORMING |
---|
1941 | #endif |
---|
1942 | ) |
---|
1943 | { |
---|
1944 | m_decodingProcess = ANNEX_I; |
---|
1945 | } |
---|
1946 | } |
---|
1947 | } |
---|
1948 | } |
---|
1949 | |
---|
1950 | |
---|
1951 | Bool TDecTop::getFirstSliceSegementInPicFlag() |
---|
1952 | { |
---|
1953 | return m_apcSlicePilot->getFirstSliceSegementInPicFlag(); |
---|
1954 | } |
---|
1955 | |
---|
1956 | Void TDecTop::x831DecProcForPicOrderCount() |
---|
1957 | { |
---|
1958 | ///////////////////////////////////////////////////// |
---|
1959 | // 8.3.1 Decoding process for picture order count // |
---|
1960 | ///////////////////////////////////////////////////// |
---|
1961 | |
---|
1962 | // Output of this process is PicOrderCntVal, the picture order count of the current picture. |
---|
1963 | // Picture order counts are used to identify pictures, for deriving motion parameters in merge mode and |
---|
1964 | // motion vector prediction, and for decoder conformance checking (see clause C.5). |
---|
1965 | // Each coded picture is associated with a picture order count variable, denoted as PicOrderCntVal. |
---|
1966 | |
---|
1967 | const TComSlice* curSlice = m_pcPic->getSlice(0); |
---|
1968 | |
---|
1969 | Int prevPicOrderCntLsb = MIN_INT; |
---|
1970 | Int prevPicOrderCntMsb = MIN_INT; |
---|
1971 | if (!(m_pcPic->isIrap() && m_pcPic->getNoRaslOutputFlag() ) ) |
---|
1972 | { |
---|
1973 | // When the current picture is not an IRAP picture with NoRaslOutputFlag equal to 1, |
---|
1974 | // the variables prevPicOrderCntLsb and prevPicOrderCntMsb are derived as follows: |
---|
1975 | |
---|
1976 | // - Let prevTid0Pic be the previous picture in decoding order that has TemporalId equal to 0 and that is not a RASL picture, |
---|
1977 | // a RADL picture or an SLNR picture. |
---|
1978 | |
---|
1979 | // - The variable prevPicOrderCntLsb is set equal to slice_pic_order_cnt_lsb of prevTid0Pic. |
---|
1980 | prevPicOrderCntLsb = m_prevTid0PicSlicePicOrderCntLsb; |
---|
1981 | |
---|
1982 | // - The variable prevPicOrderCntMsb is set equal to PicOrderCntMsb of prevTid0Pic. |
---|
1983 | prevPicOrderCntMsb = m_prevTid0PicPicOrderCntMsb; |
---|
1984 | } |
---|
1985 | |
---|
1986 | // The variable PicOrderCntMsb of the current picture is derived as follows: |
---|
1987 | |
---|
1988 | Int slicePicOrderCntLsb = curSlice->getSlicePicOrderCntLsb(); |
---|
1989 | |
---|
1990 | Int picOrderCntMsb; |
---|
1991 | |
---|
1992 | if (m_pcPic->isIrap() && m_pcPic->getNoRaslOutputFlag() ) |
---|
1993 | { |
---|
1994 | //- If the current picture is an IRAP picture with NoRaslOutputFlag equal to 1, PicOrderCntMsb is set equal to 0. |
---|
1995 | picOrderCntMsb = 0; |
---|
1996 | } |
---|
1997 | else |
---|
1998 | { |
---|
1999 | Int maxPicOrderCntLsb = curSlice->getSPS()->getMaxPicOrderCntLsb(); |
---|
2000 | |
---|
2001 | // - Otherwise, PicOrderCntMsb is derived as follows: |
---|
2002 | |
---|
2003 | if( ( slicePicOrderCntLsb < prevPicOrderCntLsb ) && |
---|
2004 | ( ( prevPicOrderCntLsb - slicePicOrderCntLsb ) >= ( maxPicOrderCntLsb / 2 ) ) ) |
---|
2005 | { |
---|
2006 | picOrderCntMsb = prevPicOrderCntMsb + maxPicOrderCntLsb; // (8 1) |
---|
2007 | } |
---|
2008 | else if( (slicePicOrderCntLsb > prevPicOrderCntLsb ) && |
---|
2009 | ( ( slicePicOrderCntLsb - prevPicOrderCntLsb ) > ( maxPicOrderCntLsb / 2 ) ) ) |
---|
2010 | { |
---|
2011 | picOrderCntMsb = prevPicOrderCntMsb - maxPicOrderCntLsb; |
---|
2012 | } |
---|
2013 | else |
---|
2014 | { |
---|
2015 | picOrderCntMsb = prevPicOrderCntMsb; |
---|
2016 | } |
---|
2017 | } |
---|
2018 | |
---|
2019 | //PicOrderCntVal is derived as follows: |
---|
2020 | Int picOrderCntVal = picOrderCntMsb + slicePicOrderCntLsb; // (8 2) |
---|
2021 | |
---|
2022 | // NOTE 1 - All IDR pictures will have PicOrderCntVal equal to 0 since slice_pic_order_cnt_lsb is inferred to be 0 for IDR |
---|
2023 | // pictures and prevPicOrderCntLsb and prevPicOrderCntMsb are both set equal to 0. |
---|
2024 | |
---|
2025 | m_pcPic->getSlice(0)->setPOC( picOrderCntVal ); |
---|
2026 | |
---|
2027 | // Update prevTid0Pic |
---|
2028 | // Let prevTid0Pic be the previous picture in decoding order that has TemporalId equal to 0 and that is not a RASL picture, a RADL picture or an SLNR picture. |
---|
2029 | if( curSlice->getTemporalId() == 0 && !m_pcPic->isRasl() && !m_pcPic->isRadl() && !m_pcPic->isSlnr() ) |
---|
2030 | { |
---|
2031 | m_prevTid0PicSlicePicOrderCntLsb = slicePicOrderCntLsb; |
---|
2032 | m_prevTid0PicPicOrderCntMsb = picOrderCntMsb; |
---|
2033 | } |
---|
2034 | } |
---|
2035 | |
---|
2036 | Void TDecTop::xF831DecProcForPicOrderCount() |
---|
2037 | { |
---|
2038 | //Output of this process is PicOrderCntVal, the picture order count of the current picture. |
---|
2039 | // Picture order counts are used to identify pictures, for deriving motion parameters in merge mode and |
---|
2040 | // motion vector prediction and for decoder conformance checking (see clause F.13.5). |
---|
2041 | |
---|
2042 | // Each coded picture is associated with a picture order count variable, denoted as PicOrderCntVal. |
---|
2043 | |
---|
2044 | const TComSlice* slice = m_pcPic->getSlice(0); |
---|
2045 | const Int nuhLayerId = m_pcPic->getLayerId(); |
---|
2046 | const TComVPS* vps = slice->getVPS(); |
---|
2047 | const TComSPS* sps = slice->getSPS(); |
---|
2048 | if ( m_pcPic->getIsFstPicOfAllLayOfPocResetPer() ) |
---|
2049 | { |
---|
2050 | // When the current picture is the first picture among all layers of a POC resetting period, |
---|
2051 | // the variable PocDecrementedInDPBFlag[ i ] is set equal to 0 for each value of i in the range of 0 to 62, inclusive. |
---|
2052 | for (Int i = 0; i <= 62; i++) |
---|
2053 | { |
---|
2054 | m_pocDecrementedInDpbFlag[ i ] = 0; |
---|
2055 | } |
---|
2056 | } |
---|
2057 | |
---|
2058 | // The variable pocResettingFlag is derived as follows: |
---|
2059 | Bool pocResettingFlag; |
---|
2060 | if (m_pcPic->getIsPocResettingPic() ) |
---|
2061 | { |
---|
2062 | //- If the current picture is a POC resetting picture, the following applies: |
---|
2063 | if( vps->getVpsPocLsbAlignedFlag() ) |
---|
2064 | { |
---|
2065 | // - If vps_poc_lsb_aligned_flag is equal to 0, pocResettingFlag is set equal to 1. |
---|
2066 | pocResettingFlag = true; |
---|
2067 | } |
---|
2068 | else if ( m_pocDecrementedInDpbFlag[ nuhLayerId ] ) |
---|
2069 | { |
---|
2070 | // - Otherwise, if PocDecrementedInDPBFlag[ nuh_layer_id ] is equal to 1, pocResettingFlag is set equal to 0. |
---|
2071 | pocResettingFlag = false; |
---|
2072 | } |
---|
2073 | else |
---|
2074 | { |
---|
2075 | // - Otherwise, pocResettingFlag is set equal to 1. |
---|
2076 | pocResettingFlag = true; |
---|
2077 | } |
---|
2078 | } |
---|
2079 | else |
---|
2080 | { |
---|
2081 | // - Otherwise, pocResettingFlag is set equal to 0. |
---|
2082 | pocResettingFlag = false; |
---|
2083 | } |
---|
2084 | |
---|
2085 | // The list affectedLayerList is derived as follows: |
---|
2086 | std::vector<Int> affectedLayerList; |
---|
2087 | if (! vps->getVpsPocLsbAlignedFlag() ) |
---|
2088 | { |
---|
2089 | //- If vps_poc_lsb_aligned_flag is equal to 0, affectedLayerList consists of the nuh_layer_id of the current picture. |
---|
2090 | affectedLayerList.push_back( nuhLayerId ); |
---|
2091 | } |
---|
2092 | else |
---|
2093 | { |
---|
2094 | // - Otherwise, affectedLayerList consists of the nuh_layer_id of the current picture and the nuh_layer_id values |
---|
2095 | // equal to IdPredictedLayer[ currNuhLayerId ][ j ] for all values of j in the range of 0 to NumPredictedLayers[ currNuhLayerId ] - 1, |
---|
2096 | // inclusive, where currNuhLayerId is the nuh_layer_id value of the current picture. |
---|
2097 | affectedLayerList.push_back( nuhLayerId ); |
---|
2098 | Int currNuhLayerId = nuhLayerId; |
---|
2099 | for (Int j = 0; j <= vps->getNumPredictedLayers( currNuhLayerId )-1; j++ ) |
---|
2100 | { |
---|
2101 | affectedLayerList.push_back( vps->getIdPredictedLayer(currNuhLayerId, j ) ); |
---|
2102 | } |
---|
2103 | } |
---|
2104 | |
---|
2105 | Int picOrderCntMsb; |
---|
2106 | Int picOrderCntVal; |
---|
2107 | |
---|
2108 | // Depending on pocResettingFlag, the following applies: |
---|
2109 | if ( pocResettingFlag ) |
---|
2110 | { |
---|
2111 | //- If pocResettingFlag is equal to 1, the following applies: |
---|
2112 | if ( m_firstPicInLayerDecodedFlag[ nuhLayerId ] ) |
---|
2113 | { |
---|
2114 | //- The variables pocMsbDelta, pocLsbDelta and DeltaPocVal are derived as follows: |
---|
2115 | Int pocMsbDelta; |
---|
2116 | Int pocLsbDelta; |
---|
2117 | Int deltaPocVal; |
---|
2118 | |
---|
2119 | { |
---|
2120 | Int pocLsbVal; |
---|
2121 | Int prevPicOrderCntLsb; |
---|
2122 | Int prevPicOrderCntMsb; |
---|
2123 | |
---|
2124 | if( slice->getPocResetIdc() == 3 ) |
---|
2125 | { |
---|
2126 | pocLsbVal = slice->getPocLsbVal(); |
---|
2127 | } |
---|
2128 | else |
---|
2129 | { |
---|
2130 | pocLsbVal = slice->getSlicePicOrderCntLsb(); |
---|
2131 | } |
---|
2132 | |
---|
2133 | if( slice->getPocMsbCycleValPresentFlag() ) |
---|
2134 | { |
---|
2135 | pocMsbDelta = slice->getPocMsbCycleVal() * sps->getMaxPicOrderCntLsb(); // (F 60) |
---|
2136 | } |
---|
2137 | else |
---|
2138 | { |
---|
2139 | prevPicOrderCntLsb = m_prevPicOrderCnt & ( sps->getMaxPicOrderCntLsb() - 1 ); |
---|
2140 | prevPicOrderCntMsb = m_prevPicOrderCnt - prevPicOrderCntLsb; |
---|
2141 | |
---|
2142 | pocMsbDelta = xGetCurrMsb( pocLsbVal, prevPicOrderCntLsb, prevPicOrderCntMsb, sps->getMaxPicOrderCntLsb() ); |
---|
2143 | } |
---|
2144 | |
---|
2145 | if( slice->getPocResetIdc() == 2 || ( slice->getPocResetIdc() == 3 && slice->getFullPocResetFlag() ) ) |
---|
2146 | { |
---|
2147 | pocLsbDelta = pocLsbVal; |
---|
2148 | } |
---|
2149 | else |
---|
2150 | { |
---|
2151 | pocLsbDelta = 0; |
---|
2152 | } |
---|
2153 | deltaPocVal = pocMsbDelta + pocLsbDelta; |
---|
2154 | } |
---|
2155 | |
---|
2156 | //- The PicOrderCntVal of each picture that has nuh_layer_id value nuhLayerId for which PocDecrementedInDPBFlag[ nuhLayerId ] is equal to 0 |
---|
2157 | // and that is equal to any value in affectedLayerList is decremented by DeltaPocVal. |
---|
2158 | for (Int i = 0; i < (Int) affectedLayerList.size(); i++ ) |
---|
2159 | { |
---|
2160 | if ( !m_pocDecrementedInDpbFlag[ affectedLayerList[i] ] ) |
---|
2161 | { |
---|
2162 | m_dpb->decrementPocsInSubDpb( affectedLayerList[i], deltaPocVal ); |
---|
2163 | } |
---|
2164 | } |
---|
2165 | |
---|
2166 | //- PocDecrementedInDPBFlag[ nuhLayerId ] is set equal to 1 for each value of nuhLayerId included in affectedLayerList. |
---|
2167 | for (Int i = 0; i < (Int) affectedLayerList.size(); i++ ) |
---|
2168 | { |
---|
2169 | m_pocDecrementedInDpbFlag[ affectedLayerList[i] ] = true; |
---|
2170 | } |
---|
2171 | } |
---|
2172 | |
---|
2173 | //- The PicOrderCntVal of the current picture is derived as follows: |
---|
2174 | if( slice->getPocResetIdc() == 1 ) |
---|
2175 | { |
---|
2176 | picOrderCntVal = slice->getSlicePicOrderCntLsb(); |
---|
2177 | } |
---|
2178 | else if (slice->getPocResetIdc() == 2 ) |
---|
2179 | { |
---|
2180 | picOrderCntVal = 0; |
---|
2181 | } |
---|
2182 | else |
---|
2183 | { |
---|
2184 | picOrderCntMsb = xGetCurrMsb( slice->getSlicePicOrderCntLsb(), slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal(), 0, sps->getMaxPicOrderCntLsb() ); |
---|
2185 | picOrderCntVal = picOrderCntMsb + slice->getSlicePicOrderCntLsb(); |
---|
2186 | } |
---|
2187 | } |
---|
2188 | else |
---|
2189 | { |
---|
2190 | //- Otherwise (pocResettingFlag is equal to 0), the following applies: |
---|
2191 | //- The PicOrderCntVal of the current picture is derived as follows: |
---|
2192 | |
---|
2193 | if( slice->getPocMsbCycleValPresentFlag() ) |
---|
2194 | { |
---|
2195 | picOrderCntMsb = slice->getPocMsbCycleVal() * sps->getMaxPicOrderCntLsb(); |
---|
2196 | } |
---|
2197 | else if( !m_firstPicInLayerDecodedFlag[ nuhLayerId ] || |
---|
2198 | slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL ) |
---|
2199 | { |
---|
2200 | picOrderCntMsb = 0; // (F 62) |
---|
2201 | } |
---|
2202 | else |
---|
2203 | { |
---|
2204 | Int prevPicOrderCntLsb = m_prevPicOrderCnt & ( sps->getMaxPicOrderCntLsb() - 1 ); |
---|
2205 | Int prevPicOrderCntMsb = m_prevPicOrderCnt - prevPicOrderCntLsb; |
---|
2206 | picOrderCntMsb = xGetCurrMsb( slice->getSlicePicOrderCntLsb(), prevPicOrderCntLsb, prevPicOrderCntMsb, sps->getMaxPicOrderCntLsb() ); |
---|
2207 | } |
---|
2208 | picOrderCntVal = picOrderCntMsb + slice->getSlicePicOrderCntLsb(); |
---|
2209 | } |
---|
2210 | |
---|
2211 | m_pcPic->getSlice(0)->setPOC( picOrderCntVal ); |
---|
2212 | |
---|
2213 | for (Int lId = 0; lId < (Int) affectedLayerList.size(); lId++ ) |
---|
2214 | { |
---|
2215 | // The value of PrevPicOrderCnt[ lId ] for each of the lId values included in affectedLayerList is derived as follows: |
---|
2216 | |
---|
2217 | if (!m_pcPic->isRasl() && !m_pcPic->isRadl() && !m_pcPic->isSlnr() && slice->getTemporalId() == 0 && !slice->getDiscardableFlag() ) |
---|
2218 | { |
---|
2219 | //- If the current picture is not a RASL picture, a RADL picture or a sub-layer non-reference picture, and the current picture |
---|
2220 | // has TemporalId equal to 0 and discardable_flag equal to 0, PrevPicOrderCnt[ lId ] is set equal to PicOrderCntVal. |
---|
2221 | m_prevPicOrderCnt = picOrderCntVal; |
---|
2222 | } |
---|
2223 | else if ( slice->getPocResetIdc() == 3 && ( |
---|
2224 | ( !m_firstPicInLayerDecodedFlag[ nuhLayerId ]) || |
---|
2225 | ( m_firstPicInLayerDecodedFlag[ nuhLayerId ] && m_pcPic->getIsPocResettingPic() ) |
---|
2226 | ) ) |
---|
2227 | { |
---|
2228 | // - Otherwise, when poc_reset_idc is equal to 3 and one of the following conditions is true, PrevPicOrderCnt[ lId ] is set equal to ( full_poc_reset_flag ? 0 : poc_lsb_val ): |
---|
2229 | // - FirstPicInLayerDecodedFlag[ nuh_layer_id ] is equal to 0. |
---|
2230 | // - FirstPicInLayerDecodedFlag[ nuh_layer_id ] is equal to 1 and the current picture is a POC resetting picture. |
---|
2231 | m_prevPicOrderCnt = ( slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal() ); |
---|
2232 | } |
---|
2233 | } |
---|
2234 | } |
---|
2235 | |
---|
2236 | Int TDecTop::xGetCurrMsb( Int cl, Int pl, Int pm, Int ml ) |
---|
2237 | { |
---|
2238 | Int currMsb; |
---|
2239 | if ((pl - cl) >= (ml/ 2)) |
---|
2240 | { |
---|
2241 | currMsb = pm + ml; |
---|
2242 | } |
---|
2243 | else if ( (cl - pl) > (ml / 2)) |
---|
2244 | { |
---|
2245 | currMsb = pm - ml; |
---|
2246 | } |
---|
2247 | else |
---|
2248 | { |
---|
2249 | currMsb = pm; |
---|
2250 | } |
---|
2251 | |
---|
2252 | return currMsb; |
---|
2253 | } |
---|
2254 | |
---|
2255 | |
---|
2256 | |
---|
2257 | Void TDecTop::x832DecProcForRefPicSet( Bool annexFModifications ) |
---|
2258 | { |
---|
2259 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
2260 | // 8.3.2 8.3.2 Decoding process for reference picture set |
---|
2261 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
2262 | |
---|
2263 | TComSlice* slice = m_pcPic->getSlice( 0 ); |
---|
2264 | const TComSPS* sps = slice->getSPS(); |
---|
2265 | // This process is invoked once per picture, after decoding of a slice header but prior to the decoding of any coding unit and prior |
---|
2266 | // to the decoding process for reference picture list construction for the slice as specified in clause 8.3.3. |
---|
2267 | // This process may result in one or more reference pictures in the DPB being marked as "unused for reference" or |
---|
2268 | // "used for long-term reference". |
---|
2269 | |
---|
2270 | // The variable currPicLayerId is set equal to nuh_layer_id of the current picture. |
---|
2271 | Int currPicLayerId = m_pcPic->getLayerId(); |
---|
2272 | Int picOrderCntVal = m_pcPic->getPOC(); |
---|
2273 | |
---|
2274 | if (m_pcPic->isIrap() && m_pcPic->getNoRaslOutputFlag() ) |
---|
2275 | { |
---|
2276 | // When the current picture is an IRAP picture with NoRaslOutputFlag equal to 1, |
---|
2277 | // all reference pictures with nuh_layer_id equal to currPicLayerId currently in the |
---|
2278 | // DPB (if any) are marked as "unused for reference". |
---|
2279 | m_dpb->markSubDpbAsUnusedForReference( currPicLayerId ); |
---|
2280 | } |
---|
2281 | // Short-term reference pictures are identified by their PicOrderCntVal values. Long-term reference pictures are identified either by |
---|
2282 | // their PicOrderCntVal values or their slice_pic_order_cnt_lsb values. |
---|
2283 | |
---|
2284 | // Five lists of picture order count values are constructed to derive the RPS. These five lists are PocStCurrBefore, |
---|
2285 | // PocStCurrAfter, PocStFoll, PocLtCurr and PocLtFoll, with NumPocStCurrBefore, NumPocStCurrAfter, NumPocStFoll, |
---|
2286 | // NumPocLtCurr and NumPocLtFoll number of elements, respectively. The five lists and the five variables are derived as follows: |
---|
2287 | |
---|
2288 | TComDecodedRps* decRps = m_pcPic->getDecodedRps(); |
---|
2289 | |
---|
2290 | std::vector<Int>& pocStCurrBefore = decRps->m_pocStCurrBefore; |
---|
2291 | std::vector<Int>& pocStCurrAfter = decRps->m_pocStCurrAfter; |
---|
2292 | std::vector<Int>& pocStFoll = decRps->m_pocStFoll; |
---|
2293 | std::vector<Int>& pocLtCurr = decRps->m_pocLtCurr; |
---|
2294 | std::vector<Int>& pocLtFoll = decRps->m_pocLtFoll; |
---|
2295 | |
---|
2296 | Int& numPocStCurrBefore = decRps->m_numPocStCurrBefore; |
---|
2297 | Int& numPocStCurrAfter = decRps->m_numPocStCurrAfter; |
---|
2298 | Int& numPocStFoll = decRps->m_numPocStFoll; |
---|
2299 | Int& numPocLtCurr = decRps->m_numPocLtCurr; |
---|
2300 | Int& numPocLtFoll = decRps->m_numPocLtFoll; |
---|
2301 | |
---|
2302 | std::vector<Int> currDeltaPocMsbPresentFlag, follDeltaPocMsbPresentFlag; |
---|
2303 | |
---|
2304 | if (m_pcPic->isIdr() ) |
---|
2305 | { |
---|
2306 | // - If the current picture is an IDR picture, PocStCurrBefore, PocStCurrAfter, PocStFoll, |
---|
2307 | // PocLtCurr and PocLtFoll are all set to be empty, and NumPocStCurrBefore, |
---|
2308 | // NumPocStCurrAfter, NumPocStFoll, NumPocLtCurr and NumPocLtFoll are all set equal to 0. |
---|
2309 | |
---|
2310 | pocStCurrBefore.clear(); |
---|
2311 | pocStCurrAfter .clear(); |
---|
2312 | pocStFoll .clear(); |
---|
2313 | pocLtCurr .clear(); |
---|
2314 | pocLtFoll .clear(); |
---|
2315 | numPocStCurrBefore = 0; |
---|
2316 | numPocStCurrAfter = 0; |
---|
2317 | numPocStFoll = 0; |
---|
2318 | numPocLtCurr = 0; |
---|
2319 | numPocLtFoll = 0; |
---|
2320 | } |
---|
2321 | else |
---|
2322 | { |
---|
2323 | const TComStRefPicSet* stRps = slice->getStRps( slice->getCurrRpsIdx() ); |
---|
2324 | // - Otherwise, the following applies: |
---|
2325 | |
---|
2326 | Int j = 0; |
---|
2327 | Int k = 0; |
---|
2328 | for( Int i = 0; i < stRps->getNumNegativePicsVar() ; i++ ) |
---|
2329 | { |
---|
2330 | if( stRps->getUsedByCurrPicS0Var( i ) ) |
---|
2331 | { |
---|
2332 | pocStCurrBefore.push_back( picOrderCntVal + stRps->getDeltaPocS0Var( i ) ); j++; |
---|
2333 | } |
---|
2334 | else |
---|
2335 | { |
---|
2336 | pocStFoll .push_back( picOrderCntVal + stRps->getDeltaPocS0Var( i ) ); k++; |
---|
2337 | } |
---|
2338 | } |
---|
2339 | numPocStCurrBefore = j; |
---|
2340 | |
---|
2341 | j = 0; |
---|
2342 | for (Int i = 0; i < stRps->getNumPositivePicsVar(); i++ ) |
---|
2343 | { |
---|
2344 | if (stRps->getUsedByCurrPicS1Var( i ) ) |
---|
2345 | { |
---|
2346 | pocStCurrAfter.push_back( picOrderCntVal + stRps->getDeltaPocS1Var( i ) ); j++; |
---|
2347 | } |
---|
2348 | else |
---|
2349 | { |
---|
2350 | pocStFoll .push_back( picOrderCntVal + stRps->getDeltaPocS1Var( i ) ); k++; |
---|
2351 | } |
---|
2352 | } |
---|
2353 | numPocStCurrAfter = j; |
---|
2354 | numPocStFoll = k; // (8 5) |
---|
2355 | |
---|
2356 | |
---|
2357 | j = 0; |
---|
2358 | k = 0; |
---|
2359 | for( Int i = 0; i < slice->getNumLongTermSps( ) + slice->getNumLongTermPics(); i++ ) |
---|
2360 | { |
---|
2361 | Int pocLt = slice->getPocLsbLtVar( i ); |
---|
2362 | if( slice->getDeltaPocMsbPresentFlag( i ) ) |
---|
2363 | { |
---|
2364 | pocLt += picOrderCntVal - slice->getDeltaPocMsbCycleLtVar( i ) * sps->getMaxPicOrderCntLsb() - |
---|
2365 | ( picOrderCntVal & ( sps->getMaxPicOrderCntLsb() - 1 ) ); |
---|
2366 | } |
---|
2367 | |
---|
2368 | if( slice->getUsedByCurrPicLtVar(i)) |
---|
2369 | { |
---|
2370 | pocLtCurr.push_back( pocLt ); |
---|
2371 | currDeltaPocMsbPresentFlag.push_back( slice->getDeltaPocMsbPresentFlag( i ) ); j++; |
---|
2372 | } |
---|
2373 | else |
---|
2374 | { |
---|
2375 | pocLtFoll.push_back( pocLt ); |
---|
2376 | follDeltaPocMsbPresentFlag.push_back( slice->getDeltaPocMsbPresentFlag( i ) ); k++; |
---|
2377 | } |
---|
2378 | } |
---|
2379 | numPocLtCurr = j; |
---|
2380 | numPocLtFoll = k; |
---|
2381 | } |
---|
2382 | |
---|
2383 | assert(numPocStCurrAfter == pocStCurrAfter .size() ); |
---|
2384 | assert(numPocStCurrBefore == pocStCurrBefore .size() ); |
---|
2385 | assert(numPocStFoll == pocStFoll .size() ); |
---|
2386 | assert(numPocLtCurr == pocLtCurr .size() ); |
---|
2387 | assert(numPocLtFoll == pocLtFoll .size() ); |
---|
2388 | |
---|
2389 | // where PicOrderCntVal is the picture order count of the current picture as specified in clause 8.3.1. |
---|
2390 | |
---|
2391 | // NOTE 2 - A value of CurrRpsIdx in the range of 0 to num_short_term_ref_pic_sets - 1, inclusive, |
---|
2392 | // indicates that a candidate short-term RPS from the active SPS for the current layer is being used, |
---|
2393 | // where CurrRpsIdx is the index of the candidate short-term RPS into the list of candidate short-term RPSs signalled |
---|
2394 | // in the active SPS for the current layer. CurrRpsIdx equal to num_short_term_ref_pic_sets indicates that |
---|
2395 | // the short-term RPS of the current picture is directly signalled in the slice header. |
---|
2396 | |
---|
2397 | for (Int i = 0; i <= numPocLtCurr - 1; i++ ) |
---|
2398 | { |
---|
2399 | // For each i in the range of 0 to NumPocLtCurr - 1, inclusive, when CurrDeltaPocMsbPresentFlag[ i ] is equal to 1, |
---|
2400 | // it is a requirement of bitstream conformance that the following conditions apply: |
---|
2401 | if ( currDeltaPocMsbPresentFlag[i] ) |
---|
2402 | { |
---|
2403 | // - There shall be no j in the range of 0 to NumPocStCurrBefore - 1, inclusive, |
---|
2404 | // for which PocLtCurr[ i ] is equal to PocStCurrBefore[ j ]. |
---|
2405 | for (Int j = 0; j <= numPocStCurrBefore - 1; j++ ) |
---|
2406 | { |
---|
2407 | assert(!( pocLtCurr[ i ] == pocStCurrBefore[ j ] ) ); |
---|
2408 | } |
---|
2409 | |
---|
2410 | // - There shall be no j in the range of 0 to NumPocStCurrAfter - 1, inclusive, |
---|
2411 | // for which PocLtCurr[ i ] is equal to PocStCurrAfter[ j ]. |
---|
2412 | for (Int j = 0; j <= numPocStCurrAfter - 1; j++ ) |
---|
2413 | { |
---|
2414 | assert(!( pocLtCurr[ i ] == pocStCurrAfter[ j ] ) ); |
---|
2415 | } |
---|
2416 | |
---|
2417 | // - There shall be no j in the range of 0 to NumPocStFoll - 1, inclusive, |
---|
2418 | // for which PocLtCurr[ i ] is equal to PocStFoll[ j ]. |
---|
2419 | for (Int j = 0; j <= numPocStFoll - 1; j++ ) |
---|
2420 | { |
---|
2421 | assert(!( pocLtCurr[ i ] == pocStFoll[ j ] ) ); |
---|
2422 | } |
---|
2423 | |
---|
2424 | // - There shall be no j in the range of 0 to NumPocLtCurr - 1, inclusive, |
---|
2425 | // where j is not equal to i, for which PocLtCurr[ i ] is equal to PocLtCurr[ j ]. |
---|
2426 | for (Int j = 0; j <= numPocLtCurr - 1; j++ ) |
---|
2427 | { |
---|
2428 | if ( i != j ) |
---|
2429 | { |
---|
2430 | assert(!( pocLtCurr[ i ] == pocLtCurr[ j ] ) ); |
---|
2431 | } |
---|
2432 | } |
---|
2433 | } |
---|
2434 | } |
---|
2435 | |
---|
2436 | for (Int i = 0; i <= numPocLtFoll - 1; i++ ) |
---|
2437 | { |
---|
2438 | // For each i in the range of 0 to NumPocLtFoll - 1, inclusive, when FollDeltaPocMsbPresentFlag[ i ] is equal to 1, |
---|
2439 | // it is a requirement of bitstream conformance that the following conditions apply: |
---|
2440 | if ( follDeltaPocMsbPresentFlag[i] ) |
---|
2441 | { |
---|
2442 | // - There shall be no j in the range of 0 to NumPocStCurrBefore - 1, inclusive, |
---|
2443 | // for which PocLtFoll[ i ] is equal to PocStCurrBefore[ j ]. |
---|
2444 | for (Int j = 0; j <= numPocStCurrBefore - 1; j++ ) |
---|
2445 | { |
---|
2446 | assert(!( pocLtFoll[ i ] == pocStCurrBefore[ j ] ) ); |
---|
2447 | } |
---|
2448 | |
---|
2449 | // - There shall be no j in the range of 0 to NumPocStCurrAfter - 1, inclusive, |
---|
2450 | // for which PocLtFoll[ i ] is equal to PocStCurrAfter[ j ]. |
---|
2451 | for (Int j = 0; j <= numPocStCurrAfter - 1; j++ ) |
---|
2452 | { |
---|
2453 | assert(!( pocLtFoll[ i ] == pocStCurrAfter[ j ] ) ); |
---|
2454 | } |
---|
2455 | |
---|
2456 | // - There shall be no j in the range of 0 to NumPocStFoll - 1, inclusive, |
---|
2457 | // for which PocLtFoll[ i ] is equal to PocStFoll[ j ]. |
---|
2458 | for (Int j = 0; j <= numPocStFoll - 1; j++ ) |
---|
2459 | { |
---|
2460 | assert(!( pocLtFoll[ i ] == pocStFoll[ j ] ) ); |
---|
2461 | } |
---|
2462 | |
---|
2463 | // - There shall be no j in the range of 0 to NumPocLtFoll - 1, inclusive, |
---|
2464 | // where j is not equal to i, for which PocLtFoll[ i ] is equal to PocLtFoll[ j ]. |
---|
2465 | for (Int j = 0; j <= numPocLtFoll - 1; j++ ) |
---|
2466 | { |
---|
2467 | if (j != i) |
---|
2468 | { |
---|
2469 | assert(!( pocLtFoll[ i ] == pocLtFoll[ j ] ) ); |
---|
2470 | } |
---|
2471 | } |
---|
2472 | |
---|
2473 | // - There shall be no j in the range of 0 to NumPocLtCurr - 1, inclusive, |
---|
2474 | // for which PocLtFoll[ i ] is equal to PocLtCurr[ j ]. |
---|
2475 | for (Int j = 0; j <= numPocLtCurr - 1; j++ ) |
---|
2476 | { |
---|
2477 | assert(!( pocLtFoll[ i ] == pocLtCurr[ j ] ) ); |
---|
2478 | } |
---|
2479 | } |
---|
2480 | } |
---|
2481 | |
---|
2482 | Int maxPicOrderCntLsb = sps->getMaxPicOrderCntLsb(); |
---|
2483 | for (Int i = 0; i <= numPocLtCurr - 1; i++ ) |
---|
2484 | { |
---|
2485 | // For each i in the range of 0 to NumPocLtCurr - 1, inclusive, when CurrDeltaPocMsbPresentFlag[ i ] is equal to 0, |
---|
2486 | // it is a requirement of bitstream conformance that the following conditions apply: |
---|
2487 | if ( currDeltaPocMsbPresentFlag[ i ] == 0 ) |
---|
2488 | { |
---|
2489 | // - There shall be no j in the range of 0 to NumPocStCurrBefore - 1, inclusive, |
---|
2490 | // for which PocLtCurr[ i ] is equal to ( PocStCurrBefore[ j ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
2491 | for (Int j = 0; j <= numPocStCurrBefore - 1; j++ ) |
---|
2492 | { |
---|
2493 | assert(!( pocLtCurr[ i ] == ( pocStCurrBefore[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) ); |
---|
2494 | } |
---|
2495 | |
---|
2496 | // - There shall be no j in the range of 0 to NumPocStCurrAfter - 1, inclusive, |
---|
2497 | // for which PocLtCurr[ i ] is equal to ( PocStCurrAfter[ j ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
2498 | for (Int j = 0; j <= numPocStCurrAfter - 1; j++ ) |
---|
2499 | { |
---|
2500 | assert(!( pocLtCurr[ i ] == ( pocStCurrAfter[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) ); |
---|
2501 | } |
---|
2502 | |
---|
2503 | // - There shall be no j in the range of 0 to NumPocStFoll - 1, inclusive, |
---|
2504 | // for which PocLtCurr[ i ] is equal to ( PocStFoll[ j ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
2505 | for (Int j = 0; j <= numPocStFoll - 1; j++ ) |
---|
2506 | { |
---|
2507 | assert(!( pocLtCurr[ i ] == ( pocStFoll[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) ); |
---|
2508 | } |
---|
2509 | |
---|
2510 | // - There shall be no j in the range of 0 to NumPocLtCurr - 1, inclusive, |
---|
2511 | // where j is not equal to i, for which PocLtCurr[ i ] is equal to ( PocLtCurr[ j ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
2512 | for (Int j = 0; j <= numPocLtCurr - 1; j++ ) |
---|
2513 | { |
---|
2514 | if (j != i) |
---|
2515 | { |
---|
2516 | assert(!( pocLtCurr[ i ] == ( pocLtCurr[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) ); |
---|
2517 | } |
---|
2518 | } |
---|
2519 | } |
---|
2520 | } |
---|
2521 | |
---|
2522 | for (Int i = 0; i <= numPocLtFoll - 1; i++ ) |
---|
2523 | { |
---|
2524 | // For each i in the range of 0 to NumPocLtFoll - 1, inclusive, when FollDeltaPocMsbPresentFlag[ i ] is equal to 0, |
---|
2525 | // it is a requirement of bitstream conformance that the following conditions apply: |
---|
2526 | if ( follDeltaPocMsbPresentFlag[ i ] == 0 ) |
---|
2527 | { |
---|
2528 | // - There shall be no j in the range of 0 to NumPocStCurrBefore - 1, inclusive, |
---|
2529 | // for which PocLtFoll[ i ] is equal to ( PocStCurrBefore[ j ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
2530 | for (Int j = 0; j <= numPocStCurrBefore - 1; j++ ) |
---|
2531 | { |
---|
2532 | assert(!( pocLtFoll[ i ] == ( pocStCurrBefore[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) ); |
---|
2533 | } |
---|
2534 | |
---|
2535 | // - There shall be no j in the range of 0 to NumPocStCurrAfter - 1, inclusive, |
---|
2536 | // for which PocLtFoll[ i ] is equal to ( PocStCurrAfter[ j ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
2537 | for (Int j = 0; j <= numPocStCurrAfter - 1; j++ ) |
---|
2538 | { |
---|
2539 | assert(!( pocLtFoll[ i ] == ( pocStCurrAfter[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) ); |
---|
2540 | } |
---|
2541 | |
---|
2542 | // - There shall be no j in the range of 0 to NumPocStFoll - 1, inclusive, |
---|
2543 | // for which PocLtFoll[ i ] is equal to ( PocStFoll[ j ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
2544 | for (Int j = 0; j <= numPocStFoll - 1; j++ ) |
---|
2545 | { |
---|
2546 | assert(!( pocLtFoll[ i ] == ( pocStFoll[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) ); |
---|
2547 | } |
---|
2548 | |
---|
2549 | // - There shall be no j in the range of 0 to NumPocLtFoll - 1, inclusive, |
---|
2550 | // where j is not equal to i, for which PocLtFoll[ i ] is equal to ( PocLtFoll[ j ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
2551 | for (Int j = 0; j <= numPocLtFoll - 1; j++ ) |
---|
2552 | { |
---|
2553 | if (j != i) |
---|
2554 | { |
---|
2555 | assert(!( pocLtFoll[ i ] == ( pocLtFoll[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) ); |
---|
2556 | } |
---|
2557 | } |
---|
2558 | |
---|
2559 | // - There shall be no j in the range of 0 to NumPocLtCurr - 1, inclusive, |
---|
2560 | // for which PocLtFoll[ i ] is equal to ( PocLtCurr[ j ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
2561 | for (Int j = 0; j <= numPocLtCurr - 1; j++ ) |
---|
2562 | { |
---|
2563 | assert(!( pocLtFoll[ i ] == ( pocLtCurr[ j ] & ( maxPicOrderCntLsb - 1 ) ) ) ); |
---|
2564 | } |
---|
2565 | } |
---|
2566 | } |
---|
2567 | |
---|
2568 | if ( !annexFModifications ) |
---|
2569 | { |
---|
2570 | // The variable NumPicTotalCurr is derived as specified in clause 7.4.7.2. |
---|
2571 | |
---|
2572 | // It is a requirement of bitstream conformance that the following applies to the value of NumPicTotalCurr: |
---|
2573 | if ( m_pcPic->isBla() || m_pcPic->isCra() ) |
---|
2574 | { |
---|
2575 | // - If the current picture is a BLA or CRA picture, the value of NumPicTotalCurr shall be equal to 0. |
---|
2576 | assert( slice->getNumPicTotalCurr() == 0 ); |
---|
2577 | } |
---|
2578 | else |
---|
2579 | { |
---|
2580 | // - Otherwise, |
---|
2581 | if ( slice->isInterP() || slice->isInterB() ) |
---|
2582 | { |
---|
2583 | // when the current picture contains a P or B slice, the value of NumPicTotalCurr shall not be equal to 0. |
---|
2584 | assert( slice->getNumPicTotalCurr() != 0 ); |
---|
2585 | } |
---|
2586 | } |
---|
2587 | } |
---|
2588 | |
---|
2589 | // The RPS of the current picture consists of five RPS lists; RefPicSetStCurrBefore, RefPicSetStCurrAfter, RefPicSetStFoll, |
---|
2590 | // RefPicSetLtCurr and RefPicSetLtFoll. RefPicSetStCurrBefore, RefPicSetStCurrAfter and RefPicSetStFoll are collectively |
---|
2591 | // referred to as the short-term RPS. RefPicSetLtCurr and RefPicSetLtFoll are collectively referred to as the long-term RPS. |
---|
2592 | |
---|
2593 | std::vector<TComPic*>& refPicSetStCurrBefore = decRps->m_refPicSetStCurrBefore; |
---|
2594 | std::vector<TComPic*>& refPicSetStCurrAfter = decRps->m_refPicSetStCurrAfter ; |
---|
2595 | std::vector<TComPic*>& refPicSetStFoll = decRps->m_refPicSetStFoll ; |
---|
2596 | std::vector<TComPic*>& refPicSetLtCurr = decRps->m_refPicSetLtCurr ; |
---|
2597 | std::vector<TComPic*>& refPicSetLtFoll = decRps->m_refPicSetLtFoll ; |
---|
2598 | |
---|
2599 | std::vector<TComPic*>** refPicSetsCurr = decRps->m_refPicSetsCurr ; |
---|
2600 | std::vector<TComPic*>** refPicSetsLt = decRps->m_refPicSetsLt ; |
---|
2601 | std::vector<TComPic*>** refPicSetsAll = decRps->m_refPicSetsAll ; |
---|
2602 | // NOTE 3 - RefPicSetStCurrBefore, RefPicSetStCurrAfter and RefPicSetLtCurr contain all reference pictures that may be |
---|
2603 | // used for inter prediction of the current picture and one or more pictures that follow the current picture in decoding order. |
---|
2604 | // RefPicSetStFoll and RefPicSetLtFoll consist of all reference pictures that are not used for inter prediction of the current |
---|
2605 | // picture but may be used in inter prediction for one or more pictures that follow the current picture in decoding order. |
---|
2606 | |
---|
2607 | // The derivation process for the RPS and picture marking are performed according to the following ordered steps: |
---|
2608 | // 1. The following applies: |
---|
2609 | |
---|
2610 | TComSubDpb* dpb = m_dpb->getSubDpb( getLayerId(), false ); |
---|
2611 | assert( refPicSetLtCurr.empty() ); |
---|
2612 | for( Int i = 0; i < numPocLtCurr; i++ ) |
---|
2613 | { |
---|
2614 | if( !currDeltaPocMsbPresentFlag[ i ] ) |
---|
2615 | { |
---|
2616 | refPicSetLtCurr.push_back( dpb->getPicFromLsb( pocLtCurr[ i ], maxPicOrderCntLsb ) ); |
---|
2617 | } |
---|
2618 | else |
---|
2619 | { |
---|
2620 | refPicSetLtCurr.push_back(dpb->getPic( pocLtCurr[ i ] )); |
---|
2621 | } |
---|
2622 | } |
---|
2623 | |
---|
2624 | assert( refPicSetLtFoll.empty() ); |
---|
2625 | for( Int i = 0; i < numPocLtFoll; i++ ) |
---|
2626 | { |
---|
2627 | if( !follDeltaPocMsbPresentFlag[ i ] ) |
---|
2628 | { |
---|
2629 | refPicSetLtFoll.push_back(dpb->getPicFromLsb(pocLtFoll[ i ], maxPicOrderCntLsb )); |
---|
2630 | } |
---|
2631 | else |
---|
2632 | { |
---|
2633 | refPicSetLtFoll.push_back(dpb->getPic( pocLtFoll[ i ] )); |
---|
2634 | } |
---|
2635 | } |
---|
2636 | |
---|
2637 | // 2. All reference pictures that are included in RefPicSetLtCurr or RefPicSetLtFoll and have nuh_layer_id equal |
---|
2638 | // to currPicLayerId are marked as "used for long-term reference". |
---|
2639 | for (Int i = 0; i < numPocLtCurr; i++) |
---|
2640 | { |
---|
2641 | if ( refPicSetLtCurr[i] != NULL ) |
---|
2642 | { |
---|
2643 | refPicSetLtCurr[i]->markAsUsedForLongTermReference(); |
---|
2644 | } |
---|
2645 | } |
---|
2646 | |
---|
2647 | for (Int i = 0; i < numPocLtFoll; i++) |
---|
2648 | { |
---|
2649 | if ( refPicSetLtFoll[i] != NULL ) |
---|
2650 | { |
---|
2651 | refPicSetLtFoll[i]->markAsUsedForLongTermReference(); |
---|
2652 | } |
---|
2653 | } |
---|
2654 | |
---|
2655 | // 3. The following applies: |
---|
2656 | assert( refPicSetStCurrBefore.empty() ); |
---|
2657 | for( Int i = 0; i < numPocStCurrBefore; i++ ) |
---|
2658 | { |
---|
2659 | refPicSetStCurrBefore.push_back(dpb->getShortTermRefPic( pocStCurrBefore[ i ] )); |
---|
2660 | } |
---|
2661 | |
---|
2662 | assert( refPicSetStCurrAfter.empty() ); |
---|
2663 | for( Int i = 0; i < numPocStCurrAfter; i++ ) |
---|
2664 | { |
---|
2665 | refPicSetStCurrAfter.push_back(dpb->getShortTermRefPic( pocStCurrAfter[ i ] )); |
---|
2666 | } |
---|
2667 | |
---|
2668 | assert( refPicSetStFoll.empty() ); |
---|
2669 | for( Int i = 0; i < numPocStFoll; i++ ) |
---|
2670 | { |
---|
2671 | refPicSetStFoll.push_back(dpb->getShortTermRefPic( pocStFoll[ i ] )); |
---|
2672 | } |
---|
2673 | |
---|
2674 | // 4. All reference pictures in the DPB that are not included in RefPicSetLtCurr, RefPicSetLtFoll, RefPicSetStCurrBefore, |
---|
2675 | // RefPicSetStCurrAfter, or RefPicSetStFoll and have nuh_layer_id equal to currPicLayerId are marked as "unused for reference". |
---|
2676 | TComSubDpb picsToMark = (*dpb); |
---|
2677 | for (Int j = 0; j < 5; j++ ) |
---|
2678 | { |
---|
2679 | picsToMark.removePics( *refPicSetsAll[j] ); |
---|
2680 | } |
---|
2681 | picsToMark.markAllAsUnusedForReference(); |
---|
2682 | |
---|
2683 | // NOTE 4 - There may be one or more entries in the RPS lists that are equal to "no reference picture" because |
---|
2684 | // the corresponding pictures are not present in the DPB. Entries in RefPicSetStFoll or RefPicSetLtFoll that are equal |
---|
2685 | // to "no reference picture" should be ignored. An unintentional picture loss should be inferred for each entry in |
---|
2686 | // RefPicSetStCurrBefore, RefPicSetStCurrAfter, or RefPicSetLtCurr that is equal to "no reference picture". |
---|
2687 | |
---|
2688 | // NOTE 5 - A picture cannot be included in more than one of the five RPS lists. |
---|
2689 | |
---|
2690 | |
---|
2691 | // It is a requirement of bitstream conformance that the RPS is restricted as follows: |
---|
2692 | |
---|
2693 | |
---|
2694 | #if NH_MV_FIX_NO_REF_PICS_CHECK |
---|
2695 | if ( !annexFModifications || m_firstPicInLayerDecodedFlag[ m_pcPic->getLayerId() ] ) |
---|
2696 | { |
---|
2697 | #endif |
---|
2698 | for (Int j = 0; j < 3; j++ ) |
---|
2699 | { |
---|
2700 | // - There shall be no entry in RefPicSetStCurrBefore, RefPicSetStCurrAfter or RefPicSetLtCurr |
---|
2701 | // for which one or more of the following are true: |
---|
2702 | |
---|
2703 | std::vector<TComPic*>* currSet = refPicSetsCurr[j]; |
---|
2704 | for (Int i = 0; i < currSet->size(); i++) |
---|
2705 | { |
---|
2706 | TComPic* pic = (*currSet)[i]; |
---|
2707 | |
---|
2708 | // - The entry is equal to "no reference picture". |
---|
2709 | assert( ! (pic == NULL ) ); |
---|
2710 | |
---|
2711 | // - The entry is an SLNR picture and has TemporalId equal to that of the current picture. |
---|
2712 | assert( !( pic->isSlnr() && pic->getTemporalId() == m_pcPic->getTemporalId() ) ); |
---|
2713 | |
---|
2714 | // - The entry is a picture that has TemporalId greater than that of the current picture. |
---|
2715 | assert( !( pic->getTemporalId() > m_pcPic->getTemporalId() ) ); |
---|
2716 | } |
---|
2717 | } |
---|
2718 | #if NH_MV_FIX_NO_REF_PICS_CHECK |
---|
2719 | } |
---|
2720 | #endif |
---|
2721 | |
---|
2722 | // - There shall be no entry in RefPicSetLtCurr or RefPicSetLtFoll for which the |
---|
2723 | // difference between the picture order count value of the current picture and the picture order count |
---|
2724 | // value of the entry is greater than or equal to 2^24. |
---|
2725 | for (Int j = 0; j < 2; j++ ) |
---|
2726 | { |
---|
2727 | std::vector<TComPic*>* ltSet = refPicSetsLt[j]; |
---|
2728 | for (Int i = 0; i < ltSet->size(); i++) |
---|
2729 | { |
---|
2730 | TComPic* pic = (*ltSet)[i]; |
---|
2731 | if( pic != NULL ) |
---|
2732 | { |
---|
2733 | assert(!( abs( m_pcPic->getPOC() - pic->getPOC() ) >= (1 << 24) )); |
---|
2734 | } |
---|
2735 | } |
---|
2736 | } |
---|
2737 | |
---|
2738 | // - When the current picture is a temporal sub-layer access (TSA) picture, there shall be no picture |
---|
2739 | // included in the RPS with TemporalId greater than or equal to the TemporalId of the current picture. |
---|
2740 | if (m_pcPic->isTsa() ) |
---|
2741 | { |
---|
2742 | for (Int j = 0; j < 5; j++ ) |
---|
2743 | { |
---|
2744 | std::vector<TComPic*>* aSet = refPicSetsAll[j]; |
---|
2745 | for (Int i = 0; i < aSet->size(); i++) |
---|
2746 | { |
---|
2747 | TComPic* pic = (*aSet)[i]; |
---|
2748 | if( pic != NULL ) |
---|
2749 | { |
---|
2750 | assert( ! (pic->getTemporalId() >= m_pcPic->getTemporalId() ) ); |
---|
2751 | } |
---|
2752 | } |
---|
2753 | } |
---|
2754 | } |
---|
2755 | |
---|
2756 | // - When the current picture is a step-wise temporal sub-layer access (STSA) picture, |
---|
2757 | // there shall be no picture included in RefPicSetStCurrBefore, RefPicSetStCurrAfter or RefPicSetLtCurr that has |
---|
2758 | // TemporalId equal to that of the current picture. |
---|
2759 | if (m_pcPic->isStsa() ) |
---|
2760 | { |
---|
2761 | for (Int j = 0; j < 3; j++ ) |
---|
2762 | { |
---|
2763 | std::vector<TComPic*>* cSet = refPicSetsCurr[j]; |
---|
2764 | for (Int i = 0; i < cSet->size(); i++) |
---|
2765 | { |
---|
2766 | TComPic* pic = (*cSet)[i]; |
---|
2767 | if( pic != NULL ) |
---|
2768 | { |
---|
2769 | assert( ! (pic->getTemporalId() == m_pcPic->getTemporalId() ) ); |
---|
2770 | } |
---|
2771 | } |
---|
2772 | } |
---|
2773 | } |
---|
2774 | |
---|
2775 | // - When the current picture is a picture that follows, in decoding order, an STSA picture |
---|
2776 | // that has TemporalId equal to that of the current picture, there shall be no picture that has |
---|
2777 | // TemporalId equal to that of the current picture included in RefPicSetStCurrBefore, RefPicSetStCurrAfter |
---|
2778 | // or RefPicSetLtCurr that precedes the STSA picture in decoding order. |
---|
2779 | if ( m_pcPic->getDecodingOrder() > m_prevStsaDecOrder && m_pcPic->getTemporalId() == m_prevStsaTemporalId ) |
---|
2780 | { |
---|
2781 | for (Int j = 0; j < 3; j++ ) |
---|
2782 | { |
---|
2783 | std::vector<TComPic*>* cSet = refPicSetsCurr[j]; |
---|
2784 | for (Int i = 0; i < cSet->size(); i++) |
---|
2785 | { |
---|
2786 | TComPic* pic = (*cSet)[i]; |
---|
2787 | if( pic != NULL ) |
---|
2788 | { |
---|
2789 | assert( ! (pic->getTemporalId() == m_pcPic->getTemporalId() && pic->getDecodingOrder() < m_prevStsaDecOrder ) ); |
---|
2790 | } |
---|
2791 | } |
---|
2792 | } |
---|
2793 | } |
---|
2794 | |
---|
2795 | // - When the current picture is a CRA picture, there shall be no picture included in the RPS that |
---|
2796 | // precedes, in output order or decoding order, any preceding IRAP picture in decoding order (when present). |
---|
2797 | if ( m_pcPic->isCra() ) |
---|
2798 | { |
---|
2799 | for (Int j = 0; j < 5; j++ ) |
---|
2800 | { |
---|
2801 | std::vector<TComPic*>* aSet = refPicSetsAll[j]; |
---|
2802 | for (Int i = 0; i < aSet->size(); i++) |
---|
2803 | { |
---|
2804 | // TBD check whether it sufficient to test only the last IRAP |
---|
2805 | TComPic* pic = (*aSet)[i]; |
---|
2806 | if( pic != NULL ) |
---|
2807 | { |
---|
2808 | assert( ! (pic->getPOC() < m_prevIrapPoc ) ); |
---|
2809 | assert( ! (pic->getDecodingOrder() < m_prevIrapDecodingOrder ) ); |
---|
2810 | } |
---|
2811 | } |
---|
2812 | } |
---|
2813 | } |
---|
2814 | |
---|
2815 | Bool isTrailingPicture = ( !m_pcPic->isIrap() ) && ( m_pcPic->getPOC() > m_prevIrapPoc ); |
---|
2816 | // - When the current picture is a trailing picture, there shall be no picture in RefPicSetStCurrBefore, |
---|
2817 | // RefPicSetStCurrAfter or RefPicSetLtCurr that was generated by the decoding process for generating unavailable |
---|
2818 | // reference pictures as specified in clause 8.3.3. |
---|
2819 | if ( isTrailingPicture ) |
---|
2820 | { |
---|
2821 | for (Int j = 0; j < 3; j++ ) |
---|
2822 | { |
---|
2823 | std::vector<TComPic*>* cSet = refPicSetsCurr[j]; |
---|
2824 | for (Int i = 0; i < cSet->size(); i++) |
---|
2825 | { |
---|
2826 | TComPic* pic = (*cSet)[i]; |
---|
2827 | if( pic != NULL ) |
---|
2828 | { |
---|
2829 | assert( ! (pic->getIsGeneratedCl833() ) ); |
---|
2830 | } |
---|
2831 | } |
---|
2832 | } |
---|
2833 | } |
---|
2834 | |
---|
2835 | // - When the current picture is a trailing picture, there shall be no picture in the RPS that precedes the |
---|
2836 | // associated IRAP picture in output order or decoding order. |
---|
2837 | if ( isTrailingPicture ) |
---|
2838 | { |
---|
2839 | for (Int j = 0; j < 5; j++ ) |
---|
2840 | { |
---|
2841 | std::vector<TComPic*>* aSet = refPicSetsAll[j]; |
---|
2842 | for (Int i = 0; i < aSet->size(); i++) |
---|
2843 | { |
---|
2844 | // TBD check whether it sufficient to test only the last IRAP |
---|
2845 | TComPic* pic = (*aSet)[i]; |
---|
2846 | if( pic != NULL ) |
---|
2847 | { |
---|
2848 | assert( ! (pic->getPOC() < m_prevIrapPoc ) ); |
---|
2849 | assert( ! (pic->getDecodingOrder() < m_prevIrapDecodingOrder ) ); |
---|
2850 | } |
---|
2851 | } |
---|
2852 | } |
---|
2853 | } |
---|
2854 | |
---|
2855 | // - When the current picture is a RADL picture, there shall be no picture included in RefPicSetStCurrBefore, |
---|
2856 | // RefPicSetStCurrAfter or RefPicSetLtCurr that is any of the following: |
---|
2857 | if ( m_pcPic->isRadl() ) |
---|
2858 | { |
---|
2859 | for (Int j = 0; j < 3; j++ ) |
---|
2860 | { |
---|
2861 | std::vector<TComPic*>* cSet = refPicSetsCurr[j]; |
---|
2862 | for (Int i = 0; i < cSet->size(); i++) |
---|
2863 | { |
---|
2864 | TComPic* pic = (*cSet)[i]; |
---|
2865 | if( pic != NULL ) |
---|
2866 | { |
---|
2867 | // - A RASL picture |
---|
2868 | assert( ! (pic->isRasl() ) ); |
---|
2869 | // - A picture that was generated by the decoding process for generating unavailable reference pictures |
---|
2870 | // as specified in clause 8.3.3 |
---|
2871 | assert( ! (pic->getIsGeneratedCl833() ) ); |
---|
2872 | // - A picture that precedes the associated IRAP picture in decoding order |
---|
2873 | assert( ! (pic->getDecodingOrder() < m_prevIrapDecodingOrder ) ); |
---|
2874 | } |
---|
2875 | } |
---|
2876 | } |
---|
2877 | } |
---|
2878 | |
---|
2879 | |
---|
2880 | if ( sps->getTemporalIdNestingFlag() ) |
---|
2881 | { |
---|
2882 | // - When sps_temporal_id_nesting_flag is equal to 1, the following applies: |
---|
2883 | // - Let tIdA be the value of TemporalId of the current picture picA. |
---|
2884 | TComPic* picA = m_pcPic; |
---|
2885 | Int tIdA = picA->getTemporalId(); |
---|
2886 | // - Any picture picB with TemporalId equal to tIdB that is less than or equal to tIdA shall not be included in |
---|
2887 | // RefPicSetStCurrBefore, RefPicSetStCurrAfter or RefPicSetLtCurr of picA when there exists a picture picC that |
---|
2888 | // has TemporalId less than tIdB, follows picB in decoding order, and precedes picA in decoding order. |
---|
2889 | for (Int j = 0; j < 3; j++ ) |
---|
2890 | { |
---|
2891 | std::vector<TComPic*>* cSet = refPicSetsCurr[j]; |
---|
2892 | for (Int i = 0; i < cSet->size(); i++) |
---|
2893 | { |
---|
2894 | TComPic* picB = (*cSet)[i]; |
---|
2895 | if( picB != NULL ) |
---|
2896 | { |
---|
2897 | Int tIdB = picB->getTemporalId(); |
---|
2898 | |
---|
2899 | if (tIdB <= tIdA) |
---|
2900 | { |
---|
2901 | for ( TComSubDpb::iterator itP = dpb->begin(); itP != dpb->end(); itP++ ) |
---|
2902 | { |
---|
2903 | TComPic* picC = (*itP); |
---|
2904 | assert(! ( picC->getTemporalId() < tIdB && picC->getDecodingOrder() > picB->getDecodingOrder() && picC->getDecodingOrder() < picA->getDecodingOrder() ) ); |
---|
2905 | } |
---|
2906 | } |
---|
2907 | } |
---|
2908 | } |
---|
2909 | } |
---|
2910 | } |
---|
2911 | } |
---|
2912 | |
---|
2913 | |
---|
2914 | Void TDecTop::xF832DecProcForRefPicSet() |
---|
2915 | { |
---|
2916 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
2917 | // F.8.3.2 Decoding process for reference picture set |
---|
2918 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
2919 | |
---|
2920 | // The specifications in clause 8.3.2 apply with the following changes: |
---|
2921 | // - The references to clauses 7.4.7.2, 8.3.1, 8.3.3 and 8.3.4 are replaced with references to |
---|
2922 | // clauses F.7.4.7.2, F.8.3.1, F.8.3.3 and F.8.3.4, respectively. |
---|
2923 | |
---|
2924 | x832DecProcForRefPicSet( true ); |
---|
2925 | |
---|
2926 | // - The following specifications are added: |
---|
2927 | if (m_pcPic->isIrap() && m_pcPic->getLayerId() == m_smallestLayerId ) |
---|
2928 | { |
---|
2929 | // - When the current picture is an IRAP picture with nuh_layer_id equal to SmallestLayerId, |
---|
2930 | // all reference pictures with any value of nuh_layer_id currently in the DPB (if any) are marked |
---|
2931 | // as "unused for reference" when at least one of the following conditions is true: |
---|
2932 | |
---|
2933 | if ( m_pcPic->getNoClrasOutputFlag() || m_pcPic->getActivatesNewVps() ) |
---|
2934 | { |
---|
2935 | // - The current picture has NoClrasOutputFlag is equal to 1. |
---|
2936 | // - The current picture activates a new VPS. |
---|
2937 | m_dpb->markAllSubDpbAsUnusedForReference( ); |
---|
2938 | } |
---|
2939 | } |
---|
2940 | |
---|
2941 | // - It is a requirement of bitstream conformance that the RPS is restricted as follows: |
---|
2942 | // - When the current picture is a CRA picture, there shall be no picture in RefPicSetStCurrBefore, RefPicSetStCurrAfter |
---|
2943 | // or RefPicSetLtCurr. |
---|
2944 | |
---|
2945 | std::vector<TComPic*>** refPicSetsCurr = m_pcPic->getDecodedRps()->m_refPicSetsCurr; |
---|
2946 | |
---|
2947 | if ( m_pcPic->isCra() ) |
---|
2948 | { |
---|
2949 | for (Int j = 0; j < 3; j++ ) |
---|
2950 | { |
---|
2951 | std::vector<TComPic*>* cSet = refPicSetsCurr[j]; |
---|
2952 | assert ( cSet->size() == 0 ); |
---|
2953 | } |
---|
2954 | } |
---|
2955 | |
---|
2956 | // - The constraints specified in clause 8.3.2 on the value of NumPicTotalCurr are replaced with the following: |
---|
2957 | // - It is a requirement of bitstream conformance that the following applies to the value of NumPicTotalCurr: |
---|
2958 | Int numPicTotalCurr = m_pcPic->getSlice(0)->getNumPicTotalCurr(); |
---|
2959 | Int currPicLayerId = m_pcPic->getLayerId(); |
---|
2960 | const TComVPS* vps = m_pcPic->getSlice(0)->getVPS(); |
---|
2961 | |
---|
2962 | if ( ( m_pcPic->isBla() || m_pcPic->isCra() ) && ( (currPicLayerId == 0 ) || ( vps->getNumDirectRefLayers( currPicLayerId ) == 0 ) ) ) |
---|
2963 | { |
---|
2964 | assert( numPicTotalCurr == 0 ); |
---|
2965 | // - If the current picture is a BLA or CRA picture and either currPicLayerId is equal to 0 or |
---|
2966 | // NumDirectRefLayers[ currPicLayerId ] is equal to 0, the value of NumPicTotalCurr shall be equal to 0. |
---|
2967 | } |
---|
2968 | else |
---|
2969 | { |
---|
2970 | // TBD: check all slices |
---|
2971 | if ( m_pcPic->getSlice(0)->getSliceType() == P_SLICE || m_pcPic->getSlice(0)->getSliceType() == B_SLICE ) |
---|
2972 | { |
---|
2973 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPicTotalCurr shall not be equal to 0. |
---|
2974 | assert( numPicTotalCurr != 0 ); |
---|
2975 | } |
---|
2976 | } |
---|
2977 | } |
---|
2978 | |
---|
2979 | |
---|
2980 | Void TDecTop::xG813DecProcForInterLayerRefPicSet() |
---|
2981 | { |
---|
2982 | //////////////////////////////////////////////////////////////////// |
---|
2983 | // G.8.1.3 Decoding process for inter-layer reference picture set // |
---|
2984 | //////////////////////////////////////////////////////////////////// |
---|
2985 | |
---|
2986 | // Outputs of this process are updated lists of inter-layer reference pictures RefPicSetInterLayer0 and RefPicSetInterLayer1 |
---|
2987 | // and the variables NumActiveRefLayerPics0 and NumActiveRefLayerPics1. |
---|
2988 | |
---|
2989 | TComDecodedRps* decRps = m_pcPic->getDecodedRps(); |
---|
2990 | TComSlice* slice = m_pcPic->getSlice( 0 ); |
---|
2991 | const TComVPS* vps = slice->getVPS(); |
---|
2992 | |
---|
2993 | Int& numActiveRefLayerPics0 = decRps->m_numActiveRefLayerPics0; |
---|
2994 | Int& numActiveRefLayerPics1 = decRps->m_numActiveRefLayerPics1; |
---|
2995 | |
---|
2996 | std::vector<TComPic*>& refPicSetInterLayer0 = decRps->m_refPicSetInterLayer0; |
---|
2997 | std::vector<TComPic*>& refPicSetInterLayer1 = decRps->m_refPicSetInterLayer1; |
---|
2998 | |
---|
2999 | // The variable currLayerId is set equal to nuh_layer_id of the current picture. |
---|
3000 | Int currLayerId = getLayerId(); |
---|
3001 | |
---|
3002 | // The lists RefPicSetInterLayer0 and RefPicSetInterLayer1 are first emptied, NumActiveRefLayerPics0 and NumActiveRefLayerPics1 |
---|
3003 | // are set equal to 0 and the following applies: |
---|
3004 | |
---|
3005 | refPicSetInterLayer0.clear(); |
---|
3006 | refPicSetInterLayer1.clear(); |
---|
3007 | |
---|
3008 | numActiveRefLayerPics0 = 0; |
---|
3009 | numActiveRefLayerPics1 = 0; |
---|
3010 | |
---|
3011 | Int viewIdCurrLayerId = vps->getViewId( currLayerId ); |
---|
3012 | Int viewId0 = vps->getViewId( 0 ); |
---|
3013 | |
---|
3014 | for( Int i = 0; i < slice->getNumActiveRefLayerPics(); i++ ) |
---|
3015 | { |
---|
3016 | Int viewIdRefPicLayerIdi = vps->getViewId( slice->getRefPicLayerId( i ) ); |
---|
3017 | |
---|
3018 | Bool refPicSet0Flag = |
---|
3019 | ( ( viewIdCurrLayerId <= viewId0 && viewIdCurrLayerId <= viewIdRefPicLayerIdi ) || |
---|
3020 | ( viewIdCurrLayerId >= viewId0 && viewIdCurrLayerId >= viewIdRefPicLayerIdi ) ); |
---|
3021 | |
---|
3022 | TComPic* picX = m_dpb->getAu(slice->getPOC(), false )->getPic( slice->getRefPicLayerId( i ) ); |
---|
3023 | if ( picX != NULL ) |
---|
3024 | { |
---|
3025 | // there is a picture picX in the DPB that is in the same access unit as the current picture and has |
---|
3026 | // nuh_layer_id equal to RefPicLayerId[ i ] |
---|
3027 | |
---|
3028 | if ( refPicSet0Flag ) |
---|
3029 | { |
---|
3030 | refPicSetInterLayer0.push_back( picX ); |
---|
3031 | refPicSetInterLayer0[ numActiveRefLayerPics0++ ]->markAsUsedForLongTermReference(); |
---|
3032 | } |
---|
3033 | else |
---|
3034 | { |
---|
3035 | refPicSetInterLayer1.push_back( picX ); |
---|
3036 | refPicSetInterLayer1[ numActiveRefLayerPics1++ ]->markAsUsedForLongTermReference(); |
---|
3037 | } |
---|
3038 | |
---|
3039 | // There shall be no picture that has discardable_flag equal to 1 in RefPicSetInterLayer0 or RefPicSetInterLayer1. |
---|
3040 | assert( ! picX->getSlice(0)->getDiscardableFlag() ); |
---|
3041 | |
---|
3042 | // If the current picture is a RADL picture, there shall be no entry in RefPicSetInterLayer0 or RefPicSetInterLayer1 |
---|
3043 | // that is a RASL picture. |
---|
3044 | if ( m_pcPic->isRadl() ) |
---|
3045 | { |
---|
3046 | assert( ! picX->isRasl() ); |
---|
3047 | } |
---|
3048 | } |
---|
3049 | else |
---|
3050 | { |
---|
3051 | if( refPicSet0Flag ) |
---|
3052 | { |
---|
3053 | refPicSetInterLayer0.push_back( NULL ); // "no reference picture" (G 1) |
---|
3054 | numActiveRefLayerPics0++; |
---|
3055 | } |
---|
3056 | else |
---|
3057 | { |
---|
3058 | refPicSetInterLayer1.push_back( NULL ); // "no reference picture"; |
---|
3059 | numActiveRefLayerPics1++; |
---|
3060 | } |
---|
3061 | // There shall be no entry equal to "no reference picture" in RefPicSetInterLayer0 or RefPicSetInterLayer1. |
---|
3062 | assert( false ); |
---|
3063 | } |
---|
3064 | } |
---|
3065 | } |
---|
3066 | |
---|
3067 | |
---|
3068 | Void TDecTop::x8331GenDecProcForGenUnavilRefPics() |
---|
3069 | { |
---|
3070 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
3071 | // 8.3.3.1 General decoding process for generating unavailable reference pictures //// |
---|
3072 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
3073 | |
---|
3074 | // This process is invoked once per coded picture when the current picture is a |
---|
3075 | // BLA picture or is a CRA picture with NoRaslOutputFlag equal to 1. |
---|
3076 | |
---|
3077 | assert( m_pcPic->isBla() || (m_pcPic->isCra() && m_pcPic->getNoRaslOutputFlag() ) ); |
---|
3078 | TComDecodedRps* decRps = m_pcPic->getDecodedRps(); |
---|
3079 | |
---|
3080 | std::vector<TComPic*>& refPicSetStFoll = decRps->m_refPicSetStFoll; |
---|
3081 | std::vector<TComPic*>& refPicSetLtFoll = decRps->m_refPicSetLtFoll; |
---|
3082 | |
---|
3083 | const std::vector<Int>& pocStFoll = decRps->m_pocStFoll; |
---|
3084 | const std::vector<Int>& pocLtFoll = decRps->m_pocLtFoll; |
---|
3085 | |
---|
3086 | const Int numPocStFoll = decRps->m_numPocStFoll; |
---|
3087 | const Int numPocLtFoll = decRps->m_numPocLtFoll; |
---|
3088 | |
---|
3089 | // When this process is invoked, the following applies: |
---|
3090 | for ( Int i = 0 ; i <= numPocStFoll - 1; i++ ) |
---|
3091 | { |
---|
3092 | if ( refPicSetStFoll[ i ] == NULL ) |
---|
3093 | { |
---|
3094 | //- For each RefPicSetStFoll[ i ], with i in the range of 0 to NumPocStFoll - 1, inclusive, that is equal |
---|
3095 | // to "no reference picture", a picture is generated as specified in clause 8.3.3.2, and the following applies: |
---|
3096 | TComPic* genPic = x8332GenOfOneUnavailPic( true ); |
---|
3097 | |
---|
3098 | // - The value of PicOrderCntVal for the generated picture is set equal to PocStFoll[ i ]. |
---|
3099 | genPic->getSlice(0)->setPOC( pocStFoll[ i ] ); |
---|
3100 | |
---|
3101 | //- The value of PicOutputFlag for the generated picture is set equal to 0. |
---|
3102 | genPic->setPicOutputFlag( false ); |
---|
3103 | |
---|
3104 | // - The generated picture is marked as "used for short-term reference". |
---|
3105 | genPic->markAsUsedForShortTermReference(); |
---|
3106 | |
---|
3107 | // - RefPicSetStFoll[ i ] is set to be the generated reference picture. |
---|
3108 | refPicSetStFoll[ i ] = genPic; |
---|
3109 | |
---|
3110 | // - The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id of the current picture. |
---|
3111 | genPic->setLayerId( m_pcPic-> getLayerId() ); |
---|
3112 | |
---|
3113 | // Insert to DPB |
---|
3114 | m_dpb->addNewPic( genPic ); |
---|
3115 | } |
---|
3116 | } |
---|
3117 | |
---|
3118 | for ( Int i = 0 ; i <= numPocLtFoll - 1; i++ ) |
---|
3119 | { |
---|
3120 | if ( refPicSetLtFoll[ i ] == NULL ) |
---|
3121 | { |
---|
3122 | //- For each RefPicSetLtFoll[ i ], with i in the range of 0 to NumPocLtFoll - 1, inclusive, that is equal to |
---|
3123 | // "no reference picture", a picture is generated as specified in clause 8.3.3.2, and the following applies: |
---|
3124 | TComPic* genPic = x8332GenOfOneUnavailPic( true ); |
---|
3125 | |
---|
3126 | //- The value of PicOrderCntVal for the generated picture is set equal to PocLtFoll[ i ]. |
---|
3127 | genPic->getSlice(0)->setPOC( pocStFoll[ i ] ); |
---|
3128 | |
---|
3129 | // - The value of slice_pic_order_cnt_lsb for the generated picture is inferred to be equal to ( PocLtFoll[ i ] & ( MaxPicOrderCntLsb - 1 ) ). |
---|
3130 | genPic->getSlice(0)->setSlicePicOrderCntLsb( ( pocLtFoll[ i ] & ( m_pcPic->getSlice(0)->getSPS()->getMaxPicOrderCntLsb() - 1 ) ) ); |
---|
3131 | |
---|
3132 | // - The value of PicOutputFlag for the generated picture is set equal to 0. |
---|
3133 | genPic->setPicOutputFlag( false ); |
---|
3134 | |
---|
3135 | // - The generated picture is marked as "used for long-term reference". |
---|
3136 | genPic->markAsUsedForLongTermReference(); |
---|
3137 | |
---|
3138 | // - RefPicSetLtFoll[ i ] is set to be the generated reference picture. |
---|
3139 | refPicSetLtFoll[ i ] = genPic; |
---|
3140 | |
---|
3141 | // - The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id of the current picture. |
---|
3142 | genPic->setLayerId( m_pcPic-> getLayerId() ); |
---|
3143 | |
---|
3144 | // Insert to DPB |
---|
3145 | m_dpb->addNewPic( genPic ); |
---|
3146 | } |
---|
3147 | } |
---|
3148 | } |
---|
3149 | |
---|
3150 | |
---|
3151 | TComPic* TDecTop::x8332GenOfOneUnavailPic( Bool calledFromCl8331 ) |
---|
3152 | { |
---|
3153 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
3154 | // 8.3.3.2 Generation of one unavailable picture |
---|
3155 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
3156 | |
---|
3157 | TComPic* genPic = new TComPic; |
---|
3158 | genPic->create( *m_pcPic->getSlice(0)->getSPS(), *m_pcPic->getSlice(0)->getPPS(), true ); |
---|
3159 | genPic->setIsGenerated( true ); |
---|
3160 | genPic->setIsGeneratedCl833( calledFromCl8331 ); |
---|
3161 | return genPic; |
---|
3162 | } |
---|
3163 | |
---|
3164 | |
---|
3165 | Void TDecTop::xF817DecProcForGenUnavRefPicForPicsFrstInDecOrderInLay() |
---|
3166 | { |
---|
3167 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
3168 | // F.8.1.7 Decoding process for generating unavailable reference pictures for pictures |
---|
3169 | // first in decoding order within a layer |
---|
3170 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
3171 | |
---|
3172 | // This process is invoked for a picture with nuh_layer_id equal to layerId, when FirstPicInLayerDecodedFlag[layerId ] is equal to 0. |
---|
3173 | assert( !m_firstPicInLayerDecodedFlag[ getLayerId() ] ); |
---|
3174 | |
---|
3175 | |
---|
3176 | TComDecodedRps* decRps = m_pcPic->getDecodedRps(); |
---|
3177 | |
---|
3178 | std::vector<TComPic*>& refPicSetStCurrBefore = decRps->m_refPicSetStCurrBefore; |
---|
3179 | std::vector<TComPic*>& refPicSetStCurrAfter = decRps->m_refPicSetStCurrAfter; |
---|
3180 | std::vector<TComPic*>& refPicSetStFoll = decRps->m_refPicSetStFoll; |
---|
3181 | std::vector<TComPic*>& refPicSetLtCurr = decRps->m_refPicSetLtCurr; |
---|
3182 | std::vector<TComPic*>& refPicSetLtFoll = decRps->m_refPicSetLtFoll; |
---|
3183 | |
---|
3184 | |
---|
3185 | const std::vector<Int>& pocStCurrBefore = decRps->m_pocStCurrBefore; |
---|
3186 | const std::vector<Int>& pocStCurrAfter = decRps->m_pocStCurrAfter; |
---|
3187 | const std::vector<Int>& pocStFoll = decRps->m_pocStFoll; |
---|
3188 | const std::vector<Int>& pocLtCurr = decRps->m_pocLtCurr; |
---|
3189 | const std::vector<Int>& pocLtFoll = decRps->m_pocLtFoll; |
---|
3190 | |
---|
3191 | const Int numPocStCurrBefore = decRps->m_numPocStCurrBefore; |
---|
3192 | const Int numPocStCurrAfter = decRps->m_numPocStCurrAfter; |
---|
3193 | const Int numPocStFoll = decRps->m_numPocStFoll; |
---|
3194 | const Int numPocLtCurr = decRps->m_numPocLtCurr; |
---|
3195 | const Int numPocLtFoll = decRps->m_numPocLtFoll; |
---|
3196 | |
---|
3197 | Int nuhLayerId = m_pcPic-> getLayerId(); |
---|
3198 | for ( Int i = 0 ; i <= numPocStCurrBefore - 1; i++ ) |
---|
3199 | { |
---|
3200 | if ( refPicSetStCurrBefore[ i ] == NULL ) |
---|
3201 | { |
---|
3202 | //- For each RefPicSetStCurrBefore[ i ], with i in the range of 0 to NumPocStCurrBefore - 1, inclusive, that is |
---|
3203 | // equal to "no reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies: |
---|
3204 | TComPic* genPic = x8332GenOfOneUnavailPic( false ); |
---|
3205 | |
---|
3206 | //- The value of PicOrderCntVal for the generated picture is set equal to PocStCurrBefore[ i ]. |
---|
3207 | genPic->getSlice(0)->setPOC( pocStCurrBefore[ i ] ); |
---|
3208 | |
---|
3209 | // - The value of PicOutputFlag for the generated picture is set equal to 0. |
---|
3210 | genPic->setPicOutputFlag( false ); |
---|
3211 | |
---|
3212 | // - The generated picture is marked as "used for short-term reference". |
---|
3213 | genPic->markAsUsedForShortTermReference(); |
---|
3214 | |
---|
3215 | // - RefPicSetStCurrBefore[ i ] is set to be the generated reference picture. |
---|
3216 | refPicSetStCurrBefore[ i ] = genPic; |
---|
3217 | |
---|
3218 | // - The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id. |
---|
3219 | genPic->setLayerId( nuhLayerId ); |
---|
3220 | |
---|
3221 | // Insert to DPB |
---|
3222 | m_dpb->addNewPic( genPic ); |
---|
3223 | } |
---|
3224 | } |
---|
3225 | |
---|
3226 | for ( Int i = 0 ; i <= numPocStCurrAfter - 1; i++ ) |
---|
3227 | { |
---|
3228 | if ( refPicSetStCurrAfter[ i ] == NULL ) |
---|
3229 | { |
---|
3230 | // - For each RefPicSetStCurrAfter[ i ], with i in the range of 0 to NumPocStCurrAfter - 1, inclusive, that is equal |
---|
3231 | // to "no reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies: |
---|
3232 | TComPic* genPic = x8332GenOfOneUnavailPic( false ); |
---|
3233 | |
---|
3234 | // - The value of PicOrderCntVal for the generated picture is set equal to PocStCurrAfter[ i ]. |
---|
3235 | genPic->getSlice(0)->setPOC( pocStCurrAfter[ i ] ); |
---|
3236 | |
---|
3237 | // - The value of PicOutputFlag for the generated picture is set equal to 0. |
---|
3238 | genPic->setPicOutputFlag( false ); |
---|
3239 | |
---|
3240 | // - The generated picture is marked as "used for short-term reference". |
---|
3241 | genPic->markAsUsedForShortTermReference(); |
---|
3242 | |
---|
3243 | // - RefPicSetStCurrAfter[ i ] is set to be the generated reference picture. |
---|
3244 | refPicSetStCurrAfter[ i ] = genPic; |
---|
3245 | |
---|
3246 | // - The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id. |
---|
3247 | genPic->setLayerId( nuhLayerId ); |
---|
3248 | |
---|
3249 | // Insert to DPB |
---|
3250 | m_dpb->addNewPic( genPic ); |
---|
3251 | |
---|
3252 | } |
---|
3253 | } |
---|
3254 | |
---|
3255 | for ( Int i = 0 ; i <= numPocStFoll - 1; i++ ) |
---|
3256 | { |
---|
3257 | if ( refPicSetStFoll[ i ] == NULL ) |
---|
3258 | { |
---|
3259 | // - For each RefPicSetStFoll[ i ], with i in the range of 0 to NumPocStFoll - 1, inclusive, that is equal to "no |
---|
3260 | // reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies: |
---|
3261 | TComPic* genPic = x8332GenOfOneUnavailPic( false ); |
---|
3262 | |
---|
3263 | // - The value of PicOrderCntVal for the generated picture is set equal to PocStFoll[ i ]. |
---|
3264 | genPic->getSlice(0)->setPOC( pocStFoll[ i ] ); |
---|
3265 | |
---|
3266 | // - The value of PicOutputFlag for the generated picture is set equal to 0. |
---|
3267 | genPic->setPicOutputFlag( false ); |
---|
3268 | |
---|
3269 | // - The generated picture is marked as "used for short-term reference". |
---|
3270 | genPic->markAsUsedForShortTermReference(); |
---|
3271 | |
---|
3272 | // - RefPicSetStFoll[ i ] is set to be the generated reference picture. |
---|
3273 | refPicSetStFoll[ i ] = genPic; |
---|
3274 | |
---|
3275 | // - The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id. |
---|
3276 | genPic->setLayerId( nuhLayerId ); |
---|
3277 | |
---|
3278 | // Insert to DPB |
---|
3279 | m_dpb->addNewPic( genPic ); |
---|
3280 | } |
---|
3281 | } |
---|
3282 | |
---|
3283 | Int maxPicOrderCntLsb = m_pcPic->getSlice(0)->getSPS()->getMaxPicOrderCntLsb(); |
---|
3284 | for ( Int i = 0 ; i <= numPocLtCurr - 1; i++ ) |
---|
3285 | { |
---|
3286 | if ( refPicSetLtCurr[ i ] == NULL ) |
---|
3287 | { |
---|
3288 | // - For each RefPicSetLtCurr[ i ], with i in the range of 0 to NumPocLtCurr - 1, inclusive, that is equal to "no |
---|
3289 | // reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies: |
---|
3290 | TComPic* genPic = x8332GenOfOneUnavailPic( false ); |
---|
3291 | |
---|
3292 | // - The value of PicOrderCntVal for the generated picture is set equal to PocLtCurr[ i ]. |
---|
3293 | genPic->getSlice(0)->setPOC( pocLtCurr[ i ] ); |
---|
3294 | |
---|
3295 | // - The value of slice_pic_order_cnt_lsb for the generated picture is inferred to be equal to ( PocLtCurr[ i ] & ( |
---|
3296 | // MaxPicOrderCntLsb - 1 ) ). |
---|
3297 | genPic->getSlice(0)->setSlicePicOrderCntLsb( ( pocLtCurr[ i ] & ( maxPicOrderCntLsb - 1 ) ) ); |
---|
3298 | |
---|
3299 | // - The value of PicOutputFlag for the generated picture is set equal to 0. |
---|
3300 | genPic->setPicOutputFlag( false ); |
---|
3301 | |
---|
3302 | // - The generated picture is marked as "used for long-term reference". |
---|
3303 | genPic->markAsUsedForLongTermReference(); |
---|
3304 | |
---|
3305 | // - RefPicSetLtCurr[ i ] is set to be the generated reference picture. |
---|
3306 | refPicSetLtCurr[ i ] = genPic; |
---|
3307 | |
---|
3308 | // - The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id. |
---|
3309 | genPic->setLayerId( nuhLayerId ); |
---|
3310 | |
---|
3311 | // Insert to DPB |
---|
3312 | m_dpb->addNewPic( genPic ); |
---|
3313 | } |
---|
3314 | } |
---|
3315 | |
---|
3316 | for ( Int i = 0 ; i <= numPocLtFoll - 1; i++ ) |
---|
3317 | { |
---|
3318 | if ( refPicSetLtFoll[ i ] == NULL ) |
---|
3319 | { |
---|
3320 | // - For each RefPicSetLtFoll[ i ], with i in the range of 0 to NumPocLtFoll - 1, inclusive, that is equal to "no |
---|
3321 | // reference picture", a picture is generated as specified in clause 8.3.3.2 and the following applies: |
---|
3322 | TComPic* genPic = x8332GenOfOneUnavailPic( false ); |
---|
3323 | |
---|
3324 | // - The value of PicOrderCntVal for the generated picture is set equal to PocLtFoll[ i ]. |
---|
3325 | genPic->getSlice(0)->setPOC( pocLtFoll[ i ] ); |
---|
3326 | |
---|
3327 | // - The value of slice_pic_order_cnt_lsb for the generated picture is inferred to be equal to ( PocLtCurr[ i ] & ( |
---|
3328 | // MaxPicOrderCntLsb - 1 ) ). |
---|
3329 | genPic->getSlice(0)->setSlicePicOrderCntLsb( ( pocLtCurr[ i ] & ( maxPicOrderCntLsb - 1 ) ) ); |
---|
3330 | |
---|
3331 | // - The value of PicOutputFlag for the generated picture is set equal to 0. |
---|
3332 | genPic->setPicOutputFlag( false ); |
---|
3333 | |
---|
3334 | // - The generated picture is marked as "used for long-term reference". |
---|
3335 | genPic->markAsUsedForLongTermReference(); |
---|
3336 | |
---|
3337 | // - RefPicSetLtFoll[ i ] is set to be the generated reference picture. |
---|
3338 | refPicSetLtFoll[ i ] = genPic; |
---|
3339 | |
---|
3340 | // - The value of nuh_layer_id for the generated picture is set equal to nuh_layer_id. |
---|
3341 | genPic->setLayerId( nuhLayerId ); |
---|
3342 | |
---|
3343 | // Insert to DPB |
---|
3344 | m_dpb->addNewPic( genPic ); |
---|
3345 | } |
---|
3346 | } |
---|
3347 | } |
---|
3348 | |
---|
3349 | Void TDecTop::xF833DecProcForGenUnavRefPics() |
---|
3350 | { |
---|
3351 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
3352 | // F.8.3.3 Decoding process for generating unavailable reference picture |
---|
3353 | /////////////////////////////////////////////////////////////////////////////////////// |
---|
3354 | |
---|
3355 | x8331GenDecProcForGenUnavilRefPics(); |
---|
3356 | } |
---|
3357 | |
---|
3358 | Void TDecTop::xCheckUnavailableRefPics() |
---|
3359 | { |
---|
3360 | std::vector<TComPic*>** refPicSetsCurr = m_pcPic->getDecodedRps()->m_refPicSetsCurr; |
---|
3361 | |
---|
3362 | Bool hasGeneratedRefPic = false; |
---|
3363 | for (Int j = 0; j < 3; j++ ) |
---|
3364 | { |
---|
3365 | std::vector<TComPic*>* cSet = refPicSetsCurr[j]; |
---|
3366 | for (Int i = 0 ; i < cSet->size(); i++ ) |
---|
3367 | { |
---|
3368 | assert( (*cSet)[i] != NULL ); |
---|
3369 | if ((*cSet)[i]->getIsGenerated() ) |
---|
3370 | { |
---|
3371 | hasGeneratedRefPic = true; |
---|
3372 | } |
---|
3373 | } |
---|
3374 | } |
---|
3375 | m_pcPic->setHasGeneratedRefPics( hasGeneratedRefPic ); |
---|
3376 | } |
---|
3377 | |
---|
3378 | #endif |
---|
3379 | |
---|
3380 | //! \} |
---|