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