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