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-2012, 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 | |
---|
42 | //! \ingroup TLibCommon |
---|
43 | //! \{ |
---|
44 | |
---|
45 | TComSlice::TComSlice() |
---|
46 | : m_iPPSId ( -1 ) |
---|
47 | , m_iPOC ( 0 ) |
---|
48 | , m_iLastIDR ( 0 ) |
---|
49 | , m_eNalUnitType ( NAL_UNIT_CODED_SLICE_IDR ) |
---|
50 | , m_eNalUnitTypeBaseViewMvc ( NAL_UNIT_INVALID ) |
---|
51 | , m_eSliceType ( I_SLICE ) |
---|
52 | , m_iSliceQp ( 0 ) |
---|
53 | #if ADAPTIVE_QP_SELECTION |
---|
54 | , m_iSliceQpBase ( 0 ) |
---|
55 | #endif |
---|
56 | , m_bLoopFilterDisable ( false ) |
---|
57 | , m_inheritDblParamFromAPS ( true ) |
---|
58 | , m_loopFilterBetaOffsetDiv2 ( 0 ) |
---|
59 | , m_loopFilterTcOffsetDiv2 ( 0 ) |
---|
60 | , m_bRefPicListModificationFlagLC ( false ) |
---|
61 | , m_bRefPicListCombinationFlag ( false ) |
---|
62 | , m_bCheckLDC ( false ) |
---|
63 | , m_iSliceQpDelta ( 0 ) |
---|
64 | , m_pcTexturePic ( NULL ) |
---|
65 | , m_iDepth ( 0 ) |
---|
66 | , m_bRefenced ( false ) |
---|
67 | , m_pcSPS ( NULL ) |
---|
68 | , m_pcPPS ( NULL ) |
---|
69 | , m_pcPic ( NULL ) |
---|
70 | , m_uiColDir ( 0 ) |
---|
71 | #if COLLOCATED_REF_IDX |
---|
72 | , m_colRefIdx ( 0 ) |
---|
73 | #endif |
---|
74 | #if ALF_CHROMA_LAMBDA || SAO_CHROMA_LAMBDA |
---|
75 | , m_dLambdaLuma( 0.0 ) |
---|
76 | , m_dLambdaChroma( 0.0 ) |
---|
77 | #else |
---|
78 | , m_dLambda ( 0.0 ) |
---|
79 | #endif |
---|
80 | , m_bNoBackPredFlag ( false ) |
---|
81 | , m_bRefIdxCombineCoding ( false ) |
---|
82 | , m_uiTLayer ( 0 ) |
---|
83 | , m_bTLayerSwitchingFlag ( false ) |
---|
84 | , m_uiSliceMode ( 0 ) |
---|
85 | , m_uiSliceArgument ( 0 ) |
---|
86 | , m_uiSliceCurStartCUAddr ( 0 ) |
---|
87 | , m_uiSliceCurEndCUAddr ( 0 ) |
---|
88 | , m_uiSliceIdx ( 0 ) |
---|
89 | , m_uiEntropySliceMode ( 0 ) |
---|
90 | , m_uiEntropySliceArgument ( 0 ) |
---|
91 | , m_uiEntropySliceCurStartCUAddr ( 0 ) |
---|
92 | , m_uiEntropySliceCurEndCUAddr ( 0 ) |
---|
93 | , m_bNextSlice ( false ) |
---|
94 | , m_bNextEntropySlice ( false ) |
---|
95 | , m_uiSliceBits ( 0 ) |
---|
96 | , m_uiEntropySliceCounter ( 0 ) |
---|
97 | , m_bFinalized ( false ) |
---|
98 | , m_uiTileByteLocation ( NULL ) |
---|
99 | , m_uiTileCount ( 0 ) |
---|
100 | , m_iTileMarkerFlag ( 0 ) |
---|
101 | , m_uiTileOffstForMultES ( 0 ) |
---|
102 | , m_puiSubstreamSizes ( NULL ) |
---|
103 | #if CABAC_INIT_FLAG |
---|
104 | , m_cabacInitFlag ( false ) |
---|
105 | #else |
---|
106 | , m_cabacInitIdc ( -1 ) |
---|
107 | #endif |
---|
108 | #if TILES_WPP_ENTRY_POINT_SIGNALLING |
---|
109 | , m_numEntryPointOffsets ( 0 ) |
---|
110 | #endif |
---|
111 | #if SONY_COLPIC_AVAILABILITY |
---|
112 | , m_iViewOrderIdx ( 0 ) |
---|
113 | #endif |
---|
114 | #if VSP_CFG |
---|
115 | , m_uiNumVspRefPics ( 0 ) |
---|
116 | #endif |
---|
117 | { |
---|
118 | m_aiNumRefIdx[0] = m_aiNumRefIdx[1] = m_aiNumRefIdx[2] = 0; |
---|
119 | |
---|
120 | #if FORCE_REF_VSP |
---|
121 | m_iRefIdxVsp[0] = m_iRefIdxVsp[1] = NOT_VALID; |
---|
122 | #endif |
---|
123 | |
---|
124 | initEqualRef(); |
---|
125 | |
---|
126 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF_LC; iNumCount++) |
---|
127 | { |
---|
128 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumCount]=-1; |
---|
129 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumCount]=-1; |
---|
130 | m_eListIdFromIdxOfLC[iNumCount]=0; |
---|
131 | m_iRefIdxFromIdxOfLC[iNumCount]=0; |
---|
132 | m_iRefIdxOfL0FromRefIdxOfL1[iNumCount] = -1; |
---|
133 | m_iRefIdxOfL1FromRefIdxOfL0[iNumCount] = -1; |
---|
134 | } |
---|
135 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF+1; iNumCount++) |
---|
136 | { |
---|
137 | m_apcRefPicList [0][iNumCount] = NULL; |
---|
138 | m_apcRefPicList [1][iNumCount] = NULL; |
---|
139 | m_aiRefPOCList [0][iNumCount] = 0; |
---|
140 | m_aiRefPOCList [1][iNumCount] = 0; |
---|
141 | m_aiRefViewIdList[0][iNumCount] = 0; |
---|
142 | m_aiRefViewIdList[1][iNumCount] = 0; |
---|
143 | } |
---|
144 | m_bCombineWithReferenceFlag = 0; |
---|
145 | resetWpScaling(m_weightPredTable); |
---|
146 | resetWpScalingLC(m_weightPredTableLC); |
---|
147 | initWpAcDcParam(); |
---|
148 | |
---|
149 | #if VSP_SLICE_HEADER |
---|
150 | m_bVspFlag = false; |
---|
151 | #if VSP_CFG |
---|
152 | memset( m_uiVspRefPos[0], 0, sizeof(UInt)*MAX_NUM_REF_PICS ); |
---|
153 | memset( m_uiVspRefPos[1], 0, sizeof(UInt)*MAX_NUM_REF_PICS ); |
---|
154 | #else |
---|
155 | m_bVspDepthDisableFlag = false; |
---|
156 | #endif |
---|
157 | #endif |
---|
158 | } |
---|
159 | |
---|
160 | TComSlice::~TComSlice() |
---|
161 | { |
---|
162 | if (m_uiTileByteLocation) |
---|
163 | { |
---|
164 | delete [] m_uiTileByteLocation; |
---|
165 | m_uiTileByteLocation = NULL; |
---|
166 | } |
---|
167 | delete[] m_puiSubstreamSizes; |
---|
168 | m_puiSubstreamSizes = NULL; |
---|
169 | } |
---|
170 | |
---|
171 | |
---|
172 | Void TComSlice::initSlice() |
---|
173 | { |
---|
174 | m_aiNumRefIdx[0] = 0; |
---|
175 | m_aiNumRefIdx[1] = 0; |
---|
176 | |
---|
177 | m_uiColDir = 0; |
---|
178 | |
---|
179 | #if COLLOCATED_REF_IDX |
---|
180 | m_colRefIdx = 0; |
---|
181 | #endif |
---|
182 | m_pcTexturePic = NULL; |
---|
183 | |
---|
184 | initEqualRef(); |
---|
185 | m_bNoBackPredFlag = false; |
---|
186 | m_bRefIdxCombineCoding = false; |
---|
187 | m_bRefPicListCombinationFlag = false; |
---|
188 | m_bRefPicListModificationFlagLC = false; |
---|
189 | m_bCheckLDC = false; |
---|
190 | |
---|
191 | m_aiNumRefIdx[REF_PIC_LIST_C] = 0; |
---|
192 | |
---|
193 | m_uiMaxNumMergeCand = MRG_MAX_NUM_CANDS_SIGNALED; |
---|
194 | |
---|
195 | m_bFinalized=false; |
---|
196 | |
---|
197 | m_uiTileCount = 0; |
---|
198 | #if CABAC_INIT_FLAG |
---|
199 | m_cabacInitFlag = false; |
---|
200 | #endif |
---|
201 | #if TILES_WPP_ENTRY_POINT_SIGNALLING |
---|
202 | m_numEntryPointOffsets = 0; |
---|
203 | #endif |
---|
204 | #if VSP_SLICE_HEADER |
---|
205 | m_bVspFlag = false; |
---|
206 | #if VSP_CFG |
---|
207 | m_uiNumVspRefPics = 0; |
---|
208 | memset( m_uiVspRefPos[0], 0, sizeof(UInt)*MAX_NUM_REF_PICS ); |
---|
209 | memset( m_uiVspRefPos[1], 0, sizeof(UInt)*MAX_NUM_REF_PICS ); |
---|
210 | #else |
---|
211 | m_bVspDepthDisableFlag = false; |
---|
212 | #endif |
---|
213 | #endif |
---|
214 | |
---|
215 | } |
---|
216 | |
---|
217 | Void TComSlice::initTiles() |
---|
218 | { |
---|
219 | Int iWidth = m_pcSPS->getPicWidthInLumaSamples(); |
---|
220 | Int iHeight = m_pcSPS->getPicHeightInLumaSamples(); |
---|
221 | UInt uiWidthInCU = ( iWidth %g_uiMaxCUWidth ) ? iWidth /g_uiMaxCUWidth + 1 : iWidth /g_uiMaxCUWidth; |
---|
222 | UInt uiHeightInCU = ( iHeight%g_uiMaxCUHeight ) ? iHeight/g_uiMaxCUHeight + 1 : iHeight/g_uiMaxCUHeight; |
---|
223 | UInt uiNumCUsInFrame = uiWidthInCU * uiHeightInCU; |
---|
224 | |
---|
225 | if (m_uiTileByteLocation==NULL) m_uiTileByteLocation = new UInt[uiNumCUsInFrame]; |
---|
226 | } |
---|
227 | |
---|
228 | |
---|
229 | /** |
---|
230 | - allocate table to contain substream sizes to be written to the slice header. |
---|
231 | . |
---|
232 | \param uiNumSubstreams Number of substreams -- the allocation will be this value - 1. |
---|
233 | */ |
---|
234 | Void TComSlice::allocSubstreamSizes(UInt uiNumSubstreams) |
---|
235 | { |
---|
236 | delete[] m_puiSubstreamSizes; |
---|
237 | m_puiSubstreamSizes = new UInt[uiNumSubstreams > 0 ? uiNumSubstreams-1 : 0]; |
---|
238 | } |
---|
239 | |
---|
240 | Void TComSlice::sortPicList (TComList<TComPic*>& rcListPic) |
---|
241 | { |
---|
242 | TComPic* pcPicExtract; |
---|
243 | TComPic* pcPicInsert; |
---|
244 | |
---|
245 | TComList<TComPic*>::iterator iterPicExtract; |
---|
246 | TComList<TComPic*>::iterator iterPicExtract_1; |
---|
247 | TComList<TComPic*>::iterator iterPicInsert; |
---|
248 | |
---|
249 | for (Int i = 1; i < (Int)(rcListPic.size()); i++) |
---|
250 | { |
---|
251 | iterPicExtract = rcListPic.begin(); |
---|
252 | for (Int j = 0; j < i; j++) iterPicExtract++; |
---|
253 | pcPicExtract = *(iterPicExtract); |
---|
254 | pcPicExtract->setCurrSliceIdx(0); |
---|
255 | |
---|
256 | iterPicInsert = rcListPic.begin(); |
---|
257 | while (iterPicInsert != iterPicExtract) |
---|
258 | { |
---|
259 | pcPicInsert = *(iterPicInsert); |
---|
260 | pcPicInsert->setCurrSliceIdx(0); |
---|
261 | if (pcPicInsert->getPOC() >= pcPicExtract->getPOC()) |
---|
262 | { |
---|
263 | break; |
---|
264 | } |
---|
265 | |
---|
266 | iterPicInsert++; |
---|
267 | } |
---|
268 | |
---|
269 | iterPicExtract_1 = iterPicExtract; iterPicExtract_1++; |
---|
270 | |
---|
271 | // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position |
---|
272 | rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1); |
---|
273 | rcListPic.erase (iterPicExtract); |
---|
274 | } |
---|
275 | } |
---|
276 | |
---|
277 | TComPic* TComSlice::xGetRefPic( TComList<TComPic*>& rcListPic, UInt uiPOC ) |
---|
278 | { |
---|
279 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
280 | TComPic* pcPic = *(iterPic); |
---|
281 | while ( iterPic != rcListPic.end() ) |
---|
282 | { |
---|
283 | if(pcPic->getPOC() == uiPOC) |
---|
284 | { |
---|
285 | break; |
---|
286 | } |
---|
287 | iterPic++; |
---|
288 | pcPic = *(iterPic); |
---|
289 | } |
---|
290 | return pcPic; |
---|
291 | } |
---|
292 | |
---|
293 | |
---|
294 | TComPic* TComSlice::xGetLongTermRefPic( TComList<TComPic*>& rcListPic, UInt uiPOC ) |
---|
295 | { |
---|
296 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
297 | TComPic* pcPic = *(iterPic); |
---|
298 | TComPic* pcStPic = pcPic; |
---|
299 | while ( iterPic != rcListPic.end() ) |
---|
300 | { |
---|
301 | pcPic = *(iterPic); |
---|
302 | if(pcPic && (pcPic->getPOC()%(1<<getSPS()->getBitsForPOC())) == (uiPOC%(1<<getSPS()->getBitsForPOC()))) |
---|
303 | { |
---|
304 | if(pcPic->getIsLongTerm()) |
---|
305 | return pcPic; |
---|
306 | else |
---|
307 | pcStPic = pcPic; |
---|
308 | break; |
---|
309 | } |
---|
310 | |
---|
311 | iterPic++; |
---|
312 | } |
---|
313 | return pcStPic; |
---|
314 | } |
---|
315 | |
---|
316 | TComPic* TComSlice::xGetInterViewRefPic( std::vector<TComPic*>& rcListIvPic, UInt uiViewId ) |
---|
317 | { |
---|
318 | TComPic* pcPic = NULL; |
---|
319 | for( Int k = 0; k < rcListIvPic.size(); k++ ) |
---|
320 | { |
---|
321 | if( rcListIvPic[k]->getViewId() == uiViewId ) |
---|
322 | { |
---|
323 | pcPic = rcListIvPic[k]; |
---|
324 | break; |
---|
325 | } |
---|
326 | } |
---|
327 | |
---|
328 | assert( pcPic != NULL ); |
---|
329 | return pcPic; |
---|
330 | } |
---|
331 | |
---|
332 | Int TComSlice::getNumPocTotalCurr() |
---|
333 | { |
---|
334 | if( m_eSliceType == I_SLICE ) |
---|
335 | { |
---|
336 | return 0; |
---|
337 | } |
---|
338 | |
---|
339 | Int numPocTotalCurr = 0; |
---|
340 | for( UInt i = 0; i < m_pcRPS->getNumberOfNegativePictures()+ m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures(); i++ ) |
---|
341 | { |
---|
342 | if(m_pcRPS->getUsed(i)) |
---|
343 | { |
---|
344 | numPocTotalCurr++; |
---|
345 | } |
---|
346 | } |
---|
347 | |
---|
348 | return numPocTotalCurr; |
---|
349 | } |
---|
350 | |
---|
351 | Int TComSlice::getNumPocTotalCurrMvc() |
---|
352 | { |
---|
353 | if( m_eSliceType == I_SLICE ) |
---|
354 | { |
---|
355 | return 0; |
---|
356 | } |
---|
357 | return getNumPocTotalCurr() + m_pcSPS->getNumberOfUsableInterViewRefs(); |
---|
358 | } |
---|
359 | |
---|
360 | Void TComSlice::setRefPOCnViewListsMvc() |
---|
361 | { |
---|
362 | for(Int iDir = 0; iDir < 2; iDir++) |
---|
363 | { |
---|
364 | for(Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++) |
---|
365 | { |
---|
366 | m_aiRefPOCList [iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC(); |
---|
367 | m_aiRefViewIdList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getViewId(); |
---|
368 | } |
---|
369 | } |
---|
370 | } |
---|
371 | |
---|
372 | Void TComSlice::generateCombinedList() |
---|
373 | { |
---|
374 | if(m_aiNumRefIdx[REF_PIC_LIST_C] > 0) |
---|
375 | { |
---|
376 | m_aiNumRefIdx[REF_PIC_LIST_C]=0; |
---|
377 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF_LC; iNumCount++) |
---|
378 | { |
---|
379 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumCount]=-1; |
---|
380 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumCount]=-1; |
---|
381 | m_eListIdFromIdxOfLC[iNumCount]=0; |
---|
382 | m_iRefIdxFromIdxOfLC[iNumCount]=0; |
---|
383 | m_iRefIdxOfL0FromRefIdxOfL1[iNumCount] = -1; |
---|
384 | m_iRefIdxOfL1FromRefIdxOfL0[iNumCount] = -1; |
---|
385 | } |
---|
386 | |
---|
387 | for (Int iNumRefIdx = 0; iNumRefIdx < MAX_NUM_REF; iNumRefIdx++) |
---|
388 | { |
---|
389 | if(iNumRefIdx < m_aiNumRefIdx[REF_PIC_LIST_0]) |
---|
390 | { |
---|
391 | Bool bTempRefIdxInL2 = true; |
---|
392 | for ( Int iRefIdxLC = 0; iRefIdxLC < m_aiNumRefIdx[REF_PIC_LIST_C]; iRefIdxLC++ ) |
---|
393 | { |
---|
394 | if( (m_apcRefPicList[REF_PIC_LIST_0][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() ) && |
---|
395 | (m_apcRefPicList[REF_PIC_LIST_0][iNumRefIdx]->getViewId() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getViewId()) ) |
---|
396 | { |
---|
397 | m_iRefIdxOfL1FromRefIdxOfL0[iNumRefIdx] = m_iRefIdxFromIdxOfLC[iRefIdxLC]; |
---|
398 | m_iRefIdxOfL0FromRefIdxOfL1[m_iRefIdxFromIdxOfLC[iRefIdxLC]] = iNumRefIdx; |
---|
399 | bTempRefIdxInL2 = false; |
---|
400 | break; |
---|
401 | } |
---|
402 | } |
---|
403 | |
---|
404 | if(bTempRefIdxInL2 == true) |
---|
405 | { |
---|
406 | m_eListIdFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = REF_PIC_LIST_0; |
---|
407 | m_iRefIdxFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = iNumRefIdx; |
---|
408 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumRefIdx] = m_aiNumRefIdx[REF_PIC_LIST_C]++; |
---|
409 | } |
---|
410 | } |
---|
411 | |
---|
412 | if(iNumRefIdx < m_aiNumRefIdx[REF_PIC_LIST_1]) |
---|
413 | { |
---|
414 | Bool bTempRefIdxInL2 = true; |
---|
415 | for ( Int iRefIdxLC = 0; iRefIdxLC < m_aiNumRefIdx[REF_PIC_LIST_C]; iRefIdxLC++ ) |
---|
416 | { |
---|
417 | if( (m_apcRefPicList[REF_PIC_LIST_1][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() ) && |
---|
418 | (m_apcRefPicList[REF_PIC_LIST_1][iNumRefIdx]->getViewId() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getViewId()) ) |
---|
419 | { |
---|
420 | m_iRefIdxOfL0FromRefIdxOfL1[iNumRefIdx] = m_iRefIdxFromIdxOfLC[iRefIdxLC]; |
---|
421 | m_iRefIdxOfL1FromRefIdxOfL0[m_iRefIdxFromIdxOfLC[iRefIdxLC]] = iNumRefIdx; |
---|
422 | bTempRefIdxInL2 = false; |
---|
423 | break; |
---|
424 | } |
---|
425 | } |
---|
426 | if(bTempRefIdxInL2 == true) |
---|
427 | { |
---|
428 | m_eListIdFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = REF_PIC_LIST_1; |
---|
429 | m_iRefIdxFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = iNumRefIdx; |
---|
430 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumRefIdx] = m_aiNumRefIdx[REF_PIC_LIST_C]++; |
---|
431 | } |
---|
432 | } |
---|
433 | } |
---|
434 | } |
---|
435 | } |
---|
436 | |
---|
437 | #if VSP_N |
---|
438 | Void TComSlice::setRefPicListMvc( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& rapcInterViewRefPics, TComPic* pcVspPic ) |
---|
439 | #else |
---|
440 | Void TComSlice::setRefPicListMvc( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& rapcInterViewRefPics ) |
---|
441 | #endif |
---|
442 | { |
---|
443 | if( m_eSliceType == I_SLICE ) |
---|
444 | { |
---|
445 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList) ); |
---|
446 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx ) ); |
---|
447 | |
---|
448 | return; |
---|
449 | } |
---|
450 | |
---|
451 | TComPic* pcRefPic; |
---|
452 | TComPic* RefPicSetStCurr0[16]; |
---|
453 | TComPic* RefPicSetStCurr1[16]; |
---|
454 | TComPic* RefPicSetLtCurr [16]; |
---|
455 | TComPic* RefPicSetIvCurr [16]; |
---|
456 | #if VSP_N |
---|
457 | TComPic* RefPicSetVspCurr [16] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; //for Linux comp |
---|
458 | #endif |
---|
459 | |
---|
460 | UInt NumPocStCurr0 = 0; |
---|
461 | UInt NumPocStCurr1 = 0; |
---|
462 | UInt NumPocLtCurr = 0; |
---|
463 | UInt NumPocIvCurr = 0; |
---|
464 | #if VSP_N |
---|
465 | UInt NumPocVspCurr = 0; |
---|
466 | #endif |
---|
467 | |
---|
468 | Int i; |
---|
469 | // short term negative |
---|
470 | for( i = 0; i < m_pcRPS->getNumberOfNegativePictures(); i++ ) |
---|
471 | { |
---|
472 | if( m_pcRPS->getUsed(i) ) |
---|
473 | { |
---|
474 | pcRefPic = xGetRefPic( rcListPic, getPOC() + m_pcRPS->getDeltaPOC(i) ); |
---|
475 | pcRefPic->setIsLongTerm( 0 ); |
---|
476 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
477 | RefPicSetStCurr0[NumPocStCurr0] = pcRefPic; |
---|
478 | NumPocStCurr0++; |
---|
479 | } |
---|
480 | } |
---|
481 | // short term positive |
---|
482 | for( ; i < m_pcRPS->getNumberOfNegativePictures() + m_pcRPS->getNumberOfPositivePictures(); i++ ) |
---|
483 | { |
---|
484 | if( m_pcRPS->getUsed(i) ) |
---|
485 | { |
---|
486 | pcRefPic = xGetRefPic( rcListPic, getPOC() + m_pcRPS->getDeltaPOC(i) ); |
---|
487 | pcRefPic->setIsLongTerm( 0 ); |
---|
488 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
489 | RefPicSetStCurr1[NumPocStCurr1] = pcRefPic; |
---|
490 | NumPocStCurr1++; |
---|
491 | } |
---|
492 | } |
---|
493 | // long term |
---|
494 | for( i = m_pcRPS->getNumberOfNegativePictures() + m_pcRPS->getNumberOfPositivePictures() + m_pcRPS->getNumberOfLongtermPictures() - 1; i > m_pcRPS->getNumberOfNegativePictures() + m_pcRPS->getNumberOfPositivePictures() - 1 ; i-- ) |
---|
495 | { |
---|
496 | if( m_pcRPS->getUsed(i) ) |
---|
497 | { |
---|
498 | pcRefPic = xGetLongTermRefPic( rcListPic, m_pcRPS->getPOC(i) ); |
---|
499 | pcRefPic->setIsLongTerm( 1 ); |
---|
500 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
501 | RefPicSetLtCurr[NumPocLtCurr] = pcRefPic; |
---|
502 | NumPocLtCurr++; |
---|
503 | } |
---|
504 | } |
---|
505 | // inter-view |
---|
506 | for( i = 0; i < m_pcSPS->getNumberOfUsableInterViewRefs(); i++ ) |
---|
507 | { |
---|
508 | pcRefPic = xGetInterViewRefPic( rapcInterViewRefPics, getViewId() + m_pcSPS->getUsableInterViewRef(i) ); |
---|
509 | pcRefPic->setIsLongTerm( 0 ); |
---|
510 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
511 | RefPicSetIvCurr[NumPocIvCurr] = pcRefPic; |
---|
512 | NumPocIvCurr++; |
---|
513 | } |
---|
514 | #if VSP_N |
---|
515 | if( pcVspPic ) |
---|
516 | { |
---|
517 | pcRefPic = pcVspPic; |
---|
518 | pcRefPic->setIsLongTerm( 0 ); |
---|
519 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
520 | RefPicSetVspCurr[NumPocVspCurr] = pcRefPic; |
---|
521 | NumPocVspCurr++; |
---|
522 | } |
---|
523 | #endif |
---|
524 | |
---|
525 | // ref_pic_list_init |
---|
526 | UInt cIdx = 0; |
---|
527 | UInt num_ref_idx_l0_active_minus1 = m_aiNumRefIdx[0] - 1; |
---|
528 | UInt num_ref_idx_l1_active_minus1 = m_aiNumRefIdx[1] - 1; |
---|
529 | |
---|
530 | assert( (NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + NumPocIvCurr) == getNumPocTotalCurrMvc() ); |
---|
531 | #if VSP_N |
---|
532 | Int numRpsCurrTempList0 = max( (num_ref_idx_l0_active_minus1 + 1), (NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + NumPocIvCurr + NumPocVspCurr) ); |
---|
533 | Int numRpsCurrTempList1 = max( (num_ref_idx_l1_active_minus1 + 1), (NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + NumPocIvCurr + NumPocVspCurr) ); |
---|
534 | #else |
---|
535 | Int numRpsCurrTempList0 = max( (num_ref_idx_l0_active_minus1 + 1), (NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + NumPocIvCurr) ); |
---|
536 | Int numRpsCurrTempList1 = max( (num_ref_idx_l1_active_minus1 + 1), (NumPocStCurr0 + NumPocStCurr1 + NumPocLtCurr + NumPocIvCurr) ); |
---|
537 | #endif |
---|
538 | |
---|
539 | assert( numRpsCurrTempList0 <= 16 ); |
---|
540 | TComPic* refPicListTemp0[16]; |
---|
541 | assert( numRpsCurrTempList1 <= 16 ); |
---|
542 | TComPic* refPicListTemp1[16]; |
---|
543 | |
---|
544 | cIdx = 0; |
---|
545 | while( cIdx < numRpsCurrTempList0 ) |
---|
546 | { |
---|
547 | for( i = 0; i < NumPocStCurr0 && cIdx < numRpsCurrTempList0; cIdx++, i++ ) { refPicListTemp0[cIdx] = RefPicSetStCurr0[i]; } |
---|
548 | for( i = 0; i < NumPocStCurr1 && cIdx < numRpsCurrTempList0; cIdx++, i++ ) { refPicListTemp0[cIdx] = RefPicSetStCurr1[i]; } |
---|
549 | for( i = 0; i < NumPocLtCurr && cIdx < numRpsCurrTempList0; cIdx++, i++ ) { refPicListTemp0[cIdx] = RefPicSetLtCurr [i]; } |
---|
550 | for( i = 0; i < NumPocIvCurr && cIdx < numRpsCurrTempList0; cIdx++, i++ ) { refPicListTemp0[cIdx] = RefPicSetIvCurr [i]; } |
---|
551 | } |
---|
552 | |
---|
553 | cIdx = 0; |
---|
554 | while( cIdx < numRpsCurrTempList1 && m_eSliceType == B_SLICE ) |
---|
555 | { |
---|
556 | for( i = 0; i < NumPocStCurr1 && cIdx < numRpsCurrTempList1; cIdx++, i++ ) { refPicListTemp1[cIdx] = RefPicSetStCurr1[i]; } |
---|
557 | for( i = 0; i < NumPocStCurr0 && cIdx < numRpsCurrTempList1; cIdx++, i++ ) { refPicListTemp1[cIdx] = RefPicSetStCurr0[i]; } |
---|
558 | for( i = 0; i < NumPocLtCurr && cIdx < numRpsCurrTempList1; cIdx++, i++ ) { refPicListTemp1[cIdx] = RefPicSetLtCurr [i]; } |
---|
559 | for( i = 0; i < NumPocIvCurr && cIdx < numRpsCurrTempList1; cIdx++, i++ ) { refPicListTemp1[cIdx] = RefPicSetIvCurr [i]; } |
---|
560 | } |
---|
561 | |
---|
562 | #if VSP_CFG |
---|
563 | UInt cIdxTmp; |
---|
564 | for( cIdx = 0, cIdxTmp = 0; cIdx <= num_ref_idx_l0_active_minus1; cIdx ++ ) |
---|
565 | #else |
---|
566 | for( cIdx = 0; cIdx <= num_ref_idx_l0_active_minus1; cIdx ++ ) |
---|
567 | #endif |
---|
568 | { |
---|
569 | #if VSP_N |
---|
570 | #if VSP_CFG |
---|
571 | Int iVspRefPos = getVspRefPos(REF_PIC_LIST_0, 0); |
---|
572 | iVspRefPos = ( iVspRefPos > 0 ? iVspRefPos - 1 : -1 ); |
---|
573 | if( pcVspPic && iVspRefPos != -1 && cIdx == (iVspRefPos >= num_ref_idx_l0_active_minus1 ? num_ref_idx_l0_active_minus1 : iVspRefPos) ) |
---|
574 | #else |
---|
575 | if( pcVspPic && cIdx == num_ref_idx_l0_active_minus1 ) |
---|
576 | #endif |
---|
577 | { |
---|
578 | m_apcRefPicList[0][cIdx] = RefPicSetVspCurr[0]; |
---|
579 | #if FORCE_REF_VSP |
---|
580 | m_iRefIdxVsp[0] = cIdx; |
---|
581 | #endif |
---|
582 | } |
---|
583 | else |
---|
584 | { |
---|
585 | #if VSP_CFG |
---|
586 | m_apcRefPicList[0][cIdx] = m_RefPicListModification.getRefPicListModificationFlagL0() ? refPicListTemp0[ m_RefPicListModification.getRefPicSetIdxL0(cIdxTmp) ] : refPicListTemp0[cIdxTmp]; |
---|
587 | cIdxTmp++; |
---|
588 | #else |
---|
589 | m_apcRefPicList[0][cIdx] = m_RefPicListModification.getRefPicListModificationFlagL0() ? refPicListTemp0[ m_RefPicListModification.getRefPicSetIdxL0(cIdx) ] : refPicListTemp0[cIdx]; |
---|
590 | #endif |
---|
591 | } |
---|
592 | #else |
---|
593 | m_apcRefPicList[0][cIdx] = m_RefPicListModification.getRefPicListModificationFlagL0() ? refPicListTemp0[ m_RefPicListModification.getRefPicSetIdxL0(cIdx) ] : refPicListTemp0[cIdx]; |
---|
594 | #endif |
---|
595 | } |
---|
596 | if( m_eSliceType == P_SLICE ) |
---|
597 | { |
---|
598 | m_aiNumRefIdx[1] = 0; |
---|
599 | ::memset( m_apcRefPicList[1], 0, sizeof(m_apcRefPicList[1]) ); |
---|
600 | } |
---|
601 | else |
---|
602 | { |
---|
603 | #if VSP_CFG |
---|
604 | for( cIdx = 0, cIdxTmp = 0; cIdx <= num_ref_idx_l1_active_minus1; cIdx ++ ) |
---|
605 | #else |
---|
606 | for( cIdx = 0; cIdx <= num_ref_idx_l1_active_minus1; cIdx ++ ) |
---|
607 | #endif |
---|
608 | { |
---|
609 | #if VSP_N |
---|
610 | #if VSP_CFG |
---|
611 | Int iVspRefPos = getVspRefPos(REF_PIC_LIST_1, 0); |
---|
612 | iVspRefPos = ( iVspRefPos > 0 ? iVspRefPos - 1 : -1 ); |
---|
613 | if( pcVspPic && iVspRefPos != -1 && cIdx == (iVspRefPos >= num_ref_idx_l1_active_minus1 ? num_ref_idx_l1_active_minus1 : iVspRefPos) ) |
---|
614 | #else |
---|
615 | if( pcVspPic && cIdx == num_ref_idx_l1_active_minus1 ) |
---|
616 | #endif |
---|
617 | { |
---|
618 | m_apcRefPicList[1][cIdx] = RefPicSetVspCurr[0]; |
---|
619 | #if FORCE_REF_VSP |
---|
620 | m_iRefIdxVsp[1] = cIdx; |
---|
621 | #endif |
---|
622 | } |
---|
623 | else |
---|
624 | { |
---|
625 | #if VSP_CFG |
---|
626 | m_apcRefPicList[1][cIdx] = m_RefPicListModification.getRefPicListModificationFlagL1() ? refPicListTemp1[ m_RefPicListModification.getRefPicSetIdxL1(cIdxTmp) ] : refPicListTemp1[cIdxTmp]; |
---|
627 | cIdxTmp++; |
---|
628 | #else |
---|
629 | m_apcRefPicList[1][cIdx] = m_RefPicListModification.getRefPicListModificationFlagL1() ? refPicListTemp1[ m_RefPicListModification.getRefPicSetIdxL1(cIdx) ] : refPicListTemp1[cIdx]; |
---|
630 | #endif |
---|
631 | } |
---|
632 | #else |
---|
633 | m_apcRefPicList[1][cIdx] = m_RefPicListModification.getRefPicListModificationFlagL1() ? refPicListTemp1[ m_RefPicListModification.getRefPicSetIdxL1(cIdx) ] : refPicListTemp1[cIdx]; |
---|
634 | #endif |
---|
635 | } |
---|
636 | } |
---|
637 | } |
---|
638 | |
---|
639 | Void TComSlice::initEqualRef() |
---|
640 | { |
---|
641 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
642 | { |
---|
643 | for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++) |
---|
644 | { |
---|
645 | for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++) |
---|
646 | { |
---|
647 | m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false); |
---|
648 | } |
---|
649 | } |
---|
650 | } |
---|
651 | } |
---|
652 | |
---|
653 | Void TComSlice::initMultiviewSlice( Int** aaiScale, Int** aaiOffset ) |
---|
654 | { |
---|
655 | if( m_pcSPS->hasCamParInSliceHeader() ) |
---|
656 | { |
---|
657 | UInt uiViewId = m_pcSPS->getViewId(); |
---|
658 | for( UInt uiBaseViewId = 0; uiBaseViewId < uiViewId; uiBaseViewId++ ) |
---|
659 | { |
---|
660 | m_aaiCodedScale [ 0 ][ uiBaseViewId ] = aaiScale [ uiBaseViewId ][ uiViewId ]; |
---|
661 | m_aaiCodedScale [ 1 ][ uiBaseViewId ] = aaiScale [ uiViewId ][ uiBaseViewId ]; |
---|
662 | m_aaiCodedOffset[ 0 ][ uiBaseViewId ] = aaiOffset[ uiBaseViewId ][ uiViewId ]; |
---|
663 | m_aaiCodedOffset[ 1 ][ uiBaseViewId ] = aaiOffset[ uiViewId ][ uiBaseViewId ]; |
---|
664 | } |
---|
665 | } |
---|
666 | } |
---|
667 | |
---|
668 | #if COLLOCATED_REF_IDX |
---|
669 | Void TComSlice::checkColRefIdx(UInt curSliceIdx, TComPic* pic) |
---|
670 | { |
---|
671 | Int i; |
---|
672 | TComSlice* curSlice = pic->getSlice(curSliceIdx); |
---|
673 | Int currColRefPOC = curSlice->getRefPOC( RefPicList(curSlice->getColDir()), curSlice->getColRefIdx()); |
---|
674 | TComSlice* preSlice; |
---|
675 | Int preColRefPOC; |
---|
676 | for(i=curSliceIdx-1; i>=0; i--) |
---|
677 | { |
---|
678 | preSlice = pic->getSlice(i); |
---|
679 | if(preSlice->getSliceType() != I_SLICE) |
---|
680 | { |
---|
681 | preColRefPOC = preSlice->getRefPOC( RefPicList(preSlice->getColDir()), preSlice->getColRefIdx()); |
---|
682 | if(currColRefPOC != preColRefPOC) |
---|
683 | { |
---|
684 | printf("Collocated_ref_idx shall always be the same for all slices of a coded picture!\n"); |
---|
685 | exit(EXIT_FAILURE); |
---|
686 | } |
---|
687 | else |
---|
688 | { |
---|
689 | break; |
---|
690 | } |
---|
691 | } |
---|
692 | } |
---|
693 | } |
---|
694 | #endif |
---|
695 | Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, TComList<TComPic*>& rcListPic) |
---|
696 | { |
---|
697 | for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) |
---|
698 | { |
---|
699 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
700 | { |
---|
701 | assert(getPOC()+pReferencePictureSet->getDeltaPOC(i) >= pocCRA); |
---|
702 | } |
---|
703 | } |
---|
704 | for(Int i = pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i < pReferencePictureSet->getNumberOfPictures(); i++) |
---|
705 | { |
---|
706 | if(pocCRA < MAX_UINT && getPOC() > pocCRA) |
---|
707 | { |
---|
708 | assert(pReferencePictureSet->getPOC(i) >= pocCRA); |
---|
709 | } |
---|
710 | } |
---|
711 | #if H0566_TLA |
---|
712 | if( getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
713 | #else |
---|
714 | if( getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_CDR ) // CDR picture found |
---|
715 | #endif |
---|
716 | { |
---|
717 | pocCRA = getPOC(); |
---|
718 | } |
---|
719 | } |
---|
720 | |
---|
721 | /** Function for marking the reference pictures when an IDR and CRA is encountered. |
---|
722 | * \param pocCRA POC of the CRA picture |
---|
723 | * \param bRefreshPending flag indicating if a deferred decoding refresh is pending |
---|
724 | * \param rcListPic reference to the reference picture list |
---|
725 | * This function marks the reference pictures as "unused for reference" in the following conditions. |
---|
726 | * If the nal_unit_type is IDR all pictures in the reference picture list |
---|
727 | * is marked as "unused for reference" |
---|
728 | * Otherwise do for the CRA case (non CRA case has no effect since both if conditions below will not be true) |
---|
729 | * If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current |
---|
730 | * temporal reference is greater than the temporal reference of the latest CRA picture (pocCRA), |
---|
731 | * mark all reference pictures except the latest CRA picture as "unused for reference" and set |
---|
732 | * the bRefreshPending flag to false. |
---|
733 | * If the nal_unit_type is CRA, set the bRefreshPending flag to true and pocCRA to the temporal |
---|
734 | * reference of the current picture. |
---|
735 | * Note that the current picture is already placed in the reference list and its marking is not changed. |
---|
736 | * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". |
---|
737 | */ |
---|
738 | Void TComSlice::decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic) |
---|
739 | { |
---|
740 | TComPic* rpcPic; |
---|
741 | UInt uiPOCCurr = getPOC(); |
---|
742 | |
---|
743 | if( getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_IDR ) // IDR |
---|
744 | { |
---|
745 | // mark all pictures as not used for reference |
---|
746 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
747 | while (iterPic != rcListPic.end()) |
---|
748 | { |
---|
749 | rpcPic = *(iterPic); |
---|
750 | rpcPic->setCurrSliceIdx(0); |
---|
751 | if (rpcPic->getPOC() != uiPOCCurr) rpcPic->getSlice(0)->setReferenced(false); |
---|
752 | iterPic++; |
---|
753 | } |
---|
754 | } |
---|
755 | else // CRA or No DR |
---|
756 | { |
---|
757 | if (bRefreshPending==true && uiPOCCurr > pocCRA) // CRA reference marking pending |
---|
758 | { |
---|
759 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
760 | while (iterPic != rcListPic.end()) |
---|
761 | { |
---|
762 | rpcPic = *(iterPic); |
---|
763 | if (rpcPic->getPOC() != uiPOCCurr && rpcPic->getPOC() != pocCRA) rpcPic->getSlice(0)->setReferenced(false); |
---|
764 | iterPic++; |
---|
765 | } |
---|
766 | bRefreshPending = false; |
---|
767 | } |
---|
768 | #if H0566_TLA |
---|
769 | if( getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found |
---|
770 | #else |
---|
771 | if( getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_CDR ) // CDR picture found |
---|
772 | #endif |
---|
773 | { |
---|
774 | bRefreshPending = true; |
---|
775 | pocCRA = uiPOCCurr; |
---|
776 | } |
---|
777 | } |
---|
778 | } |
---|
779 | |
---|
780 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
781 | { |
---|
782 | assert( pSrc != NULL ); |
---|
783 | |
---|
784 | Int i, j, k; |
---|
785 | |
---|
786 | m_iPOC = pSrc->m_iPOC; |
---|
787 | m_viewId = pSrc->m_viewId; |
---|
788 | #if SONY_COLPIC_AVAILABILITY |
---|
789 | m_iViewOrderIdx = pSrc->m_iViewOrderIdx; |
---|
790 | #endif |
---|
791 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
792 | m_eNalUnitTypeBaseViewMvc = pSrc->m_eNalUnitTypeBaseViewMvc; |
---|
793 | m_eSliceType = pSrc->m_eSliceType; |
---|
794 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
795 | #if ADAPTIVE_QP_SELECTION |
---|
796 | m_iSliceQpBase = pSrc->m_iSliceQpBase; |
---|
797 | #endif |
---|
798 | m_bLoopFilterDisable = pSrc->m_bLoopFilterDisable; |
---|
799 | m_inheritDblParamFromAPS = pSrc->m_inheritDblParamFromAPS; |
---|
800 | m_loopFilterBetaOffsetDiv2 = pSrc->m_loopFilterBetaOffsetDiv2; |
---|
801 | m_loopFilterTcOffsetDiv2 = pSrc->m_loopFilterTcOffsetDiv2; |
---|
802 | |
---|
803 | for (i = 0; i < 3; i++) |
---|
804 | { |
---|
805 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
806 | } |
---|
807 | |
---|
808 | for (i = 0; i < 2; i++) |
---|
809 | { |
---|
810 | for (j = 0; j < MAX_NUM_REF_LC; j++) |
---|
811 | { |
---|
812 | m_iRefIdxOfLC[i][j] = pSrc->m_iRefIdxOfLC[i][j]; |
---|
813 | } |
---|
814 | } |
---|
815 | for (i = 0; i < MAX_NUM_REF_LC; i++) |
---|
816 | { |
---|
817 | m_eListIdFromIdxOfLC[i] = pSrc->m_eListIdFromIdxOfLC[i]; |
---|
818 | m_iRefIdxFromIdxOfLC[i] = pSrc->m_iRefIdxFromIdxOfLC[i]; |
---|
819 | m_iRefIdxOfL1FromRefIdxOfL0[i] = pSrc->m_iRefIdxOfL1FromRefIdxOfL0[i]; |
---|
820 | m_iRefIdxOfL0FromRefIdxOfL1[i] = pSrc->m_iRefIdxOfL0FromRefIdxOfL1[i]; |
---|
821 | } |
---|
822 | m_bRefPicListModificationFlagLC = pSrc->m_bRefPicListModificationFlagLC; |
---|
823 | m_bRefPicListCombinationFlag = pSrc->m_bRefPicListCombinationFlag; |
---|
824 | m_bCheckLDC = pSrc->m_bCheckLDC; |
---|
825 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
826 | for (i = 0; i < 2; i++) |
---|
827 | { |
---|
828 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
829 | { |
---|
830 | m_apcRefPicList [i][j] = pSrc->m_apcRefPicList [i][j]; |
---|
831 | m_aiRefPOCList [i][j] = pSrc->m_aiRefPOCList [i][j]; |
---|
832 | m_aiRefViewIdList[i][j] = pSrc->m_aiRefViewIdList[i][j]; |
---|
833 | } |
---|
834 | } |
---|
835 | m_iDepth = pSrc->m_iDepth; |
---|
836 | |
---|
837 | // referenced slice |
---|
838 | m_bRefenced = pSrc->m_bRefenced; |
---|
839 | |
---|
840 | // access channel |
---|
841 | m_pcSPS = pSrc->m_pcSPS; |
---|
842 | m_pcPPS = pSrc->m_pcPPS; |
---|
843 | m_pcRPS = pSrc->m_pcRPS; |
---|
844 | m_iLastIDR = pSrc->m_iLastIDR; |
---|
845 | |
---|
846 | m_pcPic = pSrc->m_pcPic; |
---|
847 | m_pcAPS = pSrc->m_pcAPS; |
---|
848 | m_iAPSId = pSrc->m_iAPSId; |
---|
849 | |
---|
850 | m_uiColDir = pSrc->m_uiColDir; |
---|
851 | #if COLLOCATED_REF_IDX |
---|
852 | m_colRefIdx = pSrc->m_colRefIdx; |
---|
853 | #endif |
---|
854 | #if ALF_CHROMA_LAMBDA || SAO_CHROMA_LAMBDA |
---|
855 | m_dLambdaLuma = pSrc->m_dLambdaLuma; |
---|
856 | m_dLambdaChroma = pSrc->m_dLambdaChroma; |
---|
857 | #else |
---|
858 | m_dLambda = pSrc->m_dLambda; |
---|
859 | #endif |
---|
860 | for (i = 0; i < 2; i++) |
---|
861 | { |
---|
862 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
863 | { |
---|
864 | for (k =0; k < MAX_NUM_REF; k++) |
---|
865 | { |
---|
866 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
867 | } |
---|
868 | } |
---|
869 | } |
---|
870 | |
---|
871 | m_bNoBackPredFlag = pSrc->m_bNoBackPredFlag; |
---|
872 | m_bRefIdxCombineCoding = pSrc->m_bRefIdxCombineCoding; |
---|
873 | |
---|
874 | m_uiTLayer = pSrc->m_uiTLayer; |
---|
875 | m_bTLayerSwitchingFlag = pSrc->m_bTLayerSwitchingFlag; |
---|
876 | |
---|
877 | m_uiSliceMode = pSrc->m_uiSliceMode; |
---|
878 | m_uiSliceArgument = pSrc->m_uiSliceArgument; |
---|
879 | m_uiSliceCurStartCUAddr = pSrc->m_uiSliceCurStartCUAddr; |
---|
880 | m_uiSliceCurEndCUAddr = pSrc->m_uiSliceCurEndCUAddr; |
---|
881 | m_uiSliceIdx = pSrc->m_uiSliceIdx; |
---|
882 | m_uiEntropySliceMode = pSrc->m_uiEntropySliceMode; |
---|
883 | m_uiEntropySliceArgument = pSrc->m_uiEntropySliceArgument; |
---|
884 | m_uiEntropySliceCurStartCUAddr = pSrc->m_uiEntropySliceCurStartCUAddr; |
---|
885 | m_uiEntropySliceCurEndCUAddr = pSrc->m_uiEntropySliceCurEndCUAddr; |
---|
886 | m_bNextSlice = pSrc->m_bNextSlice; |
---|
887 | m_bNextEntropySlice = pSrc->m_bNextEntropySlice; |
---|
888 | m_iTileMarkerFlag = pSrc->m_iTileMarkerFlag; |
---|
889 | for ( int e=0 ; e<2 ; e++ ) |
---|
890 | for ( int n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
891 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(wpScalingParam)*3 ); |
---|
892 | |
---|
893 | m_saoEnabledFlag = pSrc->m_saoEnabledFlag; |
---|
894 | #if SAO_UNIT_INTERLEAVING |
---|
895 | m_saoInterleavingFlag = pSrc->m_saoInterleavingFlag; |
---|
896 | m_saoEnabledFlagCb = pSrc->m_saoEnabledFlagCb; |
---|
897 | m_saoEnabledFlagCr = pSrc->m_saoEnabledFlagCr; |
---|
898 | #endif |
---|
899 | #if CABAC_INIT_FLAG |
---|
900 | m_cabacInitFlag = pSrc->m_cabacInitFlag; |
---|
901 | #endif |
---|
902 | #if TILES_WPP_ENTRY_POINT_SIGNALLING |
---|
903 | m_numEntryPointOffsets = pSrc->m_numEntryPointOffsets; |
---|
904 | #endif |
---|
905 | |
---|
906 | #if H0111_MVD_L1_ZERO |
---|
907 | m_bLMvdL1Zero = pSrc->m_bLMvdL1Zero; |
---|
908 | #endif |
---|
909 | } |
---|
910 | |
---|
911 | int TComSlice::m_prevPOC = 0; |
---|
912 | /** Function for setting the slice's temporal layer ID and corresponding temporal_layer_switching_point_flag. |
---|
913 | * \param uiTLayer Temporal layer ID of the current slice |
---|
914 | * The decoder calls this function to set temporal_layer_switching_point_flag for each temporal layer based on |
---|
915 | * the SPS's temporal_id_nesting_flag and the parsed PPS. Then, current slice's temporal layer ID and |
---|
916 | * temporal_layer_switching_point_flag is set accordingly. |
---|
917 | */ |
---|
918 | Void TComSlice::setTLayerInfo( UInt uiTLayer ) |
---|
919 | { |
---|
920 | #if !H0566_TLA |
---|
921 | // If temporal_id_nesting_flag == 1, then num_temporal_layer_switching_point_flags shall be inferred to be 0 and temporal_layer_switching_point_flag shall be inferred to be 1 for all temporal layers |
---|
922 | if ( m_pcSPS->getTemporalIdNestingFlag() ) |
---|
923 | { |
---|
924 | m_pcPPS->setNumTLayerSwitchingFlags( 0 ); |
---|
925 | for ( UInt i = 0; i < MAX_TLAYER; i++ ) |
---|
926 | { |
---|
927 | m_pcPPS->setTLayerSwitchingFlag( i, true ); |
---|
928 | } |
---|
929 | } |
---|
930 | else |
---|
931 | { |
---|
932 | for ( UInt i = m_pcPPS->getNumTLayerSwitchingFlags(); i < MAX_TLAYER; i++ ) |
---|
933 | { |
---|
934 | m_pcPPS->setTLayerSwitchingFlag( i, false ); |
---|
935 | } |
---|
936 | } |
---|
937 | #endif |
---|
938 | |
---|
939 | m_uiTLayer = uiTLayer; |
---|
940 | #if !H0566_TLA |
---|
941 | m_bTLayerSwitchingFlag = m_pcPPS->getTLayerSwitchingFlag( uiTLayer ); |
---|
942 | #endif |
---|
943 | } |
---|
944 | |
---|
945 | #if H0566_TLA && H0566_TLA_SET_FOR_SWITCHING_POINTS |
---|
946 | /** Function for checking if this is a switching-point |
---|
947 | */ |
---|
948 | Bool TComSlice::isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
949 | { |
---|
950 | TComPic* rpcPic; |
---|
951 | // loop through all pictures in the reference picture buffer |
---|
952 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
953 | while ( iterPic != rcListPic.end()) |
---|
954 | { |
---|
955 | rpcPic = *(iterPic++); |
---|
956 | if(rpcPic->getSlice(0)->isReferenced() && rpcPic->getPOC() != getPOC()) |
---|
957 | { |
---|
958 | if(rpcPic->getTLayer() >= getTLayer()) |
---|
959 | { |
---|
960 | return false; |
---|
961 | } |
---|
962 | } |
---|
963 | } |
---|
964 | return true; |
---|
965 | } |
---|
966 | #endif |
---|
967 | |
---|
968 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
969 | */ |
---|
970 | Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
971 | { |
---|
972 | TComPic* rpcPic; |
---|
973 | Int i, isReference; |
---|
974 | |
---|
975 | Int j = 0; |
---|
976 | // loop through all pictures in the reference picture buffer |
---|
977 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
978 | while ( iterPic != rcListPic.end()) |
---|
979 | { |
---|
980 | j++; |
---|
981 | rpcPic = *(iterPic++); |
---|
982 | |
---|
983 | isReference = 0; |
---|
984 | // loop through all pictures in the Reference Picture Set to see if the picture should be kept as reference picture |
---|
985 | for(i=0;i<pReferencePictureSet->getNumberOfPositivePictures()+pReferencePictureSet->getNumberOfNegativePictures();i++) |
---|
986 | { |
---|
987 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i)) |
---|
988 | { |
---|
989 | isReference = 1; |
---|
990 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
991 | rpcPic->setIsLongTerm(0); |
---|
992 | } |
---|
993 | } |
---|
994 | // long term pictures |
---|
995 | for(;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
996 | { |
---|
997 | 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())) |
---|
998 | { |
---|
999 | isReference = 1; |
---|
1000 | rpcPic->setUsedByCurr(pReferencePictureSet->getUsed(i)); |
---|
1001 | } |
---|
1002 | } |
---|
1003 | // mark the picture as "unused for reference" if it is not in |
---|
1004 | // the Reference Picture Set |
---|
1005 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() != this->getPOC() && isReference == 0) |
---|
1006 | { |
---|
1007 | rpcPic->getSlice( 0 )->setReferenced( false ); |
---|
1008 | rpcPic->setIsLongTerm(0); |
---|
1009 | } |
---|
1010 | } |
---|
1011 | } |
---|
1012 | |
---|
1013 | /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. |
---|
1014 | */ |
---|
1015 | #if START_DECODING_AT_CRA |
---|
1016 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool outputFlag, Int pocRandomAccess) |
---|
1017 | #else |
---|
1018 | Int TComSlice::checkThatAllRefPicsAreAvailable( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet, Bool outputFlag) |
---|
1019 | #endif |
---|
1020 | { |
---|
1021 | TComPic* rpcPic; |
---|
1022 | Int i, isAvailable, j; |
---|
1023 | Int atLeastOneLost = 0; |
---|
1024 | Int atLeastOneRemoved = 0; |
---|
1025 | Int iPocLost = 0; |
---|
1026 | |
---|
1027 | // loop through all long-term pictures in the Reference Picture Set |
---|
1028 | // to see if the picture should be kept as reference picture |
---|
1029 | for(i=pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1030 | { |
---|
1031 | j = 0; |
---|
1032 | isAvailable = 0; |
---|
1033 | // loop through all pictures in the reference picture buffer |
---|
1034 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1035 | while ( iterPic != rcListPic.end()) |
---|
1036 | { |
---|
1037 | j++; |
---|
1038 | rpcPic = *(iterPic++); |
---|
1039 | 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()) |
---|
1040 | { |
---|
1041 | isAvailable = 1; |
---|
1042 | } |
---|
1043 | } |
---|
1044 | // if there was no such long-term check the short terms |
---|
1045 | if(!isAvailable) |
---|
1046 | { |
---|
1047 | iterPic = rcListPic.begin(); |
---|
1048 | while ( iterPic != rcListPic.end()) |
---|
1049 | { |
---|
1050 | j++; |
---|
1051 | rpcPic = *(iterPic++); |
---|
1052 | |
---|
1053 | if((rpcPic->getPicSym()->getSlice(0)->getPOC()%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC())) == (this->getPOC() + pReferencePictureSet->getDeltaPOC(i))%(1<<rpcPic->getPicSym()->getSlice(0)->getSPS()->getBitsForPOC()) && rpcPic->getSlice(0)->isReferenced()) |
---|
1054 | { |
---|
1055 | isAvailable = 1; |
---|
1056 | rpcPic->setIsLongTerm(1); |
---|
1057 | break; |
---|
1058 | } |
---|
1059 | } |
---|
1060 | } |
---|
1061 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1062 | // but not available as reference picture |
---|
1063 | if(isAvailable == 0) |
---|
1064 | { |
---|
1065 | #if START_DECODING_AT_CRA |
---|
1066 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1067 | { |
---|
1068 | #endif |
---|
1069 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1070 | { |
---|
1071 | if(outputFlag) |
---|
1072 | printf("\nLong-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1073 | atLeastOneRemoved = 1; |
---|
1074 | } |
---|
1075 | else |
---|
1076 | { |
---|
1077 | if(outputFlag) |
---|
1078 | printf("\nLong-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1079 | atLeastOneLost = 1; |
---|
1080 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1081 | } |
---|
1082 | #if START_DECODING_AT_CRA |
---|
1083 | } |
---|
1084 | #endif |
---|
1085 | } |
---|
1086 | } |
---|
1087 | // loop through all short-term pictures in the Reference Picture Set |
---|
1088 | // to see if the picture should be kept as reference picture |
---|
1089 | for(i=0;i<pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures();i++) |
---|
1090 | { |
---|
1091 | j = 0; |
---|
1092 | isAvailable = 0; |
---|
1093 | // loop through all pictures in the reference picture buffer |
---|
1094 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1095 | while ( iterPic != rcListPic.end()) |
---|
1096 | { |
---|
1097 | j++; |
---|
1098 | rpcPic = *(iterPic++); |
---|
1099 | |
---|
1100 | if(!rpcPic->getIsLongTerm() && rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1101 | { |
---|
1102 | isAvailable = 1; |
---|
1103 | } |
---|
1104 | } |
---|
1105 | // report that a picture is lost if it is in the Reference Picture Set |
---|
1106 | // but not available as reference picture |
---|
1107 | if(isAvailable == 0) |
---|
1108 | { |
---|
1109 | #if START_DECODING_AT_CRA |
---|
1110 | if (this->getPOC() + pReferencePictureSet->getDeltaPOC(i) >= pocRandomAccess) |
---|
1111 | { |
---|
1112 | #endif |
---|
1113 | if(!pReferencePictureSet->getUsed(i) ) |
---|
1114 | { |
---|
1115 | if(outputFlag) |
---|
1116 | printf("\nShort-term reference picture with POC = %3d seems to have been removed or not correctly decoded.", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1117 | atLeastOneRemoved = 1; |
---|
1118 | } |
---|
1119 | else |
---|
1120 | { |
---|
1121 | if(outputFlag) |
---|
1122 | printf("\nShort-term reference picture with POC = %3d is lost or not correctly decoded!", this->getPOC() + pReferencePictureSet->getDeltaPOC(i)); |
---|
1123 | atLeastOneLost = 1; |
---|
1124 | iPocLost=this->getPOC() + pReferencePictureSet->getDeltaPOC(i); |
---|
1125 | } |
---|
1126 | #if START_DECODING_AT_CRA |
---|
1127 | } |
---|
1128 | #endif |
---|
1129 | } |
---|
1130 | } |
---|
1131 | if(atLeastOneLost) |
---|
1132 | { |
---|
1133 | return iPocLost+1; |
---|
1134 | } |
---|
1135 | if(atLeastOneRemoved) |
---|
1136 | { |
---|
1137 | return -2; |
---|
1138 | } |
---|
1139 | else |
---|
1140 | return 0; |
---|
1141 | } |
---|
1142 | |
---|
1143 | /** Function for constructing an explicit Reference Picture Set out of the available pictures in a referenced Reference Picture Set |
---|
1144 | */ |
---|
1145 | Void TComSlice::createExplicitReferencePictureSetFromReference( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) |
---|
1146 | { |
---|
1147 | TComPic* rpcPic; |
---|
1148 | Int i, j; |
---|
1149 | Int k = 0; |
---|
1150 | Int nrOfNegativePictures = 0; |
---|
1151 | Int nrOfPositivePictures = 0; |
---|
1152 | TComReferencePictureSet* pcRPS = this->getLocalRPS(); |
---|
1153 | |
---|
1154 | // loop through all pictures in the Reference Picture Set |
---|
1155 | for(i=0;i<pReferencePictureSet->getNumberOfPictures();i++) |
---|
1156 | { |
---|
1157 | j = 0; |
---|
1158 | // loop through all pictures in the reference picture buffer |
---|
1159 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
1160 | while ( iterPic != rcListPic.end()) |
---|
1161 | { |
---|
1162 | j++; |
---|
1163 | rpcPic = *(iterPic++); |
---|
1164 | |
---|
1165 | if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced()) |
---|
1166 | { |
---|
1167 | // This picture exists as a reference picture |
---|
1168 | // and should be added to the explicit Reference Picture Set |
---|
1169 | pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i)); |
---|
1170 | pcRPS->setUsed(k, pReferencePictureSet->getUsed(i)); |
---|
1171 | if(pcRPS->getDeltaPOC(k) < 0) |
---|
1172 | nrOfNegativePictures++; |
---|
1173 | else |
---|
1174 | nrOfPositivePictures++; |
---|
1175 | k++; |
---|
1176 | } |
---|
1177 | } |
---|
1178 | } |
---|
1179 | pcRPS->setNumberOfNegativePictures(nrOfNegativePictures); |
---|
1180 | pcRPS->setNumberOfPositivePictures(nrOfPositivePictures); |
---|
1181 | pcRPS->setNumberOfPictures(nrOfNegativePictures+nrOfPositivePictures); |
---|
1182 | // This is a simplistic inter rps example. A smarter encoder will look for a better reference RPS to do the |
---|
1183 | // inter RPS prediction with. Here we just use the reference used by pReferencePictureSet. |
---|
1184 | // If pReferencePictureSet is not inter_RPS_predicted, then inter_RPS_prediction is for the current RPS also disabled. |
---|
1185 | if (!pReferencePictureSet->getInterRPSPrediction()) |
---|
1186 | { |
---|
1187 | pcRPS->setInterRPSPrediction(false); |
---|
1188 | pcRPS->setNumRefIdc(0); |
---|
1189 | } |
---|
1190 | else |
---|
1191 | { |
---|
1192 | Int rIdx = this->getRPSidx() - pReferencePictureSet->getDeltaRIdxMinus1() - 1; |
---|
1193 | Int deltaRPS = pReferencePictureSet->getDeltaRPS(); |
---|
1194 | #if RPS_IN_SPS |
---|
1195 | TComReferencePictureSet* pcRefRPS = this->getSPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
1196 | #else |
---|
1197 | TComReferencePictureSet* pcRefRPS = this->getPPS()->getRPSList()->getReferencePictureSet(rIdx); |
---|
1198 | #endif |
---|
1199 | Int iRefPics = pcRefRPS->getNumberOfPictures(); |
---|
1200 | Int iNewIdc=0; |
---|
1201 | for(i=0; i<= iRefPics; i++) |
---|
1202 | { |
---|
1203 | Int deltaPOC = ((i != iRefPics)? pcRefRPS->getDeltaPOC(i) : 0); // check if the reference abs POC is >= 0 |
---|
1204 | Int iRefIdc = 0; |
---|
1205 | for (j=0; j < pcRPS->getNumberOfPictures(); j++) // loop through the pictures in the new RPS |
---|
1206 | { |
---|
1207 | if ( (deltaPOC + deltaRPS) == pcRPS->getDeltaPOC(j)) |
---|
1208 | { |
---|
1209 | if (pcRPS->getUsed(j)) |
---|
1210 | { |
---|
1211 | iRefIdc = 1; |
---|
1212 | } |
---|
1213 | else |
---|
1214 | { |
---|
1215 | iRefIdc = 2; |
---|
1216 | } |
---|
1217 | } |
---|
1218 | } |
---|
1219 | pcRPS->setRefIdc(i, iRefIdc); |
---|
1220 | iNewIdc++; |
---|
1221 | } |
---|
1222 | pcRPS->setInterRPSPrediction(true); |
---|
1223 | pcRPS->setNumRefIdc(iNewIdc); |
---|
1224 | pcRPS->setDeltaRPS(deltaRPS); |
---|
1225 | #if RPS_IN_SPS |
---|
1226 | pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getSPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
1227 | #else |
---|
1228 | pcRPS->setDeltaRIdxMinus1(pReferencePictureSet->getDeltaRIdxMinus1() + this->getPPS()->getRPSList()->getNumberOfReferencePictureSets() - this->getRPSidx()); |
---|
1229 | #endif |
---|
1230 | } |
---|
1231 | |
---|
1232 | this->setRPS(pcRPS); |
---|
1233 | this->setRPSidx(-1); |
---|
1234 | } |
---|
1235 | |
---|
1236 | Void TComSlice::decodingMarkingForNoTMVP( TComList<TComPic*>& rcListPic, Int currentPOC ) |
---|
1237 | { |
---|
1238 | TComList<TComPic*>::iterator it; |
---|
1239 | for ( it = rcListPic.begin(); it != rcListPic.end(); it++ ) |
---|
1240 | { |
---|
1241 | if ( (*it)->getSlice(0)->getPOC() != currentPOC ) |
---|
1242 | { |
---|
1243 | (*it)->setUsedForTMVP( false ); |
---|
1244 | } |
---|
1245 | } |
---|
1246 | } |
---|
1247 | |
---|
1248 | /** get AC and DC values for weighted pred |
---|
1249 | * \param *wp |
---|
1250 | * \returns Void |
---|
1251 | */ |
---|
1252 | Void TComSlice::getWpAcDcParam(wpACDCParam *&wp) |
---|
1253 | { |
---|
1254 | wp = m_weightACDCParam; |
---|
1255 | } |
---|
1256 | |
---|
1257 | /** init AC and DC values for weighted pred |
---|
1258 | * \returns Void |
---|
1259 | */ |
---|
1260 | Void TComSlice::initWpAcDcParam() |
---|
1261 | { |
---|
1262 | for(Int iComp = 0; iComp < 3; iComp++ ) |
---|
1263 | { |
---|
1264 | m_weightACDCParam[iComp].iAC = 0; |
---|
1265 | m_weightACDCParam[iComp].iDC = 0; |
---|
1266 | } |
---|
1267 | } |
---|
1268 | |
---|
1269 | /** get WP tables for weighted pred |
---|
1270 | * \param RefPicList |
---|
1271 | * \param iRefIdx |
---|
1272 | * \param *&wpScalingParam |
---|
1273 | * \returns Void |
---|
1274 | */ |
---|
1275 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, wpScalingParam *&wp ) |
---|
1276 | { |
---|
1277 | wp = m_weightPredTable[e][iRefIdx]; |
---|
1278 | } |
---|
1279 | |
---|
1280 | /** reset Default WP tables settings : no weight. |
---|
1281 | * \param wpScalingParam |
---|
1282 | * \returns Void |
---|
1283 | */ |
---|
1284 | Void TComSlice::resetWpScaling(wpScalingParam wp[2][MAX_NUM_REF][3]) |
---|
1285 | { |
---|
1286 | for ( int e=0 ; e<2 ; e++ ) |
---|
1287 | { |
---|
1288 | for ( int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1289 | { |
---|
1290 | for ( int yuv=0 ; yuv<3 ; yuv++ ) |
---|
1291 | { |
---|
1292 | wpScalingParam *pwp = &(wp[e][i][yuv]); |
---|
1293 | pwp->bPresentFlag = false; |
---|
1294 | pwp->uiLog2WeightDenom = 0; |
---|
1295 | pwp->uiLog2WeightDenom = 0; |
---|
1296 | pwp->iWeight = 1; |
---|
1297 | pwp->iOffset = 0; |
---|
1298 | } |
---|
1299 | } |
---|
1300 | } |
---|
1301 | } |
---|
1302 | |
---|
1303 | /** init WP table |
---|
1304 | * \returns Void |
---|
1305 | */ |
---|
1306 | Void TComSlice::initWpScaling() |
---|
1307 | { |
---|
1308 | initWpScaling(m_weightPredTable); |
---|
1309 | } |
---|
1310 | |
---|
1311 | /** set WP tables |
---|
1312 | * \param wpScalingParam |
---|
1313 | * \returns Void |
---|
1314 | */ |
---|
1315 | Void TComSlice::initWpScaling(wpScalingParam wp[2][MAX_NUM_REF][3]) |
---|
1316 | { |
---|
1317 | for ( int e=0 ; e<2 ; e++ ) |
---|
1318 | { |
---|
1319 | for ( int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
1320 | { |
---|
1321 | for ( int yuv=0 ; yuv<3 ; yuv++ ) |
---|
1322 | { |
---|
1323 | wpScalingParam *pwp = &(wp[e][i][yuv]); |
---|
1324 | if ( !pwp->bPresentFlag ) { |
---|
1325 | // Inferring values not present : |
---|
1326 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
1327 | pwp->iOffset = 0; |
---|
1328 | } |
---|
1329 | |
---|
1330 | pwp->w = pwp->iWeight; |
---|
1331 | pwp->o = pwp->iOffset * (1 << (g_uiBitDepth-8)); |
---|
1332 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
1333 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
1334 | } |
---|
1335 | } |
---|
1336 | } |
---|
1337 | } |
---|
1338 | |
---|
1339 | /** get WP tables for weighted pred of LC |
---|
1340 | * \param iRefIdxLC |
---|
1341 | * \param *&wpScalingParam |
---|
1342 | * \returns Void |
---|
1343 | */ |
---|
1344 | Void TComSlice::getWpScalingLC( Int iRefIdx, wpScalingParam *&wp ) |
---|
1345 | { |
---|
1346 | wp = m_weightPredTableLC[iRefIdx]; |
---|
1347 | } |
---|
1348 | /** reset Default WP tables settings for LC : no weight. |
---|
1349 | * \param wpScalingParam |
---|
1350 | * \returns Void |
---|
1351 | */ |
---|
1352 | Void TComSlice::resetWpScalingLC(wpScalingParam wp[2*MAX_NUM_REF][3]) |
---|
1353 | { |
---|
1354 | for ( int i=0 ; i<2*MAX_NUM_REF ; i++ ) |
---|
1355 | { |
---|
1356 | for ( int yuv=0 ; yuv<3 ; yuv++ ) |
---|
1357 | { |
---|
1358 | wpScalingParam *pwp = &(wp[i][yuv]); |
---|
1359 | pwp->bPresentFlag = false; |
---|
1360 | pwp->uiLog2WeightDenom = 0; |
---|
1361 | pwp->uiLog2WeightDenom = 0; |
---|
1362 | pwp->iWeight = 1; |
---|
1363 | pwp->iOffset = 0; |
---|
1364 | } |
---|
1365 | } |
---|
1366 | } |
---|
1367 | /** set current WP tables settings for LC |
---|
1368 | * \returns Void |
---|
1369 | */ |
---|
1370 | Void TComSlice::setWpParamforLC() |
---|
1371 | { |
---|
1372 | for ( Int iRefIdx=0 ; iRefIdx<getNumRefIdx(REF_PIC_LIST_C) ; iRefIdx++ ) |
---|
1373 | { |
---|
1374 | RefPicList eRefPicList = (RefPicList)getListIdFromIdxOfLC(iRefIdx); |
---|
1375 | Int iCombRefIdx = getRefIdxFromIdxOfLC(iRefIdx); |
---|
1376 | |
---|
1377 | wpScalingParam *wp_src, *wp_dst; |
---|
1378 | getWpScalingLC(iRefIdx, wp_src); |
---|
1379 | getWpScaling(eRefPicList, iCombRefIdx, wp_dst); |
---|
1380 | copyWPtable(wp_src, wp_dst); |
---|
1381 | |
---|
1382 | if(eRefPicList == REF_PIC_LIST_0) |
---|
1383 | { |
---|
1384 | Int iRefIdxL1 = getRefIdxOfL1FromRefIdxOfL0(iCombRefIdx); |
---|
1385 | if(iRefIdxL1 >= 0) |
---|
1386 | { |
---|
1387 | getWpScaling(REF_PIC_LIST_1, iRefIdxL1, wp_dst); |
---|
1388 | copyWPtable(wp_src, wp_dst); |
---|
1389 | } |
---|
1390 | } |
---|
1391 | if(eRefPicList == REF_PIC_LIST_1) |
---|
1392 | { |
---|
1393 | Int iRefIdxL0 = getRefIdxOfL0FromRefIdxOfL1(iCombRefIdx); |
---|
1394 | if(iRefIdxL0 >= 0) |
---|
1395 | { |
---|
1396 | getWpScaling(REF_PIC_LIST_0, iRefIdxL0, wp_dst); |
---|
1397 | copyWPtable(wp_src, wp_dst); |
---|
1398 | } |
---|
1399 | } |
---|
1400 | } |
---|
1401 | initWpScaling(); |
---|
1402 | } |
---|
1403 | /** copy source WP tables to destination table for LC |
---|
1404 | * \param wpScalingParam *&wp_src : source |
---|
1405 | * \param wpScalingParam *&wp_dst : destination |
---|
1406 | * \returns Void |
---|
1407 | */ |
---|
1408 | Void TComSlice::copyWPtable(wpScalingParam *&wp_src, wpScalingParam *&wp_dst) |
---|
1409 | { |
---|
1410 | for ( Int iComp = 0; iComp < 3; iComp++ ) |
---|
1411 | { |
---|
1412 | wp_dst[iComp].uiLog2WeightDenom = (iComp==0) ? wp_src[0].uiLog2WeightDenom : wp_src[1].uiLog2WeightDenom; |
---|
1413 | wp_dst[iComp].bPresentFlag = wp_src[iComp].bPresentFlag; |
---|
1414 | wp_dst[iComp].iWeight = wp_src[iComp].iWeight; |
---|
1415 | wp_dst[iComp].iOffset = wp_src[iComp].iOffset; |
---|
1416 | } |
---|
1417 | } |
---|
1418 | |
---|
1419 | // ------------------------------------------------------------------------------------------------ |
---|
1420 | // Video parameter set (VPS) |
---|
1421 | // ------------------------------------------------------------------------------------------------ |
---|
1422 | #if VIDYO_VPS_INTEGRATION |
---|
1423 | TComVPS::TComVPS() |
---|
1424 | : m_VPSId ( 0) |
---|
1425 | , m_uiMaxTLayers ( 1) |
---|
1426 | , m_uiMaxLayers ( 1) |
---|
1427 | , m_bTemporalIdNestingFlag (false) |
---|
1428 | , m_uiExtensionType ( 0) |
---|
1429 | { |
---|
1430 | for( Int i = 0; i < MAX_LAYER_NUM; i++) |
---|
1431 | { |
---|
1432 | m_uiDependentLayer[i] = i? i-1: 0; |
---|
1433 | m_bDependentFlag[i] = false; |
---|
1434 | m_uiViewId[i] = 0; |
---|
1435 | m_bDepthFlag[i] = 0; |
---|
1436 | m_iViewOrderIdx[i] = 0; |
---|
1437 | } |
---|
1438 | |
---|
1439 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
1440 | { |
---|
1441 | m_numReorderPics[i] = 0; |
---|
1442 | m_uiMaxDecPicBuffering[i] = 0; |
---|
1443 | m_uiMaxLatencyIncrease[i] = 0; |
---|
1444 | } |
---|
1445 | } |
---|
1446 | |
---|
1447 | TComVPS::~TComVPS() |
---|
1448 | { |
---|
1449 | |
---|
1450 | |
---|
1451 | } |
---|
1452 | |
---|
1453 | #endif |
---|
1454 | |
---|
1455 | |
---|
1456 | // ------------------------------------------------------------------------------------------------ |
---|
1457 | // Sequence parameter set (SPS) |
---|
1458 | // ------------------------------------------------------------------------------------------------ |
---|
1459 | |
---|
1460 | TComSPS::TComSPS() |
---|
1461 | #if VIDYO_VPS_INTEGRATION |
---|
1462 | : m_VPSId ( 0) |
---|
1463 | , m_SPSId ( 0) |
---|
1464 | #else |
---|
1465 | : m_SPSId ( 0) |
---|
1466 | #endif |
---|
1467 | , m_ProfileIdc ( 0) |
---|
1468 | , m_LevelIdc ( 0) |
---|
1469 | , m_chromaFormatIdc (CHROMA_420) |
---|
1470 | , m_uiMaxTLayers ( 1) |
---|
1471 | // Structure |
---|
1472 | , m_picWidthInLumaSamples (352) |
---|
1473 | , m_picHeightInLumaSamples (288) |
---|
1474 | #if PIC_CROPPING |
---|
1475 | , m_picCroppingFlag (false) |
---|
1476 | , m_picCropLeftOffset ( 0) |
---|
1477 | , m_picCropRightOffset ( 0) |
---|
1478 | , m_picCropTopOffset ( 0) |
---|
1479 | , m_picCropBottomOffset ( 0) |
---|
1480 | #endif |
---|
1481 | , m_uiMaxCUWidth ( 32) |
---|
1482 | , m_uiMaxCUHeight ( 32) |
---|
1483 | , m_uiMaxCUDepth ( 3) |
---|
1484 | , m_uiMinTrDepth ( 0) |
---|
1485 | , m_uiMaxTrDepth ( 1) |
---|
1486 | #if RPS_IN_SPS |
---|
1487 | , m_bLongTermRefsPresent (false) |
---|
1488 | #endif |
---|
1489 | #if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
1490 | , m_numReorderFrames ( 0) |
---|
1491 | #endif |
---|
1492 | , m_iNumberOfUsableInterViewRefs( 0 ) |
---|
1493 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
1494 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
1495 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
1496 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
1497 | // Tool list |
---|
1498 | , m_usePCM (false) |
---|
1499 | , m_pcmLog2MaxSize ( 5) |
---|
1500 | , m_uiPCMLog2MinSize ( 7) |
---|
1501 | , m_bDisInter4x4 ( 1) |
---|
1502 | , m_bUseALF (false) |
---|
1503 | #if LCU_SYNTAX_ALF |
---|
1504 | , m_bALFCoefInSlice (false) |
---|
1505 | #endif |
---|
1506 | #if !PIC_CROPPING |
---|
1507 | , m_bUsePAD (false) |
---|
1508 | #endif |
---|
1509 | , m_bUseLMChroma (false) |
---|
1510 | , m_bUseLComb (false) |
---|
1511 | , m_bLCMod (false) |
---|
1512 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
1513 | , m_restrictedRefPicListsFlag ( 1) |
---|
1514 | , m_listsModificationPresentFlag( 0) |
---|
1515 | #endif |
---|
1516 | , m_uiBitDepth ( 8) |
---|
1517 | , m_uiBitIncrement ( 0) |
---|
1518 | #if H0736_AVC_STYLE_QP_RANGE |
---|
1519 | , m_qpBDOffsetY ( 0) |
---|
1520 | , m_qpBDOffsetC ( 0) |
---|
1521 | #endif |
---|
1522 | #if LOSSLESS_CODING |
---|
1523 | , m_useLossless (false) |
---|
1524 | #endif |
---|
1525 | , m_uiPCMBitDepthLuma ( 8) |
---|
1526 | , m_uiPCMBitDepthChroma ( 8) |
---|
1527 | , m_bPCMFilterDisableFlag (false) |
---|
1528 | , m_uiBitsForPOC ( 8) |
---|
1529 | , m_uiMaxTrSize ( 32) |
---|
1530 | , m_bLFCrossSliceBoundaryFlag (false) |
---|
1531 | , m_bUseSAO (false) |
---|
1532 | #if HHI_MPI |
---|
1533 | , m_bUseMVI (false) |
---|
1534 | #endif |
---|
1535 | , m_bLFCrossTileBoundaryFlag (false) |
---|
1536 | , m_iUniformSpacingIdr ( 0 ) |
---|
1537 | , m_iTileBoundaryIndependenceIdr ( 0 ) |
---|
1538 | , m_iNumColumnsMinus1 ( 0 ) |
---|
1539 | , m_puiColumnWidth ( NULL ) |
---|
1540 | , m_iNumRowsMinus1 ( 0 ) |
---|
1541 | , m_puiRowHeight ( NULL ) |
---|
1542 | , m_bTemporalIdNestingFlag (false) |
---|
1543 | , m_scalingListEnabledFlag (false) |
---|
1544 | #if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
1545 | , m_uiMaxDecFrameBuffering ( 0) |
---|
1546 | , m_uiMaxLatencyIncrease ( 0) |
---|
1547 | #endif |
---|
1548 | #if TILES_WPP_ENTRY_POINT_SIGNALLING |
---|
1549 | , m_tilesOrEntropyCodingSyncIdc( 0 ) |
---|
1550 | , m_numSubstreams ( 0 ) |
---|
1551 | #endif |
---|
1552 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1553 | , m_bUseDMM (false) |
---|
1554 | #endif |
---|
1555 | #if OL_DEPTHLIMIT_A0044 |
---|
1556 | , m_bDepthPartitionLimiting (false) |
---|
1557 | #endif |
---|
1558 | #if VSP_N |
---|
1559 | , m_bVspPresentFlag (false) |
---|
1560 | #if VSP_CFG |
---|
1561 | , m_bVspDepthPresentFlag (false) |
---|
1562 | #endif |
---|
1563 | #endif |
---|
1564 | { |
---|
1565 | // AMVP parameter |
---|
1566 | ::memset( m_aeAMVPMode, 0, sizeof( m_aeAMVPMode ) ); |
---|
1567 | #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
1568 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
1569 | { |
---|
1570 | m_uiMaxLatencyIncrease[i] = 0; |
---|
1571 | m_uiMaxDecPicBuffering[i] = 0; |
---|
1572 | m_numReorderPics[i] = 0; |
---|
1573 | } |
---|
1574 | #endif |
---|
1575 | |
---|
1576 | m_uiViewId = 0; |
---|
1577 | m_iViewOrderIdx = 0; |
---|
1578 | m_bDepth = false; |
---|
1579 | m_uiCamParPrecision = 0; |
---|
1580 | m_bCamParInSliceHeader = false; |
---|
1581 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
1582 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
1583 | |
---|
1584 | #if DEPTH_MAP_GENERATION |
---|
1585 | m_uiPredDepthMapGeneration = 0; |
---|
1586 | m_uiPdmPrecision = 0; |
---|
1587 | ::memset( m_aiPdmScaleNomDelta, 0x00, sizeof( m_aiPdmScaleNomDelta ) ); |
---|
1588 | ::memset( m_aiPdmOffset, 0x00, sizeof( m_aiPdmOffset ) ); |
---|
1589 | #endif |
---|
1590 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
1591 | m_uiMultiviewMvPredMode = 0; |
---|
1592 | #endif |
---|
1593 | |
---|
1594 | ::memset( m_aiUsableInterViewRefs, 0, sizeof( m_aiUsableInterViewRefs ) ); |
---|
1595 | } |
---|
1596 | |
---|
1597 | TComSPS::~TComSPS() |
---|
1598 | { |
---|
1599 | if( m_iNumColumnsMinus1 > 0 && m_iUniformSpacingIdr == 0 ) |
---|
1600 | { |
---|
1601 | delete [] m_puiColumnWidth; |
---|
1602 | m_puiColumnWidth = NULL; |
---|
1603 | } |
---|
1604 | if( m_iNumRowsMinus1 > 0 && m_iUniformSpacingIdr == 0 ) |
---|
1605 | { |
---|
1606 | delete [] m_puiRowHeight; |
---|
1607 | m_puiRowHeight = NULL; |
---|
1608 | } |
---|
1609 | } |
---|
1610 | |
---|
1611 | TComPPS::TComPPS() |
---|
1612 | : m_PPSId (0) |
---|
1613 | , m_SPSId (0) |
---|
1614 | , m_picInitQPMinus26 (0) |
---|
1615 | , m_useDQP (false) |
---|
1616 | , m_bConstrainedIntraPred (false) |
---|
1617 | , m_pcSPS (NULL) |
---|
1618 | , m_uiMaxCuDQPDepth (0) |
---|
1619 | , m_uiMinCuDQPSize (0) |
---|
1620 | , m_iChromaQpOffset (0) |
---|
1621 | , m_iChromaQpOffset2nd (0) |
---|
1622 | #if !RPS_IN_SPS |
---|
1623 | , m_bLongTermRefsPresent (false) |
---|
1624 | #endif |
---|
1625 | #if !H0566_TLA |
---|
1626 | , m_uiNumTlayerSwitchingFlags (0) |
---|
1627 | #endif |
---|
1628 | , m_iSliceGranularity (0) |
---|
1629 | , m_iTileBehaviorControlPresentFlag (0) |
---|
1630 | , m_bLFCrossTileBoundaryFlag (true) |
---|
1631 | , m_iColumnRowInfoPresent (0) |
---|
1632 | , m_iUniformSpacingIdr (0) |
---|
1633 | #if !REMOVE_TILE_DEPENDENCE |
---|
1634 | , m_iTileBoundaryIndependenceIdr (0) |
---|
1635 | #endif |
---|
1636 | , m_iNumColumnsMinus1 (0) |
---|
1637 | , m_puiColumnWidth (NULL) |
---|
1638 | , m_iNumRowsMinus1 (0) |
---|
1639 | , m_puiRowHeight (NULL) |
---|
1640 | #if !WPP_SIMPLIFICATION |
---|
1641 | , m_iEntropyCodingSynchro (0) |
---|
1642 | , m_bCabacIstateReset (false) |
---|
1643 | #endif |
---|
1644 | , m_iNumSubstreams (1) |
---|
1645 | #if MULTIBITS_DATA_HIDING |
---|
1646 | , m_signHideFlag(0) |
---|
1647 | , m_signHidingThreshold(0) |
---|
1648 | #endif |
---|
1649 | #if CABAC_INIT_FLAG |
---|
1650 | , m_cabacInitPresentFlag (false) |
---|
1651 | , m_encCABACTableIdx (0) |
---|
1652 | #if POZNAN_CABAC_INIT_FLAG_FIX |
---|
1653 | , m_encPrevPOC (0) |
---|
1654 | #endif |
---|
1655 | #endif |
---|
1656 | { |
---|
1657 | #if !H0566_TLA |
---|
1658 | for ( UInt i = 0; i < MAX_TLAYER; i++ ) |
---|
1659 | { |
---|
1660 | m_abTLayerSwitchingFlag[i] = false; |
---|
1661 | } |
---|
1662 | #endif |
---|
1663 | } |
---|
1664 | |
---|
1665 | TComPPS::~TComPPS() |
---|
1666 | { |
---|
1667 | if( m_iNumColumnsMinus1 > 0 && m_iUniformSpacingIdr == 0 ) |
---|
1668 | { |
---|
1669 | if (m_puiColumnWidth) delete [] m_puiColumnWidth; |
---|
1670 | m_puiColumnWidth = NULL; |
---|
1671 | } |
---|
1672 | if( m_iNumRowsMinus1 > 0 && m_iUniformSpacingIdr == 0 ) |
---|
1673 | { |
---|
1674 | if (m_puiRowHeight) delete [] m_puiRowHeight; |
---|
1675 | m_puiRowHeight = NULL; |
---|
1676 | } |
---|
1677 | } |
---|
1678 | |
---|
1679 | Void |
---|
1680 | TComSPS::initMultiviewSPS( UInt uiViewId, Int iViewOrderIdx, UInt uiCamParPrecision, Bool bCamParSlice, Int** aaiScale, Int** aaiOffset ) |
---|
1681 | { |
---|
1682 | AOT( uiViewId == 0 && iViewOrderIdx != 0 ); |
---|
1683 | AOT( uiViewId != 0 && iViewOrderIdx == 0 ); |
---|
1684 | AOT( uiViewId != 0 && !bCamParSlice && ( aaiScale == 0 || aaiOffset == 0 ) ); |
---|
1685 | |
---|
1686 | m_uiViewId = uiViewId; |
---|
1687 | m_iViewOrderIdx = iViewOrderIdx; |
---|
1688 | m_bDepth = false; |
---|
1689 | m_uiCamParPrecision = ( m_uiViewId ? uiCamParPrecision : 0 ); |
---|
1690 | m_bCamParInSliceHeader = ( m_uiViewId ? bCamParSlice : false ); |
---|
1691 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
1692 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
1693 | if( !m_bCamParInSliceHeader ) |
---|
1694 | { |
---|
1695 | for( UInt uiBaseViewId = 0; uiBaseViewId < m_uiViewId; uiBaseViewId++ ) |
---|
1696 | { |
---|
1697 | m_aaiCodedScale [ 0 ][ uiBaseViewId ] = aaiScale [ uiBaseViewId ][ m_uiViewId ]; |
---|
1698 | m_aaiCodedScale [ 1 ][ uiBaseViewId ] = aaiScale [ m_uiViewId ][ uiBaseViewId ]; |
---|
1699 | m_aaiCodedOffset[ 0 ][ uiBaseViewId ] = aaiOffset[ uiBaseViewId ][ m_uiViewId ]; |
---|
1700 | m_aaiCodedOffset[ 1 ][ uiBaseViewId ] = aaiOffset[ m_uiViewId ][ uiBaseViewId ]; |
---|
1701 | } |
---|
1702 | } |
---|
1703 | } |
---|
1704 | |
---|
1705 | Void |
---|
1706 | TComSPS::initMultiviewSPSDepth( UInt uiViewId, Int iViewOrderIdx ) |
---|
1707 | { |
---|
1708 | AOT( uiViewId == 0 && iViewOrderIdx != 0 ); |
---|
1709 | AOT( uiViewId != 0 && iViewOrderIdx == 0 ); |
---|
1710 | |
---|
1711 | m_uiViewId = uiViewId; |
---|
1712 | m_iViewOrderIdx = iViewOrderIdx; |
---|
1713 | m_bDepth = true; |
---|
1714 | m_uiCamParPrecision = 0; |
---|
1715 | m_bCamParInSliceHeader = false; |
---|
1716 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
1717 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
1718 | } |
---|
1719 | |
---|
1720 | #if DEPTH_MAP_GENERATION |
---|
1721 | Void |
---|
1722 | TComSPS::setPredDepthMapGeneration( UInt uiViewId, Bool bIsDepth, UInt uiPdmGenMode, UInt uiPdmMvPredMode, UInt uiPdmPrec, Int** aaiPdmScaleNomDelta, Int** aaiPdmOffset ) |
---|
1723 | { |
---|
1724 | AOF( m_uiViewId == uiViewId ); |
---|
1725 | AOF( m_bDepth == bIsDepth ); |
---|
1726 | AOT( ( uiViewId == 0 || bIsDepth ) && uiPdmGenMode ); |
---|
1727 | AOT( uiPdmGenMode && ( aaiPdmScaleNomDelta == 0 || aaiPdmOffset == 0 ) ); |
---|
1728 | AOT( uiPdmMvPredMode && uiPdmGenMode == 0 ); |
---|
1729 | |
---|
1730 | m_uiPredDepthMapGeneration = uiPdmGenMode; |
---|
1731 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
1732 | m_uiMultiviewMvPredMode = uiPdmMvPredMode; |
---|
1733 | #endif |
---|
1734 | |
---|
1735 | m_uiPdmPrecision = ( m_uiPredDepthMapGeneration ? uiPdmPrec : 0 ); |
---|
1736 | ::memset( m_aiPdmScaleNomDelta, 0x00, sizeof( m_aiPdmScaleNomDelta ) ); |
---|
1737 | ::memset( m_aiPdmOffset, 0x00, sizeof( m_aiPdmOffset ) ); |
---|
1738 | if( m_uiPredDepthMapGeneration ) |
---|
1739 | { |
---|
1740 | for( UInt uiBaseId = 0; uiBaseId < m_uiViewId; uiBaseId++ ) |
---|
1741 | { |
---|
1742 | m_aiPdmScaleNomDelta[ uiBaseId ] = aaiPdmScaleNomDelta[ m_uiViewId ][ uiBaseId ]; |
---|
1743 | m_aiPdmOffset [ uiBaseId ] = aaiPdmOffset [ m_uiViewId ][ uiBaseId ]; |
---|
1744 | } |
---|
1745 | } |
---|
1746 | } |
---|
1747 | #endif |
---|
1748 | |
---|
1749 | TComReferencePictureSet::TComReferencePictureSet() |
---|
1750 | : m_numberOfPictures (0) |
---|
1751 | , m_numberOfNegativePictures (0) |
---|
1752 | , m_numberOfPositivePictures (0) |
---|
1753 | , m_numberOfLongtermPictures (0) |
---|
1754 | , m_interRPSPrediction (0) |
---|
1755 | , m_deltaRIdxMinus1 (0) |
---|
1756 | , m_deltaRPS (0) |
---|
1757 | , m_numRefIdc (0) |
---|
1758 | { |
---|
1759 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
1760 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
1761 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
1762 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
1763 | } |
---|
1764 | |
---|
1765 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
1766 | { |
---|
1767 | } |
---|
1768 | |
---|
1769 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
1770 | { |
---|
1771 | m_used[bufferNum] = used; |
---|
1772 | } |
---|
1773 | |
---|
1774 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
1775 | { |
---|
1776 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
1777 | } |
---|
1778 | |
---|
1779 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
1780 | { |
---|
1781 | m_numberOfPictures = numberOfPictures; |
---|
1782 | } |
---|
1783 | |
---|
1784 | Int TComReferencePictureSet::getUsed(Int bufferNum) |
---|
1785 | { |
---|
1786 | return m_used[bufferNum]; |
---|
1787 | } |
---|
1788 | |
---|
1789 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) |
---|
1790 | { |
---|
1791 | return m_deltaPOC[bufferNum]; |
---|
1792 | } |
---|
1793 | |
---|
1794 | Int TComReferencePictureSet::getNumberOfPictures() |
---|
1795 | { |
---|
1796 | return m_numberOfPictures; |
---|
1797 | } |
---|
1798 | |
---|
1799 | Int TComReferencePictureSet::getPOC(Int bufferNum) |
---|
1800 | { |
---|
1801 | return m_POC[bufferNum]; |
---|
1802 | } |
---|
1803 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
1804 | { |
---|
1805 | m_POC[bufferNum] = POC; |
---|
1806 | } |
---|
1807 | |
---|
1808 | /** set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
1809 | * \param uiBufferNum |
---|
1810 | * \param iRefIdc |
---|
1811 | * \returns Void |
---|
1812 | */ |
---|
1813 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
1814 | { |
---|
1815 | m_refIdc[bufferNum] = refIdc; |
---|
1816 | } |
---|
1817 | |
---|
1818 | /** get the reference idc value at uiBufferNum |
---|
1819 | * \param uiBufferNum |
---|
1820 | * \returns Int |
---|
1821 | */ |
---|
1822 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) |
---|
1823 | { |
---|
1824 | return m_refIdc[bufferNum]; |
---|
1825 | } |
---|
1826 | |
---|
1827 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
1828 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
1829 | * +ve values are in increasing order. |
---|
1830 | * \returns Void |
---|
1831 | */ |
---|
1832 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
1833 | { |
---|
1834 | // sort in increasing order (smallest first) |
---|
1835 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
1836 | { |
---|
1837 | Int deltaPOC = getDeltaPOC(j); |
---|
1838 | Bool used = getUsed(j); |
---|
1839 | for (Int k=j-1; k >= 0; k--) |
---|
1840 | { |
---|
1841 | Int temp = getDeltaPOC(k); |
---|
1842 | if (deltaPOC < temp) |
---|
1843 | { |
---|
1844 | setDeltaPOC(k+1, temp); |
---|
1845 | setUsed(k+1, getUsed(k)); |
---|
1846 | setDeltaPOC(k, deltaPOC); |
---|
1847 | setUsed(k, used); |
---|
1848 | } |
---|
1849 | } |
---|
1850 | } |
---|
1851 | // flip the negative values to largest first |
---|
1852 | Int numNegPics = getNumberOfNegativePictures(); |
---|
1853 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
1854 | { |
---|
1855 | Int deltaPOC = getDeltaPOC(j); |
---|
1856 | Bool used = getUsed(j); |
---|
1857 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
1858 | setUsed(j, getUsed(k)); |
---|
1859 | setDeltaPOC(k, deltaPOC); |
---|
1860 | setUsed(k, used); |
---|
1861 | } |
---|
1862 | } |
---|
1863 | |
---|
1864 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
1865 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
1866 | * \returns Void |
---|
1867 | */ |
---|
1868 | Void TComReferencePictureSet::printDeltaPOC() |
---|
1869 | { |
---|
1870 | printf("DeltaPOC = { "); |
---|
1871 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
1872 | { |
---|
1873 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
1874 | } |
---|
1875 | if (getInterRPSPrediction()) |
---|
1876 | { |
---|
1877 | printf("}, RefIdc = { "); |
---|
1878 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
1879 | { |
---|
1880 | printf("%d ", getRefIdc(j)); |
---|
1881 | } |
---|
1882 | } |
---|
1883 | printf("}\n"); |
---|
1884 | } |
---|
1885 | |
---|
1886 | TComRPSList::TComRPSList() |
---|
1887 | { |
---|
1888 | } |
---|
1889 | |
---|
1890 | TComRPSList::~TComRPSList() |
---|
1891 | { |
---|
1892 | } |
---|
1893 | |
---|
1894 | Void TComRPSList::create( Int numberOfReferencePictureSets) |
---|
1895 | { |
---|
1896 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
1897 | m_referencePictureSets = new TComReferencePictureSet[numberOfReferencePictureSets]; |
---|
1898 | } |
---|
1899 | |
---|
1900 | Void TComRPSList::destroy() |
---|
1901 | { |
---|
1902 | delete [] m_referencePictureSets; |
---|
1903 | m_numberOfReferencePictureSets = 0; |
---|
1904 | m_referencePictureSets = NULL; |
---|
1905 | } |
---|
1906 | |
---|
1907 | |
---|
1908 | |
---|
1909 | TComReferencePictureSet* TComRPSList::getReferencePictureSet(Int referencePictureSetNum) |
---|
1910 | { |
---|
1911 | return &m_referencePictureSets[referencePictureSetNum]; |
---|
1912 | } |
---|
1913 | |
---|
1914 | Int TComRPSList::getNumberOfReferencePictureSets() |
---|
1915 | { |
---|
1916 | return m_numberOfReferencePictureSets; |
---|
1917 | } |
---|
1918 | |
---|
1919 | Void TComRPSList::setNumberOfReferencePictureSets(Int numberOfReferencePictureSets) |
---|
1920 | { |
---|
1921 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
1922 | } |
---|
1923 | |
---|
1924 | TComRefPicListModification::TComRefPicListModification() |
---|
1925 | : m_bRefPicListModificationFlagL0 (false) |
---|
1926 | , m_bRefPicListModificationFlagL1 (false) |
---|
1927 | #if !H0137_0138_LIST_MODIFICATION |
---|
1928 | , m_uiNumberOfRefPicListModificationsL0 (0) |
---|
1929 | , m_uiNumberOfRefPicListModificationsL1 (0) |
---|
1930 | #endif |
---|
1931 | { |
---|
1932 | #if !H0137_0138_LIST_MODIFICATION |
---|
1933 | ::memset( m_ListIdcL0, 0, sizeof(m_ListIdcL0) ); |
---|
1934 | #endif |
---|
1935 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
1936 | #if !H0137_0138_LIST_MODIFICATION |
---|
1937 | ::memset( m_ListIdcL1, 0, sizeof(m_ListIdcL1) ); |
---|
1938 | #endif |
---|
1939 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
1940 | } |
---|
1941 | |
---|
1942 | TComRefPicListModification::~TComRefPicListModification() |
---|
1943 | { |
---|
1944 | } |
---|
1945 | |
---|
1946 | TComAPS::TComAPS() |
---|
1947 | { |
---|
1948 | m_apsID = 0; |
---|
1949 | m_bAlfEnabled = false; |
---|
1950 | m_bSaoEnabled = false; |
---|
1951 | m_pSaoParam = NULL; |
---|
1952 | #if LCU_SYNTAX_ALF |
---|
1953 | m_alfParamSet = NULL; |
---|
1954 | #else |
---|
1955 | m_pAlfParam = NULL; |
---|
1956 | #endif |
---|
1957 | m_scalingList = NULL; |
---|
1958 | m_scalingListEnabled = false; |
---|
1959 | } |
---|
1960 | |
---|
1961 | TComAPS::~TComAPS() |
---|
1962 | { |
---|
1963 | |
---|
1964 | } |
---|
1965 | |
---|
1966 | TComAPS& TComAPS::operator= (const TComAPS& src) |
---|
1967 | { |
---|
1968 | m_apsID = src.m_apsID; |
---|
1969 | m_loopFilterOffsetInAPS = src.m_loopFilterOffsetInAPS; |
---|
1970 | m_loopFilterDisable = src.m_loopFilterDisable; |
---|
1971 | m_loopFilterBetaOffsetDiv2 = src.m_loopFilterBetaOffsetDiv2; |
---|
1972 | m_loopFilterTcOffsetDiv2 = src.m_loopFilterTcOffsetDiv2; |
---|
1973 | m_bAlfEnabled = src.m_bAlfEnabled; |
---|
1974 | m_bSaoEnabled = src.m_bSaoEnabled; |
---|
1975 | m_pSaoParam = src.m_pSaoParam; |
---|
1976 | #if LCU_SYNTAX_ALF |
---|
1977 | m_alfParamSet = src.m_alfParamSet; |
---|
1978 | #else |
---|
1979 | m_pAlfParam = src.m_pAlfParam; |
---|
1980 | #endif |
---|
1981 | m_scalingList = src.m_scalingList; |
---|
1982 | m_scalingListEnabled = src.m_scalingListEnabled; |
---|
1983 | #if SAO_UNIT_INTERLEAVING |
---|
1984 | m_saoInterleavingFlag = src.m_saoInterleavingFlag; |
---|
1985 | #endif |
---|
1986 | |
---|
1987 | return *this; |
---|
1988 | } |
---|
1989 | |
---|
1990 | Void TComAPS::createSaoParam() |
---|
1991 | { |
---|
1992 | m_pSaoParam = new SAOParam; |
---|
1993 | } |
---|
1994 | |
---|
1995 | Void TComAPS::destroySaoParam() |
---|
1996 | { |
---|
1997 | if(m_pSaoParam != NULL) |
---|
1998 | { |
---|
1999 | delete m_pSaoParam; |
---|
2000 | m_pSaoParam = NULL; |
---|
2001 | } |
---|
2002 | } |
---|
2003 | |
---|
2004 | Void TComAPS::createAlfParam() |
---|
2005 | { |
---|
2006 | #if LCU_SYNTAX_ALF |
---|
2007 | m_alfParamSet = new AlfParamSet; |
---|
2008 | #else |
---|
2009 | m_pAlfParam = new ALFParam; |
---|
2010 | #endif |
---|
2011 | } |
---|
2012 | Void TComAPS::destroyAlfParam() |
---|
2013 | { |
---|
2014 | #if LCU_SYNTAX_ALF |
---|
2015 | if(m_alfParamSet != NULL) |
---|
2016 | { |
---|
2017 | delete m_alfParamSet; |
---|
2018 | m_alfParamSet = NULL; |
---|
2019 | } |
---|
2020 | #else |
---|
2021 | if(m_pAlfParam != NULL) |
---|
2022 | { |
---|
2023 | delete m_pAlfParam; |
---|
2024 | m_pAlfParam = NULL; |
---|
2025 | } |
---|
2026 | #endif |
---|
2027 | } |
---|
2028 | |
---|
2029 | Void TComAPS::createScalingList() |
---|
2030 | { |
---|
2031 | m_scalingList = new TComScalingList; |
---|
2032 | } |
---|
2033 | Void TComAPS::destroyScalingList() |
---|
2034 | { |
---|
2035 | delete m_scalingList; |
---|
2036 | } |
---|
2037 | |
---|
2038 | TComScalingList::TComScalingList() |
---|
2039 | { |
---|
2040 | init(); |
---|
2041 | } |
---|
2042 | TComScalingList::~TComScalingList() |
---|
2043 | { |
---|
2044 | destroy(); |
---|
2045 | } |
---|
2046 | |
---|
2047 | /** set default quantization matrix to array |
---|
2048 | */ |
---|
2049 | Void TComSlice::setDefaultScalingList() |
---|
2050 | { |
---|
2051 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2052 | { |
---|
2053 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
2054 | { |
---|
2055 | getScalingList()->processDefaultMarix(sizeId, listId); |
---|
2056 | } |
---|
2057 | } |
---|
2058 | } |
---|
2059 | /** check if use default quantization matrix |
---|
2060 | * \returns true if use default quantization matrix in all size |
---|
2061 | */ |
---|
2062 | #if SCALING_LIST |
---|
2063 | Bool TComSlice::checkDefaultScalingList() |
---|
2064 | { |
---|
2065 | UInt defaultCounter=0; |
---|
2066 | |
---|
2067 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2068 | { |
---|
2069 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
2070 | { |
---|
2071 | if(getScalingList()->getUseDefaultScalingMatrixFlag(sizeId,listId)) |
---|
2072 | { |
---|
2073 | defaultCounter++; |
---|
2074 | } |
---|
2075 | } |
---|
2076 | } |
---|
2077 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? true : false; // -4 for 32x32 |
---|
2078 | } |
---|
2079 | #else |
---|
2080 | Bool TComSlice::checkDefaultScalingList() |
---|
2081 | { |
---|
2082 | UInt i; |
---|
2083 | Int *dst=0; |
---|
2084 | Int *src=0; |
---|
2085 | UInt defaultCounter=0; |
---|
2086 | |
---|
2087 | //4x4 |
---|
2088 | for(i=0;i<SCALING_LIST_NUM;i++) |
---|
2089 | { |
---|
2090 | src = (i<3) ? g_quantIntraDefault4x4 : g_quantInterDefault4x4; |
---|
2091 | dst = getScalingList()->getScalingListAddress(SCALING_LIST_4x4,i); |
---|
2092 | if(::memcmp(dst,src,sizeof(UInt)*16) == 0) defaultCounter++; |
---|
2093 | } |
---|
2094 | |
---|
2095 | //8x8 |
---|
2096 | for(i=0;i<SCALING_LIST_NUM;i++) |
---|
2097 | { |
---|
2098 | src = (i<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2099 | dst = getScalingList()->getScalingListAddress(SCALING_LIST_8x8,i); |
---|
2100 | if(::memcmp(dst,src,sizeof(UInt)*64) == 0) defaultCounter++; |
---|
2101 | } |
---|
2102 | //16x16 |
---|
2103 | for(i=0;i<SCALING_LIST_NUM;i++) |
---|
2104 | { |
---|
2105 | src = (i<3) ? g_quantIntraDefault16x16 : g_quantInterDefault16x16; |
---|
2106 | dst = getScalingList()->getScalingListAddress(SCALING_LIST_16x16,i); |
---|
2107 | if(::memcmp(dst,src,sizeof(UInt)*256) == 0) defaultCounter++; |
---|
2108 | } |
---|
2109 | //32x32 |
---|
2110 | for(i=0;i<SCALING_LIST_NUM_32x32;i++) |
---|
2111 | { |
---|
2112 | src = (i<1) ? g_quantIntraDefault32x32 : g_quantInterDefault32x32; |
---|
2113 | dst = getScalingList()->getScalingListAddress(SCALING_LIST_32x32,i*3); |
---|
2114 | if(::memcmp(dst,src,sizeof(UInt)*1024) == 0) defaultCounter++; |
---|
2115 | } |
---|
2116 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? true : false; // -4 for 32x32 |
---|
2117 | } |
---|
2118 | #endif |
---|
2119 | /** get scaling matrix from RefMatrixID |
---|
2120 | * \param sizeId size index |
---|
2121 | * \param Index of input matrix |
---|
2122 | * \param Index of reference matrix |
---|
2123 | */ |
---|
2124 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
2125 | { |
---|
2126 | #if SCALING_LIST |
---|
2127 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListAddress(sizeId, refListId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
2128 | #else |
---|
2129 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListAddress(sizeId, refListId),sizeof(Int)*g_scalingListSize[sizeId]); |
---|
2130 | #endif |
---|
2131 | } |
---|
2132 | /** parse syntax infomation |
---|
2133 | * \param pchFile syntax infomation |
---|
2134 | * \returns false if successful |
---|
2135 | */ |
---|
2136 | Bool TComScalingList::xParseScalingList(char* pchFile) |
---|
2137 | { |
---|
2138 | FILE *fp; |
---|
2139 | Char line[1024]; |
---|
2140 | UInt sizeIdc,listIdc; |
---|
2141 | UInt i,size = 0; |
---|
2142 | Int *src=0,data; |
---|
2143 | Char *ret; |
---|
2144 | UInt retval; |
---|
2145 | |
---|
2146 | if((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
2147 | { |
---|
2148 | printf("can't open file %s :: set Default Matrix\n",pchFile); |
---|
2149 | return true; |
---|
2150 | } |
---|
2151 | |
---|
2152 | for(sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
2153 | { |
---|
2154 | #if SCALING_LIST |
---|
2155 | size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
2156 | #else |
---|
2157 | size = g_scalingListSize[sizeIdc]; |
---|
2158 | #endif |
---|
2159 | for(listIdc = 0; listIdc < g_scalingListNum[sizeIdc]; listIdc++) |
---|
2160 | { |
---|
2161 | src = getScalingListAddress(sizeIdc, listIdc); |
---|
2162 | |
---|
2163 | fseek(fp,0,0); |
---|
2164 | do |
---|
2165 | { |
---|
2166 | ret = fgets(line, 1024, fp); |
---|
2167 | if ((ret==NULL)||(strstr(line, MatrixType[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
2168 | { |
---|
2169 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
2170 | return true; |
---|
2171 | } |
---|
2172 | } |
---|
2173 | while (strstr(line, MatrixType[sizeIdc][listIdc]) == NULL); |
---|
2174 | for (i=0; i<size; i++) |
---|
2175 | { |
---|
2176 | retval = fscanf(fp, "%d,", &data); |
---|
2177 | if (retval!=1) |
---|
2178 | { |
---|
2179 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
2180 | return true; |
---|
2181 | } |
---|
2182 | src[i] = data; |
---|
2183 | } |
---|
2184 | #if SCALING_LIST |
---|
2185 | //set DC value for default matrix check |
---|
2186 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
2187 | |
---|
2188 | if(sizeIdc > SCALING_LIST_8x8) |
---|
2189 | { |
---|
2190 | fseek(fp,0,0); |
---|
2191 | do |
---|
2192 | { |
---|
2193 | ret = fgets(line, 1024, fp); |
---|
2194 | if ((ret==NULL)||(strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
2195 | { |
---|
2196 | printf("Error: can't read DC :: set Default Matrix\n"); |
---|
2197 | return true; |
---|
2198 | } |
---|
2199 | } |
---|
2200 | while (strstr(line, MatrixType_DC[sizeIdc][listIdc]) == NULL); |
---|
2201 | retval = fscanf(fp, "%d,", &data); |
---|
2202 | if (retval!=1) |
---|
2203 | { |
---|
2204 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
2205 | return true; |
---|
2206 | } |
---|
2207 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
2208 | setScalingListDC(sizeIdc,listIdc,data); |
---|
2209 | } |
---|
2210 | #endif |
---|
2211 | } |
---|
2212 | } |
---|
2213 | fclose(fp); |
---|
2214 | return false; |
---|
2215 | } |
---|
2216 | |
---|
2217 | /** initialization process of quantization matrix array |
---|
2218 | */ |
---|
2219 | Void TComScalingList::init() |
---|
2220 | { |
---|
2221 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2222 | { |
---|
2223 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2224 | { |
---|
2225 | #if SCALING_LIST |
---|
2226 | m_scalingListCoef[sizeId][listId] = new Int [min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])]; |
---|
2227 | #else |
---|
2228 | m_scalingListCoef[sizeId][listId] = new Int [g_scalingListSize[sizeId]]; |
---|
2229 | #endif |
---|
2230 | } |
---|
2231 | } |
---|
2232 | m_scalingListCoef[SCALING_LIST_32x32][3] = m_scalingListCoef[SCALING_LIST_32x32][1]; // copy address for 32x32 |
---|
2233 | } |
---|
2234 | /** destroy quantization matrix array |
---|
2235 | */ |
---|
2236 | Void TComScalingList::destroy() |
---|
2237 | { |
---|
2238 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2239 | { |
---|
2240 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2241 | { |
---|
2242 | if(m_scalingListCoef[sizeId][listId]) delete [] m_scalingListCoef[sizeId][listId]; |
---|
2243 | } |
---|
2244 | } |
---|
2245 | } |
---|
2246 | /** get default address of quantization matrix |
---|
2247 | * \param sizeId size index |
---|
2248 | * \param listId list index |
---|
2249 | * \returns pointer of quantization matrix |
---|
2250 | */ |
---|
2251 | Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
2252 | { |
---|
2253 | Int *src = 0; |
---|
2254 | switch(sizeId) |
---|
2255 | { |
---|
2256 | case SCALING_LIST_4x4: |
---|
2257 | src = (listId<3) ? g_quantIntraDefault4x4 : g_quantInterDefault4x4; |
---|
2258 | break; |
---|
2259 | case SCALING_LIST_8x8: |
---|
2260 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2261 | break; |
---|
2262 | #if SCALING_LIST |
---|
2263 | case SCALING_LIST_16x16: |
---|
2264 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2265 | break; |
---|
2266 | case SCALING_LIST_32x32: |
---|
2267 | src = (listId<1) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2268 | break; |
---|
2269 | #else |
---|
2270 | case SCALING_LIST_16x16: |
---|
2271 | src = (listId<3) ? g_quantIntraDefault16x16 : g_quantInterDefault16x16; |
---|
2272 | break; |
---|
2273 | case SCALING_LIST_32x32: |
---|
2274 | src = (listId<1) ? g_quantIntraDefault32x32 : g_quantInterDefault32x32; |
---|
2275 | break; |
---|
2276 | #endif |
---|
2277 | default: |
---|
2278 | assert(0); |
---|
2279 | src = NULL; |
---|
2280 | break; |
---|
2281 | } |
---|
2282 | return src; |
---|
2283 | } |
---|
2284 | /** process of default matrix |
---|
2285 | * \param sizeId size index |
---|
2286 | * \param Index of input matrix |
---|
2287 | */ |
---|
2288 | Void TComScalingList::processDefaultMarix(UInt sizeId, UInt listId) |
---|
2289 | { |
---|
2290 | #if SCALING_LIST |
---|
2291 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
2292 | setUseDefaultScalingMatrixFlag(sizeId,listId,true); |
---|
2293 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
2294 | #else |
---|
2295 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*(Int)g_scalingListSize[sizeId]); |
---|
2296 | #endif |
---|
2297 | } |
---|
2298 | #if SCALING_LIST |
---|
2299 | /** check DC value of matrix for default matrix signaling |
---|
2300 | */ |
---|
2301 | Void TComScalingList::checkDcOfMatrix() |
---|
2302 | { |
---|
2303 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2304 | { |
---|
2305 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2306 | { |
---|
2307 | setUseDefaultScalingMatrixFlag(sizeId,listId,false); |
---|
2308 | //check default matrix? |
---|
2309 | if(getScalingListDC(sizeId,listId) == 0) |
---|
2310 | { |
---|
2311 | processDefaultMarix(sizeId, listId); |
---|
2312 | } |
---|
2313 | } |
---|
2314 | } |
---|
2315 | } |
---|
2316 | #endif |
---|
2317 | |
---|
2318 | ParameterSetManager::ParameterSetManager() |
---|
2319 | : m_spsMap(MAX_NUM_SPS) |
---|
2320 | , m_ppsMap(MAX_NUM_PPS) |
---|
2321 | , m_apsMap(MAX_NUM_APS) |
---|
2322 | #if VIDYO_VPS_INTEGRATION |
---|
2323 | , m_vpsMap(MAX_NUM_VPS) |
---|
2324 | #endif |
---|
2325 | { |
---|
2326 | } |
---|
2327 | |
---|
2328 | |
---|
2329 | ParameterSetManager::~ParameterSetManager() |
---|
2330 | { |
---|
2331 | } |
---|
2332 | |
---|
2333 | //! \} |
---|