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