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 TDecCAVLC.cpp |
---|
35 | \brief CAVLC decoder class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "TDecCAVLC.h" |
---|
39 | #include "SEIread.h" |
---|
40 | #include "TDecSlice.h" |
---|
41 | |
---|
42 | //! \ingroup TLibDecoder |
---|
43 | //! \{ |
---|
44 | |
---|
45 | #if ENC_DEC_TRACE |
---|
46 | |
---|
47 | #define READ_CODE(length, code, name) xReadCodeTr ( length, code, name ) |
---|
48 | #define READ_UVLC( code, name) xReadUvlcTr ( code, name ) |
---|
49 | #define READ_SVLC( code, name) xReadSvlcTr ( code, name ) |
---|
50 | #define READ_FLAG( code, name) xReadFlagTr ( code, name ) |
---|
51 | |
---|
52 | Void xTraceSPSHeader (TComSPS *pSPS) |
---|
53 | { |
---|
54 | fprintf( g_hTrace, "=========== Sequence Parameter Set ID: %d ===========\n", pSPS->getSPSId() ); |
---|
55 | } |
---|
56 | |
---|
57 | Void xTracePPSHeader (TComPPS *pPPS) |
---|
58 | { |
---|
59 | fprintf( g_hTrace, "=========== Picture Parameter Set ID: %d ===========\n", pPPS->getPPSId() ); |
---|
60 | } |
---|
61 | |
---|
62 | Void xTraceAPSHeader (TComAPS *pAPS) |
---|
63 | { |
---|
64 | fprintf( g_hTrace, "=========== Adaptation Parameter Set ===========\n"); |
---|
65 | } |
---|
66 | |
---|
67 | Void xTraceSliceHeader (TComSlice *pSlice) |
---|
68 | { |
---|
69 | fprintf( g_hTrace, "=========== Slice ===========\n"); |
---|
70 | } |
---|
71 | |
---|
72 | |
---|
73 | Void TDecCavlc::xReadCodeTr (UInt length, UInt& rValue, const Char *pSymbolName) |
---|
74 | { |
---|
75 | xReadCode (length, rValue); |
---|
76 | fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); |
---|
77 | fprintf( g_hTrace, "%-40s u(%d) : %d\n", pSymbolName, length, rValue ); |
---|
78 | fflush ( g_hTrace ); |
---|
79 | } |
---|
80 | |
---|
81 | Void TDecCavlc::xReadUvlcTr (UInt& rValue, const Char *pSymbolName) |
---|
82 | { |
---|
83 | xReadUvlc (rValue); |
---|
84 | fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); |
---|
85 | fprintf( g_hTrace, "%-40s u(v) : %d\n", pSymbolName, rValue ); |
---|
86 | fflush ( g_hTrace ); |
---|
87 | } |
---|
88 | |
---|
89 | Void TDecCavlc::xReadSvlcTr (Int& rValue, const Char *pSymbolName) |
---|
90 | { |
---|
91 | xReadSvlc(rValue); |
---|
92 | fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); |
---|
93 | fprintf( g_hTrace, "%-40s s(v) : %d\n", pSymbolName, rValue ); |
---|
94 | fflush ( g_hTrace ); |
---|
95 | } |
---|
96 | |
---|
97 | Void TDecCavlc::xReadFlagTr (UInt& rValue, const Char *pSymbolName) |
---|
98 | { |
---|
99 | xReadFlag(rValue); |
---|
100 | fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); |
---|
101 | fprintf( g_hTrace, "%-40s u(1) : %d\n", pSymbolName, rValue ); |
---|
102 | fflush ( g_hTrace ); |
---|
103 | } |
---|
104 | |
---|
105 | #else |
---|
106 | |
---|
107 | #define READ_CODE(length, code, name) xReadCode ( length, code ) |
---|
108 | #define READ_UVLC( code, name) xReadUvlc ( code ) |
---|
109 | #define READ_SVLC( code, name) xReadSvlc ( code ) |
---|
110 | #define READ_FLAG( code, name) xReadFlag ( code ) |
---|
111 | |
---|
112 | #endif |
---|
113 | |
---|
114 | |
---|
115 | |
---|
116 | // ==================================================================================================================== |
---|
117 | // Constructor / destructor / create / destroy |
---|
118 | // ==================================================================================================================== |
---|
119 | |
---|
120 | TDecCavlc::TDecCavlc() |
---|
121 | { |
---|
122 | m_iSliceGranularity = 0; |
---|
123 | |
---|
124 | m_aaiTempScale = new Int* [ MAX_VIEW_NUM ]; |
---|
125 | m_aaiTempOffset = new Int* [ MAX_VIEW_NUM ]; |
---|
126 | m_aaiTempPdmScaleNomDelta = new Int* [ MAX_VIEW_NUM ]; |
---|
127 | m_aaiTempPdmOffset = new Int* [ MAX_VIEW_NUM ]; |
---|
128 | for( UInt uiVId = 0; uiVId < MAX_VIEW_NUM; uiVId++ ) |
---|
129 | { |
---|
130 | m_aaiTempScale [ uiVId ] = new Int [ MAX_VIEW_NUM ]; |
---|
131 | m_aaiTempOffset [ uiVId ] = new Int [ MAX_VIEW_NUM ]; |
---|
132 | m_aaiTempPdmScaleNomDelta [ uiVId ] = new Int [ MAX_VIEW_NUM ]; |
---|
133 | m_aaiTempPdmOffset [ uiVId ] = new Int [ MAX_VIEW_NUM ]; |
---|
134 | } |
---|
135 | } |
---|
136 | |
---|
137 | TDecCavlc::~TDecCavlc() |
---|
138 | { |
---|
139 | for( UInt uiVId = 0; uiVId < MAX_VIEW_NUM; uiVId++ ) |
---|
140 | { |
---|
141 | delete [] m_aaiTempScale [ uiVId ]; |
---|
142 | delete [] m_aaiTempOffset [ uiVId ]; |
---|
143 | delete [] m_aaiTempPdmScaleNomDelta [ uiVId ]; |
---|
144 | delete [] m_aaiTempPdmOffset [ uiVId ]; |
---|
145 | } |
---|
146 | delete [] m_aaiTempScale; |
---|
147 | delete [] m_aaiTempOffset; |
---|
148 | delete [] m_aaiTempPdmScaleNomDelta; |
---|
149 | delete [] m_aaiTempPdmOffset; |
---|
150 | } |
---|
151 | |
---|
152 | // ==================================================================================================================== |
---|
153 | // Public member functions |
---|
154 | // ==================================================================================================================== |
---|
155 | |
---|
156 | /** |
---|
157 | * unmarshal a sequence of SEI messages from bitstream. |
---|
158 | */ |
---|
159 | void TDecCavlc::parseSEI(SEImessages& seis) |
---|
160 | { |
---|
161 | assert(!m_pcBitstream->getNumBitsUntilByteAligned()); |
---|
162 | do |
---|
163 | { |
---|
164 | parseSEImessage(*m_pcBitstream, seis); |
---|
165 | /* SEI messages are an integer number of bytes, something has failed |
---|
166 | * in the parsing if bitstream not byte-aligned */ |
---|
167 | assert(!m_pcBitstream->getNumBitsUntilByteAligned()); |
---|
168 | } while (0x80 != m_pcBitstream->peekBits(8)); |
---|
169 | assert(m_pcBitstream->getNumBitsLeft() == 8); /* rsbp_trailing_bits */ |
---|
170 | } |
---|
171 | void TDecCavlc::parseShortTermRefPicSet( TComSPS* sps, TComReferencePictureSet* rps, Int idx ) |
---|
172 | { |
---|
173 | UInt code; |
---|
174 | UInt interRPSPred; |
---|
175 | READ_FLAG(interRPSPred, "inter_ref_pic_set_prediction_flag"); rps->setInterRPSPrediction(interRPSPred); |
---|
176 | if (interRPSPred) |
---|
177 | { |
---|
178 | UInt bit; |
---|
179 | READ_UVLC(code, "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1 |
---|
180 | Int rIdx = idx - 1 - code; |
---|
181 | assert (rIdx <= idx && rIdx >= 0); |
---|
182 | TComReferencePictureSet* rpsRef = sps->getRPSList()->getReferencePictureSet(rIdx); |
---|
183 | Int k = 0, k0 = 0, k1 = 0; |
---|
184 | READ_CODE(1, bit, "delta_rps_sign"); // delta_RPS_sign |
---|
185 | READ_UVLC(code, "abs_delta_rps_minus1"); // absolute delta RPS minus 1 |
---|
186 | Int deltaRPS = (1 - (bit<<1)) * (code + 1); // delta_RPS |
---|
187 | for(Int j=0 ; j <= rpsRef->getNumberOfPictures(); j++) |
---|
188 | { |
---|
189 | READ_CODE(1, bit, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 |
---|
190 | Int refIdc = bit; |
---|
191 | if (refIdc == 0) |
---|
192 | { |
---|
193 | READ_CODE(1, bit, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise. |
---|
194 | refIdc = bit<<1; //second bit is "1" if refIdc is 2, "0" if refIdc = 0. |
---|
195 | } |
---|
196 | if (refIdc == 1 || refIdc == 2) |
---|
197 | { |
---|
198 | Int deltaPOC = deltaRPS + ((j < rpsRef->getNumberOfPictures())? rpsRef->getDeltaPOC(j) : 0); |
---|
199 | rps->setDeltaPOC(k, deltaPOC); |
---|
200 | rps->setUsed(k, (refIdc == 1)); |
---|
201 | |
---|
202 | if (deltaPOC < 0) { |
---|
203 | k0++; |
---|
204 | } |
---|
205 | else |
---|
206 | { |
---|
207 | k1++; |
---|
208 | } |
---|
209 | k++; |
---|
210 | } |
---|
211 | rps->setRefIdc(j,refIdc); |
---|
212 | } |
---|
213 | rps->setNumRefIdc(rpsRef->getNumberOfPictures()+1); |
---|
214 | rps->setNumberOfPictures(k); |
---|
215 | rps->setNumberOfNegativePictures(k0); |
---|
216 | rps->setNumberOfPositivePictures(k1); |
---|
217 | rps->sortDeltaPOC(); |
---|
218 | } |
---|
219 | else |
---|
220 | { |
---|
221 | READ_UVLC(code, "num_negative_pics"); rps->setNumberOfNegativePictures(code); |
---|
222 | READ_UVLC(code, "num_positive_pics"); rps->setNumberOfPositivePictures(code); |
---|
223 | Int prev = 0; |
---|
224 | Int poc; |
---|
225 | for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++) |
---|
226 | { |
---|
227 | READ_UVLC(code, "delta_poc_s0_minus1"); |
---|
228 | poc = prev-code-1; |
---|
229 | prev = poc; |
---|
230 | rps->setDeltaPOC(j,poc); |
---|
231 | READ_FLAG(code, "used_by_curr_pic_s0_flag"); rps->setUsed(j,code); |
---|
232 | } |
---|
233 | prev = 0; |
---|
234 | for(Int j=rps->getNumberOfNegativePictures(); j < rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); j++) |
---|
235 | { |
---|
236 | READ_UVLC(code, "delta_poc_s1_minus1"); |
---|
237 | poc = prev+code+1; |
---|
238 | prev = poc; |
---|
239 | rps->setDeltaPOC(j,poc); |
---|
240 | READ_FLAG(code, "used_by_curr_pic_s1_flag"); rps->setUsed(j,code); |
---|
241 | } |
---|
242 | rps->setNumberOfPictures(rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures()); |
---|
243 | } |
---|
244 | #if PRINT_RPS_INFO |
---|
245 | rps->printDeltaPOC(); |
---|
246 | #endif |
---|
247 | } |
---|
248 | |
---|
249 | Void TDecCavlc::parseAPS(TComAPS* aps) |
---|
250 | { |
---|
251 | #if ENC_DEC_TRACE |
---|
252 | xTraceAPSHeader(aps); |
---|
253 | #endif |
---|
254 | |
---|
255 | UInt uiCode; |
---|
256 | READ_UVLC(uiCode, "aps_id"); aps->setAPSID(uiCode); |
---|
257 | READ_FLAG(uiCode, "aps_scaling_list_data_present_flag"); aps->setScalingListEnabled( (uiCode==1)?true:false ); |
---|
258 | READ_FLAG(uiCode, "aps_deblocking_filter_flag"); aps->setLoopFilterOffsetInAPS( (uiCode==1)?true:false ); |
---|
259 | if(aps->getScalingListEnabled()) |
---|
260 | { |
---|
261 | parseScalingList( aps->getScalingList() ); |
---|
262 | } |
---|
263 | if(aps->getLoopFilterOffsetInAPS()) |
---|
264 | { |
---|
265 | xParseDblParam( aps ); |
---|
266 | } |
---|
267 | READ_FLAG(uiCode, "aps_sao_interleaving_flag"); aps->setSaoInterleavingFlag( (uiCode==1)?true:false ); |
---|
268 | if(!aps->getSaoInterleavingFlag()) |
---|
269 | { |
---|
270 | READ_FLAG(uiCode, "aps_sample_adaptive_offset_flag"); aps->setSaoEnabled( (uiCode==1)?true:false ); |
---|
271 | if(aps->getSaoEnabled()) |
---|
272 | { |
---|
273 | aps->getSaoParam()->bSaoFlag[0] = true; |
---|
274 | xParseSaoParam( aps->getSaoParam() ); |
---|
275 | } |
---|
276 | } |
---|
277 | READ_FLAG(uiCode, "aps_adaptive_loop_filter_flag"); aps->setAlfEnabled( (uiCode==1)?true:false ); |
---|
278 | if(aps->getAlfEnabled()) |
---|
279 | { |
---|
280 | xParseAlfParam( aps->getAlfParam()); |
---|
281 | } |
---|
282 | READ_FLAG( uiCode, "aps_extension_flag"); |
---|
283 | if (uiCode) |
---|
284 | { |
---|
285 | while ( xMoreRbspData() ) |
---|
286 | { |
---|
287 | READ_FLAG( uiCode, "aps_extension_data_flag"); |
---|
288 | } |
---|
289 | } |
---|
290 | |
---|
291 | } |
---|
292 | |
---|
293 | Void TDecCavlc::xParseDblParam ( TComAPS* aps ) |
---|
294 | { |
---|
295 | UInt uiSymbol; |
---|
296 | Int iSymbol; |
---|
297 | |
---|
298 | parseDFFlag(uiSymbol, "loop_filter_disable"); |
---|
299 | aps->setLoopFilterDisable(uiSymbol?true:false); |
---|
300 | |
---|
301 | if (!aps->getLoopFilterDisable()) |
---|
302 | { |
---|
303 | parseDFSvlc(iSymbol, "beta_offset_div2"); |
---|
304 | aps->setLoopFilterBetaOffset(iSymbol); |
---|
305 | parseDFSvlc(iSymbol, "tc_offset_div2"); |
---|
306 | aps->setLoopFilterTcOffset(iSymbol); |
---|
307 | } |
---|
308 | } |
---|
309 | /** parse SAO parameters |
---|
310 | * \param pSaoParam |
---|
311 | */ |
---|
312 | Void TDecCavlc::xParseSaoParam(SAOParam* pSaoParam) |
---|
313 | { |
---|
314 | UInt uiSymbol; |
---|
315 | |
---|
316 | int i,j, compIdx; |
---|
317 | int numCuInWidth; |
---|
318 | int numCuInHeight; |
---|
319 | Bool repeatedRow[3]; |
---|
320 | if (pSaoParam->bSaoFlag[0]) |
---|
321 | { |
---|
322 | READ_FLAG (uiSymbol, "sao_cb_enable_flag"); pSaoParam->bSaoFlag[1] = uiSymbol? true:false; |
---|
323 | READ_FLAG (uiSymbol, "sao_cr_enable_flag"); pSaoParam->bSaoFlag[2] = uiSymbol? true:false; |
---|
324 | READ_UVLC (uiSymbol, "sao_num_lcu_in_width_minus1"); pSaoParam->numCuInWidth = uiSymbol + 1; |
---|
325 | READ_UVLC (uiSymbol, "sao_num_lcu_in_height_minus1"); pSaoParam->numCuInHeight = uiSymbol + 1; |
---|
326 | numCuInWidth = pSaoParam->numCuInWidth; |
---|
327 | numCuInHeight = pSaoParam->numCuInHeight; |
---|
328 | |
---|
329 | READ_FLAG (uiSymbol, "sao_one_luma_unit_flag"); pSaoParam->oneUnitFlag[0] = uiSymbol? true:false; |
---|
330 | if (pSaoParam->oneUnitFlag[0] ) |
---|
331 | xParseSaoOffset(&(pSaoParam->saoLcuParam[0][0])); |
---|
332 | |
---|
333 | if (pSaoParam->bSaoFlag[1]) |
---|
334 | { |
---|
335 | READ_FLAG (uiSymbol, "sao_one_cb_unit_flag"); pSaoParam->oneUnitFlag[1] = uiSymbol? true:false; |
---|
336 | if (pSaoParam->oneUnitFlag[1] ) |
---|
337 | xParseSaoOffset(&(pSaoParam->saoLcuParam[1][0])); |
---|
338 | } |
---|
339 | if (pSaoParam->bSaoFlag[2]) |
---|
340 | { |
---|
341 | READ_FLAG (uiSymbol, "sao_one_cr_unit_flag"); pSaoParam->oneUnitFlag[2] = uiSymbol? true:false; |
---|
342 | if (pSaoParam->oneUnitFlag[2] ) |
---|
343 | xParseSaoOffset(&(pSaoParam->saoLcuParam[2][0])); |
---|
344 | } |
---|
345 | for (j=0;j<numCuInHeight;j++) |
---|
346 | { |
---|
347 | for (compIdx=0;compIdx<3;compIdx++) |
---|
348 | { |
---|
349 | repeatedRow[compIdx] = 0; |
---|
350 | } |
---|
351 | for (i=0;i<numCuInWidth;i++) |
---|
352 | { |
---|
353 | for (compIdx=0; compIdx<3; compIdx++) |
---|
354 | { |
---|
355 | if (pSaoParam->bSaoFlag[compIdx] && !pSaoParam->oneUnitFlag[compIdx]) |
---|
356 | { |
---|
357 | if (j>0 && i==0) |
---|
358 | { |
---|
359 | READ_FLAG (uiSymbol, "sao_repeat_row_flag"); repeatedRow[compIdx] = uiSymbol? true:false; |
---|
360 | } |
---|
361 | xParseSaoUnit (i,j, compIdx, pSaoParam, repeatedRow[compIdx]); |
---|
362 | } |
---|
363 | } |
---|
364 | } |
---|
365 | } |
---|
366 | } |
---|
367 | } |
---|
368 | /** copy SAO parameter |
---|
369 | * \param dst |
---|
370 | * \param src |
---|
371 | */ |
---|
372 | inline Void copySaoOneLcuParam(SaoLcuParam* dst, SaoLcuParam* src) |
---|
373 | { |
---|
374 | Int i; |
---|
375 | dst->partIdx = src->partIdx; |
---|
376 | dst->typeIdx = src->typeIdx; |
---|
377 | if (dst->typeIdx != -1) |
---|
378 | { |
---|
379 | if (dst->typeIdx == SAO_BO) |
---|
380 | { |
---|
381 | dst->bandPosition = src->bandPosition ; |
---|
382 | } |
---|
383 | else |
---|
384 | { |
---|
385 | dst->bandPosition = 0; |
---|
386 | } |
---|
387 | dst->length = src->length; |
---|
388 | for (i=0;i<dst->length;i++) |
---|
389 | { |
---|
390 | dst->offset[i] = src->offset[i]; |
---|
391 | } |
---|
392 | } |
---|
393 | else |
---|
394 | { |
---|
395 | dst->length = 0; |
---|
396 | for (i=0;i<SAO_BO_LEN;i++) |
---|
397 | { |
---|
398 | dst->offset[i] = 0; |
---|
399 | } |
---|
400 | } |
---|
401 | } |
---|
402 | /** parse SAO offset |
---|
403 | * \param saoLcuParam SAO LCU parameters |
---|
404 | */ |
---|
405 | Void TDecCavlc::xParseSaoOffset(SaoLcuParam* saoLcuParam) |
---|
406 | { |
---|
407 | UInt uiSymbol; |
---|
408 | Int iSymbol; |
---|
409 | static Int typeLength[MAX_NUM_SAO_TYPE] = { |
---|
410 | SAO_EO_LEN, |
---|
411 | SAO_EO_LEN, |
---|
412 | SAO_EO_LEN, |
---|
413 | SAO_EO_LEN, |
---|
414 | SAO_BO_LEN |
---|
415 | }; |
---|
416 | |
---|
417 | READ_UVLC (uiSymbol, "sao_type_idx"); saoLcuParam->typeIdx = (Int)uiSymbol - 1; |
---|
418 | if (uiSymbol) |
---|
419 | { |
---|
420 | saoLcuParam->length = typeLength[saoLcuParam->typeIdx]; |
---|
421 | if( saoLcuParam->typeIdx == SAO_BO ) |
---|
422 | { |
---|
423 | READ_CODE( 5, uiSymbol, "sao_band_position"); saoLcuParam->bandPosition = uiSymbol; |
---|
424 | for(Int i=0; i< saoLcuParam->length; i++) |
---|
425 | { |
---|
426 | READ_SVLC (iSymbol, "sao_offset"); saoLcuParam->offset[i] = iSymbol; |
---|
427 | } |
---|
428 | } |
---|
429 | else if( saoLcuParam->typeIdx < 4 ) |
---|
430 | { |
---|
431 | READ_UVLC (uiSymbol, "sao_offset"); saoLcuParam->offset[0] = uiSymbol; |
---|
432 | READ_UVLC (uiSymbol, "sao_offset"); saoLcuParam->offset[1] = uiSymbol; |
---|
433 | READ_UVLC (uiSymbol, "sao_offset"); saoLcuParam->offset[2] = -(Int)uiSymbol; |
---|
434 | READ_UVLC (uiSymbol, "sao_offset"); saoLcuParam->offset[3] = -(Int)uiSymbol; |
---|
435 | } |
---|
436 | } |
---|
437 | else |
---|
438 | { |
---|
439 | saoLcuParam->length = 0; |
---|
440 | } |
---|
441 | } |
---|
442 | |
---|
443 | /** parse SAO unit |
---|
444 | * \param rx x-axis location |
---|
445 | * \param ry y-axis location |
---|
446 | * \param compIdx color component index |
---|
447 | * \param saoParam SAO parameters |
---|
448 | * \param repeatedRow repeat row flag |
---|
449 | */ |
---|
450 | void TDecCavlc::xParseSaoUnit(Int rx, Int ry, Int compIdx, SAOParam* saoParam, Bool& repeatedRow ) |
---|
451 | { |
---|
452 | int addr, addrUp, addrLeft; |
---|
453 | int numCuInWidth = saoParam->numCuInWidth; |
---|
454 | SaoLcuParam* saoOneLcu; |
---|
455 | SaoLcuParam* saoOneLcuUp; |
---|
456 | SaoLcuParam* saoOneLcuLeft; |
---|
457 | UInt uiSymbol; |
---|
458 | Int iSymbol; |
---|
459 | Int runLeft; |
---|
460 | UInt maxValue; |
---|
461 | |
---|
462 | addr = rx + ry*numCuInWidth; |
---|
463 | addrLeft = (addr%numCuInWidth == 0) ? -1 : addr - 1; |
---|
464 | addrUp = (addr<numCuInWidth) ? -1 : addr - numCuInWidth; |
---|
465 | |
---|
466 | saoOneLcu = &(saoParam->saoLcuParam[compIdx][addr]); |
---|
467 | if (!repeatedRow) |
---|
468 | { |
---|
469 | runLeft = (addrLeft>=0 ) ? saoParam->saoLcuParam[compIdx][addrLeft].run : -1; |
---|
470 | if (rx == 0 || runLeft==0) |
---|
471 | { |
---|
472 | saoOneLcu->mergeLeftFlag = 0; |
---|
473 | if (ry == 0) |
---|
474 | { |
---|
475 | maxValue = numCuInWidth-rx-1; |
---|
476 | UInt length = 0; |
---|
477 | UInt val = 0; |
---|
478 | if (maxValue) |
---|
479 | { |
---|
480 | for(UInt i=0; i<32; i++) |
---|
481 | { |
---|
482 | if(maxValue&0x1) |
---|
483 | { |
---|
484 | length = i+1; |
---|
485 | } |
---|
486 | maxValue = (maxValue >> 1); |
---|
487 | } |
---|
488 | if(length) |
---|
489 | { |
---|
490 | READ_CODE(length, val, "sao_run_diff"); |
---|
491 | } |
---|
492 | } |
---|
493 | uiSymbol = val; |
---|
494 | saoOneLcu->runDiff = uiSymbol; |
---|
495 | xParseSaoOffset(saoOneLcu); |
---|
496 | saoOneLcu->run = saoOneLcu->runDiff; |
---|
497 | } |
---|
498 | else |
---|
499 | { |
---|
500 | saoOneLcuUp = &(saoParam->saoLcuParam[compIdx][addrUp]); |
---|
501 | READ_SVLC (iSymbol , "sao_run_diff" ); saoOneLcu->runDiff = iSymbol; |
---|
502 | READ_FLAG (uiSymbol, "sao_merge_up_flag"); saoOneLcu->mergeUpFlag = uiSymbol? true:false; |
---|
503 | if (!saoOneLcu->mergeUpFlag) |
---|
504 | { |
---|
505 | xParseSaoOffset(saoOneLcu); |
---|
506 | } |
---|
507 | else |
---|
508 | { |
---|
509 | saoOneLcuUp = &(saoParam->saoLcuParam[compIdx][addrUp]); |
---|
510 | copySaoOneLcuParam(saoOneLcu, saoOneLcuUp); |
---|
511 | } |
---|
512 | saoOneLcu->run = saoOneLcu->runDiff + saoOneLcuUp->run; |
---|
513 | } |
---|
514 | } |
---|
515 | else |
---|
516 | { |
---|
517 | saoOneLcuLeft = &(saoParam->saoLcuParam[compIdx][addrLeft]); |
---|
518 | copySaoOneLcuParam(saoOneLcu, saoOneLcuLeft); |
---|
519 | saoOneLcu->mergeLeftFlag = 1; |
---|
520 | saoOneLcu->run = saoOneLcuLeft->run-1; |
---|
521 | } |
---|
522 | } |
---|
523 | else |
---|
524 | { |
---|
525 | if (ry > 0) |
---|
526 | { |
---|
527 | saoOneLcuUp = &(saoParam->saoLcuParam[compIdx][addrUp]); |
---|
528 | copySaoOneLcuParam(saoOneLcu, saoOneLcuUp); |
---|
529 | saoOneLcu->mergeLeftFlag = 0; |
---|
530 | saoOneLcu->run = saoOneLcuUp->run; |
---|
531 | } |
---|
532 | } |
---|
533 | } |
---|
534 | |
---|
535 | |
---|
536 | Void TDecCavlc::xParseAlfParam(AlfParamSet* pAlfParamSet, Bool bSentInAPS, Int firstLCUAddr, Bool acrossSlice, Int numLCUInWidth, Int numLCUInHeight) |
---|
537 | { |
---|
538 | Int numLCU; |
---|
539 | UInt uiSymbol; |
---|
540 | Bool isEnabled[NUM_ALF_COMPONENT]; |
---|
541 | Bool isUniParam[NUM_ALF_COMPONENT]; |
---|
542 | |
---|
543 | isEnabled[ALF_Y] = true; |
---|
544 | READ_FLAG(uiSymbol, "alf_cb_enable_flag"); isEnabled[ALF_Cb] = ((uiSymbol ==1)?true:false); |
---|
545 | READ_FLAG(uiSymbol, "alf_cr_enable_flag"); isEnabled[ALF_Cr] = ((uiSymbol ==1)?true:false); |
---|
546 | READ_FLAG(uiSymbol, "alf_one_luma_unit_per_slice_flag"); isUniParam[ALF_Y] = ((uiSymbol ==1)?true:false); |
---|
547 | |
---|
548 | isUniParam[ALF_Cb] = true; |
---|
549 | if (isEnabled[ALF_Cb]) |
---|
550 | { |
---|
551 | READ_FLAG(uiSymbol, "alf_one_cb_unit_per_slice_flag"); isUniParam[ALF_Cb] = ((uiSymbol ==1)?true:false); |
---|
552 | } |
---|
553 | |
---|
554 | isUniParam[ALF_Cr] = true; |
---|
555 | if (isEnabled[ALF_Cr]) |
---|
556 | { |
---|
557 | READ_FLAG(uiSymbol, "alf_one_cr_unit_per_slice_flag"); isUniParam[ALF_Cr] = ((uiSymbol ==1)?true:false); |
---|
558 | } |
---|
559 | |
---|
560 | if(bSentInAPS) |
---|
561 | { |
---|
562 | READ_UVLC(uiSymbol, "alf_num_lcu_in_width_minus1"); numLCUInWidth = uiSymbol+1; |
---|
563 | READ_UVLC(uiSymbol, "alf_num_lcu_in_height_minus1"); numLCUInHeight = uiSymbol+1; |
---|
564 | numLCU = numLCUInWidth*numLCUInHeight; |
---|
565 | } |
---|
566 | else //sent in slice header |
---|
567 | { |
---|
568 | READ_UVLC(uiSymbol, "alf_num_lcu_in_slice_minus1"); numLCU = uiSymbol+1; |
---|
569 | } |
---|
570 | |
---|
571 | assert(pAlfParamSet != NULL); |
---|
572 | |
---|
573 | pAlfParamSet->create(numLCUInWidth, numLCUInHeight, numLCU); |
---|
574 | for(Int compIdx = 0; compIdx < NUM_ALF_COMPONENT; compIdx++) |
---|
575 | { |
---|
576 | pAlfParamSet->isEnabled[compIdx] = isEnabled[compIdx]; |
---|
577 | pAlfParamSet->isUniParam[compIdx]= isUniParam[compIdx]; |
---|
578 | } |
---|
579 | |
---|
580 | parseAlfParamSet(pAlfParamSet, firstLCUAddr, acrossSlice); |
---|
581 | } |
---|
582 | |
---|
583 | |
---|
584 | Void TDecCavlc::parseAlfParamSet(AlfParamSet* pAlfParamSet, Int firstLCUAddr, Bool alfAcrossSlice) |
---|
585 | { |
---|
586 | Int numLCUInWidth = pAlfParamSet->numLCUInWidth; |
---|
587 | Int numLCU = pAlfParamSet->numLCU; |
---|
588 | |
---|
589 | static Bool isRepeatedRow [NUM_ALF_COMPONENT]; |
---|
590 | static Int numStoredFilters[NUM_ALF_COMPONENT]; |
---|
591 | static Int* run [NUM_ALF_COMPONENT]; |
---|
592 | |
---|
593 | for(Int compIdx =0; compIdx < NUM_ALF_COMPONENT; compIdx++) |
---|
594 | { |
---|
595 | isRepeatedRow[compIdx] = false; |
---|
596 | numStoredFilters[compIdx] = 0; |
---|
597 | |
---|
598 | run[compIdx] = new Int[numLCU+1]; |
---|
599 | run[compIdx][0] = -1; |
---|
600 | } |
---|
601 | |
---|
602 | UInt uiSymbol; |
---|
603 | Int iSymbol, ry, rx, addrUp; |
---|
604 | |
---|
605 | for(Int i=0; i< numLCU; i++) |
---|
606 | { |
---|
607 | rx = (i+ firstLCUAddr)% numLCUInWidth; |
---|
608 | ry = (i+ firstLCUAddr)/ numLCUInWidth; |
---|
609 | |
---|
610 | for(Int compIdx =0; compIdx < NUM_ALF_COMPONENT; compIdx++) |
---|
611 | { |
---|
612 | AlfUnitParam& alfUnitParam = pAlfParamSet->alfUnitParam[compIdx][i]; |
---|
613 | |
---|
614 | if(pAlfParamSet->isEnabled[compIdx]) |
---|
615 | { |
---|
616 | if(!pAlfParamSet->isUniParam[compIdx]) |
---|
617 | { |
---|
618 | addrUp = i-numLCUInWidth; |
---|
619 | if(rx ==0 && addrUp >=0) |
---|
620 | { |
---|
621 | READ_FLAG(uiSymbol, "alf_repeat_row _flag"); isRepeatedRow[compIdx] = ((uiSymbol ==1)?true:false); |
---|
622 | } |
---|
623 | |
---|
624 | if(isRepeatedRow[compIdx]) |
---|
625 | { |
---|
626 | alfUnitParam.mergeType = ALF_MERGE_UP; |
---|
627 | assert(addrUp >=0); |
---|
628 | run[compIdx][i] = run[compIdx][addrUp]; |
---|
629 | } |
---|
630 | else |
---|
631 | { |
---|
632 | if(rx == 0 || run[compIdx][i] < 0) |
---|
633 | { |
---|
634 | if(addrUp < 0) |
---|
635 | { |
---|
636 | //alf_run_diff u(v) |
---|
637 | parseAlfFixedLengthRun(uiSymbol, rx, numLCUInWidth); |
---|
638 | run[compIdx][i] = uiSymbol; |
---|
639 | } |
---|
640 | else |
---|
641 | { |
---|
642 | //alf_run_diff s(v) |
---|
643 | READ_SVLC(iSymbol, "alf_run_diff"); |
---|
644 | run[compIdx][i] = run[compIdx][addrUp] + iSymbol; |
---|
645 | assert(run[compIdx][i] >= 0); |
---|
646 | } |
---|
647 | |
---|
648 | if(ry > 0 && (addrUp >=0 || alfAcrossSlice)) |
---|
649 | { |
---|
650 | //alf_merge_up_flag |
---|
651 | READ_FLAG(uiSymbol, "alf_merge_up_flag"); alfUnitParam.mergeType = ((uiSymbol ==1)?ALF_MERGE_UP:ALF_MERGE_DISABLED); |
---|
652 | } |
---|
653 | else |
---|
654 | { |
---|
655 | alfUnitParam.mergeType = ALF_MERGE_DISABLED; |
---|
656 | } |
---|
657 | |
---|
658 | if(alfUnitParam.mergeType != ALF_MERGE_UP) |
---|
659 | { |
---|
660 | //alf_lcu_enable_flag |
---|
661 | READ_FLAG(uiSymbol, "alf_lcu_enable_flag"); alfUnitParam.isEnabled = ((uiSymbol ==1)?true:false); |
---|
662 | |
---|
663 | if(alfUnitParam.isEnabled) |
---|
664 | { |
---|
665 | if(numStoredFilters[compIdx] > 0) |
---|
666 | { |
---|
667 | //alf_new_filter_set_flag |
---|
668 | READ_FLAG(uiSymbol, "alf_new_filter_set_flag"); alfUnitParam.isNewFilt = ((uiSymbol ==1)?true:false); |
---|
669 | |
---|
670 | if(!alfUnitParam.isNewFilt) |
---|
671 | { |
---|
672 | //alf_stored_filter_set_idx |
---|
673 | parseAlfStoredFilterIdx(uiSymbol, numStoredFilters[compIdx]); |
---|
674 | |
---|
675 | alfUnitParam.storedFiltIdx = uiSymbol; |
---|
676 | |
---|
677 | assert( alfUnitParam.storedFiltIdx < numStoredFilters[compIdx]); |
---|
678 | } |
---|
679 | } |
---|
680 | else |
---|
681 | { |
---|
682 | alfUnitParam.isNewFilt = true; |
---|
683 | } |
---|
684 | |
---|
685 | if(alfUnitParam.isNewFilt) |
---|
686 | { |
---|
687 | alfUnitParam.alfFiltParam = new ALFParam(compIdx); |
---|
688 | xParseAlfParam(alfUnitParam.alfFiltParam); |
---|
689 | alfUnitParam.alfFiltParam->alf_flag = 1; |
---|
690 | |
---|
691 | numStoredFilters[compIdx]++; |
---|
692 | } |
---|
693 | } |
---|
694 | |
---|
695 | } |
---|
696 | } |
---|
697 | else |
---|
698 | { |
---|
699 | alfUnitParam.mergeType = ALF_MERGE_LEFT; |
---|
700 | } |
---|
701 | |
---|
702 | run[compIdx][i+1] = run[compIdx][i] -1; |
---|
703 | } |
---|
704 | |
---|
705 | } |
---|
706 | else // uni-param |
---|
707 | { |
---|
708 | if(i == 0) |
---|
709 | { |
---|
710 | alfUnitParam.mergeType = ALF_MERGE_DISABLED; |
---|
711 | |
---|
712 | //alf_lcu_enable_flag |
---|
713 | READ_FLAG(uiSymbol, "alf_lcu_enable_flag"); alfUnitParam.isEnabled = ((uiSymbol ==1)?true:false); |
---|
714 | if(alfUnitParam.isEnabled) |
---|
715 | { |
---|
716 | alfUnitParam.isNewFilt = true; |
---|
717 | alfUnitParam.alfFiltParam = new ALFParam(compIdx); |
---|
718 | xParseAlfParam(alfUnitParam.alfFiltParam); |
---|
719 | alfUnitParam.alfFiltParam->alf_flag = 1; |
---|
720 | } |
---|
721 | } |
---|
722 | else |
---|
723 | { |
---|
724 | alfUnitParam.mergeType = ALF_MERGE_FIRST; |
---|
725 | } |
---|
726 | |
---|
727 | } |
---|
728 | } |
---|
729 | else |
---|
730 | { |
---|
731 | alfUnitParam.mergeType = ALF_MERGE_DISABLED; |
---|
732 | alfUnitParam.isEnabled = false; |
---|
733 | } |
---|
734 | } |
---|
735 | } |
---|
736 | |
---|
737 | for(Int compIdx =0; compIdx < NUM_ALF_COMPONENT; compIdx++) |
---|
738 | { |
---|
739 | delete[] run[compIdx]; |
---|
740 | } |
---|
741 | } |
---|
742 | |
---|
743 | |
---|
744 | Void TDecCavlc::parseAlfFixedLengthRun( UInt& idx, UInt rx, UInt numLCUInWidth ) |
---|
745 | { |
---|
746 | assert(numLCUInWidth > rx); |
---|
747 | |
---|
748 | UInt length = 0; |
---|
749 | UInt maxNumRun = numLCUInWidth - rx - 1; |
---|
750 | |
---|
751 | for(UInt i=0; i<32; i++) |
---|
752 | { |
---|
753 | if(maxNumRun&0x1) |
---|
754 | { |
---|
755 | length = i+1; |
---|
756 | } |
---|
757 | maxNumRun = (maxNumRun >> 1); |
---|
758 | } |
---|
759 | |
---|
760 | idx = 0; |
---|
761 | if(length) |
---|
762 | { |
---|
763 | READ_CODE( length, idx, "alf_run_diff" ); |
---|
764 | } |
---|
765 | else |
---|
766 | { |
---|
767 | idx = 0; |
---|
768 | } |
---|
769 | } |
---|
770 | |
---|
771 | |
---|
772 | Void TDecCavlc::parseAlfStoredFilterIdx( UInt& idx, UInt numFilterSetsInBuffer ) |
---|
773 | { |
---|
774 | assert(numFilterSetsInBuffer > 0); |
---|
775 | |
---|
776 | UInt length = 0; |
---|
777 | UInt maxValue = numFilterSetsInBuffer - 1; |
---|
778 | |
---|
779 | for(UInt i=0; i<32; i++) |
---|
780 | { |
---|
781 | if(maxValue&0x1) |
---|
782 | { |
---|
783 | length = i+1; |
---|
784 | } |
---|
785 | maxValue = (maxValue >> 1); |
---|
786 | } |
---|
787 | |
---|
788 | idx = 0; |
---|
789 | if(length) |
---|
790 | { |
---|
791 | READ_CODE( length, idx, "alf_stored_filter_set_idx" ); |
---|
792 | } |
---|
793 | else |
---|
794 | { |
---|
795 | idx = 0; |
---|
796 | } |
---|
797 | } |
---|
798 | |
---|
799 | |
---|
800 | Void TDecCavlc::xParseAlfParam(ALFParam* pAlfParam) |
---|
801 | { |
---|
802 | UInt uiSymbol; |
---|
803 | Int iSymbol; |
---|
804 | Int sqrFiltLengthTab[NUM_ALF_FILTER_SHAPE] = {ALF_FILTER_LEN}; |
---|
805 | |
---|
806 | switch(pAlfParam->componentID) |
---|
807 | { |
---|
808 | case ALF_Cb: |
---|
809 | case ALF_Cr: |
---|
810 | { |
---|
811 | pAlfParam->filter_shape = ALF_CROSS9x7_SQUARE3x3; |
---|
812 | pAlfParam->num_coeff = sqrFiltLengthTab[pAlfParam->filter_shape]; |
---|
813 | pAlfParam->filters_per_group = 1; |
---|
814 | for(Int pos=0; pos< pAlfParam->num_coeff; pos++) |
---|
815 | { |
---|
816 | READ_SVLC(iSymbol, "alf_filt_coeff"); |
---|
817 | pAlfParam->coeffmulti[0][pos] = iSymbol; |
---|
818 | } |
---|
819 | } |
---|
820 | break; |
---|
821 | case ALF_Y: |
---|
822 | { |
---|
823 | pAlfParam->filters_per_group = 0; |
---|
824 | memset (pAlfParam->filterPattern, 0 , sizeof(Int)*NO_VAR_BINS); |
---|
825 | pAlfParam->filter_shape = 0; |
---|
826 | pAlfParam->num_coeff = sqrFiltLengthTab[pAlfParam->filter_shape]; |
---|
827 | |
---|
828 | // filters_per_fr |
---|
829 | READ_UVLC (uiSymbol, "alf_no_filters_minus1"); |
---|
830 | pAlfParam->filters_per_group = uiSymbol + 1; |
---|
831 | |
---|
832 | if(uiSymbol == 1) // filters_per_group == 2 |
---|
833 | { |
---|
834 | READ_UVLC (uiSymbol, "alf_start_second_filter"); |
---|
835 | pAlfParam->startSecondFilter = uiSymbol; |
---|
836 | pAlfParam->filterPattern [uiSymbol] = 1; |
---|
837 | } |
---|
838 | else if (uiSymbol > 1) // filters_per_group > 2 |
---|
839 | { |
---|
840 | pAlfParam->filters_per_group = 1; |
---|
841 | Int numMergeFlags = 16; |
---|
842 | for (Int i=1; i<numMergeFlags; i++) |
---|
843 | { |
---|
844 | READ_FLAG (uiSymbol, "alf_filter_pattern"); |
---|
845 | pAlfParam->filterPattern[i] = uiSymbol; |
---|
846 | pAlfParam->filters_per_group += uiSymbol; |
---|
847 | } |
---|
848 | } |
---|
849 | |
---|
850 | if (pAlfParam->filters_per_group > 1) |
---|
851 | { |
---|
852 | READ_FLAG (uiSymbol, "alf_pred_method"); |
---|
853 | pAlfParam->predMethod = uiSymbol; |
---|
854 | } |
---|
855 | for(Int idx = 0; idx < pAlfParam->filters_per_group; ++idx) |
---|
856 | { |
---|
857 | READ_FLAG (uiSymbol,"alf_nb_pred_luma"); |
---|
858 | pAlfParam->nbSPred[idx] = uiSymbol; |
---|
859 | } |
---|
860 | |
---|
861 | Int minScanVal = MIN_SCAN_POS_CROSS; |
---|
862 | |
---|
863 | // Determine maxScanVal |
---|
864 | Int maxScanVal = 0; |
---|
865 | Int *pDepthInt = pDepthIntTabShapes[pAlfParam->filter_shape]; |
---|
866 | for(Int idx = 0; idx < pAlfParam->num_coeff; idx++) |
---|
867 | { |
---|
868 | maxScanVal = max(maxScanVal, pDepthInt[idx]); |
---|
869 | } |
---|
870 | |
---|
871 | // Golomb parameters |
---|
872 | if( pAlfParam->filters_per_group > 1 ) |
---|
873 | { |
---|
874 | READ_UVLC (uiSymbol, "alf_min_kstart_minus1"); |
---|
875 | pAlfParam->minKStart = 1 + uiSymbol; |
---|
876 | |
---|
877 | Int kMin = pAlfParam->minKStart; |
---|
878 | |
---|
879 | for(Int scanPos = minScanVal; scanPos < maxScanVal; scanPos++) |
---|
880 | { |
---|
881 | READ_FLAG (uiSymbol, "alf_golomb_index_bit"); |
---|
882 | pAlfParam->kMinTab[scanPos] = kMin + uiSymbol; |
---|
883 | kMin = pAlfParam->kMinTab[scanPos]; |
---|
884 | } |
---|
885 | } |
---|
886 | |
---|
887 | Int scanPos; |
---|
888 | for(Int idx = 0; idx < pAlfParam->filters_per_group; ++idx) |
---|
889 | { |
---|
890 | for(Int i = 0; i < pAlfParam->num_coeff; i++) |
---|
891 | { |
---|
892 | scanPos = pDepthInt[i] - 1; |
---|
893 | Int k = (pAlfParam->filters_per_group == 1) ? kTableTabShapes[ALF_CROSS9x7_SQUARE3x3][i] : pAlfParam->kMinTab[scanPos]; |
---|
894 | pAlfParam->coeffmulti[idx][i] = xGolombDecode(k); |
---|
895 | } |
---|
896 | } |
---|
897 | } |
---|
898 | break; |
---|
899 | default: |
---|
900 | { |
---|
901 | printf("Not a legal component ID for ALF\n"); |
---|
902 | assert(0); |
---|
903 | exit(-1); |
---|
904 | } |
---|
905 | } |
---|
906 | } |
---|
907 | |
---|
908 | Int TDecCavlc::xGolombDecode(Int k) |
---|
909 | { |
---|
910 | UInt uiSymbol; |
---|
911 | Int q = -1; |
---|
912 | Int nr = 0; |
---|
913 | Int a; |
---|
914 | |
---|
915 | uiSymbol = 1; |
---|
916 | while (uiSymbol) |
---|
917 | { |
---|
918 | xReadFlag(uiSymbol); |
---|
919 | q++; |
---|
920 | } |
---|
921 | for(a = 0; a < k; ++a) // read out the sequential log2(M) bits |
---|
922 | { |
---|
923 | xReadFlag(uiSymbol); |
---|
924 | if(uiSymbol) |
---|
925 | nr += 1 << a; |
---|
926 | } |
---|
927 | nr += q << k; |
---|
928 | if(nr != 0) |
---|
929 | { |
---|
930 | xReadFlag(uiSymbol); |
---|
931 | nr = (uiSymbol)? nr: -nr; |
---|
932 | } |
---|
933 | #if ENC_DEC_TRACE |
---|
934 | fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); |
---|
935 | fprintf( g_hTrace, "%-40s ge(v) : %d\n", "alf_coeff_luma", nr ); |
---|
936 | #endif |
---|
937 | return nr; |
---|
938 | } |
---|
939 | |
---|
940 | Void TDecCavlc::parsePPS(TComPPS* pcPPS, ParameterSetManagerDecoder *parameterSet) |
---|
941 | { |
---|
942 | #if ENC_DEC_TRACE |
---|
943 | xTracePPSHeader (pcPPS); |
---|
944 | #endif |
---|
945 | UInt uiCode; |
---|
946 | |
---|
947 | Int iCode; |
---|
948 | |
---|
949 | READ_UVLC( uiCode, "pic_parameter_set_id"); pcPPS->setPPSId (uiCode); |
---|
950 | READ_UVLC( uiCode, "seq_parameter_set_id"); pcPPS->setSPSId (uiCode); |
---|
951 | |
---|
952 | READ_FLAG ( uiCode, "sign_data_hiding_flag" ); pcPPS->setSignHideFlag( uiCode ); |
---|
953 | if( pcPPS->getSignHideFlag() ) |
---|
954 | { |
---|
955 | READ_CODE( 4, uiCode, "sign_hiding_threshold"); pcPPS->setTSIG(uiCode); |
---|
956 | } |
---|
957 | |
---|
958 | #if CABAC_INIT_FLAG |
---|
959 | READ_FLAG( uiCode, "cabac_init_present_flag" ); pcPPS->setCabacInitPresentFlag( uiCode ? true : false ); |
---|
960 | #endif |
---|
961 | // entropy_coding_mode_flag |
---|
962 | // We code the entropy_coding_mode_flag, it's needed for tests. |
---|
963 | READ_FLAG( uiCode, "entropy_coding_mode_flag" ); pcPPS->setEntropyCodingMode( uiCode ? true : false ); |
---|
964 | if (pcPPS->getEntropyCodingMode()) |
---|
965 | { |
---|
966 | } |
---|
967 | |
---|
968 | // num_ref_idx_l0_default_active_minus1 |
---|
969 | // num_ref_idx_l1_default_active_minus1 |
---|
970 | READ_SVLC(iCode, "pic_init_qp_minus26" ); pcPPS->setPicInitQPMinus26(iCode); |
---|
971 | READ_FLAG( uiCode, "constrained_intra_pred_flag" ); pcPPS->setConstrainedIntraPred( uiCode ? true : false ); |
---|
972 | READ_FLAG( uiCode, "enable_temporal_mvp_flag" ); pcPPS->setEnableTMVPFlag( uiCode ? true : false ); |
---|
973 | READ_CODE( 2, uiCode, "slice_granularity" ); pcPPS->setSliceGranularity(uiCode); |
---|
974 | |
---|
975 | // alf_param() ? |
---|
976 | |
---|
977 | READ_UVLC( uiCode, "max_cu_qp_delta_depth"); |
---|
978 | if(uiCode == 0) |
---|
979 | { |
---|
980 | pcPPS->setUseDQP (false); |
---|
981 | pcPPS->setMaxCuDQPDepth( 0 ); |
---|
982 | } |
---|
983 | else |
---|
984 | { |
---|
985 | pcPPS->setUseDQP (true); |
---|
986 | pcPPS->setMaxCuDQPDepth(uiCode - 1); |
---|
987 | } |
---|
988 | |
---|
989 | READ_SVLC( iCode, "chroma_qp_offset"); |
---|
990 | pcPPS->setChromaQpOffset(iCode); |
---|
991 | |
---|
992 | READ_SVLC( iCode, "chroma_qp_offset_2nd"); |
---|
993 | pcPPS->setChromaQpOffset2nd(iCode); |
---|
994 | |
---|
995 | READ_FLAG( uiCode, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) |
---|
996 | pcPPS->setUseWP( uiCode==1 ); |
---|
997 | READ_CODE( 2, uiCode, "weighted_bipred_idc" ); // Use of Bi-Directional Weighting Prediction (B_SLICE) |
---|
998 | pcPPS->setWPBiPredIdc( uiCode ); |
---|
999 | //printf("TDecCavlc::parsePPS():\tm_bUseWeightPred=%d\tm_uiBiPredIdc=%d\n", pcPPS->getUseWP(), pcPPS->getWPBiPredIdc()); |
---|
1000 | |
---|
1001 | READ_FLAG( uiCode, "output_flag_present_flag" ); |
---|
1002 | pcPPS->setOutputFlagPresentFlag( uiCode==1 ); |
---|
1003 | |
---|
1004 | if(parameterSet->getPrefetchedSPS(pcPPS->getSPSId())->getTilesOrEntropyCodingSyncIdc()==1) |
---|
1005 | { |
---|
1006 | READ_FLAG ( uiCode, "tile_info_present_flag" ); |
---|
1007 | pcPPS->setColumnRowInfoPresent(uiCode); |
---|
1008 | READ_FLAG ( uiCode, "tile_control_present_flag" ); |
---|
1009 | pcPPS->setTileBehaviorControlPresentFlag(uiCode); |
---|
1010 | if( pcPPS->getColumnRowInfoPresent() == 1 ) |
---|
1011 | { |
---|
1012 | READ_UVLC ( uiCode, "num_tile_columns_minus1" ); |
---|
1013 | pcPPS->setNumColumnsMinus1( uiCode ); |
---|
1014 | READ_UVLC ( uiCode, "num_tile_rows_minus1" ); |
---|
1015 | pcPPS->setNumRowsMinus1( uiCode ); |
---|
1016 | READ_FLAG ( uiCode, "uniform_spacing_flag" ); |
---|
1017 | pcPPS->setUniformSpacingIdr( uiCode ); |
---|
1018 | |
---|
1019 | if( pcPPS->getUniformSpacingIdr() == 0 ) |
---|
1020 | { |
---|
1021 | UInt* columnWidth = (UInt*)malloc(pcPPS->getNumColumnsMinus1()*sizeof(UInt)); |
---|
1022 | for(UInt i=0; i<pcPPS->getNumColumnsMinus1(); i++) |
---|
1023 | { |
---|
1024 | READ_UVLC( uiCode, "column_width" ); |
---|
1025 | columnWidth[i] = uiCode; |
---|
1026 | } |
---|
1027 | pcPPS->setColumnWidth(columnWidth); |
---|
1028 | free(columnWidth); |
---|
1029 | |
---|
1030 | UInt* rowHeight = (UInt*)malloc(pcPPS->getNumRowsMinus1()*sizeof(UInt)); |
---|
1031 | for(UInt i=0; i<pcPPS->getNumRowsMinus1(); i++) |
---|
1032 | { |
---|
1033 | READ_UVLC( uiCode, "row_height" ); |
---|
1034 | rowHeight[i] = uiCode; |
---|
1035 | } |
---|
1036 | pcPPS->setRowHeight(rowHeight); |
---|
1037 | free(rowHeight); |
---|
1038 | } |
---|
1039 | } |
---|
1040 | |
---|
1041 | |
---|
1042 | if(pcPPS->getTileBehaviorControlPresentFlag() == 1) |
---|
1043 | { |
---|
1044 | Int iNumColTilesMinus1 = (pcPPS->getColumnRowInfoPresent() == 1)?(pcPPS->getNumColumnsMinus1()):(pcPPS->getSPS()->getNumColumnsMinus1()); |
---|
1045 | Int iNumRowTilesMinus1 = (pcPPS->getColumnRowInfoPresent() == 1)?(pcPPS->getNumColumnsMinus1()):(pcPPS->getSPS()->getNumRowsMinus1()); |
---|
1046 | pcPPS->setLFCrossTileBoundaryFlag(true); //default |
---|
1047 | |
---|
1048 | if(iNumColTilesMinus1 !=0 || iNumRowTilesMinus1 !=0) |
---|
1049 | { |
---|
1050 | READ_FLAG ( uiCode, "loop_filter_across_tile_flag" ); |
---|
1051 | pcPPS->setLFCrossTileBoundaryFlag( (uiCode == 1)?true:false ); |
---|
1052 | } |
---|
1053 | } |
---|
1054 | } |
---|
1055 | else if(parameterSet->getPrefetchedSPS(pcPPS->getSPSId())->getTilesOrEntropyCodingSyncIdc()==2) |
---|
1056 | { |
---|
1057 | READ_UVLC( uiCode, "num_substreams_minus1" ); pcPPS->setNumSubstreams(uiCode+1); |
---|
1058 | } |
---|
1059 | |
---|
1060 | READ_FLAG( uiCode, "deblocking_filter_control_present_flag" ); |
---|
1061 | pcPPS->setDeblockingFilterControlPresent( uiCode ? true : false); |
---|
1062 | READ_UVLC( uiCode, "log2_parallel_merge_level_minus2"); |
---|
1063 | assert(uiCode == LOG2_PARALLEL_MERGE_LEVEL_MINUS2); |
---|
1064 | pcPPS->setLog2ParallelMergeLevelMinus2 (uiCode); |
---|
1065 | |
---|
1066 | READ_FLAG( uiCode, "pps_extension_flag"); |
---|
1067 | if (uiCode) |
---|
1068 | { |
---|
1069 | while ( xMoreRbspData() ) |
---|
1070 | { |
---|
1071 | READ_FLAG( uiCode, "pps_extension_data_flag"); |
---|
1072 | } |
---|
1073 | } |
---|
1074 | } |
---|
1075 | #if QC_MVHEVC_B0046 |
---|
1076 | Void TDecCavlc::parseVPS(TComVPS* pcVPS) |
---|
1077 | { |
---|
1078 | UInt uiCode; |
---|
1079 | READ_CODE( 4, uiCode, "video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); |
---|
1080 | READ_FLAG( uiCode, "temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); |
---|
1081 | READ_CODE( 2, uiCode, "vps_reserved_zero_2bits" ); assert( !uiCode ); |
---|
1082 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( uiCode + 1 ); |
---|
1083 | READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); |
---|
1084 | READ_CODE( 12, uiCode, "vps_extension_offset" ); assert( !uiCode ); |
---|
1085 | for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
1086 | { |
---|
1087 | READ_UVLC( uiCode, "max_dec_pic_buffering[i]" ); pcVPS->setMaxDecPicBuffering( uiCode, i ); |
---|
1088 | READ_UVLC( uiCode, "num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); |
---|
1089 | READ_UVLC( uiCode, "max_latency_increase[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); |
---|
1090 | } |
---|
1091 | READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHRDParameters(uiCode); |
---|
1092 | assert(pcVPS->getNumHRDParameters()==0); |
---|
1093 | for ( UInt i = 0; i < pcVPS->getNumHRDParameters(); i ++) |
---|
1094 | { |
---|
1095 | // if( i > 0 ) |
---|
1096 | //{ |
---|
1097 | // READ_UVLC (0, "op_num_layer_id_values_minus1[ opIdx ]"); |
---|
1098 | // for( i = 0; i <= op_num_layer_id_values_minus1[ opIdx ]; i++ ) |
---|
1099 | // READ_UVLC(0, 6, "op_layer_id[ opIdx ][ i ]"); |
---|
1100 | //} |
---|
1101 | //hrd_parameters( i = = 0, vps_max_sub_layers_minus1 ); |
---|
1102 | } |
---|
1103 | |
---|
1104 | READ_CODE( 1, uiCode, "bit_equal_to_one" ); assert( uiCode ); |
---|
1105 | //vps_extension_byte_alignment_reserved_one_bit |
---|
1106 | xReadVPSAlignOne(); |
---|
1107 | READ_CODE( 8, uiCode, "num_additional_layer_operation_points" ); pcVPS->setNumAddiLayerOperationPoints( uiCode ); |
---|
1108 | READ_CODE( 8, uiCode, "num_additional_profile_level_sets" ); pcVPS->setNumAddiProLevelSets( uiCode); |
---|
1109 | |
---|
1110 | |
---|
1111 | for(UInt i=0; i <= pcVPS->getMaxLayers()-1; i++) |
---|
1112 | { |
---|
1113 | READ_CODE( 4, uiCode, "num_types_zero_4bits[i]" ); assert( !uiCode ); |
---|
1114 | READ_CODE( 4, uiCode, "type_zero_4bits[i]" ); assert( !uiCode ); |
---|
1115 | READ_CODE( 8, uiCode, "view_id[i]" ); pcVPS->setViewId(uiCode, i); |
---|
1116 | // WRITE_SVLC( pcVPS->getViewOrderIdx(i), "view_order_idx[i]" ); |
---|
1117 | if(i) |
---|
1118 | { |
---|
1119 | READ_CODE( 6, uiCode, "num_direct_ref_layers[ i ]" ); pcVPS->setNumDirectRefLayer(uiCode, i); |
---|
1120 | for (UInt j = 0; j< pcVPS->getNumDirectRefLayer(i); j++) |
---|
1121 | { |
---|
1122 | READ_CODE( 6, uiCode, "ref_layer_id[i][j]" ); pcVPS->setDirectRefLayerId (uiCode, i, j); |
---|
1123 | } |
---|
1124 | } |
---|
1125 | } |
---|
1126 | for( UInt i=1; i<=pcVPS->getNumAddiProLevelSets(); i++) |
---|
1127 | { |
---|
1128 | //profile_tier_level |
---|
1129 | } |
---|
1130 | for( UInt i=1; i<= pcVPS->getNumAddiLayerOperationPoints(); i++) |
---|
1131 | { |
---|
1132 | if(pcVPS->getMaxLayers() == 3) |
---|
1133 | { |
---|
1134 | pcVPS->setNumOpLayerIdMinus1((i < pcVPS->getNumAddiLayerOperationPoints() ? 1: 2), (i-1)); |
---|
1135 | } |
---|
1136 | else if( i==1 ) |
---|
1137 | { |
---|
1138 | assert(pcVPS->getNumAddiLayerOperationPoints()==1); |
---|
1139 | pcVPS->setNumOpLayerIdMinus1(pcVPS->getMaxLayers()-1, (i-1)); |
---|
1140 | } |
---|
1141 | READ_UVLC( uiCode, "op_num_layer_id_values_minus1[ opIdx ]" ); pcVPS->setNumOpLayerIdMinus1(uiCode, i-1); |
---|
1142 | for(UInt j = 0; j <= pcVPS->getNumOpLayerIdMinus1(i-1); j++ ) |
---|
1143 | { |
---|
1144 | READ_UVLC( uiCode, "op_layer_id[ opIdx ][ i ]" ); pcVPS->setNumOpLayerId(uiCode, i-1, j); |
---|
1145 | } |
---|
1146 | if (pcVPS->getNumAddiProLevelSets()) |
---|
1147 | { |
---|
1148 | //profile_level_idx[ i ] |
---|
1149 | } |
---|
1150 | } |
---|
1151 | return; |
---|
1152 | } |
---|
1153 | #else |
---|
1154 | #if VIDYO_VPS_INTEGRATION |
---|
1155 | Void TDecCavlc::parseVPS(TComVPS* pcVPS) |
---|
1156 | { |
---|
1157 | UInt uiCode; |
---|
1158 | Int iCode; |
---|
1159 | |
---|
1160 | READ_CODE( 3, uiCode, "max_temporal_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); |
---|
1161 | READ_CODE( 5, uiCode, "max_layers_minus1" ); pcVPS->setMaxLayers( uiCode + 1 ); |
---|
1162 | READ_FLAG( uiCode, "temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); |
---|
1163 | READ_UVLC( uiCode, "video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); |
---|
1164 | for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
1165 | { |
---|
1166 | READ_UVLC( uiCode, "max_dec_pic_buffering[i]" ); pcVPS->setMaxDecPicBuffering( uiCode, i ); |
---|
1167 | READ_UVLC( uiCode, "num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); |
---|
1168 | READ_UVLC( uiCode, "max_latency_increase[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); |
---|
1169 | } |
---|
1170 | |
---|
1171 | READ_CODE( 1, uiCode, "bit_equal_to_one" ); assert( uiCode ); |
---|
1172 | |
---|
1173 | if( pcVPS->getMaxLayers() - 1 > 0 ) |
---|
1174 | { |
---|
1175 | READ_UVLC( uiCode, "extension_type" ); pcVPS->setExtensionType( uiCode ); |
---|
1176 | |
---|
1177 | pcVPS->setViewOrderIdx( 0, 0 ); |
---|
1178 | pcVPS->setViewId( 0, 0 ); |
---|
1179 | pcVPS->setDepthFlag( 0, 0 ); |
---|
1180 | for(UInt i = 1; i <= pcVPS->getMaxLayers()-1; i++) |
---|
1181 | { |
---|
1182 | READ_FLAG( uiCode, "dependent_flag[i]" ); pcVPS->setDependentFlag( uiCode ? true:false, i); |
---|
1183 | if( pcVPS->getDependentFlag(i) ) |
---|
1184 | { |
---|
1185 | READ_UVLC( uiCode, "delta_reference_layer_id_minus1[i]" ); pcVPS->setDependentLayer( i - uiCode + 1, i ); |
---|
1186 | if( pcVPS->getExtensionType() == VPS_EXTENSION_TYPE_MULTI_VIEW ) |
---|
1187 | { |
---|
1188 | READ_UVLC( uiCode, "view_id[i]" ); pcVPS->setViewId( uiCode, i ); |
---|
1189 | READ_FLAG( uiCode, "depth_flag[i]" ); pcVPS->setDepthFlag( uiCode ? true:false, i ); |
---|
1190 | READ_SVLC( iCode, "view_order_idx[i]" ); pcVPS->setViewOrderIdx( iCode, i ); |
---|
1191 | } |
---|
1192 | |
---|
1193 | } |
---|
1194 | } |
---|
1195 | #if INTER_VIEW_VECTOR_SCALING_C0115 |
---|
1196 | READ_FLAG( uiCode, "inter_view_vector_scaling_flag" ); pcVPS->setIVScalingFlag( uiCode ? true:false); |
---|
1197 | #endif |
---|
1198 | } |
---|
1199 | |
---|
1200 | READ_FLAG( uiCode, "vps_extension_flag" ); assert(!uiCode); |
---|
1201 | //future extensions go here.. |
---|
1202 | |
---|
1203 | return; |
---|
1204 | } |
---|
1205 | |
---|
1206 | #endif |
---|
1207 | #endif |
---|
1208 | #if HHI_MPI || H3D_QTL |
---|
1209 | Void TDecCavlc::parseSPS(TComSPS* pcSPS, Bool bIsDepth) |
---|
1210 | #else |
---|
1211 | Void TDecCavlc::parseSPS(TComSPS* pcSPS) |
---|
1212 | #endif |
---|
1213 | { |
---|
1214 | #if ENC_DEC_TRACE |
---|
1215 | xTraceSPSHeader (pcSPS); |
---|
1216 | #endif |
---|
1217 | |
---|
1218 | UInt uiCode; |
---|
1219 | #if !QC_MVHEVC_B0046 |
---|
1220 | Int iCode; |
---|
1221 | #endif |
---|
1222 | READ_CODE( 8, uiCode, "profile_idc" ); pcSPS->setProfileIdc( uiCode ); |
---|
1223 | READ_CODE( 8, uiCode, "reserved_zero_8bits" ); |
---|
1224 | READ_CODE( 8, uiCode, "level_idc" ); pcSPS->setLevelIdc( uiCode ); |
---|
1225 | READ_UVLC( uiCode, "seq_parameter_set_id" ); pcSPS->setSPSId( uiCode ); |
---|
1226 | #if VIDYO_VPS_INTEGRATION |
---|
1227 | READ_UVLC( uiCode, "video_parameter_set_id" ); pcSPS->setVPSId( uiCode ); |
---|
1228 | #endif |
---|
1229 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( uiCode ); |
---|
1230 | READ_CODE( 3, uiCode, "max_temporal_layers_minus1" ); pcSPS->setMaxTLayers( uiCode+1 ); |
---|
1231 | READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); |
---|
1232 | READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); |
---|
1233 | READ_FLAG( uiCode, "pic_cropping_flag"); pcSPS->setPicCroppingFlag ( uiCode ? true : false ); |
---|
1234 | if (uiCode != 0) |
---|
1235 | { |
---|
1236 | READ_UVLC( uiCode, "pic_crop_left_offset" ); pcSPS->setPicCropLeftOffset( uiCode ); |
---|
1237 | READ_UVLC( uiCode, "pic_crop_right_offset" ); pcSPS->setPicCropRightOffset( uiCode ); |
---|
1238 | READ_UVLC( uiCode, "pic_crop_top_offset" ); pcSPS->setPicCropTopOffset( uiCode ); |
---|
1239 | READ_UVLC( uiCode, "pic_crop_bottom_offset" ); pcSPS->setPicCropBottomOffset( uiCode ); |
---|
1240 | } |
---|
1241 | |
---|
1242 | #if FULL_NBIT |
---|
1243 | READ_UVLC( uiCode, "bit_depth_luma_minus8" ); |
---|
1244 | g_uiBitDepth = 8 + uiCode; |
---|
1245 | g_uiBitIncrement = 0; |
---|
1246 | pcSPS->setBitDepth(g_uiBitDepth); |
---|
1247 | pcSPS->setBitIncrement(g_uiBitIncrement); |
---|
1248 | #else |
---|
1249 | READ_UVLC( uiCode, "bit_depth_luma_minus8" ); |
---|
1250 | g_uiBitDepth = 8; |
---|
1251 | g_uiBitIncrement = uiCode; |
---|
1252 | pcSPS->setBitDepth(g_uiBitDepth); |
---|
1253 | pcSPS->setBitIncrement(g_uiBitIncrement); |
---|
1254 | #endif |
---|
1255 | |
---|
1256 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1257 | g_iDeltaDCsQuantOffset = g_uiBitIncrement - 2; |
---|
1258 | #endif |
---|
1259 | |
---|
1260 | pcSPS->setQpBDOffsetY( (Int) (6*uiCode) ); |
---|
1261 | |
---|
1262 | g_uiBASE_MAX = ((1<<(g_uiBitDepth))-1); |
---|
1263 | |
---|
1264 | #if IBDI_NOCLIP_RANGE |
---|
1265 | g_uiIBDI_MAX = g_uiBASE_MAX << g_uiBitIncrement; |
---|
1266 | #else |
---|
1267 | g_uiIBDI_MAX = ((1<<(g_uiBitDepth+g_uiBitIncrement))-1); |
---|
1268 | #endif |
---|
1269 | READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); |
---|
1270 | pcSPS->setQpBDOffsetC( (Int) (6*uiCode) ); |
---|
1271 | |
---|
1272 | READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false ); |
---|
1273 | |
---|
1274 | if( pcSPS->getUsePCM() ) |
---|
1275 | { |
---|
1276 | READ_CODE( 4, uiCode, "pcm_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepthLuma ( 1 + uiCode ); |
---|
1277 | READ_CODE( 4, uiCode, "pcm_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepthChroma ( 1 + uiCode ); |
---|
1278 | } |
---|
1279 | |
---|
1280 | #if LOSSLESS_CODING |
---|
1281 | READ_FLAG( uiCode, "qpprime_y_zero_transquant_bypass_flag" ); pcSPS->setUseLossless ( uiCode ? true : false ); |
---|
1282 | #endif |
---|
1283 | |
---|
1284 | READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); |
---|
1285 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
1286 | { |
---|
1287 | READ_UVLC ( uiCode, "max_dec_pic_buffering"); |
---|
1288 | pcSPS->setMaxDecPicBuffering( uiCode, i); |
---|
1289 | READ_UVLC ( uiCode, "num_reorder_pics" ); |
---|
1290 | pcSPS->setNumReorderPics(uiCode, i); |
---|
1291 | READ_UVLC ( uiCode, "max_latency_increase"); |
---|
1292 | pcSPS->setMaxLatencyIncrease( uiCode, i ); |
---|
1293 | } |
---|
1294 | |
---|
1295 | READ_FLAG( uiCode, "restricted_ref_pic_lists_flag" ); |
---|
1296 | pcSPS->setRestrictedRefPicListsFlag( uiCode ); |
---|
1297 | if( pcSPS->getRestrictedRefPicListsFlag() ) |
---|
1298 | { |
---|
1299 | READ_FLAG( uiCode, "lists_modification_present_flag" ); |
---|
1300 | pcSPS->setListsModificationPresentFlag(uiCode); |
---|
1301 | } |
---|
1302 | else |
---|
1303 | { |
---|
1304 | pcSPS->setListsModificationPresentFlag(true); |
---|
1305 | } |
---|
1306 | READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" ); |
---|
1307 | UInt log2MinCUSize = uiCode + 3; |
---|
1308 | READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); |
---|
1309 | UInt uiMaxCUDepthCorrect = uiCode; |
---|
1310 | pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + uiMaxCUDepthCorrect) ); g_uiMaxCUWidth = 1<<(log2MinCUSize + uiMaxCUDepthCorrect); |
---|
1311 | pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + uiMaxCUDepthCorrect) ); g_uiMaxCUHeight = 1<<(log2MinCUSize + uiMaxCUDepthCorrect); |
---|
1312 | READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); |
---|
1313 | |
---|
1314 | READ_UVLC( uiCode, "log2_diff_max_min_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() ); |
---|
1315 | pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
1316 | |
---|
1317 | if(log2MinCUSize == 3) |
---|
1318 | { |
---|
1319 | xReadFlag( uiCode ); pcSPS->setDisInter4x4( uiCode ? true : false ); |
---|
1320 | } |
---|
1321 | |
---|
1322 | if( pcSPS->getUsePCM() ) |
---|
1323 | { |
---|
1324 | READ_UVLC( uiCode, "log2_min_pcm_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); |
---|
1325 | READ_UVLC( uiCode, "log2_diff_max_min_pcm_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); |
---|
1326 | } |
---|
1327 | |
---|
1328 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 ); |
---|
1329 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 ); |
---|
1330 | g_uiAddCUDepth = 0; |
---|
1331 | while( ( pcSPS->getMaxCUWidth() >> uiMaxCUDepthCorrect ) > ( 1 << ( pcSPS->getQuadtreeTULog2MinSize() + g_uiAddCUDepth ) ) ) |
---|
1332 | { |
---|
1333 | g_uiAddCUDepth++; |
---|
1334 | } |
---|
1335 | pcSPS->setMaxCUDepth( uiMaxCUDepthCorrect+g_uiAddCUDepth ); |
---|
1336 | g_uiMaxCUDepth = uiMaxCUDepthCorrect+g_uiAddCUDepth; |
---|
1337 | // BB: these parameters may be removed completly and replaced by the fixed values |
---|
1338 | pcSPS->setMinTrDepth( 0 ); |
---|
1339 | pcSPS->setMaxTrDepth( 1 ); |
---|
1340 | READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); |
---|
1341 | READ_FLAG( uiCode, "chroma_pred_from_luma_enabled_flag" ); pcSPS->setUseLMChroma ( uiCode ? true : false ); |
---|
1342 | READ_FLAG( uiCode, "deblocking_filter_in_aps_enabled_flag" ); pcSPS->setUseDF ( uiCode ? true : false ); |
---|
1343 | READ_FLAG( uiCode, "loop_filter_across_slice_flag" ); pcSPS->setLFCrossSliceBoundaryFlag( uiCode ? true : false); |
---|
1344 | READ_FLAG( uiCode, "asymmetric_motion_partitions_enabled_flag" ); pcSPS->setUseAMP( uiCode ); |
---|
1345 | READ_FLAG( uiCode, "non_square_quadtree_enabled_flag" ); pcSPS->setUseNSQT( uiCode ); |
---|
1346 | READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" ); pcSPS->setUseSAO ( uiCode ? true : false ); |
---|
1347 | READ_FLAG( uiCode, "adaptive_loop_filter_enabled_flag" ); pcSPS->setUseALF ( uiCode ? true : false ); |
---|
1348 | if(pcSPS->getUseALF()) |
---|
1349 | { |
---|
1350 | READ_FLAG( uiCode, "alf_coef_in_slice_flag" ); pcSPS->setUseALFCoefInSlice ( uiCode ? true : false ); |
---|
1351 | } |
---|
1352 | if( pcSPS->getUsePCM() ) |
---|
1353 | { |
---|
1354 | READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" ); pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false ); |
---|
1355 | } |
---|
1356 | |
---|
1357 | READ_FLAG( uiCode, "temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); |
---|
1358 | |
---|
1359 | |
---|
1360 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
1361 | TComReferencePictureSet* rps; |
---|
1362 | |
---|
1363 | READ_UVLC( uiCode, "num_short_term_ref_pic_sets" ); |
---|
1364 | rpsList->create(uiCode); |
---|
1365 | |
---|
1366 | for(UInt i=0; i< rpsList->getNumberOfReferencePictureSets(); i++) |
---|
1367 | { |
---|
1368 | rps = rpsList->getReferencePictureSet(i); |
---|
1369 | parseShortTermRefPicSet(pcSPS,rps,i); |
---|
1370 | } |
---|
1371 | READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode); |
---|
1372 | |
---|
1373 | // AMVP mode for each depth (AM_NONE or AM_EXPL) |
---|
1374 | for (Int i = 0; i < pcSPS->getMaxCUDepth(); i++) |
---|
1375 | { |
---|
1376 | xReadFlag( uiCode ); |
---|
1377 | pcSPS->setAMVPMode( i, (AMVP_MODE)uiCode ); |
---|
1378 | } |
---|
1379 | |
---|
1380 | READ_CODE(2, uiCode, "tiles_or_entropy_coding_sync_idc"); pcSPS->setTilesOrEntropyCodingSyncIdc(uiCode); |
---|
1381 | |
---|
1382 | if(pcSPS->getTilesOrEntropyCodingSyncIdc() == 1) |
---|
1383 | { |
---|
1384 | READ_UVLC ( uiCode, "num_tile_columns_minus1" ); |
---|
1385 | pcSPS->setNumColumnsMinus1( uiCode ); |
---|
1386 | READ_UVLC ( uiCode, "num_tile_rows_minus1" ); |
---|
1387 | pcSPS->setNumRowsMinus1( uiCode ); |
---|
1388 | READ_FLAG ( uiCode, "uniform_spacing_flag" ); |
---|
1389 | pcSPS->setUniformSpacingIdr( uiCode ); |
---|
1390 | if( pcSPS->getUniformSpacingIdr() == 0 ) |
---|
1391 | { |
---|
1392 | UInt* columnWidth = (UInt*)malloc(pcSPS->getNumColumnsMinus1()*sizeof(UInt)); |
---|
1393 | for(UInt i=0; i<pcSPS->getNumColumnsMinus1(); i++) |
---|
1394 | { |
---|
1395 | READ_UVLC( uiCode, "column_width" ); |
---|
1396 | columnWidth[i] = uiCode; |
---|
1397 | } |
---|
1398 | pcSPS->setColumnWidth(columnWidth); |
---|
1399 | free(columnWidth); |
---|
1400 | |
---|
1401 | UInt* rowHeight = (UInt*)malloc(pcSPS->getNumRowsMinus1()*sizeof(UInt)); |
---|
1402 | for(UInt i=0; i<pcSPS->getNumRowsMinus1(); i++) |
---|
1403 | { |
---|
1404 | READ_UVLC( uiCode, "row_height" ); |
---|
1405 | rowHeight[i] = uiCode; |
---|
1406 | } |
---|
1407 | pcSPS->setRowHeight(rowHeight); |
---|
1408 | free(rowHeight); |
---|
1409 | } |
---|
1410 | pcSPS->setLFCrossTileBoundaryFlag(true); //default |
---|
1411 | |
---|
1412 | if( pcSPS->getNumColumnsMinus1() !=0 || pcSPS->getNumRowsMinus1() != 0) |
---|
1413 | { |
---|
1414 | READ_FLAG ( uiCode, "loop_filter_across_tile_flag" ); |
---|
1415 | pcSPS->setLFCrossTileBoundaryFlag( (uiCode==1)?true:false); |
---|
1416 | } |
---|
1417 | } |
---|
1418 | READ_FLAG( uiCode, "sps_extension_flag"); |
---|
1419 | #if !QC_MVHEVC_B0046 |
---|
1420 | if(uiCode) |
---|
1421 | { |
---|
1422 | READ_FLAG( uiCode, "interview_refs_present_flag"); |
---|
1423 | if(uiCode) |
---|
1424 | { |
---|
1425 | READ_UVLC( uiCode, "num_usable_interview_refs_minus1" ); |
---|
1426 | pcSPS->setNumberOfUsableInterViewRefs( uiCode + 1 ); |
---|
1427 | |
---|
1428 | Int prev = 0; |
---|
1429 | for( Int j = 0 ; j < pcSPS->getNumberOfUsableInterViewRefs(); j++ ) |
---|
1430 | { |
---|
1431 | READ_UVLC(uiCode, "delta_usable_interview_ref_minus1"); |
---|
1432 | pcSPS->setUsableInterViewRef( j, (prev - uiCode - 1) ); |
---|
1433 | prev = pcSPS->getUsableInterViewRef( j ); |
---|
1434 | } |
---|
1435 | } |
---|
1436 | |
---|
1437 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1438 | READ_FLAG( uiCode, "enable_dmm_flag" ); |
---|
1439 | pcSPS->setUseDMM( uiCode ); |
---|
1440 | #endif |
---|
1441 | |
---|
1442 | #if HHI_MPI |
---|
1443 | if( bIsDepth ) |
---|
1444 | { |
---|
1445 | READ_FLAG( uiCode, "use_mvi_flag" ); |
---|
1446 | pcSPS->setUseMVI( uiCode ); |
---|
1447 | } |
---|
1448 | #endif |
---|
1449 | #if H3D_QTL |
---|
1450 | if( bIsDepth ) |
---|
1451 | { |
---|
1452 | READ_FLAG( uiCode, "use_qtlpc_flag" ); |
---|
1453 | pcSPS->setUseQTLPC( uiCode ); |
---|
1454 | } |
---|
1455 | #endif |
---|
1456 | |
---|
1457 | #if RWTH_SDC_DLT_B0036 |
---|
1458 | if( bIsDepth ) |
---|
1459 | { |
---|
1460 | READ_FLAG( uiCode, "use_dlt_flag" ); |
---|
1461 | pcSPS->setUseDLT( uiCode ); |
---|
1462 | if( pcSPS->getUseDLT() ) |
---|
1463 | { |
---|
1464 | // decode mapping |
---|
1465 | UInt uiNumDepthValues; |
---|
1466 | // parse number of values in DLT |
---|
1467 | xReadUvlc( uiNumDepthValues ); |
---|
1468 | |
---|
1469 | // parse actual DLT values |
---|
1470 | UInt* auiIdx2DepthValue = (UInt*) calloc(uiNumDepthValues, sizeof(UInt)); |
---|
1471 | for(UInt d=0; d<uiNumDepthValues; d++) |
---|
1472 | { |
---|
1473 | xReadUvlc( uiCode ); |
---|
1474 | auiIdx2DepthValue[d] = uiCode; |
---|
1475 | } |
---|
1476 | |
---|
1477 | pcSPS->setDepthLUTs(auiIdx2DepthValue, uiNumDepthValues); |
---|
1478 | |
---|
1479 | // clean memory |
---|
1480 | free(auiIdx2DepthValue); |
---|
1481 | } |
---|
1482 | else |
---|
1483 | pcSPS->setDepthLUTs(); |
---|
1484 | } |
---|
1485 | #endif |
---|
1486 | |
---|
1487 | READ_FLAG( uiCode, "base_view_flag" ); |
---|
1488 | if( uiCode ) |
---|
1489 | { // baseview SPS -> set standard values |
---|
1490 | pcSPS->initMultiviewSPS ( 0 ); |
---|
1491 | #if DEPTH_MAP_GENERATION |
---|
1492 | pcSPS->setPredDepthMapGeneration( 0, false ); |
---|
1493 | #endif |
---|
1494 | #if H3D_IVRP |
---|
1495 | #if QC_ARP_D0177 |
---|
1496 | pcSPS->setUseAdvRP ( 0 ); |
---|
1497 | pcSPS->setARPStepNum( 1 ); |
---|
1498 | #else |
---|
1499 | pcSPS->setMultiviewResPredMode ( 0 ); |
---|
1500 | #endif |
---|
1501 | #endif |
---|
1502 | |
---|
1503 | } |
---|
1504 | else |
---|
1505 | { |
---|
1506 | READ_FLAG( uiCode, "depth_flag" ); |
---|
1507 | if( uiCode ) |
---|
1508 | { |
---|
1509 | #if FCO_FIX_SPS_CHANGE |
---|
1510 | UInt uiViewId, uiCamParPrecision; |
---|
1511 | Int iVOI; |
---|
1512 | Bool bCamParSlice; |
---|
1513 | READ_UVLC( uiCode, "view_id" ); |
---|
1514 | READ_SVLC( iCode, "view_order_idx" ); |
---|
1515 | uiViewId = uiCode; |
---|
1516 | iVOI = iCode; |
---|
1517 | |
---|
1518 | if ( uiViewId == 0 ) |
---|
1519 | { |
---|
1520 | pcSPS->initMultiviewSPSDepth ( uiViewId, iVOI ); |
---|
1521 | } |
---|
1522 | else |
---|
1523 | { |
---|
1524 | READ_UVLC( uiCamParPrecision, "camera_parameter_precision" ); |
---|
1525 | READ_FLAG( uiCode, "camera_parameter_in_slice_header" ); bCamParSlice = ( uiCode == 1 ); |
---|
1526 | if( !bCamParSlice ) |
---|
1527 | { |
---|
1528 | for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ ) |
---|
1529 | { |
---|
1530 | READ_SVLC( iCode, "coded_scale" ); m_aaiTempScale [ uiBaseId ][ uiViewId ] = iCode; |
---|
1531 | READ_SVLC( iCode, "coded_offset" ); m_aaiTempOffset[ uiBaseId ][ uiViewId ] = iCode; |
---|
1532 | READ_SVLC( iCode, "inverse_coded_scale_plus_coded_scale" ); m_aaiTempScale [ uiViewId ][ uiBaseId ] = iCode - m_aaiTempScale [ uiBaseId ][ uiViewId ]; |
---|
1533 | READ_SVLC( iCode, "inverse_coded_offset_plus_coded_offset" ); m_aaiTempOffset[ uiViewId ][ uiBaseId ] = iCode - m_aaiTempOffset[ uiBaseId ][ uiViewId ]; |
---|
1534 | } |
---|
1535 | } |
---|
1536 | pcSPS->initMultiviewSPSDepth( uiViewId, iVOI, uiCamParPrecision, bCamParSlice, m_aaiTempScale, m_aaiTempOffset ); |
---|
1537 | |
---|
1538 | } |
---|
1539 | #else |
---|
1540 | READ_UVLC( uiCode, "view_id" ); |
---|
1541 | READ_SVLC( iCode, "view_order_idx" ); |
---|
1542 | pcSPS->initMultiviewSPSDepth ( uiCode, iCode ); |
---|
1543 | #endif |
---|
1544 | #if DEPTH_MAP_GENERATION |
---|
1545 | #if FCO_FIX_SPS_CHANGE |
---|
1546 | pcSPS->setPredDepthMapGeneration( uiViewId, true ); |
---|
1547 | #else |
---|
1548 | pcSPS->setPredDepthMapGeneration( uiCode, true ); |
---|
1549 | #endif |
---|
1550 | #endif |
---|
1551 | #if H3D_IVRP |
---|
1552 | #if QC_ARP_D0177 |
---|
1553 | pcSPS->setUseAdvRP ( 0 ); |
---|
1554 | pcSPS->setARPStepNum( 1 ); |
---|
1555 | #else |
---|
1556 | pcSPS->setMultiviewResPredMode ( 0 ); |
---|
1557 | #endif |
---|
1558 | #endif |
---|
1559 | |
---|
1560 | } |
---|
1561 | else |
---|
1562 | { |
---|
1563 | UInt uiViewId, uiCamParPrecision; |
---|
1564 | Int iVOI; |
---|
1565 | Bool bCamParSlice; |
---|
1566 | READ_UVLC( uiViewId, "view_id" ); uiViewId++; |
---|
1567 | READ_SVLC( iVOI, "view_order_idx" ); |
---|
1568 | READ_UVLC( uiCamParPrecision, "camera_parameter_precision" ); |
---|
1569 | READ_FLAG( uiCode, "camera_parameter_in_slice_header" ); bCamParSlice = ( uiCode == 1 ); |
---|
1570 | if( !bCamParSlice ) |
---|
1571 | { |
---|
1572 | for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ ) |
---|
1573 | { |
---|
1574 | READ_SVLC( iCode, "coded_scale" ); m_aaiTempScale [ uiBaseId ][ uiViewId ] = iCode; |
---|
1575 | READ_SVLC( iCode, "coded_offset" ); m_aaiTempOffset[ uiBaseId ][ uiViewId ] = iCode; |
---|
1576 | READ_SVLC( iCode, "inverse_coded_scale_plus_coded_scale" ); m_aaiTempScale [ uiViewId ][ uiBaseId ] = iCode - m_aaiTempScale [ uiBaseId ][ uiViewId ]; |
---|
1577 | READ_SVLC( iCode, "inverse_coded_offset_plus_coded_offset" ); m_aaiTempOffset[ uiViewId ][ uiBaseId ] = iCode - m_aaiTempOffset[ uiBaseId ][ uiViewId ]; |
---|
1578 | } |
---|
1579 | } |
---|
1580 | pcSPS->initMultiviewSPS( uiViewId, iVOI, uiCamParPrecision, bCamParSlice, m_aaiTempScale, m_aaiTempOffset ); |
---|
1581 | |
---|
1582 | #if DEPTH_MAP_GENERATION |
---|
1583 | UInt uiPredDepthMapGeneration = 0, uiPdmPrecision = 0; |
---|
1584 | #if H3D_IVMP |
---|
1585 | UInt uiMultiviewMvPredMode = 0; |
---|
1586 | #endif |
---|
1587 | #if H3D_IVRP & !QC_ARP_D0177 |
---|
1588 | UInt uiMultiviewResPredMode = 0; |
---|
1589 | #endif |
---|
1590 | READ_UVLC( uiPredDepthMapGeneration, "Pdm_generation" ); |
---|
1591 | if( uiPredDepthMapGeneration ) |
---|
1592 | { |
---|
1593 | READ_UVLC( uiPdmPrecision, "Pdm_precision" ); |
---|
1594 | for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ ) |
---|
1595 | { |
---|
1596 | READ_SVLC( iCode, "Pdm_scale_nom_delta" ); m_aaiTempPdmScaleNomDelta[ uiViewId ][ uiBaseId ] = iCode; |
---|
1597 | READ_SVLC( iCode, "Pdm_offset" ); m_aaiTempPdmOffset [ uiViewId ][ uiBaseId ] = iCode; |
---|
1598 | } |
---|
1599 | #if H3D_IVMP |
---|
1600 | READ_UVLC( uiMultiviewMvPredMode, "multi_view_mv_pred_mode" ); |
---|
1601 | #endif |
---|
1602 | #if H3D_IVRP & !QC_ARP_D0177 |
---|
1603 | READ_FLAG( uiMultiviewResPredMode, "multi_view_residual_pred_mode" ); |
---|
1604 | #endif |
---|
1605 | } |
---|
1606 | #if H3D_IVMP |
---|
1607 | pcSPS->setPredDepthMapGeneration( uiViewId, false, uiPredDepthMapGeneration, uiMultiviewMvPredMode, uiPdmPrecision, m_aaiTempPdmScaleNomDelta, m_aaiTempPdmOffset ); |
---|
1608 | #else |
---|
1609 | pcSPS->setPredDepthMapGeneration( uiViewId, false, uiPredDepthMapGeneration, 0, uiPdmPrecision, m_aaiTempPdmScaleNomDelta, m_aaiTempPdmOffset ); |
---|
1610 | #endif |
---|
1611 | #endif |
---|
1612 | #if H3D_IVRP |
---|
1613 | #if QC_ARP_D0177 |
---|
1614 | READ_FLAG( uiCode , "advanced_residual_pred_flag" ); pcSPS->setUseAdvRP( uiCode ); |
---|
1615 | if( pcSPS->getUseAdvRP() ) |
---|
1616 | pcSPS->setARPStepNum( QC_ARP_WFNR ); |
---|
1617 | else |
---|
1618 | pcSPS->setARPStepNum( 1 ); |
---|
1619 | #else |
---|
1620 | pcSPS->setMultiviewResPredMode ( uiMultiviewResPredMode ); |
---|
1621 | #endif |
---|
1622 | #endif |
---|
1623 | |
---|
1624 | } |
---|
1625 | } |
---|
1626 | READ_FLAG( uiCode, "sps_extension2_flag"); |
---|
1627 | if (uiCode) |
---|
1628 | { |
---|
1629 | while ( xMoreRbspData() ) |
---|
1630 | { |
---|
1631 | READ_FLAG( uiCode, "sps_extension2_data_flag"); |
---|
1632 | } |
---|
1633 | } |
---|
1634 | } |
---|
1635 | #endif |
---|
1636 | } |
---|
1637 | |
---|
1638 | Void TDecCavlc::readTileMarker ( UInt& uiTileIdx, UInt uiBitsUsed ) |
---|
1639 | { |
---|
1640 | xReadCode ( uiBitsUsed, uiTileIdx ); |
---|
1641 | } |
---|
1642 | |
---|
1643 | #if MTK_DEPTH_MERGE_TEXTURE_CANDIDATE_C0137 |
---|
1644 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager, AlfCUCtrlInfo &alfCUCtrl, AlfParamSet& alfParamSet, bool isDepth) |
---|
1645 | #else |
---|
1646 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager, AlfCUCtrlInfo &alfCUCtrl, AlfParamSet& alfParamSet) |
---|
1647 | #endif |
---|
1648 | { |
---|
1649 | UInt uiCode; |
---|
1650 | Int iCode; |
---|
1651 | |
---|
1652 | #if ENC_DEC_TRACE |
---|
1653 | xTraceSliceHeader(rpcSlice); |
---|
1654 | #endif |
---|
1655 | Int numCUs = ((rpcSlice->getSPS()->getPicWidthInLumaSamples()+rpcSlice->getSPS()->getMaxCUWidth()-1)/rpcSlice->getSPS()->getMaxCUWidth())*((rpcSlice->getSPS()->getPicHeightInLumaSamples()+rpcSlice->getSPS()->getMaxCUHeight()-1)/rpcSlice->getSPS()->getMaxCUHeight()); |
---|
1656 | Int maxParts = (1<<(rpcSlice->getSPS()->getMaxCUDepth()<<1)); |
---|
1657 | Int numParts = (1<<(rpcSlice->getPPS()->getSliceGranularity()<<1)); |
---|
1658 | UInt lCUAddress = 0; |
---|
1659 | Int reqBitsOuter = 0; |
---|
1660 | while(numCUs>(1<<reqBitsOuter)) |
---|
1661 | { |
---|
1662 | reqBitsOuter++; |
---|
1663 | } |
---|
1664 | Int reqBitsInner = 0; |
---|
1665 | while((numParts)>(1<<reqBitsInner)) |
---|
1666 | { |
---|
1667 | reqBitsInner++; |
---|
1668 | } |
---|
1669 | |
---|
1670 | READ_FLAG( uiCode, "first_slice_in_pic_flag" ); |
---|
1671 | UInt address; |
---|
1672 | UInt innerAddress = 0; |
---|
1673 | |
---|
1674 | #if LGE_ILLUCOMP_B0045 |
---|
1675 | // IC flag is on only first_slice_in_pic |
---|
1676 | if (uiCode) |
---|
1677 | { |
---|
1678 | UInt uiCodeTmp = 0; |
---|
1679 | if ( rpcSlice->getSPS()->getViewId() |
---|
1680 | #if !LGE_ILLUCOMP_DEPTH_C0046 |
---|
1681 | && !rpcSlice->getSPS()->isDepth() |
---|
1682 | #endif |
---|
1683 | ) |
---|
1684 | { |
---|
1685 | READ_FLAG (uiCodeTmp, "applying IC flag"); |
---|
1686 | } |
---|
1687 | rpcSlice->setApplyIC(uiCodeTmp); |
---|
1688 | } |
---|
1689 | #endif |
---|
1690 | |
---|
1691 | if(!uiCode) |
---|
1692 | { |
---|
1693 | READ_CODE( reqBitsOuter+reqBitsInner, address, "slice_address" ); |
---|
1694 | lCUAddress = address >> reqBitsInner; |
---|
1695 | innerAddress = address - (lCUAddress<<reqBitsInner); |
---|
1696 | } |
---|
1697 | //set uiCode to equal slice start address (or entropy slice start address) |
---|
1698 | uiCode=(maxParts*lCUAddress)+(innerAddress*(maxParts>>(rpcSlice->getPPS()->getSliceGranularity()<<1))); |
---|
1699 | |
---|
1700 | rpcSlice->setEntropySliceCurStartCUAddr( uiCode ); |
---|
1701 | rpcSlice->setEntropySliceCurEndCUAddr(numCUs*maxParts); |
---|
1702 | |
---|
1703 | // slice_type |
---|
1704 | READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); |
---|
1705 | // lightweight_slice_flag |
---|
1706 | READ_FLAG( uiCode, "entropy_slice_flag" ); |
---|
1707 | Bool bEntropySlice = uiCode ? true : false; |
---|
1708 | |
---|
1709 | if (bEntropySlice) |
---|
1710 | { |
---|
1711 | rpcSlice->setNextSlice ( false ); |
---|
1712 | rpcSlice->setNextEntropySlice ( true ); |
---|
1713 | } |
---|
1714 | else |
---|
1715 | { |
---|
1716 | rpcSlice->setNextSlice ( true ); |
---|
1717 | rpcSlice->setNextEntropySlice ( false ); |
---|
1718 | |
---|
1719 | uiCode=(maxParts*lCUAddress)+(innerAddress*(maxParts>>(rpcSlice->getPPS()->getSliceGranularity()<<1))); |
---|
1720 | rpcSlice->setSliceCurStartCUAddr(uiCode); |
---|
1721 | rpcSlice->setSliceCurEndCUAddr(numCUs*maxParts); |
---|
1722 | } |
---|
1723 | TComPPS* pps = NULL; |
---|
1724 | TComSPS* sps = NULL; |
---|
1725 | |
---|
1726 | if (!bEntropySlice) |
---|
1727 | { |
---|
1728 | READ_UVLC ( uiCode, "pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); |
---|
1729 | pps = parameterSetManager->getPrefetchedPPS(uiCode); |
---|
1730 | sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); |
---|
1731 | rpcSlice->setSPS(sps); |
---|
1732 | rpcSlice->setPPS(pps); |
---|
1733 | if( pps->getOutputFlagPresentFlag() ) |
---|
1734 | { |
---|
1735 | READ_FLAG( uiCode, "pic_output_flag" ); |
---|
1736 | rpcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
1737 | } |
---|
1738 | else |
---|
1739 | { |
---|
1740 | rpcSlice->setPicOutputFlag( true ); |
---|
1741 | } |
---|
1742 | #if QC_REM_IDV_B0046 |
---|
1743 | #if !QC_MVHEVC_B0046 |
---|
1744 | if(rpcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_IDR && rpcSlice->getSPS()->getViewId() == 0) |
---|
1745 | #else |
---|
1746 | if(rpcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_IDR && rpcSlice->getViewId() == 0) |
---|
1747 | #endif |
---|
1748 | #else |
---|
1749 | if(rpcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_IDR) |
---|
1750 | #endif |
---|
1751 | { |
---|
1752 | READ_UVLC( uiCode, "idr_pic_id" ); //ignored |
---|
1753 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored |
---|
1754 | rpcSlice->setPOC(0); |
---|
1755 | TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); |
---|
1756 | rps->setNumberOfNegativePictures(0); |
---|
1757 | rps->setNumberOfPositivePictures(0); |
---|
1758 | rps->setNumberOfLongtermPictures(0); |
---|
1759 | rps->setNumberOfPictures(0); |
---|
1760 | rpcSlice->setRPS(rps); |
---|
1761 | } |
---|
1762 | else |
---|
1763 | { |
---|
1764 | READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); |
---|
1765 | Int iPOClsb = uiCode; |
---|
1766 | Int iPrevPOC = rpcSlice->getPrevPOC(); |
---|
1767 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
1768 | Int iPrevPOClsb = iPrevPOC%iMaxPOClsb; |
---|
1769 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
1770 | Int iPOCmsb; |
---|
1771 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
1772 | { |
---|
1773 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
1774 | } |
---|
1775 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
1776 | { |
---|
1777 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
1778 | } |
---|
1779 | else |
---|
1780 | { |
---|
1781 | iPOCmsb = iPrevPOCmsb; |
---|
1782 | } |
---|
1783 | rpcSlice->setPOC( iPOCmsb+iPOClsb ); |
---|
1784 | #if QC_REM_IDV_B0046 |
---|
1785 | #if !QC_MVHEVC_B0046 |
---|
1786 | if( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR && rpcSlice->getSPS()->getViewId() && rpcSlice->getPOC() == 0 ) |
---|
1787 | #else |
---|
1788 | if( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR && rpcSlice->getViewId() && rpcSlice->getPOC() == 0 ) |
---|
1789 | #endif |
---|
1790 | #else |
---|
1791 | if( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDV && rpcSlice->getPOC() == 0 ) |
---|
1792 | #endif |
---|
1793 | { |
---|
1794 | TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); |
---|
1795 | rps->setNumberOfNegativePictures(0); |
---|
1796 | rps->setNumberOfPositivePictures(0); |
---|
1797 | rps->setNumberOfLongtermPictures(0); |
---|
1798 | rps->setNumberOfPictures(0); |
---|
1799 | rpcSlice->setRPS(rps); |
---|
1800 | } |
---|
1801 | else |
---|
1802 | { |
---|
1803 | TComReferencePictureSet* rps; |
---|
1804 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
1805 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
1806 | { |
---|
1807 | rps = rpcSlice->getLocalRPS(); |
---|
1808 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
1809 | rpcSlice->setRPS(rps); |
---|
1810 | } |
---|
1811 | else // use reference to short-term reference picture set in PPS |
---|
1812 | { |
---|
1813 | READ_UVLC( uiCode, "short_term_ref_pic_set_idx"); rpcSlice->setRPS(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
1814 | rps = rpcSlice->getRPS(); |
---|
1815 | } |
---|
1816 | if(sps->getLongTermRefsPresent()) |
---|
1817 | { |
---|
1818 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
1819 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
1820 | Int prev = 0; |
---|
1821 | Int prevMsb=0; |
---|
1822 | Int prevDeltaPocLt=0; |
---|
1823 | for(Int j=rps->getNumberOfLongtermPictures()+offset-1 ; j > offset-1; j--) |
---|
1824 | { |
---|
1825 | READ_UVLC(uiCode,"delta_poc_lsb_lt"); |
---|
1826 | prev += uiCode; |
---|
1827 | |
---|
1828 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
1829 | Int decDeltaPOCMsbPresent=uiCode; |
---|
1830 | |
---|
1831 | if(decDeltaPOCMsbPresent==1) |
---|
1832 | { |
---|
1833 | READ_UVLC(uiCode, "delta_poc_msb_cycle_lt_minus1"); |
---|
1834 | if( (j==(rps->getNumberOfLongtermPictures()+offset-1)) || (prev!=prevDeltaPocLt) ) |
---|
1835 | { |
---|
1836 | prevMsb=(1+uiCode); |
---|
1837 | } |
---|
1838 | else |
---|
1839 | { |
---|
1840 | prevMsb+=(1+uiCode); |
---|
1841 | } |
---|
1842 | Int decMaxPocLsb = 1<<rpcSlice->getSPS()->getBitsForPOC(); |
---|
1843 | rps->setPOC(j,rpcSlice->getPOC()-prev-(prevMsb)*decMaxPocLsb); |
---|
1844 | rps->setDeltaPOC(j,-(Int)(prev+(prevMsb)*decMaxPocLsb)); |
---|
1845 | } |
---|
1846 | else |
---|
1847 | { |
---|
1848 | rps->setPOC(j,rpcSlice->getPOC()-prev); |
---|
1849 | rps->setDeltaPOC(j,-(Int)prev); |
---|
1850 | } |
---|
1851 | prevDeltaPocLt=prev; |
---|
1852 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
1853 | } |
---|
1854 | offset += rps->getNumberOfLongtermPictures(); |
---|
1855 | rps->setNumberOfPictures(offset); |
---|
1856 | } |
---|
1857 | } |
---|
1858 | } |
---|
1859 | |
---|
1860 | if(sps->getUseSAO() || sps->getUseALF() || sps->getScalingListFlag() || sps->getUseDF()) |
---|
1861 | { |
---|
1862 | //!!!KS: order is different in WD5! |
---|
1863 | if (sps->getUseALF()) |
---|
1864 | { |
---|
1865 | READ_FLAG(uiCode, "slice_adaptive_loop_filter_flag"); |
---|
1866 | rpcSlice->setAlfEnabledFlag((Bool)uiCode); |
---|
1867 | } |
---|
1868 | if (sps->getUseSAO()) |
---|
1869 | { |
---|
1870 | READ_FLAG(uiCode, "slice_sao_interleaving_flag"); rpcSlice->setSaoInterleavingFlag(uiCode); |
---|
1871 | READ_FLAG(uiCode, "slice_sample_adaptive_offset_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); |
---|
1872 | if (rpcSlice->getSaoEnabledFlag() && rpcSlice->getSaoInterleavingFlag()) |
---|
1873 | { |
---|
1874 | READ_FLAG(uiCode, "sao_cb_enable_flag"); rpcSlice->setSaoEnabledFlagCb((Bool)uiCode); |
---|
1875 | READ_FLAG(uiCode, "sao_cr_enable_flag"); rpcSlice->setSaoEnabledFlagCr((Bool)uiCode); |
---|
1876 | } |
---|
1877 | else |
---|
1878 | { |
---|
1879 | rpcSlice->setSaoEnabledFlagCb(0); |
---|
1880 | rpcSlice->setSaoEnabledFlagCr(0); |
---|
1881 | } |
---|
1882 | } |
---|
1883 | READ_UVLC ( uiCode, "aps_id" ); rpcSlice->setAPSId(uiCode); |
---|
1884 | } |
---|
1885 | if (!rpcSlice->isIntra()) |
---|
1886 | { |
---|
1887 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
1888 | if (uiCode) |
---|
1889 | { |
---|
1890 | READ_CODE (3, uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
1891 | if (rpcSlice->isInterB()) |
---|
1892 | { |
---|
1893 | READ_CODE (3, uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
1894 | } |
---|
1895 | else |
---|
1896 | { |
---|
1897 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
1898 | } |
---|
1899 | } |
---|
1900 | else |
---|
1901 | { |
---|
1902 | rpcSlice->setNumRefIdx(REF_PIC_LIST_0, 0); |
---|
1903 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
1904 | } |
---|
1905 | } |
---|
1906 | TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); |
---|
1907 | if( !rpcSlice->isIntra() ) |
---|
1908 | { |
---|
1909 | #if QC_MVHEVC_B0046 |
---|
1910 | if( !rpcSlice->getViewId() || !rpcSlice->getSPS()->getListsModificationPresentFlag() ) |
---|
1911 | #else |
---|
1912 | if( !rpcSlice->getSPS()->getListsModificationPresentFlag() ) |
---|
1913 | #endif |
---|
1914 | { |
---|
1915 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
1916 | } |
---|
1917 | else |
---|
1918 | { |
---|
1919 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
1920 | } |
---|
1921 | |
---|
1922 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
1923 | { |
---|
1924 | uiCode = 0; |
---|
1925 | Int i = 0; |
---|
1926 | Int NumPocTotalCurr = rpcSlice->getNumPocTotalCurrMvc(); |
---|
1927 | if ( NumPocTotalCurr > 1 ) |
---|
1928 | { |
---|
1929 | Int length = 1; |
---|
1930 | NumPocTotalCurr --; |
---|
1931 | while ( NumPocTotalCurr >>= 1) |
---|
1932 | { |
---|
1933 | length ++; |
---|
1934 | } |
---|
1935 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
1936 | { |
---|
1937 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
1938 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
1939 | } |
---|
1940 | } |
---|
1941 | else |
---|
1942 | { |
---|
1943 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
1944 | { |
---|
1945 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
1946 | } |
---|
1947 | } |
---|
1948 | } |
---|
1949 | } |
---|
1950 | else |
---|
1951 | { |
---|
1952 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
1953 | } |
---|
1954 | if(rpcSlice->isInterB()) |
---|
1955 | { |
---|
1956 | #if QC_MVHEVC_B0046 |
---|
1957 | if( !rpcSlice->getViewId() || !rpcSlice->getSPS()->getListsModificationPresentFlag() ) |
---|
1958 | #else |
---|
1959 | if( !rpcSlice->getSPS()->getListsModificationPresentFlag() ) |
---|
1960 | #endif |
---|
1961 | { |
---|
1962 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
1963 | } |
---|
1964 | else |
---|
1965 | { |
---|
1966 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
1967 | } |
---|
1968 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
1969 | { |
---|
1970 | uiCode = 0; |
---|
1971 | Int i = 0; |
---|
1972 | Int NumPocTotalCurr = rpcSlice->getNumPocTotalCurrMvc(); |
---|
1973 | if ( NumPocTotalCurr > 1 ) |
---|
1974 | { |
---|
1975 | Int length = 1; |
---|
1976 | NumPocTotalCurr --; |
---|
1977 | while ( NumPocTotalCurr >>= 1) |
---|
1978 | { |
---|
1979 | length ++; |
---|
1980 | } |
---|
1981 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
1982 | { |
---|
1983 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
1984 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
1985 | } |
---|
1986 | } |
---|
1987 | else |
---|
1988 | { |
---|
1989 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
1990 | { |
---|
1991 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
1992 | } |
---|
1993 | } |
---|
1994 | } |
---|
1995 | } |
---|
1996 | else |
---|
1997 | { |
---|
1998 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
1999 | } |
---|
2000 | } |
---|
2001 | else |
---|
2002 | { |
---|
2003 | // initialize from previous slice |
---|
2004 | pps = rpcSlice->getPPS(); |
---|
2005 | sps = rpcSlice->getSPS(); |
---|
2006 | } |
---|
2007 | // ref_pic_list_combination( ) |
---|
2008 | //!!!KS: ref_pic_list_combination() should be conditioned on entropy_slice_flag |
---|
2009 | if (rpcSlice->isInterB()) |
---|
2010 | { |
---|
2011 | READ_FLAG( uiCode, "ref_pic_list_combination_flag" ); rpcSlice->setRefPicListCombinationFlag( uiCode ? 1 : 0 ); |
---|
2012 | if(uiCode) |
---|
2013 | { |
---|
2014 | READ_UVLC( uiCode, "num_ref_idx_lc_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_C, uiCode + 1 ); |
---|
2015 | |
---|
2016 | #if QC_MVHEVC_B0046 |
---|
2017 | if( rpcSlice->getViewId() && rpcSlice->getSPS()->getListsModificationPresentFlag() ) |
---|
2018 | #else |
---|
2019 | if(rpcSlice->getSPS()->getListsModificationPresentFlag() ) |
---|
2020 | #endif |
---|
2021 | { |
---|
2022 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_lc" ); rpcSlice->setRefPicListModificationFlagLC( uiCode ? 1 : 0 ); |
---|
2023 | if(uiCode) |
---|
2024 | { |
---|
2025 | for (UInt i=0;i<rpcSlice->getNumRefIdx(REF_PIC_LIST_C);i++) |
---|
2026 | { |
---|
2027 | READ_FLAG( uiCode, "pic_from_list_0_flag" ); |
---|
2028 | rpcSlice->setListIdFromIdxOfLC(i, uiCode); |
---|
2029 | if (((rpcSlice->getListIdFromIdxOfLC(i) == REF_PIC_LIST_0) && (rpcSlice->getNumRefIdx( REF_PIC_LIST_0 ) == 1)) || ((rpcSlice->getListIdFromIdxOfLC(i) == REF_PIC_LIST_1) && (rpcSlice->getNumRefIdx( REF_PIC_LIST_1 ) == 1)) ) |
---|
2030 | { |
---|
2031 | uiCode = 0; |
---|
2032 | } |
---|
2033 | else |
---|
2034 | { |
---|
2035 | READ_UVLC( uiCode, "ref_idx_list_curr" ); |
---|
2036 | } |
---|
2037 | rpcSlice->setRefIdxFromIdxOfLC(i, uiCode); |
---|
2038 | rpcSlice->setRefIdxOfLC((RefPicList)rpcSlice->getListIdFromIdxOfLC(i), rpcSlice->getRefIdxFromIdxOfLC(i), i); |
---|
2039 | } |
---|
2040 | } |
---|
2041 | } |
---|
2042 | else |
---|
2043 | { |
---|
2044 | rpcSlice->setRefPicListModificationFlagLC(false); |
---|
2045 | } |
---|
2046 | } |
---|
2047 | else |
---|
2048 | { |
---|
2049 | rpcSlice->setRefPicListModificationFlagLC(false); |
---|
2050 | rpcSlice->setNumRefIdx(REF_PIC_LIST_C, 0); |
---|
2051 | } |
---|
2052 | } |
---|
2053 | else |
---|
2054 | { |
---|
2055 | rpcSlice->setRefPicListCombinationFlag(false); |
---|
2056 | } |
---|
2057 | |
---|
2058 | if (rpcSlice->isInterB()) |
---|
2059 | { |
---|
2060 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
2061 | } |
---|
2062 | |
---|
2063 | #if CABAC_INIT_FLAG |
---|
2064 | rpcSlice->setCabacInitFlag( false ); // default |
---|
2065 | if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) |
---|
2066 | { |
---|
2067 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
2068 | rpcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
2069 | } |
---|
2070 | #else |
---|
2071 | if(pps->getEntropyCodingMode() && !rpcSlice->isIntra()) |
---|
2072 | { |
---|
2073 | READ_UVLC(uiCode, "cabac_init_idc"); |
---|
2074 | rpcSlice->setCABACinitIDC(uiCode); |
---|
2075 | } |
---|
2076 | else if (pps->getEntropyCodingMode() && rpcSlice->isIntra()) |
---|
2077 | { |
---|
2078 | rpcSlice->setCABACinitIDC(0); |
---|
2079 | } |
---|
2080 | #endif |
---|
2081 | |
---|
2082 | if(!bEntropySlice) |
---|
2083 | { |
---|
2084 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
2085 | rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
2086 | |
---|
2087 | assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); |
---|
2088 | assert( rpcSlice->getSliceQp() <= 51 ); |
---|
2089 | |
---|
2090 | if (rpcSlice->getPPS()->getDeblockingFilterControlPresent()) |
---|
2091 | { |
---|
2092 | if ( rpcSlice->getSPS()->getUseDF() ) |
---|
2093 | { |
---|
2094 | READ_FLAG ( uiCode, "inherit_dbl_param_from_APS_flag" ); rpcSlice->setInheritDblParamFromAPS(uiCode ? 1 : 0); |
---|
2095 | } else |
---|
2096 | { |
---|
2097 | rpcSlice->setInheritDblParamFromAPS(0); |
---|
2098 | } |
---|
2099 | if(!rpcSlice->getInheritDblParamFromAPS()) |
---|
2100 | { |
---|
2101 | READ_FLAG ( uiCode, "disable_deblocking_filter_flag" ); rpcSlice->setLoopFilterDisable(uiCode ? 1 : 0); |
---|
2102 | if(!rpcSlice->getLoopFilterDisable()) |
---|
2103 | { |
---|
2104 | READ_SVLC( iCode, "beta_offset_div2" ); rpcSlice->setLoopFilterBetaOffset(iCode); |
---|
2105 | READ_SVLC( iCode, "tc_offset_div2" ); rpcSlice->setLoopFilterTcOffset(iCode); |
---|
2106 | } |
---|
2107 | } |
---|
2108 | } |
---|
2109 | if ( rpcSlice->getSliceType() == B_SLICE ) |
---|
2110 | { |
---|
2111 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
2112 | rpcSlice->setColDir(uiCode); |
---|
2113 | } |
---|
2114 | |
---|
2115 | #if COLLOCATED_REF_IDX |
---|
2116 | if ( rpcSlice->getSliceType() != I_SLICE && |
---|
2117 | ((rpcSlice->getColDir()==0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0)>1)|| |
---|
2118 | (rpcSlice->getColDir() ==1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1)>1))) |
---|
2119 | { |
---|
2120 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
2121 | rpcSlice->setColRefIdx(uiCode); |
---|
2122 | } |
---|
2123 | #endif |
---|
2124 | |
---|
2125 | if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPredIdc() && rpcSlice->getSliceType()==B_SLICE) ) |
---|
2126 | { |
---|
2127 | xParsePredWeightTable(rpcSlice); |
---|
2128 | rpcSlice->initWpScaling(); |
---|
2129 | } |
---|
2130 | } |
---|
2131 | |
---|
2132 | if (!bEntropySlice) |
---|
2133 | { |
---|
2134 | if( rpcSlice->getSPS()->hasCamParInSliceHeader() ) |
---|
2135 | { |
---|
2136 | UInt uiViewId = rpcSlice->getSPS()->getViewId(); |
---|
2137 | for( UInt uiBaseId = 0; uiBaseId < uiViewId; uiBaseId++ ) |
---|
2138 | { |
---|
2139 | READ_SVLC( iCode, "coded_scale" ); m_aaiTempScale [ uiBaseId ][ uiViewId ] = iCode; |
---|
2140 | READ_SVLC( iCode, "coded_offset" ); m_aaiTempOffset[ uiBaseId ][ uiViewId ] = iCode; |
---|
2141 | READ_SVLC( iCode, "inverse_coded_scale_plus_coded_scale" ); m_aaiTempScale [ uiViewId ][ uiBaseId ] = iCode - m_aaiTempScale [ uiBaseId ][ uiViewId ]; |
---|
2142 | READ_SVLC( iCode, "inverse_coded_offset_plus_coded_offset" ); m_aaiTempOffset[ uiViewId ][ uiBaseId ] = iCode - m_aaiTempOffset[ uiBaseId ][ uiViewId ]; |
---|
2143 | } |
---|
2144 | rpcSlice->initMultiviewSlice( m_aaiTempScale, m_aaiTempOffset ); |
---|
2145 | } |
---|
2146 | } |
---|
2147 | |
---|
2148 | #if ( HHI_MPI || H3D_IVMP ) |
---|
2149 | #if ( HHI_MPI && H3D_IVMP ) |
---|
2150 | const int iExtraMergeCandidates = ( sps->getUseMVI() || sps->getMultiviewMvPredMode() ) ? 1 : 0; |
---|
2151 | #elif HHI_MPI |
---|
2152 | const int iExtraMergeCandidates = sps->getUseMVI() ? 1 : 0; |
---|
2153 | #elif MTK_DEPTH_MERGE_TEXTURE_CANDIDATE_C0137 |
---|
2154 | const int iExtraMergeCandidates = ( (isDepth || sps->getMultiviewMvPredMode()) ) ? 1 : 0; |
---|
2155 | #else |
---|
2156 | const int iExtraMergeCandidates = sps->getMultiviewMvPredMode() ? 1 : 0; |
---|
2157 | #endif |
---|
2158 | READ_UVLC( uiCode, "5_minus_max_num_merge_cand"); |
---|
2159 | rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS + iExtraMergeCandidates - uiCode); |
---|
2160 | assert(rpcSlice->getMaxNumMergeCand()==(MRG_MAX_NUM_CANDS_SIGNALED+iExtraMergeCandidates)); |
---|
2161 | #else |
---|
2162 | READ_UVLC( uiCode, "5_minus_max_num_merge_cand"); |
---|
2163 | rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
2164 | assert(rpcSlice->getMaxNumMergeCand()==MRG_MAX_NUM_CANDS_SIGNALED); |
---|
2165 | #endif |
---|
2166 | |
---|
2167 | if (!bEntropySlice) |
---|
2168 | { |
---|
2169 | if(sps->getUseALF() && rpcSlice->getAlfEnabledFlag()) |
---|
2170 | { |
---|
2171 | UInt uiNumLCUsInWidth = sps->getPicWidthInLumaSamples() / g_uiMaxCUWidth; |
---|
2172 | UInt uiNumLCUsInHeight = sps->getPicHeightInLumaSamples() / g_uiMaxCUHeight; |
---|
2173 | |
---|
2174 | uiNumLCUsInWidth += ( sps->getPicWidthInLumaSamples() % g_uiMaxCUWidth ) ? 1 : 0; |
---|
2175 | uiNumLCUsInHeight += ( sps->getPicHeightInLumaSamples() % g_uiMaxCUHeight ) ? 1 : 0; |
---|
2176 | |
---|
2177 | Int uiNumCUsInFrame = uiNumLCUsInWidth* uiNumLCUsInHeight; |
---|
2178 | if(sps->getUseALFCoefInSlice()) |
---|
2179 | { |
---|
2180 | alfParamSet.releaseALFParam(); |
---|
2181 | alfParamSet.init(); |
---|
2182 | Bool isAcrossSlice = sps->getLFCrossSliceBoundaryFlag(); |
---|
2183 | Int numSUinLCU = 1<< (g_uiMaxCUDepth << 1); |
---|
2184 | Int firstLCUAddr = rpcSlice->getSliceCurStartCUAddr() / numSUinLCU; |
---|
2185 | xParseAlfParam(&alfParamSet, false, firstLCUAddr, isAcrossSlice, uiNumLCUsInWidth, uiNumLCUsInHeight); |
---|
2186 | } |
---|
2187 | |
---|
2188 | if(!sps->getUseALFCoefInSlice()) |
---|
2189 | { |
---|
2190 | xParseAlfCuControlParam(alfCUCtrl, uiNumCUsInFrame); |
---|
2191 | } |
---|
2192 | |
---|
2193 | } |
---|
2194 | } |
---|
2195 | |
---|
2196 | //!!!KS: The following syntax is not aligned with the working draft, TRACE support needs to be added |
---|
2197 | rpcSlice->setTileMarkerFlag ( 0 ); // default |
---|
2198 | if (!bEntropySlice) |
---|
2199 | { |
---|
2200 | xReadCode(1, uiCode); // read flag indicating if tile markers transmitted |
---|
2201 | rpcSlice->setTileMarkerFlag( uiCode ); |
---|
2202 | } |
---|
2203 | |
---|
2204 | Int tilesOrEntropyCodingSyncIdc = rpcSlice->getSPS()->getTilesOrEntropyCodingSyncIdc(); |
---|
2205 | UInt *entryPointOffset = NULL; |
---|
2206 | UInt numEntryPointOffsets, offsetLenMinus1; |
---|
2207 | |
---|
2208 | rpcSlice->setNumEntryPointOffsets ( 0 ); // default |
---|
2209 | |
---|
2210 | if (tilesOrEntropyCodingSyncIdc>0) |
---|
2211 | { |
---|
2212 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); |
---|
2213 | if (numEntryPointOffsets>0) |
---|
2214 | { |
---|
2215 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
2216 | } |
---|
2217 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
2218 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
2219 | { |
---|
2220 | Int bitsRead = m_pcBitstream->getNumBitsRead(); |
---|
2221 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset"); |
---|
2222 | entryPointOffset[ idx ] = uiCode; |
---|
2223 | if ( idx == 0 && tilesOrEntropyCodingSyncIdc == 2 ) |
---|
2224 | { |
---|
2225 | // Subtract distance from NALU header start to provide WPP 0-th substream the correct size. |
---|
2226 | entryPointOffset[ idx ] -= ( bitsRead + numEntryPointOffsets*(offsetLenMinus1+1) ) >> 3; |
---|
2227 | } |
---|
2228 | } |
---|
2229 | } |
---|
2230 | |
---|
2231 | if ( tilesOrEntropyCodingSyncIdc == 1 ) // tiles |
---|
2232 | { |
---|
2233 | rpcSlice->setTileLocationCount( numEntryPointOffsets ); |
---|
2234 | |
---|
2235 | UInt prevPos = 0; |
---|
2236 | for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) |
---|
2237 | { |
---|
2238 | rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); |
---|
2239 | prevPos += entryPointOffset[ idx ]; |
---|
2240 | } |
---|
2241 | } |
---|
2242 | else if ( tilesOrEntropyCodingSyncIdc == 2 ) // wavefront |
---|
2243 | { |
---|
2244 | Int numSubstreams = pps->getNumSubstreams(); |
---|
2245 | rpcSlice->allocSubstreamSizes(numSubstreams); |
---|
2246 | UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); |
---|
2247 | for (Int idx=0; idx<numSubstreams-1; idx++) |
---|
2248 | { |
---|
2249 | if ( idx < numEntryPointOffsets ) |
---|
2250 | { |
---|
2251 | pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; |
---|
2252 | } |
---|
2253 | else |
---|
2254 | { |
---|
2255 | pSubstreamSizes[ idx ] = 0; |
---|
2256 | } |
---|
2257 | } |
---|
2258 | } |
---|
2259 | |
---|
2260 | if (entryPointOffset) |
---|
2261 | { |
---|
2262 | delete [] entryPointOffset; |
---|
2263 | } |
---|
2264 | |
---|
2265 | if (!bEntropySlice) |
---|
2266 | { |
---|
2267 | // Reading location information |
---|
2268 | |
---|
2269 | // read out trailing bits |
---|
2270 | m_pcBitstream->readOutTrailingBits(); |
---|
2271 | } |
---|
2272 | return; |
---|
2273 | } |
---|
2274 | |
---|
2275 | Void TDecCavlc::xParseAlfCuControlParam(AlfCUCtrlInfo& cAlfParam, Int iNumCUsInPic) |
---|
2276 | { |
---|
2277 | UInt uiSymbol; |
---|
2278 | Int iSymbol; |
---|
2279 | |
---|
2280 | READ_FLAG (uiSymbol, "alf_cu_control_flag"); |
---|
2281 | cAlfParam.cu_control_flag = uiSymbol; |
---|
2282 | if (cAlfParam.cu_control_flag) |
---|
2283 | { |
---|
2284 | READ_UVLC (uiSymbol, "alf_cu_control_max_depth"); |
---|
2285 | cAlfParam.alf_max_depth = uiSymbol; |
---|
2286 | |
---|
2287 | READ_SVLC (iSymbol, "alf_length_cu_control_info"); |
---|
2288 | cAlfParam.num_alf_cu_flag = (UInt)(iSymbol + iNumCUsInPic); |
---|
2289 | |
---|
2290 | cAlfParam.alf_cu_flag.resize(cAlfParam.num_alf_cu_flag); |
---|
2291 | |
---|
2292 | for(UInt i=0; i< cAlfParam.num_alf_cu_flag; i++) |
---|
2293 | { |
---|
2294 | READ_FLAG (cAlfParam.alf_cu_flag[i], "alf_cu_flag"); |
---|
2295 | } |
---|
2296 | } |
---|
2297 | } |
---|
2298 | |
---|
2299 | #if !CABAC_INIT_FLAG |
---|
2300 | Void TDecCavlc::resetEntropy (TComSlice* pcSlice) |
---|
2301 | { |
---|
2302 | } |
---|
2303 | #endif |
---|
2304 | |
---|
2305 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
2306 | { |
---|
2307 | ruiBit = false; |
---|
2308 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
2309 | if(iBitsLeft <= 8) |
---|
2310 | { |
---|
2311 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
2312 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
2313 | { |
---|
2314 | ruiBit = true; |
---|
2315 | } |
---|
2316 | } |
---|
2317 | } |
---|
2318 | |
---|
2319 | Void TDecCavlc::parseSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2320 | { |
---|
2321 | assert(0); |
---|
2322 | } |
---|
2323 | |
---|
2324 | #if LGE_ILLUCOMP_B0045 |
---|
2325 | Void TDecCavlc::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2326 | { |
---|
2327 | assert(0); |
---|
2328 | } |
---|
2329 | #endif |
---|
2330 | |
---|
2331 | #if H3D_IVMP |
---|
2332 | Void TDecCavlc::parseMVPIdx( Int& riMVPIdx, Int iAMVPCands ) |
---|
2333 | #else |
---|
2334 | Void TDecCavlc::parseMVPIdx( Int& riMVPIdx ) |
---|
2335 | #endif |
---|
2336 | { |
---|
2337 | assert(0); |
---|
2338 | } |
---|
2339 | |
---|
2340 | Void TDecCavlc::parseSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2341 | { |
---|
2342 | assert(0); |
---|
2343 | } |
---|
2344 | |
---|
2345 | Void TDecCavlc::parsePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2346 | { |
---|
2347 | assert(0); |
---|
2348 | } |
---|
2349 | |
---|
2350 | Void TDecCavlc::parsePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2351 | { |
---|
2352 | assert(0); |
---|
2353 | } |
---|
2354 | |
---|
2355 | /** Parse I_PCM information. |
---|
2356 | * \param pcCU pointer to CU |
---|
2357 | * \param uiAbsPartIdx CU index |
---|
2358 | * \param uiDepth CU depth |
---|
2359 | * \returns Void |
---|
2360 | * |
---|
2361 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
2362 | */ |
---|
2363 | Void TDecCavlc::parseIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2364 | { |
---|
2365 | assert(0); |
---|
2366 | } |
---|
2367 | |
---|
2368 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2369 | { |
---|
2370 | assert(0); |
---|
2371 | } |
---|
2372 | |
---|
2373 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2374 | { |
---|
2375 | assert(0); |
---|
2376 | } |
---|
2377 | |
---|
2378 | Void TDecCavlc::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2379 | { |
---|
2380 | assert(0); |
---|
2381 | } |
---|
2382 | |
---|
2383 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* pcCU, Int& riRefFrmIdx, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
2384 | { |
---|
2385 | assert(0); |
---|
2386 | } |
---|
2387 | |
---|
2388 | Void TDecCavlc::parseMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ) |
---|
2389 | { |
---|
2390 | assert(0); |
---|
2391 | } |
---|
2392 | |
---|
2393 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2394 | { |
---|
2395 | Int qp; |
---|
2396 | Int iDQp; |
---|
2397 | |
---|
2398 | xReadSvlc( iDQp ); |
---|
2399 | |
---|
2400 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
2401 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
2402 | |
---|
2403 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>(8-(pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()<<1)))<<(8-(pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()<<1)) ; |
---|
2404 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
2405 | |
---|
2406 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
2407 | } |
---|
2408 | |
---|
2409 | Void TDecCavlc::parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType ) |
---|
2410 | { |
---|
2411 | assert(0); |
---|
2412 | } |
---|
2413 | |
---|
2414 | Void TDecCavlc::parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ) |
---|
2415 | { |
---|
2416 | assert(0); |
---|
2417 | } |
---|
2418 | |
---|
2419 | Void TDecCavlc::parseQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth ) |
---|
2420 | { |
---|
2421 | assert(0); |
---|
2422 | } |
---|
2423 | |
---|
2424 | Void TDecCavlc::parseQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf ) |
---|
2425 | { |
---|
2426 | assert(0); |
---|
2427 | } |
---|
2428 | |
---|
2429 | |
---|
2430 | Void TDecCavlc::parseMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) |
---|
2431 | { |
---|
2432 | assert(0); |
---|
2433 | } |
---|
2434 | |
---|
2435 | Void TDecCavlc::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2436 | { |
---|
2437 | assert(0); |
---|
2438 | } |
---|
2439 | |
---|
2440 | #if H3D_IVRP |
---|
2441 | Void |
---|
2442 | TDecCavlc::parseResPredFlag( TComDataCU* pcCU, Bool& rbResPredFlag, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2443 | { |
---|
2444 | assert(0); |
---|
2445 | } |
---|
2446 | #endif |
---|
2447 | #if QC_ARP_D0177 |
---|
2448 | Void TDecCavlc::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2449 | { |
---|
2450 | assert( false ); |
---|
2451 | } |
---|
2452 | #endif |
---|
2453 | #if RWTH_SDC_DLT_B0036 |
---|
2454 | Void TDecCavlc::parseSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2455 | { |
---|
2456 | assert(0); |
---|
2457 | } |
---|
2458 | Void TDecCavlc::parseSDCPredMode ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2459 | { |
---|
2460 | assert(0); |
---|
2461 | } |
---|
2462 | Void TDecCavlc::parseSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart ) |
---|
2463 | { |
---|
2464 | assert(0); |
---|
2465 | } |
---|
2466 | #endif |
---|
2467 | |
---|
2468 | // ==================================================================================================================== |
---|
2469 | // Protected member functions |
---|
2470 | // ==================================================================================================================== |
---|
2471 | |
---|
2472 | Void TDecCavlc::xReadCode (UInt uiLength, UInt& ruiCode) |
---|
2473 | { |
---|
2474 | assert ( uiLength > 0 ); |
---|
2475 | m_pcBitstream->read (uiLength, ruiCode); |
---|
2476 | } |
---|
2477 | |
---|
2478 | Void TDecCavlc::xReadUvlc( UInt& ruiVal) |
---|
2479 | { |
---|
2480 | UInt uiVal = 0; |
---|
2481 | UInt uiCode = 0; |
---|
2482 | UInt uiLength; |
---|
2483 | m_pcBitstream->read( 1, uiCode ); |
---|
2484 | |
---|
2485 | if( 0 == uiCode ) |
---|
2486 | { |
---|
2487 | uiLength = 0; |
---|
2488 | |
---|
2489 | while( ! ( uiCode & 1 )) |
---|
2490 | { |
---|
2491 | m_pcBitstream->read( 1, uiCode ); |
---|
2492 | uiLength++; |
---|
2493 | } |
---|
2494 | |
---|
2495 | m_pcBitstream->read( uiLength, uiVal ); |
---|
2496 | |
---|
2497 | uiVal += (1 << uiLength)-1; |
---|
2498 | } |
---|
2499 | |
---|
2500 | ruiVal = uiVal; |
---|
2501 | } |
---|
2502 | |
---|
2503 | Void TDecCavlc::xReadSvlc( Int& riVal) |
---|
2504 | { |
---|
2505 | UInt uiBits = 0; |
---|
2506 | m_pcBitstream->read( 1, uiBits ); |
---|
2507 | if( 0 == uiBits ) |
---|
2508 | { |
---|
2509 | UInt uiLength = 0; |
---|
2510 | |
---|
2511 | while( ! ( uiBits & 1 )) |
---|
2512 | { |
---|
2513 | m_pcBitstream->read( 1, uiBits ); |
---|
2514 | uiLength++; |
---|
2515 | } |
---|
2516 | |
---|
2517 | m_pcBitstream->read( uiLength, uiBits ); |
---|
2518 | |
---|
2519 | uiBits += (1 << uiLength); |
---|
2520 | riVal = ( uiBits & 1) ? -(Int)(uiBits>>1) : (Int)(uiBits>>1); |
---|
2521 | } |
---|
2522 | else |
---|
2523 | { |
---|
2524 | riVal = 0; |
---|
2525 | } |
---|
2526 | } |
---|
2527 | |
---|
2528 | Void TDecCavlc::xReadFlag (UInt& ruiCode) |
---|
2529 | { |
---|
2530 | m_pcBitstream->read( 1, ruiCode ); |
---|
2531 | } |
---|
2532 | |
---|
2533 | #if QC_MVHEVC_B0046 |
---|
2534 | /** Parse VPS alignment one bits. |
---|
2535 | * \returns Void |
---|
2536 | */ |
---|
2537 | Void TDecCavlc::xReadVPSAlignOne( ) |
---|
2538 | { |
---|
2539 | UInt uiNumberOfBits = m_pcBitstream->getNumBitsUntilByteAligned(); |
---|
2540 | |
---|
2541 | if(uiNumberOfBits) |
---|
2542 | { |
---|
2543 | UInt uiBits; |
---|
2544 | UInt uiSymbol; |
---|
2545 | |
---|
2546 | for(uiBits = 0; uiBits < uiNumberOfBits; uiBits++) |
---|
2547 | { |
---|
2548 | xReadFlag( uiSymbol ); |
---|
2549 | |
---|
2550 | if(!uiSymbol) |
---|
2551 | { |
---|
2552 | printf("\nWarning! vps_extension_byte_alignment_reserved_one_bit include a non-zero value.\n"); |
---|
2553 | } |
---|
2554 | } |
---|
2555 | } |
---|
2556 | } |
---|
2557 | #endif |
---|
2558 | /** Parse PCM alignment zero bits. |
---|
2559 | * \returns Void |
---|
2560 | */ |
---|
2561 | Void TDecCavlc::xReadPCMAlignZero( ) |
---|
2562 | { |
---|
2563 | UInt uiNumberOfBits = m_pcBitstream->getNumBitsUntilByteAligned(); |
---|
2564 | |
---|
2565 | if(uiNumberOfBits) |
---|
2566 | { |
---|
2567 | UInt uiBits; |
---|
2568 | UInt uiSymbol; |
---|
2569 | |
---|
2570 | for(uiBits = 0; uiBits < uiNumberOfBits; uiBits++) |
---|
2571 | { |
---|
2572 | xReadFlag( uiSymbol ); |
---|
2573 | |
---|
2574 | if(uiSymbol) |
---|
2575 | { |
---|
2576 | printf("\nWarning! pcm_align_zero include a non-zero value.\n"); |
---|
2577 | } |
---|
2578 | } |
---|
2579 | } |
---|
2580 | } |
---|
2581 | |
---|
2582 | Void TDecCavlc::xReadUnaryMaxSymbol( UInt& ruiSymbol, UInt uiMaxSymbol ) |
---|
2583 | { |
---|
2584 | if (uiMaxSymbol == 0) |
---|
2585 | { |
---|
2586 | ruiSymbol = 0; |
---|
2587 | return; |
---|
2588 | } |
---|
2589 | |
---|
2590 | xReadFlag( ruiSymbol ); |
---|
2591 | |
---|
2592 | if (ruiSymbol == 0 || uiMaxSymbol == 1) |
---|
2593 | { |
---|
2594 | return; |
---|
2595 | } |
---|
2596 | |
---|
2597 | UInt uiSymbol = 0; |
---|
2598 | UInt uiCont; |
---|
2599 | |
---|
2600 | do |
---|
2601 | { |
---|
2602 | xReadFlag( uiCont ); |
---|
2603 | uiSymbol++; |
---|
2604 | } |
---|
2605 | while( uiCont && (uiSymbol < uiMaxSymbol-1) ); |
---|
2606 | |
---|
2607 | if( uiCont && (uiSymbol == uiMaxSymbol-1) ) |
---|
2608 | { |
---|
2609 | uiSymbol++; |
---|
2610 | } |
---|
2611 | |
---|
2612 | ruiSymbol = uiSymbol; |
---|
2613 | } |
---|
2614 | |
---|
2615 | Void TDecCavlc::xReadExGolombLevel( UInt& ruiSymbol ) |
---|
2616 | { |
---|
2617 | UInt uiSymbol ; |
---|
2618 | UInt uiCount = 0; |
---|
2619 | do |
---|
2620 | { |
---|
2621 | xReadFlag( uiSymbol ); |
---|
2622 | uiCount++; |
---|
2623 | } |
---|
2624 | while( uiSymbol && (uiCount != 13)); |
---|
2625 | |
---|
2626 | ruiSymbol = uiCount-1; |
---|
2627 | |
---|
2628 | if( uiSymbol ) |
---|
2629 | { |
---|
2630 | xReadEpExGolomb( uiSymbol, 0 ); |
---|
2631 | ruiSymbol += uiSymbol+1; |
---|
2632 | } |
---|
2633 | |
---|
2634 | return; |
---|
2635 | } |
---|
2636 | |
---|
2637 | Void TDecCavlc::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount ) |
---|
2638 | { |
---|
2639 | UInt uiSymbol = 0; |
---|
2640 | UInt uiBit = 1; |
---|
2641 | |
---|
2642 | |
---|
2643 | while( uiBit ) |
---|
2644 | { |
---|
2645 | xReadFlag( uiBit ); |
---|
2646 | uiSymbol += uiBit << uiCount++; |
---|
2647 | } |
---|
2648 | |
---|
2649 | uiCount--; |
---|
2650 | while( uiCount-- ) |
---|
2651 | { |
---|
2652 | xReadFlag( uiBit ); |
---|
2653 | uiSymbol += uiBit << uiCount; |
---|
2654 | } |
---|
2655 | |
---|
2656 | ruiSymbol = uiSymbol; |
---|
2657 | |
---|
2658 | return; |
---|
2659 | } |
---|
2660 | |
---|
2661 | UInt TDecCavlc::xGetBit() |
---|
2662 | { |
---|
2663 | UInt ruiCode; |
---|
2664 | m_pcBitstream->read( 1, ruiCode ); |
---|
2665 | return ruiCode; |
---|
2666 | } |
---|
2667 | |
---|
2668 | |
---|
2669 | /** parse explicit wp tables |
---|
2670 | * \param TComSlice* pcSlice |
---|
2671 | * \returns Void |
---|
2672 | */ |
---|
2673 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) |
---|
2674 | { |
---|
2675 | wpScalingParam *wp; |
---|
2676 | Bool bChroma = true; // color always present in HEVC ? |
---|
2677 | TComPPS* pps = pcSlice->getPPS(); |
---|
2678 | SliceType eSliceType = pcSlice->getSliceType(); |
---|
2679 | Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
2680 | UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; |
---|
2681 | UInt uiMode = 0; |
---|
2682 | |
---|
2683 | if ( (eSliceType==P_SLICE && pps->getUseWP()) || (eSliceType==B_SLICE && pps->getWPBiPredIdc()==1 && pcSlice->getRefPicListCombinationFlag()==0) ) |
---|
2684 | uiMode = 1; // explicit |
---|
2685 | else if ( eSliceType==B_SLICE && pps->getWPBiPredIdc()==2 ) |
---|
2686 | uiMode = 2; // implicit |
---|
2687 | else if (eSliceType==B_SLICE && pps->getWPBiPredIdc()==1 && pcSlice->getRefPicListCombinationFlag()) |
---|
2688 | uiMode = 3; // combined explicit |
---|
2689 | |
---|
2690 | if ( uiMode == 1 ) // explicit |
---|
2691 | { |
---|
2692 | printf("\nTDecCavlc::xParsePredWeightTable(poc=%d) explicit...\n", pcSlice->getPOC()); |
---|
2693 | Int iDeltaDenom; |
---|
2694 | // decode delta_luma_log2_weight_denom : |
---|
2695 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
2696 | if( bChroma ) |
---|
2697 | { |
---|
2698 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
2699 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
2700 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
2701 | } |
---|
2702 | |
---|
2703 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
2704 | { |
---|
2705 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
2706 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2707 | { |
---|
2708 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2709 | |
---|
2710 | wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
2711 | wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2712 | wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2713 | |
---|
2714 | UInt uiCode; |
---|
2715 | READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag |
---|
2716 | wp[0].bPresentFlag = ( uiCode == 1 ); |
---|
2717 | if ( wp[0].bPresentFlag ) |
---|
2718 | { |
---|
2719 | Int iDeltaWeight; |
---|
2720 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] |
---|
2721 | wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); |
---|
2722 | READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] |
---|
2723 | } |
---|
2724 | else |
---|
2725 | { |
---|
2726 | wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); |
---|
2727 | wp[0].iOffset = 0; |
---|
2728 | } |
---|
2729 | if ( bChroma ) |
---|
2730 | { |
---|
2731 | READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag |
---|
2732 | wp[1].bPresentFlag = ( uiCode == 1 ); |
---|
2733 | wp[2].bPresentFlag = ( uiCode == 1 ); |
---|
2734 | if ( wp[1].bPresentFlag ) |
---|
2735 | { |
---|
2736 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2737 | { |
---|
2738 | Int iDeltaWeight; |
---|
2739 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] |
---|
2740 | wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); |
---|
2741 | |
---|
2742 | Int iDeltaChroma; |
---|
2743 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] |
---|
2744 | wp[j].iOffset = iDeltaChroma - ( ( (g_uiIBDI_MAX>>1)*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) + (g_uiIBDI_MAX>>1); |
---|
2745 | } |
---|
2746 | } |
---|
2747 | else |
---|
2748 | { |
---|
2749 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2750 | { |
---|
2751 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
2752 | wp[j].iOffset = 0; |
---|
2753 | } |
---|
2754 | } |
---|
2755 | } |
---|
2756 | } |
---|
2757 | |
---|
2758 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
2759 | { |
---|
2760 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2761 | |
---|
2762 | wp[0].bPresentFlag = false; |
---|
2763 | wp[1].bPresentFlag = false; |
---|
2764 | wp[2].bPresentFlag = false; |
---|
2765 | } |
---|
2766 | } |
---|
2767 | } |
---|
2768 | else if ( uiMode == 2 ) // implicit |
---|
2769 | { |
---|
2770 | printf("\nTDecCavlc::xParsePredWeightTable(poc=%d) implicit...\n", pcSlice->getPOC()); |
---|
2771 | } |
---|
2772 | else if ( uiMode == 3 ) // combined explicit |
---|
2773 | { |
---|
2774 | printf("\nTDecCavlc::xParsePredWeightTable(poc=%d) combined explicit...\n", pcSlice->getPOC()); |
---|
2775 | Int iDeltaDenom; |
---|
2776 | // decode delta_luma_log2_weight_denom : |
---|
2777 | READ_UVLC ( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
2778 | if( bChroma ) |
---|
2779 | { |
---|
2780 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // ue(v): delta_chroma_log2_weight_denom |
---|
2781 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
2782 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
2783 | } |
---|
2784 | |
---|
2785 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(REF_PIC_LIST_C) ; iRefIdx++ ) |
---|
2786 | { |
---|
2787 | pcSlice->getWpScalingLC(iRefIdx, wp); |
---|
2788 | |
---|
2789 | wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
2790 | wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2791 | wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2792 | |
---|
2793 | UInt uiCode; |
---|
2794 | READ_FLAG( uiCode, "luma_weight_lc_flag" ); // u(1): luma_weight_lc_flag |
---|
2795 | wp[0].bPresentFlag = ( uiCode == 1 ); |
---|
2796 | if ( wp[0].bPresentFlag ) |
---|
2797 | { |
---|
2798 | Int iDeltaWeight; |
---|
2799 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lc" ); // se(v): delta_luma_weight_lc |
---|
2800 | wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); |
---|
2801 | READ_SVLC( wp[0].iOffset, "luma_offset_lc" ); // se(v): luma_offset_lc |
---|
2802 | } |
---|
2803 | else |
---|
2804 | { |
---|
2805 | wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); |
---|
2806 | wp[0].iOffset = 0; |
---|
2807 | } |
---|
2808 | if ( bChroma ) |
---|
2809 | { |
---|
2810 | READ_FLAG( uiCode, "chroma_weight_lc_flag" ); // u(1): chroma_weight_lc_flag |
---|
2811 | wp[1].bPresentFlag = ( uiCode == 1 ); |
---|
2812 | wp[2].bPresentFlag = ( uiCode == 1 ); |
---|
2813 | if ( wp[1].bPresentFlag ) |
---|
2814 | { |
---|
2815 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2816 | { |
---|
2817 | Int iDeltaWeight; |
---|
2818 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lc" ); // se(v): delta_chroma_weight_lc |
---|
2819 | wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); |
---|
2820 | |
---|
2821 | Int iDeltaChroma; |
---|
2822 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lc" ); // se(v): delta_chroma_offset_lc |
---|
2823 | wp[j].iOffset = iDeltaChroma - ( ( (g_uiIBDI_MAX>>1)*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) + (g_uiIBDI_MAX>>1); |
---|
2824 | } |
---|
2825 | } |
---|
2826 | else |
---|
2827 | { |
---|
2828 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2829 | { |
---|
2830 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
2831 | wp[j].iOffset = 0; |
---|
2832 | } |
---|
2833 | } |
---|
2834 | } |
---|
2835 | } |
---|
2836 | |
---|
2837 | for ( Int iRefIdx=pcSlice->getNumRefIdx(REF_PIC_LIST_C) ; iRefIdx<2*MAX_NUM_REF ; iRefIdx++ ) |
---|
2838 | { |
---|
2839 | pcSlice->getWpScalingLC(iRefIdx, wp); |
---|
2840 | |
---|
2841 | wp[0].bPresentFlag = false; |
---|
2842 | wp[1].bPresentFlag = false; |
---|
2843 | wp[2].bPresentFlag = false; |
---|
2844 | } |
---|
2845 | } |
---|
2846 | else |
---|
2847 | { |
---|
2848 | printf("\n wrong weight pred table syntax \n "); |
---|
2849 | assert(0); |
---|
2850 | } |
---|
2851 | } |
---|
2852 | |
---|
2853 | /** decode quantization matrix |
---|
2854 | * \param scalingList quantization matrix information |
---|
2855 | */ |
---|
2856 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
2857 | { |
---|
2858 | UInt code, sizeId, listId; |
---|
2859 | Bool scalingListPredModeFlag; |
---|
2860 | READ_FLAG( code, "scaling_list_present_flag" ); |
---|
2861 | scalingList->setScalingListPresentFlag ( (code==1)?true:false ); |
---|
2862 | if(scalingList->getScalingListPresentFlag() == false) |
---|
2863 | { |
---|
2864 | //for each size |
---|
2865 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2866 | { |
---|
2867 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2868 | { |
---|
2869 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
2870 | scalingListPredModeFlag = (code) ? true : false; |
---|
2871 | if(!scalingListPredModeFlag) //Copy Mode |
---|
2872 | { |
---|
2873 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
2874 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code+1))); |
---|
2875 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2876 | { |
---|
2877 | scalingList->setScalingListDC(sizeId,listId,scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId))); |
---|
2878 | } |
---|
2879 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
2880 | |
---|
2881 | } |
---|
2882 | else //DPCM Mode |
---|
2883 | { |
---|
2884 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
2885 | } |
---|
2886 | } |
---|
2887 | } |
---|
2888 | } |
---|
2889 | |
---|
2890 | return; |
---|
2891 | } |
---|
2892 | /** decode DPCM |
---|
2893 | * \param scalingList quantization matrix information |
---|
2894 | * \param sizeId size index |
---|
2895 | * \param listId list index |
---|
2896 | */ |
---|
2897 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
2898 | { |
---|
2899 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
2900 | Int data; |
---|
2901 | Int scalingListDcCoefMinus8 = 0; |
---|
2902 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
2903 | UInt* scan = g_auiFrameScanXY [ (sizeId == 0)? 1 : 2 ]; |
---|
2904 | Bool stopNow = false; |
---|
2905 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
2906 | |
---|
2907 | scalingList->setUseDefaultScalingMatrixFlag(sizeId,listId,false); |
---|
2908 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2909 | { |
---|
2910 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
2911 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
2912 | if(scalingListDcCoefMinus8 == -8) |
---|
2913 | { |
---|
2914 | scalingList->processDefaultMarix(sizeId,listId); |
---|
2915 | } |
---|
2916 | } |
---|
2917 | |
---|
2918 | if( !scalingList->getUseDefaultScalingMatrixFlag(sizeId,listId)) |
---|
2919 | { |
---|
2920 | for(i = 0; i < coefNum && !stopNow ; i++) |
---|
2921 | { |
---|
2922 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
2923 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
2924 | if(sizeId < SCALING_LIST_16x16) |
---|
2925 | { |
---|
2926 | if( i == 0 && nextCoef == 0 ) |
---|
2927 | { |
---|
2928 | scalingList->processDefaultMarix(sizeId,listId); |
---|
2929 | stopNow = true; |
---|
2930 | } |
---|
2931 | } |
---|
2932 | if(!stopNow) |
---|
2933 | { |
---|
2934 | dst[scan[i]] = nextCoef; |
---|
2935 | } |
---|
2936 | } |
---|
2937 | } |
---|
2938 | } |
---|
2939 | |
---|
2940 | Void TDecCavlc::parseDFFlag(UInt& ruiVal, const Char *pSymbolName) |
---|
2941 | { |
---|
2942 | READ_FLAG(ruiVal, pSymbolName); |
---|
2943 | } |
---|
2944 | Void TDecCavlc::parseDFSvlc(Int& riVal, const Char *pSymbolName) |
---|
2945 | { |
---|
2946 | READ_SVLC(riVal, pSymbolName); |
---|
2947 | } |
---|
2948 | |
---|
2949 | Bool TDecCavlc::xMoreRbspData() |
---|
2950 | { |
---|
2951 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
2952 | |
---|
2953 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
2954 | if (bitsLeft > 8) |
---|
2955 | { |
---|
2956 | return true; |
---|
2957 | } |
---|
2958 | |
---|
2959 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
2960 | Int cnt = bitsLeft; |
---|
2961 | |
---|
2962 | // remove trailing bits equal to zero |
---|
2963 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
2964 | { |
---|
2965 | lastByte >>= 1; |
---|
2966 | cnt--; |
---|
2967 | } |
---|
2968 | // remove bit equal to one |
---|
2969 | cnt--; |
---|
2970 | |
---|
2971 | // we should not have a negative number of bits |
---|
2972 | assert (cnt>=0); |
---|
2973 | |
---|
2974 | // we have more data, if cnt is not zero |
---|
2975 | return (cnt>0); |
---|
2976 | } |
---|
2977 | |
---|
2978 | //! \} |
---|