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