1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TComSlice.cpp |
---|
35 | \brief slice header and SPS class |
---|
36 | */ |
---|
37 | |
---|
38 | #include <numeric> |
---|
39 | #include "CommonDef.h" |
---|
40 | #include "TComSlice.h" |
---|
41 | #include "TComPic.h" |
---|
42 | #include "TLibEncoder/TEncSbac.h" |
---|
43 | #include "TLibDecoder/TDecSbac.h" |
---|
44 | |
---|
45 | //! \ingroup TLibCommon |
---|
46 | //! \{ |
---|
47 | |
---|
48 | #if SVC_EXTENSION |
---|
49 | ParameterSetMap<TComVPS> ParameterSetManager::m_vpsMap(MAX_NUM_VPS); |
---|
50 | ParameterSetMap<TComSPS> ParameterSetManager::m_spsMap(MAX_NUM_SPS); |
---|
51 | ParameterSetMap<TComPPS> ParameterSetManager::m_ppsMap(MAX_NUM_PPS); |
---|
52 | Int ParameterSetManager::m_activeVPSId = -1; |
---|
53 | #endif |
---|
54 | |
---|
55 | TComSlice::TComSlice() |
---|
56 | : m_iPPSId ( -1 ) |
---|
57 | , m_iPOC ( 0 ) |
---|
58 | , m_iLastIDR ( 0 ) |
---|
59 | , m_eNalUnitType ( NAL_UNIT_CODED_SLICE_IDR_W_RADL ) |
---|
60 | , m_eSliceType ( I_SLICE ) |
---|
61 | , m_iSliceQp ( 0 ) |
---|
62 | , m_dependentSliceSegmentFlag ( false ) |
---|
63 | #if ADAPTIVE_QP_SELECTION |
---|
64 | , m_iSliceQpBase ( 0 ) |
---|
65 | #endif |
---|
66 | , m_deblockingFilterDisable ( false ) |
---|
67 | , m_deblockingFilterOverrideFlag ( false ) |
---|
68 | , m_deblockingFilterBetaOffsetDiv2 ( 0 ) |
---|
69 | , m_deblockingFilterTcOffsetDiv2 ( 0 ) |
---|
70 | , m_bCheckLDC ( false ) |
---|
71 | , m_iSliceQpDelta ( 0 ) |
---|
72 | , m_iSliceQpDeltaCb ( 0 ) |
---|
73 | , m_iSliceQpDeltaCr ( 0 ) |
---|
74 | , m_iDepth ( 0 ) |
---|
75 | , m_bRefenced ( false ) |
---|
76 | , m_pcSPS ( NULL ) |
---|
77 | , m_pcPPS ( NULL ) |
---|
78 | , m_pcPic ( NULL ) |
---|
79 | , m_colFromL0Flag ( 1 ) |
---|
80 | #if SETTING_NO_OUT_PIC_PRIOR |
---|
81 | , m_noOutputPriorPicsFlag ( false ) |
---|
82 | , m_noRaslOutputFlag ( false ) |
---|
83 | , m_handleCraAsBlaFlag ( false ) |
---|
84 | #endif |
---|
85 | , m_colRefIdx ( 0 ) |
---|
86 | , m_uiTLayer ( 0 ) |
---|
87 | , m_bTLayerSwitchingFlag ( false ) |
---|
88 | , m_sliceMode ( 0 ) |
---|
89 | , m_sliceArgument ( 0 ) |
---|
90 | , m_sliceCurStartCUAddr ( 0 ) |
---|
91 | , m_sliceCurEndCUAddr ( 0 ) |
---|
92 | , m_sliceIdx ( 0 ) |
---|
93 | , m_sliceSegmentMode ( 0 ) |
---|
94 | , m_sliceSegmentArgument ( 0 ) |
---|
95 | , m_sliceSegmentCurStartCUAddr ( 0 ) |
---|
96 | , m_sliceSegmentCurEndCUAddr ( 0 ) |
---|
97 | , m_nextSlice ( false ) |
---|
98 | , m_nextSliceSegment ( false ) |
---|
99 | , m_sliceBits ( 0 ) |
---|
100 | , m_sliceSegmentBits ( 0 ) |
---|
101 | , m_bFinalized ( false ) |
---|
102 | , m_uiTileOffstForMultES ( 0 ) |
---|
103 | , m_puiSubstreamSizes ( NULL ) |
---|
104 | , m_cabacInitFlag ( false ) |
---|
105 | , m_bLMvdL1Zero ( false ) |
---|
106 | , m_numEntryPointOffsets ( 0 ) |
---|
107 | , m_temporalLayerNonReferenceFlag ( false ) |
---|
108 | , m_enableTMVPFlag ( true ) |
---|
109 | #if R0226_SLICE_TMVP |
---|
110 | , m_availableForTMVPRefFlag ( true ) |
---|
111 | #endif |
---|
112 | #if SVC_EXTENSION |
---|
113 | , m_layerId ( 0 ) |
---|
114 | #if REF_IDX_MFM |
---|
115 | , m_bMFMEnabledFlag ( false ) |
---|
116 | #endif |
---|
117 | #if POC_RESET_FLAG |
---|
118 | , m_bPocResetFlag ( false ) |
---|
119 | #endif |
---|
120 | , m_bDiscardableFlag ( false ) |
---|
121 | #if O0149_CROSS_LAYER_BLA_FLAG |
---|
122 | , m_bCrossLayerBLAFlag ( false ) |
---|
123 | #endif |
---|
124 | #if POC_RESET_IDC_SIGNALLING |
---|
125 | , m_pocResetIdc ( 0 ) |
---|
126 | , m_pocResetPeriodId ( 0 ) |
---|
127 | , m_fullPocResetFlag ( false ) |
---|
128 | , m_pocLsbVal ( 0 ) |
---|
129 | , m_pocMsbVal ( 0 ) |
---|
130 | , m_pocMsbValRequiredFlag ( false ) |
---|
131 | , m_pocMsbValPresentFlag ( false ) |
---|
132 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
133 | , m_pocMsbValNeeded ( false ) |
---|
134 | #endif |
---|
135 | #endif |
---|
136 | #if POC_RESET_IDC_DECODER || POC_RESET_IDC_ENCODER |
---|
137 | , m_picOrderCntLsb (0) |
---|
138 | #endif |
---|
139 | #endif //SVC_EXTENSION |
---|
140 | { |
---|
141 | m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = 0; |
---|
142 | |
---|
143 | #if SVC_EXTENSION |
---|
144 | memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) ); |
---|
145 | m_activeNumILRRefIdx = 0; |
---|
146 | m_interLayerPredEnabledFlag = 0; |
---|
147 | ::memset( m_interLayerPredLayerIdc, 0, sizeof(m_interLayerPredLayerIdc) ); |
---|
148 | #if P0312_VERT_PHASE_ADJ |
---|
149 | ::memset( m_vertPhasePositionFlag, 0, sizeof(m_vertPhasePositionFlag) ); |
---|
150 | #endif |
---|
151 | #endif //SVC_EXTENSION |
---|
152 | |
---|
153 | initEqualRef(); |
---|
154 | |
---|
155 | for (Int component = 0; component < 3; component++) |
---|
156 | { |
---|
157 | m_lambdas[component] = 0.0; |
---|
158 | } |
---|
159 | |
---|
160 | for ( Int idx = 0; idx < MAX_NUM_REF; idx++ ) |
---|
161 | { |
---|
162 | m_list1IdxToList0Idx[idx] = -1; |
---|
163 | } |
---|
164 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF; iNumCount++) |
---|
165 | { |
---|
166 | m_apcRefPicList [0][iNumCount] = NULL; |
---|
167 | m_apcRefPicList [1][iNumCount] = NULL; |
---|
168 | m_aiRefPOCList [0][iNumCount] = 0; |
---|
169 | m_aiRefPOCList [1][iNumCount] = 0; |
---|
170 | } |
---|
171 | resetWpScaling(); |
---|
172 | initWpAcDcParam(); |
---|
173 | m_saoEnabledFlag = false; |
---|
174 | m_saoEnabledFlagChroma = false; |
---|
175 | } |
---|
176 | |
---|
177 | TComSlice::~TComSlice() |
---|
178 | { |
---|
179 | delete[] m_puiSubstreamSizes; |
---|
180 | m_puiSubstreamSizes = NULL; |
---|
181 | } |
---|
182 | |
---|
183 | |
---|
184 | #if SVC_EXTENSION |
---|
185 | Void TComSlice::initSlice( UInt layerId ) |
---|
186 | #else |
---|
187 | Void TComSlice::initSlice() |
---|
188 | #endif |
---|
189 | { |
---|
190 | #if SVC_EXTENSION |
---|
191 | m_layerId = layerId; |
---|
192 | m_activeNumILRRefIdx = 0; |
---|
193 | m_interLayerPredEnabledFlag = 0; |
---|
194 | #endif |
---|
195 | m_aiNumRefIdx[0] = 0; |
---|
196 | m_aiNumRefIdx[1] = 0; |
---|
197 | |
---|
198 | m_colFromL0Flag = 1; |
---|
199 | |
---|
200 | m_colRefIdx = 0; |
---|
201 | initEqualRef(); |
---|
202 | m_bCheckLDC = false; |
---|
203 | m_iSliceQpDeltaCb = 0; |
---|
204 | m_iSliceQpDeltaCr = 0; |
---|
205 | |
---|
206 | m_maxNumMergeCand = MRG_MAX_NUM_CANDS; |
---|
207 | |
---|
208 | m_bFinalized=false; |
---|
209 | |
---|
210 | m_tileByteLocation.clear(); |
---|
211 | m_cabacInitFlag = false; |
---|
212 | m_numEntryPointOffsets = 0; |
---|
213 | m_enableTMVPFlag = true; |
---|
214 | #if POC_RESET_IDC_SIGNALLING |
---|
215 | m_pocResetIdc = 0; |
---|
216 | m_pocResetPeriodId = 0; |
---|
217 | m_fullPocResetFlag = false; |
---|
218 | m_pocLsbVal = 0; |
---|
219 | m_pocMsbVal = 0; |
---|
220 | m_pocMsbValRequiredFlag = false; |
---|
221 | m_pocMsbValPresentFlag = false; |
---|
222 | #endif |
---|
223 | #if POC_RESET_IDC_DECODER || POC_RESET_IDC_ENCODER |
---|
224 | m_picOrderCntLsb = 0; |
---|
225 | #endif |
---|
226 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
227 | m_pocMsbValNeeded = false; |
---|
228 | m_pocResetDeltaPoc = 0; |
---|
229 | #endif |
---|
230 | } |
---|
231 | |
---|
232 | Bool TComSlice::getRapPicFlag() |
---|
233 | { |
---|
234 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
235 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP |
---|
236 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
237 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
238 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
239 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA; |
---|
240 | } |
---|
241 | #if NO_OUTPUT_OF_PRIOR_PICS |
---|
242 | Bool TComSlice::getBlaPicFlag () |
---|
243 | { |
---|
244 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
245 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
246 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP; |
---|
247 | } |
---|
248 | Bool TComSlice::getCraPicFlag () |
---|
249 | { |
---|
250 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA; |
---|
251 | } |
---|
252 | #endif |
---|
253 | #if POC_RESET_IDC_DECODER |
---|
254 | Bool TComSlice::getRaslPicFlag () |
---|
255 | { |
---|
256 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R |
---|
257 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N; |
---|
258 | } |
---|
259 | Bool TComSlice::getRadlPicFlag () |
---|
260 | { |
---|
261 | return getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R |
---|
262 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N; |
---|
263 | } |
---|
264 | #endif |
---|
265 | #if POC_RESET_IDC_ENCODER |
---|
266 | Void TComSlice::decrementRefPocValues(Int const decrementValue) |
---|
267 | { |
---|
268 | for(Int listNum = 0; listNum < 2; listNum++) |
---|
269 | { |
---|
270 | RefPicList dpbPicSliceList = (listNum == 1) ? REF_PIC_LIST_1 : REF_PIC_LIST_0; |
---|
271 | for(Int listIdx = 0; listIdx < getNumRefIdx( dpbPicSliceList ); listIdx++) |
---|
272 | { |
---|
273 | setRefPOC( getRefPOC(dpbPicSliceList, listIdx) - decrementValue, |
---|
274 | dpbPicSliceList, |
---|
275 | listIdx |
---|
276 | ); |
---|
277 | } |
---|
278 | } |
---|
279 | } |
---|
280 | |
---|
281 | Int TComSlice::getCurrMsb( Int currLsb, Int prevLsb, Int prevMsb, Int maxLsbVal ) |
---|
282 | { |
---|
283 | if( prevLsb - currLsb >= (maxLsbVal >> 1) ) |
---|
284 | { |
---|
285 | return prevMsb + maxLsbVal; |
---|
286 | } |
---|
287 | else if( currLsb - prevLsb > (maxLsbVal >> 1) ) |
---|
288 | { |
---|
289 | return prevMsb - maxLsbVal; |
---|
290 | } |
---|
291 | else |
---|
292 | { |
---|
293 | return prevMsb; |
---|
294 | } |
---|
295 | } |
---|
296 | #endif |
---|
297 | |
---|
298 | /** |
---|
299 | - allocate table to contain substream sizes to be written to the slice header. |
---|
300 | . |
---|
301 | \param uiNumSubstreams Number of substreams -- the allocation will be this value - 1. |
---|
302 | */ |
---|
303 | Void TComSlice::allocSubstreamSizes(UInt uiNumSubstreams) |
---|
304 | { |
---|
305 | delete[] m_puiSubstreamSizes; |
---|
306 | m_puiSubstreamSizes = new UInt[uiNumSubstreams > 0 ? uiNumSubstreams-1 : 0]; |
---|
307 | } |
---|
308 | |
---|
309 | Void TComSlice::sortPicList(TComList<TComPic*>& rcListPic) |
---|
310 | { |
---|
311 | TComPic* pcPicExtract; |
---|
312 | TComPic* pcPicInsert; |
---|
313 | |
---|
314 | TComList<TComPic*>::iterator iterPicExtract; |
---|
315 | TComList<TComPic*>::iterator iterPicExtract_1; |
---|
316 | TComList<TComPic*>::iterator iterPicInsert; |
---|
317 | |
---|
318 | for (Int i = 1; i < (Int)(rcListPic.size()); i++) |
---|
319 | { |
---|
320 | iterPicExtract = rcListPic.begin(); |
---|
321 | for (Int j = 0; j < i; j++) iterPicExtract++; |
---|
322 | pcPicExtract = *(iterPicExtract); |
---|
323 | pcPicExtract->setCurrSliceIdx(0); |
---|
324 | |
---|
325 | iterPicInsert = rcListPic.begin(); |
---|
326 | while (iterPicInsert != iterPicExtract) |
---|
327 | { |
---|
328 | pcPicInsert = *(iterPicInsert); |
---|
329 | pcPicInsert->setCurrSliceIdx(0); |
---|
330 | if (pcPicInsert->getPOC() >= pcPicExtract->getPOC()) |
---|
331 | { |
---|
332 | break; |
---|
333 | } |
---|
334 | |
---|
335 | iterPicInsert++; |
---|
336 | } |
---|
337 | |
---|
338 | iterPicExtract_1 = iterPicExtract; iterPicExtract_1++; |
---|
339 | |
---|
340 | // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position |
---|
341 | rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1); |
---|
342 | rcListPic.erase (iterPicExtract); |
---|
343 | } |
---|
344 | } |
---|
345 | |
---|
346 | TComPic* TComSlice::xGetRefPic (TComList<TComPic*>& rcListPic, |
---|
347 | Int poc) |
---|
348 | { |
---|
349 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
350 | TComPic* pcPic = *(iterPic); |
---|
351 | while ( iterPic != rcListPic.end() ) |
---|
352 | { |
---|
353 | #if POC_RESET_IDC_ENCODER |
---|
354 | if( (pcPic->getPOC() == poc) && (pcPic->getSlice(0)->isReferenced()) ) |
---|
355 | #else |
---|
356 | if(pcPic->getPOC() == poc) |
---|
357 | #endif |
---|
358 | { |
---|
359 | break; |
---|
360 | } |
---|
361 | iterPic++; |
---|
362 | #if SVC_EXTENSION |
---|
363 | // return NULL, if picture with requested POC is not in the list, otherwise iterator goes outside of the list |
---|
364 | if( iterPic == rcListPic.end() ) |
---|
365 | { |
---|
366 | return NULL; |
---|
367 | } |
---|
368 | #endif |
---|
369 | pcPic = *(iterPic); |
---|
370 | } |
---|
371 | #if POC_RESET_FLAG || POC_RESET_IDC_DECODER |
---|
372 | assert( pcPic->getSlice(0)->isReferenced() ); |
---|
373 | #endif |
---|
374 | return pcPic; |
---|
375 | } |
---|
376 | |
---|
377 | |
---|
378 | TComPic* TComSlice::xGetLongTermRefPic(TComList<TComPic*>& rcListPic, Int poc, Bool pocHasMsb) |
---|
379 | { |
---|
380 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
381 | TComPic* pcPic = *(iterPic); |
---|
382 | TComPic* pcStPic = pcPic; |
---|
383 | |
---|
384 | Int pocCycle = 1 << getSPS()->getBitsForPOC(); |
---|
385 | if (!pocHasMsb) |
---|
386 | { |
---|
387 | poc = poc & (pocCycle - 1); |
---|
388 | } |
---|
389 | |
---|
390 | while ( iterPic != rcListPic.end() ) |
---|
391 | { |
---|
392 | pcPic = *(iterPic); |
---|
393 | if (pcPic && pcPic->getPOC()!=this->getPOC() && pcPic->getSlice( 0 )->isReferenced()) |
---|
394 | { |
---|
395 | Int picPoc = pcPic->getPOC(); |
---|
396 | if (!pocHasMsb) |
---|
397 | { |
---|
398 | picPoc = picPoc & (pocCycle - 1); |
---|
399 | } |
---|
400 | |
---|
401 | #if POC_RESET_RPS |
---|
402 | if( ((!pocHasMsb) && ((poc & (pocCycle-1)) == picPoc)) || ( pocHasMsb && (poc == picPoc)) ) |
---|
403 | #else |
---|
404 | if (poc == picPoc) |
---|
405 | #endif |
---|
406 | { |
---|
407 | if (pcPic->getIsLongTerm()) |
---|
408 | { |
---|
409 | return pcPic; |
---|
410 | } |
---|
411 | else |
---|
412 | { |
---|
413 | pcStPic = pcPic; |
---|
414 | } |
---|
415 | break; |
---|
416 | } |
---|
417 | } |
---|
418 | |
---|
419 | iterPic++; |
---|
420 | } |
---|
421 | |
---|
422 | return pcStPic; |
---|
423 | } |
---|
424 | |
---|
425 | Void TComSlice::setRefPOCList() |
---|
426 | { |
---|
427 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
428 | { |
---|
429 | for (Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++) |
---|
430 | { |
---|
431 | m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC(); |
---|
432 | } |
---|
433 | } |
---|
434 | |
---|
435 | } |
---|
436 | |
---|
437 | Void TComSlice::setList1IdxToList0Idx() |
---|
438 | { |
---|
439 | Int idxL0, idxL1; |
---|
440 | for ( idxL1 = 0; idxL1 < getNumRefIdx( REF_PIC_LIST_1 ); idxL1++ ) |
---|
441 | { |
---|
442 | m_list1IdxToList0Idx[idxL1] = -1; |
---|
443 | for ( idxL0 = 0; idxL0 < getNumRefIdx( REF_PIC_LIST_0 ); idxL0++ ) |
---|
444 | { |
---|
445 | if ( m_apcRefPicList[REF_PIC_LIST_0][idxL0]->getPOC() == m_apcRefPicList[REF_PIC_LIST_1][idxL1]->getPOC() ) |
---|
446 | { |
---|
447 | m_list1IdxToList0Idx[idxL1] = idxL0; |
---|
448 | break; |
---|
449 | } |
---|
450 | } |
---|
451 | } |
---|
452 | } |
---|
453 | |
---|
454 | #if SVC_EXTENSION |
---|
455 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr, TComPic** ilpPic) |
---|
456 | #else |
---|
457 | Void TComSlice::setRefPicList( TComList<TComPic*>& rcListPic, Bool checkNumPocTotalCurr ) |
---|
458 | #endif |
---|
459 | { |
---|
460 | if (!checkNumPocTotalCurr) |
---|
461 | { |
---|
462 | if (m_eSliceType == I_SLICE) |
---|
463 | { |
---|
464 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
465 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
466 | |
---|
467 | return; |
---|
468 | } |
---|
469 | |
---|
470 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
471 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
472 | } |
---|
473 | |
---|
474 | TComPic* pcRefPic= NULL; |
---|
475 | TComPic* RefPicSetStCurr0[16]; |
---|
476 | TComPic* RefPicSetStCurr1[16]; |
---|
477 | TComPic* RefPicSetLtCurr[16]; |
---|
478 | UInt NumPocStCurr0 = 0; |
---|
479 | UInt NumPocStCurr1 = 0; |
---|
480 | UInt NumPocLtCurr = 0; |
---|
481 | Int i; |
---|
482 | |
---|
483 | #if SVC_EXTENSION |
---|
484 | if( m_layerId == 0 || ( m_layerId > 0 && ( m_activeNumILRRefIdx == 0 || !((getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)) ) ) ) |
---|
485 | { |
---|
486 | #endif |
---|
487 | for(i=0; i < m_pcRPS->getNumberOfNegativePictures(); i++) |
---|
488 | { |
---|
489 | if(m_pcRPS->getUsed(i)) |
---|
490 | { |
---|
491 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
492 | pcRefPic->setIsLongTerm(0); |
---|
493 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
494 | RefPicSetStCurr0[NumPocStCurr0] = pcRefPic; |
---|
495 | NumPocStCurr0++; |
---|
496 | pcRefPic->setCheckLTMSBPresent(false); |
---|
497 | } |
---|
498 | } |
---|
499 | |
---|
500 | for(; i < m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures(); i++) |
---|
501 | { |
---|
502 | if(m_pcRPS->getUsed(i)) |
---|
503 | { |
---|
504 | pcRefPic = xGetRefPic(rcListPic, getPOC()+m_pcRPS->getDeltaPOC(i)); |
---|
505 | pcRefPic->setIsLongTerm(0); |
---|
506 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
507 | RefPicSetStCurr1[NumPocStCurr1] = pcRefPic; |
---|
508 | NumPocStCurr1++; |
---|
509 | pcRefPic->setCheckLTMSBPresent(false); |
---|
510 | } |
---|
511 | } |
---|
512 | |
---|
513 | for(i = m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()+m_pcRPS->getNumberOfLongtermPictures()-1; i > m_pcRPS->getNumberOfNegativePictures()+m_pcRPS->getNumberOfPositivePictures()-1 ; i--) |
---|
514 | { |
---|
515 | if(m_pcRPS->getUsed(i)) |
---|
516 | { |
---|
517 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
518 | pcRefPic->setIsLongTerm(1); |
---|
519 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
520 | RefPicSetLtCurr[NumPocLtCurr] = pcRefPic; |
---|
521 | NumPocLtCurr++; |
---|
522 | } |
---|
523 | if(pcRefPic==NULL) |
---|
524 | { |
---|
525 | pcRefPic = xGetLongTermRefPic(rcListPic, m_pcRPS->getPOC(i), m_pcRPS->getCheckLTMSBPresent(i)); |
---|
526 | } |
---|
527 | pcRefPic->setCheckLTMSBPresent(m_pcRPS->getCheckLTMSBPresent(i)); |
---|
528 | } |
---|
529 | #if SVC_EXTENSION |
---|
530 | } |
---|
531 | #endif |
---|
532 | |
---|
533 | // ref_pic_list_init |
---|
534 | TComPic* rpsCurrList0[MAX_NUM_REF+1]; |
---|
535 | TComPic* rpsCurrList1[MAX_NUM_REF+1]; |
---|
536 | #if SVC_EXTENSION |
---|
537 | Int numInterLayerRPSPics = 0; |
---|
538 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
539 | if( m_layerId > 0 && m_activeNumILRRefIdx > 0 ) |
---|
540 | #else |
---|
541 | if( m_layerId > 0 ) |
---|
542 | #endif |
---|
543 | { |
---|
544 | for( i=0; i < m_pcVPS->getNumDirectRefLayers( m_layerId ); i++ ) |
---|
545 | { |
---|
546 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
547 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[i]->getSlice(0)->getLayerId(),m_layerId); |
---|
548 | #else |
---|
549 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[i]->getSlice(0)->getLayerId()); |
---|
550 | #endif |
---|
551 | if( ((Int)(ilpPic[i]->getSlice(0)->getTLayer())<= maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[i]->getSlice(0)->getRapPicFlag() ) ) |
---|
552 | { |
---|
553 | numInterLayerRPSPics++; |
---|
554 | #if DISCARDABLE_PIC_RPS |
---|
555 | assert( ilpPic[i]->getSlice(0)->getDiscardableFlag() == 0 ); // Inter-layer RPS shall not contain picture with discardable_flag = 1. |
---|
556 | #endif |
---|
557 | } |
---|
558 | } |
---|
559 | if (numInterLayerRPSPics < m_activeNumILRRefIdx) |
---|
560 | { |
---|
561 | m_activeNumILRRefIdx = numInterLayerRPSPics; |
---|
562 | } |
---|
563 | #if MAX_ONE_RESAMPLING_DIRECT_LAYERS |
---|
564 | if( m_pcVPS->getScalabilityMask( SCALABILITY_ID ) ) |
---|
565 | { |
---|
566 | Int numResampler = 0; |
---|
567 | #if MOTION_RESAMPLING_CONSTRAINT |
---|
568 | Int numMotionResamplers = 0; |
---|
569 | Int refResamplingLayer[MAX_LAYERS]; |
---|
570 | memset( refResamplingLayer, 0, sizeof( refResamplingLayer ) ); |
---|
571 | #endif |
---|
572 | #if !RESAMPLING_CONSTRAINT_BUG_FIX |
---|
573 | const Window &scalEL = getSPS()->getScaledRefLayerWindow(m_interLayerPredLayerIdc[i]); |
---|
574 | Int scalingOffset = ((scalEL.getWindowLeftOffset() == 0 ) && |
---|
575 | (scalEL.getWindowRightOffset() == 0 ) && |
---|
576 | (scalEL.getWindowTopOffset() == 0 ) && |
---|
577 | (scalEL.getWindowBottomOffset() == 0 ) |
---|
578 | ); |
---|
579 | #endif |
---|
580 | |
---|
581 | for( i=0; i < m_activeNumILRRefIdx; i++ ) |
---|
582 | { |
---|
583 | UInt refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
584 | UInt refLayerId = m_pcVPS->getRefLayerId( m_layerId, refLayerIdc ); |
---|
585 | #if RESAMPLING_CONSTRAINT_BUG_FIX |
---|
586 | #if MOVE_SCALED_OFFSET_TO_PPS |
---|
587 | #if O0098_SCALED_REF_LAYER_ID |
---|
588 | const Window &scalEL = getPPS()->getScaledRefLayerWindowForLayer(refLayerId); |
---|
589 | #else |
---|
590 | const Window &scalEL = getPPS()->getScaledRefLayerWindow(m_interLayerPredLayerIdc[i]); |
---|
591 | #endif |
---|
592 | #else |
---|
593 | #if O0098_SCALED_REF_LAYER_ID |
---|
594 | const Window &scalEL = getSPS()->getScaledRefLayerWindowForLayer(refLayerId); |
---|
595 | #else |
---|
596 | const Window &scalEL = getSPS()->getScaledRefLayerWindow(m_interLayerPredLayerIdc[i]); |
---|
597 | #endif |
---|
598 | #endif |
---|
599 | Int scalingOffset = ((scalEL.getWindowLeftOffset() == 0 ) && |
---|
600 | (scalEL.getWindowRightOffset() == 0 ) && |
---|
601 | (scalEL.getWindowTopOffset() == 0 ) && |
---|
602 | (scalEL.getWindowBottomOffset() == 0 ) |
---|
603 | ); |
---|
604 | #endif |
---|
605 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
606 | Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] ); |
---|
607 | |
---|
608 | if( !( g_posScalingFactor[refLayerIdc][0] == 65536 && g_posScalingFactor[refLayerIdc][1] == 65536 ) || !scalingOffset || !sameBitDepths |
---|
609 | #if Q0048_CGS_3D_ASYMLUT |
---|
610 | || getPPS()->getCGSFlag() |
---|
611 | #endif |
---|
612 | ) // ratio 1x |
---|
613 | #else |
---|
614 | if(!( g_posScalingFactor[refLayerIdc][0] == 65536 && g_posScalingFactor[refLayerIdc][1] == 65536 ) || (!scalingOffset)) // ratio 1x |
---|
615 | #endif |
---|
616 | { |
---|
617 | #if MOTION_RESAMPLING_CONSTRAINT |
---|
618 | UInt predType = m_pcVPS->getDirectDependencyType( m_layerId, refLayerId ) + 1; |
---|
619 | |
---|
620 | if( predType & 0x1 ) |
---|
621 | { |
---|
622 | numResampler++; |
---|
623 | refResamplingLayer[i] = refLayerIdc + 1; |
---|
624 | } |
---|
625 | |
---|
626 | if( predType & 0x2 ) |
---|
627 | { |
---|
628 | numMotionResamplers++; |
---|
629 | refResamplingLayer[i] -= refLayerIdc + 1; |
---|
630 | } |
---|
631 | #else |
---|
632 | numResampler++; |
---|
633 | #endif |
---|
634 | } |
---|
635 | } |
---|
636 | |
---|
637 | // When both picture sample values and picture motion field resampling processes are invoked for decoding of a particular picture, they shall be applied to the same reference layer picture. |
---|
638 | if( m_activeNumILRRefIdx > 1 && numResampler > 0 ) |
---|
639 | { |
---|
640 | for( i=0; i < m_activeNumILRRefIdx; i++ ) |
---|
641 | { |
---|
642 | assert( refResamplingLayer[i] >= 0 && "Motion and sample inter-layer prediction shall be from the same layer" ); |
---|
643 | } |
---|
644 | } |
---|
645 | |
---|
646 | // Bitstream constraint for SHVC: The picture resampling process as specified in subclause G.8.1.4.1 shall not be invoked more than once for decoding of each particular picture. |
---|
647 | assert(numResampler <= 1); |
---|
648 | #if MOTION_RESAMPLING_CONSTRAINT |
---|
649 | assert( numMotionResamplers <= 1 && "Up to 1 motion resampling is allowed" ); |
---|
650 | #endif |
---|
651 | } |
---|
652 | #endif |
---|
653 | } |
---|
654 | Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + m_activeNumILRRefIdx; |
---|
655 | #else //SVC_EXTENSION |
---|
656 | Int numPocTotalCurr = NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr; |
---|
657 | #endif //SVC_EXTENSION |
---|
658 | |
---|
659 | if (checkNumPocTotalCurr) |
---|
660 | { |
---|
661 | // The variable NumPocTotalCurr is derived as specified in subclause 7.4.7.2. It is a requirement of bitstream conformance that the following applies to the value of NumPocTotalCurr: |
---|
662 | #if SVC_EXTENSION // inter-layer prediction is allowed for BLA, CRA pictures of nuh_layer_id>0 |
---|
663 | // - If the current picture is a BLA or CRA picture with nuh_layer_id equal to 0, the value of NumPocTotalCurr shall be equal to 0. |
---|
664 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
665 | if (getRapPicFlag() && getLayerId()==0) |
---|
666 | #else |
---|
667 | // - If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. |
---|
668 | // - Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0. |
---|
669 | if (getRapPicFlag()) |
---|
670 | #endif |
---|
671 | { |
---|
672 | assert(numPocTotalCurr == 0); |
---|
673 | } |
---|
674 | |
---|
675 | if (m_eSliceType == I_SLICE) |
---|
676 | { |
---|
677 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
678 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
679 | |
---|
680 | return; |
---|
681 | } |
---|
682 | |
---|
683 | assert(numPocTotalCurr > 0); |
---|
684 | |
---|
685 | m_aiNumRefIdx[0] = getNumRefIdx(REF_PIC_LIST_0); |
---|
686 | m_aiNumRefIdx[1] = getNumRefIdx(REF_PIC_LIST_1); |
---|
687 | } |
---|
688 | |
---|
689 | Int cIdx = 0; |
---|
690 | for ( i=0; i<NumPocStCurr0; i++, cIdx++) |
---|
691 | { |
---|
692 | rpsCurrList0[cIdx] = RefPicSetStCurr0[i]; |
---|
693 | } |
---|
694 | #if SVC_EXTENSION |
---|
695 | #if RPL_INIT_N0316_N0082 |
---|
696 | if( m_layerId > 0 ) |
---|
697 | { |
---|
698 | for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++) |
---|
699 | { |
---|
700 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
701 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
702 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId(),m_layerId); |
---|
703 | #else |
---|
704 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId()); |
---|
705 | #endif |
---|
706 | if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) ) |
---|
707 | { |
---|
708 | rpsCurrList0[cIdx] = ilpPic[refLayerIdc]; |
---|
709 | } |
---|
710 | } |
---|
711 | } |
---|
712 | #endif |
---|
713 | #endif //SVC_EXTENSION |
---|
714 | for ( i=0; i<NumPocStCurr1; i++, cIdx++) |
---|
715 | { |
---|
716 | rpsCurrList0[cIdx] = RefPicSetStCurr1[i]; |
---|
717 | } |
---|
718 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
719 | { |
---|
720 | rpsCurrList0[cIdx] = RefPicSetLtCurr[i]; |
---|
721 | } |
---|
722 | #if !RPL_INIT_N0316_N0082 |
---|
723 | #if SVC_EXTENSION |
---|
724 | if( m_layerId > 0 ) |
---|
725 | { |
---|
726 | for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++) |
---|
727 | { |
---|
728 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
729 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
730 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId(),m_layerId); |
---|
731 | #else |
---|
732 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId()); |
---|
733 | #endif |
---|
734 | if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) ) |
---|
735 | { |
---|
736 | rpsCurrList0[cIdx] = ilpPic[refLayerIdc]; |
---|
737 | } |
---|
738 | } |
---|
739 | } |
---|
740 | #endif |
---|
741 | #endif |
---|
742 | assert(cIdx == numPocTotalCurr); |
---|
743 | |
---|
744 | if (m_eSliceType==B_SLICE) |
---|
745 | { |
---|
746 | cIdx = 0; |
---|
747 | for ( i=0; i<NumPocStCurr1; i++, cIdx++) |
---|
748 | { |
---|
749 | rpsCurrList1[cIdx] = RefPicSetStCurr1[i]; |
---|
750 | } |
---|
751 | for ( i=0; i<NumPocStCurr0; i++, cIdx++) |
---|
752 | { |
---|
753 | rpsCurrList1[cIdx] = RefPicSetStCurr0[i]; |
---|
754 | } |
---|
755 | for ( i=0; i<NumPocLtCurr; i++, cIdx++) |
---|
756 | { |
---|
757 | rpsCurrList1[cIdx] = RefPicSetLtCurr[i]; |
---|
758 | } |
---|
759 | |
---|
760 | #if SVC_EXTENSION |
---|
761 | if( m_layerId > 0 ) |
---|
762 | { |
---|
763 | for( i = 0; i < m_activeNumILRRefIdx && cIdx < numPocTotalCurr; cIdx ++, i ++) |
---|
764 | { |
---|
765 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
766 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
767 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId(),m_layerId); |
---|
768 | #else |
---|
769 | Int maxTidIlRefPicsPlus1 = getVPS()->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId()); |
---|
770 | #endif |
---|
771 | if( ((Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) ) |
---|
772 | { |
---|
773 | rpsCurrList1[cIdx] = ilpPic[refLayerIdc]; |
---|
774 | } |
---|
775 | } |
---|
776 | } |
---|
777 | #endif //SVC_EXTENSION |
---|
778 | |
---|
779 | assert(cIdx == numPocTotalCurr); |
---|
780 | } |
---|
781 | |
---|
782 | ::memset(m_bIsUsedAsLongTerm, 0, sizeof(m_bIsUsedAsLongTerm)); |
---|
783 | |
---|
784 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[0]; rIdx ++) |
---|
785 | { |
---|
786 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL0() ? m_RefPicListModification.getRefPicSetIdxL0(rIdx) : rIdx % numPocTotalCurr; |
---|
787 | assert(cIdx >= 0 && cIdx < numPocTotalCurr); |
---|
788 | m_apcRefPicList[0][rIdx] = rpsCurrList0[ cIdx ]; |
---|
789 | #if RPL_INIT_N0316_N0082 |
---|
790 | m_bIsUsedAsLongTerm[0][rIdx] = ( cIdx >= NumPocStCurr0 && cIdx < NumPocStCurr0 + m_activeNumILRRefIdx ) || ( cIdx >= NumPocStCurr0 + NumPocStCurr1 + m_activeNumILRRefIdx ); |
---|
791 | #else |
---|
792 | m_bIsUsedAsLongTerm[0][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 ); |
---|
793 | #endif |
---|
794 | } |
---|
795 | if ( m_eSliceType != B_SLICE ) |
---|
796 | { |
---|
797 | m_aiNumRefIdx[1] = 0; |
---|
798 | ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1])); |
---|
799 | } |
---|
800 | else |
---|
801 | { |
---|
802 | for (Int rIdx = 0; rIdx < m_aiNumRefIdx[1]; rIdx ++) |
---|
803 | { |
---|
804 | cIdx = m_RefPicListModification.getRefPicListModificationFlagL1() ? m_RefPicListModification.getRefPicSetIdxL1(rIdx) : rIdx % numPocTotalCurr; |
---|
805 | assert(cIdx >= 0 && cIdx < numPocTotalCurr); |
---|
806 | m_apcRefPicList[1][rIdx] = rpsCurrList1[ cIdx ]; |
---|
807 | m_bIsUsedAsLongTerm[1][rIdx] = ( cIdx >= NumPocStCurr0 + NumPocStCurr1 ); |
---|
808 | } |
---|
809 | } |
---|
810 | } |
---|
811 | |
---|
812 | #if SVC_EXTENSION |
---|
813 | Void TComSlice::setRefPicListModificationSvc() |
---|
814 | { |
---|
815 | if( !m_pcPPS->getListsModificationPresentFlag()) |
---|
816 | { |
---|
817 | return; |
---|
818 | } |
---|
819 | |
---|
820 | if(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) |
---|
821 | { |
---|
822 | return; |
---|
823 | } |
---|
824 | |
---|
825 | TComRefPicListModification* refPicListModification = &m_RefPicListModification; |
---|
826 | Int numberOfRpsCurrTempList = this->getNumRpsCurrTempList(); // total number of ref pics in listTemp0 including inter-layer ref pics |
---|
827 | #if RPL_INIT_N0316_N0082 |
---|
828 | Int numberOfPocBeforeCurr = this->getNumNegativeRpsCurrTempList(); // number of negative temporal ref pics |
---|
829 | #endif |
---|
830 | |
---|
831 | assert(m_aiNumRefIdx[REF_PIC_LIST_0] > 0); |
---|
832 | assert(m_aiNumRefIdx[REF_PIC_LIST_1] > 0); |
---|
833 | |
---|
834 | //set L0 inter-layer reference picture modification |
---|
835 | #if RPL_INIT_N0316_N0082 |
---|
836 | Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true; |
---|
837 | |
---|
838 | if( m_activeNumILRRefIdx > 1 ) |
---|
839 | { |
---|
840 | hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] >= (numberOfPocBeforeCurr + m_activeNumILRRefIdx)) ? false : true; |
---|
841 | } |
---|
842 | #else |
---|
843 | Bool hasModification = (m_aiNumRefIdx[REF_PIC_LIST_0] == numberOfRpsCurrTempList) ? false : true; |
---|
844 | #endif |
---|
845 | hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_0] > 1 ); |
---|
846 | refPicListModification->setRefPicListModificationFlagL0(hasModification); |
---|
847 | if(hasModification) |
---|
848 | { |
---|
849 | for(Int i = 0; i < min(m_aiNumRefIdx[REF_PIC_LIST_0], numberOfRpsCurrTempList); i++) |
---|
850 | { |
---|
851 | refPicListModification->setRefPicSetIdxL0(i, i); |
---|
852 | } |
---|
853 | |
---|
854 | if(m_aiNumRefIdx[REF_PIC_LIST_0] > numberOfRpsCurrTempList) |
---|
855 | { |
---|
856 | // repeat last ref pic when the number of active ref idx are more than RPS entries |
---|
857 | for (Int i = numberOfRpsCurrTempList; i < m_aiNumRefIdx[REF_PIC_LIST_0]; i ++) |
---|
858 | { |
---|
859 | refPicListModification->setRefPicSetIdxL0(i, numberOfRpsCurrTempList - 1); |
---|
860 | } |
---|
861 | } |
---|
862 | else |
---|
863 | { |
---|
864 | // number of ILRPs included into the reference picture list with the list modification |
---|
865 | Int includeNumILRP = min( max(1, m_aiNumRefIdx[REF_PIC_LIST_0]-numberOfPocBeforeCurr), m_activeNumILRRefIdx); |
---|
866 | |
---|
867 | for(Int i = includeNumILRP; i > 0; i-- ) |
---|
868 | { |
---|
869 | #if RPL_INIT_N0316_N0082 |
---|
870 | if((numberOfPocBeforeCurr) >= m_aiNumRefIdx[REF_PIC_LIST_0]) |
---|
871 | { |
---|
872 | refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr + includeNumILRP - i); |
---|
873 | } |
---|
874 | else |
---|
875 | { |
---|
876 | refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfPocBeforeCurr + includeNumILRP - i); |
---|
877 | for (Int j = numberOfPocBeforeCurr; j < (m_aiNumRefIdx[REF_PIC_LIST_0] - i); j++) |
---|
878 | { |
---|
879 | assert( j + includeNumILRP < numberOfRpsCurrTempList ); |
---|
880 | refPicListModification->setRefPicSetIdxL0(j, j + includeNumILRP); |
---|
881 | } |
---|
882 | } |
---|
883 | #else |
---|
884 | refPicListModification->setRefPicSetIdxL0(m_aiNumRefIdx[REF_PIC_LIST_0] - i, numberOfRpsCurrTempList - i); |
---|
885 | #endif |
---|
886 | } |
---|
887 | } |
---|
888 | } |
---|
889 | |
---|
890 | //set L1 inter-layer reference picture modification |
---|
891 | hasModification = (m_aiNumRefIdx[REF_PIC_LIST_1] >= numberOfRpsCurrTempList) ? false : true; |
---|
892 | hasModification = hasModification && ( m_aiNumRefIdx[REF_PIC_LIST_1] > 1 ); |
---|
893 | |
---|
894 | refPicListModification->setRefPicListModificationFlagL1(hasModification); |
---|
895 | if(hasModification) |
---|
896 | { |
---|
897 | for(Int i = 0; i < min(m_aiNumRefIdx[REF_PIC_LIST_1], numberOfRpsCurrTempList); i++) |
---|
898 | { |
---|
899 | refPicListModification->setRefPicSetIdxL1(i, i); |
---|
900 | } |
---|
901 | if(m_aiNumRefIdx[REF_PIC_LIST_1] > numberOfRpsCurrTempList) |
---|
902 | { |
---|
903 | for (Int i = numberOfRpsCurrTempList; i < m_aiNumRefIdx[REF_PIC_LIST_1]; i ++) |
---|
904 | { |
---|
905 | // repeat last ref pic when the number of active ref idx are more than RPS entries |
---|
906 | refPicListModification->setRefPicSetIdxL1(i, numberOfRpsCurrTempList - 1); |
---|
907 | } |
---|
908 | } |
---|
909 | else |
---|
910 | { |
---|
911 | Int includeNumILRP = min(m_aiNumRefIdx[REF_PIC_LIST_1], m_activeNumILRRefIdx); |
---|
912 | |
---|
913 | for(Int i = includeNumILRP; i > 0; i-- ) |
---|
914 | { |
---|
915 | refPicListModification->setRefPicSetIdxL1(m_aiNumRefIdx[REF_PIC_LIST_1] - i, numberOfRpsCurrTempList - i); |
---|
916 | } |
---|
917 | } |
---|
918 | } |
---|
919 | return; |
---|
920 | } |
---|
921 | #endif |
---|
922 | #if RPL_INIT_N0316_N0082 |
---|
923 | Int TComSlice::getNumNegativeRpsCurrTempList() |
---|
924 | { |
---|
925 | if( m_eSliceType == I_SLICE ) |
---|
926 | { |
---|
927 | return 0; |
---|
928 | } |
---|
929 | |
---|
930 | Int numPocBeforeCurr = 0; |
---|
931 | for( UInt i = 0; i < m_pcRPS->getNumberOfNegativePictures(); i++ ) |
---|
932 | { |
---|
933 | if(m_pcRPS->getUsed(i)) |
---|
934 | { |
---|
935 | numPocBeforeCurr++; |
---|
936 | } |
---|
937 | } |
---|
938 | |
---|
939 | return numPocBeforeCurr; |
---|
940 | } |
---|
941 | #endif |
---|
942 | Int TComSlice::getNumRpsCurrTempList() |
---|
943 | { |
---|
944 | Int numRpsCurrTempList = 0; |
---|
945 | |
---|
946 | #if SVC_EXTENSION |
---|
947 | if( m_eSliceType == I_SLICE || ( m_layerId && |
---|
948 | (m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && |
---|
949 | (m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) ) ) |
---|
950 | #else |
---|
951 | if (m_eSliceType == I_SLICE) |
---|
952 | #endif |
---|
953 | { |
---|
954 | #if SVC_EXTENSION |
---|
955 | return m_activeNumILRRefIdx; |
---|
956 | #else |
---|
957 | return 0; |
---|
958 | #endif |
---|
959 | } |
---|
960 | for(UInt i=0; i < m_pcRPS->getNumberOfNegativePictures()+ m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures(); i++) |
---|
961 | { |
---|
962 | if(m_pcRPS->getUsed(i)) |
---|
963 | { |
---|
964 | numRpsCurrTempList++; |
---|
965 | } |
---|
966 | } |
---|
967 | #if SVC_EXTENSION |
---|
968 | if( m_layerId > 0 ) |
---|
969 | { |
---|
970 | numRpsCurrTempList += m_activeNumILRRefIdx; |
---|
971 | } |
---|
972 | #endif |
---|
973 | |
---|
974 | return numRpsCurrTempList; |
---|
975 | } |
---|
976 | |
---|
977 | Void TComSlice::initEqualRef() |
---|
978 | { |
---|
979 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
980 | { |
---|
981 | for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++) |
---|
982 | { |
---|
983 | for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++) |
---|
984 | { |
---|
985 | m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false); |
---|
986 | } |
---|
987 | } |
---|
988 | } |
---|
989 | } |
---|
990 | |
---|
991 | Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic) |
---|
992 | { |
---|
993 | Int i; |
---|
994 | TComSlice* curSlice = pic->getSlice(curSliceIdx); |
---|
995 | Int currColRefPOC = curSlice->getRefPOC( RefPicList(1-curSlice->getColFromL0Flag()), curSlice->getColRefIdx()); |
---|
996 | TComSlice* preSlice; |
---|
997 | Int preColRefPOC; |
---|
998 | for(i=curSliceIdx-1; i>=0; i--) |
---|
999 | { |
---|
1000 | preSlice = pic->getSlice(i); |
---|
1001 | if(preSlice->getSliceType() != I_SLICE) |
---|
1002 | { |
---|
1003 | preColRefPOC = preSlice->getRefPOC( RefPicList(1-preSlice->getColFromL0Flag()), preSlice->getColRefIdx()); |
---|
1004 | if(currColRefPOC != preColRefPOC) |
---|
1005 | { |
---|
1006 | printf("Collocated_ref_idx shall always be the same for all slices of a coded picture!\n"); |
---|
1007 | exit(EXIT_FAILURE); |
---|
1008 | } |
---|
1009 | else |
---|
1010 | { |
---|
1011 | break; |
---|
1012 | } |
---|
1013 | } |
---|
1014 | } |
---|
1015 | } |
---|
1016 | |
---|
1017 | Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic) |
---|
1018 | { |
---|
1019 | for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) |
---|
1020 | { |
---|
1021 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
1022 | { |
---|
1023 | assert(getPOC()+pReferencePictureSet->getDeltaPOC(i) >= pocCRA); |
---|
1024 | } |
---|
1025 | } |
---|
1026 | for(Int i = pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i < pReferencePictureSet->getNumberOfPictures(); i++) |
---|
1027 | { |
---|
1028 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
1029 | { |
---|
1030 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
1031 | { |
---|
1032 | assert(xGetLongTermRefPic(rcListPic, pReferencePictureSet->getPOC(i), false)->getPOC() >= pocCRA); |
---|
1033 | } |
---|
1034 | else |
---|
1035 | { |
---|
1036 | assert(pReferencePictureSet->getPOC(i) >= pocCRA); |
---|
1037 | } |
---|
1038 | } |
---|
1039 | } |
---|
1040 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found |
---|
1041 | { |
---|
1042 | pocCRA = getPOC(); |
---|
1043 | associatedIRAPType = getNalUnitType(); |
---|
1044 | } |
---|
1045 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
1046 | { |
---|
1047 | pocCRA = getPOC(); |
---|
1048 | associatedIRAPType = getNalUnitType(); |
---|
1049 | } |
---|
1050 | else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1051 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1052 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found |
---|
1053 | { |
---|
1054 | pocCRA = getPOC(); |
---|
1055 | associatedIRAPType = getNalUnitType(); |
---|
1056 | } |
---|
1057 | } |
---|
1058 | |
---|
1059 | /** Function for marking the reference pictures when an IDR/CRA/CRANT/BLA/BLANT is encountered. |
---|
1060 | * \param pocCRA POC of the CRA/CRANT/BLA/BLANT picture |
---|
1061 | * \param bRefreshPending flag indicating if a deferred decoding refresh is pending |
---|
1062 | * \param rcListPic reference to the reference picture list |
---|
1063 | * This function marks the reference pictures as "unused for reference" in the following conditions. |
---|
1064 | * If the nal_unit_type is IDR/BLA/BLANT, all pictures in the reference picture list |
---|
1065 | * are marked as "unused for reference" |
---|
1066 | * If the nal_unit_type is BLA/BLANT, set the pocCRA to the temporal reference of the current picture. |
---|
1067 | * Otherwise |
---|
1068 | * If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current |
---|
1069 | * temporal reference is greater than the temporal reference of the latest CRA/CRANT/BLA/BLANT picture (pocCRA), |
---|
1070 | * mark all reference pictures except the latest CRA/CRANT/BLA/BLANT picture as "unused for reference" and set |
---|
1071 | * the bRefreshPending flag to false. |
---|
1072 | * If the nal_unit_type is CRA/CRANT, set the bRefreshPending flag to true and pocCRA to the temporal |
---|
1073 | * reference of the current picture. |
---|
1074 | * Note that the current picture is already placed in the reference list and its marking is not changed. |
---|
1075 | * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". |
---|
1076 | */ |
---|
1077 | #if NO_CLRAS_OUTPUT_FLAG |
---|
1078 | Void TComSlice::decodingRefreshMarking( TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag ) |
---|
1079 | { |
---|
1080 | if( !isIRAP() ) |
---|
1081 | { |
---|
1082 | return; |
---|
1083 | } |
---|
1084 | |
---|
1085 | Int pocCurr = getPOC(); |
---|
1086 | TComPic* rpcPic = NULL; |
---|
1087 | |
---|
1088 | // When the current picture is an IRAP picture with nuh_layer_id equal to 0 and NoClrasOutputFlag is equal to 1, |
---|
1089 | // all reference pictures with any value of nuh_layer_id currently in the DPB (if any) are marked as "unused for reference". |
---|
1090 | if( m_layerId == 0 && noClrasOutputFlag ) |
---|
1091 | { |
---|
1092 | // mark all pictures for all layers as not used for reference |
---|
1093 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1094 | while( iterPic != rcListPic.end() ) |
---|
1095 | { |
---|
1096 | rpcPic = *(iterPic); |
---|
1097 | if( rpcPic->getPOC() != pocCurr ) |
---|
1098 | { |
---|
1099 | rpcPic->getSlice(0)->setReferenced(false); |
---|
1100 | } |
---|
1101 | iterPic++; |
---|
1102 | } |
---|
1103 | } |
---|
1104 | |
---|
1105 | // When the current picture is an IRAP picture with NoRaslOutputFlag equal to 1, |
---|
1106 | // all reference pictures with nuh_layer_id equal to currPicLayerId currently in the DPB (if any) are marked as "unused for reference". |
---|
1107 | if( m_noRaslOutputFlag ) |
---|
1108 | { |
---|
1109 | // mark all pictures of a current layer as not used for reference |
---|
1110 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1111 | while( iterPic != rcListPic.end() ) |
---|
1112 | { |
---|
1113 | rpcPic = *(iterPic); |
---|
1114 | if( rpcPic->getPOC() != pocCurr && rpcPic->getLayerId() == m_layerId ) |
---|
1115 | { |
---|
1116 | rpcPic->getSlice(0)->setReferenced(false); |
---|
1117 | } |
---|
1118 | iterPic++; |
---|
1119 | } |
---|
1120 | } |
---|
1121 | } |
---|
1122 | |
---|
1123 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic, Bool noClrasOutputFlag) |
---|
1124 | #else |
---|
1125 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic) |
---|
1126 | #endif |
---|
1127 | { |
---|
1128 | TComPic* rpcPic; |
---|
1129 | #if !FIX1172 |
---|
1130 | setAssociatedIRAPPOC(pocCRA); |
---|
1131 | #endif |
---|
1132 | Int pocCurr = getPOC(); |
---|
1133 | |
---|
1134 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1135 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1136 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP |
---|
1137 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL |
---|
1138 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR or BLA picture |
---|
1139 | { |
---|
1140 | // mark all pictures as not used for reference |
---|
1141 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1142 | while (iterPic != rcListPic.end()) |
---|
1143 | { |
---|
1144 | rpcPic = *(iterPic); |
---|
1145 | rpcPic->setCurrSliceIdx(0); |
---|
1146 | #if NO_CLRAS_OUTPUT_FLAG |
---|
1147 | #if POC_RESET_IDC_ENCODER |
---|
1148 | if (noClrasOutputFlag) |
---|
1149 | { |
---|
1150 | rpcPic->getSlice(0)->setReferenced(false); // all layers // TODO. This does not mark all layers |
---|
1151 | } |
---|
1152 | else |
---|
1153 | { |
---|
1154 | if (rpcPic->getLayerId() == m_layerId) rpcPic->getSlice(0)->setReferenced(false); // only current layer |
---|
1155 | } |
---|
1156 | #else |
---|
1157 | if (noClrasOutputFlag) |
---|
1158 | { |
---|
1159 | if (rpcPic->getPOC() != pocCurr) rpcPic->getSlice(0)->setReferenced(false); // all layers |
---|
1160 | } |
---|
1161 | else |
---|
1162 | { |
---|
1163 | if (rpcPic->getPOC() != pocCurr && rpcPic->getLayerId() == m_layerId) rpcPic->getSlice(0)->setReferenced(false); // only current layer |
---|
1164 | } |
---|
1165 | #endif |
---|
1166 | #else |
---|
1167 | if (rpcPic->getPOC() != pocCurr) rpcPic->getSlice(0)->setReferenced(false); |
---|
1168 | #endif |
---|
1169 | iterPic++; |
---|
1170 | } |
---|
1171 | #if POC_RESET_IDC_ENCODER |
---|
1172 | this->getPic()->getSlice(0)->setReferenced(true); // Mark the current picture back as refererced. |
---|
1173 | #endif |
---|
1174 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1175 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1176 | || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
1177 | { |
---|
1178 | pocCRA = pocCurr; |
---|
1179 | } |
---|
1180 | #if EFFICIENT_FIELD_IRAP |
---|
1181 | bRefreshPending = true; |
---|
1182 | #endif |
---|
1183 | } |
---|
1184 | else // CRA or No DR |
---|
1185 | { |
---|
1186 | #if EFFICIENT_FIELD_IRAP |
---|
1187 | if(getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL) |
---|
1188 | { |
---|
1189 | if (bRefreshPending==true && pocCurr > m_iLastIDR) // IDR reference marking pending |
---|
1190 | { |
---|
1191 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1192 | while (iterPic != rcListPic.end()) |
---|
1193 | { |
---|
1194 | rpcPic = *(iterPic); |
---|
1195 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != m_iLastIDR) |
---|
1196 | { |
---|
1197 | rpcPic->getSlice(0)->setReferenced(false); |
---|
1198 | } |
---|
1199 | iterPic++; |
---|
1200 | } |
---|
1201 | bRefreshPending = false; |
---|
1202 | } |
---|
1203 | } |
---|
1204 | else |
---|
1205 | { |
---|
1206 | #endif |
---|
1207 | if (bRefreshPending==true && pocCurr > pocCRA) // CRA reference marking pending |
---|
1208 | { |
---|
1209 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1210 | while (iterPic != rcListPic.end()) |
---|
1211 | { |
---|
1212 | rpcPic = *(iterPic); |
---|
1213 | if (rpcPic->getPOC() != pocCurr && rpcPic->getPOC() != pocCRA) |
---|
1214 | { |
---|
1215 | rpcPic->getSlice(0)->setReferenced(false); |
---|
1216 | } |
---|
1217 | iterPic++; |
---|
1218 | } |
---|
1219 | bRefreshPending = false; |
---|
1220 | } |
---|
1221 | #if EFFICIENT_FIELD_IRAP |
---|
1222 | } |
---|
1223 | #endif |
---|
1224 | if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
1225 | { |
---|
1226 | bRefreshPending = true; |
---|
1227 | pocCRA = pocCurr; |
---|
1228 | } |
---|
1229 | } |
---|
1230 | } |
---|
1231 | |
---|
1232 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
1233 | { |
---|
1234 | assert( pSrc != NULL ); |
---|
1235 | |
---|
1236 | Int i, j, k; |
---|
1237 | |
---|
1238 | m_iPOC = pSrc->m_iPOC; |
---|
1239 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
1240 | m_eSliceType = pSrc->m_eSliceType; |
---|
1241 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
1242 | #if ADAPTIVE_QP_SELECTION |
---|
1243 | m_iSliceQpBase = pSrc->m_iSliceQpBase; |
---|
1244 | #endif |
---|
1245 | m_deblockingFilterDisable = pSrc->m_deblockingFilterDisable; |
---|
1246 | m_deblockingFilterOverrideFlag = pSrc->m_deblockingFilterOverrideFlag; |
---|
1247 | m_deblockingFilterBetaOffsetDiv2 = pSrc->m_deblockingFilterBetaOffsetDiv2; |
---|
1248 | m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2; |
---|
1249 | |
---|
1250 | for (i = 0; i < 2; i++) |
---|
1251 | { |
---|
1252 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
1253 | } |
---|
1254 | |
---|
1255 | for (i = 0; i < MAX_NUM_REF; i++) |
---|
1256 | { |
---|
1257 | m_list1IdxToList0Idx[i] = pSrc->m_list1IdxToList0Idx[i]; |
---|
1258 | } |
---|
1259 | m_bCheckLDC = pSrc->m_bCheckLDC; |
---|
1260 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
1261 | m_iSliceQpDeltaCb = pSrc->m_iSliceQpDeltaCb; |
---|
1262 | m_iSliceQpDeltaCr = pSrc->m_iSliceQpDeltaCr; |
---|
1263 | for (i = 0; i < 2; i++) |
---|
1264 | { |
---|
1265 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
1266 | { |
---|
1267 | m_apcRefPicList[i][j] = pSrc->m_apcRefPicList[i][j]; |
---|
1268 | m_aiRefPOCList[i][j] = pSrc->m_aiRefPOCList[i][j]; |
---|
1269 | } |
---|
1270 | } |
---|
1271 | for (i = 0; i < 2; i++) |
---|
1272 | { |
---|
1273 | for (j = 0; j < MAX_NUM_REF + 1; j++) |
---|
1274 | { |
---|
1275 | m_bIsUsedAsLongTerm[i][j] = pSrc->m_bIsUsedAsLongTerm[i][j]; |
---|
1276 | } |
---|
1277 | } |
---|
1278 | m_iDepth = pSrc->m_iDepth; |
---|
1279 | |
---|
1280 | // referenced slice |
---|
1281 | m_bRefenced = pSrc->m_bRefenced; |
---|
1282 | |
---|
1283 | // access channel |
---|
1284 | #if SVC_EXTENSION |
---|
1285 | m_pcVPS = pSrc->m_pcVPS; |
---|
1286 | m_layerId = pSrc->m_layerId; |
---|
1287 | m_activeNumILRRefIdx = pSrc->m_activeNumILRRefIdx; |
---|
1288 | m_interLayerPredEnabledFlag = pSrc->m_interLayerPredEnabledFlag; |
---|
1289 | memcpy( m_interLayerPredLayerIdc, pSrc->m_interLayerPredLayerIdc, sizeof( m_interLayerPredLayerIdc ) ); |
---|
1290 | #if P0312_VERT_PHASE_ADJ |
---|
1291 | memcpy( m_vertPhasePositionFlag, pSrc->m_vertPhasePositionFlag, sizeof( m_vertPhasePositionFlag ) ); |
---|
1292 | #endif |
---|
1293 | #endif |
---|
1294 | m_pcSPS = pSrc->m_pcSPS; |
---|
1295 | m_pcPPS = pSrc->m_pcPPS; |
---|
1296 | m_pcRPS = pSrc->m_pcRPS; |
---|
1297 | m_iLastIDR = pSrc->m_iLastIDR; |
---|
1298 | |
---|
1299 | m_pcPic = pSrc->m_pcPic; |
---|
1300 | |
---|
1301 | m_colFromL0Flag = pSrc->m_colFromL0Flag; |
---|
1302 | m_colRefIdx = pSrc->m_colRefIdx; |
---|
1303 | setLambdas(pSrc->getLambdas()); |
---|
1304 | for (i = 0; i < 2; i++) |
---|
1305 | { |
---|
1306 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
1307 | { |
---|
1308 | for (k =0; k < MAX_NUM_REF; k++) |
---|
1309 | { |
---|
1310 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
1311 | } |
---|
1312 | } |
---|
1313 | } |
---|
1314 | |
---|
1315 | m_uiTLayer = pSrc->m_uiTLayer; |
---|
1316 | m_bTLayerSwitchingFlag = pSrc->m_bTLayerSwitchingFlag; |
---|
1317 | |
---|
1318 | m_sliceMode = pSrc->m_sliceMode; |
---|
1319 | m_sliceArgument = pSrc->m_sliceArgument; |
---|
1320 | m_sliceCurStartCUAddr = pSrc->m_sliceCurStartCUAddr; |
---|
1321 | m_sliceCurEndCUAddr = pSrc->m_sliceCurEndCUAddr; |
---|
1322 | m_sliceIdx = pSrc->m_sliceIdx; |
---|
1323 | m_sliceSegmentMode = pSrc->m_sliceSegmentMode; |
---|
1324 | m_sliceSegmentArgument = pSrc->m_sliceSegmentArgument; |
---|
1325 | m_sliceSegmentCurStartCUAddr = pSrc->m_sliceSegmentCurStartCUAddr; |
---|
1326 | m_sliceSegmentCurEndCUAddr = pSrc->m_sliceSegmentCurEndCUAddr; |
---|
1327 | m_nextSlice = pSrc->m_nextSlice; |
---|
1328 | m_nextSliceSegment = pSrc->m_nextSliceSegment; |
---|
1329 | for ( Int e=0 ; e<2 ; e++ ) |
---|
1330 | { |
---|
1331 | for ( Int n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
1332 | { |
---|
1333 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(wpScalingParam)*3 ); |
---|
1334 | } |
---|
1335 | } |
---|
1336 | m_saoEnabledFlag = pSrc->m_saoEnabledFlag; |
---|
1337 | m_saoEnabledFlagChroma = pSrc->m_saoEnabledFlagChroma; |
---|
1338 | m_cabacInitFlag = pSrc->m_cabacInitFlag; |
---|
1339 | m_numEntryPointOffsets = pSrc->m_numEntryPointOffsets; |
---|
1340 | |
---|
1341 | m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; |
---|
1342 | m_LFCrossSliceBoundaryFlag = pSrc->m_LFCrossSliceBoundaryFlag; |
---|
1343 | m_enableTMVPFlag = pSrc->m_enableTMVPFlag; |
---|
1344 | m_maxNumMergeCand = pSrc->m_maxNumMergeCand; |
---|
1345 | } |
---|
1346 | |
---|
1347 | Int TComSlice::m_prevTid0POC = 0; |
---|
1348 | |
---|
1349 | /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. |
---|
1350 | * \param uiTLayer Temporal layer ID of the current slice |
---|
1351 | * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on |
---|
1352 | * the SPS's temporal_id_nesting_flag and the parsed PPS. Then, current slice's temporal layer ID and |
---|
1353 | * temporal_layer_switching_point_flag is set accordingly. |
---|
1354 | */ |
---|
1355 | Void TComSlice::setTLayerInfo( UInt uiTLayer ) |
---|
1356 | { |
---|
1357 | m_uiTLayer = uiTLayer; |
---|
1358 | } |
---|
1359 | |
---|
1360 | /** Function for checking if this is a switching-point |
---|
1361 | */ |
---|
1362 | Bool TComSlice::isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic ) |
---|
1363 | { |
---|
1364 | TComPic* rpcPic; |
---|
1365 | // loop through all pictures in the reference picture buffer |
---|
1366 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1367 | while ( iterPic != rcListPic.end()) |
---|
1368 | { |
---|
1369 | rpcPic = *(iterPic++); |
---|
1370 | if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC()) |
---|
1371 | { |
---|
1372 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
1373 | { |
---|
1374 | return false; |
---|
1375 | } |
---|
1376 | } |
---|
1377 | } |
---|
1378 | return true; |
---|
1379 | } |
---|
1380 | |
---|
1381 | /** Function for checking if this is a STSA candidate |
---|
1382 | */ |
---|
1383 | Bool TComSlice::isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic ) |
---|
1384 | { |
---|
1385 | TComPic* rpcPic; |
---|
1386 | |
---|
1387 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1388 | while ( iterPic != rcListPic.end()) |
---|
1389 | { |
---|
1390 | rpcPic = *(iterPic++); |
---|
1391 | if(rpcPic->getSlice(0)->isReferenced() && (rpcPic->getUsedByCurr()==true) && rpcPic->getPOC() != getPOC()) |
---|
1392 | { |
---|
1393 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
1394 | { |
---|
1395 | return false; |
---|
1396 | } |
---|
1397 | } |
---|
1398 | } |
---|
1399 | return true; |
---|
1400 | } |
---|
1401 | |
---|
1402 | #if POC_RESET_IDC_ENCODER |
---|
1403 | Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic, Bool usePocBeforeReset) |
---|
1404 | #else |
---|
1405 | Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic) |
---|
1406 | #endif |
---|
1407 | { |
---|
1408 | TComPic* rpcPic; |
---|
1409 | |
---|
1410 | Int nalUnitType = this->getNalUnitType(); |
---|
1411 | |
---|
1412 | // When a picture is a leading picture, it shall be a RADL or RASL picture. |
---|
1413 | if(this->getAssociatedIRAPPOC() > this->getPOC()) |
---|
1414 | { |
---|
1415 | // Do not check IRAP pictures since they may get a POC lower than their associated IRAP |
---|
1416 | if(nalUnitType < NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1417 | nalUnitType > NAL_UNIT_RESERVED_IRAP_VCL23) |
---|
1418 | { |
---|
1419 | assert(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1420 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
1421 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1422 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R); |
---|
1423 | } |
---|
1424 | } |
---|
1425 | |
---|
1426 | // When a picture is a trailing picture, it shall not be a RADL or RASL picture. |
---|
1427 | if(this->getAssociatedIRAPPOC() < this->getPOC()) |
---|
1428 | { |
---|
1429 | assert(nalUnitType != NAL_UNIT_CODED_SLICE_RASL_N && |
---|
1430 | nalUnitType != NAL_UNIT_CODED_SLICE_RASL_R && |
---|
1431 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_N && |
---|
1432 | nalUnitType != NAL_UNIT_CODED_SLICE_RADL_R); |
---|
1433 | } |
---|
1434 | |
---|
1435 | // No RASL pictures shall be present in the bitstream that are associated |
---|
1436 | // with a BLA picture having nal_unit_type equal to BLA_W_RADL or BLA_N_LP. |
---|
1437 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1438 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1439 | { |
---|
1440 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_W_RADL && |
---|
1441 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP); |
---|
1442 | } |
---|
1443 | |
---|
1444 | // No RASL pictures shall be present in the bitstream that are associated with |
---|
1445 | // an IDR picture. |
---|
1446 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1447 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1448 | { |
---|
1449 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP && |
---|
1450 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL); |
---|
1451 | } |
---|
1452 | |
---|
1453 | // No RADL pictures shall be present in the bitstream that are associated with |
---|
1454 | // a BLA picture having nal_unit_type equal to BLA_N_LP or that are associated |
---|
1455 | // with an IDR picture having nal_unit_type equal to IDR_N_LP. |
---|
1456 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1457 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1458 | { |
---|
1459 | assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP && |
---|
1460 | this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP); |
---|
1461 | } |
---|
1462 | |
---|
1463 | // loop through all pictures in the reference picture buffer |
---|
1464 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1465 | while ( iterPic != rcListPic.end()) |
---|
1466 | { |
---|
1467 | rpcPic = *(iterPic++); |
---|
1468 | #if BUGFIX_INTRAPERIOD |
---|
1469 | if(!rpcPic->getReconMark()) |
---|
1470 | { |
---|
1471 | continue; |
---|
1472 | } |
---|
1473 | #endif |
---|
1474 | if (rpcPic->getPOC() == this->getPOC()) |
---|
1475 | { |
---|
1476 | continue; |
---|
1477 | } |
---|
1478 | |
---|
1479 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
1480 | // in decoding order shall precede the IRAP picture in output order. |
---|
1481 | // (Note that any picture following in output order would be present in the DPB) |
---|
1482 | #if !SETTING_NO_OUT_PIC_PRIOR |
---|
1483 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) |
---|
1484 | #else |
---|
1485 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1 && !this->getNoOutputPriorPicsFlag()) |
---|
1486 | #endif |
---|
1487 | { |
---|
1488 | if(nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1489 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1490 | nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1491 | nalUnitType == NAL_UNIT_CODED_SLICE_CRA || |
---|
1492 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
1493 | nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL) |
---|
1494 | { |
---|
1495 | #if POC_RESET_IDC_ENCODER |
---|
1496 | if( usePocBeforeReset ) |
---|
1497 | { |
---|
1498 | assert(rpcPic->getSlice(0)->getPocValueBeforeReset() < this->getPocValueBeforeReset()); |
---|
1499 | } |
---|
1500 | else |
---|
1501 | { |
---|
1502 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1503 | } |
---|
1504 | #else |
---|
1505 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1506 | #endif |
---|
1507 | } |
---|
1508 | } |
---|
1509 | |
---|
1510 | // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture |
---|
1511 | // in decoding order shall precede any RADL picture associated with the IRAP |
---|
1512 | // picture in output order. |
---|
1513 | if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) |
---|
1514 | { |
---|
1515 | if((nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1516 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)) |
---|
1517 | { |
---|
1518 | // rpcPic precedes the IRAP in decoding order |
---|
1519 | if(this->getAssociatedIRAPPOC() > rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
1520 | { |
---|
1521 | // rpcPic must not be the IRAP picture |
---|
1522 | if(this->getAssociatedIRAPPOC() != rpcPic->getPOC()) |
---|
1523 | { |
---|
1524 | #if POC_RESET_IDC_ENCODER |
---|
1525 | if( usePocBeforeReset ) |
---|
1526 | { |
---|
1527 | assert(rpcPic->getSlice(0)->getPocValueBeforeReset() < this->getPocValueBeforeReset()); |
---|
1528 | } |
---|
1529 | else |
---|
1530 | { |
---|
1531 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1532 | } |
---|
1533 | #else |
---|
1534 | assert(rpcPic->getPOC() < this->getPOC()); |
---|
1535 | #endif |
---|
1536 | } |
---|
1537 | } |
---|
1538 | } |
---|
1539 | } |
---|
1540 | |
---|
1541 | // When a picture is a leading picture, it shall precede, in decoding order, |
---|
1542 | // all trailing pictures that are associated with the same IRAP picture. |
---|
1543 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1544 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || |
---|
1545 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1546 | nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1547 | { |
---|
1548 | if(rpcPic->getSlice(0)->getAssociatedIRAPPOC() == this->getAssociatedIRAPPOC()) |
---|
1549 | { |
---|
1550 | // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB |
---|
1551 | // rpcPic would violate the constraint if it was a trailing picture |
---|
1552 | #if POC_RESET_IDC_ENCODER |
---|
1553 | if( usePocBeforeReset ) |
---|
1554 | { |
---|
1555 | assert(rpcPic->getPOC() <= this->getAssociatedIrapPocBeforeReset()); |
---|
1556 | } |
---|
1557 | else |
---|
1558 | { |
---|
1559 | assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC()); |
---|
1560 | } |
---|
1561 | #else |
---|
1562 | assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC()); |
---|
1563 | #endif |
---|
1564 | } |
---|
1565 | } |
---|
1566 | |
---|
1567 | // Any RASL picture associated with a CRA or BLA picture shall precede any |
---|
1568 | // RADL picture associated with the CRA or BLA picture in output order |
---|
1569 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1570 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1571 | { |
---|
1572 | if((this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1573 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1574 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1575 | this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) && |
---|
1576 | this->getAssociatedIRAPPOC() == rpcPic->getSlice(0)->getAssociatedIRAPPOC()) |
---|
1577 | { |
---|
1578 | if(rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || |
---|
1579 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R) |
---|
1580 | { |
---|
1581 | assert(rpcPic->getPOC() > this->getPOC()); |
---|
1582 | } |
---|
1583 | } |
---|
1584 | } |
---|
1585 | |
---|
1586 | // Any RASL picture associated with a CRA picture shall follow, in output |
---|
1587 | // order, any IRAP picture that precedes the CRA picture in decoding order. |
---|
1588 | if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || |
---|
1589 | nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) |
---|
1590 | { |
---|
1591 | if(this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) |
---|
1592 | { |
---|
1593 | if(rpcPic->getSlice(0)->getPOC() < this->getAssociatedIRAPPOC() && |
---|
1594 | (rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || |
---|
1595 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || |
---|
1596 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || |
---|
1597 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || |
---|
1598 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || |
---|
1599 | rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) |
---|
1600 | { |
---|
1601 | assert(this->getPOC() > rpcPic->getSlice(0)->getPOC()); |
---|
1602 | } |
---|
1603 | } |
---|
1604 | } |
---|
1605 | } |
---|
1606 | } |
---|
1607 | |
---|
1608 | |
---|
1609 | |
---|
1610 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1611 | */ |
---|
1612 | Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
1613 | { |
---|
1614 | TComPic* rpcPic; |
---|
1615 | Int i, isReference; |
---|
1616 | |
---|
1617 | #if !ALIGNED_BUMPING |
---|
1618 | checkLeadingPictureRestrictions(rcListPic); |
---|
1619 | #endif |
---|
1620 | |
---|
1621 | // loop through all pictures in the reference picture buffer |
---|
1622 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1623 | while ( iterPic != rcListPic.end()) |
---|
1624 | { |
---|
1625 | rpcPic = *(iterPic++); |
---|
1626 | |
---|
1627 | if(!rpcPic->getSlice( 0 )->isReferenced()) |
---|
1628 | { |
---|
1629 | continue; |
---|
1630 | } |
---|
1631 | |
---|
1632 | isReference = 0; |
---|
1633 | // loop through all pictures in the Reference Picture Set |
---|
1634 | // to see if the picture should be kept as reference picture |
---|
1635 | for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++) |
---|
1636 | { |
---|
1637 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
1638 | { |
---|
1639 | isReference = 1; |
---|
1640 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1641 | rpcPic->setIsLongTerm(0); |
---|
1642 | } |
---|
1643 | } |
---|
1644 | for(;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1645 | { |
---|
1646 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1647 | { |
---|
1648 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i)) |
---|
1649 | { |
---|
1650 | isReference = 1; |
---|
1651 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1652 | } |
---|
1653 | } |
---|
1654 | else |
---|
1655 | { |
---|
1656 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1657 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
1658 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
1659 | if(rpcPic->getIsLongTerm() && curPoc == refPoc) |
---|
1660 | { |
---|
1661 | isReference = 1; |
---|
1662 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1663 | } |
---|
1664 | } |
---|
1665 | |
---|
1666 | } |
---|
1667 | #if DISCARDABLE_PIC_RPS |
---|
1668 | if( isReference ) // Current picture is in the temporal RPS |
---|
1669 | { |
---|
1670 | assert( rpcPic->getSlice(0)->getDiscardableFlag() == 0 ); // Temporal RPS shall not contain picture with discardable_flag equal to 1 |
---|
1671 | } |
---|
1672 | #endif |
---|
1673 | // mark the picture as "unused for reference" if it is not in |
---|
1674 | // the Reference Picture Set |
---|
1675 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0) |
---|
1676 | { |
---|
1677 | rpcPic->getSlice( 0 )->setReferenced( false ); |
---|
1678 | rpcPic->setUsedByCurr(0); |
---|
1679 | rpcPic->setIsLongTerm(0); |
---|
1680 | } |
---|
1681 | //check that pictures of higher temporal layers are not used |
---|
1682 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getTLayer()<=this->getTLayer()); |
---|
1683 | //check that pictures of higher or equal temporal layer are not in the RPS if the current picture is a TSA picture |
---|
1684 | if(this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_R || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) |
---|
1685 | { |
---|
1686 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getTLayer()<this->getTLayer()); |
---|
1687 | } |
---|
1688 | //check that pictures marked as temporal layer non-reference pictures are not used for reference |
---|
1689 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && rpcPic->getTLayer()==this->getTLayer()) |
---|
1690 | { |
---|
1691 | assert(rpcPic->getSlice( 0 )->isReferenced()==0||rpcPic->getUsedByCurr()==0||rpcPic->getSlice( 0 )->getTemporalLayerNonReferenceFlag()==false); |
---|
1692 | } |
---|
1693 | } |
---|
1694 | } |
---|
1695 | |
---|
1696 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1697 | */ |
---|
1698 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1699 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess, Bool bUseRecoveryPoint) |
---|
1700 | #else |
---|
1701 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool printErrors, Int pocRandomAccess) |
---|
1702 | #endif |
---|
1703 | { |
---|
1704 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1705 | Int atLeastOneUnabledByRecoveryPoint = 0; |
---|
1706 | Int atLeastOneFlushedByPreviousIDR = 0; |
---|
1707 | #endif |
---|
1708 | TComPic* rpcPic; |
---|
1709 | Int i, isAvailable; |
---|
1710 | Int atLeastOneLost = 0; |
---|
1711 | Int atLeastOneRemoved = 0; |
---|
1712 | Int iPocLost = 0; |
---|
1713 | |
---|
1714 | // loop through all long-term pictures in the Reference Picture Set |
---|
1715 | // to see if the picture should be kept as reference picture |
---|
1716 | for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1717 | { |
---|
1718 | isAvailable = 0; |
---|
1719 | // loop through all pictures in the reference picture buffer |
---|
1720 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1721 | while ( iterPic != rcListPic.end()) |
---|
1722 | { |
---|
1723 | rpcPic = *(iterPic++); |
---|
1724 | if(pReferencePictureSet->getCheckLTMSBPresent(i)==true) |
---|
1725 | { |
---|
1726 | if(rpcPic->getIsLongTerm() && (rpcPic->getPicSym()->getSlice(0)->getPOC()) == pReferencePictureSet->getPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1727 | { |
---|
1728 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1729 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1730 | { |
---|
1731 | isAvailable = 0; |
---|
1732 | } |
---|
1733 | else |
---|
1734 | { |
---|
1735 | isAvailable = 1; |
---|
1736 | } |
---|
1737 | #else |
---|
1738 | isAvailable = 1; |
---|
1739 | #endif |
---|
1740 | } |
---|
1741 | } |
---|
1742 | else |
---|
1743 | { |
---|
1744 | Int pocCycle = 1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1745 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC() & (pocCycle-1); |
---|
1746 | Int refPoc = pReferencePictureSet->getPOC(i) & (pocCycle-1); |
---|
1747 | if(rpcPic->getIsLongTerm() && curPoc == refPoc && rpcPic->getSlice(0)->isReferenced()) |
---|
1748 | { |
---|
1749 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1750 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1751 | { |
---|
1752 | isAvailable = 0; |
---|
1753 | } |
---|
1754 | else |
---|
1755 | { |
---|
1756 | isAvailable = 1; |
---|
1757 | } |
---|
1758 | #else |
---|
1759 | isAvailable = 1; |
---|
1760 | #endif |
---|
1761 | } |
---|
1762 | } |
---|
1763 | } |
---|
1764 | // if there was no such long-term check the short terms |
---|
1765 | if(!isAvailable) |
---|
1766 | { |
---|
1767 | iterPic = rcListPic.begin(); |
---|
1768 | while ( iterPic != rcListPic.end()) |
---|
1769 | { |
---|
1770 | rpcPic = *(iterPic++); |
---|
1771 | |
---|
1772 | Int pocCycle = 1 << rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC(); |
---|
1773 | Int curPoc = rpcPic->getPicSym()->getSlice(0)->getPOC(); |
---|
1774 | Int refPoc = pReferencePictureSet->getPOC(i); |
---|
1775 | if (!pReferencePictureSet->getCheckLTMSBPresent(i)) |
---|
1776 | { |
---|
1777 | curPoc = curPoc & (pocCycle - 1); |
---|
1778 | refPoc = refPoc & (pocCycle - 1); |
---|
1779 | } |
---|
1780 | |
---|
1781 | if (rpcPic->getSlice(0)->isReferenced() && curPoc == refPoc) |
---|
1782 | { |
---|
1783 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1784 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1785 | { |
---|
1786 | isAvailable = 0; |
---|
1787 | } |
---|
1788 | else |
---|
1789 | { |
---|
1790 | isAvailable = 1; |
---|
1791 | rpcPic->setIsLongTerm(1); |
---|
1792 | break; |
---|
1793 | } |
---|
1794 | #else |
---|
1795 | isAvailable = 1; |
---|
1796 | rpcPic->setIsLongTerm(1); |
---|
1797 | break; |
---|
1798 | #endif |
---|
1799 | } |
---|
1800 | } |
---|
1801 | } |
---|
1802 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1803 | // but not available as reference picture |
---|
1804 | if(isAvailable == 0) |
---|
1805 | { |
---|
1806 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1807 | { |
---|
1808 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1809 | { |
---|
1810 | if(printErrors) |
---|
1811 | { |
---|
1812 | printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1813 | } |
---|
1814 | atLeastOneRemoved = 1; |
---|
1815 | } |
---|
1816 | else |
---|
1817 | { |
---|
1818 | if(printErrors) |
---|
1819 | { |
---|
1820 | printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1821 | } |
---|
1822 | atLeastOneLost = 1; |
---|
1823 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1824 | } |
---|
1825 | } |
---|
1826 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1827 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1828 | { |
---|
1829 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
1830 | } |
---|
1831 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
1832 | { |
---|
1833 | atLeastOneFlushedByPreviousIDR = 1; |
---|
1834 | } |
---|
1835 | #endif |
---|
1836 | } |
---|
1837 | } |
---|
1838 | // loop through all short-term pictures in the Reference Picture Set |
---|
1839 | // to see if the picture should be kept as reference picture |
---|
1840 | for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++) |
---|
1841 | { |
---|
1842 | isAvailable = 0; |
---|
1843 | // loop through all pictures in the reference picture buffer |
---|
1844 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1845 | while ( iterPic != rcListPic.end()) |
---|
1846 | { |
---|
1847 | rpcPic = *(iterPic++); |
---|
1848 | |
---|
1849 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1850 | { |
---|
1851 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1852 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) |
---|
1853 | { |
---|
1854 | isAvailable = 0; |
---|
1855 | } |
---|
1856 | else |
---|
1857 | { |
---|
1858 | isAvailable = 1; |
---|
1859 | } |
---|
1860 | #else |
---|
1861 | isAvailable = 1; |
---|
1862 | #endif |
---|
1863 | } |
---|
1864 | } |
---|
1865 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1866 | // but not available as reference picture |
---|
1867 | if(isAvailable == 0) |
---|
1868 | { |
---|
1869 | #if !UNAVAILABLE_PIC_BUGFIX |
---|
1870 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1871 | #endif |
---|
1872 | { |
---|
1873 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1874 | { |
---|
1875 | if(printErrors) |
---|
1876 | { |
---|
1877 | printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1878 | } |
---|
1879 | atLeastOneRemoved = 1; |
---|
1880 | } |
---|
1881 | else |
---|
1882 | { |
---|
1883 | if(printErrors) |
---|
1884 | { |
---|
1885 | printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1886 | } |
---|
1887 | atLeastOneLost = 1; |
---|
1888 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1889 | } |
---|
1890 | } |
---|
1891 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1892 | #if UNAVAILABLE_PIC_BUGFIX |
---|
1893 | if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1894 | #else |
---|
1895 | else if(bUseRecoveryPoint && this->getPOC() > pocRandomAccess) |
---|
1896 | #endif |
---|
1897 | { |
---|
1898 | atLeastOneUnabledByRecoveryPoint = 1; |
---|
1899 | } |
---|
1900 | else if(bUseRecoveryPoint && (this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getAssociatedIRAPType()==NAL_UNIT_CODED_SLICE_IDR_W_RADL)) |
---|
1901 | { |
---|
1902 | atLeastOneFlushedByPreviousIDR = 1; |
---|
1903 | } |
---|
1904 | #endif |
---|
1905 | } |
---|
1906 | } |
---|
1907 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1908 | if(atLeastOneUnabledByRecoveryPoint || atLeastOneFlushedByPreviousIDR) |
---|
1909 | { |
---|
1910 | return -1; |
---|
1911 | } |
---|
1912 | #endif |
---|
1913 | if(atLeastOneLost) |
---|
1914 | { |
---|
1915 | return iPocLost+1; |
---|
1916 | } |
---|
1917 | if(atLeastOneRemoved) |
---|
1918 | { |
---|
1919 | return -2; |
---|
1920 | } |
---|
1921 | else |
---|
1922 | { |
---|
1923 | return 0; |
---|
1924 | } |
---|
1925 | } |
---|
1926 | |
---|
1927 | /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set |
---|
1928 | */ |
---|
1929 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1930 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP, Int pocRandomAccess, Bool bUseRecoveryPoint) |
---|
1931 | #else |
---|
1932 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool isRAP) |
---|
1933 | #endif |
---|
1934 | { |
---|
1935 | TComPic* rpcPic; |
---|
1936 | Int i, j; |
---|
1937 | Int k = 0; |
---|
1938 | Int nrOfNegativePictures = 0; |
---|
1939 | Int nrOfPositivePictures = 0; |
---|
1940 | TComReferencePictureSet* pcRPS = this->getLocalRPS(); |
---|
1941 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
1942 | Bool pocsAdjusted = false; |
---|
1943 | #endif |
---|
1944 | |
---|
1945 | // loop through all pictures in the Reference Picture Set |
---|
1946 | for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1947 | { |
---|
1948 | j = 0; |
---|
1949 | // loop through all pictures in the reference picture buffer |
---|
1950 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1951 | while ( iterPic != rcListPic.end()) |
---|
1952 | { |
---|
1953 | j++; |
---|
1954 | rpcPic = *(iterPic++); |
---|
1955 | |
---|
1956 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
1957 | // poc adjustement by poc reset needs to be taken into account here |
---|
1958 | Int deltaPOC = pReferencePictureSet->getDeltaPOC(i) - rpcPic->getPicSym()->getSlice(0)->getPocResetDeltaPoc(); |
---|
1959 | if (rpcPic->getPicSym()->getSlice(0)->getPocResetDeltaPoc() != 0) |
---|
1960 | { |
---|
1961 | pocsAdjusted = true; |
---|
1962 | } |
---|
1963 | |
---|
1964 | if (rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + deltaPOC && rpcPic->getSlice(0)->isReferenced()) |
---|
1965 | #else |
---|
1966 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1967 | #endif |
---|
1968 | { |
---|
1969 | // This picture exists as a reference picture |
---|
1970 | // and should be added to the explicit Reference Picture Set |
---|
1971 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
1972 | pcRPS->setDeltaPOC(k, deltaPOC); |
---|
1973 | #else |
---|
1974 | pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); |
---|
1975 | #endif |
---|
1976 | pcRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP)); |
---|
1977 | #if ALLOW_RECOVERY_POINT_AS_RAP |
---|
1978 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
1979 | pcRPS->setUsed(k, pcRPS->getUsed(k) && !(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + deltaPOC < pocRandomAccess) ); |
---|
1980 | #else |
---|
1981 | pcRPS->setUsed(k, pcRPS->getUsed(k) && !(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) ); |
---|
1982 | #endif |
---|
1983 | #endif |
---|
1984 | if(pcRPS->getDeltaPOC(k) < 0) |
---|
1985 | { |
---|
1986 | nrOfNegativePictures++; |
---|
1987 | } |
---|
1988 | else |
---|
1989 | { |
---|
1990 | nrOfPositivePictures++; |
---|
1991 | } |
---|
1992 | k++; |
---|
1993 | } |
---|
1994 | } |
---|
1995 | } |
---|
1996 | #if EFFICIENT_FIELD_IRAP |
---|
1997 | Bool useNewRPS = false; |
---|
1998 | // if current picture is complimentary field associated to IRAP, add the IRAP to its RPS. |
---|
1999 | if(m_pcPic->isField()) |
---|
2000 | { |
---|
2001 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
2002 | while ( iterPic != rcListPic.end()) |
---|
2003 | { |
---|
2004 | rpcPic = *(iterPic++); |
---|
2005 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getAssociatedIRAPPOC() && this->getAssociatedIRAPPOC() == this->getPOC()+1) |
---|
2006 | { |
---|
2007 | pcRPS->setDeltaPOC(k, 1); |
---|
2008 | pcRPS->setUsed(k, true); |
---|
2009 | nrOfPositivePictures++; |
---|
2010 | k ++; |
---|
2011 | useNewRPS = true; |
---|
2012 | } |
---|
2013 | } |
---|
2014 | } |
---|
2015 | #endif |
---|
2016 | pcRPS->setNumberOfNegativePictures(nrOfNegativePictures); |
---|
2017 | pcRPS->setNumberOfPositivePictures(nrOfPositivePictures); |
---|
2018 | pcRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures); |
---|
2019 | // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the |
---|
2020 | // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet. |
---|
2021 | // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled. |
---|
2022 | if (!pReferencePictureSet->getInterRPSPrediction() |
---|
2023 | #if EFFICIENT_FIELD_IRAP |
---|
2024 | || useNewRPS |
---|
2025 | #endif |
---|
2026 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
2027 | || pocsAdjusted // inter RPS prediction does not work if POCs have been adjusted |
---|
2028 | #endif |
---|
2029 | ) |
---|
2030 | { |
---|
2031 | pcRPS->setInterRPSPrediction(false); |
---|
2032 | pcRPS->setNumRefIdc(0); |
---|
2033 | } |
---|
2034 | else |
---|
2035 | { |
---|
2036 | Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1; |
---|
2037 | Int deltaRPS = pReferencePictureSet->getDeltaRPS(); |
---|
2038 | TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
2039 | Int iRefPics = pcRefRPS->getNumberOfPictures(); |
---|
2040 | Int iNewIdc=0; |
---|
2041 | for(i=0; i<= iRefPics; i++) |
---|
2042 | { |
---|
2043 | Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0 |
---|
2044 | Int iRefIdc = 0; |
---|
2045 | for (j=0; j < pcRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS |
---|
2046 | { |
---|
2047 | if ( (deltaPOC + deltaRPS) == pcRPS->getDeltaPOC(j)) |
---|
2048 | { |
---|
2049 | if (pcRPS->getUsed(j)) |
---|
2050 | { |
---|
2051 | iRefIdc = 1; |
---|
2052 | } |
---|
2053 | else |
---|
2054 | { |
---|
2055 | iRefIdc = 2; |
---|
2056 | } |
---|
2057 | } |
---|
2058 | } |
---|
2059 | pcRPS->setRefIdc(i, iRefIdc); |
---|
2060 | iNewIdc++; |
---|
2061 | } |
---|
2062 | pcRPS->setInterRPSPrediction(true); |
---|
2063 | pcRPS->setNumRefIdc(iNewIdc); |
---|
2064 | pcRPS->setDeltaRPS(deltaRPS); |
---|
2065 | pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
2066 | } |
---|
2067 | |
---|
2068 | this->setRPS(pcRPS); |
---|
2069 | this->setRPSidx(-1); |
---|
2070 | } |
---|
2071 | |
---|
2072 | /** get AC and DC values for weighted pred |
---|
2073 | * \param *wp |
---|
2074 | * \returns Void |
---|
2075 | */ |
---|
2076 | Void TComSlice::getWpAcDcParam(wpACDCParam *&wp) |
---|
2077 | { |
---|
2078 | wp = m_weightACDCParam; |
---|
2079 | } |
---|
2080 | |
---|
2081 | /** init AC and DC values for weighted pred |
---|
2082 | * \returns Void |
---|
2083 | */ |
---|
2084 | Void TComSlice::initWpAcDcParam() |
---|
2085 | { |
---|
2086 | for(Int iComp = 0; iComp < 3; iComp++ ) |
---|
2087 | { |
---|
2088 | m_weightACDCParam[iComp].iAC = 0; |
---|
2089 | m_weightACDCParam[iComp].iDC = 0; |
---|
2090 | } |
---|
2091 | } |
---|
2092 | |
---|
2093 | /** get WP tables for weighted pred |
---|
2094 | * \param RefPicList |
---|
2095 | * \param iRefIdx |
---|
2096 | * \param *&wpScalingParam |
---|
2097 | * \returns Void |
---|
2098 | */ |
---|
2099 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, wpScalingParam *&wp ) |
---|
2100 | { |
---|
2101 | wp = m_weightPredTable[e][iRefIdx]; |
---|
2102 | } |
---|
2103 | |
---|
2104 | /** reset Default WP tables settings : no weight. |
---|
2105 | * \param wpScalingParam |
---|
2106 | * \returns Void |
---|
2107 | */ |
---|
2108 | Void TComSlice::resetWpScaling() |
---|
2109 | { |
---|
2110 | for ( Int e=0 ; e<2 ; e++ ) |
---|
2111 | { |
---|
2112 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
2113 | { |
---|
2114 | for ( Int yuv=0 ; yuv<3 ; yuv++ ) |
---|
2115 | { |
---|
2116 | wpScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
2117 | pwp->bPresentFlag = false; |
---|
2118 | pwp->uiLog2WeightDenom = 0; |
---|
2119 | pwp->uiLog2WeightDenom = 0; |
---|
2120 | pwp->iWeight = 1; |
---|
2121 | pwp->iOffset = 0; |
---|
2122 | } |
---|
2123 | } |
---|
2124 | } |
---|
2125 | } |
---|
2126 | |
---|
2127 | /** init WP table |
---|
2128 | * \returns Void |
---|
2129 | */ |
---|
2130 | Void TComSlice::initWpScaling() |
---|
2131 | { |
---|
2132 | for ( Int e=0 ; e<2 ; e++ ) |
---|
2133 | { |
---|
2134 | for ( Int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
2135 | { |
---|
2136 | for ( Int yuv=0 ; yuv<3 ; yuv++ ) |
---|
2137 | { |
---|
2138 | wpScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); |
---|
2139 | if ( !pwp->bPresentFlag ) |
---|
2140 | { |
---|
2141 | // Inferring values not present : |
---|
2142 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
2143 | pwp->iOffset = 0; |
---|
2144 | } |
---|
2145 | |
---|
2146 | pwp->w = pwp->iWeight; |
---|
2147 | Int bitDepth = yuv ? g_bitDepthC : g_bitDepthY; |
---|
2148 | pwp->o = pwp->iOffset << (bitDepth-8); |
---|
2149 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
2150 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
2151 | } |
---|
2152 | } |
---|
2153 | } |
---|
2154 | } |
---|
2155 | |
---|
2156 | #if REPN_FORMAT_IN_VPS |
---|
2157 | UInt TComSlice::getPicWidthInLumaSamples() |
---|
2158 | { |
---|
2159 | TComSPS *sps = getSPS(); |
---|
2160 | TComVPS *vps = getVPS(); |
---|
2161 | UInt retVal, layerId = getLayerId(); |
---|
2162 | #if O0096_REP_FORMAT_INDEX |
---|
2163 | #if R0279_REP_FORMAT_INBL |
---|
2164 | if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 ) |
---|
2165 | { |
---|
2166 | #if VPS_AVC_BL_FLAG_REMOVAL |
---|
2167 | if( layerId == 0 && vps->getNonHEVCBaseLayerFlag() ) |
---|
2168 | #else |
---|
2169 | if( layerId == 0 && vps->getAvcBaseLayerFlag() ) |
---|
2170 | #endif |
---|
2171 | #else |
---|
2172 | if ( layerId == 0 ) |
---|
2173 | { |
---|
2174 | if( vps->getAvcBaseLayerFlag() ) |
---|
2175 | #endif |
---|
2176 | { |
---|
2177 | retVal = vps->getVpsRepFormat(layerId)->getPicWidthVpsInLumaSamples(); |
---|
2178 | } |
---|
2179 | else |
---|
2180 | { |
---|
2181 | retVal = sps->getPicWidthInLumaSamples(); |
---|
2182 | } |
---|
2183 | } |
---|
2184 | else |
---|
2185 | { |
---|
2186 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId) )->getPicWidthVpsInLumaSamples(); |
---|
2187 | } |
---|
2188 | #else |
---|
2189 | if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
2190 | { |
---|
2191 | retVal = sps->getPicWidthInLumaSamples(); |
---|
2192 | } |
---|
2193 | else |
---|
2194 | { |
---|
2195 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getPicWidthVpsInLumaSamples(); |
---|
2196 | } |
---|
2197 | #endif |
---|
2198 | return retVal; |
---|
2199 | } |
---|
2200 | UInt TComSlice::getPicHeightInLumaSamples() |
---|
2201 | { |
---|
2202 | TComSPS *sps = getSPS(); |
---|
2203 | TComVPS *vps = getVPS(); |
---|
2204 | UInt retVal, layerId = getLayerId(); |
---|
2205 | #if O0096_REP_FORMAT_INDEX |
---|
2206 | #if R0279_REP_FORMAT_INBL |
---|
2207 | if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 ) |
---|
2208 | { |
---|
2209 | #if VPS_AVC_BL_FLAG_REMOVAL |
---|
2210 | if( layerId == 0 && vps->getNonHEVCBaseLayerFlag() ) |
---|
2211 | #else |
---|
2212 | if( layerId == 0 && vps->getAvcBaseLayerFlag() ) |
---|
2213 | #endif |
---|
2214 | #else |
---|
2215 | if ( layerId == 0 ) |
---|
2216 | { |
---|
2217 | if( vps->getAvcBaseLayerFlag() ) |
---|
2218 | #endif |
---|
2219 | { |
---|
2220 | retVal = vps->getVpsRepFormat(layerId)->getPicHeightVpsInLumaSamples(); |
---|
2221 | } |
---|
2222 | else |
---|
2223 | { |
---|
2224 | retVal = sps->getPicHeightInLumaSamples(); |
---|
2225 | } |
---|
2226 | } |
---|
2227 | else |
---|
2228 | { |
---|
2229 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId) )->getPicHeightVpsInLumaSamples(); |
---|
2230 | } |
---|
2231 | #else |
---|
2232 | if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
2233 | { |
---|
2234 | retVal = sps->getPicHeightInLumaSamples(); |
---|
2235 | } |
---|
2236 | else |
---|
2237 | { |
---|
2238 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getPicHeightVpsInLumaSamples(); |
---|
2239 | } |
---|
2240 | #endif |
---|
2241 | return retVal; |
---|
2242 | } |
---|
2243 | #if AUXILIARY_PICTURES |
---|
2244 | ChromaFormat TComSlice::getChromaFormatIdc() |
---|
2245 | #else |
---|
2246 | UInt TComSlice::getChromaFormatIdc() |
---|
2247 | #endif |
---|
2248 | { |
---|
2249 | TComSPS *sps = getSPS(); |
---|
2250 | TComVPS *vps = getVPS(); |
---|
2251 | #if AUXILIARY_PICTURES |
---|
2252 | ChromaFormat retVal; |
---|
2253 | UInt layerId = getLayerId(); |
---|
2254 | #else |
---|
2255 | UInt retVal, layerId = getLayerId(); |
---|
2256 | #endif |
---|
2257 | #if O0096_REP_FORMAT_INDEX |
---|
2258 | #if R0279_REP_FORMAT_INBL |
---|
2259 | if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 ) |
---|
2260 | { |
---|
2261 | #if VPS_AVC_BL_FLAG_REMOVAL |
---|
2262 | if( layerId == 0 && vps->getNonHEVCBaseLayerFlag() ) |
---|
2263 | #else |
---|
2264 | if( layerId == 0 && vps->getAvcBaseLayerFlag() ) |
---|
2265 | #endif |
---|
2266 | #else |
---|
2267 | if ( layerId == 0 ) |
---|
2268 | { |
---|
2269 | if( vps->getAvcBaseLayerFlag() ) |
---|
2270 | #endif |
---|
2271 | { |
---|
2272 | retVal = vps->getVpsRepFormat(layerId)->getChromaFormatVpsIdc(); |
---|
2273 | } |
---|
2274 | else |
---|
2275 | { |
---|
2276 | retVal = sps->getChromaFormatIdc(); |
---|
2277 | } |
---|
2278 | } |
---|
2279 | else |
---|
2280 | { |
---|
2281 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId) )->getChromaFormatVpsIdc(); |
---|
2282 | } |
---|
2283 | #else |
---|
2284 | if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
2285 | { |
---|
2286 | retVal = sps->getChromaFormatIdc(); |
---|
2287 | } |
---|
2288 | else |
---|
2289 | { |
---|
2290 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getChromaFormatVpsIdc(); |
---|
2291 | } |
---|
2292 | #endif |
---|
2293 | return retVal; |
---|
2294 | } |
---|
2295 | UInt TComSlice::getBitDepthY() |
---|
2296 | { |
---|
2297 | TComSPS *sps = getSPS(); |
---|
2298 | TComVPS *vps = getVPS(); |
---|
2299 | UInt retVal, layerId = getLayerId(); |
---|
2300 | #if O0096_REP_FORMAT_INDEX |
---|
2301 | #if R0279_REP_FORMAT_INBL |
---|
2302 | if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 ) |
---|
2303 | #else |
---|
2304 | if ( layerId == 0 ) |
---|
2305 | #endif |
---|
2306 | { |
---|
2307 | retVal = sps->getBitDepthY(); |
---|
2308 | } |
---|
2309 | else |
---|
2310 | { |
---|
2311 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId) )->getBitDepthVpsLuma(); |
---|
2312 | } |
---|
2313 | #else |
---|
2314 | if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
2315 | { |
---|
2316 | retVal = sps->getBitDepthY(); |
---|
2317 | } |
---|
2318 | else |
---|
2319 | { |
---|
2320 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getBitDepthVpsLuma(); |
---|
2321 | } |
---|
2322 | #endif |
---|
2323 | return retVal; |
---|
2324 | } |
---|
2325 | UInt TComSlice::getBitDepthC() |
---|
2326 | { |
---|
2327 | TComSPS *sps = getSPS(); |
---|
2328 | TComVPS *vps = getVPS(); |
---|
2329 | UInt retVal, layerId = getLayerId(); |
---|
2330 | #if O0096_REP_FORMAT_INDEX |
---|
2331 | #if R0279_REP_FORMAT_INBL |
---|
2332 | if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 ) |
---|
2333 | #else |
---|
2334 | if ( layerId == 0 ) |
---|
2335 | #endif |
---|
2336 | { |
---|
2337 | retVal = sps->getBitDepthC(); |
---|
2338 | } |
---|
2339 | else |
---|
2340 | { |
---|
2341 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId) )->getBitDepthVpsChroma(); |
---|
2342 | } |
---|
2343 | #else |
---|
2344 | if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
2345 | { |
---|
2346 | retVal = sps->getBitDepthC(); |
---|
2347 | } |
---|
2348 | else |
---|
2349 | { |
---|
2350 | retVal = vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getBitDepthVpsChroma(); |
---|
2351 | } |
---|
2352 | #endif |
---|
2353 | return retVal; |
---|
2354 | } |
---|
2355 | Int TComSlice::getQpBDOffsetY() |
---|
2356 | { |
---|
2357 | return (getBitDepthY() - 8) * 6; |
---|
2358 | } |
---|
2359 | Int TComSlice::getQpBDOffsetC() |
---|
2360 | { |
---|
2361 | return (getBitDepthC() - 8) * 6; |
---|
2362 | } |
---|
2363 | |
---|
2364 | #if R0156_CONF_WINDOW_IN_REP_FORMAT |
---|
2365 | Window& TComSlice::getConformanceWindow() |
---|
2366 | { |
---|
2367 | TComSPS *sps = getSPS(); |
---|
2368 | TComVPS *vps = getVPS(); |
---|
2369 | UInt layerId = getLayerId(); |
---|
2370 | #if O0096_REP_FORMAT_INDEX |
---|
2371 | #if R0279_REP_FORMAT_INBL |
---|
2372 | if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 ) |
---|
2373 | { |
---|
2374 | #if VPS_AVC_BL_FLAG_REMOVAL |
---|
2375 | if( layerId == 0 && vps->getNonHEVCBaseLayerFlag() ) |
---|
2376 | #else |
---|
2377 | if( layerId == 0 && vps->getAvcBaseLayerFlag() ) |
---|
2378 | #endif |
---|
2379 | #else |
---|
2380 | if ( layerId == 0 ) |
---|
2381 | { |
---|
2382 | if( vps->getAvcBaseLayerFlag() ) |
---|
2383 | #endif |
---|
2384 | { |
---|
2385 | return vps->getVpsRepFormat(layerId)->getConformanceWindowVps(); |
---|
2386 | } |
---|
2387 | else |
---|
2388 | { |
---|
2389 | return sps->getConformanceWindow(); |
---|
2390 | } |
---|
2391 | } |
---|
2392 | else |
---|
2393 | { |
---|
2394 | return vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId) )->getConformanceWindowVps(); |
---|
2395 | } |
---|
2396 | #else |
---|
2397 | if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
2398 | { |
---|
2399 | return sps->getConformanceWindow(); |
---|
2400 | } |
---|
2401 | else |
---|
2402 | { |
---|
2403 | return vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getConformanceWindowVps(); |
---|
2404 | } |
---|
2405 | #endif |
---|
2406 | } |
---|
2407 | #endif |
---|
2408 | |
---|
2409 | RepFormat::RepFormat() |
---|
2410 | #if AUXILIARY_PICTURES |
---|
2411 | : m_chromaFormatVpsIdc (CHROMA_420) |
---|
2412 | #else |
---|
2413 | : m_chromaFormatVpsIdc (0) |
---|
2414 | #endif |
---|
2415 | , m_separateColourPlaneVpsFlag (false) |
---|
2416 | , m_picWidthVpsInLumaSamples (0) |
---|
2417 | , m_picHeightVpsInLumaSamples (0) |
---|
2418 | , m_bitDepthVpsLuma (0) |
---|
2419 | , m_bitDepthVpsChroma (0) |
---|
2420 | {} |
---|
2421 | #if RESOLUTION_BASED_DPB |
---|
2422 | Void RepFormat::init() |
---|
2423 | { |
---|
2424 | m_chromaFormatVpsIdc = CHROMA_420; |
---|
2425 | m_separateColourPlaneVpsFlag = false; |
---|
2426 | m_picWidthVpsInLumaSamples = 0; |
---|
2427 | m_picHeightVpsInLumaSamples = 0; |
---|
2428 | m_bitDepthVpsLuma = 0; |
---|
2429 | m_bitDepthVpsChroma = 0; |
---|
2430 | #if R0156_CONF_WINDOW_IN_REP_FORMAT |
---|
2431 | m_conformanceWindowVps.resetWindow(); |
---|
2432 | #endif |
---|
2433 | } |
---|
2434 | #endif |
---|
2435 | #endif |
---|
2436 | |
---|
2437 | // ------------------------------------------------------------------------------------------------ |
---|
2438 | // Video parameter set (VPS) |
---|
2439 | // ------------------------------------------------------------------------------------------------ |
---|
2440 | #if SVC_EXTENSION |
---|
2441 | TComVPS::TComVPS() |
---|
2442 | : m_VPSId ( 0) |
---|
2443 | #if VPS_RESERVED_FLAGS |
---|
2444 | , m_baseLayerInternalFlag (true) |
---|
2445 | , m_baseLayerAvailableFlag (true) |
---|
2446 | #endif |
---|
2447 | , m_uiMaxTLayers ( 1) |
---|
2448 | , m_uiMaxLayers ( 1) |
---|
2449 | , m_bTemporalIdNestingFlag (false) |
---|
2450 | , m_numHrdParameters ( 0) |
---|
2451 | , m_hrdParameters (NULL) |
---|
2452 | , m_hrdOpSetIdx (NULL) |
---|
2453 | , m_cprmsPresentFlag (NULL) |
---|
2454 | , m_maxLayerId (0) |
---|
2455 | , m_numLayerSets (0) |
---|
2456 | #if VPS_EXTN_OP_LAYER_SETS |
---|
2457 | , m_numOutputLayerSets (0) |
---|
2458 | #endif |
---|
2459 | , m_numProfileTierLevel (0) |
---|
2460 | #if !VPS_EXTN_UEV_CODING |
---|
2461 | , m_moreOutputLayerSetsThanDefaultFlag (false) |
---|
2462 | #endif |
---|
2463 | , m_numAddOutputLayerSets (0) |
---|
2464 | #if P0295_DEFAULT_OUT_LAYER_IDC |
---|
2465 | , m_defaultTargetOutputLayerIdc (0) |
---|
2466 | #else |
---|
2467 | #if O0109_DEFAULT_ONE_OUT_LAYER_IDC |
---|
2468 | , m_defaultOneTargetOutputLayerIdc (0) |
---|
2469 | #else |
---|
2470 | , m_defaultOneTargetOutputLayerFlag (false) |
---|
2471 | #endif |
---|
2472 | #endif |
---|
2473 | , m_bitRatePresentVpsFlag (false) |
---|
2474 | , m_picRatePresentVpsFlag (false) |
---|
2475 | #if REPN_FORMAT_IN_VPS |
---|
2476 | #if Q0195_REP_FORMAT_CLEANUP |
---|
2477 | , m_repFormatIdxPresentFlag (false) |
---|
2478 | #else |
---|
2479 | , m_repFormatIdxPresentFlag (true) |
---|
2480 | #endif |
---|
2481 | , m_vpsNumRepFormats (1) |
---|
2482 | #endif |
---|
2483 | #if VIEW_ID_RELATED_SIGNALING |
---|
2484 | #if O0109_VIEW_ID_LEN |
---|
2485 | , m_viewIdLen (0) |
---|
2486 | #else |
---|
2487 | , m_viewIdLenMinus1 (0) |
---|
2488 | #endif |
---|
2489 | #endif |
---|
2490 | #if !P0307_REMOVE_VPS_VUI_OFFSET |
---|
2491 | #if VPS_VUI_OFFSET |
---|
2492 | , m_vpsVuiOffset (0) |
---|
2493 | #endif |
---|
2494 | #endif |
---|
2495 | #if P0307_VPS_NON_VUI_EXTENSION |
---|
2496 | , m_vpsNonVuiExtLength (0) |
---|
2497 | #endif |
---|
2498 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
2499 | , m_vpsPocLsbAlignedFlag(false) |
---|
2500 | #endif |
---|
2501 | { |
---|
2502 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
2503 | { |
---|
2504 | m_numReorderPics[i] = 0; |
---|
2505 | m_uiMaxDecPicBuffering[i] = 1; |
---|
2506 | m_uiMaxLatencyIncrease[i] = 0; |
---|
2507 | } |
---|
2508 | #if VPS_EXTN_MASK_AND_DIM_INFO |
---|
2509 | #if VPS_AVC_BL_FLAG_REMOVAL |
---|
2510 | m_nonHEVCBaseLayerFlag = false; |
---|
2511 | #else |
---|
2512 | m_avcBaseLayerFlag = false; |
---|
2513 | #endif |
---|
2514 | m_splittingFlag = false; |
---|
2515 | ::memset(m_scalabilityMask, 0, sizeof(m_scalabilityMask)); |
---|
2516 | ::memset(m_dimensionIdLen, 0, sizeof(m_dimensionIdLen)); |
---|
2517 | m_nuhLayerIdPresentFlag = false; |
---|
2518 | ::memset(m_layerIdInNuh, 0, sizeof(m_layerIdInNuh)); |
---|
2519 | ::memset(m_dimensionId, 0, sizeof(m_dimensionId)); |
---|
2520 | |
---|
2521 | m_numScalabilityTypes = 0; |
---|
2522 | ::memset(m_layerIdInVps, 0, sizeof(m_layerIdInVps)); |
---|
2523 | #endif |
---|
2524 | #if VPS_EXTN_PROFILE_INFO |
---|
2525 | ::memset(m_profilePresentFlag, 0, sizeof(m_profilePresentFlag)); |
---|
2526 | #if !P0048_REMOVE_PROFILE_REF |
---|
2527 | ::memset(m_profileLayerSetRef, 0, sizeof(m_profileLayerSetRef)); |
---|
2528 | #endif |
---|
2529 | #endif |
---|
2530 | #if VPS_EXTN_OP_LAYER_SETS |
---|
2531 | ::memset(m_layerIdIncludedFlag, 0, sizeof(m_layerIdIncludedFlag)); |
---|
2532 | // Consider dynamic allocation for outputLayerSetIdx and outputLayerFlag |
---|
2533 | ::memset(m_outputLayerSetIdx, 0, sizeof(m_outputLayerSetIdx)); |
---|
2534 | ::memset(m_outputLayerFlag, 0, sizeof(m_outputLayerFlag)); |
---|
2535 | #endif |
---|
2536 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
2537 | ::memset(m_directDependencyFlag, 0, sizeof(m_directDependencyFlag)); |
---|
2538 | ::memset(m_numDirectRefLayers, 0, sizeof(m_numDirectRefLayers )); |
---|
2539 | ::memset(m_refLayerId, 0, sizeof(m_refLayerId )); |
---|
2540 | m_directDepTypeLen = 2; |
---|
2541 | ::memset(m_directDependencyType, 0, sizeof(m_directDependencyType)); |
---|
2542 | #endif |
---|
2543 | #if !NECESSARY_LAYER_FLAG |
---|
2544 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
2545 | ::memset(m_layerSetLayerIdList, 0, sizeof(m_layerSetLayerIdList)); |
---|
2546 | ::memset(m_numLayerInIdList, 0, sizeof(m_numLayerInIdList )); |
---|
2547 | #endif |
---|
2548 | #endif |
---|
2549 | #if !PER_LAYER_PTL |
---|
2550 | ::memset(m_profileLevelTierIdx, 0, sizeof(m_profileLevelTierIdx)); |
---|
2551 | #endif |
---|
2552 | m_maxOneActiveRefLayerFlag = true; |
---|
2553 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
---|
2554 | ::memset(m_pocLsbNotPresentFlag, 0, sizeof(m_pocLsbNotPresentFlag)); |
---|
2555 | #endif |
---|
2556 | #if O0223_PICTURE_TYPES_ALIGN_FLAG |
---|
2557 | m_crossLayerPictureTypeAlignFlag = true; |
---|
2558 | #endif |
---|
2559 | m_crossLayerIrapAlignFlag = true; |
---|
2560 | #if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG |
---|
2561 | m_crossLayerAlignedIdrOnlyFlag = false; |
---|
2562 | #endif |
---|
2563 | m_maxTidRefPresentFlag = true; |
---|
2564 | for( Int i = 0; i < MAX_VPS_LAYER_ID_PLUS1 - 1; i++) |
---|
2565 | { |
---|
2566 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
2567 | for( Int j = 0; j < MAX_VPS_LAYER_ID_PLUS1; j++) |
---|
2568 | { |
---|
2569 | m_maxTidIlRefPicsPlus1[i][j] = m_uiMaxTLayers + 1; |
---|
2570 | } |
---|
2571 | #else |
---|
2572 | m_maxTidIlRefPicsPlus1[i] = m_uiMaxTLayers + 1; |
---|
2573 | #endif |
---|
2574 | } |
---|
2575 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
2576 | m_tilesNotInUseFlag = true; |
---|
2577 | ::memset(m_tilesInUseFlag, 0, sizeof(m_tilesInUseFlag)); |
---|
2578 | ::memset(m_loopFilterNotAcrossTilesFlag, 0, sizeof(m_loopFilterNotAcrossTilesFlag)); |
---|
2579 | #endif |
---|
2580 | ::memset(m_tileBoundariesAlignedFlag, 0, sizeof(m_tileBoundariesAlignedFlag)); |
---|
2581 | #if VPS_VUI_WPP_NOT_IN_USE__FLAG |
---|
2582 | m_wppNotInUseFlag = true; |
---|
2583 | ::memset(m_wppInUseFlag, 0, sizeof(m_wppInUseFlag)); |
---|
2584 | #endif |
---|
2585 | #if N0160_VUI_EXT_ILP_REF |
---|
2586 | m_ilpRestrictedRefLayersFlag = false; |
---|
2587 | ::memset(m_minSpatialSegmentOffsetPlus1, 0, sizeof(m_minSpatialSegmentOffsetPlus1)); |
---|
2588 | ::memset(m_ctuBasedOffsetEnabledFlag, 0, sizeof(m_ctuBasedOffsetEnabledFlag)); |
---|
2589 | ::memset(m_minHorizontalCtuOffsetPlus1, 0, sizeof(m_minHorizontalCtuOffsetPlus1)); |
---|
2590 | #endif |
---|
2591 | #if VPS_VUI_VIDEO_SIGNAL |
---|
2592 | m_vidSigPresentVpsFlag=true; |
---|
2593 | m_vpsVidSigInfo=1; |
---|
2594 | ::memset( m_vpsVidSigIdx, 0, sizeof(m_vpsVidSigIdx) ); |
---|
2595 | m_vpsVidSigIdx[0]=0; |
---|
2596 | for (Int i=0; i < 16; i++) |
---|
2597 | { |
---|
2598 | m_vpsVidFormat[i] = 5; |
---|
2599 | m_vpsFullRangeFlag[i] = false; |
---|
2600 | m_vpsColorPrimaries[i] = 2; |
---|
2601 | m_vpsTransChar[i] = 2; |
---|
2602 | m_vpsMatCoeff[i] = 2; |
---|
2603 | } |
---|
2604 | #endif |
---|
2605 | ::memset(m_bitRatePresentFlag, 0, sizeof(m_bitRatePresentFlag)); |
---|
2606 | ::memset(m_picRatePresentFlag, 0, sizeof(m_picRatePresentFlag)); |
---|
2607 | ::memset(m_avgBitRate , 0, sizeof(m_avgBitRate) ); |
---|
2608 | ::memset(m_maxBitRate , 0, sizeof(m_maxBitRate) ); |
---|
2609 | ::memset(m_constPicRateIdc , 0, sizeof(m_constPicRateIdc) ); |
---|
2610 | ::memset(m_avgPicRate , 0, sizeof(m_avgPicRate) ); |
---|
2611 | #if REPN_FORMAT_IN_VPS |
---|
2612 | ::memset( m_vpsRepFormatIdx, 0, sizeof(m_vpsRepFormatIdx) ); |
---|
2613 | #endif |
---|
2614 | #if VIEW_ID_RELATED_SIGNALING |
---|
2615 | ::memset(m_viewIdVal, 0, sizeof(m_viewIdVal)); |
---|
2616 | #endif |
---|
2617 | #if O0092_0094_DEPENDENCY_CONSTRAINT |
---|
2618 | for (Int i = 0; i < MAX_NUM_LAYER_IDS; i++) |
---|
2619 | { |
---|
2620 | m_numberRefLayers[i] = 0; |
---|
2621 | for (Int j = 0; j < MAX_NUM_LAYER_IDS; j++) |
---|
2622 | { |
---|
2623 | m_recursiveRefLayerFlag[i][j] = 0; |
---|
2624 | } |
---|
2625 | } |
---|
2626 | #endif |
---|
2627 | #if VPS_DPB_SIZE_TABLE |
---|
2628 | ::memset( m_subLayerFlagInfoPresentFlag, 0, sizeof(m_subLayerFlagInfoPresentFlag ) ); |
---|
2629 | ::memset( m_subLayerDpbInfoPresentFlag, 0, sizeof(m_subLayerDpbInfoPresentFlag ) ); |
---|
2630 | ::memset( m_maxVpsDecPicBufferingMinus1, 0, sizeof(m_maxVpsDecPicBufferingMinus1 ) ); |
---|
2631 | #if RESOLUTION_BASED_DPB |
---|
2632 | ::memset( m_maxVpsLayerDecPicBuffMinus1, 0, sizeof(m_maxVpsLayerDecPicBuffMinus1 ) ); |
---|
2633 | #endif |
---|
2634 | ::memset( m_maxVpsNumReorderPics, 0, sizeof(m_maxVpsNumReorderPics ) ); |
---|
2635 | ::memset( m_maxVpsLatencyIncreasePlus1, 0, sizeof(m_maxVpsLatencyIncreasePlus1 ) ); |
---|
2636 | ::memset( m_numSubDpbs , 0, sizeof(m_numSubDpbs) ); |
---|
2637 | #endif |
---|
2638 | } |
---|
2639 | #else |
---|
2640 | TComVPS::TComVPS() |
---|
2641 | : m_VPSId ( 0) |
---|
2642 | , m_uiMaxTLayers ( 1) |
---|
2643 | , m_uiMaxLayers ( 1) |
---|
2644 | , m_bTemporalIdNestingFlag (false) |
---|
2645 | , m_numHrdParameters ( 0) |
---|
2646 | , m_maxNuhReservedZeroLayerId ( 0) |
---|
2647 | , m_hrdParameters (NULL) |
---|
2648 | , m_hrdOpSetIdx (NULL) |
---|
2649 | , m_cprmsPresentFlag (NULL) |
---|
2650 | { |
---|
2651 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
2652 | { |
---|
2653 | m_numReorderPics[i] = 0; |
---|
2654 | m_uiMaxDecPicBuffering[i] = 1; |
---|
2655 | m_uiMaxLatencyIncrease[i] = 0; |
---|
2656 | } |
---|
2657 | } |
---|
2658 | #endif //SVC_EXTENSION |
---|
2659 | |
---|
2660 | TComVPS::~TComVPS() |
---|
2661 | { |
---|
2662 | if( m_hrdParameters != NULL ) delete[] m_hrdParameters; |
---|
2663 | if( m_hrdOpSetIdx != NULL ) delete[] m_hrdOpSetIdx; |
---|
2664 | if( m_cprmsPresentFlag != NULL ) delete[] m_cprmsPresentFlag; |
---|
2665 | } |
---|
2666 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
2667 | #if NECESSARY_LAYER_FLAG |
---|
2668 | Void TComVPS::deriveLayerIdListVariables() |
---|
2669 | { |
---|
2670 | // For layer 0 |
---|
2671 | m_numLayerInIdList.push_back(1); |
---|
2672 | m_layerSetLayerIdList.resize(m_numLayerSets); |
---|
2673 | m_layerSetLayerIdList[0].push_back(0); |
---|
2674 | |
---|
2675 | // For other layers |
---|
2676 | for( Int i = 1; i < m_numLayerSets; i++ ) |
---|
2677 | { |
---|
2678 | for( Int m = 0; m <= m_maxLayerId; m++) |
---|
2679 | { |
---|
2680 | if( m_layerIdIncludedFlag[i][m] ) |
---|
2681 | { |
---|
2682 | m_layerSetLayerIdList[i].push_back(m); |
---|
2683 | } |
---|
2684 | } |
---|
2685 | m_numLayerInIdList.push_back(m_layerSetLayerIdList[i].size()); |
---|
2686 | } |
---|
2687 | } |
---|
2688 | #else |
---|
2689 | Void TComVPS::deriveLayerIdListVariables() |
---|
2690 | { |
---|
2691 | // For layer 0 |
---|
2692 | m_numLayerInIdList[0] = 1; |
---|
2693 | m_layerSetLayerIdList[0][0] = 0; |
---|
2694 | |
---|
2695 | // For other layers |
---|
2696 | Int i, m, n; |
---|
2697 | for( i = 1; i < m_numLayerSets; i++ ) |
---|
2698 | { |
---|
2699 | n = 0; |
---|
2700 | for( m = 0; m <= m_maxLayerId; m++) |
---|
2701 | { |
---|
2702 | if( m_layerIdIncludedFlag[i][m] ) |
---|
2703 | { |
---|
2704 | m_layerSetLayerIdList[i][n++] = m; |
---|
2705 | } |
---|
2706 | } |
---|
2707 | m_numLayerInIdList[i] = n; |
---|
2708 | } |
---|
2709 | } |
---|
2710 | #endif |
---|
2711 | #endif |
---|
2712 | #if !RESOLUTION_BASED_DPB |
---|
2713 | #if VPS_DPB_SIZE_TABLE |
---|
2714 | Void TComVPS::deriveNumberOfSubDpbs() |
---|
2715 | { |
---|
2716 | // Derive number of sub-DPBs |
---|
2717 | #if CHANGE_NUMSUBDPB_IDX |
---|
2718 | // For layer set 0 |
---|
2719 | setNumSubDpbs(0, 1); |
---|
2720 | // For other layer sets |
---|
2721 | for( Int i = 1; i < getNumLayerSets(); i++) |
---|
2722 | { |
---|
2723 | setNumSubDpbs( i, getNumLayersInIdList( i ) ); |
---|
2724 | } |
---|
2725 | #else |
---|
2726 | // For output layer set 0 |
---|
2727 | setNumSubDpbs(0, 1); |
---|
2728 | // For other output layer sets |
---|
2729 | for( Int i = 1; i < getNumOutputLayerSets(); i++) |
---|
2730 | { |
---|
2731 | setNumSubDpbs( i, getNumLayersInIdList( getOutputLayerSetIdx(i)) ); |
---|
2732 | } |
---|
2733 | #endif |
---|
2734 | } |
---|
2735 | #endif |
---|
2736 | #endif |
---|
2737 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
2738 | Void TComVPS::setTilesNotInUseFlag(Bool x) |
---|
2739 | { |
---|
2740 | m_tilesNotInUseFlag = x; |
---|
2741 | if (m_tilesNotInUseFlag) |
---|
2742 | { |
---|
2743 | for (int i = 0; i < getMaxLayers(); i++) |
---|
2744 | { |
---|
2745 | m_tilesInUseFlag[i] = m_loopFilterNotAcrossTilesFlag[i] = m_tilesNotInUseFlag; |
---|
2746 | } |
---|
2747 | } |
---|
2748 | |
---|
2749 | if (m_tilesNotInUseFlag) |
---|
2750 | { |
---|
2751 | for (int i = 1; i < getMaxLayers(); i++) |
---|
2752 | { |
---|
2753 | for(int j = 0; j < getNumDirectRefLayers(getLayerIdInNuh(i)); j++) |
---|
2754 | { |
---|
2755 | setTileBoundariesAlignedFlag(i, j, m_tilesNotInUseFlag); |
---|
2756 | } |
---|
2757 | } |
---|
2758 | } |
---|
2759 | } |
---|
2760 | #endif |
---|
2761 | |
---|
2762 | #if VPS_VUI_WPP_NOT_IN_USE__FLAG |
---|
2763 | Void TComVPS::setWppNotInUseFlag(Bool x) |
---|
2764 | { |
---|
2765 | m_wppNotInUseFlag = x; |
---|
2766 | if (m_wppNotInUseFlag) |
---|
2767 | { |
---|
2768 | for (int i = 0; i < getMaxLayers(); i++) |
---|
2769 | { |
---|
2770 | m_wppInUseFlag[i] = m_wppNotInUseFlag; |
---|
2771 | } |
---|
2772 | } |
---|
2773 | } |
---|
2774 | #endif |
---|
2775 | #if O0092_0094_DEPENDENCY_CONSTRAINT |
---|
2776 | Void TComVPS::setRefLayersFlags(Int currLayerId) |
---|
2777 | { |
---|
2778 | for (Int i = 0; i < m_numDirectRefLayers[currLayerId]; i++) |
---|
2779 | { |
---|
2780 | UInt refLayerId = getRefLayerId(currLayerId, i); |
---|
2781 | m_recursiveRefLayerFlag[currLayerId][refLayerId] = true; |
---|
2782 | for (Int k = 0; k < MAX_NUM_LAYER_IDS; k++) |
---|
2783 | { |
---|
2784 | m_recursiveRefLayerFlag[currLayerId][k] = m_recursiveRefLayerFlag[currLayerId][k] | m_recursiveRefLayerFlag[refLayerId][k]; |
---|
2785 | } |
---|
2786 | } |
---|
2787 | } |
---|
2788 | |
---|
2789 | Void TComVPS::setNumRefLayers() |
---|
2790 | { |
---|
2791 | memset( m_numberRefLayers, 0, sizeof( m_numberRefLayers ) ); |
---|
2792 | |
---|
2793 | for (Int i = 0; i < m_uiMaxLayers; i++) |
---|
2794 | { |
---|
2795 | UInt iNuhLId = m_layerIdInNuh[i]; |
---|
2796 | setRefLayersFlags(iNuhLId); |
---|
2797 | for (UInt j = 0; j < MAX_NUM_LAYER_IDS; j++) |
---|
2798 | { |
---|
2799 | m_numberRefLayers[iNuhLId] += (m_recursiveRefLayerFlag[iNuhLId][j] == true ? 1 : 0); |
---|
2800 | } |
---|
2801 | } |
---|
2802 | } |
---|
2803 | #endif |
---|
2804 | |
---|
2805 | #if Q0078_ADD_LAYER_SETS |
---|
2806 | Void TComVPS::setPredictedLayerIds() |
---|
2807 | { |
---|
2808 | for (UInt i = 0; i < m_uiMaxLayers - 1; i++) |
---|
2809 | { |
---|
2810 | UInt iNuhLId = m_layerIdInNuh[i]; |
---|
2811 | UInt predIdx = 0; |
---|
2812 | for (UInt j = iNuhLId + 1; j < MAX_NUM_LAYER_IDS; j++) |
---|
2813 | { |
---|
2814 | if( m_recursiveRefLayerFlag[j][iNuhLId] ) |
---|
2815 | { |
---|
2816 | m_predictedLayerId[iNuhLId][predIdx] = j; |
---|
2817 | predIdx++; |
---|
2818 | } |
---|
2819 | } |
---|
2820 | m_numPredictedLayers[iNuhLId] = predIdx; |
---|
2821 | } |
---|
2822 | m_numPredictedLayers[m_layerIdInNuh[m_uiMaxLayers-1]] = 0; |
---|
2823 | } |
---|
2824 | |
---|
2825 | Void TComVPS::setTreePartitionLayerIdList() |
---|
2826 | { |
---|
2827 | Bool countedLayerIdxFlag[MAX_NUM_LAYER_IDS]; |
---|
2828 | memset( countedLayerIdxFlag, 0, sizeof(countedLayerIdxFlag) ); |
---|
2829 | |
---|
2830 | Int numIndependentLayers = 0; |
---|
2831 | |
---|
2832 | for (UInt i = 0; i < m_uiMaxLayers; i++) |
---|
2833 | { |
---|
2834 | UInt iNuhLId = m_layerIdInNuh[i]; |
---|
2835 | if( m_numDirectRefLayers[iNuhLId] == 0 ) |
---|
2836 | { |
---|
2837 | m_treePartitionLayerIdList[numIndependentLayers][0] = iNuhLId; |
---|
2838 | m_numLayersInTreePartition[numIndependentLayers] = 1; |
---|
2839 | for( UInt j = 0; j < m_numPredictedLayers[iNuhLId]; j++ ) |
---|
2840 | { |
---|
2841 | if( !countedLayerIdxFlag[m_layerIdInVps[iNuhLId]] ) |
---|
2842 | { |
---|
2843 | m_treePartitionLayerIdList[numIndependentLayers][m_numLayersInTreePartition[numIndependentLayers]] = m_predictedLayerId[iNuhLId][j]; |
---|
2844 | m_numLayersInTreePartition[numIndependentLayers] = m_numLayersInTreePartition[numIndependentLayers] + 1; |
---|
2845 | countedLayerIdxFlag[m_layerIdInVps[m_predictedLayerId[iNuhLId][j]]] = true; |
---|
2846 | } |
---|
2847 | } |
---|
2848 | numIndependentLayers++; |
---|
2849 | } |
---|
2850 | } |
---|
2851 | |
---|
2852 | m_numIndependentLayers = numIndependentLayers; |
---|
2853 | } |
---|
2854 | |
---|
2855 | void TComVPS::setLayerIdIncludedFlagsForAddLayerSets() |
---|
2856 | { |
---|
2857 | for (UInt i = 0; i < m_numAddLayerSets; i++) |
---|
2858 | { |
---|
2859 | for (UInt j = 1; j < m_numIndependentLayers; j++) |
---|
2860 | { |
---|
2861 | Int layerNum = 0; |
---|
2862 | Int lsIdx = m_vpsNumLayerSetsMinus1 + 1 + i; |
---|
2863 | for (Int layerId = 0; layerId < MAX_VPS_LAYER_ID_PLUS1; layerId++) |
---|
2864 | { |
---|
2865 | m_layerIdIncludedFlag[lsIdx][layerId] = false; |
---|
2866 | } |
---|
2867 | for (Int treeIdx = 1; treeIdx < m_numIndependentLayers; treeIdx++) |
---|
2868 | { |
---|
2869 | for (Int layerCnt = 0; layerCnt < m_highestLayerIdxPlus1[i][j]; layerCnt++) |
---|
2870 | { |
---|
2871 | m_layerSetLayerIdList[lsIdx][layerNum] = m_treePartitionLayerIdList[treeIdx][layerCnt]; |
---|
2872 | m_layerIdIncludedFlag[lsIdx][m_treePartitionLayerIdList[treeIdx][layerCnt]] = true; |
---|
2873 | layerNum++; |
---|
2874 | } |
---|
2875 | } |
---|
2876 | m_numLayerInIdList[lsIdx] = layerNum; |
---|
2877 | } |
---|
2878 | } |
---|
2879 | } |
---|
2880 | |
---|
2881 | #endif |
---|
2882 | |
---|
2883 | #if VIEW_ID_RELATED_SIGNALING |
---|
2884 | Int TComVPS::getNumViews() |
---|
2885 | { |
---|
2886 | Int numViews = 1; |
---|
2887 | for( Int i = 0; i <= getMaxLayers() - 1; i++ ) |
---|
2888 | { |
---|
2889 | Int lId = getLayerIdInNuh( i ); |
---|
2890 | if ( i > 0 && ( getViewIndex( lId ) != getScalabilityId( i - 1, VIEW_ORDER_INDEX ) ) ) |
---|
2891 | { |
---|
2892 | numViews++; |
---|
2893 | } |
---|
2894 | } |
---|
2895 | |
---|
2896 | return numViews; |
---|
2897 | } |
---|
2898 | Int TComVPS::getScalabilityId( Int layerIdInVps, ScalabilityType scalType ) |
---|
2899 | { |
---|
2900 | return getScalabilityMask( scalType ) ? getDimensionId( layerIdInVps, scalTypeToScalIdx( scalType ) ) : 0; |
---|
2901 | } |
---|
2902 | Int TComVPS::scalTypeToScalIdx( ScalabilityType scalType ) |
---|
2903 | { |
---|
2904 | assert( scalType >= 0 && scalType <= MAX_VPS_NUM_SCALABILITY_TYPES ); |
---|
2905 | assert( scalType == MAX_VPS_NUM_SCALABILITY_TYPES || getScalabilityMask( scalType ) ); |
---|
2906 | Int scalIdx = 0; |
---|
2907 | for( Int curScalType = 0; curScalType < scalType; curScalType++ ) |
---|
2908 | { |
---|
2909 | scalIdx += ( getScalabilityMask( curScalType ) ? 1 : 0 ); |
---|
2910 | |
---|
2911 | } |
---|
2912 | |
---|
2913 | return scalIdx; |
---|
2914 | } |
---|
2915 | #endif |
---|
2916 | #if VPS_DPB_SIZE_TABLE |
---|
2917 | Void TComVPS::determineSubDpbInfoFlags() |
---|
2918 | { |
---|
2919 | for(Int i = 1; i < getNumOutputLayerSets(); i++) |
---|
2920 | { |
---|
2921 | Int layerSetIdxForOutputLayerSet = getOutputLayerSetIdx( i ); |
---|
2922 | // For each output layer set, set the DPB size for each layer and the reorder/latency value the maximum for all layers |
---|
2923 | Bool checkFlagOuter = false; // Used to calculate sub_layer_flag_info_present_flag |
---|
2924 | Bool checkFlagInner[MAX_TLAYER]; // Used to calculate sub_layer_dpb_info_present_flag |
---|
2925 | |
---|
2926 | for(Int j = 0; j < getMaxTLayers(); j++) |
---|
2927 | { |
---|
2928 | // -------------------------------------------------------- |
---|
2929 | // To determine value of m_subLayerDpbInfoPresentFlag |
---|
2930 | // -------------------------------------------------------- |
---|
2931 | if( j == 0 ) // checkFlagInner[0] is always 1 |
---|
2932 | { |
---|
2933 | checkFlagInner[j] = true; // Always signal sub-layer DPB information for the first sub-layer |
---|
2934 | } |
---|
2935 | else |
---|
2936 | { |
---|
2937 | checkFlagInner[j] = false; // Initialize to be false. If the values of the current sub-layers matches with the earlier sub-layer, |
---|
2938 | // then will be continue to be false - i.e. the j-th sub-layer DPB info is not signaled |
---|
2939 | checkFlagInner[j] |= ( getMaxVpsNumReorderPics(i, j) != getMaxVpsNumReorderPics(i, j - 1) ); |
---|
2940 | #if CHANGE_NUMSUBDPB_IDX |
---|
2941 | for(Int subDpbIdx = 0; subDpbIdx < getNumSubDpbs(layerSetIdxForOutputLayerSet) && !checkFlagInner[j]; subDpbIdx++) // If checkFlagInner[j] is true, break and signal the values |
---|
2942 | #else |
---|
2943 | for(Int k = 0; k < getNumSubDpbs(i) && !checkFlagInner[j]; k++) // If checkFlagInner[j] is true, break and signal the values |
---|
2944 | #endif |
---|
2945 | { |
---|
2946 | checkFlagInner[j] |= ( getMaxVpsDecPicBufferingMinus1(i, subDpbIdx, j - 1) != getMaxVpsDecPicBufferingMinus1(i, subDpbIdx, j) ); |
---|
2947 | } |
---|
2948 | #if RESOLUTION_BASED_DPB |
---|
2949 | for(Int layerIdx = 0; layerIdx < this->getNumLayersInIdList(layerSetIdxForOutputLayerSet) && !checkFlagInner[j]; layerIdx++) // If checkFlagInner[j] is true, break and signal the values |
---|
2950 | { |
---|
2951 | checkFlagInner[j] |= ( getMaxVpsLayerDecPicBuffMinus1(i, layerIdx, j - 1) != getMaxVpsLayerDecPicBuffMinus1(i, layerIdx, j) ); |
---|
2952 | } |
---|
2953 | #endif |
---|
2954 | } |
---|
2955 | // If checkFlagInner[j] = true, then some value needs to be signalled for the j-th sub-layer |
---|
2956 | setSubLayerDpbInfoPresentFlag( i, j, checkFlagInner[j] ); |
---|
2957 | } |
---|
2958 | |
---|
2959 | // -------------------------------------------------------- |
---|
2960 | // To determine value of m_subLayerFlagInfoPresentFlag |
---|
2961 | // -------------------------------------------------------- |
---|
2962 | |
---|
2963 | for(Int j = 1; j < getMaxTLayers(); j++) // Check if DPB info of any of non-zero sub-layers is signaled. If so set flag to one |
---|
2964 | { |
---|
2965 | if( getSubLayerDpbInfoPresentFlag(i, j) ) |
---|
2966 | { |
---|
2967 | checkFlagOuter = true; |
---|
2968 | break; |
---|
2969 | } |
---|
2970 | } |
---|
2971 | setSubLayerFlagInfoPresentFlag( i, checkFlagOuter ); |
---|
2972 | } |
---|
2973 | } |
---|
2974 | #endif |
---|
2975 | #if RESOLUTION_BASED_DPB |
---|
2976 | Void TComVPS::assignSubDpbIndices() |
---|
2977 | { |
---|
2978 | RepFormat layerRepFormat [MAX_LAYERS]; |
---|
2979 | RepFormat subDpbRepFormat [MAX_LAYERS]; |
---|
2980 | |
---|
2981 | for(Int lsIdx = 0; lsIdx < this->getNumLayerSets(); lsIdx++) |
---|
2982 | { |
---|
2983 | for(Int j = 0; j < MAX_LAYERS; j++) |
---|
2984 | { |
---|
2985 | layerRepFormat [j].init(); |
---|
2986 | subDpbRepFormat[j].init(); |
---|
2987 | } |
---|
2988 | |
---|
2989 | // Assign resolution, bit-depth, colour format for each layer in the layer set |
---|
2990 | for(Int i = 0; i < this->getNumLayersInIdList( lsIdx ); i++) |
---|
2991 | { |
---|
2992 | Int layerIdxInVps = this->getLayerIdInVps( this->getLayerSetLayerIdList(lsIdx, i) ); |
---|
2993 | Int repFormatIdx = this->getVpsRepFormatIdx( layerIdxInVps ); |
---|
2994 | RepFormat* repFormat = this->getVpsRepFormat( repFormatIdx ); |
---|
2995 | |
---|
2996 | // Assign the rep_format() to the layer |
---|
2997 | layerRepFormat[i] = *repFormat; |
---|
2998 | } |
---|
2999 | |
---|
3000 | // ---------------------------------------- |
---|
3001 | // Sub-DPB assignment |
---|
3002 | // ---------------------------------------- |
---|
3003 | // For the base layer |
---|
3004 | m_subDpbAssigned[lsIdx][0] = 0; |
---|
3005 | subDpbRepFormat[0] = layerRepFormat[0]; |
---|
3006 | |
---|
3007 | // Sub-DPB counter |
---|
3008 | Int subDpbCtr = 1; |
---|
3009 | |
---|
3010 | for(Int i = 1; i < this->getNumLayersInIdList( lsIdx ); i++) |
---|
3011 | { |
---|
3012 | Bool newSubDpbFlag = true; |
---|
3013 | for(Int j = 0; (j < subDpbCtr) && (newSubDpbFlag); j++) |
---|
3014 | { |
---|
3015 | if( RepFormat::checkSameSubDpb( layerRepFormat[i], subDpbRepFormat[j] ) ) |
---|
3016 | { |
---|
3017 | // Belong to i-th sub-DPB |
---|
3018 | m_subDpbAssigned[lsIdx][i] = j; |
---|
3019 | newSubDpbFlag = false; |
---|
3020 | } |
---|
3021 | } |
---|
3022 | if( newSubDpbFlag ) |
---|
3023 | { |
---|
3024 | // New sub-DPB |
---|
3025 | subDpbRepFormat[subDpbCtr] = layerRepFormat[i]; |
---|
3026 | m_subDpbAssigned[lsIdx][i] = subDpbCtr; |
---|
3027 | subDpbCtr++; // Increment # subDpbs |
---|
3028 | } |
---|
3029 | } |
---|
3030 | m_numSubDpbs[lsIdx] = subDpbCtr; |
---|
3031 | } |
---|
3032 | } |
---|
3033 | Int TComVPS::findLayerIdxInLayerSet ( Int lsIdx, Int nuhLayerId ) |
---|
3034 | { |
---|
3035 | for(Int i = 0; i < this->getNumLayersInIdList(lsIdx); i++) |
---|
3036 | { |
---|
3037 | if( this->getLayerSetLayerIdList( lsIdx, i) == nuhLayerId ) |
---|
3038 | { |
---|
3039 | return i; |
---|
3040 | } |
---|
3041 | } |
---|
3042 | return -1; // Layer not found |
---|
3043 | } |
---|
3044 | #endif |
---|
3045 | #if O0164_MULTI_LAYER_HRD |
---|
3046 | Void TComVPS::setBspHrdParameters( UInt hrdIdx, UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess ) |
---|
3047 | { |
---|
3048 | if( !getVpsVuiBspHrdPresentFlag() ) |
---|
3049 | { |
---|
3050 | return; |
---|
3051 | } |
---|
3052 | |
---|
3053 | TComHRD *hrd = getBspHrd(hrdIdx); |
---|
3054 | |
---|
3055 | Bool rateCnt = ( bitRate > 0 ); |
---|
3056 | hrd->setNalHrdParametersPresentFlag( rateCnt ); |
---|
3057 | hrd->setVclHrdParametersPresentFlag( rateCnt ); |
---|
3058 | |
---|
3059 | hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) ); |
---|
3060 | |
---|
3061 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
3062 | { |
---|
3063 | hrd->setTickDivisorMinus2( 100 - 2 ); // |
---|
3064 | hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
3065 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( true ); |
---|
3066 | hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay |
---|
3067 | } |
---|
3068 | else |
---|
3069 | { |
---|
3070 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); |
---|
3071 | } |
---|
3072 | |
---|
3073 | hrd->setBitRateScale( 4 ); // in units of 2~( 6 + 4 ) = 1,024 bps |
---|
3074 | hrd->setCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
3075 | hrd->setDuCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
3076 | |
---|
3077 | hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
3078 | if( randomAccess ) |
---|
3079 | { |
---|
3080 | hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
3081 | hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
3082 | } |
---|
3083 | else |
---|
3084 | { |
---|
3085 | hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
3086 | hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
3087 | } |
---|
3088 | |
---|
3089 | /* |
---|
3090 | Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. |
---|
3091 | */ |
---|
3092 | Int i, j; |
---|
3093 | UInt birateValue, cpbSizeValue; |
---|
3094 | UInt ducpbSizeValue; |
---|
3095 | UInt duBitRateValue = 0; |
---|
3096 | |
---|
3097 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
3098 | { |
---|
3099 | hrd->setFixedPicRateFlag( i, 1 ); |
---|
3100 | hrd->setPicDurationInTcMinus1( i, 0 ); |
---|
3101 | hrd->setLowDelayHrdFlag( i, 0 ); |
---|
3102 | hrd->setCpbCntMinus1( i, 0 ); |
---|
3103 | |
---|
3104 | birateValue = bitRate; |
---|
3105 | cpbSizeValue = bitRate; // 1 second |
---|
3106 | ducpbSizeValue = bitRate/numDU; |
---|
3107 | duBitRateValue = bitRate; |
---|
3108 | for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
3109 | { |
---|
3110 | hrd->setBitRateValueMinus1( i, j, 0, ( birateValue - 1 ) ); |
---|
3111 | hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
3112 | hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) ); |
---|
3113 | hrd->setCbrFlag( i, j, 0, ( j == 0 ) ); |
---|
3114 | |
---|
3115 | hrd->setBitRateValueMinus1( i, j, 1, ( birateValue - 1) ); |
---|
3116 | hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
3117 | hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) ); |
---|
3118 | hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); |
---|
3119 | hrd->setCbrFlag( i, j, 1, ( j == 0 ) ); |
---|
3120 | } |
---|
3121 | } |
---|
3122 | } |
---|
3123 | #endif |
---|
3124 | #if NECESSARY_LAYER_FLAG |
---|
3125 | Void TComVPS::deriveNecessaryLayerFlag() |
---|
3126 | { |
---|
3127 | m_necessaryLayerFlag.empty(); |
---|
3128 | m_numNecessaryLayers.empty(); |
---|
3129 | // Assumed that output layer sets and variables RecursiveRefLayer are already derived |
---|
3130 | for( Int olsIdx = 0; olsIdx < getNumOutputLayerSets(); olsIdx++) |
---|
3131 | { |
---|
3132 | deriveNecessaryLayerFlag(olsIdx); |
---|
3133 | } |
---|
3134 | } |
---|
3135 | Void TComVPS::deriveNecessaryLayerFlag(Int const olsIdx) |
---|
3136 | { |
---|
3137 | Int lsIdx = this->getOutputLayerSetIdx( olsIdx ); |
---|
3138 | Int numLayersInLs = this->getNumLayersInIdList( lsIdx ); |
---|
3139 | assert( m_necessaryLayerFlag.size() == olsIdx ); // Function should be called in the correct order. |
---|
3140 | m_necessaryLayerFlag.push_back( std::vector<Bool>( numLayersInLs, false ) ); // Initialize to false |
---|
3141 | for( Int lsLayerIdx = 0; lsLayerIdx < numLayersInLs; lsLayerIdx++ ) |
---|
3142 | { |
---|
3143 | if( this->m_outputLayerFlag[olsIdx][lsLayerIdx] ) |
---|
3144 | { |
---|
3145 | m_necessaryLayerFlag[olsIdx][lsLayerIdx] = true; |
---|
3146 | Int currNuhLayerId = this->m_layerSetLayerIdList[lsIdx][lsLayerIdx]; |
---|
3147 | for( Int rLsLayerIdx = 0; rLsLayerIdx < lsLayerIdx; rLsLayerIdx++ ) |
---|
3148 | { |
---|
3149 | Int refNuhLayerId = this->m_layerSetLayerIdList[lsIdx][rLsLayerIdx]; |
---|
3150 | if( this->m_recursiveRefLayerFlag[currNuhLayerId][refNuhLayerId] ) |
---|
3151 | { |
---|
3152 | m_necessaryLayerFlag[olsIdx][rLsLayerIdx] = true; |
---|
3153 | } |
---|
3154 | } |
---|
3155 | } |
---|
3156 | } |
---|
3157 | m_numNecessaryLayers.push_back(std::accumulate(m_necessaryLayerFlag[olsIdx].begin(), m_necessaryLayerFlag[olsIdx].end(), 0)); |
---|
3158 | } |
---|
3159 | Void TComVPS::checkNecessaryLayerFlagCondition() |
---|
3160 | { |
---|
3161 | /* It is a requirement of bitstream conformance that for each layer index layerIdx in the range of |
---|
3162 | ( vps_base_layer_internal_flag ? 0 : 1 ) to MaxLayersMinus1, inclusive, there shall be at least one OLS with index olsIdx such that |
---|
3163 | NecessaryLayerFlag[ olsIdx ][ lsLayerIdx ] is equal to 1 for the value of lsLayerIdx |
---|
3164 | for which LayerSetLayerIdList[ OlsIdxToLsIdx[ olsIdx ] ][ lsLayerIdx ] is equal to layer_id_in_nuh[ layerIdx ]. */ |
---|
3165 | for(Int layerIdx = this->getBaseLayerInternalFlag() ? 0 : 1; layerIdx < this->getMaxLayers(); layerIdx++) |
---|
3166 | { |
---|
3167 | Bool layerFoundNecessaryLayerFlag = false; |
---|
3168 | for(Int olsIdx = 0; olsIdx < this->getNumOutputLayerSets(); olsIdx++) |
---|
3169 | { |
---|
3170 | Int lsIdx = this->getOutputLayerSetIdx( olsIdx ); |
---|
3171 | Int currNuhLayerId = this->getLayerIdInNuh( layerIdx ); |
---|
3172 | std::vector<Int>::iterator iter = std::find( m_layerSetLayerIdList[lsIdx].begin(), m_layerSetLayerIdList[lsIdx].end(), currNuhLayerId ); |
---|
3173 | if( iter != m_layerSetLayerIdList[lsIdx].end() ) // Layer present in layer set |
---|
3174 | { |
---|
3175 | size_t positionLayer = iter - m_layerSetLayerIdList[lsIdx].begin(); |
---|
3176 | if( *(m_necessaryLayerFlag[olsIdx].begin() + positionLayer) == true ) |
---|
3177 | { |
---|
3178 | layerFoundNecessaryLayerFlag = true; |
---|
3179 | break; |
---|
3180 | } |
---|
3181 | } |
---|
3182 | } |
---|
3183 | assert( layerFoundNecessaryLayerFlag ); |
---|
3184 | } |
---|
3185 | } |
---|
3186 | #endif |
---|
3187 | #if PER_LAYER_PTL |
---|
3188 | Int TComVPS::calculateLenOfSyntaxElement( Int const numVal ) |
---|
3189 | { |
---|
3190 | Int numBits = 1; |
---|
3191 | while((1 << numBits) < numVal) |
---|
3192 | { |
---|
3193 | numBits++; |
---|
3194 | } |
---|
3195 | return numBits; |
---|
3196 | } |
---|
3197 | #endif |
---|
3198 | #if SUB_LAYERS_IN_LAYER_SET |
---|
3199 | Void TComVPS::calculateMaxSLInLayerSets() |
---|
3200 | { |
---|
3201 | for(Int lsIdx = 0; lsIdx < getNumLayerSets(); lsIdx++) |
---|
3202 | { |
---|
3203 | UInt maxSLMinus1 = 0; |
---|
3204 | for(Int k = 0; k < getNumLayersInIdList(lsIdx); k++ ) { |
---|
3205 | Int lId = getLayerSetLayerIdList(lsIdx, k); |
---|
3206 | maxSLMinus1 = std::max(maxSLMinus1, getMaxTSLayersMinus1(getLayerIdInVps(lId))); |
---|
3207 | } |
---|
3208 | setMaxSLayersInLayerSetMinus1(lsIdx,maxSLMinus1); |
---|
3209 | } |
---|
3210 | } |
---|
3211 | #endif |
---|
3212 | |
---|
3213 | #if RESOLUTION_BASED_DPB |
---|
3214 | // RepFormat Assignment operator |
---|
3215 | RepFormat& RepFormat::operator= (const RepFormat &other) |
---|
3216 | { |
---|
3217 | if( this != &other) |
---|
3218 | { |
---|
3219 | m_chromaAndBitDepthVpsPresentFlag = other.m_chromaAndBitDepthVpsPresentFlag; |
---|
3220 | m_chromaFormatVpsIdc = other.m_chromaFormatVpsIdc; |
---|
3221 | m_separateColourPlaneVpsFlag = other.m_separateColourPlaneVpsFlag; |
---|
3222 | m_picWidthVpsInLumaSamples = other.m_picWidthVpsInLumaSamples; |
---|
3223 | m_picHeightVpsInLumaSamples = other.m_picHeightVpsInLumaSamples; |
---|
3224 | m_bitDepthVpsLuma = other.m_bitDepthVpsLuma; |
---|
3225 | m_bitDepthVpsChroma = other.m_bitDepthVpsChroma; |
---|
3226 | #if R0156_CONF_WINDOW_IN_REP_FORMAT |
---|
3227 | m_conformanceWindowVps = other.m_conformanceWindowVps; |
---|
3228 | #endif |
---|
3229 | } |
---|
3230 | return *this; |
---|
3231 | } |
---|
3232 | |
---|
3233 | // Check whether x and y share the same resolution, chroma format and bit-depth. |
---|
3234 | Bool RepFormat::checkSameSubDpb(const RepFormat &x, const RepFormat &y) |
---|
3235 | { |
---|
3236 | return ( (x.m_chromaFormatVpsIdc == y.m_chromaFormatVpsIdc) |
---|
3237 | && (x.m_picWidthVpsInLumaSamples == y.m_picWidthVpsInLumaSamples) |
---|
3238 | && (x.m_picHeightVpsInLumaSamples == y.m_picHeightVpsInLumaSamples) |
---|
3239 | && (x.m_bitDepthVpsLuma == y.m_bitDepthVpsLuma) |
---|
3240 | && (x.m_bitDepthVpsChroma == y.m_bitDepthVpsChroma) |
---|
3241 | ); |
---|
3242 | } |
---|
3243 | #endif |
---|
3244 | // ------------------------------------------------------------------------------------------------ |
---|
3245 | // Sequence parameter set (SPS) |
---|
3246 | // ------------------------------------------------------------------------------------------------ |
---|
3247 | |
---|
3248 | TComSPS::TComSPS() |
---|
3249 | : m_SPSId ( 0) |
---|
3250 | , m_VPSId ( 0) |
---|
3251 | , m_chromaFormatIdc (CHROMA_420) |
---|
3252 | , m_uiMaxTLayers ( 1) |
---|
3253 | #if R0279_REP_FORMAT_INBL |
---|
3254 | , m_bV1CompatibleSPSFlag ( 0) |
---|
3255 | #endif |
---|
3256 | // Structure |
---|
3257 | , m_picWidthInLumaSamples (352) |
---|
3258 | , m_picHeightInLumaSamples (288) |
---|
3259 | , m_log2MinCodingBlockSize ( 0) |
---|
3260 | , m_log2DiffMaxMinCodingBlockSize (0) |
---|
3261 | , m_uiMaxCUWidth ( 32) |
---|
3262 | , m_uiMaxCUHeight ( 32) |
---|
3263 | , m_uiMaxCUDepth ( 3) |
---|
3264 | , m_bLongTermRefsPresent (false) |
---|
3265 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
3266 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
3267 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
3268 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
3269 | // Tool list |
---|
3270 | , m_usePCM (false) |
---|
3271 | , m_pcmLog2MaxSize ( 5) |
---|
3272 | , m_uiPCMLog2MinSize ( 7) |
---|
3273 | , m_bitDepthY ( 8) |
---|
3274 | , m_bitDepthC ( 8) |
---|
3275 | , m_qpBDOffsetY ( 0) |
---|
3276 | , m_qpBDOffsetC ( 0) |
---|
3277 | , m_uiPCMBitDepthLuma ( 8) |
---|
3278 | , m_uiPCMBitDepthChroma ( 8) |
---|
3279 | , m_bPCMFilterDisableFlag (false) |
---|
3280 | , m_uiBitsForPOC ( 8) |
---|
3281 | , m_numLongTermRefPicSPS ( 0) |
---|
3282 | , m_uiMaxTrSize ( 32) |
---|
3283 | , m_bUseSAO (false) |
---|
3284 | , m_bTemporalIdNestingFlag (false) |
---|
3285 | , m_scalingListEnabledFlag (false) |
---|
3286 | , m_useStrongIntraSmoothing (false) |
---|
3287 | , m_vuiParametersPresentFlag (false) |
---|
3288 | , m_vuiParameters () |
---|
3289 | #if SVC_EXTENSION |
---|
3290 | , m_layerId ( 0 ) |
---|
3291 | , m_extensionFlag ( false ) |
---|
3292 | #if !MOVE_SCALED_OFFSET_TO_PPS |
---|
3293 | , m_numScaledRefLayerOffsets ( 0 ) |
---|
3294 | #endif |
---|
3295 | #if REPN_FORMAT_IN_VPS |
---|
3296 | , m_updateRepFormatFlag (false) |
---|
3297 | #if O0096_REP_FORMAT_INDEX |
---|
3298 | , m_updateRepFormatIndex (0) |
---|
3299 | #endif |
---|
3300 | #endif |
---|
3301 | #if SCALINGLIST_INFERRING |
---|
3302 | , m_inferScalingListFlag ( false ) |
---|
3303 | , m_scalingListRefLayerId ( 0 ) |
---|
3304 | #endif |
---|
3305 | #endif //SVC_EXTENSION |
---|
3306 | { |
---|
3307 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
3308 | { |
---|
3309 | m_uiMaxLatencyIncrease[i] = 0; |
---|
3310 | m_uiMaxDecPicBuffering[i] = 1; |
---|
3311 | m_numReorderPics[i] = 0; |
---|
3312 | } |
---|
3313 | m_scalingList = new TComScalingList; |
---|
3314 | ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps)); |
---|
3315 | ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag)); |
---|
3316 | |
---|
3317 | #if !MOVE_SCALED_OFFSET_TO_PPS |
---|
3318 | #if P0312_VERT_PHASE_ADJ |
---|
3319 | ::memset(m_vertPhasePositionEnableFlag, 0, sizeof(m_vertPhasePositionEnableFlag)); |
---|
3320 | #endif |
---|
3321 | #endif |
---|
3322 | } |
---|
3323 | |
---|
3324 | TComSPS::~TComSPS() |
---|
3325 | { |
---|
3326 | #if SCALINGLIST_INFERRING |
---|
3327 | if( !m_inferScalingListFlag ) |
---|
3328 | #endif |
---|
3329 | delete m_scalingList; |
---|
3330 | m_RPSList.destroy(); |
---|
3331 | } |
---|
3332 | |
---|
3333 | Void TComSPS::createRPSList( Int numRPS ) |
---|
3334 | { |
---|
3335 | m_RPSList.destroy(); |
---|
3336 | m_RPSList.create(numRPS); |
---|
3337 | } |
---|
3338 | |
---|
3339 | Void TComSPS::setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess ) |
---|
3340 | { |
---|
3341 | if( !getVuiParametersPresentFlag() ) |
---|
3342 | { |
---|
3343 | return; |
---|
3344 | } |
---|
3345 | |
---|
3346 | TComVUI *vui = getVuiParameters(); |
---|
3347 | TComHRD *hrd = vui->getHrdParameters(); |
---|
3348 | |
---|
3349 | TimingInfo *timingInfo = vui->getTimingInfo(); |
---|
3350 | #if SVC_EXTENSION |
---|
3351 | if( m_layerId > 0 ) |
---|
3352 | { |
---|
3353 | timingInfo->setTimingInfoPresentFlag( false ); |
---|
3354 | return; |
---|
3355 | } |
---|
3356 | #endif |
---|
3357 | |
---|
3358 | timingInfo->setTimingInfoPresentFlag( true ); |
---|
3359 | switch( frameRate ) |
---|
3360 | { |
---|
3361 | case 24: |
---|
3362 | timingInfo->setNumUnitsInTick( 1125000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
3363 | break; |
---|
3364 | case 25: |
---|
3365 | timingInfo->setNumUnitsInTick( 1080000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
3366 | break; |
---|
3367 | case 30: |
---|
3368 | timingInfo->setNumUnitsInTick( 900900 ); timingInfo->setTimeScale ( 27000000 ); |
---|
3369 | break; |
---|
3370 | case 50: |
---|
3371 | timingInfo->setNumUnitsInTick( 540000 ); timingInfo->setTimeScale ( 27000000 ); |
---|
3372 | break; |
---|
3373 | case 60: |
---|
3374 | timingInfo->setNumUnitsInTick( 450450 ); timingInfo->setTimeScale ( 27000000 ); |
---|
3375 | break; |
---|
3376 | default: |
---|
3377 | timingInfo->setNumUnitsInTick( 1001 ); timingInfo->setTimeScale ( 60000 ); |
---|
3378 | break; |
---|
3379 | } |
---|
3380 | |
---|
3381 | Bool rateCnt = ( bitRate > 0 ); |
---|
3382 | hrd->setNalHrdParametersPresentFlag( rateCnt ); |
---|
3383 | hrd->setVclHrdParametersPresentFlag( rateCnt ); |
---|
3384 | |
---|
3385 | hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) ); |
---|
3386 | |
---|
3387 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
3388 | { |
---|
3389 | hrd->setTickDivisorMinus2( 100 - 2 ); // |
---|
3390 | hrd->setDuCpbRemovalDelayLengthMinus1( 7 ); // 8-bit precision ( plus 1 for last DU in AU ) |
---|
3391 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( true ); |
---|
3392 | hrd->setDpbOutputDelayDuLengthMinus1( 5 + 7 ); // With sub-clock tick factor of 100, at least 7 bits to have the same value as AU dpb delay |
---|
3393 | } |
---|
3394 | else |
---|
3395 | { |
---|
3396 | hrd->setSubPicCpbParamsInPicTimingSEIFlag( false ); |
---|
3397 | } |
---|
3398 | |
---|
3399 | hrd->setBitRateScale( 4 ); // in units of 2~( 6 + 4 ) = 1,024 bps |
---|
3400 | hrd->setCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
3401 | hrd->setDuCpbSizeScale( 6 ); // in units of 2~( 4 + 4 ) = 1,024 bit |
---|
3402 | |
---|
3403 | hrd->setInitialCpbRemovalDelayLengthMinus1(15); // assuming 0.5 sec, log2( 90,000 * 0.5 ) = 16-bit |
---|
3404 | if( randomAccess ) |
---|
3405 | { |
---|
3406 | hrd->setCpbRemovalDelayLengthMinus1(5); // 32 = 2^5 (plus 1) |
---|
3407 | hrd->setDpbOutputDelayLengthMinus1 (5); // 32 + 3 = 2^6 |
---|
3408 | } |
---|
3409 | else |
---|
3410 | { |
---|
3411 | hrd->setCpbRemovalDelayLengthMinus1(9); // max. 2^10 |
---|
3412 | hrd->setDpbOutputDelayLengthMinus1 (9); // max. 2^10 |
---|
3413 | } |
---|
3414 | |
---|
3415 | /* |
---|
3416 | Note: only the case of "vps_max_temporal_layers_minus1 = 0" is supported. |
---|
3417 | */ |
---|
3418 | Int i, j; |
---|
3419 | UInt birateValue, cpbSizeValue; |
---|
3420 | UInt ducpbSizeValue; |
---|
3421 | UInt duBitRateValue = 0; |
---|
3422 | |
---|
3423 | for( i = 0; i < MAX_TLAYER; i ++ ) |
---|
3424 | { |
---|
3425 | hrd->setFixedPicRateFlag( i, 1 ); |
---|
3426 | hrd->setPicDurationInTcMinus1( i, 0 ); |
---|
3427 | hrd->setLowDelayHrdFlag( i, 0 ); |
---|
3428 | hrd->setCpbCntMinus1( i, 0 ); |
---|
3429 | |
---|
3430 | birateValue = bitRate; |
---|
3431 | cpbSizeValue = bitRate; // 1 second |
---|
3432 | ducpbSizeValue = bitRate/numDU; |
---|
3433 | duBitRateValue = bitRate; |
---|
3434 | for( j = 0; j < ( hrd->getCpbCntMinus1( i ) + 1 ); j ++ ) |
---|
3435 | { |
---|
3436 | hrd->setBitRateValueMinus1( i, j, 0, ( birateValue - 1 ) ); |
---|
3437 | hrd->setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); |
---|
3438 | hrd->setDuCpbSizeValueMinus1( i, j, 0, ( ducpbSizeValue - 1 ) ); |
---|
3439 | hrd->setCbrFlag( i, j, 0, ( j == 0 ) ); |
---|
3440 | |
---|
3441 | hrd->setBitRateValueMinus1( i, j, 1, ( birateValue - 1) ); |
---|
3442 | hrd->setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); |
---|
3443 | hrd->setDuCpbSizeValueMinus1( i, j, 1, ( ducpbSizeValue - 1 ) ); |
---|
3444 | hrd->setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); |
---|
3445 | hrd->setCbrFlag( i, j, 1, ( j == 0 ) ); |
---|
3446 | } |
---|
3447 | } |
---|
3448 | } |
---|
3449 | const Int TComSPS::m_winUnitX[]={1,2,2,1}; |
---|
3450 | const Int TComSPS::m_winUnitY[]={1,2,1,1}; |
---|
3451 | |
---|
3452 | #if !MOVE_SCALED_OFFSET_TO_PPS |
---|
3453 | #if O0098_SCALED_REF_LAYER_ID |
---|
3454 | Window& TComSPS::getScaledRefLayerWindowForLayer(Int layerId) |
---|
3455 | { |
---|
3456 | static Window win; |
---|
3457 | |
---|
3458 | for (Int i = 0; i < m_numScaledRefLayerOffsets; i++) |
---|
3459 | { |
---|
3460 | if (layerId == m_scaledRefLayerId[i]) |
---|
3461 | { |
---|
3462 | return m_scaledRefLayerWindow[i]; |
---|
3463 | } |
---|
3464 | } |
---|
3465 | |
---|
3466 | win.resetWindow(); // scaled reference layer offsets are inferred to be zero when not present |
---|
3467 | return win; |
---|
3468 | } |
---|
3469 | #endif |
---|
3470 | #if REF_REGION_OFFSET |
---|
3471 | Window& TComSPS::getRefLayerWindowForLayer(Int layerId) |
---|
3472 | { |
---|
3473 | static Window win; |
---|
3474 | |
---|
3475 | for (Int i = 0; i < m_numRefLayerOffsets; i++) |
---|
3476 | { |
---|
3477 | if (layerId == m_refLayerId[i]) |
---|
3478 | { |
---|
3479 | return m_refLayerWindow[i]; |
---|
3480 | } |
---|
3481 | } |
---|
3482 | |
---|
3483 | win.resetWindow(); // reference region offsets are inferred to be zero when not present |
---|
3484 | return win; |
---|
3485 | } |
---|
3486 | #endif |
---|
3487 | #endif |
---|
3488 | |
---|
3489 | TComPPS::TComPPS() |
---|
3490 | : m_PPSId (0) |
---|
3491 | , m_SPSId (0) |
---|
3492 | , m_picInitQPMinus26 (0) |
---|
3493 | , m_useDQP (false) |
---|
3494 | , m_bConstrainedIntraPred (false) |
---|
3495 | , m_bSliceChromaQpFlag (false) |
---|
3496 | , m_pcSPS (NULL) |
---|
3497 | , m_uiMaxCuDQPDepth (0) |
---|
3498 | , m_uiMinCuDQPSize (0) |
---|
3499 | , m_chromaCbQpOffset (0) |
---|
3500 | , m_chromaCrQpOffset (0) |
---|
3501 | , m_numRefIdxL0DefaultActive (1) |
---|
3502 | , m_numRefIdxL1DefaultActive (1) |
---|
3503 | , m_TransquantBypassEnableFlag (false) |
---|
3504 | , m_useTransformSkip (false) |
---|
3505 | , m_dependentSliceSegmentsEnabledFlag (false) |
---|
3506 | , m_tilesEnabledFlag (false) |
---|
3507 | , m_entropyCodingSyncEnabledFlag (false) |
---|
3508 | , m_loopFilterAcrossTilesEnabledFlag (true) |
---|
3509 | , m_uniformSpacingFlag (false) |
---|
3510 | , m_numTileColumnsMinus1 (0) |
---|
3511 | , m_numTileRowsMinus1 (0) |
---|
3512 | , m_numSubstreams (1) |
---|
3513 | , m_signHideFlag(0) |
---|
3514 | , m_cabacInitPresentFlag (false) |
---|
3515 | , m_encCABACTableIdx (I_SLICE) |
---|
3516 | , m_sliceHeaderExtensionPresentFlag (false) |
---|
3517 | , m_loopFilterAcrossSlicesEnabledFlag (false) |
---|
3518 | , m_listsModificationPresentFlag( 0) |
---|
3519 | , m_numExtraSliceHeaderBits(0) |
---|
3520 | #if SVC_EXTENSION |
---|
3521 | , m_extensionFlag(false) |
---|
3522 | #if SCALINGLIST_INFERRING |
---|
3523 | , m_layerId(0) |
---|
3524 | , m_inferScalingListFlag ( false ) |
---|
3525 | , m_scalingListRefLayerId ( 0 ) |
---|
3526 | #endif |
---|
3527 | #if POC_RESET_IDC |
---|
3528 | , m_pocResetInfoPresentFlag (false) |
---|
3529 | #endif |
---|
3530 | #if MOVE_SCALED_OFFSET_TO_PPS |
---|
3531 | , m_numScaledRefLayerOffsets ( 0 ) |
---|
3532 | #endif |
---|
3533 | #if Q0048_CGS_3D_ASYMLUT |
---|
3534 | , m_nCGSFlag(0) |
---|
3535 | , m_nCGSOutputBitDepthY(0) |
---|
3536 | , m_nCGSOutputBitDepthC(0) |
---|
3537 | #endif |
---|
3538 | #endif //SVC_EXTENSION |
---|
3539 | { |
---|
3540 | m_scalingList = new TComScalingList; |
---|
3541 | #if REF_REGION_OFFSET |
---|
3542 | ::memset(m_scaledRefLayerOffsetPresentFlag, 0, sizeof(m_scaledRefLayerOffsetPresentFlag)); |
---|
3543 | ::memset(m_refRegionOffsetPresentFlag, 0, sizeof(m_refRegionOffsetPresentFlag)); |
---|
3544 | #endif |
---|
3545 | #if R0209_GENERIC_PHASE |
---|
3546 | ::memset(m_resamplePhaseSetPresentFlag, 0, sizeof(m_resamplePhaseSetPresentFlag)); |
---|
3547 | ::memset(m_phaseHorLuma, 0, sizeof(m_phaseHorLuma)); |
---|
3548 | ::memset(m_phaseVerLuma, 0, sizeof(m_phaseVerLuma)); |
---|
3549 | ::memset(m_phaseHorChroma, 0, sizeof(m_phaseHorChroma)); |
---|
3550 | ::memset(m_phaseVerChroma, 0, sizeof(m_phaseVerChroma)); |
---|
3551 | #endif |
---|
3552 | } |
---|
3553 | |
---|
3554 | TComPPS::~TComPPS() |
---|
3555 | { |
---|
3556 | #if SCALINGLIST_INFERRING |
---|
3557 | if( !m_inferScalingListFlag ) |
---|
3558 | #endif |
---|
3559 | delete m_scalingList; |
---|
3560 | } |
---|
3561 | |
---|
3562 | #if MOVE_SCALED_OFFSET_TO_PPS |
---|
3563 | #if O0098_SCALED_REF_LAYER_ID |
---|
3564 | Window& TComPPS::getScaledRefLayerWindowForLayer(Int layerId) |
---|
3565 | { |
---|
3566 | static Window win; |
---|
3567 | |
---|
3568 | for (Int i = 0; i < m_numScaledRefLayerOffsets; i++) |
---|
3569 | { |
---|
3570 | if (layerId == m_scaledRefLayerId[i]) |
---|
3571 | { |
---|
3572 | return m_scaledRefLayerWindow[i]; |
---|
3573 | } |
---|
3574 | } |
---|
3575 | |
---|
3576 | win.resetWindow(); // scaled reference layer offsets are inferred to be zero when not present |
---|
3577 | return win; |
---|
3578 | } |
---|
3579 | #endif |
---|
3580 | #if REF_REGION_OFFSET |
---|
3581 | Window& TComPPS::getRefLayerWindowForLayer(Int layerId) |
---|
3582 | { |
---|
3583 | static Window win; |
---|
3584 | |
---|
3585 | for (Int i = 0; i < m_numScaledRefLayerOffsets; i++) |
---|
3586 | { |
---|
3587 | if (layerId == m_scaledRefLayerId[i]) |
---|
3588 | { |
---|
3589 | return m_refLayerWindow[i]; |
---|
3590 | } |
---|
3591 | } |
---|
3592 | |
---|
3593 | win.resetWindow(); // reference region offsets are inferred to be zero when not present |
---|
3594 | return win; |
---|
3595 | } |
---|
3596 | #endif |
---|
3597 | |
---|
3598 | #if RESAMPLING_FIX |
---|
3599 | #if R0209_GENERIC_PHASE |
---|
3600 | Bool TComPPS::hasZeroResamplingPhase(Int refLayerIdc) |
---|
3601 | { |
---|
3602 | Int phaseHorLuma = this->getPhaseHorLuma(refLayerIdc); |
---|
3603 | Int phaseVerLuma = this->getPhaseVerLuma(refLayerIdc); |
---|
3604 | Int phaseHorChroma = this->getPhaseHorChroma(refLayerIdc); |
---|
3605 | Int phaseVerChroma = this->getPhaseVerChroma(refLayerIdc); |
---|
3606 | return ( phaseHorLuma == 0 && phaseHorChroma == 0 && phaseVerLuma == 0 && phaseVerChroma == 0); |
---|
3607 | } |
---|
3608 | #endif |
---|
3609 | #endif |
---|
3610 | |
---|
3611 | #endif |
---|
3612 | |
---|
3613 | TComReferencePictureSet::TComReferencePictureSet() |
---|
3614 | : m_numberOfPictures (0) |
---|
3615 | , m_numberOfNegativePictures (0) |
---|
3616 | , m_numberOfPositivePictures (0) |
---|
3617 | , m_numberOfLongtermPictures (0) |
---|
3618 | , m_interRPSPrediction (0) |
---|
3619 | , m_deltaRIdxMinus1 (0) |
---|
3620 | , m_deltaRPS (0) |
---|
3621 | , m_numRefIdc (0) |
---|
3622 | { |
---|
3623 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
3624 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
3625 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
3626 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
3627 | } |
---|
3628 | |
---|
3629 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
3630 | { |
---|
3631 | } |
---|
3632 | |
---|
3633 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
3634 | { |
---|
3635 | m_used[bufferNum] = used; |
---|
3636 | } |
---|
3637 | |
---|
3638 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
3639 | { |
---|
3640 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
3641 | } |
---|
3642 | |
---|
3643 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
3644 | { |
---|
3645 | m_numberOfPictures = numberOfPictures; |
---|
3646 | } |
---|
3647 | |
---|
3648 | Int TComReferencePictureSet::getUsed(Int bufferNum) |
---|
3649 | { |
---|
3650 | return m_used[bufferNum]; |
---|
3651 | } |
---|
3652 | |
---|
3653 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) |
---|
3654 | { |
---|
3655 | return m_deltaPOC[bufferNum]; |
---|
3656 | } |
---|
3657 | |
---|
3658 | Int TComReferencePictureSet::getNumberOfPictures() |
---|
3659 | { |
---|
3660 | return m_numberOfPictures; |
---|
3661 | } |
---|
3662 | |
---|
3663 | Int TComReferencePictureSet::getPOC(Int bufferNum) |
---|
3664 | { |
---|
3665 | return m_POC[bufferNum]; |
---|
3666 | } |
---|
3667 | |
---|
3668 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
3669 | { |
---|
3670 | m_POC[bufferNum] = POC; |
---|
3671 | } |
---|
3672 | |
---|
3673 | Bool TComReferencePictureSet::getCheckLTMSBPresent(Int bufferNum) |
---|
3674 | { |
---|
3675 | return m_bCheckLTMSB[bufferNum]; |
---|
3676 | } |
---|
3677 | |
---|
3678 | Void TComReferencePictureSet::setCheckLTMSBPresent(Int bufferNum, Bool b) |
---|
3679 | { |
---|
3680 | m_bCheckLTMSB[bufferNum] = b; |
---|
3681 | } |
---|
3682 | |
---|
3683 | /** set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
3684 | * \param uiBufferNum |
---|
3685 | * \param iRefIdc |
---|
3686 | * \returns Void |
---|
3687 | */ |
---|
3688 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
3689 | { |
---|
3690 | m_refIdc[bufferNum] = refIdc; |
---|
3691 | } |
---|
3692 | |
---|
3693 | /** get the reference idc value at uiBufferNum |
---|
3694 | * \param uiBufferNum |
---|
3695 | * \returns Int |
---|
3696 | */ |
---|
3697 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) |
---|
3698 | { |
---|
3699 | return m_refIdc[bufferNum]; |
---|
3700 | } |
---|
3701 | |
---|
3702 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
3703 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
3704 | * +ve values are in increasing order. |
---|
3705 | * \returns Void |
---|
3706 | */ |
---|
3707 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
3708 | { |
---|
3709 | // sort in increasing order (smallest first) |
---|
3710 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
3711 | { |
---|
3712 | Int deltaPOC = getDeltaPOC(j); |
---|
3713 | Bool used = getUsed(j); |
---|
3714 | for (Int k=j-1; k >= 0; k--) |
---|
3715 | { |
---|
3716 | Int temp = getDeltaPOC(k); |
---|
3717 | if (deltaPOC < temp) |
---|
3718 | { |
---|
3719 | setDeltaPOC(k+1, temp); |
---|
3720 | setUsed(k+1, getUsed(k)); |
---|
3721 | setDeltaPOC(k, deltaPOC); |
---|
3722 | setUsed(k, used); |
---|
3723 | } |
---|
3724 | } |
---|
3725 | } |
---|
3726 | // flip the negative values to largest first |
---|
3727 | Int numNegPics = getNumberOfNegativePictures(); |
---|
3728 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
3729 | { |
---|
3730 | Int deltaPOC = getDeltaPOC(j); |
---|
3731 | Bool used = getUsed(j); |
---|
3732 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
3733 | setUsed(j, getUsed(k)); |
---|
3734 | setDeltaPOC(k, deltaPOC); |
---|
3735 | setUsed(k, used); |
---|
3736 | } |
---|
3737 | } |
---|
3738 | |
---|
3739 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
3740 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
3741 | * \returns Void |
---|
3742 | */ |
---|
3743 | Void TComReferencePictureSet::printDeltaPOC() |
---|
3744 | { |
---|
3745 | printf("DeltaPOC = { "); |
---|
3746 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
3747 | { |
---|
3748 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
3749 | } |
---|
3750 | if (getInterRPSPrediction()) |
---|
3751 | { |
---|
3752 | printf("}, RefIdc = { "); |
---|
3753 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
3754 | { |
---|
3755 | printf("%d ", getRefIdc(j)); |
---|
3756 | } |
---|
3757 | } |
---|
3758 | printf("}\n"); |
---|
3759 | } |
---|
3760 | |
---|
3761 | TComRPSList::TComRPSList() |
---|
3762 | :m_referencePictureSets (NULL) |
---|
3763 | { |
---|
3764 | } |
---|
3765 | |
---|
3766 | TComRPSList::~TComRPSList() |
---|
3767 | { |
---|
3768 | } |
---|
3769 | |
---|
3770 | Void TComRPSList::create( Int numberOfReferencePictureSets) |
---|
3771 | { |
---|
3772 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
3773 | m_referencePictureSets = new TComReferencePictureSet[numberOfReferencePictureSets]; |
---|
3774 | } |
---|
3775 | |
---|
3776 | Void TComRPSList::destroy() |
---|
3777 | { |
---|
3778 | if (m_referencePictureSets) |
---|
3779 | { |
---|
3780 | delete [] m_referencePictureSets; |
---|
3781 | } |
---|
3782 | m_numberOfReferencePictureSets = 0; |
---|
3783 | m_referencePictureSets = NULL; |
---|
3784 | } |
---|
3785 | |
---|
3786 | |
---|
3787 | |
---|
3788 | TComReferencePictureSet* TComRPSList::getReferencePictureSet(Int referencePictureSetNum) |
---|
3789 | { |
---|
3790 | return &m_referencePictureSets[referencePictureSetNum]; |
---|
3791 | } |
---|
3792 | |
---|
3793 | Int TComRPSList::getNumberOfReferencePictureSets() |
---|
3794 | { |
---|
3795 | return m_numberOfReferencePictureSets; |
---|
3796 | } |
---|
3797 | |
---|
3798 | Void TComRPSList::setNumberOfReferencePictureSets(Int numberOfReferencePictureSets) |
---|
3799 | { |
---|
3800 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
3801 | } |
---|
3802 | |
---|
3803 | TComRefPicListModification::TComRefPicListModification() |
---|
3804 | : m_bRefPicListModificationFlagL0 (false) |
---|
3805 | , m_bRefPicListModificationFlagL1 (false) |
---|
3806 | { |
---|
3807 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
3808 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
3809 | } |
---|
3810 | |
---|
3811 | TComRefPicListModification::~TComRefPicListModification() |
---|
3812 | { |
---|
3813 | } |
---|
3814 | |
---|
3815 | TComScalingList::TComScalingList() |
---|
3816 | { |
---|
3817 | init(); |
---|
3818 | } |
---|
3819 | |
---|
3820 | TComScalingList::~TComScalingList() |
---|
3821 | { |
---|
3822 | destroy(); |
---|
3823 | } |
---|
3824 | |
---|
3825 | /** set default quantization matrix to array |
---|
3826 | */ |
---|
3827 | Void TComSlice::setDefaultScalingList() |
---|
3828 | { |
---|
3829 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3830 | { |
---|
3831 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
3832 | { |
---|
3833 | getScalingList()->processDefaultMatrix(sizeId, listId); |
---|
3834 | } |
---|
3835 | } |
---|
3836 | } |
---|
3837 | /** check if use default quantization matrix |
---|
3838 | * \returns true if use default quantization matrix in all size |
---|
3839 | */ |
---|
3840 | Bool TComSlice::checkDefaultScalingList() |
---|
3841 | { |
---|
3842 | UInt defaultCounter=0; |
---|
3843 | |
---|
3844 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3845 | { |
---|
3846 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
3847 | { |
---|
3848 | if( !memcmp(getScalingList()->getScalingListAddress(sizeId,listId), getScalingList()->getScalingListDefaultAddress(sizeId, listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix |
---|
3849 | && ((sizeId < SCALING_LIST_16x16) || (getScalingList()->getScalingListDC(sizeId,listId) == 16))) // check DC value |
---|
3850 | { |
---|
3851 | defaultCounter++; |
---|
3852 | } |
---|
3853 | } |
---|
3854 | } |
---|
3855 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? false : true; // -4 for 32x32 |
---|
3856 | } |
---|
3857 | |
---|
3858 | /** get scaling matrix from RefMatrixID |
---|
3859 | * \param sizeId size index |
---|
3860 | * \param Index of input matrix |
---|
3861 | * \param Index of reference matrix |
---|
3862 | */ |
---|
3863 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
3864 | { |
---|
3865 | ::memcpy(getScalingListAddress(sizeId, listId),((listId == refListId)? getScalingListDefaultAddress(sizeId, refListId): getScalingListAddress(sizeId, refListId)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
3866 | } |
---|
3867 | |
---|
3868 | /** parse syntax infomation |
---|
3869 | * \param pchFile syntax infomation |
---|
3870 | * \returns false if successful |
---|
3871 | */ |
---|
3872 | Bool TComScalingList::xParseScalingList(Char* pchFile) |
---|
3873 | { |
---|
3874 | FILE *fp; |
---|
3875 | Char line[1024]; |
---|
3876 | UInt sizeIdc,listIdc; |
---|
3877 | UInt i,size = 0; |
---|
3878 | Int *src=0,data; |
---|
3879 | Char *ret; |
---|
3880 | UInt retval; |
---|
3881 | |
---|
3882 | if((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
3883 | { |
---|
3884 | printf("can't open file %s :: set Default Matrix\n",pchFile); |
---|
3885 | return true; |
---|
3886 | } |
---|
3887 | |
---|
3888 | for(sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
3889 | { |
---|
3890 | size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
3891 | for(listIdc = 0; listIdc < g_scalingListNum[sizeIdc]; listIdc++) |
---|
3892 | { |
---|
3893 | src = getScalingListAddress(sizeIdc, listIdc); |
---|
3894 | |
---|
3895 | fseek(fp,0,0); |
---|
3896 | do |
---|
3897 | { |
---|
3898 | ret = fgets(line, 1024, fp); |
---|
3899 | if ((ret==NULL)||(strstr(line, MatrixType[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
3900 | { |
---|
3901 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
3902 | return true; |
---|
3903 | } |
---|
3904 | } |
---|
3905 | while (strstr(line, MatrixType[sizeIdc][listIdc]) == NULL); |
---|
3906 | for (i=0; i<size; i++) |
---|
3907 | { |
---|
3908 | retval = fscanf(fp, "%d,", &data); |
---|
3909 | if (retval!=1) |
---|
3910 | { |
---|
3911 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
3912 | return true; |
---|
3913 | } |
---|
3914 | src[i] = data; |
---|
3915 | } |
---|
3916 | //set DC value for default matrix check |
---|
3917 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
3918 | |
---|
3919 | if(sizeIdc > SCALING_LIST_8x8) |
---|
3920 | { |
---|
3921 | fseek(fp,0,0); |
---|
3922 | do |
---|
3923 | { |
---|
3924 | ret = fgets(line, 1024, fp); |
---|
3925 | if ((ret==NULL)||(strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
3926 | { |
---|
3927 | printf("Error: can't read DC :: set Default Matrix\n"); |
---|
3928 | return true; |
---|
3929 | } |
---|
3930 | } |
---|
3931 | while (strstr(line, MatrixType_DC[sizeIdc][listIdc]) == NULL); |
---|
3932 | retval = fscanf(fp, "%d,", &data); |
---|
3933 | if (retval!=1) |
---|
3934 | { |
---|
3935 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
3936 | return true; |
---|
3937 | } |
---|
3938 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
3939 | setScalingListDC(sizeIdc,listIdc,data); |
---|
3940 | } |
---|
3941 | } |
---|
3942 | } |
---|
3943 | fclose(fp); |
---|
3944 | return false; |
---|
3945 | } |
---|
3946 | |
---|
3947 | /** initialization process of quantization matrix array |
---|
3948 | */ |
---|
3949 | Void TComScalingList::init() |
---|
3950 | { |
---|
3951 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3952 | { |
---|
3953 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
3954 | { |
---|
3955 | m_scalingListCoef[sizeId][listId] = new Int [min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])]; |
---|
3956 | } |
---|
3957 | } |
---|
3958 | m_scalingListCoef[SCALING_LIST_32x32][3] = m_scalingListCoef[SCALING_LIST_32x32][1]; // copy address for 32x32 |
---|
3959 | } |
---|
3960 | |
---|
3961 | /** destroy quantization matrix array |
---|
3962 | */ |
---|
3963 | Void TComScalingList::destroy() |
---|
3964 | { |
---|
3965 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3966 | { |
---|
3967 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
3968 | { |
---|
3969 | if(m_scalingListCoef[sizeId][listId]) delete [] m_scalingListCoef[sizeId][listId]; |
---|
3970 | } |
---|
3971 | } |
---|
3972 | } |
---|
3973 | |
---|
3974 | /** get default address of quantization matrix |
---|
3975 | * \param sizeId size index |
---|
3976 | * \param listId list index |
---|
3977 | * \returns pointer of quantization matrix |
---|
3978 | */ |
---|
3979 | Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
3980 | { |
---|
3981 | Int *src = 0; |
---|
3982 | switch(sizeId) |
---|
3983 | { |
---|
3984 | case SCALING_LIST_4x4: |
---|
3985 | src = g_quantTSDefault4x4; |
---|
3986 | break; |
---|
3987 | case SCALING_LIST_8x8: |
---|
3988 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
3989 | break; |
---|
3990 | case SCALING_LIST_16x16: |
---|
3991 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
3992 | break; |
---|
3993 | case SCALING_LIST_32x32: |
---|
3994 | src = (listId<1) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
3995 | break; |
---|
3996 | default: |
---|
3997 | assert(0); |
---|
3998 | src = NULL; |
---|
3999 | break; |
---|
4000 | } |
---|
4001 | return src; |
---|
4002 | } |
---|
4003 | |
---|
4004 | /** process of default matrix |
---|
4005 | * \param sizeId size index |
---|
4006 | * \param Index of input matrix |
---|
4007 | */ |
---|
4008 | Void TComScalingList::processDefaultMatrix(UInt sizeId, UInt listId) |
---|
4009 | { |
---|
4010 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
4011 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
4012 | } |
---|
4013 | |
---|
4014 | /** check DC value of matrix for default matrix signaling |
---|
4015 | */ |
---|
4016 | Void TComScalingList::checkDcOfMatrix() |
---|
4017 | { |
---|
4018 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
4019 | { |
---|
4020 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
4021 | { |
---|
4022 | //check default matrix? |
---|
4023 | if(getScalingListDC(sizeId,listId) == 0) |
---|
4024 | { |
---|
4025 | processDefaultMatrix(sizeId, listId); |
---|
4026 | } |
---|
4027 | } |
---|
4028 | } |
---|
4029 | } |
---|
4030 | |
---|
4031 | ParameterSetManager::ParameterSetManager() |
---|
4032 | #if SVC_EXTENSION |
---|
4033 | : m_activeSPSId(-1) |
---|
4034 | , m_activePPSId(-1) |
---|
4035 | #else |
---|
4036 | : m_vpsMap(MAX_NUM_VPS) |
---|
4037 | , m_spsMap(MAX_NUM_SPS) |
---|
4038 | , m_ppsMap(MAX_NUM_PPS) |
---|
4039 | , m_activeVPSId(-1) |
---|
4040 | , m_activeSPSId(-1) |
---|
4041 | , m_activePPSId(-1) |
---|
4042 | #endif |
---|
4043 | { |
---|
4044 | } |
---|
4045 | |
---|
4046 | |
---|
4047 | ParameterSetManager::~ParameterSetManager() |
---|
4048 | { |
---|
4049 | } |
---|
4050 | |
---|
4051 | //! activate a SPS from a active parameter sets SEI message |
---|
4052 | //! \returns true, if activation is successful |
---|
4053 | Bool ParameterSetManager::activateSPSWithSEI(Int spsId) |
---|
4054 | { |
---|
4055 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
4056 | if (sps) |
---|
4057 | { |
---|
4058 | Int vpsId = sps->getVPSId(); |
---|
4059 | if (m_vpsMap.getPS(vpsId)) |
---|
4060 | { |
---|
4061 | m_activeVPSId = vpsId; |
---|
4062 | m_activeSPSId = spsId; |
---|
4063 | return true; |
---|
4064 | } |
---|
4065 | else |
---|
4066 | { |
---|
4067 | printf("Warning: tried to activate SPS using an Active parameter sets SEI message. Referenced VPS does not exist."); |
---|
4068 | } |
---|
4069 | } |
---|
4070 | else |
---|
4071 | { |
---|
4072 | printf("Warning: tried to activate non-existing SPS using an Active parameter sets SEI message."); |
---|
4073 | } |
---|
4074 | return false; |
---|
4075 | } |
---|
4076 | |
---|
4077 | //! activate a PPS and depending on isIDR parameter also SPS and VPS |
---|
4078 | //! \returns true, if activation is successful |
---|
4079 | Bool ParameterSetManager::activatePPS(Int ppsId, Bool isIRAP) |
---|
4080 | { |
---|
4081 | TComPPS *pps = m_ppsMap.getPS(ppsId); |
---|
4082 | if (pps) |
---|
4083 | { |
---|
4084 | Int spsId = pps->getSPSId(); |
---|
4085 | if (!isIRAP && (spsId != m_activeSPSId)) |
---|
4086 | { |
---|
4087 | printf("Warning: tried to activate PPS referring to a inactive SPS at non-IRAP."); |
---|
4088 | return false; |
---|
4089 | } |
---|
4090 | TComSPS *sps = m_spsMap.getPS(spsId); |
---|
4091 | if (sps) |
---|
4092 | { |
---|
4093 | Int vpsId = sps->getVPSId(); |
---|
4094 | if (!isIRAP && (vpsId != m_activeVPSId)) |
---|
4095 | { |
---|
4096 | printf("Warning: tried to activate PPS referring to a inactive VPS at non-IRAP."); |
---|
4097 | return false; |
---|
4098 | } |
---|
4099 | if (m_vpsMap.getPS(vpsId)) |
---|
4100 | { |
---|
4101 | m_activePPSId = ppsId; |
---|
4102 | m_activeVPSId = vpsId; |
---|
4103 | m_activeSPSId = spsId; |
---|
4104 | |
---|
4105 | return true; |
---|
4106 | } |
---|
4107 | else |
---|
4108 | { |
---|
4109 | printf("Warning: tried to activate PPS that refers to a non-existing VPS."); |
---|
4110 | } |
---|
4111 | } |
---|
4112 | else |
---|
4113 | { |
---|
4114 | printf("Warning: tried to activate a PPS that refers to a non-existing SPS."); |
---|
4115 | } |
---|
4116 | } |
---|
4117 | else |
---|
4118 | { |
---|
4119 | printf("Warning: tried to activate non-existing PPS."); |
---|
4120 | } |
---|
4121 | return false; |
---|
4122 | } |
---|
4123 | |
---|
4124 | ProfileTierLevel::ProfileTierLevel() |
---|
4125 | : m_profileSpace (0) |
---|
4126 | , m_tierFlag (false) |
---|
4127 | , m_profileIdc (0) |
---|
4128 | , m_levelIdc (0) |
---|
4129 | , m_progressiveSourceFlag (false) |
---|
4130 | , m_interlacedSourceFlag (false) |
---|
4131 | , m_nonPackedConstraintFlag(false) |
---|
4132 | , m_frameOnlyConstraintFlag(false) |
---|
4133 | { |
---|
4134 | ::memset(m_profileCompatibilityFlag, 0, sizeof(m_profileCompatibilityFlag)); |
---|
4135 | } |
---|
4136 | #if VPS_EXTN_PROFILE_INFO |
---|
4137 | Void ProfileTierLevel::copyProfileInfo(ProfileTierLevel *ptl) |
---|
4138 | { |
---|
4139 | this->setProfileSpace ( ptl->getProfileSpace() ); |
---|
4140 | this->setTierFlag ( ptl->getTierFlag() ); |
---|
4141 | this->setProfileIdc ( ptl->getProfileIdc() ); |
---|
4142 | for(Int j = 0; j < 32; j++) |
---|
4143 | { |
---|
4144 | this->setProfileCompatibilityFlag(j, ptl->getProfileCompatibilityFlag(j)); |
---|
4145 | } |
---|
4146 | this->setProgressiveSourceFlag ( ptl->getProgressiveSourceFlag() ); |
---|
4147 | this->setInterlacedSourceFlag ( ptl->getInterlacedSourceFlag() ); |
---|
4148 | this->setNonPackedConstraintFlag( ptl->getNonPackedConstraintFlag()); |
---|
4149 | this->setFrameOnlyConstraintFlag( ptl->getFrameOnlyConstraintFlag()); |
---|
4150 | } |
---|
4151 | #endif |
---|
4152 | |
---|
4153 | TComPTL::TComPTL() |
---|
4154 | { |
---|
4155 | ::memset(m_subLayerProfilePresentFlag, 0, sizeof(m_subLayerProfilePresentFlag)); |
---|
4156 | ::memset(m_subLayerLevelPresentFlag, 0, sizeof(m_subLayerLevelPresentFlag )); |
---|
4157 | } |
---|
4158 | #if VPS_EXTN_PROFILE_INFO |
---|
4159 | Void TComPTL::copyProfileInfo(TComPTL *ptl) |
---|
4160 | { |
---|
4161 | // Copy all information related to general profile |
---|
4162 | this->getGeneralPTL()->copyProfileInfo(ptl->getGeneralPTL()); |
---|
4163 | } |
---|
4164 | #endif |
---|
4165 | |
---|
4166 | #if SVC_EXTENSION |
---|
4167 | Bool TComSlice::setBaseColPic( TComList<TComPic*>& rcListPic, UInt refLayerIdc ) |
---|
4168 | { |
---|
4169 | if(m_layerId == 0) |
---|
4170 | { |
---|
4171 | memset( m_pcBaseColPic, 0, sizeof( m_pcBaseColPic ) ); |
---|
4172 | return false; |
---|
4173 | } |
---|
4174 | #if POC_RESET_FLAG || POC_RESET_IDC_DECODER |
---|
4175 | #if POC_RESET_IDC_DECODER |
---|
4176 | TComPic* pic = xGetRefPic( rcListPic, getPOC() ); |
---|
4177 | #else |
---|
4178 | TComPic* pic = xGetRefPic( rcListPic, m_bPocResetFlag ? 0 : m_iPOC ); |
---|
4179 | #endif |
---|
4180 | |
---|
4181 | if( pic ) |
---|
4182 | { |
---|
4183 | setBaseColPic(refLayerIdc, pic ); |
---|
4184 | } |
---|
4185 | else |
---|
4186 | { |
---|
4187 | return false; |
---|
4188 | } |
---|
4189 | |
---|
4190 | return true; |
---|
4191 | #else |
---|
4192 | setBaseColPic(refLayerIdc, xGetRefPic(rcListPic, getPOC())); |
---|
4193 | return true; |
---|
4194 | #endif |
---|
4195 | } |
---|
4196 | |
---|
4197 | #if MFM_ENCCONSTRAINT |
---|
4198 | TComPic* TComSlice::getBaseColPic( TComList<TComPic*>& rcListPic ) |
---|
4199 | { |
---|
4200 | #if POC_RESET_FLAG |
---|
4201 | return xGetRefPic( rcListPic, m_bPocResetFlag ? 0 : m_iPOC ); |
---|
4202 | #else |
---|
4203 | return xGetRefPic( rcListPic, m_iPOC ); |
---|
4204 | #endif |
---|
4205 | } |
---|
4206 | #endif |
---|
4207 | |
---|
4208 | Void TComSlice::setILRPic(TComPic **pcIlpPic) |
---|
4209 | { |
---|
4210 | for( Int i = 0; i < m_activeNumILRRefIdx; i++ ) |
---|
4211 | { |
---|
4212 | Int refLayerIdc = m_interLayerPredLayerIdc[i]; |
---|
4213 | |
---|
4214 | if( pcIlpPic[refLayerIdc] ) |
---|
4215 | { |
---|
4216 | TComPic* pcRefPicBL = m_pcBaseColPic[refLayerIdc]; |
---|
4217 | |
---|
4218 | // copy scalability ratio, it is needed to get the correct location for the motion field of the corresponding reference layer block |
---|
4219 | pcIlpPic[refLayerIdc]->setSpatialEnhLayerFlag( refLayerIdc, m_pcPic->isSpatialEnhLayer(refLayerIdc) ); |
---|
4220 | |
---|
4221 | pcIlpPic[refLayerIdc]->copyUpsampledPictureYuv( m_pcPic->getFullPelBaseRec( refLayerIdc ), pcIlpPic[refLayerIdc]->getPicYuvRec() ); |
---|
4222 | pcIlpPic[refLayerIdc]->getSlice(0)->setBaseColPic( refLayerIdc, pcRefPicBL ); |
---|
4223 | |
---|
4224 | //set reference picture POC of each ILP reference |
---|
4225 | pcIlpPic[refLayerIdc]->getSlice(0)->setPOC( m_iPOC ); |
---|
4226 | |
---|
4227 | //set temporal Id |
---|
4228 | pcIlpPic[refLayerIdc]->getSlice(0)->setTLayer( m_uiTLayer ); |
---|
4229 | |
---|
4230 | //copy layer id from the reference layer |
---|
4231 | pcIlpPic[refLayerIdc]->setLayerId( pcRefPicBL->getLayerId() ); |
---|
4232 | |
---|
4233 | pcIlpPic[refLayerIdc]->getPicYuvRec()->setBorderExtension( false ); |
---|
4234 | pcIlpPic[refLayerIdc]->getPicYuvRec()->extendPicBorder(); |
---|
4235 | for (Int j=0; j<pcIlpPic[refLayerIdc]->getPicSym()->getNumberOfCUsInFrame(); j++) // set reference CU layerId |
---|
4236 | { |
---|
4237 | pcIlpPic[refLayerIdc]->getPicSym()->getCU(j)->setLayerId( pcIlpPic[refLayerIdc]->getLayerId() ); |
---|
4238 | } |
---|
4239 | pcIlpPic[refLayerIdc]->setIsLongTerm(1); |
---|
4240 | |
---|
4241 | #if REF_IDX_MFM |
---|
4242 | if( m_bMFMEnabledFlag && !(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) ) |
---|
4243 | { |
---|
4244 | //set reference picture POC of each ILP reference |
---|
4245 | assert( pcIlpPic[refLayerIdc]->getPOC() == pcRefPicBL->getPOC() ); |
---|
4246 | |
---|
4247 | //copy slice type from the reference layer |
---|
4248 | pcIlpPic[refLayerIdc]->getSlice(0)->setSliceType( pcRefPicBL->getSlice(0)->getSliceType() ); |
---|
4249 | |
---|
4250 | //copy "used for reference" |
---|
4251 | pcIlpPic[refLayerIdc]->getSlice(0)->setReferenced( pcRefPicBL->getSlice(0)->isReferenced() ); |
---|
4252 | |
---|
4253 | for( Int refList = 0; refList < 2; refList++ ) |
---|
4254 | { |
---|
4255 | RefPicList refPicList = RefPicList( refList ); |
---|
4256 | |
---|
4257 | //set reference POC of ILP |
---|
4258 | pcIlpPic[refLayerIdc]->getSlice(0)->setNumRefIdx(refPicList, pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList)); |
---|
4259 | assert(pcIlpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) >= 0); |
---|
4260 | assert(pcIlpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) <= MAX_NUM_REF); |
---|
4261 | |
---|
4262 | //initialize reference POC of ILP |
---|
4263 | for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx++) |
---|
4264 | { |
---|
4265 | pcIlpPic[refLayerIdc]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(refPicList, refIdx), refPicList, refIdx); |
---|
4266 | pcIlpPic[refLayerIdc]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(refPicList, refIdx), refPicList, refIdx); |
---|
4267 | } |
---|
4268 | |
---|
4269 | for(Int refIdx = pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx < MAX_NUM_REF; refIdx++) |
---|
4270 | { |
---|
4271 | pcIlpPic[refLayerIdc]->getSlice(0)->setRefPOC(0, refPicList, refIdx); |
---|
4272 | pcIlpPic[refLayerIdc]->getSlice(0)->setRefPic(NULL, refPicList, refIdx); |
---|
4273 | } |
---|
4274 | |
---|
4275 | //copy reference pictures' marking from the reference layer |
---|
4276 | for(Int j = 0; j < MAX_NUM_REF + 1; j++) |
---|
4277 | { |
---|
4278 | pcIlpPic[refLayerIdc]->getSlice(0)->setIsUsedAsLongTerm(refList, j, pcRefPicBL->getSlice(0)->getIsUsedAsLongTerm(refList, j)); |
---|
4279 | } |
---|
4280 | } |
---|
4281 | |
---|
4282 | pcIlpPic[refLayerIdc]->copyUpsampledMvField( refLayerIdc, m_pcBaseColPic[refLayerIdc] ); |
---|
4283 | } |
---|
4284 | else |
---|
4285 | { |
---|
4286 | pcIlpPic[refLayerIdc]->initUpsampledMvField(); |
---|
4287 | } |
---|
4288 | #endif |
---|
4289 | |
---|
4290 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
4291 | Int maxTidIlRefPicsPlus1 = m_pcVPS->getMaxTidIlRefPicsPlus1( pcIlpPic[refLayerIdc]->getSlice(0)->getLayerId(), m_layerId ); |
---|
4292 | #else |
---|
4293 | Int maxTidIlRefPicsPlus1 = m_pcVPS->getMaxTidIlRefPicsPlus1( pcIlpPic[refLayerIdc]->getSlice(0)->getLayerId() ); |
---|
4294 | #endif |
---|
4295 | assert( (Int)pcIlpPic[refLayerIdc]->getSlice(0)->getTLayer() < maxTidIlRefPicsPlus1 || ( !maxTidIlRefPicsPlus1 && pcIlpPic[refLayerIdc]->getSlice(0)->getRapPicFlag() ) ); |
---|
4296 | |
---|
4297 | } |
---|
4298 | } |
---|
4299 | } |
---|
4300 | |
---|
4301 | Int TComSlice::getReferenceLayerIdc( UInt refLayerId ) |
---|
4302 | { |
---|
4303 | for( Int i = 0; i < m_activeNumILRRefIdx; i++ ) |
---|
4304 | { |
---|
4305 | if( m_pcVPS->getRefLayerId(m_layerId, m_interLayerPredLayerIdc[i]) == refLayerId ) |
---|
4306 | { |
---|
4307 | return m_interLayerPredLayerIdc[i]; |
---|
4308 | } |
---|
4309 | } |
---|
4310 | |
---|
4311 | return -1; |
---|
4312 | } |
---|
4313 | #endif //SVC_EXTENSION |
---|
4314 | |
---|
4315 | //! \} |
---|