Changeset 125 in SHVCSoftware for trunk/source/Lib/TLibDecoder


Ignore:
Timestamp:
16 Apr 2013, 06:39:31 (12 years ago)
Author:
seregin
Message:

copy from HM-10.0-dev-SHM

Location:
trunk/source/Lib/TLibDecoder
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibDecoder/AnnexBread.cpp

    r2 r125  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    3131 * THE POSSIBILITY OF SUCH DAMAGE.
    3232 */
     33
     34/**
     35 \file     AnnexBread.cpp
     36 \brief    reading functions for Annex B byte streams
     37 */
     38
    3339
    3440#include <stdint.h>
     
    147153 *         otherwise true.
    148154 */
    149 bool
     155Bool
    150156byteStreamNALUnit(
    151157  InputByteStream& bs,
     
    153159  AnnexBStats& stats)
    154160{
    155   bool eof = false;
     161  Bool eof = false;
    156162  try
    157163  {
     
    162168    eof = true;
    163169  }
    164   stats.m_numBytesInNALUnit = unsigned(nalUnit.size());
     170  stats.m_numBytesInNALUnit = UInt(nalUnit.size());
    165171  return eof;
    166172}
  • trunk/source/Lib/TLibDecoder/AnnexBread.h

    r2 r125  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    3232 */
    3333
     34/**
     35 \file     AnnexBread.h
     36 \brief    reading functions for Annex B byte streams
     37 */
     38
    3439#pragma once
    3540
     
    3742#include <istream>
    3843#include <vector>
     44
     45#include "TLibCommon/TypeDef.h"
    3946
    4047//! \ingroup TLibDecoder
     
    7582   * n bytes.
    7683   */
    77   bool eofBeforeNBytes(unsigned n)
     84  Bool eofBeforeNBytes(UInt n)
    7885  {
    7986    assert(n <= 4);
     
    8491    try
    8592    {
    86       for (unsigned i = 0; i < n; i++)
     93      for (UInt i = 0; i < n; i++)
    8794      {
    8895        m_FutureBytes = (m_FutureBytes << 8) | m_Input.get();
     
    109116   *
    110117   */
    111   uint32_t peekBytes(unsigned n)
     118  uint32_t peekBytes(UInt n)
    112119  {
    113120    eofBeforeNBytes(n);
     
    139146   * the return value.
    140147   */
    141   uint32_t readBytes(unsigned n)
     148  uint32_t readBytes(UInt n)
    142149  {
    143150    uint32_t val = 0;
    144     for (unsigned i = 0; i < n; i++)
     151    for (UInt i = 0; i < n; i++)
    145152      val = (val << 8) | readByte();
    146153    return val;
     
    148155
    149156private:
    150   unsigned m_NumFutureBytes; /* number of valid bytes in m_FutureBytes */
     157  UInt m_NumFutureBytes; /* number of valid bytes in m_FutureBytes */
    151158  uint32_t m_FutureBytes; /* bytes that have been peeked */
    152159  std::istream& m_Input; /* Input stream to read from */
     
    158165struct AnnexBStats
    159166{
    160   unsigned m_numLeadingZero8BitsBytes;
    161   unsigned m_numZeroByteBytes;
    162   unsigned m_numStartCodePrefixBytes;
    163   unsigned m_numBytesInNALUnit;
    164   unsigned m_numTrailingZero8BitsBytes;
     167  UInt m_numLeadingZero8BitsBytes;
     168  UInt m_numZeroByteBytes;
     169  UInt m_numStartCodePrefixBytes;
     170  UInt m_numBytesInNALUnit;
     171  UInt m_numTrailingZero8BitsBytes;
    165172
    166173  AnnexBStats& operator+=(const AnnexBStats& rhs)
     
    175182};
    176183
    177 bool byteStreamNALUnit(InputByteStream& bs, std::vector<uint8_t>& nalUnit, AnnexBStats& stats);
     184Bool byteStreamNALUnit(InputByteStream& bs, std::vector<uint8_t>& nalUnit, AnnexBStats& stats);
    178185
    179186//! \}
  • trunk/source/Lib/TLibDecoder/NALread.cpp

    r2 r125  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    3232 */
    3333
     34/**
     35 \file     NALread.cpp
     36 \brief    reading funtionality for NAL units
     37 */
     38
     39
    3440#include <vector>
    3541#include <algorithm>
     
    4450//! \ingroup TLibDecoder
    4551//! \{
    46 static void convertPayloadToRBSP(vector<uint8_t>& nalUnitBuf, TComInputBitstream *pcBitstream)
     52static void convertPayloadToRBSP(vector<uint8_t>& nalUnitBuf, Bool isVclNalUnit)
    4753{
    48   unsigned zeroCount = 0;
     54  UInt zeroCount = 0;
    4955  vector<uint8_t>::iterator it_read, it_write;
    5056
    5157  for (it_read = it_write = nalUnitBuf.begin(); it_read != nalUnitBuf.end(); it_read++, it_write++)
    5258  {
     59    assert(zeroCount < 2 || *it_read >= 0x03);
    5360    if (zeroCount == 2 && *it_read == 0x03)
    5461    {
    5562      it_read++;
    5663      zeroCount = 0;
     64      if (it_read == nalUnitBuf.end())
     65      {
     66        break;
     67      }
    5768    }
    5869    zeroCount = (*it_read == 0x00) ? zeroCount+1 : 0;
    5970    *it_write = *it_read;
     71  }
     72  assert(zeroCount == 0);
     73 
     74  if (isVclNalUnit)
     75  {
     76    // Remove cabac_zero_word from payload if present
     77    Int n = 0;
     78   
     79    while (it_write[-1] == 0x00)
     80    {
     81      it_write--;
     82      n++;
     83    }
     84   
     85    if (n > 0)
     86    {
     87      printf("\nDetected %d instances of cabac_zero_word", n/2);     
     88    }
    6089  }
    6190
     
    6392}
    6493
    65 #if NAL_UNIT_HEADER
    6694Void readNalUnitHeader(InputNALUnit& nalu)
    6795{
    6896  TComInputBitstream& bs = *nalu.m_Bitstream;
    6997
    70   bool forbidden_zero_bit = bs.read(1);           // forbidden_zero_bit
     98  Bool forbidden_zero_bit = bs.read(1);           // forbidden_zero_bit
    7199  assert(forbidden_zero_bit == 0);
    72100  nalu.m_nalUnitType = (NalUnitType) bs.read(6);  // nal_unit_type
     101  nalu.m_reservedZero6Bits = bs.read(6);       // nuh_reserved_zero_6bits
    73102#if SVC_EXTENSION
    74   nalu.m_reservedZero6Bits = bs.read(6);       // nuh_reserved_zero_6bits
    75103  nalu.m_layerId = nalu.m_reservedZero6Bits;
    76104#else
    77 #if TARGET_DECLAYERID_SET
    78   nalu.m_reservedZero6Bits = bs.read(6);       // nuh_reserved_zero_6bits
    79105  assert(nalu.m_reservedZero6Bits == 0);
    80 #else
    81   unsigned reserved_one_6bits = bs.read(6);       // nuh_reserved_zero_6bits
    82   assert(reserved_one_6bits == 0);
    83 #endif
    84106#endif
    85107  nalu.m_temporalId = bs.read(3) - 1;             // nuh_temporal_id_plus1
     
    87109  if ( nalu.m_temporalId )
    88110  {
    89 #if NAL_UNIT_TYPES_J1003_D7
    90111    assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA
    91112         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLANT
     
    98119         && nalu.m_nalUnitType != NAL_UNIT_EOS
    99120         && nalu.m_nalUnitType != NAL_UNIT_EOB );
    100 #else
    101     assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRA
    102          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRANT
    103          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA
    104          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLANT
    105          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR
    106          && nalu.m_nalUnitType != NAL_UNIT_VPS
    107          && nalu.m_nalUnitType != NAL_UNIT_SPS );
    108 #endif
    109121  }
    110122  else
    111123  {
    112 #if NAL_UNIT_TYPES_J1003_D7
    113124    assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TLA
    114125         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TSA_N
    115126         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_R
    116127         && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_STSA_N );
    117 #else
    118     assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_TLA );
    119 #endif
    120128  }
    121129}
    122 #endif
    123130/**
    124131 * create a NALunit structure with given header values and storage for
     
    129136  /* perform anti-emulation prevention */
    130137  TComInputBitstream *pcBitstream = new TComInputBitstream(NULL);
    131   convertPayloadToRBSP(nalUnitBuf, pcBitstream);
    132 
     138  convertPayloadToRBSP(nalUnitBuf, (nalUnitBuf[0] & 64) == 0);
     139 
    133140  nalu.m_Bitstream = new TComInputBitstream(&nalUnitBuf);
    134141  delete pcBitstream;
    135 #if NAL_UNIT_HEADER
    136142  readNalUnitHeader(nalu);
    137 #else
    138   TComInputBitstream& bs = *nalu.m_Bitstream;
    139 
    140   bool forbidden_zero_bit = bs.read(1);
    141   assert(forbidden_zero_bit == 0);
    142 #if !REMOVE_NAL_REF_FLAG
    143   nalu.m_nalRefFlag  = (bs.read(1) != 0 );
    144 #endif
    145   nalu.m_nalUnitType = (NalUnitType) bs.read(6);
    146 #if REMOVE_NAL_REF_FLAG
    147   unsigned reserved_one_6bits = bs.read(6);
    148   assert(reserved_one_6bits == 0);
    149 #endif
    150 #if TEMPORAL_ID_PLUS1
    151   nalu.m_temporalId = bs.read(3) - 1;
    152 #if !REMOVE_NAL_REF_FLAG
    153   unsigned reserved_one_5bits = bs.read(5);
    154   assert(reserved_one_5bits == 0);
    155 #endif
    156 #else
    157   nalu.m_temporalId = bs.read(3);
    158   unsigned reserved_one_5bits = bs.read(5);
    159 #if SVC_EXTENSION
    160   assert(reserved_one_5bits >= 1);
    161   nalu.m_layerId = reserved_one_5bits - 1;
    162 #else
    163   assert(reserved_one_5bits == 1);
    164 #endif
    165 #endif
    166 
    167   if ( nalu.m_temporalId )
    168   {
    169 #if NAL_UNIT_TYPES_J1003_D7
    170     assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA
    171          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLANT
    172          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA_N_LP
    173          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR
    174          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR_N_LP
    175          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRA );
    176 #else
    177     assert( nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRA
    178          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_CRANT
    179          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLA
    180          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_BLANT
    181          && nalu.m_nalUnitType != NAL_UNIT_CODED_SLICE_IDR );
    182 #endif
    183   }
    184 #endif
    185143}
    186144//! \}
  • trunk/source/Lib/TLibDecoder/NALread.h

    r2 r125  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    3232 */
    3333
     34/**
     35 \file     NALread.h
     36 \brief    reading funtionality for NAL units
     37 */
     38
    3439#pragma once
    3540
  • trunk/source/Lib/TLibDecoder/SEIread.cpp

    r2 r125  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    3232 */
    3333
     34/**
     35 \file     SEIread.cpp
     36 \brief    reading functionality for SEI messages
     37 */
     38
    3439#include "TLibCommon/CommonDef.h"
    3540#include "TLibCommon/TComBitStream.h"
     
    5560    fprintf( g_hTrace, "=========== Decoded picture hash SEI message ===========\n");
    5661    break;
    57 #if ACTIVE_PARAMETER_SETS_SEI_MESSAGE
    58   case SEI::ACTIVE_PARAMETER_SETS:
    59     fprintf( g_hTrace, "=========== Active Parameter Sets SEI message ===========\n");
    60     break;
    61 #endif
    6262  case SEI::USER_DATA_UNREGISTERED:
    6363    fprintf( g_hTrace, "=========== User Data Unregistered SEI message ===========\n");
     64    break;
     65  case SEI::ACTIVE_PARAMETER_SETS:
     66    fprintf( g_hTrace, "=========== Active Parameter sets SEI message ===========\n");
     67    break;
     68  case SEI::BUFFERING_PERIOD:
     69    fprintf( g_hTrace, "=========== Buffering period SEI message ===========\n");
     70    break;
     71  case SEI::PICTURE_TIMING:
     72    fprintf( g_hTrace, "=========== Picture timing SEI message ===========\n");
     73    break;
     74  case SEI::RECOVERY_POINT:
     75    fprintf( g_hTrace, "=========== Recovery point SEI message ===========\n");
     76    break;
     77  case SEI::FRAME_PACKING:
     78    fprintf( g_hTrace, "=========== Frame Packing Arrangement SEI message ===========\n");
     79    break;
     80  case SEI::DISPLAY_ORIENTATION:
     81    fprintf( g_hTrace, "=========== Display Orientation SEI message ===========\n");
     82    break;
     83  case SEI::TEMPORAL_LEVEL0_INDEX:
     84    fprintf( g_hTrace, "=========== Temporal Level Zero Index SEI message ===========\n");
     85    break;
     86  case SEI::REGION_REFRESH_INFO:
     87    fprintf( g_hTrace, "=========== Gradual Decoding Refresh Information SEI message ===========\n");
     88    break;
     89  case SEI::DECODING_UNIT_INFO:
     90    fprintf( g_hTrace, "=========== Decoding Unit Information SEI message ===========\n");
    6491    break;
    6592  default:
     
    73100 * unmarshal a single SEI message from bitstream bs
    74101 */
    75 void SEIReader::parseSEImessage(TComInputBitstream* bs, SEImessages& seis)
     102void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps)
    76103{
    77104  setBitstream(bs);
     
    80107  do
    81108  {
    82     xReadSEImessage(seis);
     109    xReadSEImessage(seis, nalUnitType, sps);
    83110    /* SEI messages are an integer number of bytes, something has failed
    84111    * in the parsing if bitstream not byte-aligned */
    85112    assert(!m_pcBitstream->getNumBitsUntilByteAligned());
    86   } while (0x80 != m_pcBitstream->peekBits(8));
    87   assert(m_pcBitstream->getNumBitsLeft() == 8); /* rsbp_trailing_bits */
    88 }
    89 
    90 Void SEIReader::xReadSEImessage(SEImessages& seis)
     113  } while (m_pcBitstream->getNumBitsLeft() > 8);
     114
     115  UInt rbspTrailingBits;
     116  READ_CODE(8, rbspTrailingBits, "rbsp_trailing_bits");
     117  assert(rbspTrailingBits == 0x80);
     118}
     119
     120Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps)
    91121{
    92122#if ENC_DEC_TRACE
     
    113143#endif
    114144
    115   switch (payloadType)
    116   {
    117   case SEI::USER_DATA_UNREGISTERED:
    118     seis.user_data_unregistered = new SEIuserDataUnregistered;
    119     xParseSEIuserDataUnregistered(*seis.user_data_unregistered, payloadSize);
    120     break;
    121 #if ACTIVE_PARAMETER_SETS_SEI_MESSAGE   
    122   case SEI::ACTIVE_PARAMETER_SETS:
    123     seis.active_parameter_sets = new SEIActiveParameterSets;
    124     xParseSEIActiveParameterSets(*seis.active_parameter_sets, payloadSize);
    125     break;
    126 #endif
    127   case SEI::DECODED_PICTURE_HASH:
    128     seis.picture_digest = new SEIDecodedPictureHash;
    129     xParseSEIDecodedPictureHash(*seis.picture_digest, payloadSize);
    130     break;
    131 #if BUFFERING_PERIOD_AND_TIMING_SEI
    132   case SEI::BUFFERING_PERIOD:
    133     seis.buffering_period = new SEIBufferingPeriod;
    134     seis.buffering_period->m_sps = seis.m_pSPS;
    135     xParseSEIBufferingPeriod(*seis.buffering_period, payloadSize);
    136     break;
    137   case SEI::PICTURE_TIMING:
    138     seis.picture_timing = new SEIPictureTiming;
    139     seis.picture_timing->m_sps = seis.m_pSPS;
    140     xParseSEIPictureTiming(*seis.picture_timing, payloadSize);
    141     break;
    142 #endif
    143 #if RECOVERY_POINT_SEI
    144   case SEI::RECOVERY_POINT:
    145     seis.recovery_point = new SEIRecoveryPoint;
    146     xParseSEIRecoveryPoint(*seis.recovery_point, payloadSize);
    147     break;
    148 #endif
    149   default:
    150     assert(!"Unhandled SEI message");
    151   }
     145  /* extract the payload for this single SEI message.
     146   * This allows greater safety in erroneous parsing of an SEI message
     147   * from affecting subsequent messages.
     148   * After parsing the payload, bs needs to be restored as the primary
     149   * bitstream.
     150   */
     151  TComInputBitstream *bs = getBitstream();
     152  setBitstream(bs->extractSubstream(payloadSize * 8));
     153
     154  SEI *sei = NULL;
     155
     156  if(nalUnitType == NAL_UNIT_SEI)
     157  {
     158    switch (payloadType)
     159    {
     160    case SEI::USER_DATA_UNREGISTERED:
     161      sei = new SEIuserDataUnregistered;
     162      xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize);
     163      break;
     164    case SEI::ACTIVE_PARAMETER_SETS:
     165      sei = new SEIActiveParameterSets;
     166      xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize);
     167      break;
     168    case SEI::DECODING_UNIT_INFO:
     169      if (!sps)
     170      {
     171        printf ("Warning: Found Decoding unit SEI message, but no active SPS is available. Ignoring.");
     172      }
     173      else
     174      {
     175        sei = new SEIDecodingUnitInfo;
     176        xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps);
     177      }
     178      break;
     179    case SEI::BUFFERING_PERIOD:
     180      if (!sps)
     181      {
     182        printf ("Warning: Found Buffering period SEI message, but no active SPS is available. Ignoring.");
     183      }
     184      else
     185      {
     186        sei = new SEIBufferingPeriod;
     187        xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps);
     188      }
     189      break;
     190    case SEI::PICTURE_TIMING:
     191      if (!sps)
     192      {
     193        printf ("Warning: Found Picture timing SEI message, but no active SPS is available. Ignoring.");
     194      }
     195      else
     196      {
     197        sei = new SEIPictureTiming;
     198        xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps);
     199      }
     200      break;
     201    case SEI::RECOVERY_POINT:
     202      sei = new SEIRecoveryPoint;
     203      xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize);
     204      break;
     205    case SEI::FRAME_PACKING:
     206      sei = new SEIFramePacking;
     207      xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize);
     208      break;
     209    case SEI::DISPLAY_ORIENTATION:
     210      sei = new SEIDisplayOrientation;
     211      xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize);
     212      break;
     213    case SEI::TEMPORAL_LEVEL0_INDEX:
     214      sei = new SEITemporalLevel0Index;
     215      xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize);
     216      break;
     217    case SEI::REGION_REFRESH_INFO:
     218      sei = new SEIGradualDecodingRefreshInfo;
     219      xParseSEIGradualDecodingRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize);
     220      break;
     221    default:
     222      for (UInt i = 0; i < payloadSize; i++)
     223      {
     224        UInt seiByte;
     225        READ_CODE (8, seiByte, "unknown prefix SEI payload byte");
     226      }
     227      printf ("Unknown prefix SEI message (payloadType = %d) was found!\n", payloadType);
     228    }
     229  }
     230  else
     231  {
     232    switch (payloadType)
     233    {
     234#if L0363_SEI_ALLOW_SUFFIX
     235      case SEI::USER_DATA_UNREGISTERED:
     236        sei = new SEIuserDataUnregistered;
     237        xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize);
     238        break;
     239#endif
     240      case SEI::DECODED_PICTURE_HASH:
     241        sei = new SEIDecodedPictureHash;
     242        xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize);
     243        break;
     244      default:
     245        for (UInt i = 0; i < payloadSize; i++)
     246        {
     247          UInt seiByte;
     248          READ_CODE (8, seiByte, "unknown suffix SEI payload byte");
     249        }
     250        printf ("Unknown suffix SEI message (payloadType = %d) was found!\n", payloadType);
     251    }
     252  }
     253  if (sei != NULL)
     254  {
     255    seis.push_back(sei);
     256  }
     257
     258  /* By definition the underlying bitstream terminates in a byte-aligned manner.
     259   * 1. Extract all bar the last MIN(bitsremaining,nine) bits as reserved_payload_extension_data
     260   * 2. Examine the final 8 bits to determine the payload_bit_equal_to_one marker
     261   * 3. Extract the remainingreserved_payload_extension_data bits.
     262   *
     263   * If there are fewer than 9 bits available, extract them.
     264   */
     265  Int payloadBitsRemaining = getBitstream()->getNumBitsLeft();
     266  if (payloadBitsRemaining) /* more_data_in_payload() */
     267  {
     268    for (; payloadBitsRemaining > 9; payloadBitsRemaining--)
     269    {
     270      UInt reservedPayloadExtensionData;
     271      READ_CODE (1, reservedPayloadExtensionData, "reserved_payload_extension_data");
     272    }
     273
     274    /* 2 */
     275    Int finalBits = getBitstream()->peekBits(payloadBitsRemaining);
     276    Int finalPayloadBits = 0;
     277    for (Int mask = 0xff; finalBits & (mask >> finalPayloadBits); finalPayloadBits++)
     278    {
     279      continue;
     280    }
     281
     282    /* 3 */
     283    for (; payloadBitsRemaining > 9 - finalPayloadBits; payloadBitsRemaining--)
     284    {
     285      UInt reservedPayloadExtensionData;
     286      READ_CODE (1, reservedPayloadExtensionData, "reserved_payload_extension_data");
     287    }
     288
     289    UInt dummy;
     290    READ_CODE (1, dummy, "payload_bit_equal_to_one");
     291    READ_CODE (payloadBitsRemaining-1, dummy, "payload_bit_equal_to_zero");
     292  }
     293
     294  /* restore primary bitstream for sei_message */
     295  delete getBitstream();
     296  setBitstream(bs);
    152297}
    153298
     
    186331 * of payloadSize bytes into sei.
    187332 */
    188 Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt payloadSize)
     333Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt /*payloadSize*/)
    189334{
    190335  UInt val;
    191336  READ_CODE (8, val, "hash_type");
    192337  sei.method = static_cast<SEIDecodedPictureHash::Method>(val);
    193   for(int yuvIdx = 0; yuvIdx < 3; yuvIdx++)
     338  for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++)
    194339  {
    195340    if(SEIDecodedPictureHash::MD5 == sei.method)
    196341    {
    197       for (unsigned i = 0; i < 16; i++)
     342      for (UInt i = 0; i < 16; i++)
    198343      {
    199344        READ_CODE(8, val, "picture_md5");
     
    217362  }
    218363}
    219 #if ACTIVE_PARAMETER_SETS_SEI_MESSAGE
    220 Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, unsigned payloadSize)
     364Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt /*payloadSize*/)
    221365{
    222366  UInt val;
    223   READ_CODE(4, val, "active_vps_id");
    224   sei.activeVPSId = val;
    225 
    226   READ_CODE(1, val, "active_sps_id_present_flag");
    227   sei.activeSPSIdPresentFlag = val;
    228 
    229   if(sei.activeSPSIdPresentFlag)
    230   {
    231     READ_UVLC(val, "active_seq_param_set_id");
    232     sei.activeSeqParamSetId = val;
    233   }
    234 
    235   READ_CODE(1, val, "active_param_set_sei_extension_flag");
    236   sei.activeParamSetSEIExtensionFlag = val;
    237  
     367  READ_CODE(4, val, "active_vps_id");      sei.activeVPSId = val;
     368#if L0047_APS_FLAGS
     369  READ_FLAG( val, "full_random_access_flag");  sei.m_fullRandomAccessFlag = val ? true : false;
     370  READ_FLAG( val, "no_param_set_update_flag"); sei.m_noParamSetUpdateFlag = val ? true : false;
     371#endif
     372  READ_UVLC(   val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val;
     373
     374  sei.activeSeqParamSetId.resize(sei.numSpsIdsMinus1 + 1);
     375  for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++)
     376  {
     377    READ_UVLC(val, "active_seq_param_set_id");  sei.activeSeqParamSetId[i] = val;
     378  }
     379
    238380  UInt uibits = m_pcBitstream->getNumBitsUntilByteAligned();
    239381 
     
    243385  }
    244386}
    245 #endif
    246 
    247 #if BUFFERING_PERIOD_AND_TIMING_SEI
    248 Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt payloadSize)
     387
     388Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt /*payloadSize*/, TComSPS *sps)
     389{
     390  UInt val;
     391  READ_UVLC(val, "decoding_unit_idx");
     392  sei.m_decodingUnitIdx = val;
     393
     394  TComVUI *vui = sps->getVuiParameters();
     395  if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag())
     396  {
     397    READ_CODE( ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay");
     398    sei.m_duSptCpbRemovalDelay = val;
     399  }
     400  else
     401  {
     402    sei.m_duSptCpbRemovalDelay = 0;
     403  }
     404#if L0044_DU_DPB_OUTPUT_DELAY_HRD
     405  READ_FLAG( val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = val ? true : false;
     406  if(sei.m_dpbOutputDuDelayPresentFlag)
     407  {
     408    READ_CODE(vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay");
     409    sei.m_picSptDpbOutputDuDelay = val;
     410  }
     411#endif
     412  xParseByteAlign();
     413}
     414
     415Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt /*payloadSize*/, TComSPS *sps)
    249416{
    250417  Int i, nalOrVcl;
    251418  UInt code;
    252419
    253   TComVUI *pVUI = sei.m_sps->getVuiParameters();
    254 
    255   READ_UVLC( code, "seq_parameter_set_id" );                            sei.m_seqParameterSetId     = code;
    256   if( !pVUI->getSubPicCpbParamsPresentFlag() )
    257   {
    258     READ_FLAG( code, "alt_cpb_params_present_flag" );                   sei.m_altCpbParamsPresentFlag = code;
    259   }
    260 
     420  TComVUI *pVUI = sps->getVuiParameters();
     421  TComHRD *pHRD = pVUI->getHrdParameters();
     422
     423  READ_UVLC( code, "bp_seq_parameter_set_id" );                         sei.m_bpSeqParameterSetId     = code;
     424  if( !pHRD->getSubPicCpbParamsPresentFlag() )
     425  {
     426    READ_FLAG( code, "rap_cpb_params_present_flag" );                   sei.m_rapCpbParamsPresentFlag = code;
     427  }
     428#if L0328_SPLICING
     429  //read splicing flag and cpb_removal_delay_delta
     430  READ_FLAG( code, "concatenation_flag");
     431  sei.m_concatenationFlag = code;
     432  READ_CODE( ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" );
     433  sei.m_auCpbRemovalDelayDelta = code + 1;
     434#endif
     435#if L0044_CPB_DPB_DELAY_OFFSET
     436  if( sei.m_rapCpbParamsPresentFlag )
     437  {
     438    READ_CODE( pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" );      sei.m_cpbDelayOffset = code;
     439    READ_CODE( pHRD->getDpbOutputDelayLengthMinus1()  + 1, code, "dpb_delay_offset" );      sei.m_dpbDelayOffset = code;
     440  }
     441#endif
    261442  for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
    262443  {
    263     if( ( ( nalOrVcl == 0 ) && ( pVUI->getNalHrdParametersPresentFlag() ) ) ||
    264         ( ( nalOrVcl == 1 ) && ( pVUI->getVclHrdParametersPresentFlag() ) ) )
    265     {
    266       for( i = 0; i < ( pVUI->getCpbCntMinus1( 0 ) + 1 ); i ++ )
    267       {
    268         READ_CODE( ( pVUI->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay" );
     444    if( ( ( nalOrVcl == 0 ) && ( pHRD->getNalHrdParametersPresentFlag() ) ) ||
     445        ( ( nalOrVcl == 1 ) && ( pHRD->getVclHrdParametersPresentFlag() ) ) )
     446    {
     447      for( i = 0; i < ( pHRD->getCpbCntMinus1( 0 ) + 1 ); i ++ )
     448      {
     449        READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay" );
    269450        sei.m_initialCpbRemovalDelay[i][nalOrVcl] = code;
    270         READ_CODE( ( pVUI->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay_offset" );
     451        READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay_offset" );
    271452        sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl] = code;
    272         if( pVUI->getSubPicCpbParamsPresentFlag() || sei.m_altCpbParamsPresentFlag )
     453        if( pHRD->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag )
    273454        {
    274           READ_CODE( ( pVUI->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay" );
     455          READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay" );
    275456          sei.m_initialAltCpbRemovalDelay[i][nalOrVcl] = code;
    276           READ_CODE( ( pVUI->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay_offset" );
     457          READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay_offset" );
    277458          sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl] = code;
    278459        }
     
    282463  xParseByteAlign();
    283464}
    284 Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt payloadSize)
     465Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt /*payloadSize*/, TComSPS *sps)
    285466{
    286467  Int i;
    287468  UInt code;
    288469
    289   TComVUI *vui = sei.m_sps->getVuiParameters();
    290 
    291   if( !vui->getNalHrdParametersPresentFlag() && !vui->getVclHrdParametersPresentFlag() )
     470  TComVUI *vui = sps->getVuiParameters();
     471  TComHRD *hrd = vui->getHrdParameters();
     472
     473#if !L0045_CONDITION_SIGNALLING
     474  // This condition was probably OK before the pic_struct, progressive_source_idc, duplicate_flag were added
     475  if( !hrd->getNalHrdParametersPresentFlag() && !hrd->getVclHrdParametersPresentFlag() )
    292476  {
    293477    return;
    294478  }
    295 
    296   READ_CODE( ( vui->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay" );
    297   sei.m_auCpbRemovalDelay = code;
    298   READ_CODE( ( vui->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" );
    299   sei.m_picDpbOutputDelay = code;
    300 
    301   if( sei.m_sps->getVuiParameters()->getSubPicCpbParamsPresentFlag() )
    302   {
    303     READ_UVLC( code, "num_decoding_units_minus1");
    304     sei.m_numDecodingUnitsMinus1 = code;
    305     READ_FLAG( code, "du_common_cpb_removal_delay_flag" );
    306     sei.m_duCommonCpbRemovalDelayFlag = code;
    307     if( sei.m_duCommonCpbRemovalDelayFlag )
    308     {
    309       READ_CODE( ( vui->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_minus1" );
    310       sei.m_duCommonCpbRemovalDelayMinus1 = code;
    311     }
    312     else
    313     {
     479#endif
     480
     481  if( vui->getFrameFieldInfoPresentFlag() )
     482  {
     483    READ_CODE( 4, code, "pic_struct" );             sei.m_picStruct            = code;
     484#if L0046_RENAME_PROG_SRC_IDC
     485    READ_CODE( 2, code, "source_scan_type" );       sei.m_sourceScanType = code;
     486#else
     487    READ_CODE( 2, code, "progressive_source_idc" ); sei.m_progressiveSourceIdc = code;
     488#endif
     489    READ_FLAG(    code, "duplicate_flag" );         sei.m_duplicateFlag        = ( code == 1 ? true : false );
     490  }
     491
     492#if L0045_CONDITION_SIGNALLING
     493  if( hrd->getCpbDpbDelaysPresentFlag())
     494  {
     495#endif
     496    READ_CODE( ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" );
     497    sei.m_auCpbRemovalDelay = code + 1;
     498    READ_CODE( ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" );
     499    sei.m_picDpbOutputDelay = code;
     500
     501#if L0044_DU_DPB_OUTPUT_DELAY_HRD
     502    if(hrd->getSubPicCpbParamsPresentFlag())
     503    {
     504      READ_CODE(hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" );
     505      sei.m_picDpbOutputDuDelay = code;
     506    }
     507#endif
     508    if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() )
     509    {
     510      READ_UVLC( code, "num_decoding_units_minus1");
     511      sei.m_numDecodingUnitsMinus1 = code;
     512      READ_FLAG( code, "du_common_cpb_removal_delay_flag" );
     513      sei.m_duCommonCpbRemovalDelayFlag = code;
     514      if( sei.m_duCommonCpbRemovalDelayFlag )
     515      {
     516        READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_minus1" );
     517        sei.m_duCommonCpbRemovalDelayMinus1 = code;
     518      }
    314519      if( sei.m_numNalusInDuMinus1 != NULL )
    315520      {
     
    323528      sei.m_duCpbRemovalDelayMinus1  = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ];
    324529
    325       for( i = 0; i < ( sei.m_numDecodingUnitsMinus1 + 1 ); i ++ )
     530      for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ )
    326531      {
    327532        READ_UVLC( code, "num_nalus_in_du_minus1");
    328533        sei.m_numNalusInDuMinus1[ i ] = code;
    329         READ_CODE( ( vui->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1" );
    330         sei.m_duCpbRemovalDelayMinus1[ i ] = code;
    331       }
    332     }
    333   }
    334   xParseByteAlign();
    335 }
    336 #endif
    337 #if RECOVERY_POINT_SEI
    338 Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt payloadSize)
     534        if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) )
     535        {
     536          READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1" );
     537          sei.m_duCpbRemovalDelayMinus1[ i ] = code;
     538        }
     539      }
     540    }
     541#if L0045_CONDITION_SIGNALLING
     542  }
     543#endif
     544  xParseByteAlign();
     545}
     546Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt /*payloadSize*/)
    339547{
    340548  Int  iCode;
     
    345553  xParseByteAlign();
    346554}
    347 #endif
    348 
    349 #if RECOVERY_POINT_SEI || BUFFERING_PERIOD_AND_TIMING_SEI
     555Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt /*payloadSize*/)
     556{
     557  UInt val;
     558  READ_UVLC( val, "frame_packing_arrangement_id" );                 sei.m_arrangementId = val;
     559  READ_FLAG( val, "frame_packing_arrangement_cancel_flag" );        sei.m_arrangementCancelFlag = val;
     560
     561  if ( !sei.m_arrangementCancelFlag )
     562  {
     563    READ_CODE( 7, val, "frame_packing_arrangement_type" );          sei.m_arrangementType = val;
     564#if L0444_FPA_TYPE
     565    assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) );
     566#endif
     567    READ_FLAG( val, "quincunx_sampling_flag" );                     sei.m_quincunxSamplingFlag = val;
     568
     569    READ_CODE( 6, val, "content_interpretation_type" );             sei.m_contentInterpretationType = val;
     570    READ_FLAG( val, "spatial_flipping_flag" );                      sei.m_spatialFlippingFlag = val;
     571    READ_FLAG( val, "frame0_flipped_flag" );                        sei.m_frame0FlippedFlag = val;
     572    READ_FLAG( val, "field_views_flag" );                           sei.m_fieldViewsFlag = val;
     573    READ_FLAG( val, "current_frame_is_frame0_flag" );               sei.m_currentFrameIsFrame0Flag = val;
     574    READ_FLAG( val, "frame0_self_contained_flag" );                 sei.m_frame0SelfContainedFlag = val;
     575    READ_FLAG( val, "frame1_self_contained_flag" );                 sei.m_frame1SelfContainedFlag = val;
     576
     577    if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5)
     578    {
     579      READ_CODE( 4, val, "frame0_grid_position_x" );                sei.m_frame0GridPositionX = val;
     580      READ_CODE( 4, val, "frame0_grid_position_y" );                sei.m_frame0GridPositionY = val;
     581      READ_CODE( 4, val, "frame1_grid_position_x" );                sei.m_frame1GridPositionX = val;
     582      READ_CODE( 4, val, "frame1_grid_position_y" );                sei.m_frame1GridPositionY = val;
     583    }
     584
     585    READ_CODE( 8, val, "frame_packing_arrangement_reserved_byte" );   sei.m_arrangementReservedByte = val;
     586#if L0045_PERSISTENCE_FLAGS
     587    READ_FLAG( val,  "frame_packing_arrangement_persistence_flag" );  sei.m_arrangementPersistenceFlag = val ? true : false;
     588#else
     589    READ_UVLC( val, "frame_packing_arrangement_repetition_period" );  sei.m_arrangementRepetetionPeriod = val;
     590#endif
     591  }
     592  READ_FLAG( val, "upsampled_aspect_ratio" );                       sei.m_upsampledAspectRatio = val;
     593
     594  xParseByteAlign();
     595}
     596
     597Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt /*payloadSize*/)
     598{
     599  UInt val;
     600  READ_FLAG( val,       "display_orientation_cancel_flag" );       sei.cancelFlag            = val;
     601  if( !sei.cancelFlag )
     602  {
     603    READ_FLAG( val,     "hor_flip" );                              sei.horFlip               = val;
     604    READ_FLAG( val,     "ver_flip" );                              sei.verFlip               = val;
     605    READ_CODE( 16, val, "anticlockwise_rotation" );                sei.anticlockwiseRotation = val;
     606#if L0045_PERSISTENCE_FLAGS
     607    READ_FLAG( val,     "display_orientation_persistence_flag" );  sei.persistenceFlag       = val;
     608#else
     609    READ_UVLC( val,     "display_orientation_repetition_period" ); sei.repetitionPeriod      = val;
     610#endif
     611#if !REMOVE_SINGLE_SEI_EXTENSION_FLAGS
     612    READ_FLAG( val,     "display_orientation_extension_flag" );    sei.extensionFlag         = val;
     613    assert( !sei.extensionFlag );
     614#endif
     615  }
     616  xParseByteAlign();
     617}
     618
     619Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt /*payloadSize*/)
     620{
     621  UInt val;
     622  READ_CODE ( 8, val, "tl0_idx" );  sei.tl0Idx = val;
     623  READ_CODE ( 8, val, "rap_idx" );  sei.rapIdx = val;
     624  xParseByteAlign();
     625}
     626
     627Void SEIReader::xParseSEIGradualDecodingRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt /*payloadSize*/)
     628{
     629  UInt val;
     630  READ_FLAG( val, "gdr_foreground_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0;
     631  xParseByteAlign();
     632}
     633
    350634Void SEIReader::xParseByteAlign()
    351635{
     
    360644  }
    361645}
    362 #endif
    363646//! \}
  • trunk/source/Lib/TLibDecoder/SEIread.h

    r2 r125  
    44 * granted under this license.
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    3232 */
    3333
     34/**
     35 \file     SEIread.h
     36 \brief    reading funtionality for SEI messages
     37 */
     38
    3439#ifndef __SEIREAD__
    3540#define __SEIREAD__
     
    4449#include "TLibCommon/SEI.h"
    4550class TComInputBitstream;
    46 class SEImessages;
    4751
    4852
     
    5256  SEIReader() {};
    5357  virtual ~SEIReader() {};
    54   Void parseSEImessage(TComInputBitstream* bs, SEImessages& seis);
     58  Void parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps);
    5559protected:
    56   Void xReadSEImessage                (SEImessages& seis);
     60  Void xReadSEImessage                (SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps);
    5761  Void xParseSEIuserDataUnregistered  (SEIuserDataUnregistered &sei, UInt payloadSize);
    58 #if ACTIVE_PARAMETER_SETS_SEI_MESSAGE
    59   Void xParseSEIActiveParameterSets    (SEIActiveParameterSets& sei, UInt payloadSize);
    60 #endif
     62  Void xParseSEIActiveParameterSets   (SEIActiveParameterSets  &sei, UInt payloadSize);
     63  Void xParseSEIDecodingUnitInfo      (SEIDecodingUnitInfo& sei, UInt payloadSize, TComSPS *sps);
    6164  Void xParseSEIDecodedPictureHash    (SEIDecodedPictureHash& sei, UInt payloadSize);
    62 #if BUFFERING_PERIOD_AND_TIMING_SEI
    63   Void xParseSEIBufferingPeriod       (SEIBufferingPeriod& sei, UInt payloadSize);
    64   Void xParseSEIPictureTiming         (SEIPictureTiming& sei, UInt payloadSize);
    65 #endif
    66 #if RECOVERY_POINT_SEI
     65  Void xParseSEIBufferingPeriod       (SEIBufferingPeriod& sei, UInt payloadSize, TComSPS *sps);
     66  Void xParseSEIPictureTiming         (SEIPictureTiming& sei, UInt payloadSize, TComSPS *sps);
    6767  Void xParseSEIRecoveryPoint         (SEIRecoveryPoint& sei, UInt payloadSize);
    68 #endif
    69 #if RECOVERY_POINT_SEI || BUFFERING_PERIOD_AND_TIMING_SEI
     68  Void xParseSEIFramePacking          (SEIFramePacking& sei, UInt payloadSize);
     69  Void xParseSEIDisplayOrientation    (SEIDisplayOrientation &sei, UInt payloadSize);
     70  Void xParseSEITemporalLevel0Index   (SEITemporalLevel0Index &sei, UInt payloadSize);
     71  Void xParseSEIGradualDecodingRefreshInfo (SEIGradualDecodingRefreshInfo &sei, UInt payloadSize);
    7072  Void xParseByteAlign();
    71 #endif
    7273};
    7374
  • trunk/source/Lib/TLibDecoder/SyntaxElementParser.cpp

    r2 r125  
    44* granted under this license. 
    55*
    6 * Copyright (c) 2010-2012, ITU/ISO/IEC
     6* Copyright (c) 2010-2013, ITU/ISO/IEC
    77* All rights reserved.
    88*
  • trunk/source/Lib/TLibDecoder/SyntaxElementParser.h

    r2 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    9090public:
    9191  Void  setBitstream ( TComInputBitstream* p )   { m_pcBitstream = p; }
     92  TComInputBitstream* getBitstream() { return m_pcBitstream; }
    9293};
    9394
  • trunk/source/Lib/TLibDecoder/TDecBinCoder.h

    r2 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    6262 
    6363  virtual Void  resetBac          ()                                          = 0;
    64   virtual Void  decodeNumSubseqIPCM( Int& numSubseqIPCM )                  = 0;
    6564  virtual Void  decodePCMAlignBits()                                          = 0;
    6665  virtual Void  xReadPCMCode      ( UInt uiLength, UInt& ruiCode)              = 0;
  • trunk/source/Lib/TLibDecoder/TDecBinCoderCABAC.cpp

    r2 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    251251}
    252252
    253 /** Decode subsequent_pcm_num.
    254  * \param numSubseqIPCM
    255  * \returns Void
    256  */
    257 Void TDecBinCABAC::decodeNumSubseqIPCM( Int& numSubseqIPCM )
    258 {
    259   UInt bit = 0;
    260 
    261   numSubseqIPCM = 0;
    262 
    263   do
    264   {
    265     m_uiValue += m_uiValue;
    266     if ( ++m_bitsNeeded >= 0 )
    267     {
    268       m_bitsNeeded = -8;
    269       m_uiValue += m_pcTComBitstream->readByte();
    270     }
    271     bit = ((m_uiValue&128)>>7);
    272     numSubseqIPCM++;
    273   }
    274   while( bit && (numSubseqIPCM < 3 ));
    275 
    276   if( bit && (numSubseqIPCM == 3 ))
    277   {
    278     numSubseqIPCM++;
    279   }
    280 
    281   numSubseqIPCM --;
    282 }
    283 
    284253/** Decode PCM alignment zero bits.
    285254 * \returns Void
  • trunk/source/Lib/TLibDecoder/TDecBinCoderCABAC.h

    r2 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    6464 
    6565  Void  resetBac          ();
    66   Void  decodeNumSubseqIPCM( Int& numSubseqIPCM ) ;
    6766  Void  decodePCMAlignBits();
    6867  Void  xReadPCMCode      ( UInt uiLength, UInt& ruiCode );
  • trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r33 r125  
    44* granted under this license. 
    55*
    6 * Copyright (c) 2010-2012, ITU/ISO/IEC
     6* Copyright (c) 2010-2013, ITU/ISO/IEC
    77* All rights reserved.
    88*
     
    5555}
    5656
    57 #if !REMOVE_APS
    58 Void  xTraceAPSHeader (TComAPS *pAPS)
    59 {
    60   fprintf( g_hTrace, "=========== Adaptation Parameter Set ===========\n");
    61 }
    62 #endif
    63 
    6457Void  xTraceSliceHeader (TComSlice *pSlice)
    6558{
     
    7568TDecCavlc::TDecCavlc()
    7669{
    77 #if !REMOVE_FGS
    78   m_iSliceGranularity = 0;
    79 #endif
    8070}
    8171
     
    9383  UInt code;
    9484  UInt interRPSPred;
    95   READ_FLAG(interRPSPred, "inter_ref_pic_set_prediction_flag");  rps->setInterRPSPrediction(interRPSPred);
     85  if (idx > 0)
     86  {
     87    READ_FLAG(interRPSPred, "inter_ref_pic_set_prediction_flag");  rps->setInterRPSPrediction(interRPSPred);
     88  }
     89  else
     90  {
     91    interRPSPred = false;
     92    rps->setInterRPSPrediction(false);
     93  }
     94
    9695  if (interRPSPred)
    9796  {
    9897    UInt bit;
    99 #if J0234_INTER_RPS_SIMPL
    10098    if(idx == sps->getRPSList()->getNumberOfReferencePictureSets())
    10199    {
     
    107105    }
    108106    assert(code <= idx-1); // delta_idx_minus1 shall not be larger than idx-1, otherwise we will predict from a negative row position that does not exist. When idx equals 0 there is no legal value and interRPSPred must be zero. See J0185-r2
    109 #else
    110     READ_UVLC(code, "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1
    111 #endif
    112107    Int rIdx =  idx - 1 - code;
    113 #if J0234_INTER_RPS_SIMPL
    114108    assert (rIdx <= idx-1 && rIdx >= 0); // Made assert tighter; if rIdx = idx then prediction is done from itself. rIdx must belong to range 0, idx-1, inclusive, see J0185-r2
    115 #else
    116     assert (rIdx <= idx && rIdx >= 0);
    117 #endif
    118109    TComReferencePictureSet*   rpsRef = sps->getRPSList()->getReferencePictureSet(rIdx);
    119110    Int k = 0, k0 = 0, k1 = 0;
    120111    READ_CODE(1, bit, "delta_rps_sign"); // delta_RPS_sign
    121112    READ_UVLC(code, "abs_delta_rps_minus1");  // absolute delta RPS minus 1
    122     Int deltaRPS = (1 - (bit<<1)) * (code + 1); // delta_RPS
     113    Int deltaRPS = (1 - 2 * bit) * (code + 1); // delta_RPS
    123114    for(Int j=0 ; j <= rpsRef->getNumberOfPictures(); j++)
    124115    {
     
    136127        rps->setUsed(k, (refIdc == 1));
    137128
    138         if (deltaPOC < 0) {
     129        if (deltaPOC < 0)
     130        {
    139131          k0++;
    140132        }
     
    183175}
    184176
    185 #if !REMOVE_APS
    186 Void TDecCavlc::parseAPS(TComAPS* aps)
    187 {
    188 #if ENC_DEC_TRACE 
    189   xTraceAPSHeader(aps);
    190 #endif
    191 
    192   UInt uiCode;
    193   READ_UVLC(uiCode, "aps_id");                             aps->setAPSID(uiCode);
    194 #if !REMOVE_ALF
    195   for(Int compIdx=0; compIdx< 3; compIdx++)
    196   {
    197     xParseAlfParam( (aps->getAlfParam())[compIdx]);
    198   }
    199 #endif
    200   READ_FLAG( uiCode, "aps_extension_flag");
    201   if (uiCode)
    202   {
    203     while ( xMoreRbspData() )
    204     {
    205       READ_FLAG( uiCode, "aps_extension_data_flag");
    206     }
    207   }
    208 
    209 }
    210 #endif
    211 
    212177/** copy SAO parameter
    213178* \param dst 
     
    221186  if (dst->typeIdx != -1)
    222187  {
    223 #if SAO_TYPE_CODING
    224188    dst->subTypeIdx = src->subTypeIdx ;
    225 #else
    226     if (dst->typeIdx == SAO_BO)
    227     {
    228       dst->bandPosition = src->bandPosition ;
    229     }
    230     else
    231     {
    232       dst->bandPosition = 0;
    233     }
    234 #endif
    235189    dst->length  = src->length;
    236190    for (i=0;i<dst->length;i++)
     
    249203}
    250204
    251 #if !REMOVE_ALF
    252 Void TDecCavlc::xParseAlfParam(ALFParam* pAlfParam)
    253 {
    254   UInt uiSymbol;
    255   char syntaxString[50];
    256   sprintf(syntaxString, "alf_aps_filter_flag[%d]", pAlfParam->componentID);
    257   READ_FLAG(uiSymbol, syntaxString);
    258   pAlfParam->alf_flag = uiSymbol;
    259   if(pAlfParam->alf_flag ==0)
    260   {
    261     return;
    262   }
    263   Int iSymbol;
    264   pAlfParam->num_coeff = (Int)ALF_MAX_NUM_COEF;
    265   switch(pAlfParam->componentID)
    266   {
    267   case ALF_Cb:
    268   case ALF_Cr:
    269     {
    270       pAlfParam->filter_shape = ALF_CROSS9x7_SQUARE3x3;
    271       pAlfParam->filters_per_group = 1;
    272       for(Int pos=0; pos< pAlfParam->num_coeff; pos++)
    273       {
    274         READ_SVLC(iSymbol, "alf_filt_coeff");
    275         pAlfParam->coeffmulti[0][pos] = iSymbol;
    276       }
    277     }
    278     break;
    279   case ALF_Y:
    280     {
    281       pAlfParam->filters_per_group = 0;
    282       memset (pAlfParam->filterPattern, 0 , sizeof(Int)*NO_VAR_BINS);
    283       pAlfParam->filter_shape = 0;
    284       // filters_per_fr
    285       READ_UVLC (uiSymbol, "alf_no_filters_minus1");
    286       pAlfParam->filters_per_group = uiSymbol + 1;
    287 
    288       if(uiSymbol == 1) // filters_per_group == 2
    289       {
    290         READ_UVLC (uiSymbol, "alf_start_second_filter");
    291         pAlfParam->startSecondFilter = uiSymbol;
    292         pAlfParam->filterPattern [uiSymbol] = 1;
    293       }
    294       else if (uiSymbol > 1) // filters_per_group > 2
    295       {
    296         pAlfParam->filters_per_group = 1;
    297         Int numMergeFlags = 16;
    298         for (Int i=1; i<numMergeFlags; i++)
    299         {
    300           READ_FLAG (uiSymbol,  "alf_filter_pattern");
    301           pAlfParam->filterPattern[i] = uiSymbol;
    302           pAlfParam->filters_per_group += uiSymbol;
    303         }
    304       }
    305       for(Int idx = 0; idx < pAlfParam->filters_per_group; ++idx)
    306       {
    307         for(Int i = 0; i < pAlfParam->num_coeff; i++)
    308         {
    309           pAlfParam->coeffmulti[idx][i] = xGolombDecode(kTableTabShapes[ALF_CROSS9x7_SQUARE3x3][i]);
    310         }
    311       }
    312     }
    313     break;
    314   default:
    315     {
    316       printf("Not a legal component ID for ALF\n");
    317       assert(0);
    318       exit(-1);
    319     }
    320   }
    321 }
    322 
    323 Int TDecCavlc::xGolombDecode(Int k)
    324 {
    325   Int coeff;
    326   UInt symbol;
    327   xReadEpExGolomb( symbol, k );
    328   coeff = symbol;
    329   if(symbol != 0)
    330   {
    331     xReadFlag(symbol);
    332     if(symbol == 0)
    333     {
    334       coeff = -coeff;
    335     }
    336   }
    337 #if ENC_DEC_TRACE
    338   fprintf( g_hTrace, "%8lld  ", g_nSymbolCounter++ );
    339   fprintf( g_hTrace, "%-40s se(v) : %d\n", "alf_filt_coeff", coeff );
    340 #endif
    341   return coeff;
    342 }
    343 #endif
    344 
    345205Void TDecCavlc::parsePPS(TComPPS* pcPPS)
    346206{
     
    352212  Int   iCode;
    353213
    354   READ_UVLC( uiCode, "pic_parameter_set_id");                      pcPPS->setPPSId (uiCode);
    355   READ_UVLC( uiCode, "seq_parameter_set_id");                      pcPPS->setSPSId (uiCode);
    356 
     214  READ_UVLC( uiCode, "pps_pic_parameter_set_id");                     pcPPS->setPPSId (uiCode);
     215  READ_UVLC( uiCode, "pps_seq_parameter_set_id");                     pcPPS->setSPSId (uiCode);
     216  READ_FLAG( uiCode, "dependent_slice_segments_enabled_flag"    );    pcPPS->setDependentSliceSegmentsEnabledFlag   ( uiCode == 1 );
     217#if L0255_MOVE_PPS_FLAGS
     218  READ_FLAG( uiCode, "output_flag_present_flag" );                    pcPPS->setOutputFlagPresentFlag( uiCode==1 );
     219
     220  READ_CODE(3, uiCode, "num_extra_slice_header_bits");                pcPPS->setNumExtraSliceHeaderBits(uiCode);
     221#endif
    357222  READ_FLAG ( uiCode, "sign_data_hiding_flag" ); pcPPS->setSignHideFlag( uiCode );
    358223
    359224  READ_FLAG( uiCode,   "cabac_init_present_flag" );            pcPPS->setCabacInitPresentFlag( uiCode ? true : false );
    360225
     226#if L0323_LIMIT_DEFAULT_LIST_SIZE
     227  READ_UVLC(uiCode, "num_ref_idx_l0_default_active_minus1");
     228  assert(uiCode <= 14);
     229  pcPPS->setNumRefIdxL0DefaultActive(uiCode+1);
     230 
     231  READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1");
     232  assert(uiCode <= 14);
     233  pcPPS->setNumRefIdxL1DefaultActive(uiCode+1);
     234#else
    361235  READ_UVLC(uiCode, "num_ref_idx_l0_default_active_minus1");       pcPPS->setNumRefIdxL0DefaultActive(uiCode+1);
    362236  READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1");       pcPPS->setNumRefIdxL1DefaultActive(uiCode+1);
    363 
    364   READ_SVLC(iCode, "pic_init_qp_minus26" );                        pcPPS->setPicInitQPMinus26(iCode);
     237#endif
     238 
     239  READ_SVLC(iCode, "init_qp_minus26" );                            pcPPS->setPicInitQPMinus26(iCode);
    365240  READ_FLAG( uiCode, "constrained_intra_pred_flag" );              pcPPS->setConstrainedIntraPred( uiCode ? true : false );
    366 #if PPS_TS_FLAG 
    367241  READ_FLAG( uiCode, "transform_skip_enabled_flag" );               
    368242  pcPPS->setUseTransformSkip ( uiCode ? true : false );
    369 #endif
    370 
    371 #if !REMOVE_FGS
    372   READ_CODE( 2, uiCode, "slice_granularity" );                     pcPPS->setSliceGranularity(uiCode);
    373 #endif
    374  
    375   // alf_param() ?
    376 #if CU_DQP_ENABLE_FLAG
     243
    377244  READ_FLAG( uiCode, "cu_qp_delta_enabled_flag" );            pcPPS->setUseDQP( uiCode ? true : false );
    378245  if( pcPPS->getUseDQP() )
    379246  {
    380247    READ_UVLC( uiCode, "diff_cu_qp_delta_depth" );
    381 #if REMOVE_FGS
    382248    pcPPS->setMaxCuDQPDepth( uiCode );
    383 #else
    384     pcPPS->setMaxCuDQPDepth( uiCode + pcPPS->getSliceGranularity() );
    385 #endif
    386249  }
    387250  else
     
    389252    pcPPS->setMaxCuDQPDepth( 0 );
    390253  }
    391 #else
    392   READ_UVLC( uiCode, "diff_cu_qp_delta_depth");
    393   if(uiCode == 0)
    394   {
    395     pcPPS->setUseDQP (false);
    396     pcPPS->setMaxCuDQPDepth( 0 );
    397   }
    398   else
    399   {
    400     pcPPS->setUseDQP (true);
    401 #if REMOVE_FGS
    402     pcPPS->setMaxCuDQPDepth(uiCode - 1);
    403 #else
    404     pcPPS->setMaxCuDQPDepth(uiCode + pcPPS->getSliceGranularity() - 1);
    405 #endif
    406   }
    407 #endif
    408   READ_SVLC( iCode, "cb_qp_offset");
     254  READ_SVLC( iCode, "pps_cb_qp_offset");
    409255  pcPPS->setChromaCbQpOffset(iCode);
    410 #if CHROMA_QP_EXTENSION
    411256  assert( pcPPS->getChromaCbQpOffset() >= -12 );
    412257  assert( pcPPS->getChromaCbQpOffset() <=  12 );
    413 #endif
    414 
    415   READ_SVLC( iCode, "cr_qp_offset");
     258
     259  READ_SVLC( iCode, "pps_cr_qp_offset");
    416260  pcPPS->setChromaCrQpOffset(iCode);
    417 #if CHROMA_QP_EXTENSION
    418261  assert( pcPPS->getChromaCrQpOffset() >= -12 );
    419262  assert( pcPPS->getChromaCrQpOffset() <=  12 );
    420 #endif
    421 
    422 #if CHROMA_QP_EXTENSION
    423   READ_FLAG( uiCode, "slicelevel_chroma_qp_flag" );
     263
     264  READ_FLAG( uiCode, "pps_slice_chroma_qp_offsets_present_flag" );
    424265  pcPPS->setSliceChromaQpFlag( uiCode ? true : false );
    425 #endif
    426266
    427267  READ_FLAG( uiCode, "weighted_pred_flag" );          // Use of Weighting Prediction (P_SLICE)
     
    429269  READ_FLAG( uiCode, "weighted_bipred_flag" );         // Use of Bi-Directional Weighting Prediction (B_SLICE)
    430270  pcPPS->setWPBiPred( uiCode==1 );
    431   printf("TDecCavlc::parsePPS():\tm_bUseWeightPred=%d\tm_uiBiPredIdc=%d\n", pcPPS->getUseWP(), pcPPS->getWPBiPred());
    432 
     271
     272#if !L0255_MOVE_PPS_FLAGS
    433273  READ_FLAG( uiCode, "output_flag_present_flag" );
    434274  pcPPS->setOutputFlagPresentFlag( uiCode==1 );
    435 
    436 #if !TILES_WPP_ENTROPYSLICES_FLAGS
    437 #if DEPENDENT_SLICES
    438   READ_FLAG( uiCode, "dependent_slices_enabled_flag" );
    439   pcPPS->setDependentSliceEnabledFlag( uiCode==1 );
    440 #endif
    441 #endif
    442 
     275#endif
    443276  READ_FLAG( uiCode, "transquant_bypass_enable_flag");
    444277  pcPPS->setTransquantBypassEnableFlag(uiCode ? true : false);
    445 
    446 #if TILES_WPP_ENTROPYSLICES_FLAGS
    447 #if DEPENDENT_SLICES
    448   READ_FLAG( uiCode, "dependent_slices_enabled_flag"    );    pcPPS->setDependentSliceEnabledFlag   ( uiCode == 1 );
    449 #endif
    450278  READ_FLAG( uiCode, "tiles_enabled_flag"               );    pcPPS->setTilesEnabledFlag            ( uiCode == 1 );
    451   READ_FLAG( uiCode, "entropy_coding_sync_enabled_flag" );    pcPPS->setEntropyCodingSyncEnabledFlag( uiCode == 1 );   
    452   READ_FLAG( uiCode, "entropy_slice_enabled_flag"       );    pcPPS->setEntropySliceEnabledFlag     ( uiCode == 1 );   
    453 
     279  READ_FLAG( uiCode, "entropy_coding_sync_enabled_flag" );    pcPPS->setEntropyCodingSyncEnabledFlag( uiCode == 1 );
     280 
    454281  if( pcPPS->getTilesEnabledFlag() )
    455 #else
    456   READ_CODE(2, uiCode, "tiles_or_entropy_coding_sync_idc");         pcPPS->setTilesOrEntropyCodingSyncIdc(uiCode);
    457   if(pcPPS->getTilesOrEntropyCodingSyncIdc() == 1)
    458 #endif
    459282  {
    460283    READ_UVLC ( uiCode, "num_tile_columns_minus1" );                pcPPS->setNumColumnsMinus1( uiCode ); 
     
    488311    }
    489312  }
    490 #if !TILES_WPP_ENTROPYSLICES_FLAGS
    491 #if DEPENDENT_SLICES
    492   else if( pcPPS->getTilesOrEntropyCodingSyncIdc()==3 )
    493   {
    494     READ_FLAG ( uiCode, "cabac_independent_flag" );
    495     pcPPS->setCabacIndependentFlag( (uiCode == 1)? true : false );
    496   }
    497 #endif
    498 #endif
    499 #if MOVE_LOOP_FILTER_SLICES_FLAG
    500313  READ_FLAG( uiCode, "loop_filter_across_slices_enabled_flag" );       pcPPS->setLoopFilterAcrossSlicesEnabledFlag( uiCode ? true : false );
    501 #endif
    502314  READ_FLAG( uiCode, "deblocking_filter_control_present_flag" );       pcPPS->setDeblockingFilterControlPresentFlag( uiCode ? true : false );
    503315  if(pcPPS->getDeblockingFilterControlPresentFlag())
    504316  {
    505317    READ_FLAG( uiCode, "deblocking_filter_override_enabled_flag" );    pcPPS->setDeblockingFilterOverrideEnabledFlag( uiCode ? true : false );
    506     READ_FLAG( uiCode, "pic_disable_deblocking_filter_flag" );         pcPPS->setPicDisableDeblockingFilterFlag(uiCode ? true : false );
     318    READ_FLAG( uiCode, "pps_disable_deblocking_filter_flag" );         pcPPS->setPicDisableDeblockingFilterFlag(uiCode ? true : false );
    507319    if(!pcPPS->getPicDisableDeblockingFilterFlag())
    508320    {
     
    516328    parseScalingList( pcPPS->getScalingList() );
    517329  }
     330
     331  READ_FLAG( uiCode, "lists_modification_present_flag");
     332  pcPPS->setListsModificationPresentFlag(uiCode);
     333
    518334  READ_UVLC( uiCode, "log2_parallel_merge_level_minus2");
    519335  pcPPS->setLog2ParallelMergeLevelMinus2 (uiCode);
    520336
    521 #if SLICE_HEADER_EXTENSION
    522   READ_FLAG( uiCode, "slice_header_extension_present_flag");
     337#if !L0255_MOVE_PPS_FLAGS
     338  READ_CODE(3, uiCode, "num_extra_slice_header_bits");
     339  pcPPS->setNumExtraSliceHeaderBits(uiCode);
     340#endif
     341  READ_FLAG( uiCode, "slice_segment_header_extension_present_flag");
    523342  pcPPS->setSliceHeaderExtensionPresentFlag(uiCode);
    524 #endif
    525343
    526344  READ_FLAG( uiCode, "pps_extension_flag");
     
    534352}
    535353
    536 #if SUPPORT_FOR_VUI
    537 #if !BUFFERING_PERIOD_AND_TIMING_SEI
    538 Void  TDecCavlc::parseVUI(TComVUI* pcVUI)
    539 #else
    540354Void  TDecCavlc::parseVUI(TComVUI* pcVUI, TComSPS *pcSPS)
    541 #endif
    542355{
    543356#if ENC_DEC_TRACE
     
    553366    {
    554367      READ_CODE(16, uiCode, "sar_width");                             pcVUI->setSarWidth(uiCode);
    555       READ_CODE(16, uiCode, "sar_height");                            pcVUI->setSarWidth(uiCode);
     368      READ_CODE(16, uiCode, "sar_height");                            pcVUI->setSarHeight(uiCode);
    556369    }
    557370  }
     
    589402  assert(pcVUI->getFieldSeqFlag() == false);        // not supported yet
    590403
     404  READ_FLAG(uiCode, "frame_field_info_present_flag");                 pcVUI->setFrameFieldInfoPresentFlag(uiCode);
     405
     406  READ_FLAG(     uiCode, "default_display_window_flag");
     407  if (uiCode != 0)
     408  {
     409    Window &defDisp = pcVUI->getDefaultDisplayWindow();
     410    READ_UVLC(   uiCode, "def_disp_win_left_offset" );                defDisp.setWindowLeftOffset  ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) );
     411    READ_UVLC(   uiCode, "def_disp_win_right_offset" );               defDisp.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) );
     412    READ_UVLC(   uiCode, "def_disp_win_top_offset" );                 defDisp.setWindowTopOffset   ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) );
     413    READ_UVLC(   uiCode, "def_disp_win_bottom_offset" );              defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) );
     414  }
     415#if L0043_TIMING_INFO
     416  TimingInfo *timingInfo = pcVUI->getTimingInfo();
     417  READ_FLAG(       uiCode, "vui_timing_info_present_flag");         timingInfo->setTimingInfoPresentFlag      (uiCode ? true : false);
     418  if(timingInfo->getTimingInfoPresentFlag())
     419  {
     420    READ_CODE( 32, uiCode, "vui_num_units_in_tick");                timingInfo->setNumUnitsInTick             (uiCode);
     421    READ_CODE( 32, uiCode, "vui_time_scale");                       timingInfo->setTimeScale                  (uiCode);
     422    READ_FLAG(     uiCode, "vui_poc_proportional_to_timing_flag");  timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false);
     423    if(timingInfo->getPocProportionalToTimingFlag())
     424    {
     425      READ_UVLC(   uiCode, "vui_num_ticks_poc_diff_one_minus1");    timingInfo->setNumTicksPocDiffOneMinus1   (uiCode);
     426    }
     427#endif 
    591428  READ_FLAG(     uiCode, "hrd_parameters_present_flag");              pcVUI->setHrdParametersPresentFlag(uiCode);
    592 #if !BUFFERING_PERIOD_AND_TIMING_SEI
    593   assert(pcVUI->getHrdParametersPresentFlag() == false);  // not supported yet
    594 #else
    595429  if( pcVUI->getHrdParametersPresentFlag() )
    596430  {
    597     READ_FLAG( uiCode, "timing_info_present_flag" );                  pcVUI->setTimingInfoPresentFlag( uiCode );
    598     if( pcVUI->getTimingInfoPresentFlag() )
    599     {
    600       READ_CODE( 32, uiCode, "num_units_in_tick" );                   pcVUI->setNumUnitsInTick( uiCode );
    601       READ_CODE( 32, uiCode, "time_scale" );                          pcVUI->setTimeScale( uiCode );
    602     }
    603     READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" );           pcVUI->setNalHrdParametersPresentFlag( uiCode );
    604     READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" );           pcVUI->setVclHrdParametersPresentFlag( uiCode );
    605     if( pcVUI->getNalHrdParametersPresentFlag() || pcVUI->getVclHrdParametersPresentFlag() )
    606     {
    607       READ_FLAG( uiCode, "sub_pic_Cpb_params_present_flag" );         pcVUI->setSubPicCpbParamsPresentFlag( uiCode );
    608       if( pcVUI->getSubPicCpbParamsPresentFlag() )
    609       {
    610         READ_CODE( 8, uiCode, "tick_divisor_minus2" );                pcVUI->setTickDivisorMinus2( uiCode );
    611         READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); pcVUI->setDuCpbRemovalDelayLengthMinus1( uiCode );
    612       }
    613       READ_CODE( 4, uiCode, "bit_rate_scale" );                       pcVUI->setBitRateScale( uiCode );
    614       READ_CODE( 4, uiCode, "cpb_size_scale" );                       pcVUI->setCpbSizeScale( uiCode );
    615       READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); pcVUI->setInitialCpbRemovalDelayLengthMinus1( uiCode );
    616       READ_CODE( 5, uiCode, "cpb_removal_delay_length_minus1" );      pcVUI->setCpbRemovalDelayLengthMinus1( uiCode );
    617       READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" );       pcVUI->setDpbOutputDelayLengthMinus1( uiCode );
    618     }
    619 
    620     Int i, j, nalOrVcl;
    621     for( i = 0; i < pcSPS->getMaxTLayers(); i ++ )
    622     {
    623       READ_FLAG( uiCode, "fixed_pic_rate_flag" );                     pcVUI->setFixedPicRateFlag( i, uiCode );
    624       if( pcVUI->getFixedPicRateFlag( i ) )
    625       {
    626         READ_UVLC( uiCode, "pic_duration_in_tc_minus1" );             pcVUI->setPicDurationInTcMinus1( i, uiCode );
    627       }
    628       READ_FLAG( uiCode, "low_delay_hrd_flag" );                      pcVUI->setLowDelayHrdFlag( i, uiCode );
    629       READ_UVLC( uiCode, "cpb_cnt_minus1" );                          pcVUI->setCpbCntMinus1( i, uiCode );
    630       for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
    631       {
    632         if( ( ( nalOrVcl == 0 ) && ( pcVUI->getNalHrdParametersPresentFlag() ) ) ||
    633             ( ( nalOrVcl == 1 ) && ( pcVUI->getVclHrdParametersPresentFlag() ) ) )
    634         {
    635           for( j = 0; j < ( pcVUI->getCpbCntMinus1( i ) + 1 ); j ++ )
    636           {
    637             READ_UVLC( uiCode, "bit_size_value_minus1" );             pcVUI->setBitRateValueMinus1( i, j, nalOrVcl, uiCode );
    638             READ_UVLC( uiCode, "cpb_size_value_minus1" );             pcVUI->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode );
    639             READ_FLAG( uiCode, "cbr_flag" );                          pcVUI->setCbrFlag( i, j, nalOrVcl, uiCode );
    640           }
    641         }
    642       }
    643     }
     431    parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 );
     432  }
     433#if L0043_TIMING_INFO
     434  }
     435#endif
     436#if !L0043_TIMING_INFO
     437  READ_FLAG( uiCode, "poc_proportional_to_timing_flag" ); pcVUI->setPocProportionalToTimingFlag(uiCode ? true : false);
     438  if( pcVUI->getPocProportionalToTimingFlag() && pcVUI->getHrdParameters()->getTimingInfoPresentFlag() )
     439  {
     440    READ_UVLC( uiCode, "num_ticks_poc_diff_one_minus1" ); pcVUI->setNumTicksPocDiffOneMinus1(uiCode);
    644441  }
    645442#endif
     
    649446    READ_FLAG(   uiCode, "tiles_fixed_structure_flag");               pcVUI->setTilesFixedStructureFlag(uiCode);
    650447    READ_FLAG(   uiCode, "motion_vectors_over_pic_boundaries_flag");  pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode);
     448    READ_FLAG(   uiCode, "restricted_ref_pic_lists_flag");            pcVUI->setRestrictedRefPicListsFlag(uiCode);
     449#if L0043_MSS_IDC
     450    READ_UVLC( uiCode, "min_spatial_segmentation_idc");            pcVUI->setMinSpatialSegmentationIdc(uiCode);
     451    assert(uiCode < 4096);
     452#else
     453    READ_CODE( 8, uiCode, "min_spatial_segmentation_idc");            pcVUI->setMinSpatialSegmentationIdc(uiCode);
     454#endif
    651455    READ_UVLC(   uiCode, "max_bytes_per_pic_denom" );                 pcVUI->setMaxBytesPerPicDenom(uiCode);
    652456    READ_UVLC(   uiCode, "max_bits_per_mincu_denom" );                pcVUI->setMaxBitsPerMinCuDenom(uiCode);
     
    655459  }
    656460}
    657 #endif
     461
     462Void TDecCavlc::parseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1)
     463{
     464  UInt  uiCode;
     465  if( commonInfPresentFlag )
     466  {
     467#if !L0043_TIMING_INFO
     468    READ_FLAG( uiCode, "timing_info_present_flag" );                  hrd->setTimingInfoPresentFlag( uiCode == 1 ? true : false );
     469    if( hrd->getTimingInfoPresentFlag() )
     470    {
     471      READ_CODE( 32, uiCode, "num_units_in_tick" );                   hrd->setNumUnitsInTick( uiCode );
     472      READ_CODE( 32, uiCode, "time_scale" );                          hrd->setTimeScale( uiCode );
     473    }
     474#endif
     475    READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" );           hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false );
     476    READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" );           hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false );
     477    if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() )
     478    {
     479      READ_FLAG( uiCode, "sub_pic_cpb_params_present_flag" );         hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false );
     480      if( hrd->getSubPicCpbParamsPresentFlag() )
     481      {
     482        READ_CODE( 8, uiCode, "tick_divisor_minus2" );                hrd->setTickDivisorMinus2( uiCode );
     483        READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode );
     484        READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false );
     485#if L0044_DU_DPB_OUTPUT_DELAY_HRD
     486        READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1"  ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode );
     487#endif
     488      }
     489      READ_CODE( 4, uiCode, "bit_rate_scale" );                       hrd->setBitRateScale( uiCode );
     490      READ_CODE( 4, uiCode, "cpb_size_scale" );                       hrd->setCpbSizeScale( uiCode );
     491      if( hrd->getSubPicCpbParamsPresentFlag() )
     492      {
     493        READ_CODE( 4, uiCode, "cpb_size_du_scale" );                  hrd->setDuCpbSizeScale( uiCode );
     494      }
     495      READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode );
     496      READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" );      hrd->setCpbRemovalDelayLengthMinus1( uiCode );
     497      READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" );       hrd->setDpbOutputDelayLengthMinus1( uiCode );
     498    }
     499  }
     500  Int i, j, nalOrVcl;
     501  for( i = 0; i <= maxNumSubLayersMinus1; i ++ )
     502  {
     503    READ_FLAG( uiCode, "fixed_pic_rate_general_flag" );                     hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false  );
     504    if( !hrd->getFixedPicRateFlag( i ) )
     505    {
     506      READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" );                hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false  );
     507    }
     508    else
     509    {
     510      hrd->setFixedPicRateWithinCvsFlag( i, true );
     511    }
     512#if L0372
     513    hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present
     514    hrd->setCpbCntMinus1   ( i, 0 ); // Infered to be 0 when not present
     515#endif
     516    if( hrd->getFixedPicRateWithinCvsFlag( i ) )
     517    {
     518      READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" );             hrd->setPicDurationInTcMinus1( i, uiCode );
     519    }
     520#if L0372
     521    else
     522    {     
     523      READ_FLAG( uiCode, "low_delay_hrd_flag" );                      hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false  );
     524    }
     525    if (!hrd->getLowDelayHrdFlag( i ))
     526    {
     527      READ_UVLC( uiCode, "cpb_cnt_minus1" );                          hrd->setCpbCntMinus1( i, uiCode );     
     528    }
     529#else
     530    READ_FLAG( uiCode, "low_delay_hrd_flag" );                      hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false  );
     531    READ_UVLC( uiCode, "cpb_cnt_minus1" );                          hrd->setCpbCntMinus1( i, uiCode );
     532#endif
     533    for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
     534    {
     535      if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) ||
     536          ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) )
     537      {
     538        for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ )
     539        {
     540          READ_UVLC( uiCode, "bit_rate_value_minus1" );             hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode );
     541          READ_UVLC( uiCode, "cpb_size_value_minus1" );             hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode );
     542          if( hrd->getSubPicCpbParamsPresentFlag() )
     543          {
     544#if L0363_DU_BIT_RATE
     545            READ_UVLC( uiCode, "bit_rate_du_value_minus1" );       hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode );
     546#endif
     547            READ_UVLC( uiCode, "cpb_size_du_value_minus1" );       hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode );
     548          }
     549          READ_FLAG( uiCode, "cbr_flag" );                          hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false  );
     550        }
     551      }
     552    }
     553  }
     554}
    658555
    659556Void TDecCavlc::parseSPS(TComSPS* pcSPS)
     
    664561
    665562  UInt  uiCode;
    666 #if SPS_SYNTAX_CHANGES
    667   READ_CODE( 4,  uiCode, "video_parameter_set_id");              pcSPS->setVPSId        ( uiCode );
     563  READ_CODE( 4,  uiCode, "sps_video_parameter_set_id");          pcSPS->setVPSId        ( uiCode );
    668564  READ_CODE( 3,  uiCode, "sps_max_sub_layers_minus1" );          pcSPS->setMaxTLayers   ( uiCode+1 );
    669   READ_FLAG(     uiCode, "sps_reserved_zero_bit");               assert(uiCode == 0);
     565  READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" );               pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false );
     566  if ( pcSPS->getMaxTLayers() == 1 )
     567  {
     568    // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0
     569    assert( uiCode == 1 );
     570  }
     571 
    670572  parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1);
    671   READ_UVLC(     uiCode, "seq_parameter_set_id" );               pcSPS->setSPSId( uiCode );
     573  READ_UVLC(     uiCode, "sps_seq_parameter_set_id" );           pcSPS->setSPSId( uiCode );
    672574  READ_UVLC(     uiCode, "chroma_format_idc" );                  pcSPS->setChromaFormatIdc( uiCode );
    673575  // in the first version we only support chroma_format_idc equal to 1 (4:2:0), so separate_colour_plane_flag cannot appear in the bitstream
     
    678580  }
    679581
    680 #else
    681   READ_CODE( 3,  uiCode, "profile_space" );                      pcSPS->setProfileSpace( uiCode );
    682   READ_CODE( 5,  uiCode, "profile_idc" );                        pcSPS->setProfileIdc( uiCode );
    683   READ_CODE(16,  uiCode, "reserved_indicator_flags" );           pcSPS->setRsvdIndFlags( uiCode );
    684   READ_CODE( 8,  uiCode, "level_idc" );                          pcSPS->setLevelIdc( uiCode );
    685   READ_CODE(32,  uiCode, "profile_compatibility");               pcSPS->setProfileCompat( uiCode );
    686   READ_UVLC(     uiCode, "seq_parameter_set_id" );               pcSPS->setSPSId( uiCode );
    687   READ_UVLC(     uiCode, "video_parameter_set_id" );             pcSPS->setVPSId( uiCode );
    688   READ_UVLC(     uiCode, "chroma_format_idc" );                  pcSPS->setChromaFormatIdc( uiCode );
    689   READ_CODE( 3,  uiCode, "max_temporal_layers_minus1" );         pcSPS->setMaxTLayers( uiCode+1 );
    690 #endif
    691582  READ_UVLC (    uiCode, "pic_width_in_luma_samples" );          pcSPS->setPicWidthInLumaSamples ( uiCode    );
    692583  READ_UVLC (    uiCode, "pic_height_in_luma_samples" );         pcSPS->setPicHeightInLumaSamples( uiCode    );
    693   READ_FLAG(     uiCode, "pic_cropping_flag");                   pcSPS->setPicCroppingFlag ( uiCode ? true : false );
     584  READ_FLAG(     uiCode, "conformance_window_flag");
    694585  if (uiCode != 0)
    695586  {
    696     READ_UVLC(   uiCode, "pic_crop_left_offset" );               pcSPS->setPicCropLeftOffset  ( uiCode * TComSPS::getCropUnitX( pcSPS->getChromaFormatIdc() ) );
    697     READ_UVLC(   uiCode, "pic_crop_right_offset" );              pcSPS->setPicCropRightOffset ( uiCode * TComSPS::getCropUnitX( pcSPS->getChromaFormatIdc() ) );
    698     READ_UVLC(   uiCode, "pic_crop_top_offset" );                pcSPS->setPicCropTopOffset   ( uiCode * TComSPS::getCropUnitY( pcSPS->getChromaFormatIdc() ) );
    699     READ_UVLC(   uiCode, "pic_crop_bottom_offset" );             pcSPS->setPicCropBottomOffset( uiCode * TComSPS::getCropUnitY( pcSPS->getChromaFormatIdc() ) );
    700   }
    701 
    702 #if FULL_NBIT
     587    Window &conf = pcSPS->getConformanceWindow();
     588    READ_UVLC(   uiCode, "conf_win_left_offset" );               conf.setWindowLeftOffset  ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) );
     589    READ_UVLC(   uiCode, "conf_win_right_offset" );              conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) );
     590    READ_UVLC(   uiCode, "conf_win_top_offset" );                conf.setWindowTopOffset   ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) );
     591    READ_UVLC(   uiCode, "conf_win_bottom_offset" );             conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) );
     592  }
     593
    703594  READ_UVLC(     uiCode, "bit_depth_luma_minus8" );
    704   g_uiBitDepth = 8 + uiCode;
    705   g_uiBitIncrement = 0;
    706   pcSPS->setBitDepth(g_uiBitDepth);
    707   pcSPS->setBitIncrement(g_uiBitIncrement);
    708   UInt m_uiSaoBitIncrease = g_uiBitDepth + (g_uiBitDepth-8) - min((Int)(g_uiBitDepth + (g_uiBitDepth-8)), 10);
    709 #else
    710   READ_UVLC(     uiCode, "bit_depth_luma_minus8" );
    711   g_uiBitDepth = 8;
    712   g_uiBitIncrement = uiCode;
    713   pcSPS->setBitDepth(g_uiBitDepth);
    714   pcSPS->setBitIncrement(g_uiBitIncrement);
    715 #endif
     595  g_bitDepthY = 8 + uiCode;
     596  pcSPS->setBitDepthY(g_bitDepthY);
    716597  pcSPS->setQpBDOffsetY( (Int) (6*uiCode) );
    717598
    718   g_uiBASE_MAX  = ((1<<(g_uiBitDepth))-1);
    719 
    720 #if IBDI_NOCLIP_RANGE
    721   g_uiIBDI_MAX  = g_uiBASE_MAX << g_uiBitIncrement;
    722 #else
    723   g_uiIBDI_MAX  = ((1<<(g_uiBitDepth+g_uiBitIncrement))-1);
    724 #endif
    725599  READ_UVLC( uiCode,    "bit_depth_chroma_minus8" );
     600  g_bitDepthC = 8 + uiCode;
     601  pcSPS->setBitDepthC(g_bitDepthC);
    726602  pcSPS->setQpBDOffsetC( (Int) (6*uiCode) );
    727603
    728   READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false );
    729 
    730   if( pcSPS->getUsePCM() )
    731   {
    732     READ_CODE( 4, uiCode, "pcm_bit_depth_luma_minus1" );           pcSPS->setPCMBitDepthLuma   ( 1 + uiCode );
    733     READ_CODE( 4, uiCode, "pcm_bit_depth_chroma_minus1" );         pcSPS->setPCMBitDepthChroma ( 1 + uiCode );
    734   }
    735 
    736604  READ_UVLC( uiCode,    "log2_max_pic_order_cnt_lsb_minus4" );   pcSPS->setBitsForPOC( 4 + uiCode );
     605
     606  UInt subLayerOrderingInfoPresentFlag;
     607  READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag");
    737608  for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
    738609  {
    739     READ_UVLC ( uiCode, "max_dec_pic_buffering");
     610    READ_UVLC ( uiCode, "sps_max_dec_pic_buffering");
    740611    pcSPS->setMaxDecPicBuffering( uiCode, i);
    741     READ_UVLC ( uiCode, "num_reorder_pics" );
     612    READ_UVLC ( uiCode, "sps_num_reorder_pics" );
    742613    pcSPS->setNumReorderPics(uiCode, i);
    743     READ_UVLC ( uiCode, "max_latency_increase");
     614    READ_UVLC ( uiCode, "sps_max_latency_increase");
    744615    pcSPS->setMaxLatencyIncrease( uiCode, i );
    745   }
    746 
    747   READ_FLAG( uiCode, "restricted_ref_pic_lists_flag" );
    748   pcSPS->setRestrictedRefPicListsFlag( uiCode );
    749   if( pcSPS->getRestrictedRefPicListsFlag() )
    750   {
    751     READ_FLAG( uiCode, "lists_modification_present_flag" );
    752     pcSPS->setListsModificationPresentFlag(uiCode);
    753   }
    754   else
    755   {
    756     pcSPS->setListsModificationPresentFlag(true);
    757   }
     616
     617    if (!subLayerOrderingInfoPresentFlag)
     618    {
     619      for (i++; i <= pcSPS->getMaxTLayers()-1; i++)
     620      {
     621        pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i);
     622        pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i);
     623        pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i);
     624      }
     625      break;
     626    }
     627  }
     628
    758629  READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" );
    759630  UInt log2MinCUSize = uiCode + 3;
     
    766637  READ_UVLC( uiCode, "log2_diff_max_min_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() );
    767638  pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) );
    768   if( pcSPS->getUsePCM() )
    769   {
    770     READ_UVLC( uiCode, "log2_min_pcm_coding_block_size_minus3" );  pcSPS->setPCMLog2MinSize (uiCode+3);
    771     READ_UVLC( uiCode, "log2_diff_max_min_pcm_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() );
    772   }
    773639
    774640  READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" );    pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 );
     
    793659    }
    794660  }
    795 #if !REMOVE_LMCHROMA
    796   READ_FLAG( uiCode, "chroma_pred_from_luma_enabled_flag" );        pcSPS->setUseLMChroma ( uiCode ? true : false );
    797 #endif
    798 #if !PPS_TS_FLAG
    799   READ_FLAG( uiCode, "transform_skip_enabled_flag" );               pcSPS->setUseTransformSkip ( uiCode ? true : false );
    800 #endif
    801 #if !MOVE_LOOP_FILTER_SLICES_FLAG
    802   READ_FLAG( uiCode, "loop_filter_across_slice_flag" );             pcSPS->setLFCrossSliceBoundaryFlag( uiCode ? true : false);
    803 #endif
    804   READ_FLAG( uiCode, "asymmetric_motion_partitions_enabled_flag" ); pcSPS->setUseAMP( uiCode );
    805 #if !REMOVE_NSQT
    806   READ_FLAG( uiCode, "non_square_quadtree_enabled_flag" );          pcSPS->setUseNSQT( uiCode );
    807 #endif
     661  READ_FLAG( uiCode, "amp_enabled_flag" );                          pcSPS->setUseAMP( uiCode );
    808662  READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" );       pcSPS->setUseSAO ( uiCode ? true : false );
    809 #if !REMOVE_ALF
    810   READ_FLAG( uiCode, "adaptive_loop_filter_enabled_flag" );         pcSPS->setUseALF ( uiCode ? true : false );
    811 #endif
     663
     664  READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false );
    812665  if( pcSPS->getUsePCM() )
    813666  {
    814     READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" );           pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false );
    815   }
    816 
    817   READ_FLAG( uiCode, "temporal_id_nesting_flag" );               pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false );
     667    READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" );          pcSPS->setPCMBitDepthLuma   ( 1 + uiCode );
     668    READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" );        pcSPS->setPCMBitDepthChroma ( 1 + uiCode );
     669    READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" );   pcSPS->setPCMLog2MinSize (uiCode+3);
     670    READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() );
     671    READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" );                 pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false );
     672  }
    818673
    819674  READ_UVLC( uiCode, "num_short_term_ref_pic_sets" );
     
    829684  }
    830685  READ_FLAG( uiCode, "long_term_ref_pics_present_flag" );          pcSPS->setLongTermRefsPresent(uiCode);
    831 #if LTRP_IN_SPS
    832686  if (pcSPS->getLongTermRefsPresent())
    833687  {
     
    837691    {
    838692      READ_CODE( pcSPS->getBitsForPOC(), uiCode, "lt_ref_pic_poc_lsb_sps" );
    839       pcSPS->setLtRefPicPocLsbSps(uiCode, k);
     693      pcSPS->setLtRefPicPocLsbSps(k, uiCode);
    840694      READ_FLAG( uiCode,  "used_by_curr_pic_lt_sps_flag[i]");
    841695      pcSPS->setUsedByCurrPicLtSPSFlag(k, uiCode?1:0);
    842696    }
    843697  }
    844 #endif
    845698  READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" );            pcSPS->setTMVPFlagsPresent(uiCode);
    846699#if REF_IDX_MFM
     
    849702    READ_FLAG( uiCode, "sps_enh_mfm_enable_flag" );
    850703    pcSPS->setMFMEnabledFlag( uiCode ? true : false );
    851     assert(pcSPS->getMFMEnabledFlag());
    852   }
    853 #endif
    854 #if SUPPORT_FOR_VUI
     704  }
     705#endif
     706  READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" );  pcSPS->setUseStrongIntraSmoothing(uiCode);
     707
    855708  READ_FLAG( uiCode, "vui_parameters_present_flag" );             pcSPS->setVuiParametersPresentFlag(uiCode);
    856709
    857710  if (pcSPS->getVuiParametersPresentFlag())
    858711  {
    859 #if !BUFFERING_PERIOD_AND_TIMING_SEI
    860     parseVUI(pcSPS->getVuiParameters());
    861 #else
    862712    parseVUI(pcSPS->getVuiParameters(), pcSPS);
    863 #endif
    864   }
    865 #endif
    866 #if !SPS_AMVP_CLEANUP
    867   // AMVP mode for each depth (AM_NONE or AM_EXPL)
    868   for (Int i = 0; i < pcSPS->getMaxCUDepth(); i++)
    869   {
    870     xReadFlag( uiCode );
    871     pcSPS->setAMVPMode( i, (AMVP_MODE)uiCode );
    872   }
    873 #endif
     713  }
     714
    874715  READ_FLAG( uiCode, "sps_extension_flag");
    875716  if (uiCode)
     
    886727  UInt  uiCode;
    887728 
    888 #if VPS_SYNTAX_CHANGES
    889   READ_CODE( 4,  uiCode,  "video_parameter_set_id" );             pcVPS->setVPSId( uiCode );
     729  READ_CODE( 4,  uiCode,  "vps_video_parameter_set_id" );         pcVPS->setVPSId( uiCode );
     730  READ_CODE( 2,  uiCode,  "vps_reserved_three_2bits" );           assert(uiCode == 3);
     731#if VPS_RENAME
     732  READ_CODE( 6,  uiCode,  "vps_max_layers_minus1" );              pcVPS->setMaxLayers( uiCode + 1);
     733#else
     734  READ_CODE( 6,  uiCode,  "vps_reserved_zero_6bits" );            assert(uiCode == 0);
     735#endif
     736  READ_CODE( 3,  uiCode,  "vps_max_sub_layers_minus1" );          pcVPS->setMaxTLayers( uiCode + 1 );
    890737  READ_FLAG(     uiCode,  "vps_temporal_id_nesting_flag" );       pcVPS->setTemporalNestingFlag( uiCode ? true:false );
    891   READ_CODE( 2,  uiCode,  "vps_reserved_zero_2bits" );            assert(uiCode == 0);
    892   READ_CODE( 6,  uiCode,  "vps_reserved_zero_6bits" );            assert(uiCode == 0);
    893   READ_CODE( 3,  uiCode,  "vps_max_sub_layers_minus1" );          pcVPS->setMaxTLayers( uiCode + 1 );
     738  assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag());
     739  READ_CODE( 16, uiCode,  "vps_reserved_ffff_16bits" );           assert(uiCode == 0xffff);
    894740  parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1);
    895   READ_CODE( 12, uiCode,  "vps_reserved_zero_12bits" );           assert(uiCode == 0);
    896 #else
    897   READ_CODE( 3, uiCode, "vps_max_temporal_layers_minus1" );   pcVPS->setMaxTLayers( uiCode + 1 );
    898   READ_CODE( 5, uiCode, "vps_max_layers_minus1" );            pcVPS->setMaxLayers( uiCode + 1 );
    899   READ_UVLC( uiCode,  "video_parameter_set_id" );             pcVPS->setVPSId( uiCode );
    900   READ_FLAG( uiCode,  "vps_temporal_id_nesting_flag" );       pcVPS->setTemporalNestingFlag( uiCode ? true:false );
    901 #endif
     741#if SIGNAL_BITRATE_PICRATE_IN_VPS
     742  parseBitratePicRateInfo( pcVPS->getBitratePicrateInfo(), 0, pcVPS->getMaxTLayers() - 1);
     743#endif
     744  UInt subLayerOrderingInfoPresentFlag;
     745  READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag");
    902746  for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++)
    903747  {
     
    905749    READ_UVLC( uiCode,  "vps_num_reorder_pics[i]" );          pcVPS->setNumReorderPics( uiCode, i );
    906750    READ_UVLC( uiCode,  "vps_max_latency_increase[i]" );      pcVPS->setMaxLatencyIncrease( uiCode, i );
    907   }
    908 #if VPS_SYNTAX_CHANGES
    909   READ_UVLC( uiCode,    "vps_num_hrd_parameters" );           assert(uiCode == 0);
    910   // hrd_parameters
    911 #endif 
    912   READ_FLAG( uiCode,  "vps_extension_flag" );          assert(!uiCode);
    913   //future extensions go here..
     751
     752    if (!subLayerOrderingInfoPresentFlag)
     753    {
     754      for (i++; i <= pcVPS->getMaxTLayers()-1; i++)
     755      {
     756        pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i);
     757        pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i);
     758        pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i);
     759      }
     760      break;
     761    }
     762  }
     763
     764#if VPS_RENAME
     765  assert( pcVPS->getNumHrdParameters() < MAX_VPS_LAYER_SETS_PLUS1 );
     766  assert( pcVPS->getMaxLayerId()       < MAX_VPS_LAYER_ID_PLUS1 );
     767  READ_CODE( 6, uiCode, "vps_max_layer_id" );           pcVPS->setMaxLayerId( uiCode );
     768  READ_UVLC(    uiCode, "vps_num_layer_sets_minus1" );  pcVPS->setNumLayerSets( uiCode + 1 );
     769  for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getNumLayerSets() - 1 ); opsIdx ++ )
     770  {
     771    // Operation point set
     772    for( UInt i = 0; i <= pcVPS->getMaxLayerId(); i ++ )
     773#else
     774  assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 );
     775  assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 );
     776  READ_CODE( 6, uiCode, "vps_max_nuh_reserved_zero_layer_id" );   pcVPS->setMaxNuhReservedZeroLayerId( uiCode );
     777  READ_UVLC(    uiCode, "vps_max_op_sets_minus1" );               pcVPS->setMaxOpSets( uiCode + 1 );
     778  for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ )
     779  {
     780    // Operation point set
     781    for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ )
     782#endif
     783    {
     784      READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" );   pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i );
     785    }
     786  }
     787#if L0043_TIMING_INFO
     788  TimingInfo *timingInfo = pcVPS->getTimingInfo();
     789  READ_FLAG(       uiCode, "vps_timing_info_present_flag");         timingInfo->setTimingInfoPresentFlag      (uiCode ? true : false);
     790  if(timingInfo->getTimingInfoPresentFlag())
     791  {
     792    READ_CODE( 32, uiCode, "vps_num_units_in_tick");                timingInfo->setNumUnitsInTick             (uiCode);
     793    READ_CODE( 32, uiCode, "vps_time_scale");                       timingInfo->setTimeScale                  (uiCode);
     794    READ_FLAG(     uiCode, "vps_poc_proportional_to_timing_flag");  timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false);
     795    if(timingInfo->getPocProportionalToTimingFlag())
     796    {
     797      READ_UVLC(   uiCode, "vps_num_ticks_poc_diff_one_minus1");    timingInfo->setNumTicksPocDiffOneMinus1   (uiCode);
     798    }
     799#endif
     800    READ_UVLC( uiCode, "vps_num_hrd_parameters" );                  pcVPS->setNumHrdParameters( uiCode );
     801
     802    if( pcVPS->getNumHrdParameters() > 0 )
     803    {
     804      pcVPS->createHrdParamBuffer();
     805    }
     806    for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ )
     807    {
     808      READ_UVLC( uiCode, "hrd_op_set_idx" );                       pcVPS->setHrdOpSetIdx( uiCode, i );
     809      if( i > 0 )
     810      {
     811        READ_FLAG( uiCode, "cprms_present_flag[i]" );               pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i );
     812      }
     813      parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1);
     814    }
     815#if L0043_TIMING_INFO
     816  }
     817#endif
     818  READ_FLAG( uiCode,  "vps_extension_flag" );
     819  if (uiCode)
     820  {
     821#if VPS_EXTNS
     822    parseVPSExtension(pcVPS);
     823    READ_FLAG( uiCode, "vps_entension2_flag" );
     824    if(uiCode)
     825    {
     826      while ( xMoreRbspData() )
     827      {
     828        READ_FLAG( uiCode, "vps_extension_data_flag");
     829      }
     830    }
     831#else
     832    while ( xMoreRbspData() )
     833    {
     834      READ_FLAG( uiCode, "vps_extension_data_flag");
     835    }
     836#endif
     837  }
    914838 
    915839  return;
    916840}
    917841
     842#if VPS_EXTNS
     843Void TDecCavlc::parseVPSExtension(TComVPS *vps)
     844
     845  UInt uiCode;
     846  // ... More syntax elements to be parsed here
     847#if VPS_EXTN_MASK_AND_DIM_INFO
     848  UInt numScalabilityTypes = 0, i = 0, j = 0;
     849
     850  READ_FLAG( uiCode, "avc_base_layer_flag" ); vps->setAvcBaseLayerFlag(uiCode ? true : false);
     851  READ_FLAG( uiCode, "splitting_flag" ); vps->setSplittingFlag(uiCode ? true : false);
     852
     853  for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++)
     854  {
     855    READ_FLAG( uiCode, "scalability_mask[i]" ); vps->setScalabilityMask(i, uiCode ? true : false);
     856    numScalabilityTypes += uiCode;
     857    if( i != 1 )
     858    {
     859      // Multiview and reserved masks are not used in this version of software
     860      assert( uiCode == 0 );
     861    }
     862  }
     863  vps->setNumScalabilityTypes(numScalabilityTypes);
     864
     865  for(j = 0; j < numScalabilityTypes; j++)
     866  {
     867    READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); vps->setDimensionIdLen(j, uiCode + 1);
     868  }
     869  if(vps->getSplittingFlag())
     870  {
     871    UInt numBits = 0;
     872    for(j = 0; j < numScalabilityTypes; j++)
     873    {
     874      numBits += vps->getDimensionIdLen(j);
     875    }
     876    assert( numBits <= 6 );
     877  }
     878
     879  READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); vps->setNuhLayerIdPresentFlag(uiCode ? true : false);
     880  vps->setLayerIdInNuh(0, 0);
     881  vps->setLayerIdInVps(0, 0);
     882  for(i = 1; i < vps->getMaxLayers(); i++)
     883  {
     884    if( vps->getNuhLayerIdPresentFlag() )
     885    {
     886      READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); vps->setLayerIdInNuh(i, uiCode);
     887      assert( uiCode > vps->getLayerIdInNuh(i-1) );
     888    }
     889    else
     890    {
     891      vps->setLayerIdInNuh(i, i);
     892    }
     893    vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i);
     894
     895    for(j = 0; j < numScalabilityTypes; j++)
     896    {
     897      READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode);
     898      assert( uiCode <= vps->getMaxLayerId() );
     899    }
     900  }
     901#endif
     902
     903#if VPS_EXTN_PROFILE_INFO
     904  // Profile-tier-level signalling
     905  vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets());
     906  for(Int idx = 1; idx <= vps->getNumLayerSets() - 1; idx++)
     907  {
     908    READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); vps->setProfilePresentFlag(idx, uiCode ? true : false);
     909    if( !vps->getProfilePresentFlag(idx) )
     910    {
     911      READ_UVLC( uiCode, "vps_profile_layer_set_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1);
     912      assert( vps->getProfileLayerSetRef(idx) < idx );
     913      // Copy profile information as indicated
     914      vps->getPTLForExtn(idx)->copyProfileInfo( vps->getPTLForExtn( vps->getProfileLayerSetRef(idx) ) );
     915    }   
     916    parsePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 );
     917  }
     918#endif
     919
     920#if VPS_EXTN_OP_LAYER_SETS
     921  // Target output layer signalling
     922  READ_UVLC( uiCode,            "vps_num_output_layer_sets"); vps->setNumOutputLayerSets(uiCode);
     923  for(i = 0; i < vps->getNumOutputLayerSets(); i++)
     924  {
     925    READ_UVLC( uiCode,           "vps_output_layer_set_idx[i]"); vps->setOutputLayerSetIdx(i, uiCode);
     926    Int lsIdx = vps->getOutputLayerSetIdx(i);
     927    for(j = 0; j <= vps->getMaxLayerId(); j++)
     928    {
     929      if(vps->getLayerIdIncludedFlag(lsIdx, j))
     930      {
     931        READ_FLAG( uiCode, "vps_output_layer_flag[lsIdx][j]"); vps->setOutputLayerFlag(lsIdx, j, uiCode);
     932      }
     933    }
     934  } 
     935#endif
     936#if VPS_EXTN_DIRECT_REF_LAYERS
     937  // For layer 0
     938  vps->setNumDirectRefLayers(0, 0);
     939  // For other layers
     940  for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     941  {
     942    UInt numDirectRefLayers = 0;
     943    for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
     944    {
     945      READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false);
     946      if(uiCode)
     947      {
     948        vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr);
     949        numDirectRefLayers++;
     950      }
     951    }
     952    vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers);
     953  }
     954#endif
     955}
     956#endif
     957
    918958Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager)
    919959{
     
    927967  TComSPS* sps = NULL;
    928968
    929   UInt firstSliceInPic;
    930   READ_FLAG( firstSliceInPic, "first_slice_in_pic_flag" );
    931 #if SPLICING_FRIENDLY_PARAMS
     969  UInt firstSliceSegmentInPic;
     970  READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" );
    932971  if( rpcSlice->getRapPicFlag())
    933972  {
    934973    READ_FLAG( uiCode, "no_output_of_prior_pics_flag" );  //ignored
    935974  }
    936 #endif
    937   READ_UVLC (    uiCode, "pic_parameter_set_id" );  rpcSlice->setPPSId(uiCode);
     975  READ_UVLC (    uiCode, "slice_pic_parameter_set_id" );  rpcSlice->setPPSId(uiCode);
    938976  pps = parameterSetManager->getPrefetchedPPS(uiCode);
    939977  //!KS: need to add error handling code here, if PPS is not available
     
    944982  rpcSlice->setSPS(sps);
    945983  rpcSlice->setPPS(pps);
    946 
    947   Int numCUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight());
     984  if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic ))
     985  {
     986    READ_FLAG( uiCode, "dependent_slice_segment_flag" );       rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false);
     987  }
     988  else
     989  {
     990    rpcSlice->setDependentSliceSegmentFlag(false);
     991  }
     992  Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight());
    948993  Int maxParts = (1<<(sps->getMaxCUDepth()<<1));
    949 #if REMOVE_FGS
    950   Int numParts = 0;
    951 #else
    952   Int numParts = (1<<(pps->getSliceGranularity()<<1));
    953 #endif
    954   UInt lCUAddress = 0;
    955   Int reqBitsOuter = 0;
    956   while(numCUs>(1<<reqBitsOuter))
    957   {
    958     reqBitsOuter++;
    959   }
    960   Int reqBitsInner = 0;
    961   while((numParts)>(1<<reqBitsInner))
    962   {
    963     reqBitsInner++;
    964   }
    965 
    966   UInt innerAddress = 0;
    967   Int  sliceAddress = 0;
    968   if(!firstSliceInPic)
    969   {
    970     UInt address;
    971     READ_CODE( reqBitsOuter+reqBitsInner, address, "slice_address" );
    972     lCUAddress = address >> reqBitsInner;
    973     innerAddress = address - (lCUAddress<<reqBitsInner);
     994  UInt sliceSegmentAddress = 0;
     995  Int bitsSliceSegmentAddress = 0;
     996  while(numCTUs>(1<<bitsSliceSegmentAddress))
     997  {
     998    bitsSliceSegmentAddress++;
     999  }
     1000
     1001  if(!firstSliceSegmentInPic)
     1002  {
     1003    READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" );
    9741004  }
    9751005  //set uiCode to equal slice start address (or dependent slice start address)
    976 #if REMOVE_FGS
    977   sliceAddress=(maxParts*lCUAddress)+(innerAddress);
    978 #else
    979   sliceAddress=(maxParts*lCUAddress)+(innerAddress*(maxParts>>(pps->getSliceGranularity()<<1)));
    980 #endif
    981   rpcSlice->setDependentSliceCurStartCUAddr( sliceAddress );
    982   rpcSlice->setDependentSliceCurEndCUAddr(numCUs*maxParts);
    983 
    984 #if SLICEHEADER_SYNTAX_FIX
    985   if( pps->getDependentSliceEnabledFlag() && (sliceAddress !=0 ))
    986   {
    987     READ_FLAG( uiCode, "dependent_slice_flag" );       rpcSlice->setDependentSliceFlag(uiCode ? true : false);
     1006  Int startCuAddress = maxParts*sliceSegmentAddress;
     1007  rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress );
     1008  rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts);
     1009
     1010  if (rpcSlice->getDependentSliceSegmentFlag())
     1011  {
     1012    rpcSlice->setNextSlice          ( false );
     1013    rpcSlice->setNextSliceSegment ( true  );
    9881014  }
    9891015  else
    9901016  {
    991     rpcSlice->setDependentSliceFlag(false);
    992   }
    993 
    994   if (rpcSlice->getDependentSliceFlag())
    995   {
    996     rpcSlice->setNextSlice          ( false );
    997     rpcSlice->setNextDependentSlice ( true  );
    998   }
    999   else
    1000   {
    10011017    rpcSlice->setNextSlice          ( true  );
    1002     rpcSlice->setNextDependentSlice ( false );
    1003 
    1004     rpcSlice->setSliceCurStartCUAddr(sliceAddress);
    1005     rpcSlice->setSliceCurEndCUAddr(numCUs*maxParts);
     1018    rpcSlice->setNextSliceSegment ( false );
     1019
     1020    rpcSlice->setSliceCurStartCUAddr(startCuAddress);
     1021    rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts);
    10061022  }
    10071023 
    1008   if(!rpcSlice->getDependentSliceFlag())
    1009   {
    1010 #endif
     1024  if(!rpcSlice->getDependentSliceSegmentFlag())
     1025  {
     1026    for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++)
     1027    {
     1028      READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored
     1029    }
     1030
    10111031    READ_UVLC (    uiCode, "slice_type" );            rpcSlice->setSliceType((SliceType)uiCode);
    1012 #if !SLICEHEADER_SYNTAX_FIX
    1013     // lightweight_slice_flag
    1014     READ_FLAG( uiCode, "dependent_slice_flag" );
    1015     Bool bDependentSlice = uiCode ? true : false;
    1016 #if DEPENDENT_SLICES
    1017     if( rpcSlice->getPPS()->getDependentSliceEnabledFlag())
    1018     {
    1019       if(bDependentSlice)
    1020       {
    1021         rpcSlice->setNextSlice        ( false );
    1022         rpcSlice->setNextDependentSlice( true  );
    1023 #if BYTE_ALIGNMENT
    1024         m_pcBitstream->readByteAlignment();
    1025 #else
    1026         m_pcBitstream->readOutTrailingBits();
    1027 #endif
    1028         return;
    1029       }
    1030     }
    1031 #endif
    1032   if (bDependentSlice)
    1033   {
    1034     rpcSlice->setNextSlice        ( false );
    1035     rpcSlice->setNextDependentSlice ( true  );
    1036   }
    1037   else
    1038   {
    1039     rpcSlice->setNextSlice        ( true  );
    1040     rpcSlice->setNextDependentSlice ( false );
    1041 
    1042     rpcSlice->setSliceCurStartCUAddr(sliceAddress);
    1043     rpcSlice->setSliceCurEndCUAddr(numCUs*maxParts);
    1044   }
    1045 
    1046   if (!bDependentSlice)
    1047   {
    1048 #endif // !SLICEHEADER_SYNTAX_FIX
    10491032    if( pps->getOutputFlagPresentFlag() )
    10501033    {
     
    10601043    //   colour_plane_id                                      u(2)
    10611044
    1062 #if !SPLICING_FRIENDLY_PARAMS
    1063     if(   rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR
    1064 #if SUPPORT_FOR_RAP_N_LP
    1065       || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP
    1066       || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
    1067 #endif
    1068       || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
    1069       || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    1070 #if !NAL_UNIT_TYPES_J1003_D7
    1071       || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRANT
    1072 #endif
    1073       || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA )
    1074     {
    1075       READ_UVLC( uiCode, "rap_pic_id" );  //ignored
    1076       READ_FLAG( uiCode, "no_output_of_prior_pics_flag" );  //ignored
    1077     }
    1078 #endif
    1079 #if SUPPORT_FOR_RAP_N_LP
    10801045    if( rpcSlice->getIdrPicFlag() )
    1081 #else
    1082     if( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR )
    1083 #endif
    10841046    {
    10851047      rpcSlice->setPOC(0);
     
    11121074        iPOCmsb = iPrevPOCmsb;
    11131075      }
    1114 #if SUPPORT_FOR_RAP_N_LP
    11151076      if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    11161077        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
    11171078        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
    1118 #else
    1119       if(   rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    1120         || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT )
    1121 #endif
    11221079      {
    11231080        // For BLA picture types, POCmsb is set to 0.
     
    11361093      else // use reference to short-term reference picture set in PPS
    11371094      {
    1138         READ_UVLC( uiCode, "short_term_ref_pic_set_idx"); rpcSlice->setRPS(sps->getRPSList()->getReferencePictureSet(uiCode));
     1095        Int numBits = 0;
     1096        while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets())
     1097        {
     1098          numBits++;
     1099        }
     1100        if (numBits > 0)
     1101        {
     1102          READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx");
     1103        }
     1104        else
     1105        {
     1106          uiCode = 0;
     1107        }
     1108        rpcSlice->setRPS(sps->getRPSList()->getReferencePictureSet(uiCode));
     1109
    11391110        rps = rpcSlice->getRPS();
    11401111      }
     
    11421113      {
    11431114        Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures();
    1144 #if LTRP_IN_SPS
    11451115        UInt numOfLtrp = 0;
    11461116        UInt numLtrpInSPS = 0;
     
    11521122          rps->setNumberOfLongtermPictures(numOfLtrp);
    11531123        }
    1154         Int bitsForLtrpInSPS = 1;
     1124        Int bitsForLtrpInSPS = 0;
    11551125        while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS))
     1126        {
    11561127          bitsForLtrpInSPS++;
     1128        }
    11571129        READ_UVLC( uiCode, "num_long_term_pics");             rps->setNumberOfLongtermPictures(uiCode);
    11581130        numOfLtrp += uiCode;
    11591131        rps->setNumberOfLongtermPictures(numOfLtrp);
    1160 #else
    1161         READ_UVLC( uiCode, "num_long_term_pics");             rps->setNumberOfLongtermPictures(uiCode);
    1162 #endif
    11631132        Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC();
    11641133        Int prevLSB = 0, prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;;
    1165 #if LTRP_IN_SPS
    11661134        for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++)
    1167 #else
    1168         for(Int j=offset+rps->getNumberOfLongtermPictures()-1 ; j > offset-1; j--)
    1169 #endif
    1170         {
    1171 #if LTRP_IN_SPS
     1135        {
     1136          Int pocLsbLt;
    11721137          if (k < numLtrpInSPS)
    11731138          {
    1174             READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]");
     1139            uiCode = 0;
     1140            if (bitsForLtrpInSPS > 0)
     1141            {
     1142              READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]");
     1143            }
    11751144            Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode);
    11761145
    1177             uiCode = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode);
     1146            pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode);
    11781147            rps->setUsed(j,usedByCurrFromSPS);
    11791148          }
    11801149          else
    11811150          {
    1182             READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt");
     1151            READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode;
    11831152            READ_FLAG( uiCode, "used_by_curr_pic_lt_flag");     rps->setUsed(j,uiCode);
    11841153          }
    1185 #else
    1186           READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt");
    1187 #endif
    1188           Int poc_lsb_lt = uiCode;
    11891154          READ_FLAG(uiCode,"delta_poc_msb_present_flag");
    11901155          Bool mSBPresentFlag = uiCode ? true : false;
     
    11931158            READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" );
    11941159            Bool deltaFlag = false;
    1195 #if LTRP_IN_SPS
    11961160            //            First LTRP                               || First LTRP from SH           || curr LSB    != prev LSB
    1197             if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) || (poc_lsb_lt != prevLSB) )
    1198 #else
    1199             //            First LTRP                               || curr LSB    != prev LSB
    1200             if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (poc_lsb_lt != prevLSB) )
    1201 #endif
     1161            if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) || (pocLsbLt != prevLSB) )
    12021162            {
    12031163              deltaFlag = true;
     
    12131173
    12141174            Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB
    1215                                         - iPOClsb + poc_lsb_lt;                                     
     1175                                        - iPOClsb + pocLsbLt;
    12161176            rps->setPOC     (j, pocLTCurr);
    12171177            rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr);
     
    12201180          else
    12211181          {
    1222             rps->setPOC     (j, poc_lsb_lt);
    1223             rps->setDeltaPOC(j, - rpcSlice->getPOC() + poc_lsb_lt);
     1182            rps->setPOC     (j, pocLsbLt);
     1183            rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt);
    12241184            rps->setCheckLTMSBPresent(j,false); 
    12251185          }
    1226 #if !LTRP_IN_SPS
    1227         READ_FLAG( uiCode, "used_by_curr_pic_lt_flag");     rps->setUsed(j,uiCode);
    1228 #endif
    1229           prevLSB = poc_lsb_lt;
     1186          prevLSB = pocLsbLt;
    12301187          prevDeltaMSB = deltaPocMSBCycleLT;
    12311188        }
     
    12331190        rps->setNumberOfPictures(offset);       
    12341191      } 
    1235 #if SUPPORT_FOR_RAP_N_LP
    12361192      if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    12371193        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
    12381194        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
    1239 #else
    1240       if(   rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    1241         || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT )
    1242 #endif
    12431195      {
    12441196        // In the case of BLA picture types, rps data is read from slice header but ignored
     
    12501202        rpcSlice->setRPS(rps);
    12511203      }
    1252     }
    1253 #if REMOVE_ALF
     1204      if (rpcSlice->getSPS()->getTMVPFlagsPresent())
     1205      {
     1206        READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" );
     1207        rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false );
     1208      }
     1209      else
     1210      {
     1211        rpcSlice->setEnableTMVPFlag(false);
     1212      }
     1213    }
    12541214    if(sps->getUseSAO())
    1255 #else
    1256     if(sps->getUseSAO() || sps->getUseALF())
    1257 #endif
    1258     {
    1259       if (sps->getUseSAO())
    1260       {
    1261         READ_FLAG(uiCode, "slice_sao_luma_flag");  rpcSlice->setSaoEnabledFlag((Bool)uiCode);
    1262 #if !SAO_LUM_CHROMA_ONOFF_FLAGS
    1263         if (rpcSlice->getSaoEnabledFlag() )
    1264 #endif
    1265         {
    1266 #if SAO_TYPE_SHARING
    1267           READ_FLAG(uiCode, "slice_sao_chroma_flag");  rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode);
    1268 #else
    1269           READ_FLAG(uiCode, "sao_cb_enable_flag");  rpcSlice->setSaoEnabledFlagCb((Bool)uiCode);
    1270           READ_FLAG(uiCode, "sao_cr_enable_flag");  rpcSlice->setSaoEnabledFlagCr((Bool)uiCode);
    1271 #endif
    1272         }
    1273 #if !SAO_LUM_CHROMA_ONOFF_FLAGS
    1274         else
    1275         {
    1276 #if SAO_TYPE_SHARING
    1277           rpcSlice->setSaoEnabledFlagChroma(0);
    1278 #else
    1279           rpcSlice->setSaoEnabledFlagCb(0);
    1280           rpcSlice->setSaoEnabledFlagCr(0);
    1281 #endif
    1282         }
    1283 #endif
    1284       }
    1285 #if !REMOVE_APS
    1286       READ_UVLC (    uiCode, "aps_id" );  rpcSlice->setAPSId(uiCode);
    1287 #endif
     1215    {
     1216      READ_FLAG(uiCode, "slice_sao_luma_flag");  rpcSlice->setSaoEnabledFlag((Bool)uiCode);
     1217      READ_FLAG(uiCode, "slice_sao_chroma_flag");  rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode);
     1218    }
     1219
     1220    if (rpcSlice->getIdrPicFlag())
     1221    {
     1222      rpcSlice->setEnableTMVPFlag(false);
    12881223    }
    12891224    if (!rpcSlice->isIntra())
    12901225    {
    1291       if (rpcSlice->getSPS()->getTMVPFlagsPresent())
    1292       {
    1293         READ_FLAG( uiCode, "enable_temporal_mvp_flag" );
    1294         rpcSlice->setEnableTMVPFlag(uiCode);
    1295       }
    1296       else
    1297       {
    1298         rpcSlice->setEnableTMVPFlag(false);
    1299       }
     1226
    13001227      READ_FLAG( uiCode, "num_ref_idx_active_override_flag");
    13011228      if (uiCode)
     
    13281255    if(!rpcSlice->isIntra())
    13291256    {
    1330       if( !rpcSlice->getSPS()->getListsModificationPresentFlag() )
     1257      if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 )
    13311258      {
    13321259        refPicListModification->setRefPicListModificationFlagL0( 0 );
     
    13711298    if(rpcSlice->isInterB())
    13721299    {
    1373       if( !rpcSlice->getSPS()->getListsModificationPresentFlag() )
     1300      if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 )
    13741301      {
    13751302        refPicListModification->setRefPicListModificationFlagL1( 0 );
     
    14111338      refPicListModification->setRefPicListModificationFlagL1(0);
    14121339    }
    1413 #if !SLICEHEADER_SYNTAX_FIX
    1414   }
    1415   else
    1416   {
    1417     // initialize from previous slice
    1418     pps = rpcSlice->getPPS();
    1419     sps = rpcSlice->getSPS();
    1420   }
    1421 #endif
    14221340    if (rpcSlice->isInterB())
    14231341    {
     
    14321350    }
    14331351
    1434 #if !SLICEHEADER_SYNTAX_FIX
    1435   if(!bDependentSlice)
    1436   {
    1437 #else
    14381352    if ( rpcSlice->getEnableTMVPFlag() )
    14391353    {
     
    14491363
    14501364      if ( rpcSlice->getSliceType() != I_SLICE &&
    1451         ((rpcSlice->getColFromL0Flag()==1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0)>1)||
    1452         (rpcSlice->getColFromL0Flag() ==0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1)>1)))
     1365          ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)||
     1366           (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1)))
    14531367      {
    14541368        READ_UVLC( uiCode, "collocated_ref_idx" );
     
    14651379      rpcSlice->initWpScaling();
    14661380    }
    1467     READ_UVLC( uiCode, "five_minus_max_num_merge_cand");
    1468     rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode);
    1469 
    1470 #endif
    1471     READ_SVLC( iCode, "slice_qp_delta" );
     1381    if (!rpcSlice->isIntra())
     1382    {
     1383      READ_UVLC( uiCode, "five_minus_max_num_merge_cand");
     1384      rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode);
     1385    }
     1386
     1387    READ_SVLC( iCode, "slice_qp_delta" );
    14721388    rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode);
    14731389
     
    14751391    assert( rpcSlice->getSliceQp() <=  51 );
    14761392
    1477 #if CHROMA_QP_EXTENSION
    14781393    if (rpcSlice->getPPS()->getSliceChromaQpFlag())
    14791394    {
     
    14921407      assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <=  12 );
    14931408    }
    1494 #endif
    14951409
    14961410    if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag())
     
    15201434      }
    15211435    }
    1522 #if !SLICEHEADER_SYNTAX_FIX
    1523     if ( rpcSlice->getEnableTMVPFlag() )
    1524     {
    1525       if ( rpcSlice->getSliceType() == B_SLICE )
    1526       {
    1527         READ_FLAG( uiCode, "collocated_from_l0_flag" );
    1528         rpcSlice->setColFromL0Flag(uiCode);
    1529       }
    1530 
    1531       if ( rpcSlice->getSliceType() != I_SLICE &&
    1532         ((rpcSlice->getColFromL0Flag()==1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0)>1)||
    1533         (rpcSlice->getColFromL0Flag() ==0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1)>1)))
    1534       {
    1535         READ_UVLC( uiCode, "collocated_ref_idx" );
    1536         rpcSlice->setColRefIdx(uiCode);
    1537       }
    1538       else
    1539       {
    1540         rpcSlice->setColRefIdx(0);
    1541       }
    1542     }
    1543     if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) )
    1544     {
    1545       xParsePredWeightTable(rpcSlice);
    1546       rpcSlice->initWpScaling();
    1547     }
    1548   }
    1549 
    1550     READ_UVLC( uiCode, "five_minus_max_num_merge_cand");
    1551     rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode);
    1552 
    1553   if (!bDependentSlice)
    1554   {
    1555 #endif
    1556 #if !REMOVE_ALF
    1557     if(sps->getUseALF())
    1558     {
    1559       char syntaxString[50];
    1560       for(Int compIdx=0; compIdx< 3; compIdx++)
    1561       {
    1562         sprintf(syntaxString, "alf_slice_filter_flag[%d]", compIdx);
    1563         READ_FLAG(uiCode, syntaxString);
    1564         rpcSlice->setAlfEnabledFlag( (uiCode ==1), compIdx);
    1565       }
    1566     }
    1567     Bool isAlfEnabled = (!rpcSlice->getSPS()->getUseALF())?(false):(rpcSlice->getAlfEnabledFlag(0)||rpcSlice->getAlfEnabledFlag(1)||rpcSlice->getAlfEnabledFlag(2));
    1568 #endif
    1569 #if !SAO_LUM_CHROMA_ONOFF_FLAGS
    1570     Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag());
     1436    else
     1437    { 
     1438      rpcSlice->setDeblockingFilterDisable       ( false );
     1439      rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 );
     1440      rpcSlice->setDeblockingFilterTcOffsetDiv2  ( 0 );
     1441    }
     1442
     1443    Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma());
     1444    Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable());
     1445
     1446    if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled ))
     1447    {
     1448      READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag");
     1449    }
     1450    else
     1451    {
     1452      uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0;
     1453    }
     1454    rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false);
     1455
     1456  }
     1457 
     1458  if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )
     1459  {
     1460    UInt *entryPointOffset          = NULL;
     1461    UInt numEntryPointOffsets, offsetLenMinus1;
     1462
     1463    READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets );
     1464    if (numEntryPointOffsets>0)
     1465    {
     1466      READ_UVLC(offsetLenMinus1, "offset_len_minus1");
     1467    }
     1468    entryPointOffset = new UInt[numEntryPointOffsets];
     1469    for (UInt idx=0; idx<numEntryPointOffsets; idx++)
     1470    {
     1471#if L0116_ENTRY_POINT
     1472      READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1");
     1473      entryPointOffset[ idx ] = uiCode + 1;
    15711474#else
    1572     Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma());
    1573 #endif
    1574     Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable());
    1575 
    1576 #if REMOVE_ALF
    1577 #if MOVE_LOOP_FILTER_SLICES_FLAG
    1578     if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled ))
    1579 #else
    1580     if(rpcSlice->getSPS()->getLFCrossSliceBoundaryFlag() && ( isSAOEnabled || isDBFEnabled ))
    1581 #endif
    1582 #else
    1583     if(rpcSlice->getSPS()->getLFCrossSliceBoundaryFlag() && ( isAlfEnabled || isSAOEnabled || isDBFEnabled ))
    1584 #endif
    1585     {
    1586       READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag");
    1587     }
    1588     else
    1589     {
    1590 #if MOVE_LOOP_FILTER_SLICES_FLAG
    1591       uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0;
    1592 #else
    1593       uiCode = rpcSlice->getSPS()->getLFCrossSliceBoundaryFlag()?1:0;
    1594 #endif
    1595     }
    1596     rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false);
    1597 
    1598 #if !SLICEHEADER_SYNTAX_FIX
    1599   }
    1600 #else
    1601   }
    1602     if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )
    1603 #endif
    1604     {
    1605 #if !SLICEHEADER_SYNTAX_FIX
    1606       Int tilesOrEntropyCodingSyncIdc = pps->getTilesOrEntropyCodingSyncIdc();
    1607 #endif
    1608       UInt *entryPointOffset          = NULL;
    1609       UInt numEntryPointOffsets, offsetLenMinus1;
    1610 
    1611 #if !SLICEHEADER_SYNTAX_FIX
    1612       rpcSlice->setNumEntryPointOffsets ( 0 ); // default
    1613 
    1614       if (tilesOrEntropyCodingSyncIdc>0)
    1615       {
    1616 #endif
    1617       READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets );
    1618       if (numEntryPointOffsets>0)
    1619       {
    1620         READ_UVLC(offsetLenMinus1, "offset_len_minus1");
    1621       }
    1622       entryPointOffset = new UInt[numEntryPointOffsets];
    1623       for (UInt idx=0; idx<numEntryPointOffsets; idx++)
    1624       {
    1625         READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset");
    1626         entryPointOffset[ idx ] = uiCode;
    1627       }
    1628 #if !SLICEHEADER_SYNTAX_FIX
    1629       }
    1630 #endif
    1631 
    1632 #if !SLICEHEADER_SYNTAX_FIX
    1633       if ( tilesOrEntropyCodingSyncIdc == 1 ) // tiles
    1634 #else
    1635       if ( pps->getTilesEnabledFlag() )
    1636 #endif
    1637       {
    1638         rpcSlice->setTileLocationCount( numEntryPointOffsets );
    1639 
    1640         UInt prevPos = 0;
    1641         for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++)
    1642         {
    1643           rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] );
    1644           prevPos += entryPointOffset[ idx ];
    1645         }
    1646       }
    1647 #if !SLICEHEADER_SYNTAX_FIX
    1648       else if ( tilesOrEntropyCodingSyncIdc == 2 ) // wavefront
    1649 #else
    1650       else if ( pps->getEntropyCodingSyncEnabledFlag() )
    1651 #endif
    1652       {
    1653       Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1;
    1654         rpcSlice->allocSubstreamSizes(numSubstreams);
    1655         UInt *pSubstreamSizes       = rpcSlice->getSubstreamSizes();
    1656         for (Int idx=0; idx<numSubstreams-1; idx++)
    1657         {
    1658           if ( idx < numEntryPointOffsets )
    1659           {
    1660             pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ;
    1661           }
    1662           else
    1663           {
    1664             pSubstreamSizes[ idx ] = 0;
    1665           }
    1666         }
    1667       }
    1668 
    1669       if (entryPointOffset)
    1670       {
    1671         delete [] entryPointOffset;
    1672       }
    1673     }
    1674 #if SLICEHEADER_SYNTAX_FIX
    1675     else
    1676     {
    1677       rpcSlice->setNumEntryPointOffsets ( 0 );
    1678     }
    1679 #endif
    1680 
    1681 #if SLICE_HEADER_EXTENSION
     1475      READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset");
     1476      entryPointOffset[ idx ] = uiCode;
     1477#endif
     1478    }
     1479
     1480    if ( pps->getTilesEnabledFlag() )
     1481    {
     1482      rpcSlice->setTileLocationCount( numEntryPointOffsets );
     1483
     1484      UInt prevPos = 0;
     1485      for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++)
     1486      {
     1487        rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] );
     1488        prevPos += entryPointOffset[ idx ];
     1489      }
     1490    }
     1491    else if ( pps->getEntropyCodingSyncEnabledFlag() )
     1492    {
     1493    Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1;
     1494      rpcSlice->allocSubstreamSizes(numSubstreams);
     1495      UInt *pSubstreamSizes       = rpcSlice->getSubstreamSizes();
     1496      for (Int idx=0; idx<numSubstreams-1; idx++)
     1497      {
     1498        if ( idx < numEntryPointOffsets )
     1499        {
     1500          pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ;
     1501        }
     1502        else
     1503        {
     1504          pSubstreamSizes[ idx ] = 0;
     1505        }
     1506      }
     1507    }
     1508
     1509    if (entryPointOffset)
     1510    {
     1511      delete [] entryPointOffset;
     1512    }
     1513  }
     1514  else
     1515  {
     1516    rpcSlice->setNumEntryPointOffsets ( 0 );
     1517  }
     1518
    16821519  if(pps->getSliceHeaderExtensionPresentFlag())
    16831520  {
     
    16891526    }
    16901527  }
    1691 #endif
    1692 #if BYTE_ALIGNMENT
    16931528  m_pcBitstream->readByteAlignment();
    1694 #else
    1695   if (!bDependentSlice)
    1696   {
    1697     // Reading location information
    1698     // read out trailing bits
    1699     m_pcBitstream->readOutTrailingBits();
    1700   }
    1701 #endif
    17021529  return;
    17031530}
    17041531 
    1705 #if PROFILE_TIER_LEVEL_SYNTAX
    17061532Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 )
    17071533{
     
    17131539  READ_CODE( 8, uiCode, "general_level_idc" );    rpcPTL->getGeneralPTL()->setLevelIdc(uiCode);
    17141540
     1541#if L0363_BYTE_ALIGN
     1542  for (Int i = 0; i < maxNumSubLayersMinus1; i++)
     1543  {
     1544    if(profilePresentFlag)
     1545    {
     1546      READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode);
     1547    }
     1548    READ_FLAG( uiCode, "sub_layer_level_present_flag[i]"   ); rpcPTL->setSubLayerLevelPresentFlag  (i, uiCode);
     1549  }
     1550 
     1551  if (maxNumSubLayersMinus1 > 0)
     1552  {
     1553    for (Int i = maxNumSubLayersMinus1; i < 8; i++)
     1554    {
     1555      READ_CODE(2, uiCode, "reserved_zero_2bits");
     1556      assert(uiCode == 0);
     1557    }
     1558  }
     1559#endif
     1560 
    17151561  for(Int i = 0; i < maxNumSubLayersMinus1; i++)
    17161562  {
    1717     READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode);
     1563#if !L0363_BYTE_ALIGN
     1564    if(profilePresentFlag)
     1565    {
     1566      READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode);
     1567    }
    17181568    READ_FLAG( uiCode, "sub_layer_level_present_flag[i]"   ); rpcPTL->setSubLayerLevelPresentFlag  (i, uiCode);
     1569#endif
    17191570    if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) )
    17201571    {
     
    17271578  }
    17281579}
     1580
    17291581Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl)
    17301582{
     
    17371589    READ_FLAG(  uiCode, "XXX_profile_compatibility_flag[][j]");   ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0);
    17381590  }
    1739   READ_CODE(16, uiCode, "XXX_reserved_zero_16bits[]");  assert( uiCode == 0 ); 
    1740 }
    1741 #endif
     1591#if L0046_CONSTRAINT_FLAGS
     1592  READ_FLAG(uiCode, "general_progressive_source_flag");
     1593  ptl->setProgressiveSourceFlag(uiCode ? true : false);
     1594
     1595  READ_FLAG(uiCode, "general_interlaced_source_flag");
     1596  ptl->setInterlacedSourceFlag(uiCode ? true : false);
     1597 
     1598  READ_FLAG(uiCode, "general_non_packed_constraint_flag");
     1599  ptl->setNonPackedConstraintFlag(uiCode ? true : false);
     1600 
     1601  READ_FLAG(uiCode, "general_frame_only_constraint_flag");
     1602  ptl->setFrameOnlyConstraintFlag(uiCode ? true : false);
     1603 
     1604  READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]");
     1605  READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]");
     1606  READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]");
     1607#elif L0363_MORE_BITS
     1608  READ_CODE(16, uiCode, "XXX_reserved_zero_48bits[0..15]");
     1609  READ_CODE(16, uiCode, "XXX_reserved_zero_48bits[16..31]");
     1610  READ_CODE(16, uiCode, "XXX_reserved_zero_48bits[32..47]");
     1611#else
     1612  READ_CODE(16, uiCode, "XXX_reserved_zero_16bits[]");  assert( uiCode == 0 );
     1613#endif
     1614}
     1615#if SIGNAL_BITRATE_PICRATE_IN_VPS
     1616Void TDecCavlc::parseBitratePicRateInfo(TComBitRatePicRateInfo *info, Int tempLevelLow, Int tempLevelHigh)
     1617{
     1618  UInt uiCode;
     1619  for(Int i = tempLevelLow; i <= tempLevelHigh; i++)
     1620  {
     1621    READ_FLAG( uiCode, "bit_rate_info_present_flag[i]" ); info->setBitRateInfoPresentFlag(i, uiCode ? true : false);
     1622    READ_FLAG( uiCode, "pic_rate_info_present_flag[i]" ); info->setPicRateInfoPresentFlag(i, uiCode ? true : false);
     1623    if(info->getBitRateInfoPresentFlag(i))
     1624    {
     1625      READ_CODE( 16, uiCode, "avg_bit_rate[i]" ); info->setAvgBitRate(i, uiCode);
     1626      READ_CODE( 16, uiCode, "max_bit_rate[i]" ); info->setMaxBitRate(i, uiCode);
     1627    }
     1628    if(info->getPicRateInfoPresentFlag(i))
     1629    {
     1630      READ_CODE(  2, uiCode,  "constant_pic_rate_idc[i]" ); info->setConstantPicRateIdc(i, uiCode);
     1631      READ_CODE( 16, uiCode,  "avg_pic_rate[i]"          ); info->setAvgPicRate(i, uiCode);
     1632    }
     1633  }
     1634}
     1635#endif 
    17421636Void TDecCavlc::parseTerminatingBit( UInt& ruiBit )
    17431637{
     
    17541648}
    17551649
    1756 Void TDecCavlc::parseSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     1650Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
    17571651{
    17581652  assert(0);
    17591653}
    17601654
    1761 Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     1655Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
    17621656{
    17631657  assert(0);
    17641658}
    17651659
    1766 #if INTRA_BL
    1767 Void TDecCavlc::parseIntraBLFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
     1660Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ )
    17681661{
    17691662  assert(0);
    17701663}
    1771 #endif
    1772 
    1773 Void TDecCavlc::parseMVPIdx( Int& riMVPIdx )
     1664
     1665Void TDecCavlc::parseSplitFlag     ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
    17741666{
    17751667  assert(0);
    17761668}
    17771669
    1778 Void TDecCavlc::parseSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     1670Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
    17791671{
    17801672  assert(0);
    17811673}
    17821674
    1783 Void TDecCavlc::parsePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    1784 {
    1785   assert(0);
    1786 }
    1787 
    1788 Void TDecCavlc::parsePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     1675Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
    17891676{
    17901677  assert(0);
     
    17991686* If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. 
    18001687*/
    1801 Void TDecCavlc::parseIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     1688Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
    18021689{
    18031690  assert(0);
    18041691}
    18051692
    1806 Void TDecCavlc::parseIntraDirLumaAng  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     1693Void TDecCavlc::parseIntraDirLumaAng  ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
    18071694{
    18081695  assert(0);
    18091696}
    18101697
    1811 Void TDecCavlc::parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     1698Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ )
    18121699{
    18131700  assert(0);
    18141701}
    18151702
    1816 Void TDecCavlc::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx, UInt uiDepth )
     1703Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ )
    18171704{
    18181705  assert(0);
    18191706}
    18201707
    1821 Void TDecCavlc::parseRefFrmIdx( TComDataCU* pcCU, Int& riRefFrmIdx, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList )
     1708Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ )
    18221709{
    18231710  assert(0);
    18241711}
    18251712
    1826 Void TDecCavlc::parseMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList )
     1713Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ )
    18271714{
    18281715  assert(0);
     
    18451732}
    18461733
    1847 Void TDecCavlc::parseCoeffNxN( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType )
     1734Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ )
    18481735{
    18491736  assert(0);
    18501737}
    18511738
    1852 Void TDecCavlc::parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize )
     1739Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ )
    18531740{
    18541741  assert(0);
    18551742}
    18561743
    1857 Void TDecCavlc::parseQtCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth )
     1744Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ )
    18581745{
    18591746  assert(0);
    18601747}
    18611748
    1862 Void TDecCavlc::parseQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf )
     1749Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ )
    18631750{
    18641751  assert(0);
    18651752}
    18661753
    1867 Void TDecCavlc::parseTransformSkipFlags (TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, UInt uiDepth, TextType eTType)
     1754Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/)
    18681755{
    18691756  assert(0);
    18701757}
    18711758
    1872 Void TDecCavlc::parseMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx )
     1759Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ )
    18731760{
    18741761  assert(0);
    18751762}
    18761763
    1877 Void TDecCavlc::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth )
     1764Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ )
    18781765{
    18791766  assert(0);
     
    19001787    {
    19011788      xReadFlag( uiSymbol );
    1902 
    1903       if(uiSymbol)
    1904       {
    1905         printf("\nWarning! pcm_align_zero include a non-zero value.\n");
    1906       }
     1789      assert( uiSymbol == 0 );
    19071790    }
    19081791  }
     
    20041887  wpScalingParam  *wp;
    20051888  Bool            bChroma     = true; // color always present in HEVC ?
    2006   TComPPS*        pps         = pcSlice->getPPS();
    20071889  SliceType       eSliceType  = pcSlice->getSliceType();
    20081890  Int             iNbRef       = (eSliceType == B_SLICE ) ? (2) : (1);
    20091891  UInt            uiLog2WeightDenomLuma, uiLog2WeightDenomChroma;
    2010   UInt            uiMode      = 0;
    2011 #if NUM_WP_LIMIT
    20121892  UInt            uiTotalSignalledWeightFlags = 0;
    2013 #endif
    2014   if ( (eSliceType==P_SLICE && pps->getUseWP()) || (eSliceType==B_SLICE && pps->getWPBiPred()) )
    2015   {
    2016     uiMode = 1; // explicit
    2017   }
    2018   if ( uiMode == 1 )  // explicit
    2019   {
    2020     printf("\nTDecCavlc::xParsePredWeightTable(poc=%d) explicit...\n", pcSlice->getPOC());
    2021     Int iDeltaDenom;
    2022     // decode delta_luma_log2_weight_denom :
    2023     READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" );     // ue(v): luma_log2_weight_denom
    2024     if( bChroma )
    2025     {
    2026       READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" );     // se(v): delta_chroma_log2_weight_denom
    2027       assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0);
    2028       uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma);
    2029     }
    2030 
    2031     for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ )
    2032     {
    2033       RefPicList  eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
     1893 
     1894  Int iDeltaDenom;
     1895  // decode delta_luma_log2_weight_denom :
     1896  READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" );     // ue(v): luma_log2_weight_denom
     1897  if( bChroma )
     1898  {
     1899    READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" );     // se(v): delta_chroma_log2_weight_denom
     1900    assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0);
     1901    uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma);
     1902  }
     1903
     1904  for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ )
     1905  {
     1906    RefPicList  eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
     1907    for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
     1908    {
     1909      pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
     1910
     1911      wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma;
     1912      wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma;
     1913      wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma;
     1914
     1915      UInt  uiCode;
     1916      READ_FLAG( uiCode, "luma_weight_lX_flag" );           // u(1): luma_weight_l0_flag
     1917      wp[0].bPresentFlag = ( uiCode == 1 );
     1918      uiTotalSignalledWeightFlags += wp[0].bPresentFlag;
     1919    }
     1920    if ( bChroma )
     1921    {
     1922      UInt  uiCode;
    20341923      for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
    20351924      {
    20361925        pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
    2037 
    2038         wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma;
    2039         wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma;
    2040         wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma;
    2041 
    2042         UInt  uiCode;
    2043         READ_FLAG( uiCode, "luma_weight_lX_flag" );           // u(1): luma_weight_l0_flag
    2044         wp[0].bPresentFlag = ( uiCode == 1 );
    2045 #if NUM_WP_LIMIT
    2046         uiTotalSignalledWeightFlags += wp[0].bPresentFlag;
     1926        READ_FLAG( uiCode, "chroma_weight_lX_flag" );      // u(1): chroma_weight_l0_flag
     1927        wp[1].bPresentFlag = ( uiCode == 1 );
     1928        wp[2].bPresentFlag = ( uiCode == 1 );
     1929        uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag;
     1930      }
     1931    }
     1932    for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
     1933    {
     1934      pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
     1935      if ( wp[0].bPresentFlag )
     1936      {
     1937        Int iDeltaWeight;
     1938        READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" );  // se(v): delta_luma_weight_l0[i]
     1939        wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom));
     1940        READ_SVLC( wp[0].iOffset, "luma_offset_lX" );       // se(v): luma_offset_l0[i]
     1941      }
     1942      else
     1943      {
     1944        wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom);
     1945        wp[0].iOffset = 0;
    20471946      }
    20481947      if ( bChroma )
    20491948      {
    2050         UInt  uiCode;
    2051         for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
    2052         {
    2053           pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
    2054           READ_FLAG( uiCode, "chroma_weight_lX_flag" );      // u(1): chroma_weight_l0_flag
    2055           wp[1].bPresentFlag = ( uiCode == 1 );
    2056           wp[2].bPresentFlag = ( uiCode == 1 );
    2057           uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag;
    2058         }
    2059       }
    2060       for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
    2061       {
    2062         pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
    2063 #endif
    2064         if ( wp[0].bPresentFlag )
    2065         {
    2066           Int iDeltaWeight;
    2067           READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" );  // se(v): delta_luma_weight_l0[i]
    2068           wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom));
    2069           READ_SVLC( wp[0].iOffset, "luma_offset_lX" );       // se(v): luma_offset_l0[i]
     1949        if ( wp[1].bPresentFlag )
     1950        {
     1951          for ( Int j=1 ; j<3 ; j++ )
     1952          {
     1953            Int iDeltaWeight;
     1954            READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" );  // se(v): chroma_weight_l0[i][j]
     1955            wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom));
     1956
     1957            Int iDeltaChroma;
     1958            READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" );  // se(v): delta_chroma_offset_l0[i][j]
     1959            Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) );
     1960            wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) );
     1961          }
    20701962        }
    20711963        else
    20721964        {
    2073           wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom);
    2074           wp[0].iOffset = 0;
    2075         }
    2076         if ( bChroma )
    2077         {
    2078 #if !NUM_WP_LIMIT
    2079           READ_FLAG( uiCode, "chroma_weight_lX_flag" );      // u(1): chroma_weight_l0_flag
    2080           wp[1].bPresentFlag = ( uiCode == 1 );
    2081           wp[2].bPresentFlag = ( uiCode == 1 );
    2082 #endif
    2083           if ( wp[1].bPresentFlag )
     1965          for ( Int j=1 ; j<3 ; j++ )
    20841966          {
    2085             for ( Int j=1 ; j<3 ; j++ )
    2086             {
    2087               Int iDeltaWeight;
    2088               READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" );  // se(v): chroma_weight_l0[i][j]
    2089               wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom));
    2090 
    2091               Int iDeltaChroma;
    2092               READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" );  // se(v): delta_chroma_offset_l0[i][j]
    2093               Int shift = ((1<<(g_uiBitDepth+g_uiBitIncrement-1)));
    2094               Int pred = ( shift - ( ( shift*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) );
    2095 #if WP_PARAM_RANGE_LIMIT
    2096               wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) );
    2097 #else
    2098               wp[j].iOffset = iDeltaChroma + pred;
    2099 #endif
    2100             }
     1967            wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom);
     1968            wp[j].iOffset = 0;
    21011969          }
    2102           else
    2103           {
    2104             for ( Int j=1 ; j<3 ; j++ )
    2105             {
    2106               wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom);
    2107               wp[j].iOffset = 0;
    2108             }
    2109           }
    2110         }
    2111       }
    2112 
    2113       for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ )
    2114       {
    2115         pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
    2116 
    2117         wp[0].bPresentFlag = false;
    2118         wp[1].bPresentFlag = false;
    2119         wp[2].bPresentFlag = false;
    2120       }
    2121     }
    2122 #if NUM_WP_LIMIT
    2123     assert(uiTotalSignalledWeightFlags<=24);
    2124 #endif
    2125   }
    2126   else
    2127   {
    2128     printf("\n wrong weight pred table syntax \n ");
    2129     assert(0);
    2130   }
     1970        }
     1971      }
     1972    }
     1973
     1974    for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ )
     1975    {
     1976      pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
     1977
     1978      wp[0].bPresentFlag = false;
     1979      wp[1].bPresentFlag = false;
     1980      wp[2].bPresentFlag = false;
     1981    }
     1982  }
     1983  assert(uiTotalSignalledWeightFlags<=24);
    21311984}
    21321985
     
    21762029  Int scalingListDcCoefMinus8 = 0;
    21772030  Int nextCoef = SCALING_LIST_START_VALUE;
    2178 #if REMOVE_ZIGZAG_SCAN
    21792031  UInt* scan  = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] :  g_sigLastScanCG32x32;
    2180 #else
    2181   UInt* scan  = g_auiFrameScanXY [ (sizeId == 0)? 1 : 2 ];
    2182 #endif
    21832032  Int *dst = scalingList->getScalingListAddress(sizeId, listId);
    21842033
     
    22272076}
    22282077
     2078#if INTRA_BL
     2079Void TDecCavlc::parseIntraBLFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth )
     2080{
     2081  assert(0);
     2082}
     2083#endif
     2084
    22292085//! \}
    22302086
  • trunk/source/Lib/TLibDecoder/TDecCAVLC.h

    r2 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    5353// ====================================================================================================================
    5454
    55 class SEImessages;
    56 
    5755/// CAVLC decoder class
    5856class TDecCavlc : public SyntaxElementParser, public TDecEntropyIf
     
    7371  void  parseShortTermRefPicSet            (TComSPS* pcSPS, TComReferencePictureSet* pcRPS, Int idx);
    7472private:
    75 #if !REMOVE_FGS
    76   Int           m_iSliceGranularity; //!< slice granularity
    77 #endif
    7873 
    7974public:
    8075
    8176  /// rest entropy coder by intial QP and IDC in CABAC
    82   Void  resetEntropy        ( TComSlice* pcSlice  )     { assert(0); };
     77  Void  resetEntropy        ( TComSlice* /*pcSlice*/  )     { assert(0); };
    8378  Void  setBitstream        ( TComInputBitstream* p )   { m_pcBitstream = p; }
    84 #if !REMOVE_FGS
    85   /// set slice granularity
    86   Void setSliceGranularity(Int iSliceGranularity)  {m_iSliceGranularity = iSliceGranularity;}
    87 
    88   /// get slice granularity
    89   Int  getSliceGranularity()                       {return m_iSliceGranularity;             }
    90 #endif
    9179  Void  parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize );
    9280  Void  parseQtCbf          ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth );
    93   Void  parseQtRootCbf      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf );
     81  Void  parseQtRootCbf      ( UInt uiAbsPartIdx, UInt& uiQtRootCbf );
    9482  Void  parseVPS            ( TComVPS* pcVPS );
     83#if VPS_EXTNS
     84  Void  parseVPSExtension   ( TComVPS* pcVPS );
     85#endif
    9586  Void  parseSPS            ( TComSPS* pcSPS );
    9687  Void  parsePPS            ( TComPPS* pcPPS);
    97 #if SUPPORT_FOR_VUI
    98 #if !BUFFERING_PERIOD_AND_TIMING_SEI
    99   Void  parseVUI            ( TComVUI* pcVUI );
    100 #else
    10188  Void  parseVUI            ( TComVUI* pcVUI, TComSPS* pcSPS );
    102 #endif
    103 #endif
    104   Void  parseSEI(SEImessages&);
    105 #if !REMOVE_APS
    106   Void  parseAPS            ( TComAPS* pAPS );
    107 #endif
    108 #if PROFILE_TIER_LEVEL_SYNTAX
     89  Void  parseSEI            ( SEIMessages& );
    10990  Void  parsePTL            ( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 );
    11091  Void  parseProfileTier    (ProfileTierLevel *ptl);
     92#if SIGNAL_BITRATE_PICRATE_IN_VPS
     93  Void  parseBitratePicRateInfo(TComBitRatePicRateInfo *info, Int tempLevelLow, Int tempLevelHigh);
    11194#endif
     95  Void  parseHrdParameters  (TComHRD *hrd, Bool cprms_present_flag, UInt tempLevelHigh);
    11296  Void  parseSliceHeader    ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager);
    11397  Void  parseTerminatingBit ( UInt& ruiBit );
     
    118102  Void  parseCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    119103  Void parseMergeFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );
    120   Void parseMergeIndex      ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth );
     104  Void parseMergeIndex      ( TComDataCU* pcCU, UInt& ruiMergeIndex );
    121105  Void parseSplitFlag       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    122106  Void parsePartSize        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
     
    127111  Void parseIntraDirChroma  ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    128112 
    129   Void parseInterDir        ( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx, UInt uiDepth );
    130   Void parseRefFrmIdx       ( TComDataCU* pcCU, Int& riRefFrmIdx,  UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList );
     113  Void parseInterDir        ( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx );
     114  Void parseRefFrmIdx       ( TComDataCU* pcCU, Int& riRefFrmIdx,  RefPicList eRefList );
    131115  Void parseMvd             ( TComDataCU* pcCU, UInt uiAbsPartAddr,UInt uiPartIdx,    UInt uiDepth, RefPicList eRefList );
    132116 
     
    137121  Void parseIPCMInfo        ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth);
    138122
     123  Void updateContextTables  ( SliceType /*eSliceType*/, Int /*iQp*/ ) { return; }
     124
    139125#if INTRA_BL
    140126  Void parseIntraBLFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth );
    141127#endif
    142   Void updateContextTables  ( SliceType eSliceType, Int iQp ) { return; }
    143   Void decodeFlush() {};
    144128
    145129  Void xParsePredWeightTable ( TComSlice* pcSlice );
     
    147131  Void xDecodeScalingList    ( TComScalingList *scalingList, UInt sizeId, UInt listId);
    148132protected:
    149 #if !REMOVE_ALF
    150   Void  xParseAlfParam       ( ALFParam* pAlfParam );
    151   Int   xGolombDecode        ( Int k );
    152 #endif
    153133  Bool  xMoreRbspData();
    154134};
  • trunk/source/Lib/TLibDecoder/TDecCu.cpp

    r55 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    6262#if SVC_EXTENSION
    6363Void TDecCu::init(TDecTop** ppcDecTop, TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction, UInt layerId)
     64{
     65  m_pcEntropyDecoder  = pcEntropyDecoder;
     66  m_pcTrQuant         = pcTrQuant;
     67  m_pcPrediction      = pcPrediction;
     68  m_ppcTDecTop = ppcDecTop;
     69  m_layerId = layerId;
     70
     71  for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
     72  {
     73    m_ppcCU     [ui]->setLayerId(layerId);
     74  }
     75}
    6476#else
    6577Void TDecCu::init( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction)
    66 #endif
    6778{
    6879  m_pcEntropyDecoder  = pcEntropyDecoder;
    6980  m_pcTrQuant         = pcTrQuant;
    7081  m_pcPrediction      = pcPrediction;
    71 #if SVC_EXTENSION   
    72   m_ppcTDecTop = ppcDecTop;
    73   m_layerId = layerId;
    74 
    75   for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ )
    76   {
    77     m_ppcCU     [ui]->setLayerId(layerId);
    78   }
    79 #endif
    80 }
     82}
     83#endif
    8184
    8285/**
     
    114117  // initialize conversion matrix from partition index to pel
    115118  initRasterToPelXY( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
    116   initMotionReferIdx ( uiMaxWidth, uiMaxHeight, m_uiMaxDepth );
    117119}
    118120
     
    145147  }
    146148
    147   pcCU->setNumSucIPCM(0);
    148 
    149149  // start from the top level CU
    150150#if SVC_EXTENSION
     
    158158Void TDecCu::decompressCU( TComDataCU* pcCU )
    159159{
    160   xDecompressCU( pcCU, pcCU, 0,  0 );
     160  xDecompressCU( pcCU, 0,  0 );
    161161}
    162162
     
    179179  UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples();
    180180  UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples();
    181 #if REMOVE_FGS
    182181  UInt uiGranularityWidth = g_uiMaxCUWidth;
    183 #else
    184   UInt uiGranularityWidth = g_uiMaxCUWidth>>(pcSlice->getPPS()->getSliceGranularity());
    185 #endif
    186182  UInt uiPosX = pcCU->getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiAbsPartIdx] ];
    187183  UInt uiPosY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ];
     
    199195  if(uiIsLast)
    200196  {
    201     if(pcSlice->isNextDependentSlice()&&!pcSlice->isNextSlice())
    202     {
    203       pcSlice->setDependentSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
     197    if(pcSlice->isNextSliceSegment()&&!pcSlice->isNextSlice())
     198    {
     199      pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
    204200    }
    205201    else
    206202    {
    207203      pcSlice->setSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
    208       pcSlice->setDependentSliceCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
     204      pcSlice->setSliceSegmentCurEndCUAddr(pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts);
    209205    }
    210206  }
     
    233229 
    234230  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
    235   Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getDependentSliceCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getDependentSliceCurStartCUAddr();
     231  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
    236232  if((!bStartInCU) && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
    237233  {
    238     if(pcCU->getNumSucIPCM() == 0)
    239     {
    240       m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
    241     }
    242     else
    243     {
    244       pcCU->setDepthSubParts( uiDepth, uiAbsPartIdx );
    245     }
     234    m_pcEntropyDecoder->decodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth );
    246235  }
    247236  else
     
    264253      uiTPelY   = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
    265254     
    266       Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getDependentSliceCurStartCUAddr();
     255      Bool bSubInSlice = pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr();
    267256      if ( bSubInSlice )
    268257      {
    269         if ( ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )
     258        if ( !ruiIsLast && ( uiLPelX < pcCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ) )
    270259        {
    271260          xDecodeCU( pcCU, uiIdx, uiDepth+1, ruiIsLast );
     
    276265        }
    277266      }
    278       if(ruiIsLast)
    279       {
    280         break;
    281       }
    282267     
    283268      uiIdx += uiQNumParts;
     
    288273      {
    289274        UInt uiQPSrcPartIdx;
    290         if ( pcPic->getCU( pcCU->getAddr() )->getDependentSliceStartCU(uiAbsPartIdx) != pcSlice->getDependentSliceCurStartCUAddr() )
     275        if ( pcPic->getCU( pcCU->getAddr() )->getSliceSegmentStartCU(uiAbsPartIdx) != pcSlice->getSliceSegmentCurStartCUAddr() )
    291276        {
    292           uiQPSrcPartIdx = pcSlice->getDependentSliceCurStartCUAddr() % pcPic->getNumPartInCU();
     277          uiQPSrcPartIdx = pcSlice->getSliceSegmentCurStartCUAddr() % pcPic->getNumPartInCU();
    293278        }
    294279        else
     
    308293  }
    309294
    310   if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag() && pcCU->getNumSucIPCM() == 0 )
     295  if (pcCU->getSlice()->getPPS()->getTransquantBypassEnableFlag())
    311296  {
    312297    m_pcEntropyDecoder->decodeCUTransquantBypassFlag( pcCU, uiAbsPartIdx, uiDepth );
     
    314299 
    315300  // decode CU mode and the partition size
    316   if( !pcCU->getSlice()->isIntra() && pcCU->getNumSucIPCM() == 0 )
     301  if( !pcCU->getSlice()->isIntra())
    317302  {
    318303    m_pcEntropyDecoder->decodeSkipFlag( pcCU, uiAbsPartIdx, uiDepth );
     
    330315      uhInterDirNeighbours[ui] = 0;
    331316    }
    332     m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, SIZE_2Nx2N, uhInterDirNeighbours, cMvFieldNeighbours, uiDepth );
     317    m_pcEntropyDecoder->decodeMergeIndex( pcCU, 0, uiAbsPartIdx, uiDepth );
    333318    UInt uiMergeIndex = pcCU->getMergeIndex(uiAbsPartIdx);
    334     m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
     319    m_ppcCU[uiDepth]->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    335320    pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiAbsPartIdx, 0, uiDepth );
    336321
     
    359344#endif
    360345
    361   if( pcCU->getNumSucIPCM() == 0 )
    362   {
    363     m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
    364     m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
    365   }
    366   else
    367   {
    368     pcCU->setPredModeSubParts( MODE_INTRA, uiAbsPartIdx, uiDepth );
    369     pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
    370     pcCU->setSizeSubParts( g_uiMaxCUWidth>>uiDepth, g_uiMaxCUHeight>>uiDepth, uiAbsPartIdx, uiDepth );
    371     pcCU->setTrIdxSubParts( 0, uiAbsPartIdx, uiDepth );
    372   }
     346  m_pcEntropyDecoder->decodePredMode( pcCU, uiAbsPartIdx, uiDepth );
     347  m_pcEntropyDecoder->decodePartSize( pcCU, uiAbsPartIdx, uiDepth );
    373348
    374349  if (pcCU->isIntra( uiAbsPartIdx ) && pcCU->getPartitionSize( uiAbsPartIdx ) == SIZE_2Nx2N )
     
    381356      return;
    382357    }
    383   } 
     358  }
    384359#if INTRA_BL
    385360  // prediction mode ( Intra : direction mode, Inter : Mv, reference idx )
     
    409384    pcCU->setQPSubParts( getdQPFlag()?pcCU->getRefQP(uiAbsPartIdx):pcCU->getCodedQP(), uiAbsPartIdx, uiDepth ); // set QP
    410385  }
    411   if( pcCU->getNumSucIPCM() > 0 )
    412   {
    413     ruiIsLast = 0;
    414     return;
    415   }
    416386
    417387  ruiIsLast = xDecodeSliceEnd( pcCU, uiAbsPartIdx, uiDepth);
    418388}
    419389
    420 Void TDecCu::xDecompressCU( TComDataCU* pcCU, TComDataCU* pcCUCur, UInt uiAbsPartIdx,  UInt uiDepth )
     390Void TDecCu::xDecompressCU( TComDataCU* pcCU, UInt uiAbsPartIdx,  UInt uiDepth )
    421391{
    422392  TComPic* pcPic = pcCU->getPic();
     
    430400  UInt uiCurNumParts    = pcPic->getNumPartInCU() >> (uiDepth<<1);
    431401  TComSlice * pcSlice = pcCU->getPic()->getSlice(pcCU->getPic()->getCurrSliceIdx());
    432   Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getDependentSliceCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getDependentSliceCurStartCUAddr();
     402  Bool bStartInCU = pcCU->getSCUAddr()+uiAbsPartIdx+uiCurNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurStartCUAddr();
    433403  if(bStartInCU||( uiRPelX >= pcSlice->getSPS()->getPicWidthInLumaSamples() ) || ( uiBPelY >= pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
    434404  {
     
    446416      uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiIdx] ];
    447417     
    448       Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getDependentSliceCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getDependentSliceCurEndCUAddr());
     418      Bool binSlice = (pcCU->getSCUAddr()+uiIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr())&&(pcCU->getSCUAddr()+uiIdx<pcSlice->getSliceSegmentCurEndCUAddr());
    449419      if(binSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) )
    450420      {
    451         xDecompressCU(pcCU, m_ppcCU[uiNextDepth], uiIdx, uiNextDepth );
     421        xDecompressCU(pcCU, uiIdx, uiNextDepth );
    452422      }
    453423     
     
    465435  {
    466436    case MODE_INTER:
    467       xReconInter( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
     437      xReconInter( m_ppcCU[uiDepth], uiDepth );
    468438      break;
    469439    case MODE_INTRA:
    470       xReconIntraQT( m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth );
     440      xReconIntraQT( m_ppcCU[uiDepth], uiDepth );
    471441      break;
    472442#if INTRA_BL
     
    485455  if ( m_ppcCU[uiDepth]->isLosslessCoded(0) && (m_ppcCU[uiDepth]->getIPCMFlag(0) == false))
    486456  {
    487     xFillPCMBuffer(m_ppcCU[uiDepth], uiAbsPartIdx, uiDepth);   
     457    xFillPCMBuffer(m_ppcCU[uiDepth], uiDepth);
    488458  }
    489459 
     
    491461}
    492462
    493 Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     463Void TDecCu::xReconInter( TComDataCU* pcCU, UInt uiDepth )
    494464{
    495465 
     
    553523  else
    554524#endif
    555   m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail );
     525  m_pcPrediction->predIntraLumaAng( pcCU->getPattern(), uiLumaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail );
    556526 
    557527  //===== inverse transform =====
     
    572542    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    573543    {
    574       pReco    [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] );
     544      pReco    [ uiX ] = ClipY( pPred[ uiX ] + pResi[ uiX ] );
    575545      pRecIPred[ uiX ] = pReco[ uiX ];
    576546    }
     
    629599  pcCU->getPattern()->initPattern         ( pcCU, uiTrDepth, uiAbsPartIdx );
    630600
    631 #if !REMOVE_LMCHROMA
    632   if( uiChromaPredMode == LM_CHROMA_IDX && uiChromaId == 0 )
    633   {
    634     pcCU->getPattern()->initAdiPattern( pcCU, uiAbsPartIdx, uiTrDepth,
    635                                      m_pcPrediction->getPredicBuf       (),
    636                                      m_pcPrediction->getPredicBufWidth  (),
    637                                      m_pcPrediction->getPredicBufHeight (),
    638                                      bAboveAvail, bLeftAvail,
    639                                      true );
    640 
    641     m_pcPrediction->getLumaRecPixels( pcCU->getPattern(), uiWidth, uiHeight );
    642   }
    643 #endif
    644  
    645601  pcCU->getPattern()->initAdiPatternChroma( pcCU, uiAbsPartIdx, uiTrDepth,
    646602                                           m_pcPrediction->getPredicBuf       (),
     
    658614  else
    659615#endif
    660 #if !REMOVE_LMCHROMA
    661   if( uiChromaPredMode == LM_CHROMA_IDX )
    662   {
    663     m_pcPrediction->predLMIntraChroma( pcCU->getPattern(), pPatChroma, piPred, uiStride, uiWidth, uiHeight, uiChromaId );
    664   }
    665   else
    666 #endif
    667616  {
    668617    if( uiChromaPredMode == DM_CHROMA_IDX )
     
    670619      uiChromaPredMode = pcCU->getLumaIntraDir( 0 );
    671620    }
    672     m_pcPrediction->predIntraChromaAng( pcCU->getPattern(), pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, pcCU, bAboveAvail, bLeftAvail ); 
     621    m_pcPrediction->predIntraChromaAng( pPatChroma, uiChromaPredMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); 
    673622  }
    674623
    675624  //===== inverse transform =====
    676 #if CHROMA_QP_EXTENSION
    677625  Int curChromaQpOffset;
    678626  if(eText == TEXT_CHROMA_U)
     
    685633  }
    686634  m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
    687 #else
    688   if(eText == TEXT_CHROMA_U)
    689   {
    690     m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaCbQpOffset() );
    691   }
    692   else
    693   {
    694     m_pcTrQuant->setQPforQuant  ( pcCU->getQP(0), eText, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaCrQpOffset() );
    695   }
    696 #endif
    697635
    698636  Int scalingListType = (pcCU->isIntra(uiAbsPartIdx) ? 0 : 3) + g_eTTable[(Int)eText];
     
    709647    for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    710648    {
    711       pReco    [ uiX ] = Clip( pPred[ uiX ] + pResi[ uiX ] );
     649      pReco    [ uiX ] = ClipC( pPred[ uiX ] + pResi[ uiX ] );
    712650      pRecIPred[ uiX ] = pReco[ uiX ];
    713651    }
     
    721659
    722660Void
    723 TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     661TDecCu::xReconIntraQT( TComDataCU* pcCU, UInt uiDepth )
    724662{
    725663  UInt  uiInitTrDepth = ( pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1 );
     
    729667  if (pcCU->getIPCMFlag(0))
    730668  {
    731     xReconPCM( pcCU, uiAbsPartIdx, uiDepth );
     669    xReconPCM( pcCU, uiDepth );
    732670    return;
    733671  }
     
    744682
    745683}
    746 
    747 #if NO_RESIDUAL_FLAG_FOR_BLPRED
    748 Void
    749 TDecCu::xReconIntraBL( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
    750 {
    751   m_ppcYuvReco[uiDepth]->copyFromPicLuma  ( pcCU->getSlice()->getFullPelBaseRec(),  pcCU->getAddr(), pcCU->getZorderIdxInCU(), 0, pcCU->getWidth(0), pcCU->getHeight(0));
    752   m_ppcYuvReco[uiDepth]->copyFromPicChroma( pcCU->getSlice()->getFullPelBaseRec(),  pcCU->getAddr(), pcCU->getZorderIdxInCU(), 0, (pcCU->getWidth(0)>>1), (pcCU->getHeight(0)>>1), 0);
    753   m_ppcYuvReco[uiDepth]->copyFromPicChroma( pcCU->getSlice()->getFullPelBaseRec(),  pcCU->getAddr(), pcCU->getZorderIdxInCU(), 0, (pcCU->getWidth(0)>>1), (pcCU->getHeight(0)>>1), 1);
    754 
    755   // inter recon
    756   xDecodeInterTexture( pcCU, 0, uiDepth );
    757 
    758   // clip for only non-zero cbp case
    759   if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
    760   {
    761     m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
    762   }
    763   else
    764   {
    765     m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
    766   }
    767 }
    768 #endif
    769684
    770685/** Function for deriving recontructed PU/CU Luma sample with QTree structure
     
    853768 
    854769  Pel*    pResi;
    855   UInt    uiLumaTrMode, uiChromaTrMode;
    856  
    857   pcCU->convertTransIdx( uiAbsPartIdx, pcCU->getTransformIdx( uiAbsPartIdx ), uiLumaTrMode, uiChromaTrMode );
     770  UInt    trMode = pcCU->getTransformIdx( uiAbsPartIdx );
    858771 
    859772  // Y
     
    863776  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 );
    864777
    865   m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, uiLumaTrMode, 0, piCoeff );
     778  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_LUMA, pResi, 0, m_ppcYuvResi[uiDepth]->getStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
    866779 
    867780  // Cb and Cr
    868 #if CHROMA_QP_EXTENSION
    869781  Int curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCbQpOffset() + pcCU->getSlice()->getSliceQpDeltaCb();
    870782  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
    871 #else
    872   m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaCbQpOffset() );
    873 #endif
    874783
    875784  uiWidth  >>= 1;
    876785  uiHeight >>= 1;
    877786  piCoeff = pcCU->getCoeffCb(); pResi = m_ppcYuvResi[uiDepth]->getCbAddr();
    878   m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff );
    879 
    880 #if CHROMA_QP_EXTENSION
     787  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_U, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
     788
    881789  curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
    882790  m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), curChromaQpOffset );
    883 #else
    884   m_pcTrQuant->setQPforQuant( pcCU->getQP( uiAbsPartIdx ), TEXT_CHROMA, pcCU->getSlice()->getSPS()->getQpBDOffsetC(), pcCU->getSlice()->getPPS()->getChromaCrQpOffset() );
    885 #endif
    886791
    887792  piCoeff = pcCU->getCoeffCr(); pResi = m_ppcYuvResi[uiDepth]->getCrAddr();
    888   m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, uiChromaTrMode, 0, piCoeff );
     793  m_pcTrQuant->invRecurTransformNxN ( pcCU, 0, TEXT_CHROMA_V, pResi, 0, m_ppcYuvResi[uiDepth]->getCStride(), uiWidth, uiHeight, trMode, 0, piCoeff );
    889794}
    890795
     
    911816    uiPicStride   = pcCU->getPic()->getPicYuvRec()->getStride();
    912817    piPicReco = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
    913     uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();
     818    uiPcmLeftShiftBit = g_bitDepthY - pcCU->getSlice()->getSPS()->getPCMBitDepthLuma();
    914819  }
    915820  else
     
    925830      piPicReco = pcCU->getPic()->getPicYuvRec()->getCrAddr(pcCU->getAddr(), pcCU->getZorderIdxInCU()+uiPartIdx);
    926831    }
    927     uiPcmLeftShiftBit = g_uiBitDepth + g_uiBitIncrement - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
     832    uiPcmLeftShiftBit = g_bitDepthC - pcCU->getSlice()->getSPS()->getPCMBitDepthChroma();
    928833  }
    929834
     
    943848/** Function for reconstructing a PCM mode CU.
    944849 * \param pcCU pointer to current CU
    945  * \param uiAbsPartIdx CU index
    946850 * \param uiDepth CU Depth
    947851 * \returns Void
    948852 */
    949 Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     853Void TDecCu::xReconPCM( TComDataCU* pcCU, UInt uiDepth )
    950854{
    951855  // Luma
     
    977881/** Function for filling the PCM buffer of a CU using its reconstructed sample array
    978882 * \param pcCU pointer to current CU
    979  * \param uiAbsPartIdx CU index
    980883 * \param uiDepth CU Depth
    981884 * \returns Void
    982885 */
    983 Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt absPartIdx, UInt depth)
     886Void TDecCu::xFillPCMBuffer(TComDataCU* pCU, UInt depth)
    984887{
    985888  // Luma
     
    1028931}
    1029932
     933#if NO_RESIDUAL_FLAG_FOR_BLPRED
     934Void
     935TDecCu::xReconIntraBL( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth )
     936{
     937  m_ppcYuvReco[uiDepth]->copyFromPicLuma  ( pcCU->getSlice()->getFullPelBaseRec(),  pcCU->getAddr(), pcCU->getZorderIdxInCU(), 0, pcCU->getWidth(0), pcCU->getHeight(0));
     938  m_ppcYuvReco[uiDepth]->copyFromPicChroma( pcCU->getSlice()->getFullPelBaseRec(),  pcCU->getAddr(), pcCU->getZorderIdxInCU(), 0, (pcCU->getWidth(0)>>1), (pcCU->getHeight(0)>>1), 0);
     939  m_ppcYuvReco[uiDepth]->copyFromPicChroma( pcCU->getSlice()->getFullPelBaseRec(),  pcCU->getAddr(), pcCU->getZorderIdxInCU(), 0, (pcCU->getWidth(0)>>1), (pcCU->getHeight(0)>>1), 1);
     940
     941  // inter recon
     942  xDecodeInterTexture( pcCU, 0, uiDepth );
     943
     944  // clip for only non-zero cbp case
     945  if  ( ( pcCU->getCbf( 0, TEXT_LUMA ) ) || ( pcCU->getCbf( 0, TEXT_CHROMA_U ) ) || ( pcCU->getCbf(0, TEXT_CHROMA_V ) ) )
     946  {
     947    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
     948  }
     949  else
     950  {
     951    m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
     952  }
     953}
     954#endif
     955
    1030956//! \}
  • trunk/source/Lib/TLibDecoder/TDecCu.h

    r17 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    9191  Void  init                    ( TDecEntropy* pcEntropyDecoder, TComTrQuant* pcTrQuant, TComPrediction* pcPrediction );
    9292#endif
    93 
     93 
    9494  /// create internal buffers
    9595  Void  create                  ( UInt uiMaxDepth, UInt uiMaxWidth, UInt uiMaxHeight );
     
    106106#if SVC_EXTENSION
    107107  TDecTop*   getLayerDec        ( UInt LayerId )  { return m_ppcTDecTop[LayerId]; }
    108 #endif
    109108#if INTRA_BL
    110109  Void  setBaseRecPic           ( TComPicYuv* p ) { m_pcPicYuvRecBase = p; }
    111110#endif
     111#endif
    112112protected:
    113113 
     
    115115  Void xFinishDecodeCU          ( TComDataCU* pcCU,                       UInt uiAbsPartIdx, UInt uiDepth, UInt &ruiIsLast);
    116116  Bool xDecodeSliceEnd          ( TComDataCU* pcCU,                       UInt uiAbsPartIdx, UInt uiDepth);
    117   Void xDecompressCU            ( TComDataCU* pcCU, TComDataCU* pcCUCur,  UInt uiAbsPartIdx, UInt uiDepth );
     117  Void xDecompressCU            ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    118118 
    119   Void xReconInter              ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
     119  Void xReconInter              ( TComDataCU* pcCU, UInt uiDepth );
    120120 
    121   Void  xReconIntraQT           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
     121  Void  xReconIntraQT           ( TComDataCU* pcCU, UInt uiDepth );
    122122  Void  xIntraRecLumaBlk        ( TComDataCU* pcCU, UInt uiTrDepth, UInt uiAbsPartIdx, TComYuv* pcRecoYuv, TComYuv* pcPredYuv, TComYuv* pcResiYuv );
    123123  Void  xIntraRecChromaBlk      ( TComDataCU* pcCU, UInt uiTrDepth, UInt uiAbsPartIdx, TComYuv* pcRecoYuv, TComYuv* pcPredYuv, TComYuv* pcResiYuv, UInt uiChromaId );
     
    126126#endif
    127127 
    128   Void  xReconPCM               ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
     128  Void  xReconPCM               ( TComDataCU* pcCU, UInt uiDepth );
    129129
    130130  Void xDecodeInterTexture      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
     
    138138  Bool getdQPFlag               ()                        { return m_bDecodeDQP;        }
    139139  Void setdQPFlag               ( Bool b )                { m_bDecodeDQP = b;           }
    140   Void xFillPCMBuffer           (TComDataCU* pCU, UInt absPartIdx, UInt depth);
     140  Void xFillPCMBuffer           (TComDataCU* pCU, UInt depth);
    141141};
    142142
  • trunk/source/Lib/TLibDecoder/TDecEntropy.cpp

    r17 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4646}
    4747
    48 #include "TLibCommon/TComAdaptiveLoopFilter.h"
    4948#include "TLibCommon/TComSampleAdaptiveOffset.h"
    5049
     
    8887 * \returns Void
    8988 */
    90 Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, PartSize eCUMode, UChar* puhInterDirNeighbours, TComMvField* pcMvFieldNeighbours, UInt uiDepth )
     89Void TDecEntropy::decodeMergeIndex( TComDataCU* pcCU, UInt uiPartIdx, UInt uiAbsPartIdx, UInt uiDepth )
    9190{
    9291  UInt uiMergeIndex = 0;
    93   m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex, uiAbsPartIdx, uiDepth );
     92  m_pcEntropyDecoderIf->parseMergeIndex( pcCU, uiMergeIndex );
    9493  pcCU->setMergeIndexSubParts( uiMergeIndex, uiAbsPartIdx, uiPartIdx, uiDepth );
    9594}
     
    178177  }
    179178  Int numValidMergeCand = 0;
    180   bool isMerged = false;
     179  Bool isMerged = false;
    181180
    182181  pcSubCU->copyInterPredInfoFrom( pcCU, uiAbsPartIdx, REF_PIC_LIST_0 );
     
    187186    if ( pcCU->getMergeFlag( uiSubPartIdx ) )
    188187    {
    189       decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, ePartSize, uhInterDirNeighbours, cMvFieldNeighbours, uiDepth );
     188      decodeMergeIndex( pcCU, uiPartIdx, uiSubPartIdx, uiDepth );
    190189      UInt uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
    191 #if REF_IDX_FRAMEWORK  // HM bug fix
     190#if 0 //REF_IDX_FRAMEWORK  // HM bug fix
    192191      if(uiPartIdx)
    193192      {
     
    204203        if ( !isMerged )
    205204        {
    206           pcSubCU->getInterMergeCandidates( 0, 0, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
     205          pcSubCU->getInterMergeCandidates( 0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand );
    207206          isMerged = true;
    208207        }
     
    212211      {
    213212        uiMergeIndex = pcCU->getMergeIndex(uiSubPartIdx);
    214         pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, uiDepth, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
     213        pcSubCU->getInterMergeCandidates( uiSubPartIdx-uiAbsPartIdx, uiPartIdx, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand, uiMergeIndex );
    215214      }
    216215      pcCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeIndex], uiSubPartIdx, uiPartIdx, uiDepth );
     
    268267  else
    269268  {
    270     m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx, uiDepth );
     269    m_pcEntropyDecoderIf->parseInterDir( pcCU, uiInterDir, uiAbsPartIdx );
    271270  }
    272271
     
    281280  if ( pcCU->getSlice()->getNumRefIdx( eRefList ) > 1 && iParseRefFrmIdx )
    282281  {
    283     m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, uiAbsPartIdx, uiDepth, eRefList );
     282    m_pcEntropyDecoderIf->parseRefFrmIdx( pcCU, iRefFrmIdx, eRefList );
    284283  }
    285284  else if ( !iParseRefFrmIdx )
     
    326325  cMv = cZeroMv;
    327326
    328 #if !SPS_AMVP_CLEANUP
    329   if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) && (pcSubCU->getAMVPMode(uiPartAddr) == AM_EXPL) )
    330 #else
    331327  if ( (pcSubCU->getInterDir(uiPartAddr) & ( 1 << eRefList )) )
    332 #endif
    333328  {
    334329    m_pcEntropyDecoderIf->parseMVPIdx( iMVPIdx );
     
    339334  if ( iRefIdx >= 0 )
    340335  {
    341     m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, iRefIdx, cMv);
     336    m_pcPrediction->getMvPredAMVP( pcSubCU, uiPartIdx, uiPartAddr, eRefList, cMv);
    342337    cMv += pcSubCUMvField->getMvd( uiPartAddr );
    343338  }
     
    347342}
    348343
    349 Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, UInt uiInnerQuadIdx, Bool& bCodeDQP)
     344Void TDecEntropy::xDecodeTransform( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP)
    350345{
    351346  UInt uiSubdiv;
     
    388383  {
    389384    assert( uiLog2TrafoSize > pcCU->getQuadtreeTULog2MinSizeInCU(uiAbsPartIdx) );
    390 #if TRANS_SPLIT_FLAG_CTX_REDUCTION
    391385    m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, 5 - uiLog2TrafoSize );
    392 #else
    393     m_pcEntropyDecoderIf->parseTransformSubdivFlag( uiSubdiv, uiDepth );
    394 #endif
    395386  }
    396387 
     
    431422    const UInt uiQPartNum = pcCU->getPic()->getNumPartInCU() >> (uiDepth << 1);
    432423    const UInt uiStartAbsPartIdx = uiAbsPartIdx;
    433     UInt uiLumaTrMode, uiChromaTrMode;
    434     pcCU->convertTransIdx( uiStartAbsPartIdx, uiTrDepth+1, uiLumaTrMode, uiChromaTrMode );
    435424    UInt uiYCbf = 0;
    436425    UInt uiUCbf = 0;
     
    439428    for( Int i = 0; i < 4; i++ )
    440429    {
    441 #if REMOVE_NSQT
    442       UInt nsAddr = uiAbsPartIdx;
    443 #else
    444       UInt nsAddr = 0;
    445       nsAddr = pcCU->getNSAbsPartIdx( uiLog2TrafoSize-1, uiAbsPartIdx, absTUPartIdx, i, uiTrDepth+1 );
    446 #endif
    447       xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, nsAddr, uiDepth, width, height, uiTrIdx, i, bCodeDQP );
    448       uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode );
    449       uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiChromaTrMode );
    450       uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiChromaTrMode );
     430      xDecodeTransform( pcCU, offsetLuma, offsetChroma, uiAbsPartIdx, uiDepth, width, height, uiTrIdx, bCodeDQP );
     431      uiYCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_LUMA, uiTrDepth+1 );
     432      uiUCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_U, uiTrDepth+1 );
     433      uiVCbf |= pcCU->getCbf( uiAbsPartIdx, TEXT_CHROMA_V, uiTrDepth+1 );
    451434      uiAbsPartIdx += uiQPartNum;
    452435      offsetLuma += size;  offsetChroma += (size>>2);
    453436    }
    454437   
    455     pcCU->convertTransIdx( uiStartAbsPartIdx, uiTrDepth, uiLumaTrMode, uiChromaTrMode );
    456438    for( UInt ui = 0; ui < 4 * uiQPartNum; ++ui )
    457439    {
    458       pcCU->getCbf( TEXT_LUMA     )[uiStartAbsPartIdx + ui] |= uiYCbf << uiLumaTrMode;
    459       pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiChromaTrMode;
    460       pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiChromaTrMode;
     440      pcCU->getCbf( TEXT_LUMA     )[uiStartAbsPartIdx + ui] |= uiYCbf << uiTrDepth;
     441      pcCU->getCbf( TEXT_CHROMA_U )[uiStartAbsPartIdx + ui] |= uiUCbf << uiTrDepth;
     442      pcCU->getCbf( TEXT_CHROMA_V )[uiStartAbsPartIdx + ui] |= uiVCbf << uiTrDepth;
    461443    }
    462444  }
     
    477459    }
    478460   
    479     UInt uiLumaTrMode, uiChromaTrMode;
    480     pcCU->convertTransIdx( uiAbsPartIdx, uiTrDepth, uiLumaTrMode, uiChromaTrMode );
    481 #if !REMOVE_NSQT
    482     if(pcCU->getPredictionMode( uiAbsPartIdx ) == MODE_INTER && pcCU->useNonSquarePU( uiAbsPartIdx ) )
    483     {
    484       pcCU->setNSQTIdxSubParts( uiLog2TrafoSize, uiAbsPartIdx, absTUPartIdx, uiLumaTrMode );
    485     }
    486 #endif
    487461    pcCU->setCbfSubParts ( 0, TEXT_LUMA, uiAbsPartIdx, uiDepth );
    488462#if INTRA_BL
     
    496470#endif
    497471    {
    498       pcCU->setCbfSubParts( 1 << uiLumaTrMode, TEXT_LUMA, uiAbsPartIdx, uiDepth );
     472      pcCU->setCbfSubParts( 1 << uiTrDepth, TEXT_LUMA, uiAbsPartIdx, uiDepth );
    499473    }
    500474    else
    501475    {
    502       m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiLumaTrMode, uiDepth );
     476      m_pcEntropyDecoderIf->parseQtCbf( pcCU, uiAbsPartIdx, TEXT_LUMA, uiTrDepth, uiDepth );
    503477    }
    504478
     
    533507      Int trWidth = width;
    534508      Int trHeight = height;
    535 #if !REMOVE_NSQT
    536       pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight );
    537 #endif
    538509      m_pcEntropyDecoderIf->parseCoeffNxN( pcCU, (pcCU->getCoeffY()+offsetLuma), uiAbsPartIdx, trWidth, trHeight, uiDepth, TEXT_LUMA );
    539510    }
     
    542513      Int trWidth = width >> 1;
    543514      Int trHeight = height >> 1;
    544 #if !REMOVE_NSQT
    545       pcCU->getNSQTSize( uiTrIdx, uiAbsPartIdx, trWidth, trHeight );
    546 #endif
    547515      if( cbfU )
    548516      {
     
    561529        Int trWidth = width;
    562530        Int trHeight = height;
    563 #if !REMOVE_NSQT
    564         pcCU->getNSQTSize( uiTrIdx - 1, uiAbsPartIdx, trWidth, trHeight );
    565 #endif
    566531        if( cbfU )
    567532        {
     
    613578    if( !( pcCU->getPartitionSize( uiAbsPartIdx) == SIZE_2Nx2N && pcCU->getMergeFlag( uiAbsPartIdx ) ) )
    614579    {
    615       m_pcEntropyDecoderIf->parseQtRootCbf( pcCU, uiAbsPartIdx, uiDepth, uiQtRootCbf );
     580      m_pcEntropyDecoderIf->parseQtRootCbf( uiAbsPartIdx, uiQtRootCbf );
    616581    }
    617582    if ( !uiQtRootCbf )
     
    619584      pcCU->setCbfSubParts( 0, 0, 0, uiAbsPartIdx, uiDepth );
    620585      pcCU->setTrIdxSubParts( 0 , uiAbsPartIdx, uiDepth );
    621 #if !REMOVE_NSQT
    622       pcCU->setNSQTIdxSubParts( uiAbsPartIdx, uiDepth );
    623 #endif
    624586      return;
    625587    }
    626588   
    627589  }
    628   xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, 0, bCodeDQP );
     590  xDecodeTransform( pcCU, uiLumaOffset, uiChromaOffset, uiAbsPartIdx, uiDepth, uiWidth, uiHeight, 0, bCodeDQP );
    629591}
    630592
  • trunk/source/Lib/TLibDecoder/TDecEntropy.h

    r2 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4444#include "TLibCommon/TComPic.h"
    4545#include "TLibCommon/TComPrediction.h"
    46 #include "TLibCommon/TComAdaptiveLoopFilter.h"
    4746#include "TLibCommon/TComSampleAdaptiveOffset.h"
    4847
    4948class TDecSbac;
    5049class TDecCavlc;
    51 class SEImessages;
    5250class ParameterSetManagerDecoder;
    5351
     
    6765  virtual Void  setBitstream          ( TComInputBitstream* p )  = 0;
    6866
    69   virtual Void  decodeFlush()                                                                      = 0;
    7067  virtual Void  parseVPS                  ( TComVPS* pcVPS )                       = 0;
    7168  virtual Void  parseSPS                  ( TComSPS* pcSPS )                                      = 0;
    7269  virtual Void  parsePPS                  ( TComPPS* pcPPS )                                      = 0;
    73 #if !REMOVE_APS
    74   virtual Void  parseAPS                  ( TComAPS* pAPS  )                                      = 0;
    75 #endif
    7670
    7771  virtual Void parseSliceHeader          ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager)       = 0;
     
    8680  virtual Void parseSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    8781  virtual Void parseMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx ) = 0;
    88   virtual Void parseMergeIndex    ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
     82  virtual Void parseMergeIndex    ( TComDataCU* pcCU, UInt& ruiMergeIndex ) = 0;
    8983  virtual Void parsePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    9084  virtual Void parsePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
     
    9488  virtual Void parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    9589 
    96   virtual Void parseInterDir      ( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
    97   virtual Void parseRefFrmIdx     ( TComDataCU* pcCU, Int& riRefFrmIdx, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList ) = 0;
     90  virtual Void parseInterDir      ( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx ) = 0;
     91  virtual Void parseRefFrmIdx     ( TComDataCU* pcCU, Int& riRefFrmIdx, RefPicList eRefList ) = 0;
    9892  virtual Void parseMvd           ( TComDataCU* pcCU, UInt uiAbsPartAddr, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList ) = 0;
    9993 
    10094  virtual Void parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize ) = 0;
    10195  virtual Void parseQtCbf         ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth ) = 0;
    102   virtual Void parseQtRootCbf     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf ) = 0;
     96  virtual Void parseQtRootCbf     ( UInt uiAbsPartIdx, UInt& uiQtRootCbf ) = 0;
    10397 
    10498  virtual Void parseDeltaQP       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) = 0;
     
    112106  virtual Void parseIntraBLFlag   ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) = 0;
    113107#endif
    114 #if !REMOVE_FGS
    115   /// set slice granularity
    116   virtual Void setSliceGranularity(Int iSliceGranularity) = 0;
    117108
    118   /// get slice granularity
    119   virtual Int  getSliceGranularity()                      = 0;
    120 #endif
    121109  virtual Void updateContextTables( SliceType eSliceType, Int iQp ) = 0;
    122110 
     
    147135  Void    decodeVPS                   ( TComVPS* pcVPS ) { m_pcEntropyDecoderIf->parseVPS(pcVPS); }
    148136  Void    decodeSPS                   ( TComSPS* pcSPS     )    { m_pcEntropyDecoderIf->parseSPS(pcSPS);                    }
    149   Void    decodePPS                   ( TComPPS* pcPPS, ParameterSetManagerDecoder *parameterSet    )    { m_pcEntropyDecoderIf->parsePPS(pcPPS);                    }
    150 #if !REMOVE_APS
    151   Void    decodeAPS                   ( TComAPS* pAPS      )    { m_pcEntropyDecoderIf->parseAPS(pAPS);}
    152 #endif
     137  Void    decodePPS                   ( TComPPS* pcPPS )    { m_pcEntropyDecoderIf->parsePPS(pcPPS);                    }
    153138  Void    decodeSliceHeader           ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager)  { m_pcEntropyDecoderIf->parseSliceHeader(rpcSlice, parameterSetManager);         }
    154139
     
    162147  Void decodeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    163148  Void decodeMergeFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );
    164   Void decodeMergeIndex        ( TComDataCU* pcSubCU, UInt uiPartIdx, UInt uiPartAddr, PartSize eCUMode, UChar* puhInterDirNeighbours, TComMvField* pcMvFieldNeighbours, UInt uiDepth );
     149  Void decodeMergeIndex        ( TComDataCU* pcSubCU, UInt uiPartIdx, UInt uiPartAddr, UInt uiDepth );
    165150  Void decodePredMode          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    166151  Void decodePartSize          ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
     
    182167 
    183168private:
    184   Void xDecodeTransform        ( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt absTUPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, UInt uiInnerQuadIdx, Bool& bCodeDQP );
     169  Void xDecodeTransform        ( TComDataCU* pcCU, UInt offsetLuma, UInt offsetChroma, UInt uiAbsPartIdx, UInt uiDepth, UInt width, UInt height, UInt uiTrIdx, Bool& bCodeDQP );
    185170
    186171public:
    187172  Void decodeCoeff             ( TComDataCU* pcCU                 , UInt uiAbsPartIdx, UInt uiDepth, UInt uiWidth, UInt uiHeight, Bool& bCodeDQP );
    188173 
    189 #if !REMOVE_FGS
    190   /// set slice granularity
    191   Void setSliceGranularity (Int iSliceGranularity) {m_pcEntropyDecoderIf->setSliceGranularity(iSliceGranularity);}
    192 #endif
    193  
    194   Void decodeFlush() { m_pcEntropyDecoderIf->decodeFlush(); }
    195 
    196174};// END CLASS DEFINITION TDecEntropy
    197175
  • trunk/source/Lib/TLibDecoder/TDecGop.cpp

    r28 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    3636*/
    3737
    38 extern bool g_md5_mismatch; ///< top level flag to signal when there is a decode problem
    39 
    4038#include "TDecGop.h"
    4139#include "TDecCAVLC.h"
     
    5149#include <time.h>
    5250
     51extern Bool g_md5_mismatch; ///< top level flag to signal when there is a decode problem
     52
    5353//! \ingroup TLibDecoder
    5454//! \{
    55 static void calcAndPrintHashStatus(TComPicYuv& pic, const SEImessages* seis);
     55static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI);
    5656// ====================================================================================================================
    5757// Constructor / destructor / initialization / destroy
     
    6060TDecGop::TDecGop()
    6161{
    62   m_iGopSize = 0;
    6362  m_dDecTime = 0;
    6463  m_pcSbacDecoders = NULL;
     
    9796                   TDecSlice*              pcSliceDecoder,
    9897                   TComLoopFilter*         pcLoopFilter,
    99 #if !REMOVE_ALF
    100                    TComAdaptiveLoopFilter* pcAdaptiveLoopFilter,
    101 #endif
    10298                   TComSampleAdaptiveOffset* pcSAO
    10399                   )
     
    109105  m_pcSliceDecoder        = pcSliceDecoder;
    110106  m_pcLoopFilter          = pcLoopFilter;
    111 #if !REMOVE_ALF
    112   m_pcAdaptiveLoopFilter  = pcAdaptiveLoopFilter;
    113 #endif
    114107  m_pcSAO  = pcSAO;
    115108#if SVC_EXTENSION   
     
    136129  long iBeforeTime = clock();
    137130 
    138   UInt uiStartCUAddr   = pcSlice->getDependentSliceCurStartCUAddr();
     131  UInt uiStartCUAddr   = pcSlice->getSliceSegmentCurStartCUAddr();
    139132
    140133  UInt uiSliceStartCuAddr = pcSlice->getSliceCurStartCUAddr();
     
    147140  m_pcEntropyDecoder->setEntropyDecoder (m_pcSbacDecoder);
    148141
    149 #if TILES_WPP_ENTROPYSLICES_FLAGS
    150142  UInt uiNumSubstreams = pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag() ? pcSlice->getNumEntryPointOffsets()+1 : pcSlice->getPPS()->getNumSubstreams();
    151 #else
    152   UInt uiNumSubstreams = pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc() == 2 ? pcSlice->getNumEntryPointOffsets()+1 : pcSlice->getPPS()->getNumSubstreams();
    153 #endif
    154143
    155144  // init each couple {EntropyDecoder, Substream}
     
    178167  {
    179168    m_LFCrossSliceBoundaryFlag.push_back( pcSlice->getLFCrossSliceBoundaryFlag());
    180 #if !REMOVE_ALF
    181     if(pcSlice->getSPS()->getUseALF())
    182     {
    183       for(Int compIdx=0; compIdx < 3; compIdx++)
    184       {
    185         m_sliceAlfEnabled[compIdx].push_back(  pcSlice->getAlfEnabledFlag(compIdx) );
    186       }
    187     }
    188 #endif
    189169  }
    190170  m_pcSbacDecoders[0].load(m_pcSbacDecoder);
    191   m_pcSliceDecoder->decompressSlice( pcBitstream, ppcSubstreams, rpcPic, m_pcSbacDecoder, m_pcSbacDecoders);
     171  m_pcSliceDecoder->decompressSlice( ppcSubstreams, rpcPic, m_pcSbacDecoder, m_pcSbacDecoders);
    192172  m_pcEntropyDecoder->setBitstream(  ppcSubstreams[uiNumSubstreams-1] );
    193173  // deallocate all created substreams, including internal buffers.
     
    201181  delete[] m_pcBinCABACs; m_pcBinCABACs = NULL;
    202182
    203   m_dDecTime += (double)(clock()-iBeforeTime) / CLOCKS_PER_SEC;
     183  m_dDecTime += (Double)(clock()-iBeforeTime) / CLOCKS_PER_SEC;
    204184}
    205185
     
    213193  // deblocking filter
    214194  Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag();
    215   m_pcLoopFilter->setCfg(pcSlice->getPPS()->getDeblockingFilterControlPresentFlag(), pcSlice->getDeblockingFilterDisable(), pcSlice->getDeblockingFilterBetaOffsetDiv2(), pcSlice->getDeblockingFilterTcOffsetDiv2(), bLFCrossTileBoundary);
     195  m_pcLoopFilter->setCfg(bLFCrossTileBoundary);
    216196  m_pcLoopFilter->loopFilterPic( rpcPic );
    217197
    218   pcSlice = rpcPic->getSlice(0);
    219 #if REMOVE_ALF
    220198  if(pcSlice->getSPS()->getUseSAO())
    221 #else
    222   if(pcSlice->getSPS()->getUseSAO() || pcSlice->getSPS()->getUseALF())
    223 #endif
    224   {
    225 #if !REMOVE_FGS
    226     Int sliceGranularity = pcSlice->getPPS()->getSliceGranularity();
    227 #endif
     199  {
    228200    m_sliceStartCUAddress.push_back(rpcPic->getNumCUsInFrame()* rpcPic->getNumPartInCU());
    229 #if REMOVE_FGS
    230201    rpcPic->createNonDBFilterInfo(m_sliceStartCUAddress, 0, &m_LFCrossSliceBoundaryFlag, rpcPic->getPicSym()->getNumTiles(), bLFCrossTileBoundary);
    231 #else
    232     rpcPic->createNonDBFilterInfo(m_sliceStartCUAddress, sliceGranularity, &m_LFCrossSliceBoundaryFlag, rpcPic->getPicSym()->getNumTiles(), bLFCrossTileBoundary);
    233 #endif
    234202  }
    235203
    236204  if( pcSlice->getSPS()->getUseSAO() )
    237205  {
    238 #if !SAO_LUM_CHROMA_ONOFF_FLAGS
    239     if(pcSlice->getSaoEnabledFlag())
    240 #else
    241     if(pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma())
    242 #endif
    243     {
    244 #if REMOVE_APS
     206    {
    245207      SAOParam *saoParam = rpcPic->getPicSym()->getSaoParam();
    246 #else
    247       SAOParam *saoParam = pcSlice->getAPS()->getSaoParam();
    248 #endif
    249208      saoParam->bSaoFlag[0] = pcSlice->getSaoEnabledFlag();
    250 #if SAO_TYPE_SHARING
    251209      saoParam->bSaoFlag[1] = pcSlice->getSaoEnabledFlagChroma();
    252 #else
    253       saoParam->bSaoFlag[1] = pcSlice->getSaoEnabledFlagCb();
    254       saoParam->bSaoFlag[2] = pcSlice->getSaoEnabledFlagCr();
    255 #endif
    256210      m_pcSAO->setSaoLcuBasedOptimization(1);
    257       m_pcSAO->createPicSaoInfo(rpcPic, (Int) m_sliceStartCUAddress.size() - 1);
    258       m_pcSAO->SAOProcess(rpcPic, saoParam);
    259 #if !REMOVE_ALF
    260       m_pcAdaptiveLoopFilter->PCMLFDisableProcess(rpcPic);
    261 #else
     211      m_pcSAO->createPicSaoInfo(rpcPic);
     212      m_pcSAO->SAOProcess(saoParam);
    262213      m_pcSAO->PCMLFDisableProcess(rpcPic);
    263 #endif
    264214      m_pcSAO->destroyPicSaoInfo();
    265215    }
    266216  }
    267217
    268 #if !REMOVE_ALF
    269   // adaptive loop filter
    270   if( pcSlice->getSPS()->getUseALF() )
    271   {
    272     m_pcAdaptiveLoopFilter->createPicAlfInfo(rpcPic, (Int) m_sliceStartCUAddress.size()-1);
    273     m_pcAdaptiveLoopFilter->ALFProcess(rpcPic, pcSlice->getAPS()->getAlfParam(), m_sliceAlfEnabled);
    274     m_pcAdaptiveLoopFilter->PCMLFDisableProcess(rpcPic);
    275     m_pcAdaptiveLoopFilter->destroyPicAlfInfo();
    276   }
    277 #endif
    278 
    279 #if REMOVE_ALF
    280218  if(pcSlice->getSPS()->getUseSAO())
    281 #else
    282   if(pcSlice->getSPS()->getUseSAO() || pcSlice->getSPS()->getUseALF())
    283 #endif
    284219  {
    285220    rpcPic->destroyNonDBFilterInfo();
     
    287222
    288223  rpcPic->compressMotion();
    289 
    290 
    291224  Char c = (pcSlice->isIntra() ? 'I' : pcSlice->isInterP() ? 'P' : 'B');
    292225  if (!pcSlice->isReferenced()) c += 32;
     
    305238                                                    pcSlice->getSliceQp() );
    306239#endif
    307   m_dDecTime += (double)(clock()-iBeforeTime) / CLOCKS_PER_SEC;
     240  m_dDecTime += (Double)(clock()-iBeforeTime) / CLOCKS_PER_SEC;
    308241  printf ("[DT %6.3f] ", m_dDecTime );
    309242  m_dDecTime  = 0;
     
    320253  if (m_decodedPictureHashSEIEnabled)
    321254  {
    322     calcAndPrintHashStatus(*rpcPic->getPicYuvRec(), rpcPic->getSEIs());
    323   }
    324 
    325 #if FIXED_ROUNDING_FRAME_MEMORY
    326   rpcPic->getPicYuvRec()->xFixedRoundingPic();
    327 #endif
     255    SEIMessages pictureHashes = getSeisByType(rpcPic->getSEIs(), SEI::DECODED_PICTURE_HASH );
     256    const SEIDecodedPictureHash *hash = ( pictureHashes.size() > 0 ) ? (SEIDecodedPictureHash*) *(pictureHashes.begin()) : NULL;
     257    if (pictureHashes.size() > 1)
     258    {
     259      printf ("Warning: Got multiple decoded picture hash SEI messages. Using first.");
     260    }
     261    calcAndPrintHashStatus(*rpcPic->getPicYuvRec(), hash);
     262  }
    328263
    329264  rpcPic->setOutputMark(true);
    330265  rpcPic->setReconMark(true);
    331266  m_sliceStartCUAddress.clear();
    332 #if !REMOVE_ALF
    333   for(Int compIdx=0; compIdx < 3; compIdx++)
    334   {
    335     m_sliceAlfEnabled[compIdx].clear();
    336   }
    337 #endif
    338267  m_LFCrossSliceBoundaryFlag.clear();
    339268}
     
    350279 *            unk         - no SEI message was available for comparison
    351280 */
    352 static void calcAndPrintHashStatus(TComPicYuv& pic, const SEImessages* seis)
     281static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI)
    353282{
    354283  /* calculate MD5sum for entire reconstructed picture */
    355   unsigned char recon_digest[3][16];
    356   int numChar=0;
    357   const char* hashType = "\0";
    358 
    359   if (seis && seis->picture_digest)
    360   {
    361     switch (seis->picture_digest->method)
     284  UChar recon_digest[3][16];
     285  Int numChar=0;
     286  const Char* hashType = "\0";
     287
     288  if (pictureHashSEI)
     289  {
     290    switch (pictureHashSEI->method)
    362291    {
    363292    case SEIDecodedPictureHash::MD5:
     
    390319
    391320  /* compare digest against received version */
    392   const char* ok = "(unk)";
    393   bool mismatch = false;
    394 
    395   if (seis && seis->picture_digest)
     321  const Char* ok = "(unk)";
     322  Bool mismatch = false;
     323
     324  if (pictureHashSEI)
    396325  {
    397326    ok = "(OK)";
    398     for(int yuvIdx = 0; yuvIdx < 3; yuvIdx++)
    399     {
    400       for (unsigned i = 0; i < numChar; i++)
    401       {
    402         if (recon_digest[yuvIdx][i] != seis->picture_digest->digest[yuvIdx][i])
     327    for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++)
     328    {
     329      for (UInt i = 0; i < numChar; i++)
     330      {
     331        if (recon_digest[yuvIdx][i] != pictureHashSEI->digest[yuvIdx][i])
    403332        {
    404333          ok = "(***ERROR***)";
     
    414343  {
    415344    g_md5_mismatch = true;
    416     printf("[rx%s:%s] ", hashType, digestToString(seis->picture_digest->digest, numChar));
     345    printf("[rx%s:%s] ", hashType, digestToString(pictureHashSEI->digest, numChar));
    417346  }
    418347}
  • trunk/source/Lib/TLibDecoder/TDecGop.h

    r2 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4949#include "TLibCommon/TComPic.h"
    5050#include "TLibCommon/TComLoopFilter.h"
    51 #include "TLibCommon/TComAdaptiveLoopFilter.h"
    5251#include "TLibCommon/TComSampleAdaptiveOffset.h"
    5352
     
    6867{
    6968private:
    70   Int                   m_iGopSize;
    7169  TComList<TComPic*>    m_cListPic;         //  Dynamic buffer
    7270 
     
    8179  TComLoopFilter*       m_pcLoopFilter;
    8280 
    83 #if !REMOVE_ALF
    84   // Adaptive Loop filter
    85   TComAdaptiveLoopFilter*       m_pcAdaptiveLoopFilter;
    86 #endif
    8781  TComSampleAdaptiveOffset*     m_pcSAO;
    8882  Double                m_dDecTime;
    8983  Int                   m_decodedPictureHashSEIEnabled;  ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
    9084
    91   //! list that contains the CU address of each slice plus the end address
     85  //! list that contains the CU address of each slice plus the end address 
    9286  std::vector<Int> m_sliceStartCUAddress;
    9387  std::vector<Bool> m_LFCrossSliceBoundaryFlag;
    94 #if !REMOVE_ALF
    95   std::vector<Bool> m_sliceAlfEnabled[3];
    96 #endif
    9788
    9889#if SVC_EXTENSION
     
    115106                 TDecSlice*              pcSliceDecoder,
    116107                 TComLoopFilter*         pcLoopFilter,
    117 #if !REMOVE_ALF
    118                  TComAdaptiveLoopFilter* pcAdaptiveLoopFilter,
    119 #endif
    120108                 TComSampleAdaptiveOffset* pcSAO
    121109                 );
     
    126114#endif
    127115  Void  destroy ();
    128 //  Void  decompressGop(TComInputBitstream* pcBitstream, TComPic*& rpcPic, Bool bExecuteDeblockAndAlf );
    129116  Void  decompressSlice(TComInputBitstream* pcBitstream, TComPic*& rpcPic );
    130117  Void  filterPicture  (TComPic*& rpcPic );
    131   Void  setGopSize( Int i) { m_iGopSize = i; }
    132118
    133119  void setDecodedPictureHashSEIEnabled(Int enabled) { m_decodedPictureHashSEIEnabled = enabled; }
  • trunk/source/Lib/TLibDecoder/TDecSbac.cpp

    r2 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    5656, m_cCUPartSizeSCModel        ( 1,             1,               NUM_PART_SIZE_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
    5757, m_cCUPredModeSCModel        ( 1,             1,               NUM_PRED_MODE_CTX             , m_contextModels + m_numContextModels, m_numContextModels)
    58 , m_cCUAlfCtrlFlagSCModel     ( 1,             1,               NUM_ALF_CTRL_FLAG_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
    5958, m_cCUIntraPredSCModel       ( 1,             1,               NUM_ADI_CTX                   , m_contextModels + m_numContextModels, m_numContextModels)
    6059, m_cCUChromaPredSCModel      ( 1,             1,               NUM_CHROMA_PRED_CTX           , m_contextModels + m_numContextModels, m_numContextModels)
     
    7372, m_cCUAbsSCModel             ( 1,             1,               NUM_ABS_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    7473, m_cMVPIdxSCModel            ( 1,             1,               NUM_MVP_IDX_CTX               , m_contextModels + m_numContextModels, m_numContextModels)
    75 , m_cALFFlagSCModel           ( 1,             1,               NUM_ALF_FLAG_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    76 , m_cALFUvlcSCModel           ( 1,             1,               NUM_ALF_UVLC_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    77 , m_cALFSvlcSCModel           ( 1,             1,               NUM_ALF_SVLC_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    7874, m_cCUAMPSCModel             ( 1,             1,               NUM_CU_AMP_CTX                , m_contextModels + m_numContextModels, m_numContextModels)
    79 #if !SAO_ABS_BY_PASS
    80 , m_cSaoUvlcSCModel           ( 1,             1,               NUM_SAO_UVLC_CTX              , m_contextModels + m_numContextModels, m_numContextModels)
    81 #endif
    82 #if SAO_MERGE_ONE_CTX
    8375, m_cSaoMergeSCModel      ( 1,             1,               NUM_SAO_MERGE_FLAG_CTX   , m_contextModels + m_numContextModels, m_numContextModels)
    84 #else
    85 , m_cSaoMergeLeftSCModel      ( 1,             1,               NUM_SAO_MERGE_LEFT_FLAG_CTX   , m_contextModels + m_numContextModels, m_numContextModels)
    86 , m_cSaoMergeUpSCModel        ( 1,             1,               NUM_SAO_MERGE_UP_FLAG_CTX     , m_contextModels + m_numContextModels, m_numContextModels)
    87 #endif
     76, m_cSaoTypeIdxSCModel        ( 1,             1,               NUM_SAO_TYPE_IDX_CTX          , m_contextModels + m_numContextModels, m_numContextModels)
     77, m_cTransformSkipSCModel     ( 1,             2,               NUM_TRANSFORMSKIP_FLAG_CTX    , m_contextModels + m_numContextModels, m_numContextModels)
     78, m_CUTransquantBypassFlagSCModel( 1,          1,               NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels)
    8879#if INTRA_BL
    8980, m_cIntraBLPredFlagSCModel   (1,              1,               NUM_INTRA_BL_PRED_CTX         , m_contextModels + m_numContextModels, m_numContextModels)
    9081#endif
    91 , m_cSaoTypeIdxSCModel        ( 1,             1,               NUM_SAO_TYPE_IDX_CTX          , m_contextModels + m_numContextModels, m_numContextModels)
    92 , m_cTransformSkipSCModel     ( 1,             2,               NUM_TRANSFORMSKIP_FLAG_CTX    , m_contextModels + m_numContextModels, m_numContextModels)
    93 , m_CUTransquantBypassFlagSCModel( 1,          1,               NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX, m_contextModels + m_numContextModels, m_numContextModels)
    9482{
    9583  assert( m_numContextModels <= MAX_NUM_CTX_MOD );
    96 #if !REMOVE_FGS
    97   m_iSliceGranularity = 0;
    98 #endif
    9984}
    10085
     
    131116  m_cCUMergeFlagExtSCModel.initBuffer    ( sliceType, qp, (UChar*)INIT_MERGE_FLAG_EXT );
    132117  m_cCUMergeIdxExtSCModel.initBuffer     ( sliceType, qp, (UChar*)INIT_MERGE_IDX_EXT );
    133   m_cCUAlfCtrlFlagSCModel.initBuffer     ( sliceType, qp, (UChar*)INIT_ALF_CTRL_FLAG );
    134118  m_cCUPartSizeSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_PART_SIZE );
    135119  m_cCUAMPSCModel.initBuffer             ( sliceType, qp, (UChar*)INIT_CU_AMP_POS );
     
    150134  m_cCUAbsSCModel.initBuffer             ( sliceType, qp, (UChar*)INIT_ABS_FLAG );
    151135  m_cMVPIdxSCModel.initBuffer            ( sliceType, qp, (UChar*)INIT_MVP_IDX );
    152   m_cALFFlagSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_ALF_FLAG );
    153   m_cALFUvlcSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_ALF_UVLC );
    154   m_cALFSvlcSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_ALF_SVLC );
    155 #if !SAO_ABS_BY_PASS
    156   m_cSaoUvlcSCModel.initBuffer           ( sliceType, qp, (UChar*)INIT_SAO_UVLC );
    157 #endif
    158 #if SAO_MERGE_ONE_CTX
    159136  m_cSaoMergeSCModel.initBuffer      ( sliceType, qp, (UChar*)INIT_SAO_MERGE_FLAG );
    160 #else
    161   m_cSaoMergeLeftSCModel.initBuffer      ( sliceType, qp, (UChar*)INIT_SAO_MERGE_LEFT_FLAG );
    162   m_cSaoMergeUpSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_SAO_MERGE_UP_FLAG );
    163 #endif
    164137  m_cSaoTypeIdxSCModel.initBuffer        ( sliceType, qp, (UChar*)INIT_SAO_TYPE_IDX );
    165138
     
    191164  m_cCUMergeFlagExtSCModel.initBuffer    ( eSliceType, iQp, (UChar*)INIT_MERGE_FLAG_EXT );
    192165  m_cCUMergeIdxExtSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_MERGE_IDX_EXT );
    193   m_cCUAlfCtrlFlagSCModel.initBuffer     ( eSliceType, iQp, (UChar*)INIT_ALF_CTRL_FLAG );
    194166  m_cCUPartSizeSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_PART_SIZE );
    195167  m_cCUAMPSCModel.initBuffer             ( eSliceType, iQp, (UChar*)INIT_CU_AMP_POS );
     
    210182  m_cCUAbsSCModel.initBuffer             ( eSliceType, iQp, (UChar*)INIT_ABS_FLAG );
    211183  m_cMVPIdxSCModel.initBuffer            ( eSliceType, iQp, (UChar*)INIT_MVP_IDX );
    212   m_cALFFlagSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_ALF_FLAG );
    213   m_cALFUvlcSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_ALF_UVLC );
    214   m_cALFSvlcSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_ALF_SVLC );
    215 #if !SAO_ABS_BY_PASS
    216   m_cSaoUvlcSCModel.initBuffer           ( eSliceType, iQp, (UChar*)INIT_SAO_UVLC );
    217 #endif
    218 #if SAO_MERGE_ONE_CTX
    219184  m_cSaoMergeSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_FLAG );
    220 #else
    221   m_cSaoMergeLeftSCModel.initBuffer      ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_LEFT_FLAG );
    222   m_cSaoMergeUpSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_MERGE_UP_FLAG );
    223 #endif
    224185  m_cSaoTypeIdxSCModel.initBuffer        ( eSliceType, iQp, (UChar*)INIT_SAO_TYPE_IDX );
    225186  m_cCUTransSubdivFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_TRANS_SUBDIV_FLAG );
     
    334295  prefix -= codeWord;
    335296  codeWord=0;
    336 #if COEF_REMAIN_BIN_REDUCTION
    337297  if (prefix < COEF_REMAIN_BIN_REDUCTION )
    338 #else
    339   if (prefix < 8 )
    340 #endif
    341298  {
    342299    m_pcTDecBinIf->decodeBinsEP(codeWord,rParam);
     
    345302  else
    346303  {
    347 #if COEF_REMAIN_BIN_REDUCTION
    348304    m_pcTDecBinIf->decodeBinsEP(codeWord,prefix-COEF_REMAIN_BIN_REDUCTION+rParam);
    349305    rSymbol = (((1<<(prefix-COEF_REMAIN_BIN_REDUCTION))+COEF_REMAIN_BIN_REDUCTION-1)<<rParam)+codeWord;
    350 #else
    351     m_pcTDecBinIf->decodeBinsEP(codeWord,prefix-8+rParam);
    352     rSymbol = (((1<<(prefix-8))+8-1)<<rParam)+codeWord;
    353 #endif
    354306  }
    355307}
     
    366318{
    367319  UInt uiSymbol;
    368   Int numSubseqIPCM = 0;
    369320  Bool readPCMSampleFlag = false;
    370321
    371   if(pcCU->getNumSucIPCM() > 0)
    372   {
    373     readPCMSampleFlag = true;
    374   }
    375   else
    376   {
    377322    m_pcTDecBinIf->decodeBinTrm(uiSymbol);
    378323
     
    380325    {
    381326      readPCMSampleFlag = true;
    382       m_pcTDecBinIf->decodeNumSubseqIPCM(numSubseqIPCM);
    383       pcCU->setNumSucIPCM(numSubseqIPCM + 1);
    384327      m_pcTDecBinIf->decodePCMAlignBits();
    385328    }
    386   }
    387329
    388330  if (readPCMSampleFlag == true)
     
    453395    }
    454396
    455     pcCU->setNumSucIPCM( pcCU->getNumSucIPCM() - 1);
    456     if(pcCU->getNumSucIPCM() == 0)
    457     {
    458397      m_pcTDecBinIf->resetBac();
    459     }
    460398  }
    461399}
     
    494432  if( uiSymbol )
    495433  {
    496 #if SKIP_FLAG
    497434    pcCU->setSkipFlagSubParts( true,        uiAbsPartIdx, uiDepth );
    498 #endif
    499435    pcCU->setPredModeSubParts( MODE_INTER,  uiAbsPartIdx, uiDepth );
    500436    pcCU->setPartSizeSubParts( SIZE_2Nx2N, uiAbsPartIdx, uiDepth );
     
    555491}
    556492
    557 Void TDecSbac::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth )
     493Void TDecSbac::parseMergeIndex ( TComDataCU* pcCU, UInt& ruiMergeIndex )
    558494{
    559495  UInt uiUnaryIdx = 0;
     
    783719  else
    784720  {
    785 #if !REMOVE_LMCHROMA
    786     if( pcCU->getSlice()->getSPS()->getUseLMChroma() )
    787     {
    788       m_pcTDecBinIf->decodeBin( uiSymbol, m_cCUChromaPredSCModel.get( 0, 0, 1 ) );
    789     }
    790     else
    791     {
    792       uiSymbol = 1;
    793     }
    794 
    795     if( uiSymbol == 0 )
    796     {
    797       uiSymbol = LM_CHROMA_IDX;
    798     }
    799     else
    800 #endif
    801721    {
    802722      UInt uiIPredMode;
     
    811731}
    812732
    813 Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx, UInt uiDepth )
     733Void TDecSbac::parseInterDir( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx )
    814734{
    815735  UInt uiSymbol;
    816736  const UInt uiCtx = pcCU->getCtxInterDir( uiAbsPartIdx );
    817737  ContextModel *pCtx = m_cCUInterDirSCModel.get( 0 );
    818 #if DISALLOW_BIPRED_IN_8x4_4x8PUS
    819738  uiSymbol = 0;
    820739  if (pcCU->getPartitionSize(uiAbsPartIdx) == SIZE_2Nx2N || pcCU->getHeight(uiAbsPartIdx) != 8 )
    821740  {
    822 #endif
    823741    m_pcTDecBinIf->decodeBin( uiSymbol, *( pCtx + uiCtx ) );
    824 #if DISALLOW_BIPRED_IN_8x4_4x8PUS
    825   }
    826 #endif
     742  }
    827743
    828744  if( uiSymbol )
     
    841757}
    842758
    843 Void TDecSbac::parseRefFrmIdx( TComDataCU* pcCU, Int& riRefFrmIdx, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList )
     759Void TDecSbac::parseRefFrmIdx( TComDataCU* pcCU, Int& riRefFrmIdx, RefPicList eRefList )
    844760{
    845761  UInt uiSymbol;
     
    850766    if( uiSymbol )
    851767    {
    852 #if REF_IDX_BYPASS
    853768      UInt uiRefNum = pcCU->getSlice()->getNumRefIdx( eRefList ) - 2;
    854769      pCtx++;
     
    870785      }
    871786      uiSymbol = ui + 1;
    872 #else
    873       xReadUnaryMaxSymbol( uiSymbol, pCtx + 1, 1, pcCU->getSlice()->getNumRefIdx( eRefList )-2 );
    874       uiSymbol++;
    875 #endif
    876787    }
    877788    riRefFrmIdx = uiSymbol;
     
    958869}
    959870
    960 Void TDecSbac::parseQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf )
     871Void TDecSbac::parseQtRootCbf( UInt uiAbsPartIdx, UInt& uiQtRootCbf )
    961872{
    962873  UInt uiSymbol;
     
    982893  Int  iDQp;
    983894 
    984 #if CU_DQP_TU_EG
    985895  UInt uiSymbol;
    986896
     
    1010920    qp = pcCU->getRefQP(uiAbsPartIdx);
    1011921  }
    1012 #else
    1013   m_pcTDecBinIf->decodeBin( uiDQp, m_cCUDeltaQpSCModel.get( 0, 0, 0 ) );
    1014  
    1015   if ( uiDQp == 0 )
    1016   {
    1017     qp = pcCU->getRefQP(uiAbsPartIdx);
    1018   }
    1019   else
    1020   {
    1021     UInt uiSign;
    1022     Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY();
    1023     m_pcTDecBinIf->decodeBinEP(uiSign);
    1024 
    1025     UInt uiMaxAbsDQpMinus1 = 24 + (qpBdOffsetY/2) + (uiSign);
    1026     UInt uiAbsDQpMinus1;
    1027     xReadUnaryMaxSymbol (uiAbsDQpMinus1,  &m_cCUDeltaQpSCModel.get( 0, 0, 1 ), 1, uiMaxAbsDQpMinus1);
    1028 
    1029     iDQp = uiAbsDQpMinus1 + 1;
    1030 
    1031     if(uiSign)
    1032     {
    1033       iDQp = -iDQp;
    1034     }
    1035 
    1036     qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+qpBdOffsetY)) - qpBdOffsetY;
    1037   }
    1038 #endif
    1039922  pcCU->setQPSubParts(qp, uiAbsPartIdx, uiDepth); 
    1040923  pcCU->setCodedQP(qp);
     
    1044927{
    1045928  UInt uiSymbol;
    1046   const UInt uiCtx = pcCU->getCtxQtCbf( uiAbsPartIdx, eType, uiTrDepth );
     929  const UInt uiCtx = pcCU->getCtxQtCbf( eType, uiTrDepth );
    1047930  m_pcTDecBinIf->decodeBin( uiSymbol , m_cCUQtCbfSCModel.get( 0, eType ? TEXT_CHROMA: eType, uiCtx ) );
    1048931 
     
    1068951    return;
    1069952  }
    1070 #if !INTER_TRANSFORMSKIP
    1071   if(!pcCU->isIntra(uiAbsPartIdx))
    1072   {
    1073     return;
    1074   }
    1075 #endif
    1076953  if(width != 4 || height != 4)
    1077954  {
     
    12051082    uiHeight = pcCU->getSlice()->getSPS()->getMaxTrSize();
    12061083  }
    1207 #if PPS_TS_FLAG
    12081084  if(pcCU->getSlice()->getPPS()->getUseTransformSkip())
    1209 #else
    1210   if(pcCU->getSlice()->getSPS()->getUseTransformSkip())
    1211 #endif
    12121085  {
    12131086    parseTransformSkipFlags( pcCU, uiAbsPartIdx, uiWidth, uiHeight, uiDepth, eTType);
     
    12211094  const UInt  uiMaxNumCoeffM1   = uiMaxNumCoeff - 1;
    12221095  UInt uiScanIdx = pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, eTType==TEXT_LUMA, pcCU->isIntra(uiAbsPartIdx));
    1223   int blockType = uiLog2BlockSize;
    1224   if (uiWidth != uiHeight)
    1225   {
    1226     uiScanIdx = SCAN_DIAG;
    1227     blockType = 4;
    1228   }
    12291096 
    12301097  //===== decode last significant =====
     
    12351102
    12361103  //===== decode significance flags =====
    1237   UInt uiScanPosLast   = uiBlkPosLast;
    1238   if (uiScanIdx == SCAN_ZIGZAG)
    1239   {
    1240     // Map zigzag to diagonal scan
    1241     uiScanIdx = SCAN_DIAG;
    1242   }
    1243 #if REMOVE_NSQT
    1244   const UInt *scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ];
    1245 #else
    1246   const UInt * scan;
    1247   if (uiWidth == uiHeight)
    1248   {
    1249     scan = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ];
    1250   }
    1251   else
    1252   {
    1253     scan = g_sigScanNSQT[ uiLog2BlockSize - 2 ];
    1254   }
    1255 #endif
     1104  UInt uiScanPosLast = uiBlkPosLast;
     1105  const UInt *scan   = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize-1 ];
    12561106  for( uiScanPosLast = 0; uiScanPosLast < uiMaxNumCoeffM1; uiScanPosLast++ )
    12571107  {
     
    12671117
    12681118  const Int  iLastScanSet      = uiScanPosLast >> LOG2_SCAN_SET_SIZE;
    1269 #if REMOVE_NUM_GREATER1
    12701119  UInt c1 = 1;
    1271 #else
    1272   UInt uiNumOne                = 0;
    1273 #endif
    12741120  UInt uiGoRiceParam           = 0;
    12751121
     
    12891135  const UInt uiNumBlkSide = uiWidth >> (MLS_CG_SIZE >> 1);
    12901136  const UInt * scanCG;
    1291 #if !REMOVE_NSQT
    1292   if (uiWidth == uiHeight)
    1293 #endif
    12941137  {
    12951138    scanCG = g_auiSigLastScan[ uiScanIdx ][ uiLog2BlockSize > 3 ? uiLog2BlockSize-2-1 : 0  ];   
     
    13031146    }
    13041147  }
    1305 #if !REMOVE_NSQT
    1306   else
    1307   {
    1308     scanCG = g_sigCGScanNSQT[ uiLog2BlockSize - 2 ];
    1309   }
    1310 #endif
    13111148  Int  iScanPosSig             = (Int) uiScanPosLast;
    13121149  for( Int iSubSet = iLastScanSet; iSubSet >= 0; iSubSet-- )
     
    13321169    Int iCGPosY   = iCGBlkPos / uiNumBlkSide;
    13331170    Int iCGPosX   = iCGBlkPos - (iCGPosY * uiNumBlkSide);
    1334 #if !REMOVAL_8x2_2x8_CG
    1335     if( uiWidth == 8 && uiHeight == 8 && (uiScanIdx == SCAN_HOR || uiScanIdx == SCAN_VER) )
    1336     {
    1337       iCGPosY = (uiScanIdx == SCAN_HOR ? iCGBlkPos : 0);
    1338       iCGPosX = (uiScanIdx == SCAN_VER ? iCGBlkPos : 0);
    1339     }
    1340 #endif
    13411171    if( iSubSet == iLastScanSet || iSubSet == 0)
    13421172    {
     
    13461176    {
    13471177      UInt uiSigCoeffGroup;
    1348       UInt uiCtxSig  = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiScanIdx, uiWidth, uiHeight );
     1178      UInt uiCtxSig  = TComTrQuant::getSigCoeffGroupCtxInc( uiSigCoeffGroupFlag, iCGPosX, iCGPosY, uiWidth, uiHeight );
    13491179      m_pcTDecBinIf->decodeBin( uiSigCoeffGroup, baseCoeffGroupCtx[ uiCtxSig ] );
    13501180      uiSigCoeffGroupFlag[ iCGBlkPos ] = uiSigCoeffGroup;
     
    13651195        if( iScanPosSig > iSubPos || iSubSet == 0  || numNonZero )
    13661196        {
    1367 #if REMOVAL_8x2_2x8_CG
    1368           uiCtxSig  = TComTrQuant::getSigCtxInc( patternSigCtx, uiScanIdx, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType );
    1369 #else
    1370           uiCtxSig  = TComTrQuant::getSigCtxInc( patternSigCtx, uiPosX, uiPosY, blockType, uiWidth, uiHeight, eTType );
    1371 #endif
     1197          uiCtxSig  = TComTrQuant::getSigCtxInc( patternSigCtx, uiScanIdx, uiPosX, uiPosY, uiLog2BlockSize, eTType );
    13721198          m_pcTDecBinIf->decodeBin( uiSig, baseCtx[ uiCtxSig ] );
    13731199        }
     
    13941220      Bool signHidden = ( lastNZPosInCG - firstNZPosInCG >= SBH_THRESHOLD );
    13951221      absSum = 0;
    1396 #if !REMOVE_NUM_GREATER1
    1397       UInt c1 = 1;
    1398 #endif
    13991222      UInt uiCtxSet    = (iSubSet > 0 && eTType==TEXT_LUMA) ? 2 : 0;
    14001223      UInt uiBin;
    1401 #if REMOVE_NUM_GREATER1
    14021224      if( c1 == 0 )
    1403 #else
    1404       if( uiNumOne > 0 )
    1405 #endif
    14061225      {
    14071226        uiCtxSet++;
    14081227      }
    1409 #if REMOVE_NUM_GREATER1
    14101228      c1 = 1;
    1411 #else
    1412       uiNumOne       >>= 1;
    1413 #endif
    14141229      ContextModel *baseCtxMod = ( eTType==TEXT_LUMA ) ? m_cCUOneSCModel.get( 0, 0 ) + 4 * uiCtxSet : m_cCUOneSCModel.get( 0, 0 ) + NUM_ONE_FLAG_CTX_LUMA + 4 * uiCtxSet;
    14151230      Int absCoeff[SCAN_SET_SIZE];
     
    14801295          {
    14811296            iFirstCoeff2 = 0;
    1482 #if !REMOVE_NUM_GREATER1
    1483             uiNumOne++;
    1484 #endif
    14851297          }
    14861298        }
     
    15101322      }
    15111323    }
    1512 #if !REMOVE_NUM_GREATER1
    1513     else
    1514     {
    1515       uiNumOne >>= 1;
    1516     }
    1517 #endif
    15181324  }
    15191325 
     
    15321338  UInt code;
    15331339  Int  i;
    1534 #if SAO_ABS_BY_PASS
    15351340  m_pcTDecBinIf->decodeBinEP( code );
    1536 #else
    1537   m_pcTDecBinIf->decodeBin( code, m_cSaoUvlcSCModel.get( 0, 0, 0 ) );
    1538 #endif
    15391341  if ( code == 0 )
    15401342  {
     
    15461348  while (1)
    15471349  {
    1548 #if SAO_ABS_BY_PASS
    15491350    m_pcTDecBinIf->decodeBinEP( code );
    1550 #else
    1551     m_pcTDecBinIf->decodeBin( code, m_cSaoUvlcSCModel.get( 0, 0, 1 ) );
    1552 #endif
    15531351    if ( code == 0 )
    15541352    {
     
    15641362  val = i;
    15651363}
    1566 #if SAO_TYPE_CODING
    15671364Void TDecSbac::parseSaoUflc (UInt uiLength, UInt&  riVal)
    15681365{
    15691366  m_pcTDecBinIf->decodeBinsEP ( riVal, uiLength );
    15701367}
    1571 #else
    1572 Void TDecSbac::parseSaoUflc (UInt&  riVal)
    1573 {
    1574   m_pcTDecBinIf->decodeBinsEP ( riVal, 5 );
    1575 }
    1576 #endif
    1577 #if SAO_MERGE_ONE_CTX
    15781368Void TDecSbac::parseSaoMerge (UInt&  ruiVal)
    1579 #else
    1580 Void TDecSbac::parseSaoMergeLeft (UInt&  ruiVal, UInt uiCompIdx)
    1581 #endif
    15821369{
    15831370  UInt uiCode;
    1584 #if SAO_MERGE_ONE_CTX
    15851371  m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeSCModel.get( 0, 0, 0 ) );
    1586 #else
    1587 #if SAO_SINGLE_MERGE
    1588   m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeLeftSCModel.get( 0, 0, 0 ) );
    1589 #else
    1590   m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeLeftSCModel.get( 0, 0, uiCompIdx ) );
    1591 #endif
    1592 #endif
    15931372  ruiVal = (Int)uiCode;
    15941373}
    1595 #if !SAO_MERGE_ONE_CTX
    1596 Void TDecSbac::parseSaoMergeUp (UInt&  ruiVal)
     1374Void TDecSbac::parseSaoTypeIdx (UInt&  ruiVal)
    15971375{
    15981376  UInt uiCode;
    1599   m_pcTDecBinIf->decodeBin( uiCode, m_cSaoMergeUpSCModel.get( 0, 0, 0 ) );
    1600   ruiVal = (Int)uiCode;
    1601 }
    1602 #endif
    1603 Void TDecSbac::parseSaoTypeIdx (UInt&  ruiVal)
    1604 {
    1605   UInt uiCode;
    1606 #if SAO_TYPE_CODING
    16071377  m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) );
    16081378  if (uiCode == 0)
     
    16221392    }
    16231393  }
    1624 #else
    1625   Int  i;
    1626   m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 0 ) );
    1627   if ( uiCode == 0 )
    1628   {
    1629     ruiVal = 0;
    1630     return;
    1631   }
    1632   i=1;
    1633   while (1)
    1634   {
    1635     m_pcTDecBinIf->decodeBin( uiCode, m_cSaoTypeIdxSCModel.get( 0, 0, 1 ) );
    1636     if ( uiCode == 0 )
    1637     {
    1638       break;
    1639     }
    1640     i++;
    1641   }
    1642   ruiVal = i;
    1643 #endif
    16441394}
    16451395
     
    16511401  if (psDst->typeIdx != -1)
    16521402  {
    1653 #if SAO_TYPE_CODING
    16541403    psDst->subTypeIdx = psSrc->subTypeIdx ;
    1655 #else
    1656     if (psDst->typeIdx == SAO_BO)
    1657     {
    1658       psDst->bandPosition = psSrc->bandPosition ;
    1659     }
    1660     else
    1661     {
    1662       psDst->bandPosition = 0;
    1663     }
    1664 #endif
    16651404    psDst->length  = psSrc->length;
    16661405    for (i=0;i<psDst->length;i++)
     
    16791418}
    16801419
    1681 #if SAO_TYPE_SHARING
    16821420Void TDecSbac::parseSaoOffset(SaoLcuParam* psSaoLcuParam, UInt compIdx)
    1683 #else
    1684 Void TDecSbac::parseSaoOffset(SaoLcuParam* psSaoLcuParam)
    1685 #endif
    16861421{
    16871422  UInt uiSymbol;
     
    16951430  };
    16961431
    1697 #if SAO_TYPE_SHARING
    1698 if (compIdx==2)
    1699 {
    1700 uiSymbol = (UInt)( psSaoLcuParam->typeIdx + 1);
    1701 }
    1702 else
    1703 {
    1704 parseSaoTypeIdx(uiSymbol);
    1705 }
    1706 #else
    1707   parseSaoTypeIdx(uiSymbol);
    1708 #endif
     1432  if (compIdx==2)
     1433  {
     1434    uiSymbol = (UInt)( psSaoLcuParam->typeIdx + 1);
     1435  }
     1436  else
     1437  {
     1438    parseSaoTypeIdx(uiSymbol);
     1439  }
    17091440  psSaoLcuParam->typeIdx = (Int)uiSymbol - 1;
    17101441  if (uiSymbol)
    17111442  {
    17121443    psSaoLcuParam->length = iTypeLength[psSaoLcuParam->typeIdx];
    1713 #if FULL_NBIT
    1714     Int offsetTh = 1 << ( min((Int)(g_uiBitDepth + (g_uiBitDepth-8)-5),5) );
    1715 #else
    1716     Int offsetTh = 1 << ( min((Int)(g_uiBitDepth + g_uiBitIncrement-5),5) );
    1717 #endif
     1444
     1445    Int bitDepth = compIdx ? g_bitDepthC : g_bitDepthY;
     1446    Int offsetTh = 1 << min(bitDepth - 5,5);
    17181447
    17191448    if( psSaoLcuParam->typeIdx == SAO_BO )
    17201449    {
    1721 #if !SAO_TYPE_CODING
    1722     // Parse Left Band Index
    1723     parseSaoUflc( uiSymbol );
    1724     psSaoLcuParam->bandPosition = uiSymbol;
    1725 #endif
    17261450      for(Int i=0; i< psSaoLcuParam->length; i++)
    17271451      {
     
    17401464        }
    17411465      }
    1742 #if SAO_TYPE_CODING
    17431466      parseSaoUflc(5, uiSymbol );
    17441467      psSaoLcuParam->subTypeIdx = uiSymbol;
    1745 #endif
    17461468    }
    17471469    else if( psSaoLcuParam->typeIdx < 4 )
     
    17511473      parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[2] = -(Int)uiSymbol;
    17521474      parseSaoMaxUvlc(uiSymbol, offsetTh -1 ); psSaoLcuParam->offset[3] = -(Int)uiSymbol;
    1753 #if SAO_TYPE_CODING
    1754 #if SAO_TYPE_SHARING
    17551475     if (compIdx != 2)
    17561476     {
     
    17591479       psSaoLcuParam->typeIdx += psSaoLcuParam->subTypeIdx;
    17601480     }
    1761 #else
    1762      parseSaoUflc(2, uiSymbol );
    1763      psSaoLcuParam->subTypeIdx = uiSymbol;
    1764      psSaoLcuParam->typeIdx += psSaoLcuParam->subTypeIdx;
    1765 #endif
    1766 #endif
    17671481   }
    17681482  }
     
    17771491  Int iAddr = pcCU->getAddr();
    17781492  UInt uiSymbol;
    1779 #if SAO_SINGLE_MERGE
    17801493  for (Int iCompIdx=0; iCompIdx<3; iCompIdx++)
    17811494  {
    17821495    pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag    = 0;
    17831496    pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag  = 0;
    1784 #if SAO_TYPE_CODING
    17851497    pSaoParam->saoLcuParam[iCompIdx][iAddr].subTypeIdx     = 0;
    1786 #else
    1787     pSaoParam->saoLcuParam[iCompIdx][iAddr].bandPosition   = 0;
    1788 #endif
    17891498    pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx        = -1;
    17901499    pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[0]     = 0;
     
    17941503
    17951504  }
    1796 #if SAO_TYPE_SHARING
    17971505 if (pSaoParam->bSaoFlag[0] || pSaoParam->bSaoFlag[1] )
    1798 #else
    1799  if (pSaoParam->bSaoFlag[0] || pSaoParam->bSaoFlag[1] || pSaoParam->bSaoFlag[2])
    1800 #endif
    18011506  {
    18021507    if (rx>0 && iCUAddrInSlice!=0 && allowMergeLeft)
    18031508    {
    1804 #if SAO_MERGE_ONE_CTX
    18051509      parseSaoMerge(uiSymbol);
    18061510      pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag = (Bool)uiSymbol; 
    1807 #else
    1808       parseSaoMergeLeft(uiSymbol, 0);
    1809       pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag = (Bool)uiSymbol;   
    1810 #endif
    18111511    }
    18121512    if (pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag==0)
     
    18141514      if ((ry > 0) && (iCUAddrUpInSlice>=0) && allowMergeUp)
    18151515      {
    1816 #if SAO_MERGE_ONE_CTX
    18171516        parseSaoMerge(uiSymbol);
    18181517        pSaoParam->saoLcuParam[0][iAddr].mergeUpFlag = (Bool)uiSymbol;
    1819 #else
    1820         parseSaoMergeUp(uiSymbol);
    1821         pSaoParam->saoLcuParam[0][iAddr].mergeUpFlag = (Bool)uiSymbol;
    1822 #endif
    1823       }
    1824     }
    1825   }
    1826 #endif
     1518      }
     1519    }
     1520  }
    18271521
    18281522  for (Int iCompIdx=0; iCompIdx<3; iCompIdx++)
    18291523  {
    1830 #if !SAO_SINGLE_MERGE
    1831     pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag    = 0;
    1832     pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag  = 0;
    1833     pSaoParam->saoLcuParam[iCompIdx][iAddr].bandPosition   = 0;
    1834     pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx        = -1;
    1835     pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[0]     = 0;
    1836     pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[1]     = 0;
    1837     pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[2]     = 0;
    1838     pSaoParam->saoLcuParam[iCompIdx][iAddr].offset[3]     = 0;
    1839 #endif
    1840 #if SAO_TYPE_SHARING
    18411524    if ((iCompIdx == 0  && pSaoParam->bSaoFlag[0]) || (iCompIdx > 0  && pSaoParam->bSaoFlag[1]) )
    1842 #else
    1843     if (pSaoParam->bSaoFlag[iCompIdx])
    1844 #endif
    18451525    {
    18461526      if (rx>0 && iCUAddrInSlice!=0 && allowMergeLeft)
    18471527      {
    1848 #if SAO_SINGLE_MERGE
    18491528        pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = pSaoParam->saoLcuParam[0][iAddr].mergeLeftFlag;
    1850 #else
    1851         parseSaoMergeLeft(uiSymbol,iCompIdx); pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeLeftFlag = (Int)uiSymbol;
    1852 #endif
    18531529      }
    18541530      else
     
    18611537        if ((ry > 0) && (iCUAddrUpInSlice>=0) && allowMergeUp)
    18621538        {
    1863 #if SAO_SINGLE_MERGE
    18641539          pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = pSaoParam->saoLcuParam[0][iAddr].mergeUpFlag;
    1865 #else
    1866           parseSaoMergeUp(uiSymbol);  pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag = uiSymbol;
    1867 #endif
    18681540        }
    18691541        else
     
    18731545        if (!pSaoParam->saoLcuParam[iCompIdx][iAddr].mergeUpFlag)
    18741546        {
    1875 #if SAO_TYPE_SHARING
    18761547          pSaoParam->saoLcuParam[2][iAddr].typeIdx = pSaoParam->saoLcuParam[1][iAddr].typeIdx;
    18771548          parseSaoOffset(&(pSaoParam->saoLcuParam[iCompIdx][iAddr]), iCompIdx);
    1878 #else
    1879           parseSaoOffset(&(pSaoParam->saoLcuParam[iCompIdx][iAddr]));
    1880 #endif
    18811549        }
    18821550        else
     
    18931561    {
    18941562      pSaoParam->saoLcuParam[iCompIdx][iAddr].typeIdx = -1;
    1895 #if SAO_TYPE_CODING
    18961563      pSaoParam->saoLcuParam[iCompIdx][iAddr].subTypeIdx = 0;
    1897 #else
    1898       pSaoParam->saoLcuParam[iCompIdx][iAddr].bandPosition = 0;
    1899 #endif
    1900     }
    1901   }
    1902 }
    1903 
    1904 #if !REMOVE_ALF
    1905 Void TDecSbac::parseAlfCtrlFlag (Int compIdx, UInt& code)
    1906 {
    1907   UInt decodedSymbol;
    1908   m_pcTDecBinIf->decodeBin( decodedSymbol, m_cCUAlfCtrlFlagSCModel.get( 0, 0, 0 ) );
    1909   code = decodedSymbol;
    1910 
    1911   DTRACE_CABAC_VL( g_nSymbolCounter++ )
    1912   DTRACE_CABAC_T( "parseAlfCtrlFlag()" )
    1913   DTRACE_CABAC_T( "\tsymbol=" )
    1914   DTRACE_CABAC_V( decodedSymbol )
    1915   DTRACE_CABAC_T( "\tcompIdx=" )
    1916   DTRACE_CABAC_V( compIdx )
    1917   DTRACE_CABAC_T( "\n" )
    1918 }
    1919 #endif
     1564    }
     1565  }
     1566}
    19201567
    19211568/**
     
    19471594  xCopyContextsFrom(pScr);
    19481595}
    1949 
    1950 Void TDecSbac::decodeFlush ( )
    1951 {
    1952   UInt uiBit;
    1953   m_pcTDecBinIf->decodeBinTrm(uiBit);
    1954   m_pcTDecBinIf->flush();
    1955 
    1956 }
    19571596//! \}
  • trunk/source/Lib/TLibDecoder/TDecSbac.h

    r2 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    5858// ====================================================================================================================
    5959
    60 class SEImessages;
    61 
    6260/// SBAC decoder class
    6361class TDecSbac : public TDecEntropyIf
     
    7472  Void xCopyFrom           ( TDecSbac* pSrc );
    7573  Void xCopyContextsFrom       ( TDecSbac* pSrc );
    76   Void decodeFlush();
    7774
    7875  Void  resetEntropy (TComSlice* pSlice );
    7976  Void  setBitstream              ( TComInputBitstream* p  ) { m_pcBitstream = p; m_pcTDecBinIf->init( p ); }
    80   Void  parseVPS                  ( TComVPS* pcVPS )  {}
    81   Void  parseSPS                  ( TComSPS* pcSPS         ) {}
    82   Void  parsePPS                  ( TComPPS* pcPPS         ) {}
    83 #if !REMOVE_APS
    84   Void  parseAPS                  ( TComAPS* pAPS          ) {}
    85 #endif
     77  Void  parseVPS                  ( TComVPS* /*pcVPS*/ ) {}
     78  Void  parseSPS                  ( TComSPS* /*pcSPS*/ ) {}
     79  Void  parsePPS                  ( TComPPS* /*pcPPS*/ ) {}
    8680
    87   Void  parseSliceHeader          ( TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) {}
     81  Void  parseSliceHeader          ( TComSlice*& /*rpcSlice*/, ParameterSetManagerDecoder* /*parameterSetManager*/) {}
    8882  Void  parseTerminatingBit       ( UInt& ruiBit );
    8983  Void  parseMVPIdx               ( Int& riMVPIdx          );
    9084  Void  parseSaoMaxUvlc           ( UInt& val, UInt maxSymbol );
    91 #if SAO_MERGE_ONE_CTX
    9285  Void  parseSaoMerge         ( UInt&  ruiVal   );
    93 #else
    94   Void  parseSaoMergeLeft         ( UInt&  ruiVal, UInt uiCompIdx   );
    95   Void  parseSaoMergeUp           ( UInt&  ruiVal  );
    96 #endif
    9786  Void  parseSaoTypeIdx           ( UInt&  ruiVal  );
    98 #if SAO_TYPE_CODING
    9987  Void  parseSaoUflc              ( UInt uiLength, UInt& ruiVal     );
    100 #else
    101   Void  parseSaoUflc              ( UInt& ruiVal           );
    102 #endif
    10388  Void  parseSaoOneLcuInterleaving(Int rx, Int ry, SAOParam* pSaoParam, TComDataCU* pcCU, Int iCUAddrInSlice, Int iCUAddrUpInSlice, Int allowMergeLeft, Int allowMergeUp);
    104 #if SAO_TYPE_SHARING
    10589  Void  parseSaoOffset            (SaoLcuParam* psSaoLcuParam, UInt compIdx);
    106 #else
    107   Void  parseSaoOffset            (SaoLcuParam* psSaoLcuParam);
    108 #endif
    10990private:
    11091  Void  xReadUnarySymbol    ( UInt& ruiSymbol, ContextModel* pcSCModel, Int iOffset );
     
    11697  TDecBinIf*        m_pcTDecBinIf;
    11798 
    118 #if !REMOVE_FGS
    119   Int           m_iSliceGranularity; //!< slice granularity
    120 #endif
    121  
    12299public:
    123 #if !REMOVE_ALF
    124   Void parseAlfCtrlFlag   (Int compIdx, UInt& code);
    125 #endif
    126 #if !REMOVE_FGS
    127   /// set slice granularity
    128   Void setSliceGranularity(Int iSliceGranularity)  {m_iSliceGranularity = iSliceGranularity;}
    129 
    130   /// get slice granularity
    131   Int  getSliceGranularity()                       {return m_iSliceGranularity;             }
    132 #endif
    133100 
    134101  Void parseSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
     
    136103  Void parseSplitFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    137104  Void parseMergeFlag     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPUIdx );
    138   Void parseMergeIndex    ( TComDataCU* pcCU, UInt& ruiMergeIndex, UInt uiAbsPartIdx, UInt uiDepth );
     105  Void parseMergeIndex    ( TComDataCU* pcCU, UInt& ruiMergeIndex );
    139106  Void parsePartSize      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    140107  Void parsePredMode      ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
     
    144111  Void parseIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
    145112 
    146   Void parseInterDir      ( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx, UInt uiDepth );
    147   Void parseRefFrmIdx     ( TComDataCU* pcCU, Int& riRefFrmIdx, UInt uiAbsPartIdx, UInt uiDepth, RefPicList eRefList );
     113  Void parseInterDir      ( TComDataCU* pcCU, UInt& ruiInterDir, UInt uiAbsPartIdx );
     114  Void parseRefFrmIdx     ( TComDataCU* pcCU, Int& riRefFrmIdx, RefPicList eRefList );
    148115  Void parseMvd           ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth, RefPicList eRefList );
    149116 
    150117  Void parseTransformSubdivFlag( UInt& ruiSubdivFlag, UInt uiLog2TransformBlockSize );
    151118  Void parseQtCbf         ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth, UInt uiDepth );
    152   Void parseQtRootCbf     ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt& uiQtRootCbf );
     119  Void parseQtRootCbf     ( UInt uiAbsPartIdx, UInt& uiQtRootCbf );
    153120 
    154121  Void parseDeltaQP       ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth );
     
    162129  Void updateContextTables( SliceType eSliceType, Int iQp );
    163130
    164   Void  parseScalingList ( TComScalingList* scalingList ) {}
     131  Void  parseScalingList ( TComScalingList* /*scalingList*/ ) {}
    165132
    166133#if INTRA_BL
     
    179146  ContextModel3DBuffer m_cCUPartSizeSCModel;
    180147  ContextModel3DBuffer m_cCUPredModeSCModel;
    181   ContextModel3DBuffer m_cCUAlfCtrlFlagSCModel;
    182148  ContextModel3DBuffer m_cCUIntraPredSCModel;
    183149  ContextModel3DBuffer m_cCUChromaPredSCModel;
     
    199165  ContextModel3DBuffer m_cMVPIdxSCModel;
    200166 
    201   ContextModel3DBuffer m_cALFFlagSCModel;
    202   ContextModel3DBuffer m_cALFUvlcSCModel;
    203   ContextModel3DBuffer m_cALFSvlcSCModel;
    204167  ContextModel3DBuffer m_cCUAMPSCModel;
    205 #if !SAO_ABS_BY_PASS
    206   ContextModel3DBuffer m_cSaoUvlcSCModel;
    207 #endif
    208 #if SAO_MERGE_ONE_CTX
    209168  ContextModel3DBuffer m_cSaoMergeSCModel;
    210 #else
    211   ContextModel3DBuffer m_cSaoMergeLeftSCModel;
    212   ContextModel3DBuffer m_cSaoMergeUpSCModel;
    213 #endif
     169  ContextModel3DBuffer m_cSaoTypeIdxSCModel;
     170  ContextModel3DBuffer m_cTransformSkipSCModel;
     171  ContextModel3DBuffer m_CUTransquantBypassFlagSCModel;
    214172#if INTRA_BL
    215173  ContextModel3DBuffer m_cIntraBLPredFlagSCModel;
    216174#endif
    217   ContextModel3DBuffer m_cSaoTypeIdxSCModel;
    218   ContextModel3DBuffer m_cTransformSkipSCModel;
    219   ContextModel3DBuffer m_CUTransquantBypassFlagSCModel;
    220175};
    221176
  • trunk/source/Lib/TLibDecoder/TDecSlice.cpp

    r2 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4141//! \{
    4242
     43#if SVC_EXTENSION
     44  ParameterSetMap<TComVPS> ParameterSetManagerDecoder::m_vpsBuffer(MAX_NUM_VPS);
     45#endif
     46
    4347//////////////////////////////////////////////////////////////////////
    4448// Construction/Destruction
     
    5559TDecSlice::~TDecSlice()
    5660{
    57 #if DEPENDENT_SLICES
    5861  for (std::vector<TDecSbac*>::iterator i = CTXMem.begin(); i != CTXMem.end(); i++)
    5962  {
     
    6164  }
    6265  CTXMem.clear();
    63 #endif
    64 }
    65 
    66 #if DEPENDENT_SLICES
     66}
     67
    6768Void TDecSlice::initCtxMem(  UInt i )               
    6869{   
     
    7475  CTXMem.resize(i);
    7576}
    76 #endif
    77 
    78 Void TDecSlice::create( TComSlice* pcSlice, Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth )
     77
     78Void TDecSlice::create()
    7979{
    8080}
     
    106106#if SVC_EXTENSION
    107107Void TDecSlice::init(TDecTop** ppcDecTop,TDecEntropy* pcEntropyDecoder, TDecCu* pcCuDecoder)
     108{
     109  m_pcEntropyDecoder  = pcEntropyDecoder;
     110  m_pcCuDecoder       = pcCuDecoder;
     111  m_ppcTDecTop        = ppcDecTop;
     112}
    108113#else
    109114Void TDecSlice::init(TDecEntropy* pcEntropyDecoder, TDecCu* pcCuDecoder)
    110 #endif
    111115{
    112116  m_pcEntropyDecoder  = pcEntropyDecoder;
    113117  m_pcCuDecoder       = pcCuDecoder;
    114 #if SVC_EXTENSION   
    115   m_ppcTDecTop        = ppcDecTop;
    116 #endif
    117 }
    118 
    119 Void TDecSlice::decompressSlice(TComInputBitstream* pcBitstream, TComInputBitstream** ppcSubstreams, TComPic*& rpcPic, TDecSbac* pcSbacDecoder, TDecSbac* pcSbacDecoders)
     118}
     119#endif
     120
     121Void TDecSlice::decompressSlice(TComInputBitstream** ppcSubstreams, TComPic*& rpcPic, TDecSbac* pcSbacDecoder, TDecSbac* pcSbacDecoders)
    120122{
    121123  TComDataCU* pcCU;
    122124  UInt        uiIsLast = 0;
    123   Int   iStartCUEncOrder = max(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr()/rpcPic->getNumPartInCU(), rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getDependentSliceCurStartCUAddr()/rpcPic->getNumPartInCU());
     125  Int   iStartCUEncOrder = max(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr()/rpcPic->getNumPartInCU(), rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceSegmentCurStartCUAddr()/rpcPic->getNumPartInCU());
    124126  Int   iStartCUAddr = rpcPic->getPicSym()->getCUOrderMap(iStartCUEncOrder);
    125127
     
    194196  UInt uiTileStartLCU;
    195197  UInt uiTileLCUX;
    196   UInt uiTileLCUY;
    197   UInt uiTileWidth;
    198   UInt uiTileHeight;
    199198  Int iNumSubstreamsPerTile = 1; // if independent.
    200 
    201199#if INTRA_BL
    202200  m_pcCuDecoder->setBaseRecPic( rpcPic->getLayerId() > 0 ? rpcPic->getFullPelBaseRec() : NULL);
    203201#endif
    204 #if DEPENDENT_SLICES
    205   Bool bAllowDependence = false;
    206 #if TILES_WPP_ENTROPYSLICES_FLAGS
    207   if( rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceEnabledFlag()&& (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getEntropySliceEnabledFlag()) )
    208 #else
    209   if( rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceEnabledFlag()&& (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getCabacIndependentFlag()) )
    210 #endif
    211   {
    212     bAllowDependence = true;
    213   }
    214   if( bAllowDependence )
    215   {
    216     if( !rpcPic->getSlice(rpcPic->getCurrSliceIdx())->isNextSlice() )
    217     {
    218       uiTileCol = 0;
    219 #if TILES_WPP_ENTROPYSLICES_FLAGS
     202  Bool depSliceSegmentsEnabled = rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceSegmentsEnabledFlag();
     203  uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr();
     204  if( depSliceSegmentsEnabled )
     205  {
     206    if( (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->isNextSlice()) &&
     207       iStartCUAddr != rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr())
     208    {
    220209      if(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())
    221 #else
    222       if(pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc()==2)
    223 #endif
    224       {
     210      {
     211        uiTileCol = rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1);
    225212        m_pcBufferSbacDecoders[uiTileCol].loadContexts( CTXMem[1]  );//2.LCU
     213        if ( (iStartCUAddr%uiWidthInLCUs+1) >= uiWidthInLCUs  )
     214        {
     215          uiTileLCUX = uiTileStartLCU % uiWidthInLCUs;
     216          uiCol     = iStartCUAddr % uiWidthInLCUs;
     217          if(uiCol==uiTileLCUX)
     218          {
     219            CTXMem[0]->loadContexts(pcSbacDecoder);
     220          }
     221        }
    226222      }
    227223      pcSbacDecoder->loadContexts(CTXMem[0] ); //end of depSlice-1
     
    230226    else
    231227    {
    232 #if TILES_WPP_ENTROPYSLICES_FLAGS
    233228      if(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())
    234 #else
    235       if(pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc()==2)
    236 #endif
    237229      {
    238230        CTXMem[1]->loadContexts(pcSbacDecoder);
     
    241233    }
    242234  }
    243 #endif
    244235  for( Int iCUAddr = iStartCUAddr; !uiIsLast && iCUAddr < rpcPic->getNumCUsInFrame(); iCUAddr = rpcPic->getPicSym()->xCalculateNxtCUAddr(iCUAddr) )
    245236  {
     
    249240    uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr();
    250241    uiTileLCUX = uiTileStartLCU % uiWidthInLCUs;
    251     uiTileLCUY = uiTileStartLCU / uiWidthInLCUs;
    252     uiTileWidth = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getTileWidth();
    253     uiTileHeight = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getTileHeight();
    254242    uiCol     = iCUAddr % uiWidthInLCUs;
    255243    // The 'line' is now relative to the 1st line in the slice, not the 1st line in the picture.
    256244    uiLin     = (iCUAddr/uiWidthInLCUs)-(iStartCUAddr/uiWidthInLCUs);
    257245    // inherit from TR if necessary, select substream to use.
    258 #if DEPENDENT_SLICES
    259 #if TILES_WPP_ENTROPYSLICES_FLAGS
    260     if( (pcSlice->getPPS()->getNumSubstreams() > 1) || ( bAllowDependence  && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) ))
    261 #else
    262     if( (pcSlice->getPPS()->getNumSubstreams() > 1) || ( bAllowDependence  && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc()==2) ))
    263 #endif
    264 #else
    265     if( pcSlice->getPPS()->getNumSubstreams() > 1 )
    266 #endif
     246    if( (pcSlice->getPPS()->getNumSubstreams() > 1) || ( depSliceSegmentsEnabled  && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) ))
    267247    {
    268248      // independent tiles => substreams are "per tile".  iNumSubstreams has already been multiplied.
     
    272252      m_pcEntropyDecoder->setBitstream( ppcSubstreams[uiSubStrm] );
    273253      // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line.
    274 #if DEPENDENT_SLICES
    275 #if TILES_WPP_ENTROPYSLICES_FLAGS
    276       if (((pcSlice->getPPS()->getNumSubstreams() > 1) || bAllowDependence ) && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()))
    277 #else
    278       if (((pcSlice->getPPS()->getNumSubstreams() > 1) || bAllowDependence ) && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc()==2))
    279 #endif
    280 #else
    281       if (pcSlice->getPPS()->getNumSubstreams() > 1 && uiCol == uiTileLCUX)
    282 #endif
     254      if (((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled ) && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()))
    283255      {
    284256        // We'll sync if the TR is available.
     
    296268             ((pcCUTR->getSCUAddr()+uiMaxParts-1) < pcSlice->getSliceCurStartCUAddr()) ||
    297269             ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(iCUAddr)))
    298              ))||
    299              (true/*bEnforceDependentSliceRestriction*/ &&
    300              ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) ||
    301              ((pcCUTR->getSCUAddr()+uiMaxParts-1) < pcSlice->getDependentSliceCurStartCUAddr()) ||
    302              ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(iCUAddr)))
    303270             ))
    304271           )
    305272        {
    306 #if DEPENDENT_SLICES
    307           if( (iCUAddr!=0) && ((pcCUTR->getSCUAddr()+uiMaxParts-1) >= pcSlice->getSliceCurStartCUAddr()) && bAllowDependence)
    308           {
    309              pcSbacDecoders[uiSubStrm].loadContexts( &m_pcBufferSbacDecoders[uiTileCol] );
    310           }
    311 #endif
    312273          // TR not available.
    313274        }
     
    328289    if ( (iCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr()) && // 1st in tile.
    329290         (iCUAddr!=0) && (iCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceCurStartCUAddr())/rpcPic->getNumPartInCU())
    330 #if DEPENDENT_SLICES
    331          && (iCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getDependentSliceCurStartCUAddr())/rpcPic->getNumPartInCU())
    332 #endif
     291         && (iCUAddr!=rpcPic->getPicSym()->getPicSCUAddr(rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getSliceSegmentCurStartCUAddr())/rpcPic->getNumPartInCU())
    333292         ) // !1st in frame && !1st in slice
    334293    {
     
    366325    g_bJustDoIt = g_bEncDecTraceEnable;
    367326#endif
    368 #if !SAO_LUM_CHROMA_ONOFF_FLAGS
    369     if ( pcSlice->getSPS()->getUseSAO() && pcSlice->getSaoEnabledFlag() )
    370 #else
    371327    if ( pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) )
    372 #endif
    373     {
    374 #if REMOVE_APS
     328    {
    375329      SAOParam *saoParam = rpcPic->getPicSym()->getSaoParam();
    376 #else
    377       SAOParam *saoParam = pcSlice->getAPS()->getSaoParam();
    378 #endif
    379330      saoParam->bSaoFlag[0] = pcSlice->getSaoEnabledFlag();
    380331      if (iCUAddr == iStartCUAddr)
    381332      {
    382 #if SAO_TYPE_SHARING
    383333        saoParam->bSaoFlag[1] = pcSlice->getSaoEnabledFlagChroma();
    384 #else
    385         saoParam->bSaoFlag[1] = pcSlice->getSaoEnabledFlagCb();
    386         saoParam->bSaoFlag[2] = pcSlice->getSaoEnabledFlagCr();
    387 #endif
    388334      }
    389335      Int numCuInWidth     = saoParam->numCuInWidth;
     
    410356      pcSbacDecoder->parseSaoOneLcuInterleaving(rx, ry, saoParam,pcCU, cuAddrInSlice, cuAddrUpInSlice, allowMergeLeft, allowMergeUp);
    411357    }
    412 #if !REMOVE_ALF
    413     if(pcSlice->getSPS()->getUseALF())
    414     {
    415       UInt alfEnabledFlag;
    416       for(Int compIdx=0; compIdx< 3; compIdx++)
    417       {
    418         alfEnabledFlag = 0;
    419         if(pcSlice->getAlfEnabledFlag(compIdx))
    420         {
    421           pcSbacDecoder->parseAlfCtrlFlag(compIdx, alfEnabledFlag);
    422         }
    423         pcCU->setAlfLCUEnabled((alfEnabledFlag==1)?true:false, compIdx);
    424       }
    425     }
    426 #endif
     358    else if ( pcSlice->getSPS()->getUseSAO() )
     359    {
     360      Int addr = pcCU->getAddr();
     361      SAOParam *saoParam = rpcPic->getPicSym()->getSaoParam();
     362      for (Int cIdx=0; cIdx<3; cIdx++)
     363      {
     364        SaoLcuParam *saoLcuParam = &(saoParam->saoLcuParam[cIdx][addr]);
     365        if ( ((cIdx == 0) && !pcSlice->getSaoEnabledFlag()) || ((cIdx == 1 || cIdx == 2) && !pcSlice->getSaoEnabledFlagChroma()))
     366        {
     367          saoLcuParam->mergeUpFlag   = 0;
     368          saoLcuParam->mergeLeftFlag = 0;
     369          saoLcuParam->subTypeIdx    = 0;
     370          saoLcuParam->typeIdx       = -1;
     371          saoLcuParam->offset[0]     = 0;
     372          saoLcuParam->offset[1]     = 0;
     373          saoLcuParam->offset[2]     = 0;
     374          saoLcuParam->offset[3]     = 0;
     375        }
     376      }
     377    }
    427378    m_pcCuDecoder->decodeCU     ( pcCU, uiIsLast );
    428379    m_pcCuDecoder->decompressCU ( pcCU );
     
    431382    g_bJustDoIt = g_bEncDecTraceDisable;
    432383#endif
    433     /*If at the end of a LCU line but not at the end of a substream, perform CABAC flush*/
    434     if (!uiIsLast && pcSlice->getPPS()->getNumSubstreams() > 1)
    435     {
    436       if ((uiCol == uiTileLCUX+uiTileWidth-1) && (uiLin+iNumSubstreamsPerTile < uiTileLCUY+uiTileHeight))
    437       {
    438         m_pcEntropyDecoder->decodeFlush();
    439       }
    440     }
    441384    pcSbacDecoders[uiSubStrm].load(pcSbacDecoder);
    442385
    443386    //Store probabilities of second LCU in line into buffer
    444 #if DEPENDENT_SLICES
    445 #if TILES_WPP_ENTROPYSLICES_FLAGS
    446     if ( (uiCol == uiTileLCUX+1)&& (bAllowDependence || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) )
    447 #else
    448     if ( (uiCol == uiTileLCUX+1)&& (bAllowDependence || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc() == 2))
    449 #endif
    450 #else
    451     if (pcSlice->getPPS()->getNumSubstreams() > 1 && (uiCol == uiTileLCUX+1))
    452 #endif
     387    if ( (uiCol == uiTileLCUX+1)&& (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) )
    453388    {
    454389      m_pcBufferSbacDecoders[uiTileCol].loadContexts( &pcSbacDecoders[uiSubStrm] );
    455390    }
    456 #if DEPENDENT_SLICES
    457     if( uiIsLast && bAllowDependence )
    458     {
    459 #if TILES_WPP_ENTROPYSLICES_FLAGS
     391    if( uiIsLast && depSliceSegmentsEnabled )
     392    {
    460393      if (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())
    461 #else
    462       if (pcSlice->getPPS()->getTilesOrEntropyCodingSyncIdc()==2)
    463 #endif
    464394       {
    465395         CTXMem[1]->loadContexts( &m_pcBufferSbacDecoders[uiTileCol] );//ctx 2.LCU
     
    468398      return;
    469399    }
    470 #endif
    471400  }
    472401}
    473402
    474403ParameterSetManagerDecoder::ParameterSetManagerDecoder()
     404#if SVC_EXTENSION
     405: m_spsBuffer(MAX_NUM_SPS)
     406, m_ppsBuffer(MAX_NUM_PPS)
     407#else
    475408: m_vpsBuffer(MAX_NUM_VPS)
    476 ,m_spsBuffer(256)
    477 , m_ppsBuffer(16)
    478 #if !REMOVE_APS
    479 , m_apsBuffer(64)
    480 #endif
    481 {
    482 
     409, m_spsBuffer(MAX_NUM_SPS)
     410, m_ppsBuffer(MAX_NUM_PPS)
     411#endif
     412{
    483413}
    484414
     
    525455}
    526456
    527 #if !REMOVE_APS
    528 TComAPS* ParameterSetManagerDecoder::getPrefetchedAPS  (Int apsId)
    529 {
    530   if (m_apsBuffer.getPS(apsId) != NULL )
    531   {
    532     return m_apsBuffer.getPS(apsId);
    533   }
    534   else
    535   {
    536     return getAPS(apsId);
    537   }
    538 }
    539 #endif
    540 
    541457Void     ParameterSetManagerDecoder::applyPrefetchedPS()
    542458{
    543459  m_vpsMap.mergePSList(m_vpsBuffer);
    544 #if !REMOVE_APS
    545   m_apsMap.mergePSList(m_apsBuffer);
    546 #endif
    547460  m_ppsMap.mergePSList(m_ppsBuffer);
    548461  m_spsMap.mergePSList(m_spsBuffer);
  • trunk/source/Lib/TLibDecoder/TDecSlice.h

    r2 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    7171  TDecSbac*       m_pcBufferLowLatSbacDecoders;   ///< dependent tiles: line to store temporary contexts, one per column of tiles.
    7272  TDecBinCABAC*   m_pcBufferLowLatBinCABACs;
    73 #if DEPENDENT_SLICES
    7473  std::vector<TDecSbac*> CTXMem;
    75 #endif
    76 
    7774#if SVC_EXTENSION
    7875  TDecTop**       m_ppcTDecTop;
    79 #endif  
     76#endif
    8077 
    8178public:
     
    8885  Void  init              ( TDecEntropy* pcEntropyDecoder, TDecCu* pcMbDecoder );
    8986#endif
    90   Void  create            ( TComSlice* pcSlice, Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth );
     87  Void  create            ();
    9188  Void  destroy           ();
    9289 
    93   Void  decompressSlice   ( TComInputBitstream* pcBitstream, TComInputBitstream** ppcSubstreams,   TComPic*& rpcPic, TDecSbac* pcSbacDecoder, TDecSbac* pcSbacDecoders );
    94 #if DEPENDENT_SLICES
     90  Void  decompressSlice   ( TComInputBitstream** ppcSubstreams,   TComPic*& rpcPic, TDecSbac* pcSbacDecoder, TDecSbac* pcSbacDecoders );
    9591  Void      initCtxMem(  UInt i );
    96   Void      setCtxMem( TDecSbac* sb, int b )   { CTXMem[b] = sb; }
    97 #endif
    98 
     92  Void      setCtxMem( TDecSbac* sb, Int b )   { CTXMem[b] = sb; }
    9993#if SVC_EXTENSION
    10094  TDecTop*  getLayerDec   ( UInt LayerId )  { return m_ppcTDecTop[LayerId]; } 
    101 #endif 
     95#endif
    10296};
    10397
     
    114108  Void     storePrefetchedPPS(TComPPS *pps)  { m_ppsBuffer.storePS( pps->getPPSId(), pps); };
    115109  TComPPS* getPrefetchedPPS  (Int ppsId);
    116 #if !REMOVE_APS
    117   Void     storePrefetchedAPS(TComAPS *aps)  { m_apsBuffer.storePS( aps->getAPSID(), aps); };
    118   TComAPS* getPrefetchedAPS  (Int apsId);
    119 #endif
    120110  Void     applyPrefetchedPS();
    121111
    122112private:
     113#if SVC_EXTENSION
     114  static ParameterSetMap<TComVPS> m_vpsBuffer;
     115#else
    123116  ParameterSetMap<TComVPS> m_vpsBuffer;
     117#endif
    124118  ParameterSetMap<TComSPS> m_spsBuffer;
    125119  ParameterSetMap<TComPPS> m_ppsBuffer;
    126 #if !REMOVE_APS
    127   ParameterSetMap<TComAPS> m_apsBuffer;
    128 #endif
    129120};
    130121
  • trunk/source/Lib/TLibDecoder/TDecTop.cpp

    r55 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4040
    4141#if SVC_EXTENSION
    42 ParameterSetManagerDecoder TDecTop::m_parameterSetManagerDecoder;  // storage for parameter sets
    4342UInt  TDecTop::m_prevPOC = MAX_UINT;
    4443UInt  TDecTop::m_uiPrevLayerId = MAX_UINT;
     
    5049
    5150TDecTop::TDecTop()
    52 : m_SEIs(0)
    5351{
    5452  m_pcPic = 0;
    55   m_iGopSize      = 0;
    56   m_bGopSizeSet   = false;
    5753  m_iMaxRefPicNum = 0;
    5854#if ENC_DEC_TRACE
     
    6157  g_nSymbolCounter = 0;
    6258#endif
    63   m_bRefreshPending = 0;
    6459  m_pocCRA = 0;
    6560  m_prevRAPisBLA = false;
     
    134129#endif
    135130#if SVC_EXTENSION
    136 #if REMOVE_ALF
    137131  m_cGopDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO);
    138 #else
    139   m_cGopDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cAdaptiveLoopFilter, &m_cSAO);
    140 #endif
    141132  m_cSliceDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cCuDecoder );
    142133#else
    143 #if REMOVE_ALF
    144134  m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO);
    145 #else
    146   m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cAdaptiveLoopFilter, &m_cSAO);
    147 #endif
    148135  m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder );
    149136#endif
     
    156143  if(m_layerId>0)
    157144  {
     145    Int  numReorderPics[MAX_TLAYER];
     146    Window &conformanceWindow = pcSPS->getConformanceWindow();
     147    Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window();
     148
     149    for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++)
     150    {
     151      numReorderPics[temporalLayer] = pcSPS->getNumReorderPics(temporalLayer);
     152    }
     153
    158154    if (m_cIlpPic[0] == NULL)
    159155    {
     
    163159        //m_cIlpPic[j]->createWithOutYuv(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, &m_cSPS, true);
    164160#if SVC_UPSAMPLING
    165         m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, pcSPS, true);
    166 #else
    167         m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true);
    168 #endif
    169 #if REF_IDX_ME_AROUND_ZEROMV || REF_IDX_ME_ZEROMV || REF_IDX_MFM
    170         m_cIlpPic[j]->setIsILR(true);
     161        m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, pcSPS, true);
     162#else
     163        m_cIlpPic[j]->create(pcSPS->getPicWidthInLumaSamples(), pcSPS->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    171164#endif
    172165        for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++)
     
    186179    m_cIlpPic[0]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(), m_cIlpPic[0]->getPicYuvRec());
    187180    m_cIlpPic[0]->getSlice(0)->setPOC(pcPic->getPOC());
     181    m_cIlpPic[0]->setLayerId(0); //set reference layerId
    188182    m_cIlpPic[0]->getPicYuvRec()->setBorderExtension(false);
    189183    m_cIlpPic[0]->getPicYuvRec()->extendPicBorder();
     
    216210  }
    217211 
    218 #if !REMOVE_ALF
    219   // destroy ALF temporary buffers
    220   m_cAdaptiveLoopFilter.destroy();
    221 #endif
    222  
    223212  m_cSAO.destroy();
    224213 
     
    231220}
    232221
    233 Void TDecTop::xUpdateGopSize (TComSlice* pcSlice)
    234 {
    235   if ( !pcSlice->isIntra() && !m_bGopSizeSet)
    236   {
    237     m_iGopSize    = pcSlice->getPOC();
    238     m_bGopSizeSet = true;
    239    
    240     m_cGopDecoder.setGopSize(m_iGopSize);
    241   }
    242 }
    243 
    244222Void TDecTop::xGetNewPicBuffer ( TComSlice* pcSlice, TComPic*& rpcPic )
    245223{
    246   xUpdateGopSize(pcSlice);
    247  
     224  Int  numReorderPics[MAX_TLAYER];
     225  Window &conformanceWindow = pcSlice->getSPS()->getConformanceWindow();
     226  Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window();
     227
     228  for( Int temporalLayer=0; temporalLayer < MAX_TLAYER; temporalLayer++)
     229  {
     230    numReorderPics[temporalLayer] = pcSlice->getSPS()->getNumReorderPics(temporalLayer);
     231  }
     232
    248233  m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer())+pcSlice->getSPS()->getNumReorderPics(pcSlice->getTLayer()) + 1; // +1 to have space for the picture currently being decoded
    249234  if (m_cListPic.size() < (UInt)m_iMaxRefPicNum)
    250235  {
    251236    rpcPic = new TComPic();
    252    
     237
    253238#if SVC_EXTENSION //Temporal solution, should be modified
    254239    if(m_layerId > 0)
     
    265250   
    266251#if SVC_UPSAMPLING
    267     rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, pcSlice->getSPS(), true);
    268 #else
    269     rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true);
    270 #endif
    271 
    272 #if REMOVE_APS
     252    rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
     253                     conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
     254#else
     255    rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
     256                     conformanceWindow, defaultDisplayWindow, numReorderPics, true);
     257#endif
    273258    rpcPic->getPicSym()->allocSaoParam(&m_cSAO);
    274 #endif
    275 
    276 
    277259    m_cListPic.pushBack( rpcPic );
    278260   
     
    314296
    315297#if SVC_UPSAMPLING
    316   rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, pcSlice->getSPS(), true);
    317 #else
    318   rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true);
    319 #endif
    320 #if REMOVE_APS
     298  rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
     299                   conformanceWindow, defaultDisplayWindow, numReorderPics, pcSlice->getSPS(), true);
     300
     301#else
     302  rpcPic->create ( pcSlice->getSPS()->getPicWidthInLumaSamples(), pcSlice->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
     303                   conformanceWindow, defaultDisplayWindow, numReorderPics, true);
     304#endif
    321305  rpcPic->getPicSym()->allocSaoParam(&m_cSAO);
    322 #endif
    323 
    324 
    325 }
    326 
    327 Void TDecTop::executeDeblockAndAlf(UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, Int& iSkipFrame, Int& iPOCLastDisplay)
     306}
     307
     308Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic)
    328309{
    329310  if (!m_pcPic)
     
    335316  TComPic*&   pcPic         = m_pcPic;
    336317
    337   // Execute Deblock and ALF only + Cleanup
     318  // Execute Deblock + Cleanup
    338319
    339320  m_cGopDecoder.filterPicture(pcPic);
     
    342323  pcPic->wrireBLSyntax( getBLSyntaxFile(), SYNTAX_BYTES );
    343324#endif
    344 
    345325  TComSlice::sortPicList( m_cListPic ); // sorting for application output
    346   ruiPOC              = pcPic->getSlice(m_uiSliceIdx-1)->getPOC();
     326  poc                 = pcPic->getSlice(m_uiSliceIdx-1)->getPOC();
    347327  rpcListPic          = &m_cListPic; 
    348328  m_cCuDecoder.destroy();       
     
    356336  printf("\ninserting lost poc : %d\n",iLostPoc);
    357337  TComSlice cFillSlice;
     338#if SVC_EXTENSION
     339  cFillSlice.setSPS( m_parameterSetManagerDecoder[m_layerId].getFirstSPS() );
     340  cFillSlice.setPPS( m_parameterSetManagerDecoder[m_layerId].getFirstPPS() );
     341  cFillSlice.initSlice( m_layerId );
     342#else
    358343  cFillSlice.setSPS( m_parameterSetManagerDecoder.getFirstSPS() );
    359344  cFillSlice.setPPS( m_parameterSetManagerDecoder.getFirstPPS() );
    360 #if SET_SLICE_LAYER_ID
    361   cFillSlice.initSlice( m_parameterSetManagerDecoder.getFirstSPS()->getLayerId() );
    362 #else
    363345  cFillSlice.initSlice();
    364346#endif
    365347  TComPic *cFillPic;
    366348  xGetNewPicBuffer(&cFillSlice,cFillPic);
     349#if SVC_EXTENSION
     350  cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder[m_layerId].getFirstSPS() );
     351  cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder[m_layerId].getFirstPPS() );
     352  cFillPic->getSlice(0)->initSlice( m_layerId );
     353#else
    367354  cFillPic->getSlice(0)->setSPS( m_parameterSetManagerDecoder.getFirstSPS() );
    368355  cFillPic->getSlice(0)->setPPS( m_parameterSetManagerDecoder.getFirstPPS() );
    369 #if SET_SLICE_LAYER_ID
    370   cFillPic->getSlice(0)->initSlice( cFillPic->getLayerId() );
    371 #else
    372356  cFillPic->getSlice(0)->initSlice();
    373357#endif
     
    412396Void TDecTop::xActivateParameterSets()
    413397{
     398#if SVC_EXTENSION
     399  m_parameterSetManagerDecoder[m_layerId].applyPrefetchedPS();
     400 
     401  TComPPS *pps = m_parameterSetManagerDecoder[m_layerId].getPPS(m_apcSlicePilot->getPPSId());
     402  assert (pps != 0);
     403
     404  TComSPS *sps = m_parameterSetManagerDecoder[m_layerId].getSPS(pps->getSPSId());
     405  assert (sps != 0);
     406
     407  if( false == m_parameterSetManagerDecoder[m_layerId].activatePPS(m_apcSlicePilot->getPPSId(), m_apcSlicePilot->getIdrPicFlag()) )
     408#else
    414409  m_parameterSetManagerDecoder.applyPrefetchedPS();
    415 
     410 
    416411  TComPPS *pps = m_parameterSetManagerDecoder.getPPS(m_apcSlicePilot->getPPSId());
    417412  assert (pps != 0);
     
    419414  TComSPS *sps = m_parameterSetManagerDecoder.getSPS(pps->getSPSId());
    420415  assert (sps != 0);
     416
     417  if (false == m_parameterSetManagerDecoder.activatePPS(m_apcSlicePilot->getPPSId(),m_apcSlicePilot->getIdrPicFlag()))
     418#endif
     419  {
     420    printf ("Parameter set activation failed!");
     421    assert (0);
     422  }
    421423
    422424  m_apcSlicePilot->setPPS(pps);
    423425  m_apcSlicePilot->setSPS(sps);
    424426  pps->setSPS(sps);
    425 #if TILES_WPP_ENTROPYSLICES_FLAGS
    426427  pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1);
    427 #else
    428   pps->setNumSubstreams(pps->getTilesOrEntropyCodingSyncIdc() == 2 ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1);
    429 #endif
    430 #if !REMOVE_APS
    431 #if REMOVE_ALF
    432   if(sps->getUseSAO())
    433 #else
    434   if(sps->getUseSAO() || sps->getUseALF())
    435 #endif
    436   {
    437     m_apcSlicePilot->setAPS( m_parameterSetManagerDecoder.getAPS(m_apcSlicePilot->getAPSId())  );
    438   }
    439 #endif
    440428  pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) );
    441429
     
    451439
    452440  m_cSAO.destroy();
    453   m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
     441  m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight );
    454442  m_cLoopFilter.        create( g_uiMaxCUDepth );
    455443}
     
    462450{
    463451  TComPic*&   pcPic         = m_pcPic;
    464 #if SET_SLICE_LAYER_ID
     452#if SVC_EXTENSION
    465453  m_apcSlicePilot->initSlice( nalu.m_layerId );
    466454#else
     
    479467
    480468  m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType);
    481 #if TEMPORAL_LAYER_NON_REFERENCE
    482469  if((m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N) ||
    483470     (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N) ||
     
    486473    m_apcSlicePilot->setTemporalLayerNonReferenceFlag(true);
    487474  }
    488 #endif
    489 #if REMOVE_NAL_REF_FLAG
    490475  m_apcSlicePilot->setReferenced(true); // Putting this as true ensures that picture is referenced the first time it is in an RPS
    491 #else
    492   m_apcSlicePilot->setReferenced(nalu.m_nalRefFlag);
    493 #endif
    494476  m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId);
     477
     478#if SVC_EXTENSION
     479  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder[m_layerId]);
     480#else
    495481  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder);
    496 #if !BYTE_ALIGNMENT
    497   // byte align
    498   {
    499     Int numBitsForByteAlignment = nalu.m_Bitstream->getNumBitsUntilByteAligned();
    500     if ( numBitsForByteAlignment > 0 )
    501     {
    502       UInt bitsForByteAlignment;
    503       nalu.m_Bitstream->read( numBitsForByteAlignment, bitsForByteAlignment );
    504       assert( bitsForByteAlignment == ( ( 1 << numBitsForByteAlignment ) - 1 ) );
    505     }
    506   }
    507 #endif
     482#endif
     483  if (m_apcSlicePilot->isNextSlice())
     484  {
     485    // Skip pictures due to random access
     486    if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
     487    {
     488      return false;
     489    }
     490    // Skip TFD pictures associated with BLA/BLANT pictures
     491    if (isSkipPictureForBLA(iPOCLastDisplay))
     492    {
     493      return false;
     494    }
     495  }
     496
    508497  // exit when a new picture is found
    509498#if SVC_EXTENSION
    510499  bNewPOC = (m_apcSlicePilot->getPOC()!= m_prevPOC);
    511   if (m_apcSlicePilot->isNextSlice() && (bNewPOC || m_layerId!=m_uiPrevLayerId)
    512     && !m_bFirstSliceInSequence )
     500  if (m_apcSlicePilot->isNextSlice() && (bNewPOC || m_layerId!=m_uiPrevLayerId) && !m_bFirstSliceInSequence )
    513501  {
    514502    m_prevPOC = m_apcSlicePilot->getPOC();
     
    540528  }
    541529  m_bFirstSliceInSequence = false;
    542   if (m_apcSlicePilot->isNextSlice())
    543   {
    544     // Skip pictures due to random access
    545     if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay))
    546     {
    547       return false;
    548     }
    549     // Skip TFD pictures associated with BLA/BLANT pictures
    550     if (isSkipPictureForBLA(iPOCLastDisplay))
    551     {
    552       return false;
    553     }
    554   }
    555530  //detect lost reference picture and insert copy of earlier frame.
    556531  Int lostPoc;
     
    566541    TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
    567542    fstream* pFile  = m_ppcTDecTop[0]->getBLReconFile();
    568     UInt uiWidth    = pBLPic->getPicYuvRec()->getWidth() - pBLPic->getPicYuvRec()->getPicCropLeftOffset() - pBLPic->getPicYuvRec()->getPicCropRightOffset();;
    569     UInt uiHeight   = pBLPic->getPicYuvRec()->getHeight() - pBLPic->getPicYuvRec()->getPicCropTopOffset() - pBLPic->getPicYuvRec()->getPicCropBottomOffset();
     543    const Window &conf = pBLPic->getConformanceWindow();
     544    UInt uiWidth    = pBLPic->getPicYuvRec()->getWidth() - conf.getWindowLeftOffset() - conf.getWindowRightOffset();
     545    UInt uiHeight   = pBLPic->getPicYuvRec()->getHeight() - conf.getWindowTopOffset() - conf.getWindowBottomOffset();
    570546       
    571547    if( pFile->good() )
     
    617593    xGetNewPicBuffer (m_apcSlicePilot, pcPic);
    618594
    619     /* transfer any SEI messages that have been received to the picture */
     595    // transfer any SEI messages that have been received to the picture
    620596    pcPic->setSEIs(m_SEIs);
    621     m_SEIs = NULL;
     597    m_SEIs.clear();
    622598
    623599    // Recursive structure
     
    630606    m_cTrQuant.init     ( g_uiMaxCUWidth, g_uiMaxCUHeight, m_apcSlicePilot->getSPS()->getMaxTrSize());
    631607
    632     m_cSliceDecoder.create( m_apcSlicePilot, m_apcSlicePilot->getSPS()->getPicWidthInLumaSamples(), m_apcSlicePilot->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
    633   }
    634 
     608    m_cSliceDecoder.create();
     609  }
     610  else
     611  {
     612    // Check if any new SEI has arrived
     613    if(!m_SEIs.empty())
     614    {
     615      // Currently only decoding Unit SEI message occurring between VCL NALUs copied
     616      SEIMessages &picSEI = pcPic->getSEIs();
     617      SEIMessages decodingUnitInfos = extractSeisByType (m_SEIs, SEI::DECODING_UNIT_INFO);
     618      picSEI.insert(picSEI.end(), decodingUnitInfos.begin(), decodingUnitInfos.end());
     619      deleteSEIs(m_SEIs);
     620    }
     621  }
     622 
    635623  //  Set picture slice pointer
    636624  TComSlice*  pcSlice = m_apcSlicePilot;
     
    712700
    713701  //convert the start and end CU addresses of the slice and dependent slice into encoding order
    714   pcSlice->setDependentSliceCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getDependentSliceCurStartCUAddr()) );
    715   pcSlice->setDependentSliceCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getDependentSliceCurEndCUAddr()) );
     702  pcSlice->setSliceSegmentCurStartCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurStartCUAddr()) );
     703  pcSlice->setSliceSegmentCurEndCUAddr( pcPic->getPicSym()->getPicSCUEncOrder(pcSlice->getSliceSegmentCurEndCUAddr()) );
    716704  if(pcSlice->isNextSlice())
    717705  {
     
    744732  if (bNextSlice)
    745733  {
    746     pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_prevRAPisBLA, m_cListPic);
    747 #if !REF_IDX_FRAMEWORK || AVC_SYNTAX
     734    pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_prevRAPisBLA );
    748735    // Set reference list
     736#if REF_LIST_BUGFIX
     737    if (m_layerId == 0)
     738    {
     739      pcSlice->setRefPicList( m_cListPic );
     740    }
     741#else
    749742    pcSlice->setRefPicList( m_cListPic );
    750743#endif
     
    788781
    789782#if REF_IDX_FRAMEWORK
    790 #if !AVC_SYNTAX
    791     // Set reference list
    792     pcSlice->setRefPicList( m_cListPic );
    793 #endif
    794783    if(m_layerId > 0)
    795784    {
     
    798787      pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic());
    799788#endif
    800 
     789#if REF_LIST_BUGFIX
     790      pcSlice->setRefPicListSvc( m_cListPic, m_cIlpPic);
     791#else
    801792      pcSlice->addRefPicList ( m_cIlpPic,
    802793                               1,
    803794                               ((pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA) &&
    804795                                (pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)) ? 0: -1);
     796#endif
    805797    }
    806798#endif
     
    818810      }
    819811    }
    820     if (pcSlice->isInterB())
     812    if (!pcSlice->isIntra())
    821813    {
    822814      Bool bLowDelay = true;
     
    831823        }
    832824      }
    833       for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++)
    834       {
    835         if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC )
     825      if (pcSlice->isInterB())
     826      {
     827        for (iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(REF_PIC_LIST_1) && bLowDelay; iRefIdx++)
    836828        {
    837           bLowDelay = false;
    838         }
     829          if ( pcSlice->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() > iCurrPOC )
     830          {
     831            bLowDelay = false;
     832          }
     833        }       
    839834      }
    840835
     
    870865      pcSlice->setScalingList ( pcSlice->getPPS()->getScalingList()  );
    871866    }
    872 #if TS_FLAT_QUANTIZATION_MATRIX
    873867    pcSlice->getScalingList()->setUseTransformSkip(pcSlice->getPPS()->getUseTransformSkip());
    874 #endif
    875868    if(!pcSlice->getPPS()->getScalingListPresentFlag() && !pcSlice->getSPS()->getScalingListPresentFlag())
    876869    {
     
    900893 
    901894  m_cEntropyDecoder.decodeVPS( vps );
     895#if SVC_EXTENSION
     896  m_parameterSetManagerDecoder[0].storePrefetchedVPS(vps);
     897#else
    902898  m_parameterSetManagerDecoder.storePrefetchedVPS(vps); 
     899#endif
    903900}
    904901
     
    910907#endif
    911908  m_cEntropyDecoder.decodeSPS( sps );
     909#if SVC_EXTENSION
     910  m_parameterSetManagerDecoder[m_layerId].storePrefetchedSPS(sps);
     911#else
    912912  m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
    913 #if REF_IDX_MFM
    914   m_pcSPS = sps;
    915   setMFMEnabledFlag(sps->getMFMEnabledFlag());
    916 #endif
    917 #if !REMOVE_ALF
    918   m_cAdaptiveLoopFilter.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
    919913#endif
    920914#if REF_IDX_FRAMEWORK
     
    929923{
    930924  TComPPS* pps = new TComPPS();
    931   m_cEntropyDecoder.decodePPS( pps, &m_parameterSetManagerDecoder );
     925  m_cEntropyDecoder.decodePPS( pps );
     926#if SVC_EXTENSION
     927  m_parameterSetManagerDecoder[m_layerId].storePrefetchedPPS( pps );
     928#else
    932929  m_parameterSetManagerDecoder.storePrefetchedPPS( pps );
    933 
    934 #if DEPENDENT_SLICES
    935 #if TILES_WPP_ENTROPYSLICES_FLAGS
    936   if( pps->getDependentSliceEnabledFlag() && (!pps->getEntropySliceEnabledFlag()) )
    937 #else
    938   if( pps->getDependentSliceEnabledFlag() && (!pps->getCabacIndependentFlag()) )
    939 #endif
    940   {
    941 #if TILES_WPP_ENTROPYSLICES_FLAGS
    942     int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1;
    943 #else
    944     int NumCtx = (pps->getTilesOrEntropyCodingSyncIdc() == 2)?2:1;
    945 #endif
     930#endif
     931
     932  if( pps->getDependentSliceSegmentsEnabledFlag() )
     933  {
     934    Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1;
    946935    m_cSliceDecoder.initCtxMem(NumCtx);
    947936    for ( UInt st = 0; st < NumCtx; st++ )
     
    953942    }
    954943  }
    955 #endif
    956 }
    957 
    958 #if !REMOVE_APS
    959 Void TDecTop::xDecodeAPS()
    960 {
    961   TComAPS  *aps = new TComAPS();
    962   allocAPS (aps);
    963   decodeAPS(aps);
    964   m_parameterSetManagerDecoder.storePrefetchedAPS(aps);
    965 }
    966 #endif
    967 
    968 Void TDecTop::xDecodeSEI( TComInputBitstream* bs )
    969 {
    970 #if RECOVERY_POINT_SEI || BUFFERING_PERIOD_AND_TIMING_SEI
    971   if ( m_SEIs == NULL )
    972 #endif
    973   m_SEIs = new SEImessages;
    974 #if BUFFERING_PERIOD_AND_TIMING_SEI
    975   m_SEIs->m_pSPS = m_parameterSetManagerDecoder.getSPS(0);
    976 #endif
    977   m_seiReader.parseSEImessage( bs, *m_SEIs );
     944}
     945
     946Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType )
     947{
     948#if SVC_EXTENSION
     949  if(nalUnitType == NAL_UNIT_SEI_SUFFIX)
     950  {
     951    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveSPS() );
     952  }
     953  else
     954  {
     955    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder[m_layerId].getActiveSPS() );
     956    SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS);
     957    if (activeParamSets.size()>0)
     958    {
     959      SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin());
     960      m_parameterSetManagerDecoder[m_layerId].applyPrefetchedPS();
     961      assert(seiAps->activeSeqParamSetId.size()>0);
     962      if (! m_parameterSetManagerDecoder[m_layerId].activateSPSWithSEI(seiAps->activeSeqParamSetId[0] ))
     963      {
     964        printf ("Warning SPS activation with Active parameter set SEI failed");
     965      }
     966    }
     967  }
     968#else
     969  if(nalUnitType == NAL_UNIT_SEI_SUFFIX)
     970  {
     971    m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
     972  }
     973  else
     974  {
     975    m_seiReader.parseSEImessage( bs, m_SEIs, nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() );
     976    SEIMessages activeParamSets = getSeisByType(m_SEIs, SEI::ACTIVE_PARAMETER_SETS);
     977    if (activeParamSets.size()>0)
     978    {
     979      SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin());
     980      m_parameterSetManagerDecoder.applyPrefetchedPS();
     981      assert(seiAps->activeSeqParamSetId.size()>0);
     982      if (! m_parameterSetManagerDecoder.activateSPSWithSEI(seiAps->activeSeqParamSetId[0] ))
     983      {
     984        printf ("Warning SPS activation with Active parameter set SEI failed");
     985      }
     986    }
     987  }
     988#endif
    978989}
    979990
     
    10011012        if( nalu.m_layerId == 1 && pBLPic->getPicYuvRec() == NULL )
    10021013        {
     1014          TComSPS* sps = new TComSPS();
     1015          Int  numReorderPics[MAX_TLAYER];
     1016          Window &conformanceWindow = sps->getConformanceWindow();
     1017          Window defaultDisplayWindow = sps->getVuiParametersPresentFlag() ? sps->getVuiParameters()->getDefaultDisplayWindow() : Window();
    10031018#if SVC_UPSAMPLING
    10041019#if AVC_SYNTAX
    1005           TComSPS* sps = new TComSPS();
    1006           pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, sps, true);
    1007 #else
    1008           pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL, true);
    1009 #endif
    1010 #else
    1011           pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true);
     1020
     1021          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, sps, true);
     1022#else
     1023          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true);
     1024#endif
     1025#else
     1026          pBLPic->create( m_ppcTDecTop[0]->getBLWidth(), m_ppcTDecTop[0]->getBLHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, onformanceWindow, defaultDisplayWindow, numReorderPics, true);
    10121027#endif
    10131028        }
     
    10191034      xDecodePPS();
    10201035      return false;
    1021 #if !REMOVE_APS
    1022     case NAL_UNIT_APS:
    1023       xDecodeAPS();
    1024       return false;
    1025 #endif
    10261036     
    10271037    case NAL_UNIT_SEI:
    1028       xDecodeSEI( nalu.m_Bitstream );
     1038    case NAL_UNIT_SEI_SUFFIX:
     1039      xDecodeSEI( nalu.m_Bitstream, nalu.m_nalUnitType );
    10291040      return false;
    10301041
    1031 #if NAL_UNIT_TYPES_J1003_D7
    10321042    case NAL_UNIT_CODED_SLICE_TRAIL_R:
    10331043    case NAL_UNIT_CODED_SLICE_TRAIL_N:
     
    10421052    case NAL_UNIT_CODED_SLICE_IDR_N_LP:
    10431053    case NAL_UNIT_CODED_SLICE_CRA:
     1054    case NAL_UNIT_CODED_SLICE_RADL_N:
    10441055    case NAL_UNIT_CODED_SLICE_DLP:
     1056    case NAL_UNIT_CODED_SLICE_RASL_N:
    10451057    case NAL_UNIT_CODED_SLICE_TFD:
    1046 #else
    1047     case NAL_UNIT_CODED_SLICE:
    1048     case NAL_UNIT_CODED_SLICE_TFD:
    1049     case NAL_UNIT_CODED_SLICE_TLA:
    1050     case NAL_UNIT_CODED_SLICE_CRA:
    1051     case NAL_UNIT_CODED_SLICE_CRANT:
    1052     case NAL_UNIT_CODED_SLICE_BLA:
    1053     case NAL_UNIT_CODED_SLICE_BLANT:
    1054     case NAL_UNIT_CODED_SLICE_IDR:
    1055 #endif
    10561058#if SVC_EXTENSION
    10571059      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, curLayerId, bNewPOC);
     
    10751077Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay)
    10761078{
    1077   if (m_prevRAPisBLA && m_apcSlicePilot->getPOC() < m_pocCRA && m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TFD)
     1079  if (m_prevRAPisBLA && m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TFD || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
    10781080  {
    10791081    iPOCLastDisplay++;
     
    11061108  {
    11071109    if (   m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA
    1108 #if !NAL_UNIT_TYPES_J1003_D7
    1109         || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRANT
    1110 #endif
    11111110        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    1112 #if SUPPORT_FOR_RAP_N_LP
    11131111        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
    1114 #endif
    11151112        || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT )
    11161113    {
     
    11181115      m_pocRandomAccess = m_apcSlicePilot->getPOC();
    11191116    }
    1120 #if SUPPORT_FOR_RAP_N_LP
    11211117    else if ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
    1122 #else
    1123     else if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR)
    1124 #endif
    1125     {
    1126       m_pocRandomAccess = 0; // no need to skip the reordered pictures in IDR, they are decodable.
     1118    {
     1119      m_pocRandomAccess = -MAX_INT; // no need to skip the reordered pictures in IDR, they are decodable.
    11271120    }
    11281121    else
    11291122    {
    1130       static bool warningMessage = false;
     1123      static Bool warningMessage = false;
    11311124      if(!warningMessage)
    11321125      {
     
    11381131  }
    11391132  // skip the reordered pictures, if necessary
    1140   else if (m_apcSlicePilot->getPOC() < m_pocRandomAccess && m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TFD)
     1133  else if (m_apcSlicePilot->getPOC() < m_pocRandomAccess && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TFD || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N))
    11411134  {
    11421135    iPOCLastDisplay++;
     
    11471140}
    11481141
    1149 #if !REMOVE_APS
    1150 Void TDecTop::allocAPS (TComAPS* pAPS)
    1151 {
    1152   // we don't know the SPS before it has been activated. These fields could exist
    1153   // depending on the corresponding flags in the APS, but SAO/ALF allocation functions will
    1154   // have to be moved for that
    1155   pAPS->createSaoParam();
    1156   m_cSAO.allocSaoParam(pAPS->getSaoParam());
    1157 #if !REMOVE_ALF
    1158   pAPS->createAlfParam();
    1159 #endif
    1160 }
    1161 #endif
    1162 
    11631142//! \}
  • trunk/source/Lib/TLibDecoder/TDecTop.h

    r55 r125  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    6565{
    6666private:
    67   Int                     m_iGopSize;
    68   Bool                    m_bGopSizeSet;
    6967  Int                     m_iMaxRefPicNum;
    7068 
    71   Bool                    m_bRefreshPending;    ///< refresh pending flag
    7269  Int                     m_pocCRA;            ///< POC number of the latest CRA picture
    7370  Bool                    m_prevRAPisBLA;      ///< true if the previous RAP (CRA/CRANT/BLA/BLANT/IDR) picture is a BLA/BLANT picture
     
    7673  TComList<TComPic*>      m_cListPic;         //  Dynamic buffer
    7774#if SVC_EXTENSION
    78   static ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
     75  ParameterSetManagerDecoder m_parameterSetManagerDecoder[MAX_LAYERS];  // storage for parameter sets
    7976#else
    8077  ParameterSetManagerDecoder m_parameterSetManagerDecoder;  // storage for parameter sets
    8178#endif
    8279
    83 #if REF_IDX_MFM
    84   TComSPS*               m_pcSPS;
    85   Bool                   m_bMFMEnabledFlag;
    86 #endif
    87 
    8880  TComSlice*              m_apcSlicePilot;
    8981 
    90   SEImessages *m_SEIs; ///< "all" SEI messages.  If not NULL, we own the object.
     82  SEIMessages             m_SEIs; ///< List of SEI messages that have been received before the first slice and between slices
    9183
    9284  // functional classes
     
    10294  SEIReader               m_seiReader;
    10395  TComLoopFilter          m_cLoopFilter;
    104 #if !REMOVE_ALF
    105   TComAdaptiveLoopFilter  m_cAdaptiveLoopFilter;
    106 #endif
    10796  TComSampleAdaptiveOffset m_cSAO;
    10897
     
    157146  Void  deletePicBuffer();
    158147
    159   Void executeDeblockAndAlf(UInt& ruiPOC, TComList<TComPic*>*& rpcListPic, Int& iSkipFrame,  Int& iPOCLastDisplay);
     148  Void executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic);
    160149
    161150#if SVC_EXTENSION
     
    183172  Void      setILRPic(TComPic *pcPic);
    184173#endif
    185 #if REF_IDX_MFM
    186   TComSPS*  getSPS()                       {return m_pcSPS;}
    187   Void      setMFMEnabledFlag(Bool flag)   {m_bMFMEnabledFlag = flag;}
    188   Bool      getMFMEnabledFlag()            {return m_bMFMEnabledFlag;}
    189 #endif
    190174
    191175protected:
    192176  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
    193   Void  xUpdateGopSize    (TComSlice* pcSlice);
    194177  Void  xCreateLostPicture (Int iLostPOC);
    195178
    196 #if !REMOVE_APS
    197   Void      decodeAPS( TComAPS* cAPS) { m_cEntropyDecoder.decodeAPS(cAPS); };
    198 #endif
    199179  Void      xActivateParameterSets();
    200180#if SVC_EXTENSION
     
    206186  Void      xDecodeSPS();
    207187  Void      xDecodePPS();
    208 #if !REMOVE_APS
    209   Void      xDecodeAPS();
    210 #endif
    211   Void      xDecodeSEI( TComInputBitstream* bs );
     188  Void      xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType );
    212189
    213 #if !REMOVE_APS
    214   Void      allocAPS (TComAPS* pAPS); //!< memory allocation for APS
    215 #endif
    216190};// END CLASS DEFINITION TDecTop
    217191
Note: See TracChangeset for help on using the changeset viewer.