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-2011, 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 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 | |
---|
35 | |
---|
36 | /** \file TComSlice.cpp |
---|
37 | \brief slice header and SPS class |
---|
38 | */ |
---|
39 | |
---|
40 | #include "CommonDef.h" |
---|
41 | #include "TComSlice.h" |
---|
42 | #include "TComPic.h" |
---|
43 | |
---|
44 | TComSlice::TComSlice() |
---|
45 | { |
---|
46 | m_uiPPSId = 0; |
---|
47 | m_iPOC = 0; |
---|
48 | m_eSliceType = I_SLICE; |
---|
49 | m_iSliceQp = 0; |
---|
50 | m_iSymbolMode = 1; |
---|
51 | m_aiNumRefIdx[0] = 0; |
---|
52 | m_aiNumRefIdx[1] = 0; |
---|
53 | m_bLoopFilterDisable = false; |
---|
54 | |
---|
55 | m_iSliceQpDelta = 0; |
---|
56 | |
---|
57 | m_iDepth = 0; |
---|
58 | |
---|
59 | m_pcPic = NULL; |
---|
60 | m_bRefenced = false; |
---|
61 | #ifdef ROUNDING_CONTROL_BIPRED |
---|
62 | m_bRounding = false; |
---|
63 | #endif |
---|
64 | m_uiColDir = 0; |
---|
65 | |
---|
66 | m_iViewIdx = 0 ; |
---|
67 | |
---|
68 | #if BITSTREAM_EXTRACTION |
---|
69 | m_uiLayerId = 0; |
---|
70 | #endif |
---|
71 | |
---|
72 | #if SONY_COLPIC_AVAILABILITY |
---|
73 | m_iViewOrderIdx = 0; |
---|
74 | #endif |
---|
75 | |
---|
76 | initEqualRef(); |
---|
77 | m_bNoBackPredFlag = false; |
---|
78 | #if MS_LCEC_LOOKUP_TABLE_EXCEPTION |
---|
79 | m_bRefIdxCombineCoding = false; |
---|
80 | #endif |
---|
81 | #if DCM_COMB_LIST |
---|
82 | m_bRefPicListCombinationFlag = false; |
---|
83 | m_bRefPicListModificationFlagLC = false; |
---|
84 | #endif |
---|
85 | m_uiSliceCurStartCUAddr = 0; |
---|
86 | m_uiEntropySliceCurStartCUAddr = 0; |
---|
87 | |
---|
88 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
89 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
90 | m_pcTexturePic = NULL; |
---|
91 | #ifdef WEIGHT_PRED |
---|
92 | resetWpScaling(m_weightPredTable); |
---|
93 | initWpAcDcParam(); |
---|
94 | #endif |
---|
95 | } |
---|
96 | |
---|
97 | TComSlice::~TComSlice() |
---|
98 | { |
---|
99 | } |
---|
100 | |
---|
101 | |
---|
102 | Void TComSlice::initSlice() |
---|
103 | { |
---|
104 | m_aiNumRefIdx[0] = 0; |
---|
105 | m_aiNumRefIdx[1] = 0; |
---|
106 | |
---|
107 | m_uiColDir = 0; |
---|
108 | |
---|
109 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
110 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
111 | m_pcTexturePic = NULL; |
---|
112 | |
---|
113 | initEqualRef(); |
---|
114 | m_bNoBackPredFlag = false; |
---|
115 | #if MS_LCEC_LOOKUP_TABLE_EXCEPTION |
---|
116 | m_bRefIdxCombineCoding = false; |
---|
117 | #endif |
---|
118 | #if DCM_COMB_LIST |
---|
119 | m_bRefPicListCombinationFlag = false; |
---|
120 | m_bRefPicListModificationFlagLC = false; |
---|
121 | #endif |
---|
122 | } |
---|
123 | |
---|
124 | Void TComSlice::sortPicList (TComList<TComPic*>& rcListPic) |
---|
125 | { |
---|
126 | TComPic* pcPicExtract; |
---|
127 | TComPic* pcPicInsert; |
---|
128 | |
---|
129 | TComList<TComPic*>::iterator iterPicExtract; |
---|
130 | TComList<TComPic*>::iterator iterPicExtract_1; |
---|
131 | TComList<TComPic*>::iterator iterPicInsert; |
---|
132 | |
---|
133 | for (Int i = 1; i < (Int)(rcListPic.size()); i++) |
---|
134 | { |
---|
135 | iterPicExtract = rcListPic.begin(); |
---|
136 | for (Int j = 0; j < i; j++) iterPicExtract++; |
---|
137 | pcPicExtract = *(iterPicExtract); |
---|
138 | pcPicExtract->setCurrSliceIdx(0); |
---|
139 | |
---|
140 | iterPicInsert = rcListPic.begin(); |
---|
141 | while (iterPicInsert != iterPicExtract) |
---|
142 | { |
---|
143 | pcPicInsert = *(iterPicInsert); |
---|
144 | pcPicInsert->setCurrSliceIdx(0); |
---|
145 | if (pcPicInsert->getPOC() >= pcPicExtract->getPOC()) |
---|
146 | { |
---|
147 | break; |
---|
148 | } |
---|
149 | |
---|
150 | iterPicInsert++; |
---|
151 | } |
---|
152 | |
---|
153 | iterPicExtract_1 = iterPicExtract; iterPicExtract_1++; |
---|
154 | |
---|
155 | // swap iterPicExtract and iterPicInsert, iterPicExtract = curr. / iterPicInsert = insertion position |
---|
156 | rcListPic.insert (iterPicInsert, iterPicExtract, iterPicExtract_1); |
---|
157 | rcListPic.erase (iterPicExtract); |
---|
158 | } |
---|
159 | } |
---|
160 | |
---|
161 | Void TComSlice::setRefPOCList () |
---|
162 | { |
---|
163 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
164 | { |
---|
165 | for (Int iNumRefIdx = 0; iNumRefIdx < m_aiNumRefIdx[iDir]; iNumRefIdx++) |
---|
166 | { |
---|
167 | m_aiRefPOCList[iDir][iNumRefIdx] = m_apcRefPicList[iDir][iNumRefIdx]->getPOC(); |
---|
168 | } |
---|
169 | } |
---|
170 | |
---|
171 | } |
---|
172 | |
---|
173 | #if DCM_COMB_LIST |
---|
174 | Void TComSlice::generateCombinedList() |
---|
175 | { |
---|
176 | if(m_aiNumRefIdx[REF_PIC_LIST_C] > 0) |
---|
177 | { |
---|
178 | m_aiNumRefIdx[REF_PIC_LIST_C]=0; |
---|
179 | for(Int iNumCount = 0; iNumCount < MAX_NUM_REF_LC; iNumCount++) |
---|
180 | { |
---|
181 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumCount]=-1; |
---|
182 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumCount]=-1; |
---|
183 | m_eListIdFromIdxOfLC[iNumCount]=0; |
---|
184 | m_iRefIdxFromIdxOfLC[iNumCount]=0; |
---|
185 | m_iRefIdxOfL0FromRefIdxOfL1[iNumCount] = -1; |
---|
186 | m_iRefIdxOfL1FromRefIdxOfL0[iNumCount] = -1; |
---|
187 | } |
---|
188 | |
---|
189 | for (Int iNumRefIdx = 0; iNumRefIdx < MAX_NUM_REF; iNumRefIdx++) |
---|
190 | { |
---|
191 | if(iNumRefIdx < m_aiNumRefIdx[REF_PIC_LIST_0]){ |
---|
192 | Bool bTempRefIdxInL2 = true; |
---|
193 | for ( Int iRefIdxLC = 0; iRefIdxLC < m_aiNumRefIdx[REF_PIC_LIST_C]; iRefIdxLC++ ) |
---|
194 | { |
---|
195 | if (( m_apcRefPicList[REF_PIC_LIST_0][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() ) && |
---|
196 | ( m_apcRefPicList[REF_PIC_LIST_0][iNumRefIdx]->getViewIdx() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getViewIdx() )) |
---|
197 | { |
---|
198 | m_iRefIdxOfL1FromRefIdxOfL0[iNumRefIdx] = m_iRefIdxFromIdxOfLC[iRefIdxLC]; |
---|
199 | m_iRefIdxOfL0FromRefIdxOfL1[m_iRefIdxFromIdxOfLC[iRefIdxLC]] = iNumRefIdx; |
---|
200 | bTempRefIdxInL2 = false; |
---|
201 | assert(m_eListIdFromIdxOfLC[iRefIdxLC]==REF_PIC_LIST_1); |
---|
202 | break; |
---|
203 | } |
---|
204 | } |
---|
205 | |
---|
206 | if(bTempRefIdxInL2 == true) |
---|
207 | { |
---|
208 | m_eListIdFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = REF_PIC_LIST_0; |
---|
209 | m_iRefIdxFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = iNumRefIdx; |
---|
210 | m_iRefIdxOfLC[REF_PIC_LIST_0][iNumRefIdx] = m_aiNumRefIdx[REF_PIC_LIST_C]++; |
---|
211 | } |
---|
212 | } |
---|
213 | |
---|
214 | if(iNumRefIdx < m_aiNumRefIdx[REF_PIC_LIST_1]){ |
---|
215 | Bool bTempRefIdxInL2 = true; |
---|
216 | for ( Int iRefIdxLC = 0; iRefIdxLC < m_aiNumRefIdx[REF_PIC_LIST_C]; iRefIdxLC++ ) |
---|
217 | { |
---|
218 | if (( m_apcRefPicList[REF_PIC_LIST_1][iNumRefIdx]->getPOC() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getPOC() ) && |
---|
219 | ( m_apcRefPicList[REF_PIC_LIST_1][iNumRefIdx]->getViewIdx() == m_apcRefPicList[m_eListIdFromIdxOfLC[iRefIdxLC]][m_iRefIdxFromIdxOfLC[iRefIdxLC]]->getViewIdx() )) |
---|
220 | { |
---|
221 | m_iRefIdxOfL0FromRefIdxOfL1[iNumRefIdx] = m_iRefIdxFromIdxOfLC[iRefIdxLC]; |
---|
222 | m_iRefIdxOfL1FromRefIdxOfL0[m_iRefIdxFromIdxOfLC[iRefIdxLC]] = iNumRefIdx; |
---|
223 | bTempRefIdxInL2 = false; |
---|
224 | assert(m_eListIdFromIdxOfLC[iRefIdxLC]==REF_PIC_LIST_0); |
---|
225 | break; |
---|
226 | } |
---|
227 | } |
---|
228 | if(bTempRefIdxInL2 == true) |
---|
229 | { |
---|
230 | m_eListIdFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = REF_PIC_LIST_1; |
---|
231 | m_iRefIdxFromIdxOfLC[m_aiNumRefIdx[REF_PIC_LIST_C]] = iNumRefIdx; |
---|
232 | m_iRefIdxOfLC[REF_PIC_LIST_1][iNumRefIdx] = m_aiNumRefIdx[REF_PIC_LIST_C]++; |
---|
233 | } |
---|
234 | } |
---|
235 | } |
---|
236 | } |
---|
237 | } |
---|
238 | #endif |
---|
239 | |
---|
240 | Void TComSlice::setRefPicListFromGOPSTring( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& rapcSpatRefPics ) |
---|
241 | { |
---|
242 | |
---|
243 | if (m_eSliceType == I_SLICE) |
---|
244 | { |
---|
245 | ::memset( m_apcRefPicList, 0, sizeof (m_apcRefPicList)); |
---|
246 | ::memset( m_aiNumRefIdx, 0, sizeof ( m_aiNumRefIdx )); |
---|
247 | |
---|
248 | return; |
---|
249 | } |
---|
250 | |
---|
251 | sortPicList(rcListPic); |
---|
252 | assert( m_eSliceType != P_SLICE || m_pcPic->getNumRefs( REF_PIC_LIST_1 ) == 0 ); |
---|
253 | for(Int iRefList = 0; iRefList<2; iRefList++ ) |
---|
254 | { |
---|
255 | RefPicList eRefList = (RefPicList) iRefList; |
---|
256 | m_aiNumRefIdx[eRefList] = m_pcPic->getNumRefs( eRefList ); |
---|
257 | for( Int i =0; i<m_pcPic->getNumRefs(eRefList); i++ ) |
---|
258 | { |
---|
259 | const int iRefPoc = m_pcPic->getRefPOC( eRefList, i ); |
---|
260 | const int iRefViewIdx = m_pcPic->getRefViewIdx( eRefList, i ); |
---|
261 | m_aiRefPOCList[eRefList][i] = iRefPoc; |
---|
262 | m_aiRefViewList[eRefList][i] = iRefViewIdx; |
---|
263 | |
---|
264 | TComPic* pcRefPic = NULL; |
---|
265 | if( iRefViewIdx == m_iViewIdx ) |
---|
266 | { |
---|
267 | // temporal prediction from current view |
---|
268 | for( TComList<TComPic*>::iterator it = rcListPic.begin(); it!=rcListPic.end(); it++) |
---|
269 | { |
---|
270 | if((*it)->getPOC() == iRefPoc) |
---|
271 | { |
---|
272 | pcRefPic = *it; |
---|
273 | break; |
---|
274 | } |
---|
275 | } |
---|
276 | assert( pcRefPic ); |
---|
277 | if( pcRefPic == NULL && iRefPoc > m_iPOC ) |
---|
278 | { |
---|
279 | const int iAltRefPoc = m_iPOC-(iRefPoc-m_iPOC) ; |
---|
280 | m_aiRefPOCList[eRefList][i] = iAltRefPoc ; |
---|
281 | for( TComList<TComPic*>::iterator it = rcListPic.begin(); it!=rcListPic.end(); it++) |
---|
282 | { |
---|
283 | if((*it)->getPOC() == iAltRefPoc) |
---|
284 | { |
---|
285 | pcRefPic = *it ; |
---|
286 | break; |
---|
287 | } |
---|
288 | } |
---|
289 | } |
---|
290 | } |
---|
291 | else |
---|
292 | { |
---|
293 | // inter-view prediction |
---|
294 | assert( iRefPoc == m_iPOC ); |
---|
295 | assert( 0 <= iRefViewIdx && iRefViewIdx < rapcSpatRefPics.size() ); |
---|
296 | pcRefPic = rapcSpatRefPics[iRefViewIdx]; |
---|
297 | } |
---|
298 | if( pcRefPic ) |
---|
299 | { |
---|
300 | m_apcRefPicList[eRefList][i] = pcRefPic; |
---|
301 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
302 | } |
---|
303 | else |
---|
304 | { |
---|
305 | printf("\n inconsistence in gop string!") ; // gop string inconsistent |
---|
306 | assert(0) ; |
---|
307 | } |
---|
308 | } |
---|
309 | } |
---|
310 | } |
---|
311 | Void TComSlice::setRefPicListExplicitlyDecoderSided( TComList<TComPic*>& rcListPic, std::vector<TComPic*>& rapcSpatRefPics ) |
---|
312 | { |
---|
313 | sortPicList(rcListPic); |
---|
314 | TComPic* pcRefPic = NULL; |
---|
315 | |
---|
316 | for(Int iRefList = 0; iRefList<2; iRefList++) |
---|
317 | { |
---|
318 | RefPicList eRefList = (RefPicList) iRefList; |
---|
319 | for( Int i=0; i<m_aiNumRefIdx[eRefList]; i++ ) |
---|
320 | { |
---|
321 | const int iRefPoc = m_aiRefPOCList[ eRefList][i ]; |
---|
322 | const int iRefViewIdx = m_aiRefViewList[ eRefList][i ]; |
---|
323 | if( iRefViewIdx == m_iViewIdx ) |
---|
324 | { |
---|
325 | for( TComList<TComPic*>::iterator it = rcListPic.begin(); it!=rcListPic.end(); it++) |
---|
326 | { |
---|
327 | if((*it)->getPOC() == iRefPoc) |
---|
328 | { |
---|
329 | pcRefPic = *it; |
---|
330 | break; |
---|
331 | } |
---|
332 | } |
---|
333 | } |
---|
334 | else |
---|
335 | { |
---|
336 | // inter-view prediction |
---|
337 | assert( iRefPoc == m_iPOC ); |
---|
338 | assert( 0 <= iRefViewIdx && iRefViewIdx < rapcSpatRefPics.size() ); |
---|
339 | pcRefPic = rapcSpatRefPics[iRefViewIdx]; |
---|
340 | } |
---|
341 | if( pcRefPic ) |
---|
342 | { |
---|
343 | m_apcRefPicList[eRefList][i] = pcRefPic; |
---|
344 | pcRefPic->getPicYuvRec()->extendPicBorder(); |
---|
345 | } |
---|
346 | else |
---|
347 | { |
---|
348 | printf("\n inconsistence in gop string!") ; // gop string inconsistent |
---|
349 | assert(0) ; |
---|
350 | } |
---|
351 | } |
---|
352 | } |
---|
353 | } |
---|
354 | |
---|
355 | Void TComSlice::initEqualRef() |
---|
356 | { |
---|
357 | for (Int iDir = 0; iDir < 2; iDir++) |
---|
358 | { |
---|
359 | for (Int iRefIdx1 = 0; iRefIdx1 < MAX_NUM_REF; iRefIdx1++) |
---|
360 | { |
---|
361 | for (Int iRefIdx2 = iRefIdx1; iRefIdx2 < MAX_NUM_REF; iRefIdx2++) |
---|
362 | { |
---|
363 | m_abEqualRef[iDir][iRefIdx1][iRefIdx2] = m_abEqualRef[iDir][iRefIdx2][iRefIdx1] = (iRefIdx1 == iRefIdx2? true : false); |
---|
364 | } |
---|
365 | } |
---|
366 | } |
---|
367 | } |
---|
368 | |
---|
369 | Void TComSlice::initMultiviewSlice( Int** aaiScale, Int** aaiOffset ) |
---|
370 | { |
---|
371 | if( m_pcSPS->hasCamParInSliceHeader() ) |
---|
372 | { |
---|
373 | UInt uiViewId = m_pcSPS->getViewId(); |
---|
374 | for( UInt uiBaseViewId = 0; uiBaseViewId < uiViewId; uiBaseViewId++ ) |
---|
375 | { |
---|
376 | m_aaiCodedScale [ 0 ][ uiBaseViewId ] = aaiScale [ uiBaseViewId ][ uiViewId ]; |
---|
377 | m_aaiCodedScale [ 1 ][ uiBaseViewId ] = aaiScale [ uiViewId ][ uiBaseViewId ]; |
---|
378 | m_aaiCodedOffset[ 0 ][ uiBaseViewId ] = aaiOffset[ uiBaseViewId ][ uiViewId ]; |
---|
379 | m_aaiCodedOffset[ 1 ][ uiBaseViewId ] = aaiOffset[ uiViewId ][ uiBaseViewId ]; |
---|
380 | } |
---|
381 | } |
---|
382 | } |
---|
383 | |
---|
384 | |
---|
385 | #if DCM_DECODING_REFRESH |
---|
386 | /** Function for marking the reference pictures when an IDR and CDR is encountered. |
---|
387 | * \param uiPOCCDR POC of the CDR picture |
---|
388 | * \param bRefreshPending flag indicating if a deferred decoding refresh is pending |
---|
389 | * \param rcListPic reference to the reference picture list |
---|
390 | * This function marks the reference pictures as "unused for reference" in the following conditions. |
---|
391 | * If the nal_unit_type is IDR all pictures in the reference picture list |
---|
392 | * is marked as "unused for reference" |
---|
393 | * Otherwise do for the CDR case (non CDR case has no effect since both if conditions below will not be true) |
---|
394 | * If the bRefreshPending flag is true (a deferred decoding refresh is pending) and the current |
---|
395 | * temporal reference is greater than the temporal reference of the latest CDR picture (uiPOCCDR), |
---|
396 | * mark all reference pictures except the latest CDR picture as "unused for reference" and set |
---|
397 | * the bRefreshPending flag to false. |
---|
398 | * If the nal_unit_type is CDR, set the bRefreshPending flag to true and iPOCCDR to the temporal |
---|
399 | * reference of the current picture. |
---|
400 | * Note that the current picture is already placed in the reference list and its marking is not changed. |
---|
401 | * If the current picture has a nal_ref_idc that is not 0, it will remain marked as "used for reference". |
---|
402 | */ |
---|
403 | Void TComSlice::decodingRefreshMarking(UInt& uiPOCCDR, Bool& bRefreshPending, TComList<TComPic*>& rcListPic) |
---|
404 | { |
---|
405 | TComPic* rpcPic; |
---|
406 | UInt uiPOCCurr = getPOC(); |
---|
407 | |
---|
408 | if (getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR) // IDR |
---|
409 | { |
---|
410 | // mark all pictures as not used for reference |
---|
411 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
412 | while (iterPic != rcListPic.end()) |
---|
413 | { |
---|
414 | rpcPic = *(iterPic); |
---|
415 | rpcPic->setCurrSliceIdx(0); |
---|
416 | if (rpcPic->getPOC() != uiPOCCurr) rpcPic->getSlice(0)->setReferenced(false); |
---|
417 | iterPic++; |
---|
418 | } |
---|
419 | } |
---|
420 | else // CDR or No DR |
---|
421 | { |
---|
422 | if (bRefreshPending==true && uiPOCCurr > uiPOCCDR) // CDR reference marking pending |
---|
423 | { |
---|
424 | TComList<TComPic*>::iterator iterPic = rcListPic.begin(); |
---|
425 | while (iterPic != rcListPic.end()) |
---|
426 | { |
---|
427 | rpcPic = *(iterPic); |
---|
428 | if (rpcPic->getPOC() != uiPOCCurr && rpcPic->getPOC() != uiPOCCDR) rpcPic->getSlice(0)->setReferenced(false); |
---|
429 | iterPic++; |
---|
430 | } |
---|
431 | bRefreshPending = false; |
---|
432 | } |
---|
433 | if (getNalUnitType() == NAL_UNIT_CODED_SLICE_CDR) // CDR picture found |
---|
434 | { |
---|
435 | bRefreshPending = true; |
---|
436 | uiPOCCDR = uiPOCCurr; |
---|
437 | } |
---|
438 | } |
---|
439 | } |
---|
440 | #endif |
---|
441 | |
---|
442 | Void TComSlice::copySliceInfo(TComSlice *pSrc) |
---|
443 | { |
---|
444 | assert( pSrc != NULL ); |
---|
445 | |
---|
446 | Int i, j, k; |
---|
447 | |
---|
448 | m_iPOC = pSrc->m_iPOC; |
---|
449 | m_iViewIdx = pSrc->m_iViewIdx; |
---|
450 | #if SONY_COLPIC_AVAILABILITY |
---|
451 | m_iViewOrderIdx = pSrc->m_iViewOrderIdx; |
---|
452 | #endif |
---|
453 | #if DCM_DECODING_REFRESH |
---|
454 | m_eNalUnitType = pSrc->m_eNalUnitType; |
---|
455 | #endif |
---|
456 | m_eSliceType = pSrc->m_eSliceType; |
---|
457 | m_iSliceQp = pSrc->m_iSliceQp; |
---|
458 | m_iSymbolMode = pSrc->m_iSymbolMode; |
---|
459 | m_bLoopFilterDisable = pSrc->m_bLoopFilterDisable; |
---|
460 | |
---|
461 | #if DCM_COMB_LIST |
---|
462 | for (i = 0; i < 3; i++) |
---|
463 | { |
---|
464 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
465 | } |
---|
466 | |
---|
467 | for (i = 0; i < 2; i++) |
---|
468 | { |
---|
469 | for (j = 0; j < MAX_NUM_REF_LC; j++) |
---|
470 | { |
---|
471 | m_iRefIdxOfLC[i][j] = pSrc->m_iRefIdxOfLC[i][j]; |
---|
472 | } |
---|
473 | } |
---|
474 | for (i = 0; i < MAX_NUM_REF_LC; i++) |
---|
475 | { |
---|
476 | m_eListIdFromIdxOfLC[i] = pSrc->m_eListIdFromIdxOfLC[i]; |
---|
477 | m_iRefIdxFromIdxOfLC[i] = pSrc->m_iRefIdxFromIdxOfLC[i]; |
---|
478 | m_iRefIdxOfL1FromRefIdxOfL0[i] = pSrc->m_iRefIdxOfL1FromRefIdxOfL0[i]; |
---|
479 | m_iRefIdxOfL0FromRefIdxOfL1[i] = pSrc->m_iRefIdxOfL0FromRefIdxOfL1[i]; |
---|
480 | } |
---|
481 | m_bRefPicListModificationFlagLC = pSrc->m_bRefPicListModificationFlagLC; |
---|
482 | m_bRefPicListCombinationFlag = pSrc->m_bRefPicListCombinationFlag; |
---|
483 | #else |
---|
484 | for (i = 0; i < 2; i++) |
---|
485 | { |
---|
486 | m_aiNumRefIdx[i] = pSrc->m_aiNumRefIdx[i]; |
---|
487 | } |
---|
488 | #endif |
---|
489 | |
---|
490 | m_iSliceQpDelta = pSrc->m_iSliceQpDelta; |
---|
491 | for (i = 0; i < 2; i++) |
---|
492 | { |
---|
493 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
494 | { |
---|
495 | m_apcRefPicList[i][j] = pSrc->m_apcRefPicList[i][j]; |
---|
496 | m_aiRefPOCList[i][j] = pSrc->m_aiRefPOCList[i][j]; |
---|
497 | m_aiRefViewList[i][j] = pSrc->m_aiRefViewList[i][j]; |
---|
498 | } |
---|
499 | } |
---|
500 | m_iDepth = pSrc->m_iDepth; |
---|
501 | |
---|
502 | // referenced slice |
---|
503 | m_bRefenced = pSrc->m_bRefenced; |
---|
504 | #ifdef ROUNDING_CONTROL_BIPRED |
---|
505 | m_bRounding = pSrc->m_bRounding; |
---|
506 | #endif |
---|
507 | |
---|
508 | // access channel |
---|
509 | m_pcSPS = pSrc->m_pcSPS; |
---|
510 | m_pcPPS = pSrc->m_pcPPS; |
---|
511 | m_uiPPSId = pSrc->m_uiPPSId; |
---|
512 | m_pcPic = pSrc->m_pcPic; |
---|
513 | |
---|
514 | m_uiColDir = pSrc->m_uiColDir; |
---|
515 | m_dLambda = pSrc->m_dLambda; |
---|
516 | for (i = 0; i < 2; i++) |
---|
517 | { |
---|
518 | for (j = 0; j < MAX_NUM_REF; j++) |
---|
519 | { |
---|
520 | for (k =0; k < MAX_NUM_REF; k++) |
---|
521 | { |
---|
522 | m_abEqualRef[i][j][k] = pSrc->m_abEqualRef[i][j][k]; |
---|
523 | } |
---|
524 | } |
---|
525 | } |
---|
526 | |
---|
527 | m_bNoBackPredFlag = pSrc->m_bNoBackPredFlag; |
---|
528 | #if MS_LCEC_LOOKUP_TABLE_EXCEPTION |
---|
529 | m_bRefIdxCombineCoding = pSrc->m_bRefIdxCombineCoding; |
---|
530 | #endif |
---|
531 | m_uiSliceMode = pSrc->m_uiSliceMode; |
---|
532 | m_uiSliceArgument = pSrc->m_uiSliceArgument; |
---|
533 | m_uiSliceCurStartCUAddr = pSrc->m_uiSliceCurStartCUAddr; |
---|
534 | m_uiSliceCurEndCUAddr = pSrc->m_uiSliceCurEndCUAddr; |
---|
535 | m_uiSliceIdx = pSrc->m_uiSliceIdx; |
---|
536 | m_uiEntropySliceMode = pSrc->m_uiEntropySliceMode; |
---|
537 | m_uiEntropySliceArgument = pSrc->m_uiEntropySliceArgument; |
---|
538 | m_uiEntropySliceCurStartCUAddr = pSrc->m_uiEntropySliceCurStartCUAddr; |
---|
539 | m_uiEntropySliceCurEndCUAddr = pSrc->m_uiEntropySliceCurEndCUAddr; |
---|
540 | m_bNextSlice = pSrc->m_bNextSlice; |
---|
541 | m_bNextEntropySlice = pSrc->m_bNextEntropySlice; |
---|
542 | #ifdef WEIGHT_PRED |
---|
543 | for ( int e=0 ; e<2 ; e++ ) |
---|
544 | for ( int n=0 ; n<MAX_NUM_REF ; n++ ) |
---|
545 | memcpy(m_weightPredTable[e][n], pSrc->m_weightPredTable[e][n], sizeof(wpScalingParam)*3 ); |
---|
546 | #endif |
---|
547 | } |
---|
548 | |
---|
549 | #ifdef WEIGHT_PRED |
---|
550 | Void TComSlice::getWpScaling( RefPicList e, Int iRefIdx, wpScalingParam *&wp ) |
---|
551 | { |
---|
552 | wp = m_weightPredTable[e][iRefIdx]; |
---|
553 | } |
---|
554 | |
---|
555 | Void TComSlice::displayWpScaling() |
---|
556 | { |
---|
557 | Bool bFound = false; |
---|
558 | for ( int e=0 ; e<2 ; e++ ) { |
---|
559 | for ( int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
560 | for ( int yuv=0 ; yuv<3 ; yuv++ ) |
---|
561 | if ( m_weightPredTable[e][i][yuv].bPresentFlag ) { |
---|
562 | if ( !bFound ) { |
---|
563 | printf("\tluma_log2_weight_denom = %d\n", m_weightPredTable[0][0][0].uiLog2WeightDenom); |
---|
564 | printf("\tchroma_log2_weight_denom = %d\n", m_weightPredTable[0][0][1].uiLog2WeightDenom); |
---|
565 | bFound = true; |
---|
566 | } |
---|
567 | Double weight = (Double)m_weightPredTable[e][i][yuv].iWeight / (Double)(1<<m_weightPredTable[0][0][0].uiLog2WeightDenom); |
---|
568 | if ( yuv == 0 ) { |
---|
569 | printf("\tluma_weight_l%d_flag = 1\n", e); |
---|
570 | printf("\t luma_weight_l%d[%d] = %d => w = %g\n", e, i, m_weightPredTable[e][i][yuv].iWeight, weight); |
---|
571 | printf("\t luma_offset_l%d[%d] = %d\n", e, i, m_weightPredTable[e][i][yuv].iOffset); |
---|
572 | } |
---|
573 | else { |
---|
574 | if ( yuv == 1 ) printf("\tchroma_weight_l%d_flag = 1\n", e); |
---|
575 | printf("\t chroma_weight_l%d[%d][%d] = %d => w = %g\n", e, i, yuv-1, m_weightPredTable[e][i][yuv].iWeight, weight); |
---|
576 | printf("\t chroma_offset_l%d[%d][%d] = %d\n", e, i, yuv-1, m_weightPredTable[e][i][yuv].iOffset); |
---|
577 | } |
---|
578 | } |
---|
579 | } |
---|
580 | } |
---|
581 | |
---|
582 | // Default WP values settings : no weight. |
---|
583 | Void TComSlice::resetWpScaling(wpScalingParam wp[2][MAX_NUM_REF][3]) |
---|
584 | { |
---|
585 | for ( int e=0 ; e<2 ; e++ ) { |
---|
586 | for ( int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
587 | for ( int yuv=0 ; yuv<3 ; yuv++ ) { |
---|
588 | wpScalingParam *pwp = &(wp[e][i][yuv]); |
---|
589 | pwp->bPresentFlag = false; |
---|
590 | pwp->uiLog2WeightDenom = 0; |
---|
591 | pwp->uiLog2WeightDenom = 0; |
---|
592 | pwp->iWeight = 1; |
---|
593 | pwp->iOffset = 0; |
---|
594 | } |
---|
595 | } |
---|
596 | } |
---|
597 | |
---|
598 | Void TComSlice::initWpScaling() |
---|
599 | { |
---|
600 | initWpScaling(m_weightPredTable); |
---|
601 | } |
---|
602 | |
---|
603 | Void TComSlice::initWpScaling(wpScalingParam wp[2][MAX_NUM_REF][3]) |
---|
604 | { |
---|
605 | for ( int e=0 ; e<2 ; e++ ) { |
---|
606 | for ( int i=0 ; i<MAX_NUM_REF ; i++ ) |
---|
607 | for ( int yuv=0 ; yuv<3 ; yuv++ ) { |
---|
608 | wpScalingParam *pwp = &(wp[e][i][yuv]); |
---|
609 | if ( !pwp->bPresentFlag ) { |
---|
610 | // Inferring values not present : |
---|
611 | pwp->iWeight = (1 << pwp->uiLog2WeightDenom); |
---|
612 | pwp->iOffset = 0; |
---|
613 | } |
---|
614 | |
---|
615 | pwp->w = pwp->iWeight; |
---|
616 | pwp->o = pwp->iOffset * (1 << (g_uiBitDepth-8)); |
---|
617 | pwp->shift = pwp->uiLog2WeightDenom; |
---|
618 | pwp->round = (pwp->uiLog2WeightDenom>=1) ? (1 << (pwp->uiLog2WeightDenom-1)) : (0); |
---|
619 | } |
---|
620 | } |
---|
621 | } |
---|
622 | #endif |
---|
623 | |
---|
624 | #ifdef WEIGHT_PRED |
---|
625 | Void TComSlice::getWpAcDcParam(wpACDCParam *&wp) |
---|
626 | { |
---|
627 | wp = m_weightACDCParam; |
---|
628 | } |
---|
629 | |
---|
630 | Void TComSlice::initWpAcDcParam() |
---|
631 | { |
---|
632 | for(Int iComp = 0; iComp < 3; iComp++ ) |
---|
633 | { |
---|
634 | m_weightACDCParam[iComp].iAC = 0; |
---|
635 | m_weightACDCParam[iComp].iDC = 0; |
---|
636 | } |
---|
637 | } |
---|
638 | #endif |
---|
639 | |
---|
640 | // ------------------------------------------------------------------------------------------------ |
---|
641 | // Sequence parameter set (SPS) |
---|
642 | // ------------------------------------------------------------------------------------------------ |
---|
643 | |
---|
644 | TComSPS::TComSPS() |
---|
645 | { |
---|
646 | // Structure |
---|
647 | m_uiSPSId = 0; |
---|
648 | m_uiWidth = 352; |
---|
649 | m_uiHeight = 288; |
---|
650 | m_uiMaxCUWidth = 32; |
---|
651 | m_uiMaxCUHeight = 32; |
---|
652 | m_uiMaxCUDepth = 3; |
---|
653 | m_uiMinTrDepth = 0; |
---|
654 | m_uiMaxTrDepth = 1; |
---|
655 | m_uiMaxTrSize = 32; |
---|
656 | |
---|
657 | // Tool list |
---|
658 | m_bUseALF = false; |
---|
659 | m_bUseDQP = false; |
---|
660 | |
---|
661 | m_bUseMRG = false; // SOPH: |
---|
662 | #if HHI_MPI |
---|
663 | m_bUseMVI = false; |
---|
664 | #endif |
---|
665 | |
---|
666 | #if BITSTREAM_EXTRACTION |
---|
667 | m_uiLayerId = 0; |
---|
668 | #endif |
---|
669 | m_uiViewId = 0; |
---|
670 | m_iViewOrderIdx = 0; |
---|
671 | m_bDepth = false; |
---|
672 | m_uiCamParPrecision = 0; |
---|
673 | m_bCamParInSliceHeader = false; |
---|
674 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
675 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
676 | |
---|
677 | #if DEPTH_MAP_GENERATION |
---|
678 | m_uiPredDepthMapGeneration = 0; |
---|
679 | m_uiPdmPrecision = 0; |
---|
680 | ::memset( m_aiPdmScaleNomDelta, 0x00, sizeof( m_aiPdmScaleNomDelta ) ); |
---|
681 | ::memset( m_aiPdmOffset, 0x00, sizeof( m_aiPdmOffset ) ); |
---|
682 | #endif |
---|
683 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
684 | m_uiMultiviewMvPredMode = 0; |
---|
685 | #endif |
---|
686 | #if HHI_INTER_VIEW_RESIDUAL_PRED |
---|
687 | m_uiMultiviewResPredMode = 0; |
---|
688 | #endif |
---|
689 | |
---|
690 | // AMVP parameter |
---|
691 | ::memset( m_aeAMVPMode, 0, sizeof( m_aeAMVPMode ) ); |
---|
692 | |
---|
693 | #if ( HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX ) |
---|
694 | m_bUseDMM = false; |
---|
695 | #endif |
---|
696 | #if HHI_DMM_PRED_TEX && FLEX_CODING_ORDER |
---|
697 | m_bUseDMM34 = false; |
---|
698 | #endif |
---|
699 | } |
---|
700 | |
---|
701 | TComSPS::~TComSPS() |
---|
702 | { |
---|
703 | } |
---|
704 | |
---|
705 | TComPPS::TComPPS() |
---|
706 | { |
---|
707 | #if BITSTREAM_EXTRACTION |
---|
708 | m_uiLayerId = 0; |
---|
709 | #endif |
---|
710 | #if CONSTRAINED_INTRA_PRED |
---|
711 | m_bConstrainedIntraPred = false; |
---|
712 | #endif |
---|
713 | m_uiSPSId = 0; |
---|
714 | m_uiPPSId = 0; |
---|
715 | } |
---|
716 | |
---|
717 | TComPPS::~TComPPS() |
---|
718 | { |
---|
719 | } |
---|
720 | |
---|
721 | Void |
---|
722 | TComSPS::initMultiviewSPS( UInt uiViewId, Int iViewOrderIdx, UInt uiCamParPrecision, Bool bCamParSlice, Int** aaiScale, Int** aaiOffset ) |
---|
723 | { |
---|
724 | AOT( uiViewId == 0 && iViewOrderIdx != 0 ); |
---|
725 | AOT( uiViewId != 0 && iViewOrderIdx == 0 ); |
---|
726 | AOT( uiViewId != 0 && !bCamParSlice && ( aaiScale == 0 || aaiOffset == 0 ) ); |
---|
727 | |
---|
728 | m_uiViewId = uiViewId; |
---|
729 | m_iViewOrderIdx = iViewOrderIdx; |
---|
730 | m_bDepth = false; |
---|
731 | m_uiCamParPrecision = ( m_uiViewId ? uiCamParPrecision : 0 ); |
---|
732 | m_bCamParInSliceHeader = ( m_uiViewId ? bCamParSlice : false ); |
---|
733 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
734 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
735 | if( !m_bCamParInSliceHeader ) |
---|
736 | { |
---|
737 | for( UInt uiBaseViewId = 0; uiBaseViewId < m_uiViewId; uiBaseViewId++ ) |
---|
738 | { |
---|
739 | m_aaiCodedScale [ 0 ][ uiBaseViewId ] = aaiScale [ uiBaseViewId ][ m_uiViewId ]; |
---|
740 | m_aaiCodedScale [ 1 ][ uiBaseViewId ] = aaiScale [ m_uiViewId ][ uiBaseViewId ]; |
---|
741 | m_aaiCodedOffset[ 0 ][ uiBaseViewId ] = aaiOffset[ uiBaseViewId ][ m_uiViewId ]; |
---|
742 | m_aaiCodedOffset[ 1 ][ uiBaseViewId ] = aaiOffset[ m_uiViewId ][ uiBaseViewId ]; |
---|
743 | } |
---|
744 | } |
---|
745 | } |
---|
746 | |
---|
747 | Void |
---|
748 | TComSPS::initMultiviewSPSDepth( UInt uiViewId, Int iViewOrderIdx ) |
---|
749 | { |
---|
750 | AOT( uiViewId == 0 && iViewOrderIdx != 0 ); |
---|
751 | AOT( uiViewId != 0 && iViewOrderIdx == 0 ); |
---|
752 | |
---|
753 | m_uiViewId = uiViewId; |
---|
754 | m_iViewOrderIdx = iViewOrderIdx; |
---|
755 | m_bDepth = true; |
---|
756 | m_uiCamParPrecision = 0; |
---|
757 | m_bCamParInSliceHeader = false; |
---|
758 | ::memset( m_aaiCodedScale, 0x00, sizeof( m_aaiCodedScale ) ); |
---|
759 | ::memset( m_aaiCodedOffset, 0x00, sizeof( m_aaiCodedOffset ) ); |
---|
760 | } |
---|
761 | |
---|
762 | |
---|
763 | #if DEPTH_MAP_GENERATION |
---|
764 | Void |
---|
765 | TComSPS::setPredDepthMapGeneration( UInt uiViewId, Bool bIsDepth, UInt uiPdmGenMode, UInt uiPdmMvPredMode, UInt uiPdmPrec, Int** aaiPdmScaleNomDelta, Int** aaiPdmOffset ) |
---|
766 | { |
---|
767 | AOF( m_uiViewId == uiViewId ); |
---|
768 | AOF( m_bDepth == bIsDepth ); |
---|
769 | AOT( ( uiViewId == 0 || bIsDepth ) && uiPdmGenMode ); |
---|
770 | AOT( uiPdmGenMode && ( aaiPdmScaleNomDelta == 0 || aaiPdmOffset == 0 ) ); |
---|
771 | AOT( uiPdmMvPredMode && uiPdmGenMode == 0 ); |
---|
772 | |
---|
773 | m_uiPredDepthMapGeneration = uiPdmGenMode; |
---|
774 | #if HHI_INTER_VIEW_MOTION_PRED |
---|
775 | m_uiMultiviewMvPredMode = uiPdmMvPredMode; |
---|
776 | #endif |
---|
777 | m_uiPdmPrecision = ( m_uiPredDepthMapGeneration ? uiPdmPrec : 0 ); |
---|
778 | ::memset( m_aiPdmScaleNomDelta, 0x00, sizeof( m_aiPdmScaleNomDelta ) ); |
---|
779 | ::memset( m_aiPdmOffset, 0x00, sizeof( m_aiPdmOffset ) ); |
---|
780 | if( m_uiPredDepthMapGeneration ) |
---|
781 | { |
---|
782 | for( UInt uiBaseId = 0; uiBaseId < m_uiViewId; uiBaseId++ ) |
---|
783 | { |
---|
784 | m_aiPdmScaleNomDelta[ uiBaseId ] = aaiPdmScaleNomDelta[ m_uiViewId ][ uiBaseId ]; |
---|
785 | m_aiPdmOffset [ uiBaseId ] = aaiPdmOffset [ m_uiViewId ][ uiBaseId ]; |
---|
786 | } |
---|
787 | } |
---|
788 | } |
---|
789 | #endif |
---|