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