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