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