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