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