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