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