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