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