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