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