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