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