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 | #if LGE_ILLUCOMP_DEPTH_C0046 |
---|
1385 | Double dThresholdOrgSAD = getIsDepth() ? 0.1 : 0.05; |
---|
1386 | #else |
---|
1387 | double dThresholdOrgSAD = 0.05; |
---|
1388 | #endif |
---|
1389 | // Histogram building - luminance |
---|
1390 | for ( Int y = 0; y < iHeight; y++) |
---|
1391 | { |
---|
1392 | for ( Int x = 0; x < iWidth; x++) |
---|
1393 | { |
---|
1394 | aiCurrHist[pCurrY[x]]++; |
---|
1395 | aiRefOrgHist[pRefOrgY[x]]++; |
---|
1396 | } |
---|
1397 | pCurrY += iCurrStride; |
---|
1398 | pRefOrgY += iRefStride; |
---|
1399 | } |
---|
1400 | // Calc SAD |
---|
1401 | for (Int i = 0; i < iMaxPelValue; i++) |
---|
1402 | { |
---|
1403 | iSumOrgSAD += abs(aiCurrHist[i] - aiRefOrgHist[i]); |
---|
1404 | } |
---|
1405 | // Setting |
---|
1406 | if ( iSumOrgSAD > Int(dThresholdOrgSAD * iWidth * iHeight) ) |
---|
1407 | { |
---|
1408 | m_bApplyIC = true; |
---|
1409 | } |
---|
1410 | else |
---|
1411 | { |
---|
1412 | m_bApplyIC = false; |
---|
1413 | } |
---|
1414 | } |
---|
1415 | xFree(aiCurrHist); |
---|
1416 | xFree(aiRefOrgHist); |
---|
1417 | aiCurrHist = NULL; |
---|
1418 | aiRefOrgHist = NULL; |
---|
1419 | } |
---|
1420 | #endif |
---|
1421 | |
---|
1422 | // ------------------------------------------------------------------------------------------------ |
---|
1423 | // Video parameter set (VPS) |
---|
1424 | // ------------------------------------------------------------------------------------------------ |
---|
1425 | #if QC_MVHEVC_B0046 |
---|
1426 | TComVPS::TComVPS() |
---|
1427 | : m_VPSId ( 0) |
---|
1428 | , m_uiMaxTLayers ( 1) |
---|
1429 | , m_uiMaxLayers ( 1) |
---|
1430 | , m_bTemporalIdNestingFlag (false) |
---|
1431 | , m_uiNumHRDParameter ( 0) |
---|
1432 | , m_numAddiLayerOperationPoints (2) |
---|
1433 | , m_numAddiProLevelSets ( 1) |
---|
1434 | { |
---|
1435 | for( Int i = 0; i < MAX_LAYER_NUM; i++) |
---|
1436 | { |
---|
1437 | m_numOpLayerIdMinus1[i] = 0; |
---|
1438 | if(i) |
---|
1439 | m_numDirectRefLayer[i] = 1; |
---|
1440 | else |
---|
1441 | m_numDirectRefLayer[i] = 0; |
---|
1442 | for( Int j = 0; j < MAX_LAYER_NUM; j++) |
---|
1443 | { |
---|
1444 | m_numDirectRefID[i][j] = 0; |
---|
1445 | m_numOpLayerId[i][j] = 0; |
---|
1446 | } |
---|
1447 | m_uiViewId[i] = 0; |
---|
1448 | m_iViewOrderIdx[i] = 0; |
---|
1449 | } |
---|
1450 | |
---|
1451 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
1452 | { |
---|
1453 | m_numReorderPics[i] = 0; |
---|
1454 | m_uiMaxDecPicBuffering[i] = 0; |
---|
1455 | m_uiMaxLatencyIncrease[i] = 0; |
---|
1456 | } |
---|
1457 | } |
---|
1458 | |
---|
1459 | TComVPS::~TComVPS() |
---|
1460 | { |
---|
1461 | } |
---|
1462 | #else |
---|
1463 | #if VIDYO_VPS_INTEGRATION |
---|
1464 | TComVPS::TComVPS() |
---|
1465 | : m_VPSId ( 0) |
---|
1466 | , m_uiMaxTLayers ( 1) |
---|
1467 | , m_uiMaxLayers ( 1) |
---|
1468 | , m_bTemporalIdNestingFlag (false) |
---|
1469 | , m_uiExtensionType ( 0) |
---|
1470 | { |
---|
1471 | for( Int i = 0; i < MAX_LAYER_NUM; i++) |
---|
1472 | { |
---|
1473 | m_uiDependentLayer[i] = i? i-1: 0; |
---|
1474 | m_bDependentFlag[i] = false; |
---|
1475 | m_uiViewId[i] = 0; |
---|
1476 | m_bDepthFlag[i] = 0; |
---|
1477 | m_iViewOrderIdx[i] = 0; |
---|
1478 | } |
---|
1479 | |
---|
1480 | for( Int i = 0; i < MAX_TLAYER; i++) |
---|
1481 | { |
---|
1482 | m_numReorderPics[i] = 0; |
---|
1483 | m_uiMaxDecPicBuffering[i] = 0; |
---|
1484 | m_uiMaxLatencyIncrease[i] = 0; |
---|
1485 | } |
---|
1486 | } |
---|
1487 | |
---|
1488 | TComVPS::~TComVPS() |
---|
1489 | { |
---|
1490 | |
---|
1491 | |
---|
1492 | } |
---|
1493 | |
---|
1494 | #endif |
---|
1495 | #endif |
---|
1496 | |
---|
1497 | // ------------------------------------------------------------------------------------------------ |
---|
1498 | // Sequence parameter set (SPS) |
---|
1499 | // ------------------------------------------------------------------------------------------------ |
---|
1500 | |
---|
1501 | TComSPS::TComSPS() |
---|
1502 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
1503 | : m_VPSId ( 0) |
---|
1504 | , m_SPSId ( 0) |
---|
1505 | #else |
---|
1506 | : m_SPSId ( 0) |
---|
1507 | #endif |
---|
1508 | , m_ProfileIdc ( 0) |
---|
1509 | , m_LevelIdc ( 0) |
---|
1510 | , m_chromaFormatIdc (CHROMA_420) |
---|
1511 | , m_uiMaxTLayers ( 1) |
---|
1512 | // Structure |
---|
1513 | , m_picWidthInLumaSamples (352) |
---|
1514 | , m_picHeightInLumaSamples (288) |
---|
1515 | #if PIC_CROPPING |
---|
1516 | , m_picCroppingFlag (false) |
---|
1517 | , m_picCropLeftOffset ( 0) |
---|
1518 | , m_picCropRightOffset ( 0) |
---|
1519 | , m_picCropTopOffset ( 0) |
---|
1520 | , m_picCropBottomOffset ( 0) |
---|
1521 | #endif |
---|
1522 | , m_uiMaxCUWidth ( 32) |
---|
1523 | , m_uiMaxCUHeight ( 32) |
---|
1524 | , m_uiMaxCUDepth ( 3) |
---|
1525 | , m_uiMinTrDepth ( 0) |
---|
1526 | , m_uiMaxTrDepth ( 1) |
---|
1527 | #if RPS_IN_SPS |
---|
1528 | , m_bLongTermRefsPresent (false) |
---|
1529 | #endif |
---|
1530 | #if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
1531 | , m_numReorderFrames ( 0) |
---|
1532 | #endif |
---|
1533 | , m_iNumberOfUsableInterViewRefs( 0 ) |
---|
1534 | , m_uiQuadtreeTULog2MaxSize ( 0) |
---|
1535 | , m_uiQuadtreeTULog2MinSize ( 0) |
---|
1536 | , m_uiQuadtreeTUMaxDepthInter ( 0) |
---|
1537 | , m_uiQuadtreeTUMaxDepthIntra ( 0) |
---|
1538 | // Tool list |
---|
1539 | , m_usePCM (false) |
---|
1540 | , m_pcmLog2MaxSize ( 5) |
---|
1541 | , m_uiPCMLog2MinSize ( 7) |
---|
1542 | , m_bDisInter4x4 ( 1) |
---|
1543 | , m_bUseALF (false) |
---|
1544 | #if LCU_SYNTAX_ALF |
---|
1545 | , m_bALFCoefInSlice (false) |
---|
1546 | #endif |
---|
1547 | #if !PIC_CROPPING |
---|
1548 | , m_bUsePAD (false) |
---|
1549 | #endif |
---|
1550 | , m_bUseLMChroma (false) |
---|
1551 | , m_bUseLComb (false) |
---|
1552 | , m_bLCMod (false) |
---|
1553 | #if H0412_REF_PIC_LIST_RESTRICTION |
---|
1554 | #if QC_MVHEVC_B0046 |
---|
1555 | , m_restrictedRefPicListsFlag ( 0) |
---|
1556 | #else |
---|
1557 | , m_restrictedRefPicListsFlag ( 1) |
---|
1558 | #endif |
---|
1559 | , m_listsModificationPresentFlag( 0) |
---|
1560 | #endif |
---|
1561 | , m_uiBitDepth ( 8) |
---|
1562 | , m_uiBitIncrement ( 0) |
---|
1563 | #if H0736_AVC_STYLE_QP_RANGE |
---|
1564 | , m_qpBDOffsetY ( 0) |
---|
1565 | , m_qpBDOffsetC ( 0) |
---|
1566 | #endif |
---|
1567 | #if LOSSLESS_CODING |
---|
1568 | , m_useLossless (false) |
---|
1569 | #endif |
---|
1570 | , m_uiPCMBitDepthLuma ( 8) |
---|
1571 | , m_uiPCMBitDepthChroma ( 8) |
---|
1572 | , m_bPCMFilterDisableFlag (false) |
---|
1573 | , m_uiBitsForPOC ( 8) |
---|
1574 | , m_uiMaxTrSize ( 32) |
---|
1575 | , m_bLFCrossSliceBoundaryFlag (false) |
---|
1576 | , m_bUseSAO (false) |
---|
1577 | #if HHI_MPI |
---|
1578 | , m_bUseMVI (false) |
---|
1579 | #endif |
---|
1580 | , m_bLFCrossTileBoundaryFlag (false) |
---|
1581 | , m_iUniformSpacingIdr ( 0 ) |
---|
1582 | , m_iTileBoundaryIndependenceIdr ( 0 ) |
---|
1583 | , m_iNumColumnsMinus1 ( 0 ) |
---|
1584 | , m_puiColumnWidth ( NULL ) |
---|
1585 | , m_iNumRowsMinus1 ( 0 ) |
---|
1586 | , m_puiRowHeight ( NULL ) |
---|
1587 | , m_bTemporalIdNestingFlag (false) |
---|
1588 | , m_scalingListEnabledFlag (false) |
---|
1589 | #if !H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
1590 | , m_uiMaxDecFrameBuffering ( 0) |
---|
1591 | , m_uiMaxLatencyIncrease ( 0) |
---|
1592 | #endif |
---|
1593 | #if TILES_WPP_ENTRY_POINT_SIGNALLING |
---|
1594 | , m_tilesOrEntropyCodingSyncIdc( 0 ) |
---|
1595 | , m_numSubstreams ( 0 ) |
---|
1596 | #endif |
---|
1597 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1598 | , m_bUseDMM (false) |
---|
1599 | #endif |
---|
1600 | #if FLEX_CODING_ORDER_M23723 && HHI_DMM_PRED_TEX |
---|
1601 | , m_bUseDMM34 (false) |
---|
1602 | #endif |
---|
1603 | #if OL_QTLIMIT_PREDCODING_B0068 |
---|
1604 | , m_bUseQTLPC (false) |
---|
1605 | #endif |
---|
1606 | { |
---|
1607 | // AMVP parameter |
---|
1608 | ::memset( m_aeAMVPMode, 0, sizeof( m_aeAMVPMode ) ); |
---|
1609 | #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER |
---|
1610 | for ( Int i = 0; i < MAX_TLAYER; i++ ) |
---|
1611 | { |
---|
1612 | m_uiMaxLatencyIncrease[i] = 0; |
---|
1613 | m_uiMaxDecPicBuffering[i] = 0; |
---|
1614 | m_numReorderPics[i] = 0; |
---|
1615 | } |
---|
1616 | #endif |
---|
1617 | |
---|
1618 | m_uiViewId = 0; |
---|
1619 | m_iViewOrderIdx = 0; |
---|
1620 | m_bDepth = false; |
---|
1621 | m_uiCamParPrecision = 0; |
---|
1622 | m_bCamParInSliceHeader = false; |
---|
1623 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
1624 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
1625 | |
---|
1626 | #if DEPTH_MAP_GENERATION |
---|
1627 | m_uiPredDepthMapGeneration = 0; |
---|
1628 | m_uiPdmPrecision = 0; |
---|
1629 | ::memset( m_aiPdmScaleNomDelta, 0x00, sizeof( m_aiPdmScaleNomDelta ) ); |
---|
1630 | ::memset( m_aiPdmOffset, 0x00, sizeof( m_aiPdmOffset ) ); |
---|
1631 | #endif |
---|
1632 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
1633 | m_uiMultiviewMvPredMode = 0; |
---|
1634 | #endif |
---|
1635 | |
---|
1636 | ::memset( m_aiUsableInterViewRefs, 0, sizeof( m_aiUsableInterViewRefs ) ); |
---|
1637 | |
---|
1638 | #if RWTH_SDC_DLT_B0036 |
---|
1639 | m_bUseDLT = false; |
---|
1640 | |
---|
1641 | m_uiBitsPerDepthValue = g_uiBitDepth; |
---|
1642 | m_uiNumDepthmapValues = 0; |
---|
1643 | m_uiDepthValue2Idx = NULL; |
---|
1644 | m_uiIdx2DepthValue = NULL; |
---|
1645 | #endif |
---|
1646 | } |
---|
1647 | |
---|
1648 | TComSPS::~TComSPS() |
---|
1649 | { |
---|
1650 | if( m_iNumColumnsMinus1 > 0 && m_iUniformSpacingIdr == 0 ) |
---|
1651 | { |
---|
1652 | delete [] m_puiColumnWidth; |
---|
1653 | m_puiColumnWidth = NULL; |
---|
1654 | } |
---|
1655 | if( m_iNumRowsMinus1 > 0 && m_iUniformSpacingIdr == 0 ) |
---|
1656 | { |
---|
1657 | delete [] m_puiRowHeight; |
---|
1658 | m_puiRowHeight = NULL; |
---|
1659 | } |
---|
1660 | } |
---|
1661 | |
---|
1662 | #if RWTH_SDC_DLT_B0036 |
---|
1663 | Void TComSPS::setDepthLUTs(UInt* uidx2DepthValue, UInt uiNumDepthValues) |
---|
1664 | { |
---|
1665 | UInt uiMaxDepthValue = g_uiIBDI_MAX; |
---|
1666 | |
---|
1667 | // allocate some memory |
---|
1668 | if( m_uiNumDepthmapValues == 0 ) |
---|
1669 | { |
---|
1670 | m_uiNumDepthmapValues = uiMaxDepthValue+1; |
---|
1671 | m_uiBitsPerDepthValue = (UInt)ceil(Log2(m_uiNumDepthmapValues)); |
---|
1672 | |
---|
1673 | m_uiDepthValue2Idx = (UInt*) xMalloc(UInt, m_uiNumDepthmapValues); |
---|
1674 | m_uiIdx2DepthValue = (UInt*) xMalloc(UInt, m_uiNumDepthmapValues); |
---|
1675 | |
---|
1676 | //default mapping |
---|
1677 | for (Int i=0; i<m_uiNumDepthmapValues; i++) |
---|
1678 | { |
---|
1679 | m_uiDepthValue2Idx[i] = i; |
---|
1680 | m_uiIdx2DepthValue[i] = i; |
---|
1681 | } |
---|
1682 | } |
---|
1683 | |
---|
1684 | if( uidx2DepthValue == NULL || uiNumDepthValues == 0 ) // default mapping only |
---|
1685 | return; |
---|
1686 | |
---|
1687 | // copy idx2DepthValue to internal array |
---|
1688 | memcpy(m_uiIdx2DepthValue, uidx2DepthValue, uiNumDepthValues*sizeof(UInt)); |
---|
1689 | |
---|
1690 | for(Int p=0; p<=uiMaxDepthValue; p++) |
---|
1691 | { |
---|
1692 | Int iIdxDown = 0; |
---|
1693 | Int iIdxUp = uiNumDepthValues-1; |
---|
1694 | Bool bFound = false; |
---|
1695 | |
---|
1696 | // iterate over indices to find lower closest depth |
---|
1697 | Int i = 1; |
---|
1698 | while(!bFound && i<uiNumDepthValues) |
---|
1699 | { |
---|
1700 | if( m_uiIdx2DepthValue[i] > p ) |
---|
1701 | { |
---|
1702 | iIdxDown = i-1; |
---|
1703 | bFound = true; |
---|
1704 | } |
---|
1705 | |
---|
1706 | i++; |
---|
1707 | } |
---|
1708 | // iterate over indices to find upper closest depth |
---|
1709 | i = uiNumDepthValues-2; |
---|
1710 | bFound = false; |
---|
1711 | while(!bFound && i>=0) |
---|
1712 | { |
---|
1713 | if( m_uiIdx2DepthValue[i] < p ) |
---|
1714 | { |
---|
1715 | iIdxUp = i+1; |
---|
1716 | bFound = true; |
---|
1717 | } |
---|
1718 | |
---|
1719 | i--; |
---|
1720 | } |
---|
1721 | |
---|
1722 | // assert monotony |
---|
1723 | assert(iIdxDown<=iIdxUp); |
---|
1724 | |
---|
1725 | // assign closer depth value/idx |
---|
1726 | if( abs(p-(Int)m_uiIdx2DepthValue[iIdxDown]) < abs(p-(Int)m_uiIdx2DepthValue[iIdxUp]) ) |
---|
1727 | { |
---|
1728 | m_uiDepthValue2Idx[p] = iIdxDown; |
---|
1729 | } |
---|
1730 | else |
---|
1731 | { |
---|
1732 | m_uiDepthValue2Idx[p] = iIdxUp; |
---|
1733 | } |
---|
1734 | |
---|
1735 | } |
---|
1736 | |
---|
1737 | // update globals |
---|
1738 | m_uiNumDepthmapValues = uiNumDepthValues; |
---|
1739 | m_uiBitsPerDepthValue = (UInt)ceil(Log2(m_uiNumDepthmapValues)); |
---|
1740 | } |
---|
1741 | #endif |
---|
1742 | |
---|
1743 | TComPPS::TComPPS() |
---|
1744 | : m_PPSId (0) |
---|
1745 | , m_SPSId (0) |
---|
1746 | , m_picInitQPMinus26 (0) |
---|
1747 | , m_useDQP (false) |
---|
1748 | , m_bConstrainedIntraPred (false) |
---|
1749 | , m_pcSPS (NULL) |
---|
1750 | , m_uiMaxCuDQPDepth (0) |
---|
1751 | , m_uiMinCuDQPSize (0) |
---|
1752 | , m_iChromaQpOffset (0) |
---|
1753 | , m_iChromaQpOffset2nd (0) |
---|
1754 | #if !RPS_IN_SPS |
---|
1755 | , m_bLongTermRefsPresent (false) |
---|
1756 | #endif |
---|
1757 | #if !H0566_TLA |
---|
1758 | , m_uiNumTlayerSwitchingFlags (0) |
---|
1759 | #endif |
---|
1760 | , m_iSliceGranularity (0) |
---|
1761 | , m_iTileBehaviorControlPresentFlag (0) |
---|
1762 | , m_bLFCrossTileBoundaryFlag (true) |
---|
1763 | , m_iColumnRowInfoPresent (0) |
---|
1764 | , m_iUniformSpacingIdr (0) |
---|
1765 | #if !REMOVE_TILE_DEPENDENCE |
---|
1766 | , m_iTileBoundaryIndependenceIdr (0) |
---|
1767 | #endif |
---|
1768 | , m_iNumColumnsMinus1 (0) |
---|
1769 | , m_puiColumnWidth (NULL) |
---|
1770 | , m_iNumRowsMinus1 (0) |
---|
1771 | , m_puiRowHeight (NULL) |
---|
1772 | #if !WPP_SIMPLIFICATION |
---|
1773 | , m_iEntropyCodingSynchro (0) |
---|
1774 | , m_bCabacIstateReset (false) |
---|
1775 | #endif |
---|
1776 | , m_iNumSubstreams (1) |
---|
1777 | #if MULTIBITS_DATA_HIDING |
---|
1778 | , m_signHideFlag(0) |
---|
1779 | , m_signHidingThreshold(0) |
---|
1780 | #endif |
---|
1781 | #if CABAC_INIT_FLAG |
---|
1782 | , m_cabacInitPresentFlag (false) |
---|
1783 | , m_encCABACTableIdx (0) |
---|
1784 | #if FIX_POZNAN_CABAC_INIT_FLAG |
---|
1785 | , m_encPrevPOC (0) |
---|
1786 | #endif |
---|
1787 | #endif |
---|
1788 | { |
---|
1789 | #if !H0566_TLA |
---|
1790 | for ( UInt i = 0; i < MAX_TLAYER; i++ ) |
---|
1791 | { |
---|
1792 | m_abTLayerSwitchingFlag[i] = false; |
---|
1793 | } |
---|
1794 | #endif |
---|
1795 | } |
---|
1796 | |
---|
1797 | TComPPS::~TComPPS() |
---|
1798 | { |
---|
1799 | if( m_iNumColumnsMinus1 > 0 && m_iUniformSpacingIdr == 0 ) |
---|
1800 | { |
---|
1801 | if (m_puiColumnWidth) delete [] m_puiColumnWidth; |
---|
1802 | m_puiColumnWidth = NULL; |
---|
1803 | } |
---|
1804 | if( m_iNumRowsMinus1 > 0 && m_iUniformSpacingIdr == 0 ) |
---|
1805 | { |
---|
1806 | if (m_puiRowHeight) delete [] m_puiRowHeight; |
---|
1807 | m_puiRowHeight = NULL; |
---|
1808 | } |
---|
1809 | } |
---|
1810 | |
---|
1811 | Void |
---|
1812 | TComSPS::initMultiviewSPS( UInt uiViewId, Int iViewOrderIdx, UInt uiCamParPrecision, Bool bCamParSlice, Int** aaiScale, Int** aaiOffset ) |
---|
1813 | { |
---|
1814 | #if !QC_MVHEVC_B0046 |
---|
1815 | AOT( uiViewId == 0 && iViewOrderIdx != 0 ); |
---|
1816 | AOT( uiViewId != 0 && iViewOrderIdx == 0 ); |
---|
1817 | AOT( uiViewId != 0 && !bCamParSlice && ( aaiScale == 0 || aaiOffset == 0 ) ); |
---|
1818 | #endif |
---|
1819 | m_uiViewId = uiViewId; |
---|
1820 | m_iViewOrderIdx = iViewOrderIdx; |
---|
1821 | m_bDepth = false; |
---|
1822 | m_uiCamParPrecision = ( m_uiViewId ? uiCamParPrecision : 0 ); |
---|
1823 | m_bCamParInSliceHeader = ( m_uiViewId ? bCamParSlice : false ); |
---|
1824 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
1825 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
1826 | #if !QC_MVHEVC_B0046 |
---|
1827 | if( !m_bCamParInSliceHeader ) |
---|
1828 | { |
---|
1829 | for( UInt uiBaseViewId = 0; uiBaseViewId < m_uiViewId; uiBaseViewId++ ) |
---|
1830 | { |
---|
1831 | m_aaiCodedScale [ 0 ][ uiBaseViewId ] = aaiScale [ uiBaseViewId ][ m_uiViewId ]; |
---|
1832 | m_aaiCodedScale [ 1 ][ uiBaseViewId ] = aaiScale [ m_uiViewId ][ uiBaseViewId ]; |
---|
1833 | m_aaiCodedOffset[ 0 ][ uiBaseViewId ] = aaiOffset[ uiBaseViewId ][ m_uiViewId ]; |
---|
1834 | m_aaiCodedOffset[ 1 ][ uiBaseViewId ] = aaiOffset[ m_uiViewId ][ uiBaseViewId ]; |
---|
1835 | } |
---|
1836 | } |
---|
1837 | #endif |
---|
1838 | } |
---|
1839 | |
---|
1840 | Void |
---|
1841 | TComSPS::initMultiviewSPSDepth( UInt uiViewId, Int iViewOrderIdx ) |
---|
1842 | { |
---|
1843 | AOT( uiViewId == 0 && iViewOrderIdx != 0 ); |
---|
1844 | AOT( uiViewId != 0 && iViewOrderIdx == 0 ); |
---|
1845 | |
---|
1846 | m_uiViewId = uiViewId; |
---|
1847 | m_iViewOrderIdx = iViewOrderIdx; |
---|
1848 | m_bDepth = true; |
---|
1849 | m_uiCamParPrecision = 0; |
---|
1850 | m_bCamParInSliceHeader = false; |
---|
1851 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
1852 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
1853 | } |
---|
1854 | |
---|
1855 | #if DEPTH_MAP_GENERATION |
---|
1856 | Void |
---|
1857 | TComSPS::setPredDepthMapGeneration( UInt uiViewId, Bool bIsDepth, UInt uiPdmGenMode, UInt uiPdmMvPredMode, UInt uiPdmPrec, Int** aaiPdmScaleNomDelta, Int** aaiPdmOffset ) |
---|
1858 | { |
---|
1859 | AOF( m_uiViewId == uiViewId ); |
---|
1860 | AOF( m_bDepth == bIsDepth ); |
---|
1861 | AOT( ( uiViewId == 0 || bIsDepth ) && uiPdmGenMode ); |
---|
1862 | AOT( uiPdmGenMode && ( aaiPdmScaleNomDelta == 0 || aaiPdmOffset == 0 ) ); |
---|
1863 | AOT( uiPdmMvPredMode && uiPdmGenMode == 0 ); |
---|
1864 | |
---|
1865 | m_uiPredDepthMapGeneration = uiPdmGenMode; |
---|
1866 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
1867 | m_uiMultiviewMvPredMode = uiPdmMvPredMode; |
---|
1868 | #endif |
---|
1869 | |
---|
1870 | m_uiPdmPrecision = ( m_uiPredDepthMapGeneration ? uiPdmPrec : 0 ); |
---|
1871 | ::memset( m_aiPdmScaleNomDelta, 0x00, sizeof( m_aiPdmScaleNomDelta ) ); |
---|
1872 | ::memset( m_aiPdmOffset, 0x00, sizeof( m_aiPdmOffset ) ); |
---|
1873 | if( m_uiPredDepthMapGeneration ) |
---|
1874 | { |
---|
1875 | for( UInt uiBaseId = 0; uiBaseId < m_uiViewId; uiBaseId++ ) |
---|
1876 | { |
---|
1877 | m_aiPdmScaleNomDelta[ uiBaseId ] = aaiPdmScaleNomDelta[ m_uiViewId ][ uiBaseId ]; |
---|
1878 | m_aiPdmOffset [ uiBaseId ] = aaiPdmOffset [ m_uiViewId ][ uiBaseId ]; |
---|
1879 | } |
---|
1880 | } |
---|
1881 | } |
---|
1882 | #endif |
---|
1883 | |
---|
1884 | TComReferencePictureSet::TComReferencePictureSet() |
---|
1885 | : m_numberOfPictures (0) |
---|
1886 | , m_numberOfNegativePictures (0) |
---|
1887 | , m_numberOfPositivePictures (0) |
---|
1888 | , m_numberOfLongtermPictures (0) |
---|
1889 | , m_interRPSPrediction (0) |
---|
1890 | , m_deltaRIdxMinus1 (0) |
---|
1891 | , m_deltaRPS (0) |
---|
1892 | , m_numRefIdc (0) |
---|
1893 | { |
---|
1894 | ::memset( m_deltaPOC, 0, sizeof(m_deltaPOC) ); |
---|
1895 | ::memset( m_POC, 0, sizeof(m_POC) ); |
---|
1896 | ::memset( m_used, 0, sizeof(m_used) ); |
---|
1897 | ::memset( m_refIdc, 0, sizeof(m_refIdc) ); |
---|
1898 | } |
---|
1899 | |
---|
1900 | TComReferencePictureSet::~TComReferencePictureSet() |
---|
1901 | { |
---|
1902 | } |
---|
1903 | |
---|
1904 | Void TComReferencePictureSet::setUsed(Int bufferNum, Bool used) |
---|
1905 | { |
---|
1906 | m_used[bufferNum] = used; |
---|
1907 | } |
---|
1908 | |
---|
1909 | Void TComReferencePictureSet::setDeltaPOC(Int bufferNum, Int deltaPOC) |
---|
1910 | { |
---|
1911 | m_deltaPOC[bufferNum] = deltaPOC; |
---|
1912 | } |
---|
1913 | |
---|
1914 | Void TComReferencePictureSet::setNumberOfPictures(Int numberOfPictures) |
---|
1915 | { |
---|
1916 | m_numberOfPictures = numberOfPictures; |
---|
1917 | } |
---|
1918 | |
---|
1919 | Int TComReferencePictureSet::getUsed(Int bufferNum) |
---|
1920 | { |
---|
1921 | return m_used[bufferNum]; |
---|
1922 | } |
---|
1923 | |
---|
1924 | Int TComReferencePictureSet::getDeltaPOC(Int bufferNum) |
---|
1925 | { |
---|
1926 | return m_deltaPOC[bufferNum]; |
---|
1927 | } |
---|
1928 | |
---|
1929 | Int TComReferencePictureSet::getNumberOfPictures() |
---|
1930 | { |
---|
1931 | return m_numberOfPictures; |
---|
1932 | } |
---|
1933 | |
---|
1934 | Int TComReferencePictureSet::getPOC(Int bufferNum) |
---|
1935 | { |
---|
1936 | return m_POC[bufferNum]; |
---|
1937 | } |
---|
1938 | Void TComReferencePictureSet::setPOC(Int bufferNum, Int POC) |
---|
1939 | { |
---|
1940 | m_POC[bufferNum] = POC; |
---|
1941 | } |
---|
1942 | |
---|
1943 | /** set the reference idc value at uiBufferNum entry to the value of iRefIdc |
---|
1944 | * \param uiBufferNum |
---|
1945 | * \param iRefIdc |
---|
1946 | * \returns Void |
---|
1947 | */ |
---|
1948 | Void TComReferencePictureSet::setRefIdc(Int bufferNum, Int refIdc) |
---|
1949 | { |
---|
1950 | m_refIdc[bufferNum] = refIdc; |
---|
1951 | } |
---|
1952 | |
---|
1953 | /** get the reference idc value at uiBufferNum |
---|
1954 | * \param uiBufferNum |
---|
1955 | * \returns Int |
---|
1956 | */ |
---|
1957 | Int TComReferencePictureSet::getRefIdc(Int bufferNum) |
---|
1958 | { |
---|
1959 | return m_refIdc[bufferNum]; |
---|
1960 | } |
---|
1961 | |
---|
1962 | /** Sorts the deltaPOC and Used by current values in the RPS based on the deltaPOC values. |
---|
1963 | * deltaPOC values are sorted with -ve values before the +ve values. -ve values are in decreasing order. |
---|
1964 | * +ve values are in increasing order. |
---|
1965 | * \returns Void |
---|
1966 | */ |
---|
1967 | Void TComReferencePictureSet::sortDeltaPOC() |
---|
1968 | { |
---|
1969 | // sort in increasing order (smallest first) |
---|
1970 | for(Int j=1; j < getNumberOfPictures(); j++) |
---|
1971 | { |
---|
1972 | Int deltaPOC = getDeltaPOC(j); |
---|
1973 | Bool used = getUsed(j); |
---|
1974 | for (Int k=j-1; k >= 0; k--) |
---|
1975 | { |
---|
1976 | Int temp = getDeltaPOC(k); |
---|
1977 | if (deltaPOC < temp) |
---|
1978 | { |
---|
1979 | setDeltaPOC(k+1, temp); |
---|
1980 | setUsed(k+1, getUsed(k)); |
---|
1981 | setDeltaPOC(k, deltaPOC); |
---|
1982 | setUsed(k, used); |
---|
1983 | } |
---|
1984 | } |
---|
1985 | } |
---|
1986 | // flip the negative values to largest first |
---|
1987 | Int numNegPics = getNumberOfNegativePictures(); |
---|
1988 | for(Int j=0, k=numNegPics-1; j < numNegPics>>1; j++, k--) |
---|
1989 | { |
---|
1990 | Int deltaPOC = getDeltaPOC(j); |
---|
1991 | Bool used = getUsed(j); |
---|
1992 | setDeltaPOC(j, getDeltaPOC(k)); |
---|
1993 | setUsed(j, getUsed(k)); |
---|
1994 | setDeltaPOC(k, deltaPOC); |
---|
1995 | setUsed(k, used); |
---|
1996 | } |
---|
1997 | } |
---|
1998 | |
---|
1999 | /** Prints the deltaPOC and RefIdc (if available) values in the RPS. |
---|
2000 | * A "*" is added to the deltaPOC value if it is Used bu current. |
---|
2001 | * \returns Void |
---|
2002 | */ |
---|
2003 | Void TComReferencePictureSet::printDeltaPOC() |
---|
2004 | { |
---|
2005 | printf("DeltaPOC = { "); |
---|
2006 | for(Int j=0; j < getNumberOfPictures(); j++) |
---|
2007 | { |
---|
2008 | printf("%d%s ", getDeltaPOC(j), (getUsed(j)==1)?"*":""); |
---|
2009 | } |
---|
2010 | if (getInterRPSPrediction()) |
---|
2011 | { |
---|
2012 | printf("}, RefIdc = { "); |
---|
2013 | for(Int j=0; j < getNumRefIdc(); j++) |
---|
2014 | { |
---|
2015 | printf("%d ", getRefIdc(j)); |
---|
2016 | } |
---|
2017 | } |
---|
2018 | printf("}\n"); |
---|
2019 | } |
---|
2020 | |
---|
2021 | TComRPSList::TComRPSList() |
---|
2022 | { |
---|
2023 | } |
---|
2024 | |
---|
2025 | TComRPSList::~TComRPSList() |
---|
2026 | { |
---|
2027 | } |
---|
2028 | |
---|
2029 | Void TComRPSList::create( Int numberOfReferencePictureSets) |
---|
2030 | { |
---|
2031 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
2032 | m_referencePictureSets = new TComReferencePictureSet[numberOfReferencePictureSets]; |
---|
2033 | } |
---|
2034 | |
---|
2035 | Void TComRPSList::destroy() |
---|
2036 | { |
---|
2037 | delete [] m_referencePictureSets; |
---|
2038 | m_numberOfReferencePictureSets = 0; |
---|
2039 | m_referencePictureSets = NULL; |
---|
2040 | } |
---|
2041 | |
---|
2042 | |
---|
2043 | |
---|
2044 | TComReferencePictureSet* TComRPSList::getReferencePictureSet(Int referencePictureSetNum) |
---|
2045 | { |
---|
2046 | return &m_referencePictureSets[referencePictureSetNum]; |
---|
2047 | } |
---|
2048 | |
---|
2049 | Int TComRPSList::getNumberOfReferencePictureSets() |
---|
2050 | { |
---|
2051 | return m_numberOfReferencePictureSets; |
---|
2052 | } |
---|
2053 | |
---|
2054 | Void TComRPSList::setNumberOfReferencePictureSets(Int numberOfReferencePictureSets) |
---|
2055 | { |
---|
2056 | m_numberOfReferencePictureSets = numberOfReferencePictureSets; |
---|
2057 | } |
---|
2058 | |
---|
2059 | TComRefPicListModification::TComRefPicListModification() |
---|
2060 | : m_bRefPicListModificationFlagL0 (false) |
---|
2061 | , m_bRefPicListModificationFlagL1 (false) |
---|
2062 | #if !H0137_0138_LIST_MODIFICATION |
---|
2063 | , m_uiNumberOfRefPicListModificationsL0 (0) |
---|
2064 | , m_uiNumberOfRefPicListModificationsL1 (0) |
---|
2065 | #endif |
---|
2066 | { |
---|
2067 | #if !H0137_0138_LIST_MODIFICATION |
---|
2068 | ::memset( m_ListIdcL0, 0, sizeof(m_ListIdcL0) ); |
---|
2069 | #endif |
---|
2070 | ::memset( m_RefPicSetIdxL0, 0, sizeof(m_RefPicSetIdxL0) ); |
---|
2071 | #if !H0137_0138_LIST_MODIFICATION |
---|
2072 | ::memset( m_ListIdcL1, 0, sizeof(m_ListIdcL1) ); |
---|
2073 | #endif |
---|
2074 | ::memset( m_RefPicSetIdxL1, 0, sizeof(m_RefPicSetIdxL1) ); |
---|
2075 | } |
---|
2076 | |
---|
2077 | TComRefPicListModification::~TComRefPicListModification() |
---|
2078 | { |
---|
2079 | } |
---|
2080 | |
---|
2081 | TComAPS::TComAPS() |
---|
2082 | { |
---|
2083 | m_apsID = 0; |
---|
2084 | m_bAlfEnabled = false; |
---|
2085 | m_bSaoEnabled = false; |
---|
2086 | m_pSaoParam = NULL; |
---|
2087 | #if LCU_SYNTAX_ALF |
---|
2088 | m_alfParamSet = NULL; |
---|
2089 | #else |
---|
2090 | m_pAlfParam = NULL; |
---|
2091 | #endif |
---|
2092 | m_scalingList = NULL; |
---|
2093 | m_scalingListEnabled = false; |
---|
2094 | } |
---|
2095 | |
---|
2096 | TComAPS::~TComAPS() |
---|
2097 | { |
---|
2098 | |
---|
2099 | } |
---|
2100 | |
---|
2101 | TComAPS& TComAPS::operator= (const TComAPS& src) |
---|
2102 | { |
---|
2103 | m_apsID = src.m_apsID; |
---|
2104 | m_loopFilterOffsetInAPS = src.m_loopFilterOffsetInAPS; |
---|
2105 | m_loopFilterDisable = src.m_loopFilterDisable; |
---|
2106 | m_loopFilterBetaOffsetDiv2 = src.m_loopFilterBetaOffsetDiv2; |
---|
2107 | m_loopFilterTcOffsetDiv2 = src.m_loopFilterTcOffsetDiv2; |
---|
2108 | m_bAlfEnabled = src.m_bAlfEnabled; |
---|
2109 | m_bSaoEnabled = src.m_bSaoEnabled; |
---|
2110 | m_pSaoParam = src.m_pSaoParam; |
---|
2111 | #if LCU_SYNTAX_ALF |
---|
2112 | m_alfParamSet = src.m_alfParamSet; |
---|
2113 | #else |
---|
2114 | m_pAlfParam = src.m_pAlfParam; |
---|
2115 | #endif |
---|
2116 | m_scalingList = src.m_scalingList; |
---|
2117 | m_scalingListEnabled = src.m_scalingListEnabled; |
---|
2118 | #if SAO_UNIT_INTERLEAVING |
---|
2119 | m_saoInterleavingFlag = src.m_saoInterleavingFlag; |
---|
2120 | #endif |
---|
2121 | |
---|
2122 | return *this; |
---|
2123 | } |
---|
2124 | |
---|
2125 | Void TComAPS::createSaoParam() |
---|
2126 | { |
---|
2127 | m_pSaoParam = new SAOParam; |
---|
2128 | } |
---|
2129 | |
---|
2130 | Void TComAPS::destroySaoParam() |
---|
2131 | { |
---|
2132 | if(m_pSaoParam != NULL) |
---|
2133 | { |
---|
2134 | delete m_pSaoParam; |
---|
2135 | m_pSaoParam = NULL; |
---|
2136 | } |
---|
2137 | } |
---|
2138 | |
---|
2139 | Void TComAPS::createAlfParam() |
---|
2140 | { |
---|
2141 | #if LCU_SYNTAX_ALF |
---|
2142 | m_alfParamSet = new AlfParamSet; |
---|
2143 | #else |
---|
2144 | m_pAlfParam = new ALFParam; |
---|
2145 | #endif |
---|
2146 | } |
---|
2147 | Void TComAPS::destroyAlfParam() |
---|
2148 | { |
---|
2149 | #if LCU_SYNTAX_ALF |
---|
2150 | if(m_alfParamSet != NULL) |
---|
2151 | { |
---|
2152 | delete m_alfParamSet; |
---|
2153 | m_alfParamSet = NULL; |
---|
2154 | } |
---|
2155 | #else |
---|
2156 | if(m_pAlfParam != NULL) |
---|
2157 | { |
---|
2158 | delete m_pAlfParam; |
---|
2159 | m_pAlfParam = NULL; |
---|
2160 | } |
---|
2161 | #endif |
---|
2162 | } |
---|
2163 | |
---|
2164 | Void TComAPS::createScalingList() |
---|
2165 | { |
---|
2166 | m_scalingList = new TComScalingList; |
---|
2167 | } |
---|
2168 | Void TComAPS::destroyScalingList() |
---|
2169 | { |
---|
2170 | delete m_scalingList; |
---|
2171 | } |
---|
2172 | |
---|
2173 | TComScalingList::TComScalingList() |
---|
2174 | { |
---|
2175 | init(); |
---|
2176 | } |
---|
2177 | TComScalingList::~TComScalingList() |
---|
2178 | { |
---|
2179 | destroy(); |
---|
2180 | } |
---|
2181 | |
---|
2182 | /** set default quantization matrix to array |
---|
2183 | */ |
---|
2184 | Void TComSlice::setDefaultScalingList() |
---|
2185 | { |
---|
2186 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2187 | { |
---|
2188 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
2189 | { |
---|
2190 | getScalingList()->processDefaultMarix(sizeId, listId); |
---|
2191 | } |
---|
2192 | } |
---|
2193 | } |
---|
2194 | /** check if use default quantization matrix |
---|
2195 | * \returns true if use default quantization matrix in all size |
---|
2196 | */ |
---|
2197 | #if SCALING_LIST |
---|
2198 | Bool TComSlice::checkDefaultScalingList() |
---|
2199 | { |
---|
2200 | UInt defaultCounter=0; |
---|
2201 | |
---|
2202 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2203 | { |
---|
2204 | for(UInt listId=0;listId<g_scalingListNum[sizeId];listId++) |
---|
2205 | { |
---|
2206 | if(getScalingList()->getUseDefaultScalingMatrixFlag(sizeId,listId)) |
---|
2207 | { |
---|
2208 | defaultCounter++; |
---|
2209 | } |
---|
2210 | } |
---|
2211 | } |
---|
2212 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? true : false; // -4 for 32x32 |
---|
2213 | } |
---|
2214 | #else |
---|
2215 | Bool TComSlice::checkDefaultScalingList() |
---|
2216 | { |
---|
2217 | UInt i; |
---|
2218 | Int *dst=0; |
---|
2219 | Int *src=0; |
---|
2220 | UInt defaultCounter=0; |
---|
2221 | |
---|
2222 | //4x4 |
---|
2223 | for(i=0;i<SCALING_LIST_NUM;i++) |
---|
2224 | { |
---|
2225 | src = (i<3) ? g_quantIntraDefault4x4 : g_quantInterDefault4x4; |
---|
2226 | dst = getScalingList()->getScalingListAddress(SCALING_LIST_4x4,i); |
---|
2227 | if(::memcmp(dst,src,sizeof(UInt)*16) == 0) defaultCounter++; |
---|
2228 | } |
---|
2229 | |
---|
2230 | //8x8 |
---|
2231 | for(i=0;i<SCALING_LIST_NUM;i++) |
---|
2232 | { |
---|
2233 | src = (i<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2234 | dst = getScalingList()->getScalingListAddress(SCALING_LIST_8x8,i); |
---|
2235 | if(::memcmp(dst,src,sizeof(UInt)*64) == 0) defaultCounter++; |
---|
2236 | } |
---|
2237 | //16x16 |
---|
2238 | for(i=0;i<SCALING_LIST_NUM;i++) |
---|
2239 | { |
---|
2240 | src = (i<3) ? g_quantIntraDefault16x16 : g_quantInterDefault16x16; |
---|
2241 | dst = getScalingList()->getScalingListAddress(SCALING_LIST_16x16,i); |
---|
2242 | if(::memcmp(dst,src,sizeof(UInt)*256) == 0) defaultCounter++; |
---|
2243 | } |
---|
2244 | //32x32 |
---|
2245 | for(i=0;i<SCALING_LIST_NUM_32x32;i++) |
---|
2246 | { |
---|
2247 | src = (i<1) ? g_quantIntraDefault32x32 : g_quantInterDefault32x32; |
---|
2248 | dst = getScalingList()->getScalingListAddress(SCALING_LIST_32x32,i*3); |
---|
2249 | if(::memcmp(dst,src,sizeof(UInt)*1024) == 0) defaultCounter++; |
---|
2250 | } |
---|
2251 | return (defaultCounter == (SCALING_LIST_NUM * SCALING_LIST_SIZE_NUM - 4)) ? true : false; // -4 for 32x32 |
---|
2252 | } |
---|
2253 | #endif |
---|
2254 | /** get scaling matrix from RefMatrixID |
---|
2255 | * \param sizeId size index |
---|
2256 | * \param Index of input matrix |
---|
2257 | * \param Index of reference matrix |
---|
2258 | */ |
---|
2259 | Void TComScalingList::processRefMatrix( UInt sizeId, UInt listId , UInt refListId ) |
---|
2260 | { |
---|
2261 | #if SCALING_LIST |
---|
2262 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListAddress(sizeId, refListId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
2263 | #else |
---|
2264 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListAddress(sizeId, refListId),sizeof(Int)*g_scalingListSize[sizeId]); |
---|
2265 | #endif |
---|
2266 | } |
---|
2267 | /** parse syntax infomation |
---|
2268 | * \param pchFile syntax infomation |
---|
2269 | * \returns false if successful |
---|
2270 | */ |
---|
2271 | Bool TComScalingList::xParseScalingList(char* pchFile) |
---|
2272 | { |
---|
2273 | FILE *fp; |
---|
2274 | Char line[1024]; |
---|
2275 | UInt sizeIdc,listIdc; |
---|
2276 | UInt i,size = 0; |
---|
2277 | Int *src=0,data; |
---|
2278 | Char *ret; |
---|
2279 | UInt retval; |
---|
2280 | |
---|
2281 | if((fp = fopen(pchFile,"r")) == (FILE*)NULL) |
---|
2282 | { |
---|
2283 | printf("can't open file %s :: set Default Matrix\n",pchFile); |
---|
2284 | return true; |
---|
2285 | } |
---|
2286 | |
---|
2287 | for(sizeIdc = 0; sizeIdc < SCALING_LIST_SIZE_NUM; sizeIdc++) |
---|
2288 | { |
---|
2289 | #if SCALING_LIST |
---|
2290 | size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeIdc]); |
---|
2291 | #else |
---|
2292 | size = g_scalingListSize[sizeIdc]; |
---|
2293 | #endif |
---|
2294 | for(listIdc = 0; listIdc < g_scalingListNum[sizeIdc]; listIdc++) |
---|
2295 | { |
---|
2296 | src = getScalingListAddress(sizeIdc, listIdc); |
---|
2297 | |
---|
2298 | fseek(fp,0,0); |
---|
2299 | do |
---|
2300 | { |
---|
2301 | ret = fgets(line, 1024, fp); |
---|
2302 | if ((ret==NULL)||(strstr(line, MatrixType[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
2303 | { |
---|
2304 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
2305 | return true; |
---|
2306 | } |
---|
2307 | } |
---|
2308 | while (strstr(line, MatrixType[sizeIdc][listIdc]) == NULL); |
---|
2309 | for (i=0; i<size; i++) |
---|
2310 | { |
---|
2311 | retval = fscanf(fp, "%d,", &data); |
---|
2312 | if (retval!=1) |
---|
2313 | { |
---|
2314 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
2315 | return true; |
---|
2316 | } |
---|
2317 | src[i] = data; |
---|
2318 | } |
---|
2319 | #if SCALING_LIST |
---|
2320 | //set DC value for default matrix check |
---|
2321 | setScalingListDC(sizeIdc,listIdc,src[0]); |
---|
2322 | |
---|
2323 | if(sizeIdc > SCALING_LIST_8x8) |
---|
2324 | { |
---|
2325 | fseek(fp,0,0); |
---|
2326 | do |
---|
2327 | { |
---|
2328 | ret = fgets(line, 1024, fp); |
---|
2329 | if ((ret==NULL)||(strstr(line, MatrixType_DC[sizeIdc][listIdc])==NULL && feof(fp))) |
---|
2330 | { |
---|
2331 | printf("Error: can't read DC :: set Default Matrix\n"); |
---|
2332 | return true; |
---|
2333 | } |
---|
2334 | } |
---|
2335 | while (strstr(line, MatrixType_DC[sizeIdc][listIdc]) == NULL); |
---|
2336 | retval = fscanf(fp, "%d,", &data); |
---|
2337 | if (retval!=1) |
---|
2338 | { |
---|
2339 | printf("Error: can't read Matrix :: set Default Matrix\n"); |
---|
2340 | return true; |
---|
2341 | } |
---|
2342 | //overwrite DC value when size of matrix is larger than 16x16 |
---|
2343 | setScalingListDC(sizeIdc,listIdc,data); |
---|
2344 | } |
---|
2345 | #endif |
---|
2346 | } |
---|
2347 | } |
---|
2348 | fclose(fp); |
---|
2349 | return false; |
---|
2350 | } |
---|
2351 | |
---|
2352 | /** initialization process of quantization matrix array |
---|
2353 | */ |
---|
2354 | Void TComScalingList::init() |
---|
2355 | { |
---|
2356 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2357 | { |
---|
2358 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2359 | { |
---|
2360 | #if SCALING_LIST |
---|
2361 | m_scalingListCoef[sizeId][listId] = new Int [min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])]; |
---|
2362 | #else |
---|
2363 | m_scalingListCoef[sizeId][listId] = new Int [g_scalingListSize[sizeId]]; |
---|
2364 | #endif |
---|
2365 | } |
---|
2366 | } |
---|
2367 | m_scalingListCoef[SCALING_LIST_32x32][3] = m_scalingListCoef[SCALING_LIST_32x32][1]; // copy address for 32x32 |
---|
2368 | } |
---|
2369 | /** destroy quantization matrix array |
---|
2370 | */ |
---|
2371 | Void TComScalingList::destroy() |
---|
2372 | { |
---|
2373 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2374 | { |
---|
2375 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2376 | { |
---|
2377 | if(m_scalingListCoef[sizeId][listId]) delete [] m_scalingListCoef[sizeId][listId]; |
---|
2378 | } |
---|
2379 | } |
---|
2380 | } |
---|
2381 | /** get default address of quantization matrix |
---|
2382 | * \param sizeId size index |
---|
2383 | * \param listId list index |
---|
2384 | * \returns pointer of quantization matrix |
---|
2385 | */ |
---|
2386 | Int* TComScalingList::getScalingListDefaultAddress(UInt sizeId, UInt listId) |
---|
2387 | { |
---|
2388 | Int *src = 0; |
---|
2389 | switch(sizeId) |
---|
2390 | { |
---|
2391 | case SCALING_LIST_4x4: |
---|
2392 | src = (listId<3) ? g_quantIntraDefault4x4 : g_quantInterDefault4x4; |
---|
2393 | break; |
---|
2394 | case SCALING_LIST_8x8: |
---|
2395 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2396 | break; |
---|
2397 | #if SCALING_LIST |
---|
2398 | case SCALING_LIST_16x16: |
---|
2399 | src = (listId<3) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2400 | break; |
---|
2401 | case SCALING_LIST_32x32: |
---|
2402 | src = (listId<1) ? g_quantIntraDefault8x8 : g_quantInterDefault8x8; |
---|
2403 | break; |
---|
2404 | #else |
---|
2405 | case SCALING_LIST_16x16: |
---|
2406 | src = (listId<3) ? g_quantIntraDefault16x16 : g_quantInterDefault16x16; |
---|
2407 | break; |
---|
2408 | case SCALING_LIST_32x32: |
---|
2409 | src = (listId<1) ? g_quantIntraDefault32x32 : g_quantInterDefault32x32; |
---|
2410 | break; |
---|
2411 | #endif |
---|
2412 | default: |
---|
2413 | assert(0); |
---|
2414 | src = NULL; |
---|
2415 | break; |
---|
2416 | } |
---|
2417 | return src; |
---|
2418 | } |
---|
2419 | /** process of default matrix |
---|
2420 | * \param sizeId size index |
---|
2421 | * \param Index of input matrix |
---|
2422 | */ |
---|
2423 | Void TComScalingList::processDefaultMarix(UInt sizeId, UInt listId) |
---|
2424 | { |
---|
2425 | #if SCALING_LIST |
---|
2426 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])); |
---|
2427 | setUseDefaultScalingMatrixFlag(sizeId,listId,true); |
---|
2428 | setScalingListDC(sizeId,listId,SCALING_LIST_DC); |
---|
2429 | #else |
---|
2430 | ::memcpy(getScalingListAddress(sizeId, listId),getScalingListDefaultAddress(sizeId,listId),sizeof(Int)*(Int)g_scalingListSize[sizeId]); |
---|
2431 | #endif |
---|
2432 | } |
---|
2433 | #if SCALING_LIST |
---|
2434 | /** check DC value of matrix for default matrix signaling |
---|
2435 | */ |
---|
2436 | Void TComScalingList::checkDcOfMatrix() |
---|
2437 | { |
---|
2438 | for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2439 | { |
---|
2440 | for(UInt listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2441 | { |
---|
2442 | setUseDefaultScalingMatrixFlag(sizeId,listId,false); |
---|
2443 | //check default matrix? |
---|
2444 | if(getScalingListDC(sizeId,listId) == 0) |
---|
2445 | { |
---|
2446 | processDefaultMarix(sizeId, listId); |
---|
2447 | } |
---|
2448 | } |
---|
2449 | } |
---|
2450 | } |
---|
2451 | #endif |
---|
2452 | |
---|
2453 | ParameterSetManager::ParameterSetManager() |
---|
2454 | : m_spsMap(MAX_NUM_SPS) |
---|
2455 | , m_ppsMap(MAX_NUM_PPS) |
---|
2456 | , m_apsMap(MAX_NUM_APS) |
---|
2457 | #if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046 |
---|
2458 | , m_vpsMap(MAX_NUM_VPS) |
---|
2459 | #endif |
---|
2460 | { |
---|
2461 | } |
---|
2462 | |
---|
2463 | |
---|
2464 | ParameterSetManager::~ParameterSetManager() |
---|
2465 | { |
---|
2466 | } |
---|
2467 | |
---|
2468 | //! \} |
---|