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