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