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