Changeset 1287 in SHVCSoftware


Ignore:
Timestamp:
17 Jul 2015, 05:43:37 (10 years ago)
Author:
seregin
Message:

port rev 4322 (g_bitDepth)

Location:
branches/SHM-dev/source
Files:
62 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp

    r1273 r1287  
    5757
    5858#if Q0074_COLOUR_REMAPPING_SEI
    59 static Void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* colourRemappingInfoSEI, UInt layerId=0 );
     59static Void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* colourRemappingInfoSEI, const BitDepths& bitDpeths, UInt layerId=0 );
    6060static std::vector<SEIColourRemappingInfo> storeCriSEI; //Persistent Colour Remapping Information SEI
    6161static SEIColourRemappingInfo *seiColourRemappingInfoPrevious=NULL ;
     
    290290#endif
    291291    {
    292       // Set bitdepth for each layer when doing DBF
    293       g_bitDepth[CHANNEL_TYPE_LUMA]   = g_bitDepthLayer[CHANNEL_TYPE_LUMA][curLayerId];
    294       g_bitDepth[CHANNEL_TYPE_CHROMA] = g_bitDepthLayer[CHANNEL_TYPE_CHROMA][curLayerId];
    295 
    296292      if (!loopFiltered[curLayerId] || bitstreamFile)
    297293      {
     
    322318      if ( m_pchReconFile[curLayerId] && !openedReconFile[curLayerId] )
    323319      {
     320        const BitDepths &bitDepths=pcListPic->front()->getSlice(0)->getBitDepths(); // use bit depths of first reconstructed picture.
    324321        for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
    325322        {
    326323          if (m_outputBitDepth[channelType] == 0)
    327324          {
    328             m_outputBitDepth[channelType] = g_bitDepth[channelType];
     325            m_outputBitDepth[channelType] = bitDepths.recon[channelType];
    329326          }
    330327        }
    331         m_acTVideoIOYuvReconFile[curLayerId].open( m_pchReconFile[curLayerId], true, m_outputBitDepth, m_outputBitDepth, g_bitDepth ); // write mode
     328        m_acTVideoIOYuvReconFile[curLayerId].open( m_pchReconFile[curLayerId], true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode
    332329
    333330        openedReconFile[curLayerId] = true;
     
    541538      if ( m_pchReconFile && !openedReconFile )
    542539      {
     540        const BitDepths &bitDepths=pcListPic->front()->getPicSym()->getSPS().getBitDepths(); // use bit depths of first reconstructed picture.
    543541        for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
    544542        {
    545543          if (m_outputBitDepth[channelType] == 0)
    546544          {
    547             m_outputBitDepth[channelType] = g_bitDepth[channelType];
     545            m_outputBitDepth[channelType] = bitDepths.recon[channelType];
    548546          }
    549547        }
    550548
    551         m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepth, m_outputBitDepth, g_bitDepth ); // write mode
     549        m_cTVideoIOYuvReconFile.open( m_pchReconFile, true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode
    552550        openedReconFile = true;
    553551      }
     
    12981296      {
    12991297        //printf ("\n\nColour Remapping is applied to POC : %d and LayerId : %d ",pic->getPOC(), pic->getLayerId());
    1300         applyColourRemapping(*pic->getPicYuvRec(), seiColourRemappingInfo
    13011298#if SVC_EXTENSION
    1302        , pic->getLayerId()
    1303 #endif
    1304         );
     1299        applyColourRemapping(*pic->getPicYuvRec(), seiColourRemappingInfo, pic->getSlice(0)->getBitDepths(), pic->getLayerId());
     1300#else
     1301        applyColourRemapping(*pic->getPicYuvRec(), seiColourRemappingInfo, pic->getSlice(0)->getBitDepths());
     1302#endif
    13051303      }
    13061304      else  // using the last CRI SEI received
     
    13081306        const SEIColourRemappingInfo *seiColourRemappingInfoCopy;
    13091307        seiColourRemappingInfoCopy = seiColourRemappingInfoPrevious;
    1310         applyColourRemapping(*pic->getPicYuvRec(), seiColourRemappingInfoCopy
    13111308#if SVC_EXTENSION
    1312         , pic->getLayerId()
    1313 #endif
    1314         );
     1309        applyColourRemapping(*pic->getPicYuvRec(), seiColourRemappingInfoCopy, pic->getSlice(0)->getBitDepths(), pic->getLayerId());
     1310#else
     1311        applyColourRemapping(*pic->getPicYuvRec(), seiColourRemappingInfoCopy, pic->getSlice(0)->getBitDepths());
     1312#endif
    13151313      }
    13161314
     
    15451543
    15461544        TComPictureHash recon_digest;
    1547         Int numChar = calcMD5(*pic->getPicYuvRec(), recon_digest);
     1545        Int numChar = calcMD5(*pic->getPicYuvRec(), recon_digest, pic->getSlice(0)->getBitDepths());
    15481546        fprintf(fptr, "%8d%9d    MD5:%s\n", pic->getLayerId(), pic->getSlice(0)->getPOC(), hashToString(recon_digest, numChar).c_str());
    15491547        fclose(fptr);
     
    15701568      if( this->getDecodedYuvLayerRefresh(layerId) )
    15711569      {
    1572         m_outputBitDepth[CHANNEL_TYPE_LUMA]   = g_bitDepth[CHANNEL_TYPE_LUMA]   = g_bitDepthLayer[CHANNEL_TYPE_LUMA][layerId];
    1573         m_outputBitDepth[CHANNEL_TYPE_CHROMA] = g_bitDepth[CHANNEL_TYPE_CHROMA] = g_bitDepthLayer[CHANNEL_TYPE_CHROMA][layerId];
    1574 
    15751570        char tempFileName[256];
    15761571        strcpy(tempFileName, this->getDecodedYuvLayerFileName( layerId ).c_str());
    1577         m_confReconFile[layerId].open(tempFileName, true, m_outputBitDepth, m_outputBitDepth, g_bitDepth ); // write mode
     1572
     1573        const TComVPS *vps = m_acTDecTop->getLayerDec(layerId)->getParameterSetManager()->getActiveVPS();
     1574        const TComSPS *sps = m_acTDecTop->getLayerDec(layerId)->getParameterSetManager()->getActiveSPS();
     1575        const BitDepths &bitDpeths = vps->getBitDepths(sps, layerId);
     1576        Int bitDepth[] = {bitDpeths.recon[CHANNEL_TYPE_LUMA], bitDpeths.recon[CHANNEL_TYPE_CHROMA]};
     1577
     1578        m_confReconFile[layerId].open(tempFileName, true, m_outputBitDepth, m_outputBitDepth, bitDepth ); // write mode
    15781579        this->setDecodedYuvLayerRefresh( layerId, false );
    15791580      }
     
    18451846
    18461847#if Q0074_COLOUR_REMAPPING_SEI
    1847 Void xInitColourRemappingLut( const Int bitDepthY, const Int bitDepthC, std::vector<Int>(&preLut)[3], std::vector<Int>(&postLut)[3], const SEIColourRemappingInfo* const pCriSEI )
     1848Void xInitColourRemappingLut( const BitDepths &bitDepths, std::vector<Int>(&preLut)[3], std::vector<Int>(&postLut)[3], const SEIColourRemappingInfo* const pCriSEI )
    18481849{
    18491850  for ( Int c=0 ; c<3 ; c++ )
    18501851  { 
    1851     Int bitDepth = c ? bitDepthC : bitDepthY ;
     1852    Int bitDepth = bitDepths.recon[toChannelType(ComponentID(c))];
    18521853    preLut[c].resize(1 << bitDepth);
    18531854    postLut[c].resize(1 << pCriSEI->m_colourRemapBitDepth);
     
    19021903}
    19031904
    1904 static void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* pCriSEI, UInt layerId )
     1905static Void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* pCriSEI, const BitDepths& bitDpeths, UInt layerId )
    19051906
    19061907  if( !storeCriSEI.size() )
     
    19401941    YUVOut[2] = picColourRemapped.getAddr(COMPONENT_Cr);
    19411942
    1942 #if SVC_EXTENSION
    1943     Int bitDepthY = g_bitDepthLayer[CHANNEL_TYPE_LUMA][layerId];
    1944     Int bitDepthC = g_bitDepthLayer[CHANNEL_TYPE_CHROMA][layerId];
    1945 
    1946 #else
    1947     Int bitDepthY = g_bitDepth[CHANNEL_TYPE_LUMA];
    1948     Int bitDepthC = g_bitDepth[CHANNEL_TYPE_CHROMA];
    1949 #endif
    1950 
    19511943    std::vector<Int> preLut[3];
    19521944    std::vector<Int> postLut[3];
    1953     xInitColourRemappingLut( bitDepthY, bitDepthC, preLut, postLut, &storeCriSEI[layerId] );
     1945    xInitColourRemappingLut( bitDpeths, preLut, postLut, &storeCriSEI[layerId] );
    19541946   
    19551947    Int roundingOffset = (storeCriSEI[layerId].m_log2MatrixDenom==0) ? 0 : (1 << (storeCriSEI[layerId].m_log2MatrixDenom - 1));
  • branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.h

    r1259 r1287  
    9696  Void  xInitDecLib       (); ///< initialize decoder class
    9797 
     98#if Q0074_COLOUR_REMAPPING_SEI
     99  Void  xInitColourRemappingLut( const BitDepths &bitDepths, std::vector<Int>(&preLut)[3], std::vector<Int>(&postLut)[3], const SEIColourRemappingInfo* const pCriSEI );
     100#endif
    98101#if SVC_EXTENSION
    99102  Void  xWriteOutput      ( TComList<TComPic*>* pcListPic, UInt layerId, UInt tId ); ///< write YUV to file
  • branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp

    r1286 r1287  
    43084308  g_uiMaxCUDepth = m_uiMaxCUDepth;
    43094309#endif
    4310 
    4311   // set internal bit-depth and constants
    4312   for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
    4313   {
    4314 #if O0043_BEST_EFFORT_DECODING
    4315     g_bitDepthInStream[channelType] = g_bitDepth[channelType] = m_internalBitDepth[channelType];
    4316 #else
    4317     g_bitDepth   [channelType] = m_internalBitDepth[channelType];
    4318 #endif
    4319   }
    43204310}
    43214311#endif
     
    44894479  printf("TOOL CFG: ");
    44904480#if !SVC_EXTENSION
    4491   printf("IBD:%d ", ((g_bitDepth[CHANNEL_TYPE_LUMA] > m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA]) || (g_bitDepth[CHANNEL_TYPE_CHROMA] > m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA])));
     4481  printf("IBD:%d ", ((m_internalBitDepth[CHANNEL_TYPE_LUMA] > m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA]) || (m_internalBitDepth[CHANNEL_TYPE_CHROMA] > m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA])));
    44924482#endif
    44934483  printf("HAD:%d ", m_bUseHADME           );
  • branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp

    r1285 r1287  
    217217  {
    218218    //1
    219     g_bitDepth[CHANNEL_TYPE_LUMA]   = m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA];
    220     g_bitDepth[CHANNEL_TYPE_CHROMA] = m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA];
    221 
    222     // Set this to be used in Upsampling filter in function "TComUpsampleFilter::upsampleBasePic"
    223     g_bitDepthLayer[CHANNEL_TYPE_LUMA][m_acLayerCfg[layer].m_layerId]   = g_bitDepth[CHANNEL_TYPE_LUMA];
    224     g_bitDepthLayer[CHANNEL_TYPE_CHROMA][m_acLayerCfg[layer].m_layerId] = g_bitDepth[CHANNEL_TYPE_CHROMA];
    225 
    226219    m_acTEncTop[layer].setInterLayerWeightedPredFlag                      ( m_useInterLayerWeightedPred );
    227220   
     
    475468    for( UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++ )
    476469    {
    477       m_acTEncTop[layer].setPCMBitDepth                                      ((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_MSBExtendedBitDepth[channelType] : m_acLayerCfg[layer].m_internalBitDepth[channelType]);
     470      m_acTEncTop[layer].setBitDepth                                       ((ChannelType)channelType, m_acLayerCfg[layer].m_internalBitDepth[channelType]);
     471      m_acTEncTop[layer].setPCMBitDepth                                    ((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_acLayerCfg[layer].m_MSBExtendedBitDepth[channelType] : m_acLayerCfg[layer].m_internalBitDepth[channelType]);
    478472    }
    479473    m_acTEncTop[layer].setPCMLog2MaxSize                                   ( m_pcmLog2MaxSize);
     
    904898  for (UInt channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++)
    905899  {
    906 //#if O0043_BEST_EFFORT_DECODING
    907     //g_bitDepthInStream[channelType] = g_bitDepth[channelType] = m_internalBitDepth[channelType];
    908 //#else
    909     //g_bitDepth   [channelType] = m_internalBitDepth[channelType];
    910 //#endif
     900    m_cTEncTop.setBitDepth((ChannelType)channelType, m_internalBitDepth[channelType]);
    911901    m_cTEncTop.setPCMBitDepth((ChannelType)channelType, m_bPCMInputBitDepthFlag ? m_MSBExtendedBitDepth[channelType] : m_internalBitDepth[channelType]);
    912902  }
     
    10941084  {
    10951085    //2
    1096     for( UInt channelTypeIndex = 0; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++)
    1097     {
    1098       g_bitDepth[channelTypeIndex]    = m_acLayerCfg[layer].m_internalBitDepth[channelTypeIndex];
    1099     }
    1100 
    11011086#if LAYER_CTB
    11021087    g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
     
    11931178  {
    11941179    //3
    1195     for (UInt channelTypeIndex = 0; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++)
    1196     {
    1197       g_bitDepth[channelTypeIndex]    = m_acLayerCfg[layer].m_internalBitDepth[channelTypeIndex];
    1198     }
    11991180#if LAYER_CTB
    12001181    g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
     
    12331214        Int layerIdx = vps->getLayerIdxInVps(m_layerSetLayerIdList[setId][i]);
    12341215        //4
    1235         g_bitDepth[CHANNEL_TYPE_LUMA]   = m_acLayerCfg[layerIdx].m_internalBitDepth[CHANNEL_TYPE_LUMA];
    1236         g_bitDepth[CHANNEL_TYPE_CHROMA] = m_acLayerCfg[layerIdx].m_internalBitDepth[CHANNEL_TYPE_CHROMA];
    1237 
    12381216        vps->setLayerIdIncludedFlag(true, setId, layerId);
    12391217      }
     
    12501228        //4
    12511229        UInt layerId = vps->getLayerIdInNuh(layerIdx);
    1252         g_bitDepth[CHANNEL_TYPE_LUMA]   = m_acLayerCfg[layerIdx].m_internalBitDepth[CHANNEL_TYPE_LUMA];
    1253         g_bitDepth[CHANNEL_TYPE_CHROMA] = m_acLayerCfg[layerIdx].m_internalBitDepth[CHANNEL_TYPE_CHROMA];
    12541230
    12551231        if (layerId <= setId)
     
    17021678  {
    17031679    //5
    1704     g_bitDepth[CHANNEL_TYPE_LUMA]   = m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA];
    1705     g_bitDepth[CHANNEL_TYPE_CHROMA] = m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA];
    1706 
    17071680    // allocate original YUV buffer
    17081681    pcPicYuvOrg[layer] = new TComPicYuv;
     
    17391712      {
    17401713        //6
    1741         for (UInt channelTypeIndex = 0; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++)
    1742         {
    1743           g_bitDepth[channelTypeIndex]    = m_acLayerCfg[layer].m_internalBitDepth[channelTypeIndex];
    1744         }
    17451714#if LAYER_CTB
    17461715        g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
     
    17591728        if( m_acLayerCfg[layer].getChromaFormatIDC() == CHROMA_400 || (m_apcTEncTop[0]->getVPS()->getScalabilityMask(AUX_ID) && (m_acLayerCfg[layer].getAuxId() == AUX_ALPHA || m_acLayerCfg[layer].getAuxId() == AUX_DEPTH)) )
    17601729        {
    1761           pcPicYuvOrg[layer]->convertToMonochrome();
     1730          pcPicYuvOrg[layer]->convertToMonochrome(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
    17621731        }
    17631732#endif
     
    18231792      {
    18241793        //7
    1825         for( UInt channelTypeIndex = 0; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++ )
    1826         {
    1827           g_bitDepth[channelTypeIndex]    = m_acLayerCfg[layer].m_internalBitDepth[channelTypeIndex];
    1828         }
    18291794#if LAYER_CTB
    18301795        g_uiMaxCUWidth  = g_auiLayerMaxCUWidth[layer];
     
    18951860    {
    18961861      //8
    1897       for( UInt channelTypeIndex = 0; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++ )
    1898       {
    1899         g_bitDepth[channelTypeIndex]    = m_acLayerCfg[layer].m_internalBitDepth[channelTypeIndex];
    1900       }
    1901 
    19021862      // write bistream to file if necessary
    19031863      iNumEncoded = m_acTEncTop[layer].getNumPicRcvd();
     
    19831943  for(layer = 0; layer < m_numLayers; layer++)
    19841944  {
    1985     m_gcAnalyzeAll[layer].printOut('a', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, layer);
     1945    const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
     1946
     1947    m_gcAnalyzeAll[layer].printOut('a', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
    19861948  }
    19871949
     
    19891951  for(layer = 0; layer < m_numLayers; layer++)
    19901952  {
    1991     m_gcAnalyzeI[layer].printOut('i', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, layer);
     1953    const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
     1954
     1955    m_gcAnalyzeI[layer].printOut('i', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
    19921956  }
    19931957
     
    19951959  for(layer = 0; layer < m_numLayers; layer++)
    19961960  {
    1997     m_gcAnalyzeP[layer].printOut('p', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, layer);
     1961    const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
     1962
     1963    m_gcAnalyzeP[layer].printOut('p', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
    19981964  }
    19991965
     
    20011967  for(layer = 0; layer < m_numLayers; layer++)
    20021968  {
    2003     m_gcAnalyzeB[layer].printOut('b', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, layer);
     1969    const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
     1970
     1971    m_gcAnalyzeB[layer].printOut('b', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
    20041972  }
    20051973
     
    20081976    for(layer = 0; layer < m_numLayers; layer++)
    20091977    {
     1978      const BitDepths bitDepths(m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_LUMA], m_acLayerCfg[layer].m_internalBitDepth[CHANNEL_TYPE_CHROMA]);
     1979
    20101980      //-- interlaced summary
    20111981      m_gcAnalyzeAll_in.setFrmRate( m_acLayerCfg[layer].getFrameRate());
     
    20141984
    20151985      printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" );
    2016       m_gcAnalyzeAll_in.printOut('a', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, layer);
     1986      m_gcAnalyzeAll_in.printOut('a', m_acLayerCfg[layer].getChromaFormatIDC(), printMSEBasedSNR, printSequenceMSE, bitDepths, layer);
    20171987
    20181988#if _SUMMARY_OUT_
  • branches/SHM-dev/source/Lib/TLibCommon/CommonDef.h

    r1283 r1287  
    144144// ====================================================================================================================
    145145
    146 extern Int g_bitDepth[MAX_NUM_CHANNEL_TYPE];
    147 
    148 #if SVC_EXTENSION
    149 extern Int  g_bitDepthLayer[MAX_NUM_CHANNEL_TYPE][MAX_LAYERS];
    150 extern void* g_refWeightACDCParam; //type:wpACDCParam
    151 #endif
    152 
    153146template <typename T> inline T Clip3 (const T minVal, const T maxVal, const T a) { return std::min<T> (std::max<T> (minVal, a) , maxVal); }  ///< general min/max clip
    154147template <typename T> inline T ClipBD(const T x, const Int bitDepth)             { return Clip3(T(0), T((1 << bitDepth)-1), x);           }
    155 template <typename T> inline T Clip  (const T x, const ChannelType type)         { return ClipBD(x, g_bitDepth[type]);                    }
    156148
    157149template <typename T> inline Void Check3( T minVal, T maxVal, T a)
  • branches/SHM-dev/source/Lib/TLibCommon/TComChromaFormat.h

    r1285 r1287  
    163163//------------------------------------------------
    164164
    165 static inline Int getTransformShift(const ChannelType type, const UInt uiLog2TrSize, const Int maxLog2TrDynamicRange)
    166 {
    167 #if O0043_BEST_EFFORT_DECODING
    168   return maxLog2TrDynamicRange - g_bitDepthInStream[type] - uiLog2TrSize;
    169 #else
    170   return maxLog2TrDynamicRange - g_bitDepth[type] - uiLog2TrSize;
    171 #endif
     165static inline Int getTransformShift(const Int channelBitDepth, const UInt uiLog2TrSize, const Int maxLog2TrDynamicRange)
     166{
     167  return maxLog2TrDynamicRange - channelBitDepth - uiLog2TrSize;
    172168}
    173169
  • branches/SHM-dev/source/Lib/TLibCommon/TComInterpolationFilter.cpp

    r1260 r1287  
    338338 * \param  fmt        Chroma format
    339339 */
    340 Void TComInterpolationFilter::filterHor(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isLast, const ChromaFormat fmt )
     340Void TComInterpolationFilter::filterHor(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isLast, const ChromaFormat fmt, const Int bitDepth )
    341341{
    342342  if ( frac == 0 )
    343343  {
    344     filterCopy(g_bitDepth[toChannelType(compID)], src, srcStride, dst, dstStride, width, height, true, isLast );
     344    filterCopy(bitDepth, src, srcStride, dst, dstStride, width, height, true, isLast );
    345345  }
    346346  else if (isLuma(compID))
    347347  {
    348348    assert(frac >= 0 && frac < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
    349     filterHor<NTAPS_LUMA>(g_bitDepth[toChannelType(compID)], src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilter[frac]);
     349    filterHor<NTAPS_LUMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilter[frac]);
    350350  }
    351351  else
     
    353353    const UInt csx = getComponentScaleX(compID, fmt);
    354354    assert(frac >=0 && csx<2 && (frac<<(1-csx)) < CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
    355     filterHor<NTAPS_CHROMA>(g_bitDepth[toChannelType(compID)], src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilter[frac<<(1-csx)]);
     355    filterHor<NTAPS_CHROMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isLast, m_chromaFilter[frac<<(1-csx)]);
    356356  }
    357357}
     
    373373 * \param  fmt        Chroma format
    374374 */
    375 Void TComInterpolationFilter::filterVer(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast, const ChromaFormat fmt )
     375Void TComInterpolationFilter::filterVer(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast, const ChromaFormat fmt, const Int bitDepth )
    376376{
    377377  if ( frac == 0 )
    378378  {
    379     filterCopy(g_bitDepth[toChannelType(compID)], src, srcStride, dst, dstStride, width, height, isFirst, isLast );
     379    filterCopy(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast );
    380380  }
    381381  else if (isLuma(compID))
    382382  {
    383383    assert(frac >= 0 && frac < LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
    384     filterVer<NTAPS_LUMA>(g_bitDepth[toChannelType(compID)], src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilter[frac]);
     384    filterVer<NTAPS_LUMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilter[frac]);
    385385  }
    386386  else
     
    388388    const UInt csy = getComponentScaleY(compID, fmt);
    389389    assert(frac >=0 && csy<2 && (frac<<(1-csy)) < CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS);
    390     filterVer<NTAPS_CHROMA>(g_bitDepth[toChannelType(compID)], src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilter[frac<<(1-csy)]);
     390    filterVer<NTAPS_CHROMA>(bitDepth, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_chromaFilter[frac<<(1-csy)]);
    391391  }
    392392}
  • branches/SHM-dev/source/Lib/TLibCommon/TComInterpolationFilter.h

    r1259 r1287  
    7373  ~TComInterpolationFilter() {}
    7474
    75   Void filterHor(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac,               Bool isLast, const ChromaFormat fmt );
    76   Void filterVer(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast, const ChromaFormat fmt );
     75  Void filterHor(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac,               Bool isLast, const ChromaFormat fmt, const Int bitDepth );
     76  Void filterVer(const ComponentID compID, Pel *src, Int srcStride, Pel *dst, Int dstStride, Int width, Int height, Int frac, Bool isFirst, Bool isLast, const ChromaFormat fmt, const Int bitDepth );
    7777};
    7878
  • branches/SHM-dev/source/Lib/TLibCommon/TComLoopFilter.cpp

    r1260 r1287  
    564564  Pel* piSrc    = pcPicYuvRec->getAddr(COMPONENT_Y, pcCU->getCtuRsAddr(), uiAbsZorderIdx );
    565565  Pel* piTmpSrc = piSrc;
     566#if SVC_EXTENSION
     567  const Int bitDepthLuma = pcCU->getSlice()->getBitDepth(CHANNEL_TYPE_LUMA);
     568#else
     569  const Int bitDepthLuma = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
     570#endif
    566571
    567572  const Bool lfCrossSliceBoundaryFlag=pcCU->getSlice()->getLFCrossSliceBoundaryFlag();
     
    600605  }
    601606
     607  const Int iBitdepthScale = 1 << (bitDepthLuma-8);
     608
    602609  for ( UInt iIdx = 0; iIdx < uiNumParts; iIdx++ )
    603610  {
     
    620627      iQP_P = pcCUP->getQP(uiPartPIdx);
    621628      iQP = (iQP_P + iQP_Q + 1) >> 1;
    622       Int iBitdepthScale = 1 << (g_bitDepth[CHANNEL_TYPE_LUMA]-8);
    623629
    624630      Int iIndexTC = Clip3(0, MAX_QP+DEFAULT_INTRA_TC_OFFSET, Int(iQP + DEFAULT_INTRA_TC_OFFSET*(uiBs-1) + (tcOffsetDiv2 << 1)));
     
    666672          for ( Int i = 0; i < DEBLOCK_SMALLEST_BLOCK/2; i++)
    667673          {
    668             xPelFilterLuma( piTmpSrc+iSrcStep*(iIdx*uiPelsInPart+iBlkIdx*4+i), iOffset, iTc, sw, bPartPNoFilter, bPartQNoFilter, iThrCut, bFilterP, bFilterQ);
     674            xPelFilterLuma( piTmpSrc+iSrcStep*(iIdx*uiPelsInPart+iBlkIdx*4+i), iOffset, iTc, sw, bPartPNoFilter, bPartQNoFilter, iThrCut, bFilterP, bFilterQ, bitDepthLuma);
    669675          }
    670676        }
     
    681687  Pel*        piSrcCb     = pcPicYuvRec->getAddr( COMPONENT_Cb, pcCU->getCtuRsAddr(), uiAbsZorderIdx );
    682688  Pel*        piSrcCr     = pcPicYuvRec->getAddr( COMPONENT_Cr, pcCU->getCtuRsAddr(), uiAbsZorderIdx );
     689#if SVC_EXTENSION
     690  const Int bitDepthChroma = pcCU->getSlice()->getBitDepth(CHANNEL_TYPE_CHROMA);
     691#else
     692  const Int bitDepthChroma = pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA);
     693#endif
    683694  Int iQP = 0;
    684695  Int iQP_P = 0;
     
    740751    uiLoopLength=uiPelsInPartChromaH;
    741752  }
     753
     754#if SVC_EXTENSION
     755  const Int iBitdepthScale = 1 << (pcCU->getSlice()->getBitDepth(CHANNEL_TYPE_CHROMA)-8);
     756#else
     757  const Int iBitdepthScale = 1 << (pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)-8);
     758#endif
    742759
    743760  for ( UInt iIdx = 0; iIdx < uiNumParts; iIdx++ )
     
    798815        }
    799816
    800         Int iBitdepthScale = 1 << (g_bitDepth[CHANNEL_TYPE_CHROMA]-8);
    801 
    802817        Int iIndexTC = Clip3(0, MAX_QP+DEFAULT_INTRA_TC_OFFSET, iQP + DEFAULT_INTRA_TC_OFFSET*(ucBs - 1) + (tcOffsetDiv2 << 1));
    803818        Int iTc =  sm_tcTable[iIndexTC]*iBitdepthScale;
     
    805820        for ( UInt uiStep = 0; uiStep < uiLoopLength; uiStep++ )
    806821        {
    807           xPelFilterChroma( piTmpSrcChroma + iSrcStep*(uiStep+iIdx*uiLoopLength), iOffset, iTc , bPartPNoFilter, bPartQNoFilter);
     822          xPelFilterChroma( piTmpSrcChroma + iSrcStep*(uiStep+iIdx*uiLoopLength), iOffset, iTc , bPartPNoFilter, bPartQNoFilter, bitDepthChroma);
    808823        }
    809824      }
     
    825840 \param bFilterSecondQ  decision weak filter/no filter for partQ
    826841*/
    827 __inline Void TComLoopFilter::xPelFilterLuma( Pel* piSrc, Int iOffset, Int tc, Bool sw, Bool bPartPNoFilter, Bool bPartQNoFilter, Int iThrCut, Bool bFilterSecondP, Bool bFilterSecondQ)
     842__inline Void TComLoopFilter::xPelFilterLuma( Pel* piSrc, Int iOffset, Int tc, Bool sw, Bool bPartPNoFilter, Bool bPartQNoFilter, Int iThrCut, Bool bFilterSecondP, Bool bFilterSecondQ, const Int bitDepthLuma)
    828843{
    829844  Int delta;
     
    855870    {
    856871      delta = Clip3(-tc, tc, delta);
    857       piSrc[-iOffset] = Clip((m3+delta), CHANNEL_TYPE_LUMA);
    858       piSrc[0] = Clip((m4-delta), CHANNEL_TYPE_LUMA);
     872      piSrc[-iOffset] = ClipBD((m3+delta), bitDepthLuma);
     873      piSrc[0] = ClipBD((m4-delta), bitDepthLuma);
    859874
    860875      Int tc2 = tc>>1;
     
    862877      {
    863878        Int delta1 = Clip3(-tc2, tc2, (( ((m1+m3+1)>>1)- m2+delta)>>1));
    864         piSrc[-iOffset*2] = Clip((m2+delta1), CHANNEL_TYPE_LUMA);
     879        piSrc[-iOffset*2] = ClipBD((m2+delta1), bitDepthLuma);
    865880      }
    866881      if(bFilterSecondQ)
    867882      {
    868883        Int delta2 = Clip3(-tc2, tc2, (( ((m6+m4+1)>>1)- m5-delta)>>1));
    869         piSrc[ iOffset] = Clip((m5+delta2), CHANNEL_TYPE_LUMA);
     884        piSrc[ iOffset] = ClipBD((m5+delta2), bitDepthLuma);
    870885      }
    871886    }
     
    895910 \param bPartQNoFilter  indicator to disable filtering on partQ
    896911 */
    897 __inline Void TComLoopFilter::xPelFilterChroma( Pel* piSrc, Int iOffset, Int tc, Bool bPartPNoFilter, Bool bPartQNoFilter)
     912__inline Void TComLoopFilter::xPelFilterChroma( Pel* piSrc, Int iOffset, Int tc, Bool bPartPNoFilter, Bool bPartQNoFilter, const Int bitDepthChroma)
    898913{
    899914  Int delta;
     
    905920
    906921  delta = Clip3(-tc,tc, (((( m4 - m3 ) << 2 ) + m2 - m5 + 4 ) >> 3) );
    907   piSrc[-iOffset] = Clip((m3+delta), CHANNEL_TYPE_CHROMA);
    908   piSrc[0] = Clip((m4-delta), CHANNEL_TYPE_CHROMA);
     922  piSrc[-iOffset] = ClipBD((m3+delta), bitDepthChroma);
     923  piSrc[0] = ClipBD((m4-delta), bitDepthChroma);
    909924
    910925  if(bPartPNoFilter)
  • branches/SHM-dev/source/Lib/TLibCommon/TComLoopFilter.h

    r1259 r1287  
    108108  Void xEdgeFilterChroma          ( TComDataCU* pcCU, UInt uiAbsZorderIdx, UInt uiDepth, DeblockEdgeDir edgeDir, Int iEdge );
    109109
    110   __inline Void xPelFilterLuma( Pel* piSrc, Int iOffset, Int tc, Bool sw, Bool bPartPNoFilter, Bool bPartQNoFilter, Int iThrCut, Bool bFilterSecondP, Bool bFilterSecondQ);
    111   __inline Void xPelFilterChroma( Pel* piSrc, Int iOffset, Int tc, Bool bPartPNoFilter, Bool bPartQNoFilter);
     110  __inline Void xPelFilterLuma( Pel* piSrc, Int iOffset, Int tc, Bool sw, Bool bPartPNoFilter, Bool bPartQNoFilter, Int iThrCut, Bool bFilterSecondP, Bool bFilterSecondQ, const Int bitDepthLuma);
     111  __inline Void xPelFilterChroma( Pel* piSrc, Int iOffset, Int tc, Bool bPartPNoFilter, Bool bPartQNoFilter, const Int bitDepthChroma);
    112112
    113113
  • branches/SHM-dev/source/Lib/TLibCommon/TComPattern.cpp

    r1260 r1287  
    7979                                           Int iRoiWidth,
    8080                                           Int iRoiHeight,
    81                                            Int iStride
     81                                           Int iStride,
     82                                           Int bitDepth
    8283                                           )
    8384{
    8485  m_piROIOrigin    = piTexture;
    85   m_iROIWidth       = iRoiWidth;
    86   m_iROIHeight      = iRoiHeight;
    87   m_iPatternStride  = iStride;
     86  m_iROIWidth      = iRoiWidth;
     87  m_iROIHeight     = iRoiHeight;
     88  m_iPatternStride = iStride;
     89  m_bitDepth       = bitDepth;
    8890}
    8991
     
    9597                               Int iRoiWidth,
    9698                               Int iRoiHeight,
    97                                Int iStride)
    98 {
    99   m_cPatternY. setPatternParamPel( piY,  iRoiWidth, iRoiHeight, iStride);
     99                               Int iStride,
     100                               Int bitDepthLuma)
     101{
     102  m_cPatternY. setPatternParamPel( piY,  iRoiWidth, iRoiHeight, iStride, bitDepthLuma);
    100103}
    101104
     
    120123  const Int  iAboveUnits      = iTUWidthInUnits  << 1;
    121124  const Int  iLeftUnits       = iTUHeightInUnits << 1;
     125#if SVC_EXTENSION
     126  const Int  bitDepthForChannel = pcCU->getSlice()->getBitDepth(chType);
     127#else
     128  const Int  bitDepthForChannel = pcCU->getSlice()->getSPS()->getBitDepth(chType);
     129#endif
    122130
    123131  assert(iTUHeightInUnits > 0 && iTUWidthInUnits > 0);
     
    156164    Pel *piRoiOrigin = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiZorderIdxInPart);
    157165#if O0043_BEST_EFFORT_DECODING
    158     fillReferenceSamples (g_bitDepthInStream[chType], g_bitDepthInStream[chType] - g_bitDepth[chType], pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor,  iUnitWidth, iUnitHeight, iAboveUnits, iLeftUnits,
    159 #else
    160     fillReferenceSamples (g_bitDepth[chType], pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor,  iUnitWidth, iUnitHeight, iAboveUnits, iLeftUnits,
     166    const Int  bitDepthForChannelInStream = pcCU->getSlice()->getSPS()->getStreamBitDepth(chType);
     167    fillReferenceSamples (bitDepthForChannelInStream, bitDepthForChannelInStream - bitDepthForChannel, pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor,  iUnitWidth, iUnitHeight, iAboveUnits, iLeftUnits,
     168#else
     169    fillReferenceSamples (bitDepthForChannel, pcCU, piRoiOrigin, piAdiTemp, bNeighborFlags, iNumIntraNeighbor,  iUnitWidth, iUnitHeight, iAboveUnits, iLeftUnits,
    161170#endif
    162171                          uiTuWidth, uiTuHeight, uiROIWidth, uiROIHeight, iPicStride, toChannelType(compID), chFmt);
     
    202211      {
    203212#if O0043_BEST_EFFORT_DECODING
    204         const Int  threshold     = 1 << (g_bitDepthInStream[chType] - 5);
    205 #else
    206         const Int  threshold     = 1 << (g_bitDepth[chType] - 5);
     213        const Int  threshold     = 1 << (bitDepthForChannelInStream - 5);
     214#else
     215        const Int  threshold     = 1 << (bitDepthForChannel - 5);
    207216#endif
    208217        const Bool bilinearLeft  = abs((bottomLeft + topLeft ) - (2 * piAdiTemp[stride * uiTuHeight])) < threshold; //difference between the
  • branches/SHM-dev/source/Lib/TLibCommon/TComPattern.h

    r1262 r1287  
    6262  Int   m_iROIHeight;
    6363  Int   m_iPatternStride;
     64  Int   m_bitDepth;
    6465
    6566  /// return starting position of ROI (ROI = &pattern[AboveOffset][LeftOffset])
     
    7071
    7172  /// set parameters from Pel buffer for accessing neighbouring pixels
    72   Void setPatternParamPel (Pel*        piTexture,
    73                            Int         iRoiWidth,
    74                            Int         iRoiHeight,
    75                            Int         iStride
    76                            );
     73  Void setPatternParamPel( Pel* piTexture, Int iRoiWidth, Int iRoiHeight, Int iStride, Int bitDepth );
    7774};
    7875
     
    9289  Int   getROIYHeight()           { return m_cPatternY.m_iROIHeight;      }
    9390  Int   getPatternLStride()       { return m_cPatternY.m_iPatternStride;  }
     91  Int   getBitDepthY()            { return m_cPatternY.m_bitDepth; }
    9492
    9593  // -------------------------------------------------------------------------------------------------------------------
     
    9896
    9997  /// set parameters from Pel buffers for accessing neighbouring pixels
    100   Void initPattern            (Pel*        piY,
    101                                Int         iRoiWidth,
    102                                Int         iRoiHeight,
    103                                Int         iStride );
    104 
    105 
    106 
    107 
     98  Void initPattern( Pel* piY, Int iRoiWidth, Int iRoiHeight, Int iStride, Int bitDepthLuma );
    10899};
    109100
  • branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.cpp

    r1259 r1287  
    256256
    257257// NOTE: This function is never called, but may be useful for developers.
    258 Void TComPicYuv::dump (const Char* pFileName, Bool bAdd) const
     258Void TComPicYuv::dump (const Char* pFileName, const BitDepths &bitDepths, Bool bAdd) const
    259259{
    260260  FILE* pFile;
     
    272272  {
    273273    const ComponentID  ch     = ComponentID(chan);
    274     const Int          shift  = g_bitDepth[toChannelType(ch)] - 8;
     274    const Int          shift  = bitDepths.recon[toChannelType(ch)] - 8;
    275275    const Int          offset = (shift>0)?(1<<(shift-1)):0;
    276276    const Pel         *pi     = getAddr(ch);
     
    307307  if( bitDepth == 8 )
    308308  {
    309     dump( pFileName, bAdd );
     309    dump( pFileName, bitDepth, bAdd );
    310310    return;
    311311  }
     
    338338
    339339#if AUXILIARY_PICTURES
    340 Void TComPicYuv::convertToMonochrome()
    341 {
    342   Pel grayVal = (1 << (g_bitDepth[CHANNEL_TYPE_CHROMA] - 1));
     340Void TComPicYuv::convertToMonochrome(Int bitDepthChroma)
     341{
     342  Pel grayVal = (1 << (bitDepthChroma - 1));
    343343
    344344  for( UInt comp = 1; comp < getNumberValidComponents(); comp++ )
  • branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.h

    r1273 r1287  
    160160
    161161  //  Dump picture
    162   Void          dump              (const Char* pFileName, Bool bAdd = false) const ;
     162  Void          dump              (const Char* pFileName, const BitDepths &bitDepths, Bool bAdd = false) const ;
    163163
    164164  // Set border extension flag
     
    172172  Bool          isReconstructed()                                { return m_isReconstructed;                }
    173173#if AUXILIARY_PICTURES 
    174   Void          convertToMonochrome();
     174  Void          convertToMonochrome(Int bitDepthChroma);
    175175#endif
    176176#endif
     
    182182
    183183// These functions now return the length of the digest strings.
    184 UInt calcChecksum(const TComPicYuv& pic, TComPictureHash &digest);
    185 UInt calcCRC     (const TComPicYuv& pic, TComPictureHash &digest);
    186 UInt calcMD5     (const TComPicYuv& pic, TComPictureHash &digest);
     184UInt calcChecksum(const TComPicYuv& pic, TComPictureHash &digest, const BitDepths &bitDepths);
     185UInt calcCRC     (const TComPicYuv& pic, TComPictureHash &digest, const BitDepths &bitDepths);
     186UInt calcMD5     (const TComPicYuv& pic, TComPictureHash &digest, const BitDepths &bitDepths);
    187187std::string hashToString(const TComPictureHash &digest, Int numChar);
    188188//! \}
  • branches/SHM-dev/source/Lib/TLibCommon/TComPicYuvMD5.cpp

    r1273 r1287  
    127127}
    128128
    129 UInt calcCRC(const TComPicYuv& pic, TComPictureHash &digest)
     129UInt calcCRC(const TComPicYuv& pic, TComPictureHash &digest, const BitDepths &bitDepths)
    130130{
    131131  UInt digestLen=0;
     
    134134  {
    135135    const ComponentID compID=ComponentID(chan);
    136     digestLen=compCRC(g_bitDepth[toChannelType(compID)], pic.getAddr(compID), pic.getWidth(compID), pic.getHeight(compID), pic.getStride(compID), digest);
     136    digestLen=compCRC(bitDepths.recon[toChannelType(compID)], pic.getAddr(compID), pic.getWidth(compID), pic.getHeight(compID), pic.getStride(compID), digest);
    137137  }
    138138  return digestLen;
    139139}
    140140
    141 UInt compChecksum(Int bitdepth, const Pel* plane, UInt width, UInt height, UInt stride, TComPictureHash &digest)
     141UInt compChecksum(Int bitdepth, const Pel* plane, UInt width, UInt height, UInt stride, TComPictureHash &digest, const BitDepths &/*bitDepths*/)
    142142{
    143143  UInt checksum = 0;
     
    165165}
    166166
    167 UInt calcChecksum(const TComPicYuv& pic, TComPictureHash &digest)
     167UInt calcChecksum(const TComPicYuv& pic, TComPictureHash &digest, const BitDepths &bitDepths)
    168168{
    169169  UInt digestLen=0;
     
    172172  {
    173173    const ComponentID compID=ComponentID(chan);
    174     digestLen=compChecksum(g_bitDepth[toChannelType(compID)], pic.getAddr(compID), pic.getWidth(compID), pic.getHeight(compID), pic.getStride(compID), digest);
     174    digestLen=compChecksum(bitDepths.recon[toChannelType(compID)], pic.getAddr(compID), pic.getWidth(compID), pic.getHeight(compID), pic.getStride(compID), digest, bitDepths);
    175175  }
    176176  return digestLen;
     
    183183 * uses little-endian two byte words; 8bit data uses single byte words.
    184184 */
    185 UInt calcMD5(const TComPicYuv& pic, TComPictureHash &digest)
     185UInt calcMD5(const TComPicYuv& pic, TComPictureHash &digest, const BitDepths &bitDepths)
    186186{
    187187  /* choose an md5_plane packing function based on the system bitdepth */
     
    195195  {
    196196    const ComponentID compID=ComponentID(chan);
    197     md5_plane_func = g_bitDepth[toChannelType(compID)] <= 8 ? (MD5PlaneFunc)md5_plane<1> : (MD5PlaneFunc)md5_plane<2>;
     197    md5_plane_func = bitDepths.recon[toChannelType(compID)] <= 8 ? (MD5PlaneFunc)md5_plane<1> : (MD5PlaneFunc)md5_plane<2>;
    198198    UChar tmp_digest[MD5_DIGEST_STRING_LENGTH];
    199199    md5_plane_func(md5[compID], pic.getAddr(compID), pic.getWidth(compID), pic.getHeight(compID), pic.getStride(compID));
  • branches/SHM-dev/source/Lib/TLibCommon/TComPrediction.cpp

    r1262 r1287  
    480480      const UInt              uiAbsPartIdx      = rTu.GetAbsPartIdxTU();
    481481      const Bool              enableEdgeFilters = !(pcCU->isRDPCMEnabled(uiAbsPartIdx) && pcCU->getCUTransquantBypass(uiAbsPartIdx));
    482 
    483482#if O0043_BEST_EFFORT_DECODING
    484       xPredIntraAng( g_bitDepthInStream[channelType], ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, channelType, format, uiDirMode, bAbove, bLeft, enableEdgeFilters );
     483      const Int channelsBitDepthForPrediction = rTu.getCU()->getSlice()->getSPS()->getStreamBitDepth(channelType);
    485484#else
    486       xPredIntraAng( g_bitDepth[channelType], ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, channelType, format, uiDirMode, bAbove, bLeft, enableEdgeFilters );
     485#if SVC_EXTENSION
     486      const Int channelsBitDepthForPrediction = rTu.getCU()->getSlice()->getBitDepth(channelType);
     487#else
     488      const Int channelsBitDepthForPrediction = rTu.getCU()->getSlice()->getSPS()->getBitDepth(channelType);
    487489#endif
     490#endif
     491      xPredIntraAng( channelsBitDepthForPrediction, ptrSrc+sw+1, sw, pDst, uiStride, iWidth, iHeight, channelType, format, uiDirMode, bAbove, bLeft, enableEdgeFilters );
    488492
    489493      if(( uiDirMode == DC_IDX ) && bAbove && bLeft )
     
    614618#endif
    615619
    616   for (UInt ch=COMPONENT_Y; ch<pcYuvPred->getNumberValidComponents(); ch++)
    617   {
    618     xPredInterBlk  (ComponentID(ch),  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi );
     620  for (UInt comp=COMPONENT_Y; comp<pcYuvPred->getNumberValidComponents(); comp++)
     621  {
     622    const ComponentID compID=ComponentID(comp);
     623#if SVC_EXTENSION
     624    xPredInterBlk  (compID,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getBitDepth(toChannelType(compID)) );
     625#else
     626    xPredInterBlk  (compID,  pcCU, pcCU->getSlice()->getRefPic( eRefPicList, iRefIdx )->getPicYuvRec(), uiPartAddr, &cMv, iWidth, iHeight, pcYuvPred, bi, pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)) );
     627#endif
    619628  }
    620629}
     
    666675  else
    667676  {
    668     xWeightedAverage( &m_acYuvPred[REF_PIC_LIST_0], &m_acYuvPred[REF_PIC_LIST_1], iRefIdx[REF_PIC_LIST_0], iRefIdx[REF_PIC_LIST_1], uiPartAddr, iWidth, iHeight, pcYuvPred );
     677#if SVC_EXTENSION
     678    xWeightedAverage( &m_acYuvPred[REF_PIC_LIST_0], &m_acYuvPred[REF_PIC_LIST_1], iRefIdx[REF_PIC_LIST_0], iRefIdx[REF_PIC_LIST_1], uiPartAddr, iWidth, iHeight, pcYuvPred, pcCU->getSlice()->getBitDepths() );
     679#else
     680    xWeightedAverage( &m_acYuvPred[REF_PIC_LIST_0], &m_acYuvPred[REF_PIC_LIST_1], iRefIdx[REF_PIC_LIST_0], iRefIdx[REF_PIC_LIST_1], uiPartAddr, iWidth, iHeight, pcYuvPred, pcCU->getSlice()->getSPS()->getBitDepths() );
     681#endif
    669682  }
    670683}
     
    685698
    686699
    687 Void TComPrediction::xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi )
     700Void TComPrediction::xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi, const Int bitDepth )
    688701{
    689702  Int     refStride  = refPic->getStride(compID);
     
    707720  if ( yFrac == 0 )
    708721  {
    709     m_if.filterHor(compID, ref, refStride, dst,  dstStride, cxWidth, cxHeight, xFrac, !bi, chFmt);
     722    m_if.filterHor(compID, ref, refStride, dst,  dstStride, cxWidth, cxHeight, xFrac, !bi, chFmt, bitDepth);
    710723  }
    711724  else if ( xFrac == 0 )
    712725  {
    713     m_if.filterVer(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, yFrac, true, !bi, chFmt);
     726    m_if.filterVer(compID, ref, refStride, dst, dstStride, cxWidth, cxHeight, yFrac, true, !bi, chFmt, bitDepth);
    714727  }
    715728  else
     
    720733    const Int vFilterSize = isLuma(compID) ? NTAPS_LUMA : NTAPS_CHROMA;
    721734
    722     m_if.filterHor(compID, ref - ((vFilterSize>>1) -1)*refStride, refStride, tmp, tmpStride, cxWidth, cxHeight+vFilterSize-1, xFrac, false,      chFmt);
    723     m_if.filterVer(compID, tmp + ((vFilterSize>>1) -1)*tmpStride, tmpStride, dst, dstStride, cxWidth, cxHeight,               yFrac, false, !bi, chFmt);
    724   }
    725 }
    726 
    727 Void TComPrediction::xWeightedAverage( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv* pcYuvDst )
     735    m_if.filterHor(compID, ref - ((vFilterSize>>1) -1)*refStride, refStride, tmp, tmpStride, cxWidth, cxHeight+vFilterSize-1, xFrac, false,      chFmt, bitDepth);
     736    m_if.filterVer(compID, tmp + ((vFilterSize>>1) -1)*tmpStride, tmpStride, dst, dstStride, cxWidth, cxHeight,               yFrac, false, !bi, chFmt, bitDepth);
     737  }
     738}
     739
     740Void TComPrediction::xWeightedAverage( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv* pcYuvDst, const BitDepths &clipBitDepths )
    728741{
    729742  if( iRefIdx0 >= 0 && iRefIdx1 >= 0 )
    730743  {
    731     pcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight );
     744    pcYuvDst->addAvg( pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight, clipBitDepths );
    732745  }
    733746  else if ( iRefIdx0 >= 0 && iRefIdx1 <  0 )
     
    870883
    871884#if SVC_EXTENSION
    872 Void TComPrediction::upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic )
    873 {
    874   m_cUsf.upsampleBasePic( currSlice, refLayerIdc, pcUsPic, pcBasePic, pcTempPic );
     885Void TComPrediction::upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Int refBitDepthLuma, const Int refBitDepthChroma )
     886{
     887  m_cUsf.upsampleBasePic( currSlice, refLayerIdc, pcUsPic, pcBasePic, pcTempPic, refBitDepthLuma, refBitDepthChroma );
    875888}
    876889#endif //SVC_EXTENSION
  • branches/SHM-dev/source/Lib/TLibCommon/TComPrediction.h

    r1262 r1287  
    9494  Void xPredInterUni            ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv* pcYuvPred, Bool bi=false          );
    9595  Void xPredInterBi             ( TComDataCU* pcCU,                          UInt uiPartAddr,               Int iWidth, Int iHeight,                         TComYuv* pcYuvPred          );
    96   Void xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi );
    97   Void xWeightedAverage         ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv* pcYuvDst );
     96  Void xPredInterBlk(const ComponentID compID, TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *dstPic, Bool bi, const Int bitDepth );
     97  Void xWeightedAverage         ( TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv* pcYuvDst, const BitDepths &clipBitDepths );
    9898
    9999  Void xGetLLSPrediction ( const Pel* pSrc0, Int iSrcStride, Pel* pDst0, Int iDstStride, UInt uiWidth, UInt uiHeight, UInt uiExt0, const ChromaFormat chFmt  DEBUG_STRING_FN_DECLARE(sDebug) );
     
    145145
    146146#if SVC_EXTENSION
    147 Void upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic );
    148 #endif //SVC_EXTENSION
     147  Void upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Int refBitDepthLuma, const Int refBitDepthChroma );
     148#endif
    149149};
    150150
  • branches/SHM-dev/source/Lib/TLibCommon/TComRdCost.cpp

    r1259 r1287  
    192192}
    193193
    194 Void TComRdCost::setLambda( Double dLambda )
     194Void TComRdCost::setLambda( Double dLambda, const BitDepths &bitDepths )
    195195{
    196196  m_dLambda           = dLambda;
     
    202202  dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12) / 3.0));
    203203#else
    204   dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12 - 6 * (g_bitDepth[CHANNEL_TYPE_LUMA] - 8)) / 3.0));
     204  dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12 - 6 * (bitDepths.recon[CHANNEL_TYPE_LUMA] - 8)) / 3.0));
    205205#endif
    206206  m_dLambdaMotionSAD[1] = 65536.0 * sqrt(dLambda);
     
    212212  dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12) / 3.0));
    213213#else
    214   dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12 - 6 * (g_bitDepth[CHANNEL_TYPE_LUMA] - 8)) / 3.0));
     214  dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12 - 6 * (bitDepths.recon[CHANNEL_TYPE_LUMA] - 8)) / 3.0));
    215215#endif
    216216  m_uiLambdaMotionSAD[1] = (UInt)floor(65536.0 * sqrt(dLambda));
     
    340340Void TComRdCost::setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME )
    341341{
    342 #if SVC_EXTENSION
    343   // Set bit depth for weighted cost calculation
    344   rcDistParam.bitDepth = g_bitDepth[CHANNEL_TYPE_LUMA];
    345 #endif
    346342  // set Original & Curr Pointer / Stride
    347343  rcDistParam.pOrg = pcPatternKey->getROIY();
  • branches/SHM-dev/source/Lib/TLibCommon/TComRdCost.h

    r1259 r1287  
    138138
    139139  Void    setDistortionWeight  ( const ComponentID compID, const Double distortionWeight ) { m_distortionWeight[compID] = distortionWeight; }
    140   Void    setLambda      ( Double dLambda );
     140  Void    setLambda      ( Double dLambda, const BitDepths &bitDepths );
    141141  Void    setFrameLambda ( Double dLambda ) { m_dFrameLambda = dLambda; }
    142142
  • branches/SHM-dev/source/Lib/TLibCommon/TComRom.cpp

    r1285 r1287  
    541541
    542542// ====================================================================================================================
    543 // Bit-depth
    544 // ====================================================================================================================
    545 
    546 Int g_bitDepth   [MAX_NUM_CHANNEL_TYPE] = {8, 8};
    547 #if O0043_BEST_EFFORT_DECODING
    548 Int g_bitDepthInStream   [MAX_NUM_CHANNEL_TYPE] = {8, 8}; // In the encoder, this is the same as g_bitDepth. In the decoder, this can vary from g_bitDepth if the decoder is forced to use 'best-effort decoding' at a particular bit-depth.
    549 #endif
    550 
    551 // ====================================================================================================================
    552543// Misc.
    553544// ====================================================================================================================
     
    681672UInt g_predefSetIntraModes[NUM_INTRA_MODE-1] = {26,10,18,34,2,22,14,30,6,24,12,28,8,20,16,32,4,17,19,15,21,13,23,11,25,9,27,7,29,5,31,3,33,0,2};
    682673#endif
    683 Int  g_bitDepthLayer[MAX_NUM_CHANNEL_TYPE][MAX_LAYERS];
    684 void * g_refWeightACDCParam; // type=wpACDCParam
    685674Int g_mvScalingFactor  [MAX_LAYERS][2] = {{0,0}, {0,0}};
    686675Int g_posScalingFactor [MAX_LAYERS][2] = {{0,0}, {0,0}};
  • branches/SHM-dev/source/Lib/TLibCommon/TComRom.h

    r1285 r1287  
    153153
    154154// ====================================================================================================================
    155 // Bit-depth
    156 // ====================================================================================================================
    157 
    158 extern        Int g_bitDepth   [MAX_NUM_CHANNEL_TYPE];
    159 #if O0043_BEST_EFFORT_DECODING
    160 extern        Int g_bitDepthInStream   [MAX_NUM_CHANNEL_TYPE]; // In the encoder, this is the same as g_bitDepth. In the decoder, this can vary from g_bitDepth if the decoder is forced to use 'best-effort decoding' at a particular bit-depth.
    161 #endif
    162 
    163 // ====================================================================================================================
    164155// Mode-Dependent DST Matrices
    165156// ====================================================================================================================
  • branches/SHM-dev/source/Lib/TLibCommon/TComSampleAdaptiveOffset.cpp

    r1260 r1287  
    4444//! \ingroup TLibCommon
    4545//! \{
    46 #if !SVC_EXTENSION
    47 UInt g_saoMaxOffsetQVal[MAX_NUM_COMPONENT];
    48 #endif
    4946
    5047SAOOffset::SAOOffset()
     
    154151  for(Int compIdx = 0; compIdx < MAX_NUM_COMPONENT; compIdx++)
    155152  {
    156     Int bitDepthSample = g_bitDepth[toChannelType(ComponentID(compIdx))];
    157153    m_offsetStepLog2  [compIdx] = isLuma(ComponentID(compIdx))? lumaBitShift : chromaBitShift;
    158 #if SVC_EXTENSION
    159     m_saoMaxOffsetQVal[compIdx] = (1<<(min(bitDepthSample,MAX_SAO_TRUNCATED_BITDEPTH)-5))-1; //Table 9-32, inclusive
    160 #else
    161     g_saoMaxOffsetQVal[compIdx] = (1<<(min(bitDepthSample,MAX_SAO_TRUNCATED_BITDEPTH)-5))-1; //Table 9-32, inclusive
    162 #endif
    163154  }
    164155}
     
    320311
    321312
    322 Void TComSampleAdaptiveOffset::offsetBlock(ComponentID compIdx, Int typeIdx, Int* offset
     313Void TComSampleAdaptiveOffset::offsetBlock(const Int channelBitDepth, Int typeIdx, Int* offset
    323314                                          , Pel* srcBlk, Pel* resBlk, Int srcStride, Int resStride,  Int width, Int height
    324315                                          , Bool isLeftAvail,  Bool isRightAvail, Bool isAboveAvail, Bool isBelowAvail, Bool isAboveLeftAvail, Bool isAboveRightAvail, Bool isBelowLeftAvail, Bool isBelowRightAvail)
     
    343334  }
    344335
    345   const Int maxSampleValueIncl = (1<< g_bitDepth[toChannelType(compIdx)] )-1;
     336  const Int maxSampleValueIncl = (1<< channelBitDepth )-1;
    346337
    347338  Int x,y, startX, startY, endX, endY, edgeType;
     
    540531  case SAO_TYPE_BO:
    541532    {
    542       const Int shiftBits = g_bitDepth[toChannelType(compIdx)] - NUM_SAO_BO_CLASSES_LOG2;
     533      const Int shiftBits = channelBitDepth - NUM_SAO_BO_CLASSES_LOG2;
    543534      for (y=0; y< height; y++)
    544535      {
     
    608599      Pel* resBlk     = resYuv->getAddr(component) + blkYPos*resStride + blkXPos;
    609600
    610       offsetBlock( component, ctbOffset.typeIdc, ctbOffset.offset
     601#if SVC_EXTENSION
     602      offsetBlock( pPic->getSlice(0)->getBitDepth(toChannelType(component)), ctbOffset.typeIdc, ctbOffset.offset
     603#else
     604      offsetBlock( pPic->getPicSym()->getSPS().getBitDepth(toChannelType(component)), ctbOffset.typeIdc, ctbOffset.offset
     605#endif
    611606                  , srcBlk, resBlk, srcStride, resStride, blkWidth, blkHeight
    612607                  , isLeftAvail, isRightAvail
     
    743738  else
    744739  {
    745     uiPcmLeftShiftBit = g_bitDepth[toChannelType(compID)] - pcCU->getSlice()->getSPS()->getPCMBitDepth(toChannelType(compID));
     740#if SVC_EXTENSION
     741    uiPcmLeftShiftBit = pcCU->getSlice()->getBitDepth(toChannelType(compID)) - pcCU->getSlice()->getSPS()->getPCMBitDepth(toChannelType(compID));
     742#else
     743    uiPcmLeftShiftBit = pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)) - pcCU->getSlice()->getSPS()->getPCMBitDepth(toChannelType(compID));
     744#endif
    746745  }
    747746
  • branches/SHM-dev/source/Lib/TLibCommon/TComSampleAdaptiveOffset.h

    r1260 r1287  
    5555// Class definition
    5656// ====================================================================================================================
    57 #if !SVC_EXTENSION
    58 extern UInt g_saoMaxOffsetQVal[MAX_NUM_COMPONENT];
    59 #endif
    6057
    6158template <typename T> Int sgn(T val)
     
    7471  Void reconstructBlkSAOParams(TComPic* pic, SAOBlkParam* saoBlkParams);
    7572  Void PCMLFDisableProcess (TComPic* pcPic);
    76 #if SVC_EXTENSION
    77   UInt* getSaoMaxOffsetQVal() { return m_saoMaxOffsetQVal; }
    78 #endif
     73  static Int getMaxOffsetQVal(const Int channelBitDepth) { return (1<<(std::min<Int>(channelBitDepth,MAX_SAO_TRUNCATED_BITDEPTH)-5))-1; } //Table 9-32, inclusive
     74
    7975protected:
    80   Void offsetBlock(ComponentID compIdx, Int typeIdx, Int* offset, Pel* srcBlk, Pel* resBlk, Int srcStride, Int resStride,  Int width, Int height
     76  Void offsetBlock(const Int channelBitDepth, Int typeIdx, Int* offset, Pel* srcBlk, Pel* resBlk, Int srcStride, Int resStride,  Int width, Int height
    8177                  , Bool isLeftAvail, Bool isRightAvail, Bool isAboveAvail, Bool isBelowAvail, Bool isAboveLeftAvail, Bool isAboveRightAvail, Bool isBelowLeftAvail, Bool isBelowRightAvail);
    8278  Void invertQuantOffsets(ComponentID compIdx, Int typeIdc, Int typeAuxInfo, Int* dstOffsets, Int* srcOffsets);
     
    105101private:
    106102  Bool m_picSAOEnabled[MAX_NUM_COMPONENT];
    107 
    108 #if SVC_EXTENSION
    109   UInt m_saoMaxOffsetQVal[MAX_NUM_COMPONENT];
    110 #endif
    111103};
    112104
  • branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp

    r1273 r1287  
    512512                            );
    513513
    514         Bool sameBitDepths = ( g_bitDepthLayer[CHANNEL_TYPE_LUMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_LUMA][refLayerId] ) && ( g_bitDepthLayer[CHANNEL_TYPE_CHROMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_CHROMA][refLayerId] );
     514        Bool sameBitDepths = ( getBitDepth(CHANNEL_TYPE_LUMA) == ilpPic[refLayerIdc]->getSlice(0)->getBitDepth(CHANNEL_TYPE_LUMA) ) && ( getBitDepth(CHANNEL_TYPE_CHROMA) == ilpPic[refLayerIdc]->getSlice(0)->getBitDepth(CHANNEL_TYPE_CHROMA) );
    515515
    516516        // motion resampling constraint
     
    18211821}
    18221822
    1823 //! get AC and DC values for weighted pred
    1824 Void  TComSlice::getWpAcDcParam(WPACDCParam *&wp)
    1825 {
    1826   wp = m_weightACDCParam;
    1827 }
    1828 
    18291823//! init AC and DC values for weighted pred
    18301824Void  TComSlice::initWpAcDcParam()
     
    18821876        }
    18831877
    1884         const Int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (g_bitDepth[toChannelType(ComponentID(yuv))]-8));
     1878#if SVC_EXTENSION
     1879        const Int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (getBitDepth(toChannelType(ComponentID(yuv)))-8));
     1880#else
     1881        const Int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (sps->getBitDepth(toChannelType(ComponentID(yuv)))-8));
     1882#endif
    18851883
    18861884        pwp->w      = pwp->iWeight;
     
    20982096  for(Int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++)
    20992097  {
    2100     m_uiBitDepth   [ch] = 8;
    2101     m_uiPCMBitDepth[ch] = 8;
     2098    m_bitDepths.recon[ch] = 8;
     2099#if O0043_BEST_EFFORT_DECODING
     2100    m_bitDepths.stream[ch] = 8;
     2101#endif
     2102    m_pcmBitDepths[ch] = 8;
    21022103    m_qpBDOffset   [ch] = 0;
    21032104  }
     
    35603561}
    35613562
    3562 UInt TComSlice::getBitDepthY()
     3563BitDepths& TComSlice::getBitDepths()
     3564{
     3565  static BitDepths bitDepths;
     3566
     3567  bitDepths.recon[CHANNEL_TYPE_LUMA] = getBitDepth(CHANNEL_TYPE_LUMA);
     3568  bitDepths.recon[CHANNEL_TYPE_CHROMA] = getBitDepth(CHANNEL_TYPE_CHROMA);
     3569
     3570  return bitDepths;
     3571}
     3572
     3573UInt TComSlice::getBitDepth(ChannelType type) const
    35633574{
    35643575  UInt retVal, layerId = getLayerId();
     
    35683579    if( layerId == 0 && m_pcVPS->getNonHEVCBaseLayerFlag() )
    35693580    {
    3570       retVal = m_pcVPS->getVpsRepFormat(layerId)->getBitDepthVpsLuma();
     3581      retVal = m_pcVPS->getVpsRepFormat(layerId)->getBitDepthVps(type);
    35713582    }
    35723583    else
    35733584    {
    3574       retVal = m_pcSPS->getBitDepth(CHANNEL_TYPE_LUMA);
     3585      retVal = m_pcSPS->getBitDepth(type);
    35753586    }
    35763587  }
    35773588  else
    35783589  {
    3579     retVal = m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(layerId)))->getBitDepthVpsLuma();
     3590    retVal = m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(layerId)))->getBitDepthVps(type);
    35803591  }
    35813592
     
    35833594}
    35843595
    3585 UInt TComVPS::getBitDepthY( const TComSPS* sps, const UInt layerId ) const
     3596UInt TComVPS::getBitDepth( ChannelType type, const TComSPS* sps, const UInt layerId ) const
    35863597{
    35873598  UInt retVal;
     
    35913602    if( layerId == 0 && m_nonHEVCBaseLayerFlag )
    35923603    {
    3593       retVal = m_vpsRepFormat[layerId].getBitDepthVpsLuma();
     3604      retVal = m_vpsRepFormat[layerId].getBitDepthVps(type);
    35943605    }
    35953606    else
    35963607    {
    3597       retVal = sps->getBitDepth(CHANNEL_TYPE_LUMA);
     3608      retVal = sps->getBitDepth(type);
    35983609    }
    35993610  }
    36003611  else
    36013612  {
    3602     retVal = m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getBitDepthVpsLuma();
     3613    retVal = m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getBitDepthVps(type);
    36033614  }
    36043615
     
    36063617}
    36073618
    3608 UInt TComSlice::getBitDepthC()
    3609 {
    3610   UInt retVal, layerId = getLayerId();
    3611 
    3612   if( layerId == 0 || m_pcSPS->getV1CompatibleSPSFlag() == 1 )
    3613   {
    3614     if( layerId == 0 && m_pcVPS->getNonHEVCBaseLayerFlag() )
    3615     {
    3616       retVal = m_pcVPS->getVpsRepFormat(layerId)->getBitDepthVpsChroma();
    3617     }
    3618     else
    3619     {
    3620       retVal = m_pcSPS->getBitDepth(CHANNEL_TYPE_CHROMA);
    3621     }
    3622   }
    3623   else
    3624   {
    3625     retVal = m_pcVPS->getVpsRepFormat(m_pcSPS->getUpdateRepFormatFlag() ? m_pcSPS->getUpdateRepFormatIndex() : m_pcVPS->getVpsRepFormatIdx(m_pcVPS->getLayerIdxInVps(layerId)))->getBitDepthVpsChroma();
    3626   }
    3627 
    3628   return retVal;
    3629 }
    3630 
    3631 UInt TComVPS::getBitDepthC( const TComSPS* sps, const UInt layerId ) const
    3632 {
    3633   UInt retVal;
    3634 
    3635   if( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 )
    3636   {
    3637     if( layerId == 0 && m_nonHEVCBaseLayerFlag )
    3638     {
    3639       retVal = m_vpsRepFormat[layerId].getBitDepthVpsChroma();
    3640     }
    3641     else
    3642     {
    3643       retVal = sps->getBitDepth(CHANNEL_TYPE_CHROMA);
    3644     }
    3645   }
    3646   else
    3647   {
    3648     retVal = m_vpsRepFormat[sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : m_vpsRepFormatIdx[m_layerIdxInVps[layerId]]].getBitDepthVpsChroma();
    3649   }
    3650 
    3651   return retVal;
    3652 }
    3653 
    3654 Int TComSlice::getQpBDOffsetY()
    3655 {
    3656   return (getBitDepthY() - 8) * 6;
    3657 }
    3658 
    3659 Int TComSlice::getQpBDOffsetC()
    3660 {
    3661   return (getBitDepthC() - 8) * 6;
     3619const BitDepths& TComVPS::getBitDepths( const TComSPS* sps, const UInt layerId ) const
     3620{
     3621  static const BitDepths bitDepths( getBitDepth(CHANNEL_TYPE_LUMA, sps, layerId), getBitDepth(CHANNEL_TYPE_CHROMA, sps, layerId) );
     3622  return bitDepths;
    36623623}
    36633624
     
    37833744      pcIlpPic[refLayerIdc]->getSlice(0)->setPPS( m_pcPic->getSlice(0)->getPPS() );
    37843745
     3746      // assign SPS to ILRP to be used for obtaining bit depth
     3747      pcIlpPic[refLayerIdc]->getSlice(0)->setSPS( m_pcPic->getSlice(0)->getSPS() );
     3748
    37853749      // assing VPS to ILRP to be used for deriving layerIdx
    37863750      pcIlpPic[refLayerIdc]->getSlice(0)->setVPS( m_pcPic->getSlice(0)->getVPS() );
  • branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h

    r1285 r1287  
    563563  Void setBitDepthVpsChroma(Int x)                            { m_bitDepthVpsChroma = x;                                         }
    564564
    565   Int  getBitDepthVps(ChannelType type)                       { return isLuma(type) ? m_bitDepthVpsLuma : m_bitDepthVpsChroma;   }
     565  Int  getBitDepthVps(ChannelType type) const                 { return isLuma(type) ? m_bitDepthVpsLuma : m_bitDepthVpsChroma;   }
    566566
    567567  Window& getConformanceWindowVps()                           { return m_conformanceWindowVps;                                   }
     
    11291129  UInt              getPicHeightInLumaSamples( const TComSPS* sps, const UInt layerId ) const;
    11301130  UInt              getPicWidthInLumaSamples( const TComSPS* sps, const UInt layerId ) const;
    1131   UInt              getBitDepthY( const TComSPS* sps, const UInt layerId ) const;
    1132   UInt              getBitDepthC( const TComSPS* sps, const UInt layerId ) const;
     1131  UInt              getBitDepth( ChannelType type, const TComSPS* sps, const UInt layerId ) const;
     1132  const BitDepths&  getBitDepths( const TComSPS* sps, const UInt layerId ) const;
    11331133  const Window&     getConformanceWindow( const TComSPS* sps, const UInt layerId ) const;
    11341134#endif //SVC_EXTENSION
     
    13041304};
    13051305
     1306
    13061307/// SPS class
    13071308class TComSPS
     
    13421343
    13431344  // Parameter
    1344   Int              m_uiBitDepth[MAX_NUM_CHANNEL_TYPE];
     1345  BitDepths        m_bitDepths;
    13451346  Int              m_qpBDOffset[MAX_NUM_CHANNEL_TYPE];
    13461347  Bool             m_useExtendedPrecision;
     
    13511352  Bool             m_alignCABACBeforeBypass;
    13521353  Bool             m_useResidualDPCM[NUMBER_OF_RDPCM_SIGNALLING_MODES];
    1353   UInt             m_uiPCMBitDepth[MAX_NUM_CHANNEL_TYPE];
     1354  Int              m_pcmBitDepths[MAX_NUM_CHANNEL_TYPE];
    13541355  Bool             m_bPCMFilterDisableFlag;
    13551356  Bool             m_disableIntraReferenceSmoothing;
     
    14781479
    14791480  // Bit-depth
    1480   Int                    getBitDepth(ChannelType type) const                                             { return m_uiBitDepth[type];                                           }
    1481   Void                   setBitDepth(ChannelType type, Int u )                                           { m_uiBitDepth[type] = u;                                              }
    1482   Int                    getMaxLog2TrDynamicRange(ChannelType channelType) const                         { return getUseExtendedPrecision() ? std::max<Int>(15, Int(m_uiBitDepth[channelType] + 6)) : 15; }
    1483 
    1484   Int                    getDifferentialLumaChromaBitDepth() const                                       { return Int(m_uiBitDepth[CHANNEL_TYPE_LUMA]) - Int(m_uiBitDepth[CHANNEL_TYPE_CHROMA]); }
     1481  Int                    getBitDepth(ChannelType type) const                                             { return m_bitDepths.recon[type];                                      }
     1482  Void                   setBitDepth(ChannelType type, Int u )                                           { m_bitDepths.recon[type] = u;                                         }
     1483#if O0043_BEST_EFFORT_DECODING
     1484  Int                    getStreamBitDepth(ChannelType type) const                                       { return m_bitDepths.stream[type];                                     }
     1485  Void                   setStreamBitDepth(ChannelType type, Int u )                                     { m_bitDepths.stream[type] = u;                                        }
     1486#endif
     1487  const BitDepths&       getBitDepths() const                                                            { return m_bitDepths;                                                  }
     1488  Int                    getMaxLog2TrDynamicRange(ChannelType channelType) const                         { return getUseExtendedPrecision() ? std::max<Int>(15, Int(m_bitDepths.recon[channelType] + 6)) : 15; }
     1489
     1490  Int                    getDifferentialLumaChromaBitDepth() const                                       { return Int(m_bitDepths.recon[CHANNEL_TYPE_LUMA]) - Int(m_bitDepths.recon[CHANNEL_TYPE_CHROMA]); }
    14851491  Int                    getQpBDOffset(ChannelType type) const                                           { return m_qpBDOffset[type];                                           }
    14861492  Void                   setQpBDOffset(ChannelType type, Int i)                                          { m_qpBDOffset[type] = i;                                              }
     
    15131519  Bool                   getTemporalIdNestingFlag() const                                                { return m_bTemporalIdNestingFlag;                                     }
    15141520  Void                   setTemporalIdNestingFlag( Bool bValue )                                         { m_bTemporalIdNestingFlag = bValue;                                   }
    1515   UInt                   getPCMBitDepth(ChannelType type) const                                          { return m_uiPCMBitDepth[type];                                        }
    1516   Void                   setPCMBitDepth(ChannelType type, UInt u)                                        { m_uiPCMBitDepth[type] = u;                                           }
     1521  UInt                   getPCMBitDepth(ChannelType type) const                                          { return m_pcmBitDepths[type];                                         }
     1522  Void                   setPCMBitDepth(ChannelType type, UInt u)                                        { m_pcmBitDepths[type] = u;                                            }
    15171523  Void                   setPCMFilterDisableFlag( Bool bValue )                                          { m_bPCMFilterDisableFlag = bValue;                                    }
    15181524  Bool                   getPCMFilterDisableFlag() const                                                 { return m_bPCMFilterDisableFlag;                                      }
     
    22602266  }
    22612267
    2262   Void                        getWpAcDcParam( WPACDCParam *&wp );
     2268  WPACDCParam*                getWpAcDcParam()                                       { return &m_weightACDCParam[0]; }
     2269
    22632270  Void                        initWpAcDcParam();
    22642271
     
    22932300
    22942301  Void                        setLayerId(UInt layerId)                               { m_layerId = layerId;                                          }
    2295   UInt                        getLayerId()                                           { return m_layerId;                                             }
     2302  UInt                        getLayerId() const                                     { return m_layerId;                                             }
    22962303  UInt                        getLayerIdx()                                          { return m_pcVPS->getLayerIdxInVps(m_layerId);                  }
    22972304
     
    23472354  UInt                        getPicHeightInLumaSamples();
    23482355  ChromaFormat                getChromaFormatIdc();
    2349   UInt                        getBitDepthY();
    2350   UInt                        getBitDepthC();
    2351   Int                         getQpBDOffsetY();
    2352   Int                         getQpBDOffsetC();
     2356  UInt                        getBitDepth(ChannelType type) const;
     2357  BitDepths&                  getBitDepths();
     2358  Int                         getQpBDOffset(ChannelType type) const                  { return (getBitDepth(type) - 8) * 6;                           }
    23532359
    23542360  const Window&               getConformanceWindow() const;
  • branches/SHM-dev/source/Lib/TLibCommon/TComTrQuant.cpp

    r1285 r1287  
    119119                  toChannelType(compID),
    120120#if SVC_EXTENSION
    121                   isLuma(compID) ? slice->getQpBDOffsetY() : slice->getQpBDOffsetC(),
     121                  cu.getSlice()->getQpBDOffset(toChannelType(compID)),
    122122#else
    123123                  cu.getSlice()->getSPS()->getQpBDOffset(toChannelType(compID)),
     
    11471147  TComDataCU* pcCU          = rTu.getCU();
    11481148  const UInt uiAbsPartIdx   = rTu.GetAbsPartIdxTU();
     1149#if SVC_EXTENSION
     1150  const Int channelBitDepth = pcCU->getSlice()->getBitDepth(toChannelType(compID));
     1151#else
     1152  const Int channelBitDepth = pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID));
     1153#endif
    11491154
    11501155  TCoeff* piCoef    = pSrc;
     
    11921197
    11931198    // Represents scaling through forward transform
    1194     Int iTransformShift = getTransformShift(toChannelType(compID), uiLog2TrSize, maxLog2TrDynamicRange);
     1199    Int iTransformShift = getTransformShift(channelBitDepth, uiLog2TrSize, maxLog2TrDynamicRange);
    11951200    if (useTransformSkip && pcCU->getSlice()->getSPS()->getUseExtendedPrecision())
    11961201    {
     
    12711276  const Bool                 enableScalingLists = getUseScalingList(uiWidth, uiHeight, (pcCU->getTransformSkip(uiAbsPartIdx, compID) != 0));
    12721277  const Int                  scalingListType    = getScalingListType(pcCU->getPredictionMode(uiAbsPartIdx), compID);
     1278#if O0043_BEST_EFFORT_DECODING
     1279  const Int                  channelBitDepth    = pcCU->getSlice()->getSPS()->getStreamBitDepth(toChannelType(compID));
     1280#else
     1281#if SVC_EXTENSION
     1282  const Int                  channelBitDepth    = pcCU->getSlice()->getBitDepth(toChannelType(compID));
     1283#else
     1284  const Int                  channelBitDepth    = pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID));
     1285#endif
     1286#endif
    12731287
    12741288  assert (scalingListType < SCALING_LIST_NUM);
     
    12771291  // Represents scaling through forward transform
    12781292  const Bool bClipTransformShiftTo0 = (pcCU->getTransformSkip(uiAbsPartIdx, compID) != 0) && pcCU->getSlice()->getSPS()->getUseExtendedPrecision();
    1279   const Int  originalTransformShift = getTransformShift(toChannelType(compID), uiLog2TrSize, maxLog2TrDynamicRange);
     1293  const Int  originalTransformShift = getTransformShift(channelBitDepth, uiLog2TrSize, maxLog2TrDynamicRange);
    12801294  const Int  iTransformShift        = bClipTransformShiftTo0 ? std::max<Int>(0, originalTransformShift) : originalTransformShift;
    12811295
     
    14431457      else
    14441458      {
    1445         xT( compID, rTu.useDST(compID), pcResidual, uiStride, m_plTempCoeff, uiWidth, uiHeight, pcCU->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(compID)) );
     1459#if SVC_EXTENSION
     1460        const Int channelBitDepth=pcCU->getSlice()->getBitDepth(toChannelType(compID));
     1461#else
     1462        const Int channelBitDepth=pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID));
     1463#endif
     1464        xT( channelBitDepth, rTu.useDST(compID), pcResidual, uiStride, m_plTempCoeff, uiWidth, uiHeight, pcCU->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(compID)) );
    14461465      }
    14471466
     
    15731592    else
    15741593    {
    1575       xIT( compID, rTu.useDST(compID), m_plTempCoeff, pcResidual, uiStride, uiWidth, uiHeight, pcCU->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(compID)) );
     1594#if O0043_BEST_EFFORT_DECODING
     1595      const Int channelBitDepth = pcCU->getSlice()->getSPS()->getStreamBitDepth(toChannelType(compID));
     1596#else
     1597#if SVC_EXTENSION
     1598      const Int channelBitDepth = pcCU->getSlice()->getBitDepth(toChannelType(compID));
     1599#else
     1600      const Int channelBitDepth = pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID));
     1601#endif
     1602#endif
     1603      xIT( channelBitDepth, rTu.useDST(compID), m_plTempCoeff, pcResidual, uiStride, uiWidth, uiHeight, pcCU->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(compID)) );
    15761604
    15771605#if defined DEBUG_STRING
     
    18651893 *  \param iHeight transform height
    18661894 */
    1867 Void TComTrQuant::xT( const ComponentID compID, Bool useDST, Pel* piBlkResi, UInt uiStride, TCoeff* psCoeff, Int iWidth, Int iHeight, const Int maxLog2TrDynamicRange )
     1895Void TComTrQuant::xT( const Int channelBitDepth, Bool useDST, Pel* piBlkResi, UInt uiStride, TCoeff* psCoeff, Int iWidth, Int iHeight, const Int maxLog2TrDynamicRange )
    18681896{
    18691897#if MATRIX_MULT
    18701898  if( iWidth == iHeight)
    18711899  {
    1872     xTr(g_bitDepth[toChannelType(compID)], piBlkResi, psCoeff, uiStride, (UInt)iWidth, useDST, maxLog2TrDynamicRange);
     1900    xTr(channelBitDepth, piBlkResi, psCoeff, uiStride, (UInt)iWidth, useDST, maxLog2TrDynamicRange);
    18731901    return;
    18741902  }
     
    18861914  }
    18871915
    1888   xTrMxN( g_bitDepth[toChannelType(compID)], block, coeff, iWidth, iHeight, useDST, maxLog2TrDynamicRange );
     1916  xTrMxN( channelBitDepth, block, coeff, iWidth, iHeight, useDST, maxLog2TrDynamicRange );
    18891917
    18901918  memcpy(psCoeff, coeff, (iWidth * iHeight * sizeof(TCoeff)));
     
    19001928 *  \param iHeight transform height
    19011929 */
    1902 Void TComTrQuant::xIT( const ComponentID compID, Bool useDST, TCoeff* plCoef, Pel* pResidual, UInt uiStride, Int iWidth, Int iHeight, const Int maxLog2TrDynamicRange )
     1930Void TComTrQuant::xIT( const Int channelBitDepth, Bool useDST, TCoeff* plCoef, Pel* pResidual, UInt uiStride, Int iWidth, Int iHeight, const Int maxLog2TrDynamicRange )
    19031931{
    19041932#if MATRIX_MULT
    19051933  if( iWidth == iHeight )
    19061934  {
    1907 #if O0043_BEST_EFFORT_DECODING
    1908     xITr(g_bitDepthInStream[toChannelType(compID)], plCoef, pResidual, uiStride, (UInt)iWidth, useDST, maxLog2TrDynamicRange);
    1909 #else
    1910     xITr(g_bitDepth[toChannelType(compID)], plCoef, pResidual, uiStride, (UInt)iWidth, useDST, maxLog2TrDynamicRange);
    1911 #endif
     1935    xITr(channelBitDepth, plCoef, pResidual, uiStride, (UInt)iWidth, useDST, maxLog2TrDynamicRange);
    19121936    return;
    19131937  }
     
    19191943  memcpy(coeff, plCoef, (iWidth * iHeight * sizeof(TCoeff)));
    19201944
    1921 #if O0043_BEST_EFFORT_DECODING
    1922   xITrMxN( g_bitDepthInStream[toChannelType(compID)], coeff, block, iWidth, iHeight, useDST, maxLog2TrDynamicRange );
    1923 #else
    1924   xITrMxN( g_bitDepth[toChannelType(compID)], coeff, block, iWidth, iHeight, useDST, maxLog2TrDynamicRange );
    1925 #endif
     1945  xITrMxN( channelBitDepth, coeff, block, iWidth, iHeight, useDST, maxLog2TrDynamicRange );
    19261946
    19271947  for (Int y = 0; y < iHeight; y++)
     
    19471967  const Int height          = rect.height;
    19481968  const Int maxLog2TrDynamicRange = rTu.getCU()->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(component));
    1949 
    1950   Int iTransformShift = getTransformShift(toChannelType(component), rTu.GetEquivalentLog2TrSize(component), maxLog2TrDynamicRange);
     1969#if SVC_EXTENSION
     1970  const Int channelBitDepth = rTu.getCU()->getSlice()->getBitDepth(toChannelType(component));
     1971#else
     1972  const Int channelBitDepth = rTu.getCU()->getSlice()->getSPS()->getBitDepth(toChannelType(component));
     1973#endif
     1974
     1975  Int iTransformShift = getTransformShift(channelBitDepth, rTu.GetEquivalentLog2TrSize(component), maxLog2TrDynamicRange);
    19511976  if (rTu.getCU()->getSlice()->getSPS()->getUseExtendedPrecision())
    19521977  {
     
    19952020  const Int height          = rect.height;
    19962021  const Int maxLog2TrDynamicRange = rTu.getCU()->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(component));
    1997 
    1998   Int iTransformShift = getTransformShift(toChannelType(component), rTu.GetEquivalentLog2TrSize(component), maxLog2TrDynamicRange);
     2022#if O0043_BEST_EFFORT_DECODING
     2023  const Int channelBitDepth = rTu.getCU()->getSlice()->getSPS()->getStreamBitDepth(toChannelType(component));
     2024#else
     2025#if SVC_EXTENSION
     2026  const Int channelBitDepth = rTu.getCU()->getSlice()->getBitDepth(toChannelType(component));
     2027#else
     2028  const Int channelBitDepth = rTu.getCU()->getSlice()->getSPS()->getBitDepth(toChannelType(component));
     2029#endif
     2030#endif
     2031
     2032  Int iTransformShift = getTransformShift(channelBitDepth, rTu.GetEquivalentLog2TrSize(component), maxLog2TrDynamicRange);
    19992033  if (rTu.getCU()->getSlice()->getSPS()->getUseExtendedPrecision())
    20002034  {
     
    20632097  const Bool             extendedPrecision = pcCU->getSlice()->getSPS()->getUseExtendedPrecision();
    20642098  const Int              maxLog2TrDynamicRange = pcCU->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(compID));
     2099#if SVC_EXTENSION
     2100  const Int              channelBitDepth = rTu.getCU()->getSlice()->getBitDepth(channelType);
     2101#else
     2102  const Int              channelBitDepth = rTu.getCU()->getSlice()->getSPS()->getBitDepth(channelType);
     2103#endif
    20652104
    20662105  /* for 422 chroma blocks, the effective scaling applied during transformation is not a power of 2, hence it cannot be
     
    20712110
    20722111  // Represents scaling through forward transform
    2073   Int iTransformShift            = getTransformShift(channelType, uiLog2TrSize, maxLog2TrDynamicRange);
     2112  Int iTransformShift = getTransformShift(channelBitDepth, uiLog2TrSize, maxLog2TrDynamicRange);
    20742113  if ((pcCU->getTransformSkip(uiAbsPartIdx, compID) != 0) && pcCU->getSlice()->getSPS()->getUseExtendedPrecision())
    20752114  {
     
    24572496    const Double inverseQuantScale = Double(g_invQuantScales[cQP.rem]);
    24582497    Int64 rdFactor = (Int64)(inverseQuantScale * inverseQuantScale * (1 << (2 * cQP.per))
    2459                              / m_dLambda / 16 / (1 << (2 * DISTORTION_PRECISION_ADJUSTMENT(g_bitDepth[channelType] - 8)))
     2498                             / m_dLambda / 16 / (1 << (2 * DISTORTION_PRECISION_ADJUSTMENT(channelBitDepth - 8)))
    24602499                             + 0.5);
    24612500
     
    29863025 * \param format      chroma format
    29873026 */
    2988 Void TComTrQuant::setScalingList(TComScalingList *scalingList, const ChromaFormat format, const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE])
     3027Void TComTrQuant::setScalingList(TComScalingList *scalingList, const ChromaFormat format, const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE], const BitDepths &bitDepths)
    29893028{
    29903029  const Int minimumQp = 0;
     
    29993038        xSetScalingListEnc(scalingList,list,size,qp,format);
    30003039        xSetScalingListDec(*scalingList,list,size,qp,format);
    3001         setErrScaleCoeff(list,size,qp,maxLog2TrDynamicRange);
     3040        setErrScaleCoeff(list,size,qp,maxLog2TrDynamicRange, bitDepths);
    30023041      }
    30033042    }
     
    30293068 * \param qp   Quantization parameter
    30303069 */
    3031 Void TComTrQuant::setErrScaleCoeff(UInt list, UInt size, Int qp, const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE])
     3070Void TComTrQuant::setErrScaleCoeff(UInt list, UInt size, Int qp, const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE], const BitDepths &bitDepths)
    30323071{
    30333072  const UInt uiLog2TrSize = g_aucConvertToBit[ g_scalingListSizeX[size] ] + 2;
    30343073  const ChannelType channelType = ((list == 0) || (list == MAX_NUM_COMPONENT)) ? CHANNEL_TYPE_LUMA : CHANNEL_TYPE_CHROMA;
    30353074
    3036   const Int iTransformShift = getTransformShift(channelType, uiLog2TrSize, maxLog2TrDynamicRange[channelType]);  // Represents scaling through forward transform
     3075  const Int channelBitDepth    = bitDepths.recon[channelType];
     3076  const Int iTransformShift = getTransformShift(channelBitDepth, uiLog2TrSize, maxLog2TrDynamicRange[channelType]);  // Represents scaling through forward transform
    30373077
    30383078  UInt i,uiMaxNumCoeff = g_scalingListSize[size];
     
    30473087  for(i=0;i<uiMaxNumCoeff;i++)
    30483088  {
    3049     pdErrScale[i] =  dErrScale / piQuantcoeff[i] / piQuantcoeff[i] / (1 << DISTORTION_PRECISION_ADJUSTMENT(2 * (g_bitDepth[channelType] - 8)));
    3050   }
    3051 
    3052   getErrScaleCoeffNoScalingList(list, size, qp) = dErrScale / g_quantScales[qp] / g_quantScales[qp] / (1 << DISTORTION_PRECISION_ADJUSTMENT(2 * (g_bitDepth[channelType] - 8)));
     3089    pdErrScale[i] =  dErrScale / piQuantcoeff[i] / piQuantcoeff[i] / (1 << DISTORTION_PRECISION_ADJUSTMENT(2 * (bitDepths.recon[channelType] - 8)));
     3090  }
     3091
     3092  getErrScaleCoeffNoScalingList(list, size, qp) = dErrScale / g_quantScales[qp] / g_quantScales[qp] / (1 << DISTORTION_PRECISION_ADJUSTMENT(2 * (bitDepths.recon[channelType] - 8)));
    30533093}
    30543094
     
    31083148/** set flat matrix value to quantized coefficient
    31093149 */
    3110 Void TComTrQuant::setFlatScalingList(const ChromaFormat format, const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE])
     3150Void TComTrQuant::setFlatScalingList(const ChromaFormat format, const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE], const BitDepths &bitDepths)
    31113151{
    31123152  const Int minimumQp = 0;
     
    31203160      {
    31213161        xsetFlatScalingList(list,size,qp,format);
    3122         setErrScaleCoeff(list,size,qp,maxLog2TrDynamicRange);
     3162        setErrScaleCoeff(list,size,qp,maxLog2TrDynamicRange, bitDepths);
    31233163      }
    31243164    }
     
    32563296  const UInt           uiHeight                       = rect.height;
    32573297  const Int            maxLog2TrDynamicRange          = pcCU->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(compID));
    3258   const Int            iTransformShift                = getTransformShift(toChannelType(compID), rTu.GetEquivalentLog2TrSize(compID), maxLog2TrDynamicRange);
     3298#if SVC_EXTENSION
     3299  const Int            channelBitDepth                = pcCU->getSlice()->getBitDepth(toChannelType(compID));
     3300#else
     3301  const Int            channelBitDepth                = pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID));
     3302#endif
     3303  const Int            iTransformShift                = getTransformShift(channelBitDepth, rTu.GetEquivalentLog2TrSize(compID), maxLog2TrDynamicRange);
    32593304  const Int            scalingListType                = getScalingListType(pcCU->getPredictionMode(uiAbsPartIdx), compID);
    32603305  const Bool           enableScalingLists             = getUseScalingList(uiWidth, uiHeight, true);
     
    33153360  const Int            QP_rem             = cQP.rem;
    33163361  const Int            maxLog2TrDynamicRange = pcCU->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(compID));
    3317   const Int            iTransformShift    = getTransformShift(toChannelType(compID), rTu.GetEquivalentLog2TrSize(compID), maxLog2TrDynamicRange);
     3362#if O0043_BEST_EFFORT_DECODING
     3363  const Int            channelBitDepth    = pcCU->getSlice()->getSPS()->getStreamBitDepth(toChannelType(compID));
     3364#else
     3365#if SVC_EXTENSION
     3366  const Int            channelBitDepth    = pcCU->getSlice()->getBitDepth(toChannelType(compID));
     3367#else
     3368  const Int            channelBitDepth    = pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID));
     3369#endif
     3370#endif
     3371  const Int            iTransformShift    = getTransformShift(channelBitDepth, rTu.GetEquivalentLog2TrSize(compID), maxLog2TrDynamicRange);
    33183372  const Int            scalingListType    = getScalingListType(pcCU->getPredictionMode(uiAbsPartIdx), compID);
    33193373  const Bool           enableScalingLists = getUseScalingList(uiWidth, uiHeight, true);
  • branches/SHM-dev/source/Lib/TLibCommon/TComTrQuant.h

    r1285 r1287  
    172172  Void initScalingList                      ();
    173173  Void destroyScalingList                   ();
    174   Void setErrScaleCoeff    ( UInt list, UInt size, Int qp, const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE] );
     174  Void setErrScaleCoeff    ( UInt list, UInt size, Int qp, const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE], const BitDepths &bitDepths );
    175175  Double* getErrScaleCoeff              ( UInt list, UInt size, Int qp ) { return m_errScale             [size][list][qp]; };  //!< get Error Scale Coefficent
    176176  Double& getErrScaleCoeffNoScalingList ( UInt list, UInt size, Int qp ) { return m_errScaleNoScalingList[size][list][qp]; };  //!< get Error Scale Coefficent
     
    179179  Void setUseScalingList   ( Bool bUseScalingList){ m_scalingListEnabledFlag = bUseScalingList; };
    180180  Bool getUseScalingList   (const UInt width, const UInt height, const Bool isTransformSkip){ return m_scalingListEnabledFlag && (!isTransformSkip || ((width == 4) && (height == 4))); };
    181   Void setFlatScalingList  (const ChromaFormat format, const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE]);
     181  Void setFlatScalingList  (const ChromaFormat format, const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE], const BitDepths &bitDepths);
    182182  Void xsetFlatScalingList ( UInt list, UInt size, Int qp, const ChromaFormat format);
    183183  Void xSetScalingListEnc  ( TComScalingList *scalingList, UInt list, UInt size, Int qp, const ChromaFormat format);
    184184  Void xSetScalingListDec  ( const TComScalingList &scalingList, UInt list, UInt size, Int qp, const ChromaFormat format);
    185   Void setScalingList      ( TComScalingList *scalingList, const ChromaFormat format, const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE]);
     185  Void setScalingList      ( TComScalingList *scalingList, const ChromaFormat format, const Int maxLog2TrDynamicRange[MAX_NUM_CHANNEL_TYPE], const BitDepths &bitDepths);
    186186  Void setScalingListDec   ( const TComScalingList &scalingList, const ChromaFormat format);
    187187  Void processScalingListEnc( Int *coeff, Int *quantcoeff, Int quantScales, UInt height, UInt width, UInt ratio, Int sizuNum, UInt dc);
     
    230230private:
    231231  // forward Transform
    232   Void xT   ( const ComponentID compID, Bool useDST, Pel* piBlkResi, UInt uiStride, TCoeff* psCoeff, Int iWidth, Int iHeight, const Int maxLog2TrDynamicRange );
     232  Void xT   ( const Int channelBitDepth, Bool useDST, Pel* piBlkResi, UInt uiStride, TCoeff* psCoeff, Int iWidth, Int iHeight, const Int maxLog2TrDynamicRange );
    233233
    234234  // skipping Transform
     
    304304
    305305  // inverse transform
    306   Void xIT    ( const ComponentID compID, Bool useDST, TCoeff* plCoef, Pel* pResidual, UInt uiStride, Int iWidth, Int iHeight, const Int maxLog2TrDynamicRange );
     306  Void xIT    ( const Int channelBitDepth, Bool useDST, TCoeff* plCoef, Pel* pResidual, UInt uiStride, Int iWidth, Int iHeight, const Int maxLog2TrDynamicRange );
    307307
    308308  // inverse skipping transform
  • branches/SHM-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp

    r1235 r1287  
    5151}
    5252
    53 Void TComUpsampleFilter::upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic )
     53Void TComUpsampleFilter::upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Int refBitDepthLuma, const Int refBitDepthChroma )
    5454{
    5555  assert ( NTAPS_US_LUMA == 8 );
     
    6363  const Window &scalEL = currSlice->getPPS()->getScaledRefLayerWindowForLayer(refLayerId);
    6464  const Window &windowRL = currSlice->getPPS()->getRefLayerWindowForLayer(refLayerId);
     65
     66  Int bitDepthLuma = currSlice->getBitDepth(CHANNEL_TYPE_LUMA);
     67  Int bitDepthChroma = currSlice->getBitDepth(CHANNEL_TYPE_CHROMA);
    6568
    6669  //========== Y component upsampling ===========
     
    115118    piDstY = piDstBufY + scalEL.getWindowLeftOffset() + scalEL.getWindowTopOffset() * strideEL;
    116119
    117     Int shift = g_bitDepthLayer[CHANNEL_TYPE_LUMA][currLayerId] - g_bitDepthLayer[CHANNEL_TYPE_LUMA][refLayerId];
     120    Int shift = bitDepthLuma - refBitDepthLuma;
    118121
    119122#if CGS_3D_ASYMLUT
    120123    if( currSlice->getPPS()->getCGSFlag() )
    121124    {
    122       shift = g_bitDepthLayer[CHANNEL_TYPE_LUMA][currLayerId] - currSlice->getPPS()->getCGSOutputBitDepthY();
     125      shift = bitDepthLuma - currSlice->getPPS()->getCGSOutputBitDepthY();
    123126    }
    124127    assert( shift >= 0 );
     
    151154    piDstV = piDstBufV + ( scalEL.getWindowLeftOffset() >> 1 ) + ( scalEL.getWindowTopOffset() >> 1 ) * strideEL;
    152155
    153     shift = g_bitDepthLayer[CHANNEL_TYPE_CHROMA][currLayerId] - g_bitDepthLayer[CHANNEL_TYPE_CHROMA][refLayerId];
     156    shift = bitDepthChroma - refBitDepthChroma;
    154157
    155158#if CGS_3D_ASYMLUT
    156159    if( currSlice->getPPS()->getCGSFlag() )
    157160    {
    158       shift = g_bitDepthLayer[CHANNEL_TYPE_CHROMA][currLayerId] - currSlice->getPPS()->getCGSOutputBitDepthC();
     161      shift = currSlice->getBitDepth(CHANNEL_TYPE_CHROMA) - currSlice->getPPS()->getCGSOutputBitDepthC();
    159162    }
    160163#endif
     
    218221
    219222    // g_bitDepthY was set to EL bit-depth, but shift1 should be calculated using BL bit-depth
    220     Int shift1 = g_bitDepthLayer[CHANNEL_TYPE_LUMA][refLayerId] - 8;
     223    Int shift1 = refBitDepthLuma - 8;
    221224
    222225#if CGS_3D_ASYMLUT
     
    254257    pcTempPic->setHeight(heightEL);
    255258
    256     Int nShift = 20 - g_bitDepthLayer[CHANNEL_TYPE_LUMA][currLayerId];
     259    Int nShift = 20 - bitDepthLuma;
    257260    Int iOffset = 1 << (nShift - 1);
    258261
     
    273276      for( i = pcTempPic->getWidth(COMPONENT_Y); i > 0; i-- )
    274277      {
    275         *piDstY = Clip( (sumLumaVer(piSrcY, coeff, strideEL) + iOffset) >> (nShift), CHANNEL_TYPE_LUMA );
     278        *piDstY = ClipBD( (sumLumaVer(piSrcY, coeff, strideEL) + iOffset) >> (nShift), bitDepthLuma );
    276279        piSrcY++;
    277280        piDstY++;
     
    318321
    319322    // g_bitDepthC was set to EL bit-depth, but shift1 should be calculated using BL bit-depth
    320     shift1 = g_bitDepthLayer[CHANNEL_TYPE_CHROMA][refLayerId] - 8;
     323    shift1 = refBitDepthChroma - 8;
    321324
    322325#if CGS_3D_ASYMLUT
     
    360363    pcTempPic->setHeight(heightEL << 1);
    361364
    362     nShift = 20 - g_bitDepthLayer[CHANNEL_TYPE_CHROMA][currLayerId];
     365    nShift = 20 - bitDepthChroma;
    363366
    364367    iOffset = 1 << (nShift - 1);
     
    384387      for( i = pcTempPic->getWidth(COMPONENT_Y) >> 1; i > 0; i-- )
    385388      {
    386         *piDstU = Clip( (sumChromaVer(piSrcU, coeff, strideEL) + iOffset) >> (nShift), CHANNEL_TYPE_CHROMA );
    387         *piDstV = Clip( (sumChromaVer(piSrcV, coeff, strideEL) + iOffset) >> (nShift), CHANNEL_TYPE_CHROMA );
     389        *piDstU = ClipBD( (sumChromaVer(piSrcU, coeff, strideEL) + iOffset) >> (nShift), bitDepthChroma );
     390        *piDstV = ClipBD( (sumChromaVer(piSrcV, coeff, strideEL) + iOffset) >> (nShift), bitDepthChroma );
    388391        piSrcU++;
    389392        piSrcV++;
  • branches/SHM-dev/source/Lib/TLibCommon/TComUpsampleFilter.h

    r1090 r1287  
    4242  TComUpsampleFilter(void);
    4343  ~TComUpsampleFilter(void);
    44   Void upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic );
     44  Void upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Int refBitDepthLuma, const Int refBitDepthChroma );
    4545
    4646};
  • branches/SHM-dev/source/Lib/TLibCommon/TComWeightPrediction.cpp

    r1262 r1287  
    6767Void TComWeightPrediction::addWeightBi( const TComYuv              *pcYuvSrc0,
    6868                                        const TComYuv              *pcYuvSrc1,
     69                                        const BitDepths            &bitDepths,
    6970                                        const UInt                  iPartUnitIdx,
    7071                                        const UInt                  uiWidth,
     
    7374                                        const WPScalingParam *const wp1,
    7475                                              TComYuv        *const rpcYuvDst,
    75                                         const Bool                  bRoundLuma )
     76                                        const Bool                  bRoundLuma)
    7677{
    7778
     
    9192    const Int  w0          = wp0[compID].w;
    9293    const Int  offset      = wp0[compID].offset;
    93     const Int  clipBD      = g_bitDepth[toChannelType(compID)];
     94    const Int  clipBD      = bitDepths.recon[toChannelType(compID)];
    9495    const Int  shiftNum    = std::max<Int>(2, (IF_INTERNAL_PREC - clipBD));
    9596    const Int  shift       = wp0[compID].shift + shiftNum;
     
    131132//! weighted averaging for uni-pred
    132133Void TComWeightPrediction::addWeightUni( const TComYuv        *const pcYuvSrc0,
     134                                         const BitDepths            &bitDepths,
    133135                                         const UInt                  iPartUnitIdx,
    134136                                         const UInt                  uiWidth,
     
    149151    const Int  w0          = wp0[compID].w;
    150152    const Int  offset      = wp0[compID].offset;
    151     const Int  clipBD      = g_bitDepth[toChannelType(compID)];
     153    const Int  clipBD      = bitDepths.recon[toChannelType(compID)];
    152154    const Int  shiftNum    = std::max<Int>(2, (IF_INTERNAL_PREC - clipBD));
    153155    const Int  shift       = wp0[compID].shift + shiftNum;
     
    230232    for ( Int yuv=0 ; yuv<numValidComponent ; yuv++ )
    231233    {
    232       const Int bitDepth            = g_bitDepth[toChannelType(ComponentID(yuv))];
     234#if SVC_EXTENSION
     235      const Int bitDepth            = pcSlice->getBitDepth(toChannelType(ComponentID(yuv)));
     236#else
     237      const Int bitDepth            = pcSlice->getSPS()->getBitDepth(toChannelType(ComponentID(yuv)));
     238#endif
    233239      const Int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (bitDepth-8));
    234240
     
    251257    for ( Int yuv=0 ; yuv<numValidComponent ; yuv++ )
    252258    {
    253       const Int bitDepth            = g_bitDepth[toChannelType(ComponentID(yuv))];
     259#if SVC_EXTENSION
     260      const Int bitDepth            = pcSlice->getBitDepth(toChannelType(ComponentID(yuv)));
     261#else
     262      const Int bitDepth            = pcSlice->getSPS()->getBitDepth(toChannelType(ComponentID(yuv)));
     263#endif
    254264      const Int offsetScalingFactor = bUseHighPrecisionPredictionWeighting ? 1 : (1 << (bitDepth-8));
    255265
     
    283293  if( iRefIdx0 >= 0 && iRefIdx1 >= 0 )
    284294  {
    285     addWeightBi(pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight, pwp0, pwp1, rpcYuvDst );
     295#if SVC_EXTENSION
     296    addWeightBi(pcYuvSrc0, pcYuvSrc1, pcCU->getSlice()->getBitDepths(), uiPartIdx, iWidth, iHeight, pwp0, pwp1, rpcYuvDst );
     297#else
     298    addWeightBi(pcYuvSrc0, pcYuvSrc1, pcCU->getSlice()->getSPS()->getBitDepths(), uiPartIdx, iWidth, iHeight, pwp0, pwp1, rpcYuvDst );
     299#endif
    286300  }
    287301  else if ( iRefIdx0 >= 0 && iRefIdx1 <  0 )
    288302  {
    289     addWeightUni( pcYuvSrc0, uiPartIdx, iWidth, iHeight, pwp0, rpcYuvDst );
     303#if SVC_EXTENSION
     304    addWeightUni( pcYuvSrc0, pcCU->getSlice()->getBitDepths(), uiPartIdx, iWidth, iHeight, pwp0, rpcYuvDst );
     305#else
     306    addWeightUni( pcYuvSrc0, pcCU->getSlice()->getSPS()->getBitDepths(), uiPartIdx, iWidth, iHeight, pwp0, rpcYuvDst );
     307#endif
    290308  }
    291309  else if ( iRefIdx0 <  0 && iRefIdx1 >= 0 )
    292310  {
    293     addWeightUni( pcYuvSrc1, uiPartIdx, iWidth, iHeight, pwp1, rpcYuvDst );
     311#if SVC_EXTENSION
     312    addWeightUni( pcYuvSrc1, pcCU->getSlice()->getBitDepths(), uiPartIdx, iWidth, iHeight, pwp1, rpcYuvDst );
     313#else
     314    addWeightUni( pcYuvSrc1, pcCU->getSlice()->getSPS()->getBitDepths(), uiPartIdx, iWidth, iHeight, pwp1, rpcYuvDst );
     315#endif
    294316  }
    295317  else
     
    327349    getWpScaling(pcCU, -1, iRefIdx, pwpTmp, pwp);
    328350  }
    329   addWeightUni( pcYuvSrc, uiPartAddr, iWidth, iHeight, pwp, pcYuvPred );
    330 }
     351#if SVC_EXTENSION
     352  addWeightUni( pcYuvSrc, pcCU->getSlice()->getBitDepths(), uiPartAddr, iWidth, iHeight, pwp, pcYuvPred );
     353#else
     354  addWeightUni( pcYuvSrc, pcCU->getSlice()->getSPS()->getBitDepths(), uiPartAddr, iWidth, iHeight, pwp, pcYuvPred );
     355#endif
     356}
  • branches/SHM-dev/source/Lib/TLibCommon/TComWeightPrediction.h

    r1262 r1287  
    6363  Void addWeightBi(             const TComYuv              *pcYuvSrc0,
    6464                                const TComYuv              *pcYuvSrc1,
     65                                const BitDepths            &bitDepths,
    6566                                const UInt                  iPartUnitIdx,
    6667                                const UInt                  uiWidth,
     
    7273
    7374  Void  addWeightUni(           const TComYuv        *const pcYuvSrc0,
     75                                const BitDepths            &bitDepths,
    7476                                const UInt                  iPartUnitIdx,
    7577                                const UInt                  uiWidth,
  • branches/SHM-dev/source/Lib/TLibCommon/TComYuv.cpp

    r1259 r1287  
    278278
    279279
    280 Void TComYuv::addClip( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt uiTrUnitIdx, const UInt uiPartSize )
     280Void TComYuv::addClip( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt uiTrUnitIdx, const UInt uiPartSize, const BitDepths &clipBitDepths )
    281281{
    282282  for(Int chan=0; chan<getNumberValidComponents(); chan++)
     
    293293    const UInt iSrc1Stride = pcYuvSrc1->getStride(ch);
    294294    const UInt iDstStride  = getStride(ch);
    295     const Int clipbd = g_bitDepth[toChannelType(ch)];
     295    const Int clipbd = clipBitDepths.recon[toChannelType(ch)];
    296296#if O0043_BEST_EFFORT_DECODING
    297     const Int bitDepthDelta = g_bitDepthInStream[toChannelType(ch)] - g_bitDepth[toChannelType(ch)];
     297    const Int bitDepthDelta = clipBitDepths.stream[toChannelType(ch)] - clipbd;
    298298#endif
    299299
     
    350350
    351351
    352 Void TComYuv::addAvg( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt iPartUnitIdx, const UInt uiWidth, const UInt uiHeight )
     352Void TComYuv::addAvg( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt iPartUnitIdx, const UInt uiWidth, const UInt uiHeight, const BitDepths &clipBitDepths )
    353353{
    354354  for(Int chan=0; chan<getNumberValidComponents(); chan++)
     
    362362    const UInt  iSrc1Stride = pcYuvSrc1->getStride(ch);
    363363    const UInt  iDstStride  = getStride(ch);
    364     const Int   clipbd      = g_bitDepth[toChannelType(ch)];
     364    const Int   clipbd      = clipBitDepths.recon[toChannelType(ch)];
    365365    const Int   shiftNum    = std::max<Int>(2, (IF_INTERNAL_PREC - clipbd)) + 1;
    366366    const Int   offset      = ( 1 << ( shiftNum - 1 ) ) + 2 * IF_INTERNAL_OFFS;
  • branches/SHM-dev/source/Lib/TLibCommon/TComYuv.h

    r1262 r1287  
    131131
    132132  //  Clip(pcYuvSrc0 + pcYuvSrc1) -> m_apiBuf
    133   Void         addClip                    ( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt uiTrUnitIdx, const UInt uiPartSize );
     133  Void         addClip                    ( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt uiTrUnitIdx, const UInt uiPartSize, const BitDepths &clipBitDepths );
    134134
    135135  //  pcYuvSrc0 - pcYuvSrc1 -> m_apiBuf
     
    137137
    138138  //  (pcYuvSrc0 + pcYuvSrc1)/2 for YUV partition
    139   Void         addAvg                     ( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt iPartUnitIdx, const UInt iWidth, const UInt iHeight );
     139  Void         addAvg                     ( const TComYuv* pcYuvSrc0, const TComYuv* pcYuvSrc1, const UInt iPartUnitIdx, const UInt iWidth, const UInt iHeight, const BitDepths &clipBitDepths );
    140140
    141141  Void         removeHighFreq             ( const TComYuv* pcYuvSrc, const UInt uiPartIdx, const UInt uiWidth, const UInt uiHeight );
  • branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h

    r1273 r1287  
    842842
    843843
     844struct BitDepths
     845{
     846#if O0043_BEST_EFFORT_DECODING
     847  Int recon[MAX_NUM_CHANNEL_TYPE]; ///< the bit depth used for reconstructing the video
     848  Int stream[MAX_NUM_CHANNEL_TYPE];///< the bit depth used indicated in the SPS
     849#else
     850  Int recon[MAX_NUM_CHANNEL_TYPE]; ///< the bit depth as indicated in the SPS
     851#endif
     852
     853#if SVC_EXTENSION
     854  BitDepths()
     855  {
     856  }
     857  BitDepths(Int bitDepthY, Int bitDepthC)
     858  {
     859    recon[CHANNEL_TYPE_LUMA] = bitDepthY;
     860    recon[CHANNEL_TYPE_CHROMA] = bitDepthC;
     861  }
     862#endif
     863};
     864
    844865/// parameters for deblocking filter
    845866typedef struct _LFCUParam
  • branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r1275 r1287  
    766766  READ_UVLC(     uiCode, "bit_depth_luma_minus8" );
    767767#if O0043_BEST_EFFORT_DECODING
     768  pcSPS->setStreamBitDepth(CHANNEL_TYPE_LUMA, 8 + uiCode);
    768769  const UInt forceDecodeBitDepth = pcSPS->getForceDecodeBitDepth();
    769   g_bitDepthInStream[CHANNEL_TYPE_LUMA] = 8 + uiCode;
    770770  if (forceDecodeBitDepth != 0)
    771771  {
     
    774774#endif
    775775  assert(uiCode <= 8);
    776 
    777776  pcSPS->setBitDepth(CHANNEL_TYPE_LUMA, 8 + uiCode);
     777
    778778#if O0043_BEST_EFFORT_DECODING
    779   pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*(g_bitDepthInStream[CHANNEL_TYPE_LUMA]-8)) );
     779  pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*(pcSPS->getStreamBitDepth(CHANNEL_TYPE_LUMA)-8)) );
    780780#else
    781781  pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*uiCode) );
     
    784784  READ_UVLC( uiCode,    "bit_depth_chroma_minus8" );
    785785#if O0043_BEST_EFFORT_DECODING
    786   g_bitDepthInStream[CHANNEL_TYPE_CHROMA] = 8 + uiCode;
     786  pcSPS->setStreamBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode);
    787787  if (forceDecodeBitDepth != 0)
    788788  {
     
    793793  pcSPS->setBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode);
    794794#if O0043_BEST_EFFORT_DECODING
    795   pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA,  (Int) (6*(g_bitDepthInStream[CHANNEL_TYPE_CHROMA]-8)) );
     795  pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA,  (Int) (6*(pcSPS->getStreamBitDepth(CHANNEL_TYPE_CHROMA)-8)) );
    796796#else
    797797  pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA,  (Int) (6*uiCode) );
     
    18211821
    18221822#if SVC_EXTENSION
    1823     g_bitDepthLayer[CHANNEL_TYPE_LUMA][pcSlice->getLayerId()] = pcSlice->getBitDepthY();
    1824     g_bitDepthLayer[CHANNEL_TYPE_CHROMA][pcSlice->getLayerId()] = pcSlice->getBitDepthC();
    1825 
    1826     assert( pcSlice->getSliceQp() >= -pcSlice->getQpBDOffsetY() );
     1823    assert( pcSlice->getSliceQp() >= -pcSlice->getQpBDOffset(CHANNEL_TYPE_LUMA) );
    18271824#else   
    18281825    assert( pcSlice->getSliceQp() >= -sps->getQpBDOffset(CHANNEL_TYPE_LUMA) );
     
    23602357
    23612358#if SVC_EXTENSION
    2362   Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY();
     2359  Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffset(CHANNEL_TYPE_LUMA);
    23632360#else
    23642361  Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA);
     
    24832480        wp[COMPONENT_Y].iWeight = (iDeltaWeight + (1<<wp[COMPONENT_Y].uiLog2WeightDenom));
    24842481        READ_SVLC( wp[COMPONENT_Y].iOffset, iNumRef==0?"luma_offset_l0[i]":"luma_offset_l1[i]" );
    2485         Int range=sps->getUseHighPrecisionPredictionWeighting() ? (1<<g_bitDepth[CHANNEL_TYPE_LUMA])/2 : 128;
     2482#if SVC_EXTENSION
     2483        Int range=sps->getUseHighPrecisionPredictionWeighting() ? (1<<pcSlice->getBitDepth(CHANNEL_TYPE_LUMA))/2 : 128;
     2484#else
     2485        Int range=sps->getUseHighPrecisionPredictionWeighting() ? (1<<sps->getBitDepth(CHANNEL_TYPE_LUMA))/2 : 128;
     2486#endif
    24862487        assert( wp[0].iOffset >= -range );
    24872488        assert( wp[0].iOffset <   range );
     
    24962497        if ( wp[COMPONENT_Cb].bPresentFlag )
    24972498        {
    2498           Int range=sps->getUseHighPrecisionPredictionWeighting() ? (1<<g_bitDepth[CHANNEL_TYPE_CHROMA])/2 : 128;
     2499#if SVC_EXTENSION
     2500          Int range=sps->getUseHighPrecisionPredictionWeighting() ? (1<<pcSlice->getBitDepth(CHANNEL_TYPE_CHROMA))/2 : 128;
     2501#else
     2502          Int range=sps->getUseHighPrecisionPredictionWeighting() ? (1<<sps->getBitDepth(CHANNEL_TYPE_CHROMA))/2 : 128;
     2503#endif
    24992504          for ( Int j=1 ; j<numValidComp ; j++ )
    25002505          {
  • branches/SHM-dev/source/Lib/TLibDecoder/TDecCu.cpp

    r1263 r1287  
    499499  if  ( pcCU->getQtRootCbf( 0) )
    500500  {
    501     m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ) );
     501#if SVC_EXTENSION
     502    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getBitDepths() );
     503#else
     504    m_ppcYuvReco[uiDepth]->addClip( m_ppcYuvReco[uiDepth], m_ppcYuvResi[uiDepth], 0, pcCU->getWidth( 0 ), pcCU->getSlice()->getSPS()->getBitDepths() );
     505#endif
    502506  }
    503507  else
     
    642646#endif
    643647
     648#if SVC_EXTENSION
     649  const Int clipbd = pcCU->getSlice()->getBitDepth(toChannelType(compID));
     650#else
     651  const Int clipbd = pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID));
     652#endif
    644653#if O0043_BEST_EFFORT_DECODING
    645   const Int bitDepthDelta = g_bitDepthInStream[toChannelType(compID)] - g_bitDepth[toChannelType(compID)];
    646 #endif
    647   const Int clipbd = g_bitDepth[toChannelType(compID)];
     654  const Int bitDepthDelta = pcCU->getSlice()->getSPS()->getStreamBitDepth(toChannelType(compID)) - clipbd;
     655#endif
    648656
    649657  if( useCrossComponentPrediction )
     
    825833        Pel* piPicReco         = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiPartIdx);
    826834  const UInt uiPicStride       = pcCU->getPic()->getPicYuvRec()->getStride(compID);
    827   const UInt uiPcmLeftShiftBit = g_bitDepth[toChannelType(compID)] - pcCU->getSlice()->getSPS()->getPCMBitDepth(toChannelType(compID));
     835#if SVC_EXTENSION
     836  const UInt uiPcmLeftShiftBit = pcCU->getSlice()->getBitDepth(toChannelType(compID)) - pcCU->getSlice()->getSPS()->getPCMBitDepth(toChannelType(compID));
     837#else
     838  const UInt uiPcmLeftShiftBit = pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID)) - pcCU->getSlice()->getSPS()->getPCMBitDepth(toChannelType(compID));
     839#endif
    828840
    829841  for(UInt uiY = 0; uiY < uiHeight; uiY++ )
  • branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp

    r1273 r1287  
    6363//! \ingroup TLibDecoder
    6464//! \{
    65 static Void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI);
     65static Void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI, const BitDepths &bitDepths);
    6666// ====================================================================================================================
    6767// Constructor / destructor / initialization / destroy
     
    246246      printf ("Warning: Got multiple decoded picture hash SEI messages. Using first.");
    247247    }
    248     calcAndPrintHashStatus(*(pcPic->getPicYuvRec()), hash);
     248#if SVC_EXTENSION
     249    calcAndPrintHashStatus(*(pcPic->getPicYuvRec()), hash, pcSlice->getBitDepths());
     250#else
     251    calcAndPrintHashStatus(*(pcPic->getPicYuvRec()), hash, pcSlice->getSPS()->getBitDepths());
     252#endif
    249253  }
    250254#if CONFORMANCE_BITSTREAM_MODE
     
    275279 *            unk         - no SEI message was available for comparison
    276280 */
    277 static Void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI)
     281static Void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI, const BitDepths &bitDepths)
    278282{
    279283  /* calculate MD5sum for entire reconstructed picture */
     
    289293        {
    290294          hashType = "MD5";
    291           numChar = calcMD5(pic, recon_digest);
     295          numChar = calcMD5(pic, recon_digest, bitDepths);
    292296          break;
    293297        }
     
    295299        {
    296300          hashType = "CRC";
    297           numChar = calcCRC(pic, recon_digest);
     301          numChar = calcCRC(pic, recon_digest, bitDepths);
    298302          break;
    299303        }
     
    301305        {
    302306          hashType = "Checksum";
    303           numChar = calcChecksum(pic, recon_digest);
     307          numChar = calcChecksum(pic, recon_digest, bitDepths);
    304308          break;
    305309        }
  • branches/SHM-dev/source/Lib/TLibDecoder/TDecSbac.cpp

    r1285 r1287  
    947947    UInt uiSign;
    948948#if SVC_EXTENSION
    949     Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY();
     949    Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffset(CHANNEL_TYPE_LUMA);
    950950#else
    951951    Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA);
     
    16871687
    16881688Void TDecSbac::parseSAOBlkParam (SAOBlkParam& saoBlkParam
    1689 #if SVC_EXTENSION
    1690                                 , UInt* saoMaxOffsetQVal
    1691 #endif
    16921689                                , Bool* sliceEnabled
    16931690                                , Bool leftMergeAvail
    16941691                                , Bool aboveMergeAvail
     1692                                , const BitDepths &bitDepths
    16951693                                )
    16961694{
     
    17271725      const ComponentID firstCompOfChType = getFirstComponentOfChannel(toChannelType(compIdx));
    17281726      SAOOffset& ctbParam = saoBlkParam[compIdx];
    1729 
     1727#if O0043_BEST_EFFORT_DECODING
     1728      const Int bitDepthOrig = bitDepths.stream[toChannelType(compIdx)];
     1729      const Int forceBitDepthAdjust = bitDepthOrig - bitDepths.recon[toChannelType(compIdx)];
     1730#else
     1731      const Int bitDepthOrig = bitDepths.recon[toChannelType(compIdx)];
     1732#endif
     1733      const Int maxOffsetQVal=TComSampleAdaptiveOffset::getMaxOffsetQVal(bitDepthOrig);
    17301734      if(!sliceEnabled[compIdx])
    17311735      {
     
    17661770      if(ctbParam.modeIdc == SAO_MODE_NEW)
    17671771      {
    1768 #if O0043_BEST_EFFORT_DECODING
    1769         Int bitDepthOrig = g_bitDepthInStream[toChannelType(compIdx)];
    1770         Int forceBitDepthAdjust = bitDepthOrig - g_bitDepth[toChannelType(compIdx)];
    1771 #endif
    17721772        Int offset[4];
    17731773        for(Int i=0; i< 4; i++)
    17741774        {
    1775 #if O0043_BEST_EFFORT_DECODING
    1776           Int saoMaxOffsetQVal = (1<<(min(bitDepthOrig, MAX_SAO_TRUNCATED_BITDEPTH)-5))-1;
    1777           parseSaoMaxUvlc(uiSymbol, saoMaxOffsetQVal); //sao_offset_abs
    1778 #else
    1779 #if SVC_EXTENSION
    1780           parseSaoMaxUvlc(uiSymbol,  saoMaxOffsetQVal[compIdx] ); //sao_offset_abs
    1781 #else
    1782           parseSaoMaxUvlc(uiSymbol,  g_saoMaxOffsetQVal[compIdx] ); //sao_offset_abs
    1783 #endif
    1784 #endif
     1775          parseSaoMaxUvlc(uiSymbol, maxOffsetQVal ); //sao_offset_abs
    17851776          offset[i] = (Int)uiSymbol;
    17861777        }
  • branches/SHM-dev/source/Lib/TLibDecoder/TDecSbac.h

    r1285 r1287  
    9393  Void  parseSaoTypeIdx           ( UInt&  ruiVal  );
    9494  Void  parseSaoUflc              ( UInt uiLength, UInt& ruiVal     );
    95 
    96 #if SVC_EXTENSION
    97   Void parseSAOBlkParam           (SAOBlkParam& saoBlkParam, UInt* saoMaxOffsetQVal, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail );
    98 #else
    99   Void parseSAOBlkParam           (SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail);
    100 #endif
     95  Void parseSAOBlkParam           (SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, const BitDepths &bitDepths);
    10196  Void parseSaoSign               (UInt& val);
    10297
  • branches/SHM-dev/source/Lib/TLibDecoder/TDecSlice.cpp

    r1259 r1287  
    6161}
    6262
    63 #if SVC_EXTENSION
    64 Void TDecSlice::init(TDecEntropy* pcEntropyDecoder, TDecCu* pcCuDecoder, UInt* saoMaxOffsetQVal)
     63Void TDecSlice::init(TDecEntropy* pcEntropyDecoder, TDecCu* pcCuDecoder)
    6564{
    6665  m_pcEntropyDecoder  = pcEntropyDecoder;
    6766  m_pcCuDecoder       = pcCuDecoder;
    68   m_saoMaxOffsetQVal  = saoMaxOffsetQVal;
    69 }
    70 #else
    71 Void TDecSlice::init(TDecEntropy* pcEntropyDecoder, TDecCu* pcCuDecoder)
    72 {
    73   m_pcEntropyDecoder  = pcEntropyDecoder;
    74   m_pcCuDecoder       = pcCuDecoder;
    75 }
    76 #endif
     67}
    7768
    7869Void TDecSlice::decompressSlice(TComInputBitstream** ppcSubstreams, TComPic* pcPic, TDecSbac* pcSbacDecoder)
     
    211202        }
    212203#if SVC_EXTENSION
    213         pcSbacDecoder->parseSAOBlkParam( saoblkParam, m_saoMaxOffsetQVal, sliceEnabled, leftMergeAvail, aboveMergeAvail);
     204        pcSbacDecoder->parseSAOBlkParam( saoblkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail, pcSlice->getBitDepths());
    214205#else
    215         pcSbacDecoder->parseSAOBlkParam( saoblkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail);
    216 #endif     
     206        pcSbacDecoder->parseSAOBlkParam( saoblkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail, pcSlice->getSPS()->getBitDepths());
     207#endif
    217208      }
    218209    }
  • branches/SHM-dev/source/Lib/TLibDecoder/TDecSlice.h

    r1259 r1287  
    7777  virtual ~TDecSlice();
    7878 
    79 #if SVC_EXTENSION 
    80   Void  init              ( TDecEntropy* pcEntropyDecoder, TDecCu* pcMbDecoder, UInt* saoMaxOffsetQVal );
    81 #else
    8279  Void  init              ( TDecEntropy* pcEntropyDecoder, TDecCu* pcMbDecoder );
    83 #endif
    8480  Void  create            ();
    8581  Void  destroy           ();
  • branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp

    r1285 r1287  
    181181#if SVC_EXTENSION
    182182  m_cGopDecoder.init( m_ppcTDecTop, &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO);
    183   m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder, m_cSAO.getSaoMaxOffsetQVal() );
    184183#else
    185184  m_cGopDecoder.init( &m_cEntropyDecoder, &m_cSbacDecoder, &m_cBinCABAC, &m_cCavlcDecoder, &m_cSliceDecoder, &m_cLoopFilter, &m_cSAO);
     185#endif
    186186  m_cSliceDecoder.init( &m_cEntropyDecoder, &m_cCuDecoder );
    187 #endif
    188187  m_cEntropyDecoder.init(&m_cPrediction);
    189188}
     
    499498        // it is needed where the VPS is accessed through the slice
    500499        pBLPic->getSlice(0)->setVPS( vps );
    501 
    502         g_bitDepthLayer[CHANNEL_TYPE_LUMA][0] = repFormat->getBitDepthVpsLuma();
    503         g_bitDepthLayer[CHANNEL_TYPE_CHROMA][0] = repFormat->getBitDepthVpsChroma();
    504500      }
    505501    }
     
    577573
    578574    // TODO: remove the use of the following globals:
    579     for (UInt channel = 0; channel < MAX_NUM_CHANNEL_TYPE; channel++)
    580     {
    581 #if SVC_EXTENSION
    582       g_bitDepth[channel] = isLuma(ChannelType(channel)) ? vps->getBitDepthY(sps, m_apcSlicePilot->getLayerId()) : vps->getBitDepthC(sps, m_apcSlicePilot->getLayerId());
    583 #else
    584       g_bitDepth[channel] = sps->getBitDepth(ChannelType(channel));
    585 #endif     
    586     }
    587575    g_uiMaxCUWidth  = sps->getMaxCUWidth();
    588576    g_uiMaxCUHeight = sps->getMaxCUHeight();
     
    13101298      if( pFile->good() )
    13111299      {
    1312         Bool is16bit  = g_bitDepthLayer[CHANNEL_TYPE_LUMA][0] > 8 || g_bitDepthLayer[CHANNEL_TYPE_CHROMA][0] > 8;
     1300        Bool is16bit  = pBLPic->getSlice(0)->getBitDepth(CHANNEL_TYPE_LUMA) > 8 || pBLPic->getSlice(0)->getBitDepth(CHANNEL_TYPE_CHROMA) > 8;
    13131301        UInt uiWidth  = pBLPic->getPicYuvRec()->getWidth(COMPONENT_Y);
    13141302        UInt uiHeight = pBLPic->getPicYuvRec()->getHeight(COMPONENT_Y);
     
    16041592        if( pcSlice->getPPS()->getCGSFlag() && m_c3DAsymLUTPPS.isRefLayer( pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc) ) )
    16051593        {
    1606           assert( pcSlice->getBaseColPic( refLayerIdc )->getSlice( 0 )->getBitDepthY() == m_c3DAsymLUTPPS.getInputBitDepthY() );
    1607           assert( pcSlice->getBaseColPic( refLayerIdc )->getSlice( 0 )->getBitDepthC() == m_c3DAsymLUTPPS.getInputBitDepthC() );
    1608           assert( pcSlice->getBitDepthY() >= m_c3DAsymLUTPPS.getOutputBitDepthY() );
    1609           assert( pcSlice->getBitDepthY() >= m_c3DAsymLUTPPS.getOutputBitDepthC() );
     1594          assert( pcSlice->getBaseColPic( refLayerIdc )->getSlice( 0 )->getBitDepth(CHANNEL_TYPE_LUMA) == m_c3DAsymLUTPPS.getInputBitDepthY() );
     1595          assert( pcSlice->getBaseColPic( refLayerIdc )->getSlice( 0 )->getBitDepth(CHANNEL_TYPE_CHROMA) == m_c3DAsymLUTPPS.getInputBitDepthC() );
     1596          assert( pcSlice->getBitDepth(CHANNEL_TYPE_LUMA) >= m_c3DAsymLUTPPS.getOutputBitDepthY() );
     1597          assert( pcSlice->getBitDepth(CHANNEL_TYPE_LUMA) >= m_c3DAsymLUTPPS.getOutputBitDepthC() );
    16101598
    16111599          if( !m_pColorMappedPic )
     
    16141602          }
    16151603
    1616           m_c3DAsymLUTPPS.colorMapping( pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(),  m_pColorMappedPic );
     1604          m_c3DAsymLUTPPS.colorMapping( pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), m_pColorMappedPic );
    16171605          pBaseColRec = m_pColorMappedPic;
    16181606        }
     
    16241612          if( pcSlice->getVPS()->isSamplePredictionType( pcSlice->getVPS()->getLayerIdxInVps(m_layerId), pcSlice->getVPS()->getLayerIdxInVps(refLayerId) ) )
    16251613          {
    1626             m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec());
     1614            m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, m_pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, m_pcPic->getPicYuvRec(), pcSlice->getBaseColPic( refLayerIdc )->getSlice( 0 )->getBitDepth(CHANNEL_TYPE_LUMA), pcSlice->getBaseColPic( refLayerIdc )->getSlice( 0 )->getBitDepth(CHANNEL_TYPE_CHROMA));
    16271615          }
    16281616        }
     
    18041792    };
    18051793#if SVC_EXTENSION
    1806     m_cTrQuant.setFlatScalingList(pcSlice->getChromaFormatIdc(), maxLog2TrDynamicRange);
     1794    m_cTrQuant.setFlatScalingList(pcSlice->getChromaFormatIdc(), maxLog2TrDynamicRange, pcSlice->getBitDepths());
    18071795#else
    1808     m_cTrQuant.setFlatScalingList(pcSlice->getSPS()->getChromaFormatIdc(), maxLog2TrDynamicRange);
     1796    m_cTrQuant.setFlatScalingList(pcSlice->getSPS()->getChromaFormatIdc(), maxLog2TrDynamicRange, pcSlice->getSPS()->getBitDepths());
    18091797#endif
    18101798    m_cTrQuant.setUseScalingList(false);
     
    22102198  const TComSPS* sps  = slice->getSPS();
    22112199
    2212   Int bitDepthY   = slice->getBitDepthY();
    2213   Int bitDepthC   = slice->getBitDepthC();
    2214 
    22152200  if( m_layerId > 0 )
    22162201  {
    2217 
    2218     g_bitDepth[CHANNEL_TYPE_LUMA]     = bitDepthY;
    2219     g_bitDepth[CHANNEL_TYPE_CHROMA]   = bitDepthC;
    22202202    g_uiMaxCUWidth  = sps->getMaxCUWidth();
    22212203    g_uiMaxCUHeight = sps->getMaxCUHeight();
     
    25592541
    25602542    TDecTop *pcTDecTopBase = (TDecTop *)getRefLayerDec( i );
    2561     TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec();
    2562 
    2563     UInt refLayerId = vps.getRefLayerId(m_layerId, i);
    2564     Bool sameBitDepths = ( g_bitDepthLayer[CHANNEL_TYPE_LUMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_LUMA][refLayerId] ) && ( g_bitDepthLayer[CHANNEL_TYPE_CHROMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_CHROMA][refLayerId] );
     2543    TComPicYuv* pcPicYuvRecBase = (*(pcTDecTopBase->getListPic()->begin()))->getPicYuvRec();
     2544
     2545    const Int bitDepthLuma = vps.getBitDepth(CHANNEL_TYPE_LUMA, &sps, m_layerId);
     2546    const Int bitDepthChroma = vps.getBitDepth(CHANNEL_TYPE_CHROMA, &sps, m_layerId);
     2547    const Int refBitDepthLuma = (*(pcTDecTopBase->getListPic()->begin()))->getSlice(0)->getBitDepth(CHANNEL_TYPE_LUMA);
     2548    const Int refBitDepthChroma = (*(pcTDecTopBase->getListPic()->begin()))->getSlice(0)->getBitDepth(CHANNEL_TYPE_CHROMA);
     2549   
     2550    Bool sameBitDepths = ( bitDepthLuma == refBitDepthLuma ) && ( bitDepthChroma == refBitDepthChroma );
    25652551
    25662552    if( pcPicYuvRecBase->getWidth(COMPONENT_Y) == vps.getPicWidthInLumaSamples(&sps, m_layerId) && pcPicYuvRecBase->getHeight(COMPONENT_Y) == vps.getPicHeightInLumaSamples(&sps, m_layerId) && equalOffsets && zeroPhase )
  • branches/SHM-dev/source/Lib/TLibEncoder/SEIEncoder.cpp

    r1273 r1287  
    304304
    305305//! calculate hashes for entire reconstructed picture
    306 Void SEIEncoder::initDecodedPictureHashSEI(SEIDecodedPictureHash *decodedPictureHashSEI, TComPic *pcPic, std::string &rHashString)
     306Void SEIEncoder::initDecodedPictureHashSEI(SEIDecodedPictureHash *decodedPictureHashSEI, TComPic *pcPic, std::string &rHashString, const BitDepths &bitDepths)
    307307{
    308308  assert (m_isInitialized);
     
    313313  {
    314314    decodedPictureHashSEI->method = SEIDecodedPictureHash::MD5;
    315     UInt numChar=calcMD5(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash);
     315    UInt numChar=calcMD5(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths);
    316316    rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar);
    317317  }
     
    319319  {
    320320    decodedPictureHashSEI->method = SEIDecodedPictureHash::CRC;
    321     UInt numChar=calcCRC(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash);
     321    UInt numChar=calcCRC(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths);
    322322    rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar);
    323323  }
     
    325325  {
    326326    decodedPictureHashSEI->method = SEIDecodedPictureHash::CHECKSUM;
    327     UInt numChar=calcChecksum(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash);
     327    UInt numChar=calcChecksum(*pcPic->getPicYuvRec(), decodedPictureHashSEI->m_pictureHash, bitDepths);
    328328    rHashString = hashToString(decodedPictureHashSEI->m_pictureHash, numChar);
    329329  }
  • branches/SHM-dev/source/Lib/TLibEncoder/SEIEncoder.h

    r1273 r1287  
    102102
    103103  // trailing SEIs
    104   Void initDecodedPictureHashSEI(SEIDecodedPictureHash *sei, TComPic *pcPic, std::string &rHashString);
     104  Void initDecodedPictureHashSEI(SEIDecodedPictureHash *sei, TComPic *pcPic, std::string &rHashString, const BitDepths &bitDepths);
    105105  Void initTemporalLevel0IndexSEI(SEITemporalLevel0Index *sei, TComSlice *slice);
    106106
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncAnalyze.h

    r1259 r1287  
    101101
    102102
    103   Void calculateCombinedValues(const ChromaFormat chFmt, Double &PSNRyuv, Double &MSEyuv)
     103  Void calculateCombinedValues(const ChromaFormat chFmt, Double &PSNRyuv, Double &MSEyuv, const BitDepths &bitDepths)
    104104  {
    105105    MSEyuv    = 0;
    106106    Int scale = 0;
    107107
    108     Int maximumBitDepth = g_bitDepth[0];
     108    Int maximumBitDepth = bitDepths.recon[CHANNEL_TYPE_LUMA];
    109109    for (UInt channelTypeIndex = 1; channelTypeIndex < MAX_NUM_CHANNEL_TYPE; channelTypeIndex++)
    110110    {
    111       if (g_bitDepth[channelTypeIndex] > maximumBitDepth)
     111      if (bitDepths.recon[channelTypeIndex] > maximumBitDepth)
    112112      {
    113         maximumBitDepth = g_bitDepth[channelTypeIndex];
     113        maximumBitDepth = bitDepths.recon[channelTypeIndex];
    114114      }
    115115    }
     
    124124      const UInt        csy           = getComponentScaleY(compID, chFmt);
    125125      const Int         scaleChan     = (4>>(csx+csy));
    126       const UInt        bitDepthShift = 2 * (maximumBitDepth - g_bitDepth[toChannelType(compID)]); //*2 because this is a squared number
     126      const UInt        bitDepthShift = 2 * (maximumBitDepth - bitDepths.recon[toChannelType(compID)]); //*2 because this is a squared number
    127127
    128128      const Double      channelMSE    = (m_MSEyuvframe[compID] * Double(1 << bitDepthShift)) / Double(getNumPic());
     
    137137
    138138#if SVC_EXTENSION
    139   Void    printOut ( Char cDelim, const ChromaFormat chFmt, const Bool printMSEBasedSNR, const Bool printSequenceMSE, UInt layer )
    140 #else
    141   Void    printOut ( Char cDelim, const ChromaFormat chFmt, const Bool printMSEBasedSNR, const Bool printSequenceMSE )
     139  Void    printOut ( Char cDelim, const ChromaFormat chFmt, const Bool printMSEBasedSNR, const Bool printSequenceMSE, const BitDepths &bitDepths, UInt layer )
     140#else
     141  Void    printOut ( Char cDelim, const ChromaFormat chFmt, const Bool printMSEBasedSNR, const Bool printSequenceMSE, const BitDepths &bitDepths )
    142142#endif
    143143  {
     
    159159        {
    160160          //NOTE: this is not the true maximum value for any bitDepth other than 8. It comes from the original HM PSNR calculation
    161           const UInt maxval = 255 << (g_bitDepth[toChannelType(compID)] - 8);
     161          const UInt maxval = 255 << (bitDepths.recon[toChannelType(compID)] - 8);
    162162          const Double MSE = m_MSEyuvframe[compID];
    163163
     
    261261          Double MSEyuv  = MAX_DOUBLE;
    262262         
    263           calculateCombinedValues(chFmt, PSNRyuv, MSEyuv);
     263          calculateCombinedValues(chFmt, PSNRyuv, MSEyuv, bitDepths);
    264264
    265265          if (printMSEBasedSNR)
     
    376376
    377377
    378   Void    printSummary(const ChromaFormat chFmt, const Bool printSequenceMSE, Char ch='T')
     378  Void    printSummary(const ChromaFormat chFmt, const Bool printSequenceMSE, const BitDepths &bitDepths, Char ch='T')
    379379  {
    380380    FILE* pFile = NULL;
     
    416416          Double MSEyuv  = MAX_DOUBLE;
    417417         
    418           calculateCombinedValues(chFmt, PSNRyuv, MSEyuv);
     418          calculateCombinedValues(chFmt, PSNRyuv, MSEyuv, bitDepths);
    419419
    420420          fprintf(pFile, "%f\t %f\t %f\t %f\t %f",
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp

    r1275 r1287  
    16241624
    16251625#if SVC_EXTENSION
    1626   Int qpBdOffsetY =  pcCU->getSlice()->getQpBDOffsetY();
     1626  Int qpBdOffsetY =  pcCU->getSlice()->getQpBDOffset(CHANNEL_TYPE_LUMA);
    16271627#else
    16281628  Int qpBdOffsetY =  pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA);
     
    17241724              WRITE_SVLC( iDeltaWeight, iNumRef==0?"delta_chroma_weight_l0[i]":"delta_chroma_weight_l1[i]" );
    17251725
    1726               Int range=pcSlice->getSPS()->getUseHighPrecisionPredictionWeighting() ? (1<<g_bitDepth[CHANNEL_TYPE_CHROMA])/2 : 128;
     1726#if SVC_EXTENSION
     1727              Int range=pcSlice->getSPS()->getUseHighPrecisionPredictionWeighting() ? (1<<pcSlice->getBitDepth(CHANNEL_TYPE_CHROMA))/2 : 128;
     1728#else
     1729              Int range=pcSlice->getSPS()->getUseHighPrecisionPredictionWeighting() ? (1<<pcSlice->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA))/2 : 128;
     1730#endif
    17271731              Int pred = ( range - ( ( range*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) );
    17281732              Int iDeltaChroma = (wp[j].iOffset - pred);
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.h

    r1259 r1287  
    104104
    105105  Void codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList );
    106 #if SVC_EXTENSION
    107   Void codeSAOBlkParam(SAOBlkParam& saoBlkParam, UInt* saoMaxOffsetQVal, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false){printf("only supported in CABAC"); assert(0); exit(-1);}
    108 #else
    109   Void codeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false){printf("only supported in CABAC"); assert(0); exit(-1);}
    110 #endif
     106  Void codeSAOBlkParam(SAOBlkParam& saoBlkParam, const BitDepths &bitDepths, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false){printf("only supported in CABAC"); assert(0); exit(-1);}
    111107  Void codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx );
    112108  Void codeSkipFlag      ( TComDataCU* pcCU, UInt uiAbsPartIdx );
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h

    r1284 r1287  
    186186
    187187  //====== Tool list ========
     188  Int       m_bitDepth[MAX_NUM_CHANNEL_TYPE];
    188189  Bool      m_bUseASR;
    189190  Bool      m_bUseHADME;
     
    602603
    603604  //==== Tool list ========
     605  Void      setBitDepth( const ChannelType chType, Int internalBitDepthForChannel ) { m_bitDepth[chType] = internalBitDepthForChannel; }
    604606  Void      setUseASR                       ( Bool  b )     { m_bUseASR     = b; }
    605607  Void      setUseHADME                     ( Bool  b )     { m_bUseHADME   = b; }
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncCu.cpp

    r1260 r1287  
    400400    Int idQP = m_pcEncCfg->getMaxDeltaQP();
    401401#if SVC_EXTENSION
    402     iMinQP = Clip3( -rpcTempCU->getSlice()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP );
    403     iMaxQP = Clip3( -rpcTempCU->getSlice()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP );
     402    iMinQP = Clip3( -rpcTempCU->getSlice()->getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, iBaseQP-idQP );
     403    iMaxQP = Clip3( -rpcTempCU->getSlice()->getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, iBaseQP+idQP );
    404404#else
    405405    iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, iBaseQP-idQP );
     
    735735          && rpcTempCU->getWidth(0) >= (1<<pcPic->getSlice(0)->getSPS()->getPCMLog2MinSize()) )
    736736        {
    737           UInt uiRawBits = getTotalBits(rpcBestCU->getWidth(0), rpcBestCU->getHeight(0), rpcBestCU->getPic()->getChromaFormat(), g_bitDepth);
     737#if SVC_EXTENSION
     738          UInt uiRawBits = getTotalBits(rpcBestCU->getWidth(0), rpcBestCU->getHeight(0), rpcBestCU->getPic()->getChromaFormat(), pcPic->getSlice(0)->getBitDepths().recon);
     739#else
     740          UInt uiRawBits = getTotalBits(rpcBestCU->getWidth(0), rpcBestCU->getHeight(0), rpcBestCU->getPic()->getChromaFormat(), pcPic->getSlice(0)->getSPS()->getBitDepths().recon);
     741#endif
    738742          UInt uiBestBits = rpcBestCU->getTotalBits();
    739743          if((uiBestBits > uiRawBits) || (rpcBestCU->getTotalCost() > m_pcRdCost->calcRdCost(uiRawBits, 0)))
     
    799803    Int idQP = m_pcEncCfg->getMaxDeltaQP();
    800804#if SVC_EXTENSION
    801     iMinQP = Clip3( -rpcTempCU->getSlice()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP );
    802     iMaxQP = Clip3( -rpcTempCU->getSlice()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP );
     805    iMinQP = Clip3( -rpcTempCU->getSlice()->getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, iBaseQP-idQP );
     806    iMaxQP = Clip3( -rpcTempCU->getSlice()->getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, iBaseQP+idQP );
    803807#else
    804808    iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, iBaseQP-idQP );
     
    10271031  }
    10281032#if SVC_EXTENSION
    1029   return Clip3(-pcCU->getSlice()->getQpBDOffsetY(), MAX_QP, iBaseQp+iQpOffset );
     1033  return Clip3(-pcCU->getSlice()->getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, iBaseQp+iQpOffset );
    10301034#else
    10311035  return Clip3(-pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, iBaseQp+iQpOffset );
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncEntropy.h

    r1259 r1287  
    114114  virtual Void codeCoeffNxN      ( TComTU &rTu, TCoeff* pcCoef, const ComponentID compID ) = 0;
    115115  virtual Void codeTransformSkipFlags ( TComTU &rTu, ComponentID component ) = 0;
     116  virtual Void codeSAOBlkParam   (SAOBlkParam& saoBlkParam, const BitDepths &bitDepths, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false)    =0;
     117  virtual Void estBit               (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType) = 0;
     118
     119  virtual Void codeDFFlag (UInt uiCode, const Char *pSymbolName) = 0;
     120  virtual Void codeDFSvlc (Int iCode, const Char *pSymbolName)   = 0;
     121
     122  virtual Void codeExplicitRdpcmMode ( TComTU &rTu, const ComponentID compID ) = 0;
     123
     124  virtual ~TEncEntropyIf() {}
     125
    116126#if SVC_EXTENSION
    117127  virtual Void codeSliceHeaderExtn( TComSlice* pSlice, Int shBitsWrittenTillNow )     = 0;
    118   virtual Void codeSAOBlkParam   (SAOBlkParam& saoBlkParam, UInt* saoMaxOffsetQVal, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false)    =0;
    119 #else
    120   virtual Void codeSAOBlkParam   (SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false)    =0;
    121 #endif
    122   virtual Void estBit               (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType) = 0;
    123 
    124   virtual Void codeDFFlag (UInt uiCode, const Char *pSymbolName) = 0;
    125   virtual Void codeDFSvlc (Int iCode, const Char *pSymbolName)   = 0;
    126 
    127   virtual Void codeExplicitRdpcmMode ( TComTU &rTu, const ComponentID compID ) = 0;
    128 
    129   virtual ~TEncEntropyIf() {}
     128#endif
    130129};
    131130
     
    194193
    195194  Void estimateBit             ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType );
     195
     196  Void encodeSAOBlkParam(SAOBlkParam& saoBlkParam, const BitDepths &bitDepths, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail){m_pcEntropyCoderIf->codeSAOBlkParam(saoBlkParam, bitDepths, sliceEnabled, leftMergeAvail, aboveMergeAvail, false);}
     197
     198  static Int countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize );
     199
    196200#if SVC_EXTENSION
    197201  Void encodeSliceHeaderExtn( TComSlice* pSlice, Int shBitsWrittenTillNow );
    198   Void encodeSAOBlkParam(SAOBlkParam& saoBlkParam, UInt* saoMaxOffsetQVal, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail){m_pcEntropyCoderIf->codeSAOBlkParam(saoBlkParam, saoMaxOffsetQVal, sliceEnabled, leftMergeAvail, aboveMergeAvail, false);}
    199 #else
    200   Void encodeSAOBlkParam(SAOBlkParam& saoBlkParam, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail){m_pcEntropyCoderIf->codeSAOBlkParam(saoBlkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail, false);}
    201 #endif
    202   static Int countNonZeroCoeffs( TCoeff* pcCoef, UInt uiSize );
    203 
     202#endif
    204203};// END CLASS DEFINITION TEncEntropy
    205204
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r1286 r1287  
    198198    {
    199199      prevLayerIdx = pcTEncTop->getPredLayerIdx( pcTEncTop->getNumActiveRefLayers() - 1);
    200       prevLayerId  = pcTEncTop->getRefLayerId(prevLayerIdx);
    201     }
    202     m_Enc3DAsymLUTPicUpdate.create( m_pcCfg->getCGSMaxOctantDepth() , g_bitDepthLayer[CHANNEL_TYPE_LUMA][prevLayerId] , g_bitDepthLayer[CHANNEL_TYPE_CHROMA][prevLayerId] , g_bitDepthLayer[CHANNEL_TYPE_LUMA][pcTEncTop->getLayerId()] , g_bitDepthLayer[CHANNEL_TYPE_CHROMA][pcTEncTop->getLayerId()] , m_pcCfg->getCGSMaxYPartNumLog2() /*, m_pcCfg->getCGSPhaseAlignment()*/ );
    203     m_Enc3DAsymLUTPPS.create(   m_pcCfg->getCGSMaxOctantDepth() , g_bitDepthLayer[CHANNEL_TYPE_LUMA][prevLayerId] , g_bitDepthLayer[CHANNEL_TYPE_CHROMA][prevLayerId] , g_bitDepthLayer[CHANNEL_TYPE_LUMA][pcTEncTop->getLayerId()] , g_bitDepthLayer[CHANNEL_TYPE_CHROMA][pcTEncTop->getLayerId()] , m_pcCfg->getCGSMaxYPartNumLog2() /*, m_pcCfg->getCGSPhaseAlignment()*/ );
     200      prevLayerId  = pcTEncTop->getRefLayerId(prevLayerIdx);     
     201    }
     202
     203    const TComVPS *vps = pcTEncTop->getVPS();
     204
     205    const Int bitDepthLuma = vps->getBitDepth(CHANNEL_TYPE_LUMA, pcTEncTop->getSPS(), pcTEncTop->getLayerId());
     206    const Int bitDepthChroma = vps->getBitDepth(CHANNEL_TYPE_CHROMA, pcTEncTop->getSPS(), pcTEncTop->getLayerId());
     207    const Int prevBitDepthLuma = vps->getBitDepth(CHANNEL_TYPE_LUMA, m_ppcTEncTop[prevLayerIdx]->getSPS(), prevLayerId);
     208    const Int prevBitDepthChroma = vps->getBitDepth(CHANNEL_TYPE_CHROMA, m_ppcTEncTop[prevLayerIdx]->getSPS(), prevLayerId);
     209
     210    m_Enc3DAsymLUTPicUpdate.create( m_pcCfg->getCGSMaxOctantDepth() , prevBitDepthLuma, prevBitDepthChroma, bitDepthLuma, bitDepthChroma , m_pcCfg->getCGSMaxYPartNumLog2() );
     211    m_Enc3DAsymLUTPPS.create( m_pcCfg->getCGSMaxOctantDepth(), prevBitDepthLuma, prevBitDepthChroma, bitDepthLuma, prevBitDepthChroma , m_pcCfg->getCGSMaxYPartNumLog2() );
    204212    if(!m_pColorMappedPic)
    205213    {
     
    14831491#if SVC_EXTENSION
    14841492    pcPic->setLayerId( m_layerId );
     1493#endif
    14851494    m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, isField );
    1486 #else
    1487     m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, &(pcPic->getPicSym()->getSPS()), &(pcPic->getPicSym()->getPPS()), isField );
    1488 #endif
    14891495
    14901496    //Set Frame/Field coding
     
    16781684          {
    16791685            //downsampling
    1680             downScalePic(pcPic->getPicYuvOrg(), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvOrg());
     1686            downScalePic(pcPic->getPicYuvOrg(), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvOrg(), pcSlice->getBitDepths());
    16811687           
    16821688            m_Enc3DAsymLUTPPS.setDsOrigPic(pcSlice->getBaseColPic(refLayerIdc)->getPicYuvOrg());
     
    17091715          if( pcSlice->getVPS()->isSamplePredictionType( pcSlice->getVPS()->getLayerIdxInVps(m_layerId), pcSlice->getVPS()->getLayerIdxInVps(refLayerId) ) )
    17101716          {
    1711             m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec() );
     1717            m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getBaseColPic(refLayerIdc)->getSlice(0 )->getBitDepth(CHANNEL_TYPE_LUMA), pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getBitDepth(CHANNEL_TYPE_CHROMA) );
    17121718          }
    17131719        }
     
    23642370
    23652371#if SVC_EXTENSION
    2366       sliceQP = Clip3( -pcSlice->getQpBDOffsetY(), MAX_QP, sliceQP );
     2372      sliceQP = Clip3( -pcSlice->getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, sliceQP );
    23672373#else
    23682374      sliceQP = Clip3( -pcSlice->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, sliceQP );
     
    26682674    // cabac_zero_words processing
    26692675    {
     2676#if !SVC_EXTENSION
     2677      const TComSPS &sps=*(pcSlice->getSPS());
     2678#endif
    26702679      const Int log2subWidthCxsubHeightC = (pcPic->getComponentScaleX(COMPONENT_Cb)+pcPic->getComponentScaleY(COMPONENT_Cb));
    26712680      const Int minCuWidth  = pcPic->getMinCUWidth();
     
    26742683      const Int paddedWidth = ((pcSlice->getPicWidthInLumaSamples()  + minCuWidth  - 1) / minCuWidth) * minCuWidth;
    26752684      const Int paddedHeight= ((pcSlice->getPicHeightInLumaSamples() + minCuHeight - 1) / minCuHeight) * minCuHeight;
     2685      const Int rawBits = paddedWidth * paddedHeight *
     2686                             (pcSlice->getBitDepth(CHANNEL_TYPE_LUMA) + 2*(pcSlice->getBitDepth(CHANNEL_TYPE_CHROMA)>>log2subWidthCxsubHeightC));
    26762687#else
    26772688      const Int paddedWidth = ((pcSlice->getSPS()->getPicWidthInLumaSamples()  + minCuWidth  - 1) / minCuWidth) * minCuWidth;
    26782689      const Int paddedHeight= ((pcSlice->getSPS()->getPicHeightInLumaSamples() + minCuHeight - 1) / minCuHeight) * minCuHeight;
    2679 #endif
    26802690      const Int rawBits = paddedWidth * paddedHeight *
    2681                              (g_bitDepth[CHANNEL_TYPE_LUMA] + 2*(g_bitDepth[CHANNEL_TYPE_CHROMA]>>log2subWidthCxsubHeightC));
     2691                             (sps.getBitDepth(CHANNEL_TYPE_LUMA) + 2*(sps.getBitDepth(CHANNEL_TYPE_CHROMA)>>log2subWidthCxsubHeightC));
     2692#endif
    26822693      const std::size_t threshold = (32/3)*numBytesInVclNalUnits + (rawBits/32);
    26832694      if (binCountsInNalUnits >= threshold)
     
    27182729    {
    27192730      SEIDecodedPictureHash *decodedPictureHashSei = new SEIDecodedPictureHash();
    2720       m_seiEncoder.initDecodedPictureHashSEI(decodedPictureHashSei, pcPic, digestStr);
     2731#if SVC_EXTENSION
     2732      m_seiEncoder.initDecodedPictureHashSEI(decodedPictureHashSei, pcPic, digestStr, pcSlice->getBitDepths());
     2733#else
     2734      m_seiEncoder.initDecodedPictureHashSEI(decodedPictureHashSei, pcPic, digestStr, pcSlice->getSPS()->getBitDepths());
     2735#endif
    27212736      trailingSeiMessages.push_back(decodedPictureHashSei);
    27222737    }
     
    29332948
    29342949#if !SVC_EXTENSION
    2935 Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded, Bool isField, const Bool printMSEBasedSNR, const Bool printSequenceMSE)
     2950Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded, Bool isField, const Bool printMSEBasedSNR, const Bool printSequenceMSE, const BitDepths &bitDepths)
    29362951{
    29372952  assert (uiNumAllPicCoded == m_gcAnalyzeAll.getNumPic());
     
    29482963  //-- all
    29492964  printf( "\n\nSUMMARY --------------------------------------------------------\n" );
    2950   m_gcAnalyzeAll.printOut('a', chFmt, printMSEBasedSNR, printSequenceMSE);
     2965  m_gcAnalyzeAll.printOut('a', chFmt, printMSEBasedSNR, printSequenceMSE, bitDepths);
    29512966
    29522967  printf( "\n\nI Slices--------------------------------------------------------\n" );
    2953   m_gcAnalyzeI.printOut('i', chFmt, printMSEBasedSNR, printSequenceMSE);
     2968  m_gcAnalyzeI.printOut('i', chFmt, printMSEBasedSNR, printSequenceMSE, bitDepths);
    29542969
    29552970  printf( "\n\nP Slices--------------------------------------------------------\n" );
    2956   m_gcAnalyzeP.printOut('p', chFmt, printMSEBasedSNR, printSequenceMSE);
     2971  m_gcAnalyzeP.printOut('p', chFmt, printMSEBasedSNR, printSequenceMSE, bitDepths);
    29572972
    29582973  printf( "\n\nB Slices--------------------------------------------------------\n" );
    2959   m_gcAnalyzeB.printOut('b', chFmt, printMSEBasedSNR, printSequenceMSE);
     2974  m_gcAnalyzeB.printOut('b', chFmt, printMSEBasedSNR, printSequenceMSE, bitDepths);
    29602975
    29612976#if _SUMMARY_OUT_
     
    29762991
    29772992    printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" );
    2978     m_gcAnalyzeAll_in.printOut('a', chFmt, printMSEBasedSNR, printSequenceMSE);
     2993    m_gcAnalyzeAll_in.printOut('a', chFmt, printMSEBasedSNR, printSequenceMSE, bitDepths);
    29792994
    29802995#if _SUMMARY_OUT_
     
    29953010  if (!bCalcDist)
    29963011  {
    2997     ruiDist = xFindDistortionFrame(pcPic->getPicYuvOrg(), pcPic->getPicYuvRec());
     3012#if SVC_EXTENSION
     3013    ruiDist = xFindDistortionFrame(pcPic->getPicYuvOrg(), pcPic->getPicYuvRec(), pcPic->getSlice(0)->getBitDepths());
     3014#else
     3015    ruiDist = xFindDistortionFrame(pcPic->getPicYuvOrg(), pcPic->getPicYuvRec(), pcPic->getPicSym()->getSPS().getBitDepths());
     3016#endif
    29983017  }
    29993018}
     
    30663085}
    30673086
    3068 UInt64 TEncGOP::xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1)
     3087UInt64 TEncGOP::xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1, const BitDepths &bitDepths)
    30693088{
    30703089  UInt64  uiTotalDiff = 0;
     
    30753094    Pel*  pSrc0   = pcPic0 ->getAddr(ch);
    30763095    Pel*  pSrc1   = pcPic1 ->getAddr(ch);
    3077     UInt  uiShift     = 2 * DISTORTION_PRECISION_ADJUSTMENT(g_bitDepth[toChannelType(ch)]-8);
     3096    UInt  uiShift     = 2 * DISTORTION_PRECISION_ADJUSTMENT(bitDepths.recon[toChannelType(ch)]-8);
    30783097
    30793098    const Int   iStride = pcPic0->getStride(ch);
     
    31443163  {
    31453164    cscd.create(pcPicD->getWidth(COMPONENT_Y), pcPicD->getHeight(COMPONENT_Y), pcPicD->getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);
    3146     TVideoIOYuv::ColourSpaceConvert(*pcPicD, cscd, conversion, g_bitDepth, false);
     3165#if SVC_EXTENSION
     3166    TVideoIOYuv::ColourSpaceConvert(*pcPicD, cscd, conversion, pcPic->getSlice(0)->getBitDepths().recon, false);
     3167#else
     3168    TVideoIOYuv::ColourSpaceConvert(*pcPicD, cscd, conversion, pcPic->getPicSym()->getSPS().getBitDepths().recon, false);
     3169#endif
    31473170  }
    31483171  TComPicYuv &picd=(conversion==IPCOLOURSPACE_UNCHANGED)?*pcPicD : cscd;
     
    31743197      pRec += iStride;
    31753198    }
    3176     const Int maxval = 255 << (g_bitDepth[toChannelType(ch)] - 8);
     3199#if SVC_EXTENSION
     3200    const Int maxval = 255 << (pcPic->getSlice(0)->getBitDepth(toChannelType(ch)) - 8);
     3201#else
     3202    const Int maxval = 255 << (pcPic->getPicSym()->getSPS().getBitDepth(toChannelType(ch)) - 8);
     3203#endif
    31773204    const Double fRefValue = (Double) maxval * maxval * iSize;
    31783205    dPSNR[ch]         = ( uiSSDtemp ? 10.0 * log10( fRefValue / (Double)uiSSDtemp ) : 999.99 );
     
    33403367                                           const AccessUnit& accessUnit, Double dEncTime, const InputColourSpaceConversion conversion, const Bool printFrameMSE )
    33413368{
     3369#if !SVC_EXTENSION
     3370  const TComSPS &sps=pcPicOrgFirstField->getPicSym()->getSPS();
     3371#endif
    33423372  Double  dPSNR[MAX_NUM_COMPONENT];
    33433373  TComPic    *apcPicOrgFields[2]={pcPicOrgFirstField, pcPicOrgSecondField};
     
    33563386      TComPicYuv &reconField=*(apcPicRecFields[fieldNum]);
    33573387      cscd[fieldNum].create(reconField.getWidth(COMPONENT_Y), reconField.getHeight(COMPONENT_Y), reconField.getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth);
    3358       TVideoIOYuv::ColourSpaceConvert(reconField, cscd[fieldNum], conversion, g_bitDepth, false);
     3388#if SVC_EXTENSION
     3389      TVideoIOYuv::ColourSpaceConvert(reconField, cscd[fieldNum], conversion, pcPicOrgFirstField->getSlice(0)->getBitDepths().recon, false);
     3390#else
     3391      TVideoIOYuv::ColourSpaceConvert(reconField, cscd[fieldNum], conversion, sps.getBitDepths().recon, false);
     3392#endif
    33593393      apcPicRecFields[fieldNum]=cscd+fieldNum;
    33603394    }
     
    34003434      }
    34013435    }
    3402     const Int maxval = 255 << (g_bitDepth[toChannelType(ch)] - 8);
     3436#if SVC_EXTENSION
     3437    const Int maxval = 255 << (pcPicOrgFirstField->getSlice(0)->getBitDepth(toChannelType(ch)) - 8);
     3438#else
     3439    const Int maxval = 255 << (sps.getBitDepth(toChannelType(ch)) - 8);
     3440#endif
    34033441    const Double fRefValue = (Double) maxval * maxval * iSize*2;
    34043442    dPSNR[ch]         = ( uiSSDtemp ? 10.0 * log10( fRefValue / (Double)uiSSDtemp ) : 999.99 );
     
    36843722
    36853723  Int qp = pcPic->getSlice(0)->getSliceQp();
    3686   Int bitdepthScale = 1 << (g_bitDepth[CHANNEL_TYPE_LUMA]-8);
     3724#if SVC_EXTENSION
     3725  const Int bitDepthLuma=pcPic->getSlice(0)->getBitDepth(CHANNEL_TYPE_LUMA);
     3726#else
     3727  const Int bitDepthLuma=pcPic->getSlice(0)->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA);
     3728#endif
     3729  Int bitdepthScale = 1 << (bitDepthLuma-8);
    36873730  Int beta = TComLoopFilter::getBeta( qp ) * bitdepthScale;
    36883731  const Int thr2 = (beta>>2);
     
    37573800
    37583801  UInt64 avgSAD = ((colSADsum + rowSADsum)>>1);
    3759   avgSAD >>= (g_bitDepth[CHANNEL_TYPE_LUMA]-8);
     3802  avgSAD >>= (bitDepthLuma-8);
    37603803
    37613804  if ( avgSAD > 2048 )
     
    41684211}
    41694212
    4170 Void TEncGOP::downScalePic( TComPicYuv* pcYuvSrc, TComPicYuv* pcYuvDest)
    4171 {
    4172   Int inputBitDepth  = g_bitDepthLayer[CHANNEL_TYPE_LUMA][m_layerId];
    4173   Int outputBitDepth = g_bitDepthLayer[CHANNEL_TYPE_CHROMA][m_layerId];
    4174   {
    4175     pcYuvSrc->setBorderExtension(false);
    4176     pcYuvSrc->extendPicBorder   (); // extend the border.
    4177     pcYuvSrc->setBorderExtension(false);
    4178 
    4179     Int iWidth  = pcYuvSrc->getWidth(COMPONENT_Y);
    4180     Int iHeight = pcYuvSrc->getHeight(COMPONENT_Y);
    4181 
    4182     if(!m_temp)
    4183     {
    4184       initDs(iWidth, iHeight, m_pcCfg->getIntraPeriod()>1);
    4185     }
    4186 
    4187     filterImg(pcYuvSrc->getAddr(COMPONENT_Y),  pcYuvSrc->getStride(COMPONENT_Y),  pcYuvDest->getAddr(COMPONENT_Y),  pcYuvDest->getStride(COMPONENT_Y),  iHeight,    iWidth,    inputBitDepth-outputBitDepth, 0);
    4188     filterImg(pcYuvSrc->getAddr(COMPONENT_Cb), pcYuvSrc->getStride(COMPONENT_Cb), pcYuvDest->getAddr(COMPONENT_Cb), pcYuvDest->getStride(COMPONENT_Cb), iHeight>>1, iWidth>>1, inputBitDepth-outputBitDepth, 1);
    4189     filterImg(pcYuvSrc->getAddr(COMPONENT_Cr), pcYuvSrc->getStride(COMPONENT_Cr), pcYuvDest->getAddr(COMPONENT_Cr), pcYuvDest->getStride(COMPONENT_Cr), iHeight>>1, iWidth>>1, inputBitDepth-outputBitDepth, 2); 
    4190   }
     4213Void TEncGOP::downScalePic( TComPicYuv* pcYuvSrc, TComPicYuv* pcYuvDest, BitDepths& bitDepth)
     4214{
     4215  pcYuvSrc->setBorderExtension(false);
     4216  pcYuvSrc->extendPicBorder   (); // extend the border.
     4217  pcYuvSrc->setBorderExtension(false);
     4218
     4219  Int iWidth  = pcYuvSrc->getWidth(COMPONENT_Y);
     4220  Int iHeight = pcYuvSrc->getHeight(COMPONENT_Y);
     4221
     4222  if(!m_temp)
     4223  {
     4224    initDs(iWidth, iHeight, m_pcCfg->getIntraPeriod()>1);
     4225  }
     4226
     4227  filterImg(pcYuvSrc->getAddr(COMPONENT_Y),  pcYuvSrc->getStride(COMPONENT_Y),  pcYuvDest->getAddr(COMPONENT_Y),  pcYuvDest->getStride(COMPONENT_Y),  iHeight,    iWidth,    bitDepth, 0);
     4228  filterImg(pcYuvSrc->getAddr(COMPONENT_Cb), pcYuvSrc->getStride(COMPONENT_Cb), pcYuvDest->getAddr(COMPONENT_Cb), pcYuvDest->getStride(COMPONENT_Cb), iHeight>>1, iWidth>>1, bitDepth, 1);
     4229  filterImg(pcYuvSrc->getAddr(COMPONENT_Cr), pcYuvSrc->getStride(COMPONENT_Cr), pcYuvDest->getAddr(COMPONENT_Cr), pcYuvDest->getStride(COMPONENT_Cr), iHeight>>1, iWidth>>1, bitDepth, 2); 
    41914230}
    41924231const Int TEncGOP::m_phase_filter_0_t0[4][13]={
     
    42294268#endif
    42304269#endif
    4231 Void TEncGOP::filterImg(
    4232     Pel           *src,
    4233     Int           iSrcStride,
    4234     Pel           *dst,
    4235     Int           iDstStride,
    4236     Int           height1, 
    4237     Int           width1, 
    4238     Int           shift,
    4239     Int           plane)
     4270Void TEncGOP::filterImg( Pel *src, Int iSrcStride, Pel *dst, Int iDstStride, Int height1, Int width1, BitDepths& bitDepth, Int plane )
    42404271{
    42414272  Int length = m_iTap;
     
    42484279  Pel *p_src_line, *p_dst_line;
    42494280  Int **p_temp, *p_tmp;
     4281  Int shift = bitDepth.recon[CHANNEL_TYPE_LUMA] - bitDepth.recon[CHANNEL_TYPE_CHROMA];
    42504282  Int shift2 = 2*7+shift;
    42514283  Int shift_round = (1 << (shift2 - 1));
    4252   Int iMax = (1<<(g_bitDepth[CHANNEL_TYPE_LUMA]-shift))-1;
     4284  Int iMax = (1<<(bitDepth.recon[CHANNEL_TYPE_LUMA]-shift))-1;
    42534285  height2 = (height1 * m_iM) / m_iN;
    42544286  width2  = (width1  * m_iM) / m_iN;
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.h

    r1277 r1287  
    224224                                     const AccessUnit& accessUnit, Double dEncTime, const InputColourSpaceConversion snr_conversion, const Bool printFrameMSE );
    225225
    226   UInt64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1);
     226  UInt64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1, const BitDepths &bitDepths);
    227227
    228228  Double xCalculateRVM();
     
    288288#if CGS_3D_ASYMLUT
    289289  Void xDetermin3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS );
    290   Void downScalePic( TComPicYuv* pcYuvSrc, TComPicYuv* pcYuvDest);
     290  Void downScalePic( TComPicYuv* pcYuvSrc, TComPicYuv* pcYuvDest, BitDepths& bitDepth);
    291291  Void downScaleComponent2x2( const Pel* pSrc, Pel* pDest, const Int iSrcStride, const Int iDestStride, const Int iSrcWidth, const Int iSrcHeight, const Int inputBitDepth, const Int outputBitDepth );
    292292  inline Short xClip( Short x , Int bitdepth );
    293293  Void initDs(Int iWidth, Int iHeight, Int iType);
    294   Void filterImg( Pel *src, Int iSrcStride, Pel *dst, Int iDstStride, Int height1, Int width1, Int shift, Int plane);
     294  Void filterImg( Pel *src, Int iSrcStride, Pel *dst, Int iDstStride, Int height1, Int width1, BitDepths& bitDepth, Int plane );
    295295
    296296  Int get_mem2DintWithPad(Int ***array2D, Int dim0, Int dim1, Int iPadY, Int iPadX);
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp

    r1260 r1287  
    349349      Pel* orgBlk     = orgYuv->getAddr(component) + ((yPos >> componentScaleY) * orgStride) + (xPos >> componentScaleX);
    350350
    351       getBlkStats(component, blkStats[ctuRsAddr][component]
     351#if SVC_EXTENSION
     352      getBlkStats(component, pPic->getSlice(0)->getBitDepth(toChannelType(component)), blkStats[ctuRsAddr][component]
     353#else
     354      getBlkStats(component, pPic->getPicSym()->getSPS().getBitDepth(toChannelType(component)), blkStats[ctuRsAddr][component]
     355#endif
    352356                , srcBlk, orgBlk, srcStride, orgStride, (width  >> componentScaleX), (height >> componentScaleY)
    353357                , isLeftAvail,  isRightAvail, isAboveAvail, isBelowAvail, isAboveLeftAvail, isAboveRightAvail, isBelowLeftAvail, isBelowRightAvail
     
    395399}
    396400
    397 Int64 TEncSampleAdaptiveOffset::getDistortion(ComponentID compIdx, Int typeIdc, Int typeAuxInfo, Int* invQuantOffset, SAOStatData& statData)
     401Int64 TEncSampleAdaptiveOffset::getDistortion(const Int channelBitDepth, Int typeIdc, Int typeAuxInfo, Int* invQuantOffset, SAOStatData& statData)
    398402{
    399403  Int64 dist        = 0;
    400   Int shift         = 2 * DISTORTION_PRECISION_ADJUSTMENT(g_bitDepth[toChannelType(compIdx)] - 8);
     404  Int shift         = 2 * DISTORTION_PRECISION_ADJUSTMENT(channelBitDepth - 8);
    401405
    402406  switch(typeIdc)
     
    472476}
    473477
    474 Void TEncSampleAdaptiveOffset::deriveOffsets(ComponentID compIdx, Int typeIdc, SAOStatData& statData, Int* quantOffsets, Int& typeAuxInfo)
    475 {
    476   Int bitDepth = g_bitDepth[toChannelType(compIdx)];
     478Void TEncSampleAdaptiveOffset::deriveOffsets(ComponentID compIdx, const Int channelBitDepth, Int typeIdc, SAOStatData& statData, Int* quantOffsets, Int& typeAuxInfo)
     479{
     480  Int bitDepth = channelBitDepth;
    477481  Int shift    = 2 * DISTORTION_PRECISION_ADJUSTMENT(bitDepth-8);
    478 #if SVC_EXTENSION
    479   Int offsetTh = getSaoMaxOffsetQVal()[compIdx];  //inclusive
    480 #else
    481   Int offsetTh = g_saoMaxOffsetQVal[compIdx];  //inclusive
    482 #endif
     482  Int offsetTh = TComSampleAdaptiveOffset::getMaxOffsetQVal(channelBitDepth);  //inclusive
    483483
    484484  ::memset(quantOffsets, 0, sizeof(Int)*MAX_NUM_SAO_CLASSES);
     
    595595}
    596596
    597 Void TEncSampleAdaptiveOffset::deriveModeNewRDO(Int ctuRsAddr, SAOBlkParam* mergeList[NUM_SAO_MERGE_TYPES], Bool* sliceEnabled, SAOStatData*** blkStats, SAOBlkParam& modeParam, Double& modeNormCost, TEncSbac** cabacCoderRDO, Int inCabacLabel)
     597Void TEncSampleAdaptiveOffset::deriveModeNewRDO(const BitDepths &bitDepths, Int ctuRsAddr, SAOBlkParam* mergeList[NUM_SAO_MERGE_TYPES], Bool* sliceEnabled, SAOStatData*** blkStats, SAOBlkParam& modeParam, Double& modeNormCost, TEncSbac** cabacCoderRDO, Int inCabacLabel)
    598598{
    599599  Double minCost, cost;
     
    612612  modeParam[COMPONENT_Y].modeIdc = SAO_MODE_OFF;
    613613  m_pcRDGoOnSbacCoder->load(cabacCoderRDO[inCabacLabel]);
    614 #if SVC_EXTENSION
    615   m_pcRDGoOnSbacCoder->codeSAOBlkParam(modeParam, getSaoMaxOffsetQVal(), sliceEnabled, (mergeList[SAO_MERGE_LEFT]!= NULL), (mergeList[SAO_MERGE_ABOVE]!= NULL), true);
    616 #else
    617   m_pcRDGoOnSbacCoder->codeSAOBlkParam(modeParam, sliceEnabled, (mergeList[SAO_MERGE_LEFT]!= NULL), (mergeList[SAO_MERGE_ABOVE]!= NULL), true);
    618 #endif
     614  m_pcRDGoOnSbacCoder->codeSAOBlkParam(modeParam, bitDepths, sliceEnabled, (mergeList[SAO_MERGE_LEFT]!= NULL), (mergeList[SAO_MERGE_ABOVE]!= NULL), true);
    619615  m_pcRDGoOnSbacCoder->store(cabacCoderRDO[SAO_CABACSTATE_BLK_MID]);
    620616
    621617    //------ luma --------//
    622618  {
    623     ComponentID compIdx = COMPONENT_Y;
     619    const ComponentID compIdx = COMPONENT_Y;
    624620    //"off" case as initial cost
    625621    modeParam[compIdx].modeIdc = SAO_MODE_OFF;
    626622    m_pcRDGoOnSbacCoder->resetBits();
    627 #if SVC_EXTENSION
    628     m_pcRDGoOnSbacCoder->codeSAOOffsetParam(compIdx, modeParam[compIdx], sliceEnabled[compIdx], getSaoMaxOffsetQVal());
    629 #else
    630     m_pcRDGoOnSbacCoder->codeSAOOffsetParam(compIdx, modeParam[compIdx], sliceEnabled[compIdx]);
    631 #endif
     623    m_pcRDGoOnSbacCoder->codeSAOOffsetParam(compIdx, modeParam[compIdx], sliceEnabled[compIdx], bitDepths.recon[CHANNEL_TYPE_LUMA]);
    632624    modeDist[compIdx] = 0;
    633625    minCost= m_lambda[compIdx]*((Double)m_pcRDGoOnSbacCoder->getNumberOfWrittenBits());
     
    641633
    642634        //derive coded offset
    643         deriveOffsets(compIdx, typeIdc, blkStats[ctuRsAddr][compIdx][typeIdc], testOffset[compIdx].offset, testOffset[compIdx].typeAuxInfo);
     635        deriveOffsets(compIdx, bitDepths.recon[CHANNEL_TYPE_LUMA], typeIdc, blkStats[ctuRsAddr][compIdx][typeIdc], testOffset[compIdx].offset, testOffset[compIdx].typeAuxInfo);
    644636
    645637        //inversed quantized offsets
     
    647639
    648640        //get distortion
    649         dist[compIdx] = getDistortion(compIdx, testOffset[compIdx].typeIdc, testOffset[compIdx].typeAuxInfo, invQuantOffset, blkStats[ctuRsAddr][compIdx][typeIdc]);
     641        dist[compIdx] = getDistortion(bitDepths.recon[CHANNEL_TYPE_LUMA], testOffset[compIdx].typeIdc, testOffset[compIdx].typeAuxInfo, invQuantOffset, blkStats[ctuRsAddr][compIdx][typeIdc]);
    650642
    651643        //get rate
    652644        m_pcRDGoOnSbacCoder->load(cabacCoderRDO[SAO_CABACSTATE_BLK_MID]);
    653645        m_pcRDGoOnSbacCoder->resetBits();
    654 #if SVC_EXTENSION
    655         m_pcRDGoOnSbacCoder->codeSAOOffsetParam(compIdx, testOffset[compIdx], sliceEnabled[compIdx], getSaoMaxOffsetQVal());
    656 #else
    657         m_pcRDGoOnSbacCoder->codeSAOOffsetParam(compIdx, testOffset[compIdx], sliceEnabled[compIdx]);
    658 #endif
     646        m_pcRDGoOnSbacCoder->codeSAOOffsetParam(compIdx, testOffset[compIdx], sliceEnabled[compIdx], bitDepths.recon[CHANNEL_TYPE_LUMA]);
    659647        Int rate = m_pcRDGoOnSbacCoder->getNumberOfWrittenBits();
    660648        cost = (Double)dist[compIdx] + m_lambda[compIdx]*((Double)rate);
     
    683671    modeParam[component].modeIdc = SAO_MODE_OFF;
    684672    modeDist [component]         = 0;
    685 
    686 #if SVC_EXTENSION
    687     m_pcRDGoOnSbacCoder->codeSAOOffsetParam(component, modeParam[component], sliceEnabled[component], getSaoMaxOffsetQVal());
    688 #else
    689     m_pcRDGoOnSbacCoder->codeSAOOffsetParam(component, modeParam[component], sliceEnabled[component]);
    690 #endif
    691 
     673    m_pcRDGoOnSbacCoder->codeSAOOffsetParam(component, modeParam[component], sliceEnabled[component], bitDepths.recon[CHANNEL_TYPE_CHROMA]);
     674   
    692675    const UInt currentWrittenBits = m_pcRDGoOnSbacCoder->getNumberOfWrittenBits();
    693676    cost += m_lambda[component] * (currentWrittenBits - previousWrittenBits);
     
    719702
    720703      //derive offset & get distortion
    721       deriveOffsets(component, typeIdc, blkStats[ctuRsAddr][component][typeIdc], testOffset[component].offset, testOffset[component].typeAuxInfo);
     704      deriveOffsets(component, bitDepths.recon[CHANNEL_TYPE_CHROMA], typeIdc, blkStats[ctuRsAddr][component][typeIdc], testOffset[component].offset, testOffset[component].typeAuxInfo);
    722705      invertQuantOffsets(component, typeIdc, testOffset[component].typeAuxInfo, invQuantOffset, testOffset[component].offset);
    723       dist[component] = getDistortion(component, typeIdc, testOffset[component].typeAuxInfo, invQuantOffset, blkStats[ctuRsAddr][component][typeIdc]);
    724 
    725 #if SVC_EXTENSION
    726       m_pcRDGoOnSbacCoder->codeSAOOffsetParam(component, testOffset[component], sliceEnabled[component], getSaoMaxOffsetQVal());
    727 #else
    728       m_pcRDGoOnSbacCoder->codeSAOOffsetParam(component, testOffset[component], sliceEnabled[component]);
    729 #endif
     706      dist[component] = getDistortion(bitDepths.recon[CHANNEL_TYPE_CHROMA], typeIdc, testOffset[component].typeAuxInfo, invQuantOffset, blkStats[ctuRsAddr][component][typeIdc]);
     707
     708      m_pcRDGoOnSbacCoder->codeSAOOffsetParam(component, testOffset[component], sliceEnabled[component], bitDepths.recon[CHANNEL_TYPE_CHROMA]);
    730709
    731710      const UInt currentWrittenBits = m_pcRDGoOnSbacCoder->getNumberOfWrittenBits();
     
    755734  m_pcRDGoOnSbacCoder->load(cabacCoderRDO[inCabacLabel]);
    756735  m_pcRDGoOnSbacCoder->resetBits();
    757 #if SVC_EXTENSION
    758   m_pcRDGoOnSbacCoder->codeSAOBlkParam(modeParam, getSaoMaxOffsetQVal(), sliceEnabled, (mergeList[SAO_MERGE_LEFT]!= NULL), (mergeList[SAO_MERGE_ABOVE]!= NULL), false);
    759 #else
    760   m_pcRDGoOnSbacCoder->codeSAOBlkParam(modeParam, sliceEnabled, (mergeList[SAO_MERGE_LEFT]!= NULL), (mergeList[SAO_MERGE_ABOVE]!= NULL), false);
    761 #endif
     736  m_pcRDGoOnSbacCoder->codeSAOBlkParam(modeParam, bitDepths, sliceEnabled, (mergeList[SAO_MERGE_LEFT]!= NULL), (mergeList[SAO_MERGE_ABOVE]!= NULL), false);
    762737  modeNormCost += (Double)m_pcRDGoOnSbacCoder->getNumberOfWrittenBits();
    763738}
    764739
    765 Void TEncSampleAdaptiveOffset::deriveModeMergeRDO(Int ctuRsAddr, SAOBlkParam* mergeList[NUM_SAO_MERGE_TYPES], Bool* sliceEnabled, SAOStatData*** blkStats, SAOBlkParam& modeParam, Double& modeNormCost, TEncSbac** cabacCoderRDO, Int inCabacLabel)
     740Void TEncSampleAdaptiveOffset::deriveModeMergeRDO(const BitDepths &bitDepths, Int ctuRsAddr, SAOBlkParam* mergeList[NUM_SAO_MERGE_TYPES], Bool* sliceEnabled, SAOStatData*** blkStats, SAOBlkParam& modeParam, Double& modeNormCost, TEncSbac** cabacCoderRDO, Int inCabacLabel)
    766741{
    767742  modeNormCost = MAX_DOUBLE;
     
    791766      {
    792767        //offsets have been reconstructed. Don't call inversed quantization function.
    793         normDist += (((Double)getDistortion(ComponentID(compIdx), mergedOffsetParam.typeIdc, mergedOffsetParam.typeAuxInfo, mergedOffsetParam.offset, blkStats[ctuRsAddr][compIdx][mergedOffsetParam.typeIdc]))
     768        normDist += (((Double)getDistortion(bitDepths.recon[toChannelType(ComponentID(compIdx))], mergedOffsetParam.typeIdc, mergedOffsetParam.typeAuxInfo, mergedOffsetParam.offset, blkStats[ctuRsAddr][compIdx][mergedOffsetParam.typeIdc]))
    794769                       /m_lambda[compIdx]
    795770                    );
     
    801776    m_pcRDGoOnSbacCoder->load(cabacCoderRDO[inCabacLabel]);
    802777    m_pcRDGoOnSbacCoder->resetBits();
    803 #if SVC_EXTENSION
    804     m_pcRDGoOnSbacCoder->codeSAOBlkParam(testBlkParam, getSaoMaxOffsetQVal(), sliceEnabled, (mergeList[SAO_MERGE_LEFT]!= NULL), (mergeList[SAO_MERGE_ABOVE]!= NULL), false);
    805 #else
    806     m_pcRDGoOnSbacCoder->codeSAOBlkParam(testBlkParam, sliceEnabled, (mergeList[SAO_MERGE_LEFT]!= NULL), (mergeList[SAO_MERGE_ABOVE]!= NULL), false);
    807 #endif
     778    m_pcRDGoOnSbacCoder->codeSAOBlkParam(testBlkParam, bitDepths, sliceEnabled, (mergeList[SAO_MERGE_LEFT]!= NULL), (mergeList[SAO_MERGE_ABOVE]!= NULL), false);
    808779    Int rate = m_pcRDGoOnSbacCoder->getNumberOfWrittenBits();
    809780
     
    869840      case SAO_MODE_NEW:
    870841        {
    871           deriveModeNewRDO(ctuRsAddr, mergeList, sliceEnabled, blkStats, modeParam, modeCost, m_pppcRDSbacCoder, SAO_CABACSTATE_BLK_CUR);
     842#if SVC_EXTENSION
     843          deriveModeNewRDO(pic->getSlice(0)->getBitDepths(), ctuRsAddr, mergeList, sliceEnabled, blkStats, modeParam, modeCost, m_pppcRDSbacCoder, SAO_CABACSTATE_BLK_CUR);
     844#else
     845          deriveModeNewRDO(pic->getPicSym()->getSPS().getBitDepths(), ctuRsAddr, mergeList, sliceEnabled, blkStats, modeParam, modeCost, m_pppcRDSbacCoder, SAO_CABACSTATE_BLK_CUR);
     846#endif
    872847
    873848        }
     
    875850      case SAO_MODE_MERGE:
    876851        {
    877           deriveModeMergeRDO(ctuRsAddr, mergeList, sliceEnabled, blkStats , modeParam, modeCost, m_pppcRDSbacCoder, SAO_CABACSTATE_BLK_CUR);
     852#if SVC_EXTENSION
     853          deriveModeMergeRDO(pic->getSlice(0)->getBitDepths(), ctuRsAddr, mergeList, sliceEnabled, blkStats , modeParam, modeCost, m_pppcRDSbacCoder, SAO_CABACSTATE_BLK_CUR);
     854#else
     855          deriveModeMergeRDO(pic->getPicSym()->getSPS().getBitDepths(), ctuRsAddr, mergeList, sliceEnabled, blkStats , modeParam, modeCost, m_pppcRDSbacCoder, SAO_CABACSTATE_BLK_CUR);
     856#endif
    878857        }
    879858        break;
     
    953932
    954933
    955 Void TEncSampleAdaptiveOffset::getBlkStats(ComponentID compIdx, SAOStatData* statsDataTypes
     934Void TEncSampleAdaptiveOffset::getBlkStats(const ComponentID compIdx, const Int channelBitDepth, SAOStatData* statsDataTypes
    956935                        , Pel* srcBlk, Pel* orgBlk, Int srcStride, Int orgStride, Int width, Int height
    957936                        , Bool isLeftAvail,  Bool isRightAvail, Bool isAboveAvail, Bool isBelowAvail, Bool isAboveLeftAvail, Bool isAboveRightAvail, Bool isBelowLeftAvail, Bool isBelowRightAvail
     
    13591338#endif
    13601339        endY = isBelowAvail ? (height- skipLinesB[typeIdx]) : height;
    1361         Int shiftBits = g_bitDepth[toChannelType(compIdx)] - NUM_SAO_BO_CLASSES_LOG2;
     1340        Int shiftBits = channelBitDepth - NUM_SAO_BO_CLASSES_LOG2;
    13621341        for (y=0; y< endY; y++)
    13631342        {
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h

    r1259 r1287  
    126126  Void decidePicParams(Bool* sliceEnabled, Int picTempLayer);
    127127  Void decideBlkParams(TComPic* pic, Bool* sliceEnabled, SAOStatData*** blkStats, TComPicYuv* srcYuv, TComPicYuv* resYuv, SAOBlkParam* reconParams, SAOBlkParam* codedParams);
    128   Void getBlkStats(ComponentID compIdx, SAOStatData* statsDataTypes, Pel* srcBlk, Pel* orgBlk, Int srcStride, Int orgStride, Int width, Int height, Bool isLeftAvail,  Bool isRightAvail, Bool isAboveAvail, Bool isBelowAvail, Bool isAboveLeftAvail, Bool isAboveRightAvail, Bool isBelowLeftAvail, Bool isBelowRightAvail
     128  Void getBlkStats(const ComponentID compIdx, const Int channelBitDepth, SAOStatData* statsDataTypes, Pel* srcBlk, Pel* orgBlk, Int srcStride, Int orgStride, Int width, Int height, Bool isLeftAvail,  Bool isRightAvail, Bool isAboveAvail, Bool isBelowAvail, Bool isAboveLeftAvail, Bool isAboveRightAvail, Bool isBelowLeftAvail, Bool isBelowRightAvail
    129129#if SAO_ENCODE_ALLOW_USE_PREDEBLOCK
    130130                  , Bool isCalculatePreDeblockSamples
    131131#endif
    132132                  );
    133   Void deriveModeNewRDO(Int ctuRsAddr, SAOBlkParam* mergeList[NUM_SAO_MERGE_TYPES], Bool* sliceEnabled, SAOStatData*** blkStats, SAOBlkParam& modeParam, Double& modeNormCost, TEncSbac** cabacCoderRDO, Int inCabacLabel);
    134   Void deriveModeMergeRDO(Int ctuRsAddr, SAOBlkParam* mergeList[NUM_SAO_MERGE_TYPES], Bool* sliceEnabled, SAOStatData*** blkStats, SAOBlkParam& modeParam, Double& modeNormCost, TEncSbac** cabacCoderRDO, Int inCabacLabel);
    135   Int64 getDistortion(ComponentID compIdx, Int typeIdc, Int typeAuxInfo, Int* offsetVal, SAOStatData& statData);
    136   Void deriveOffsets(ComponentID compIdx, Int typeIdc, SAOStatData& statData, Int* quantOffsets, Int& typeAuxInfo);
     133  Void deriveModeNewRDO(const BitDepths &bitDepths, Int ctuRsAddr, SAOBlkParam* mergeList[NUM_SAO_MERGE_TYPES], Bool* sliceEnabled, SAOStatData*** blkStats, SAOBlkParam& modeParam, Double& modeNormCost, TEncSbac** cabacCoderRDO, Int inCabacLabel);
     134  Void deriveModeMergeRDO(const BitDepths &bitDepths, Int ctuRsAddr, SAOBlkParam* mergeList[NUM_SAO_MERGE_TYPES], Bool* sliceEnabled, SAOStatData*** blkStats, SAOBlkParam& modeParam, Double& modeNormCost, TEncSbac** cabacCoderRDO, Int inCabacLabel);
     135  Int64 getDistortion(const Int channelBitDepth, Int typeIdc, Int typeAuxInfo, Int* offsetVal, SAOStatData& statData);
     136  Void deriveOffsets(ComponentID compIdx, const Int channelBitDepth, Int typeIdc, SAOStatData& statData, Int* quantOffsets, Int& typeAuxInfo);
    137137  inline Int64 estSaoDist(Int64 count, Int64 offset, Int64 diffSum, Int shift);
    138138  inline Int estIterOffset(Int typeIdx, Int classIdx, Double lambda, Int offsetInput, Int64 count, Int64 diffSum, Int shift, Int bitIncrease, Int64& bestDist, Double& bestCost, Int offsetTh );
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncSbac.cpp

    r1286 r1287  
    886886 
    887887#if SVC_EXTENSION 
    888   Int qpBdOffsetY =  pcCU->getSlice()->getQpBDOffsetY();
     888  Int qpBdOffsetY =  pcCU->getSlice()->getQpBDOffset(CHANNEL_TYPE_LUMA);
    889889#else
    890890  Int qpBdOffsetY =  pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA);
     
    16081608  }
    16091609}
    1610 #if SVC_EXTENSION
    1611 Void TEncSbac::codeSAOOffsetParam(ComponentID compIdx, SAOOffset& ctbParam, Bool sliceEnabled, UInt* saoMaxOffsetQVal)
    1612 #else
    1613 Void TEncSbac::codeSAOOffsetParam(ComponentID compIdx, SAOOffset& ctbParam, Bool sliceEnabled)
    1614 #endif
     1610
     1611Void TEncSbac::codeSAOOffsetParam(ComponentID compIdx, SAOOffset& ctbParam, Bool sliceEnabled, const Int channelBitDepth)
    16151612{
    16161613  UInt uiSymbol;
     
    16581655    }
    16591656
     1657    const Int  maxOffsetQVal = TComSampleAdaptiveOffset::getMaxOffsetQVal(channelBitDepth);
    16601658    for(Int i=0; i< 4; i++)
    16611659    {
    1662 #if SVC_EXTENSION
    1663       codeSaoMaxUvlc((offset[i]<0)?(-offset[i]):(offset[i]),  saoMaxOffsetQVal[compIdx] ); //sao_offset_abs
    1664 #else
    1665       codeSaoMaxUvlc((offset[i]<0)?(-offset[i]):(offset[i]),  g_saoMaxOffsetQVal[compIdx] ); //sao_offset_abs
    1666 #endif
     1660      codeSaoMaxUvlc((offset[i]<0)?(-offset[i]):(offset[i]),  maxOffsetQVal ); //sao_offset_abs
    16671661    }
    16681662
     
    16931687
    16941688
    1695 Void TEncSbac::codeSAOBlkParam(SAOBlkParam& saoBlkParam
    1696 #if SVC_EXTENSION
    1697                               , UInt* saoMaxOffsetQVal
    1698 #endif
     1689Void TEncSbac::codeSAOBlkParam(SAOBlkParam& saoBlkParam, const BitDepths &bitDepths
    16991690                              , Bool* sliceEnabled
    17001691                              , Bool leftMergeAvail
     
    17281719    for(Int compIdx=0; compIdx < MAX_NUM_COMPONENT; compIdx++)
    17291720    {
    1730 #if SVC_EXTENSION
    1731       codeSAOOffsetParam(ComponentID(compIdx), saoBlkParam[compIdx], sliceEnabled[compIdx], saoMaxOffsetQVal);
    1732 #else
    1733       codeSAOOffsetParam(ComponentID(compIdx), saoBlkParam[compIdx], sliceEnabled[compIdx]);
    1734 #endif
     1721      codeSAOOffsetParam(ComponentID(compIdx), saoBlkParam[compIdx], sliceEnabled[compIdx], bitDepths.recon[toChannelType(ComponentID(compIdx))]);
    17351722    }
    17361723  }
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncSbac.h

    r1285 r1287  
    104104  Void  codeSAOSign          ( UInt  uiCode);  //<! code SAO offset sign
    105105
    106 #if SVC_EXTENSION
    107   Void  codeSliceHeaderExtn     ( TComSlice* pSlice, Int shBitsWrittenTillNow );
    108   Void  codeSAOOffsetParam(ComponentID compIdx, SAOOffset& ctbParam, Bool sliceEnabled, UInt* saoMaxOffsetQVal);
    109   Void  codeSAOBlkParam(SAOBlkParam& saoBlkParam
    110                     , UInt* saoMaxOffsetQVal
     106  Void codeSAOOffsetParam(ComponentID compIdx, SAOOffset& ctbParam, Bool sliceEnabled, const Int channelBitDepth);
     107  Void codeSAOBlkParam(SAOBlkParam& saoBlkParam, const BitDepths &bitDepths
    111108                    , Bool* sliceEnabled
    112109                    , Bool leftMergeAvail
     
    114111                    , Bool onlyEstMergeInfo = false
    115112                    );
    116 #else
    117   Void codeSAOOffsetParam(ComponentID compIdx, SAOOffset& ctbParam, Bool sliceEnabled);
    118   Void codeSAOBlkParam(SAOBlkParam& saoBlkParam
    119                     , Bool* sliceEnabled
    120                     , Bool leftMergeAvail
    121                     , Bool aboveMergeAvail
    122                     , Bool onlyEstMergeInfo = false
    123                     );
     113
     114#if SVC_EXTENSION
     115  Void  codeSliceHeaderExtn     ( TComSlice* pSlice, Int shBitsWrittenTillNow );
    124116#endif 
    125117
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp

    r1283 r1287  
    359359
    360360  // distortion
    361   m_cDistParam.bitDepth = g_bitDepth[CHANNEL_TYPE_LUMA];
     361  m_cDistParam.bitDepth = pcPatternKey->getBitDepthY();
    362362  if(m_pcEncCfg->getFastSearch() == SELECTIVE)
    363363  {
     
    848848
    849849    m_cDistParam.pCur = piRefPos;
    850     m_cDistParam.bitDepth = g_bitDepth[CHANNEL_TYPE_LUMA];
     850    m_cDistParam.bitDepth = pcPatternKey->getBitDepthY();
    851851    uiDist = m_cDistParam.DistFunc( &m_cDistParam );
    852852    uiDist += m_pcRdCost->getCost( cMvTest.getHor(), cMvTest.getVer() );
     
    11151115  const ChromaFormat chFmt = pcOrgYuv->getChromaFormat();
    11161116  const ChannelType chType = toChannelType(compID);
     1117#if SVC_EXTENSION
     1118  const Int  bitDepth = pcCU->getSlice()->getBitDepth(chType);
     1119#else
     1120  const Int  bitDepth = pcCU->getSlice()->getSPS()->getBitDepth(chType);
     1121#endif
    11171122
    11181123  const UInt    uiWidth           = rect.width;
     
    12961301    Pel* pRecQt     = piRecQt;
    12971302    Pel* pRecIPred  = piRecIPred;
    1298     const UInt clipbd=g_bitDepth[chType];
    12991303
    13001304    if (pcCU->getSlice()->getPPS()->getUseCrossComponentPrediction())
     
    13401344            ss << pResi[ uiX ] << ", ";
    13411345          }
    1342           pReco    [ uiX ] = Pel(ClipBD<Int>( Int(pPred[uiX]) + Int(pResi[uiX]), clipbd ));
     1346          pReco    [ uiX ] = Pel(ClipBD<Int>( Int(pPred[uiX]) + Int(pResi[uiX]), bitDepth ));
    13431347          pRecQt   [ uiX ] = pReco[ uiX ];
    13441348          pRecIPred[ uiX ] = pReco[ uiX ];
     
    13691373        for( UInt uiX = 0; uiX < uiWidth; uiX++ )
    13701374        {
    1371           pReco    [ uiX ] = Pel(ClipBD<Int>( Int(pPred[uiX]) + Int(pResi[uiX]), clipbd ));
     1375          pReco    [ uiX ] = Pel(ClipBD<Int>( Int(pPred[uiX]) + Int(pResi[uiX]), bitDepth ));
    13721376          pRecQt   [ uiX ] = pReco[ uiX ];
    13731377          pRecIPred[ uiX ] = pReco[ uiX ];
     
    13831387
    13841388  //===== update distortion =====
    1385   ruiDist += m_pcRdCost->getDistPart( g_bitDepth[chType], piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight, compID );
     1389  ruiDist += m_pcRdCost->getDistPart( bitDepth, piReco, uiStride, piOrg, uiStride, uiWidth, uiHeight, compID );
    13861390}
    13871391
     
    21902194  const ChromaFormat chFmt                 = pcCU->getPic()->getChromaFormat();
    21912195  const UInt         numberValidComponents = getNumberValidComponents(chFmt);
     2196  const TComSPS     &sps                   = *(pcCU->getSlice()->getSPS());
     2197  const TComPPS     &pps                   = *(pcCU->getSlice()->getPPS());
    21922198        Distortion   uiOverallDistY        = 0;
    21932199        UInt         CandNum;
     
    22102216#else
    22112217  const Double sqrtLambdaForFirstPass= (m_pcEncCfg->getCostMode()==COST_MIXED_LOSSLESS_LOSSY_CODING && pcCU->getCUTransquantBypass(0)) ?
    2212                 sqrt(0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12 - 6 * (g_bitDepth[CHANNEL_TYPE_LUMA] - 8)) / 3.0)))
     2218#if SVC_EXTENSION
     2219                sqrt(0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12 - 6 * (pcCU->getSlice()->getBitDepth(CHANNEL_TYPE_LUMA) - 8)) / 3.0)))
     2220#else
     2221                sqrt(0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12 - 6 * (sps.getBitDepth(CHANNEL_TYPE_LUMA) - 8)) / 3.0)))
     2222#endif
    22132223              : m_pcRdCost->getSqrtLambda();
    22142224#endif
    22152225
    22162226  //===== set QP and clear Cbf =====
    2217   if ( pcCU->getSlice()->getPPS()->getUseDQP() == true)
     2227  if ( pps.getUseDQP() == true)
    22182228  {
    22192229    pcCU->setQPSubParts( pcCU->getQP(0), 0, uiDepth );
     
    22872297      DistParam distParam;
    22882298      const Bool bUseHadamard=pcCU->getCUTransquantBypass(0) == 0;
    2289       m_pcRdCost->setDistParam(distParam, g_bitDepth[CHANNEL_TYPE_LUMA], piOrg, uiStride, piPred, uiStride, puRect.width, puRect.height, bUseHadamard);
     2299#if SVC_EXTENSION
     2300      m_pcRdCost->setDistParam(distParam, pcCU->getSlice()->getBitDepth(CHANNEL_TYPE_LUMA), piOrg, uiStride, piPred, uiStride, puRect.width, puRect.height, bUseHadamard);
     2301#else
     2302      m_pcRdCost->setDistParam(distParam, sps.getBitDepth(CHANNEL_TYPE_LUMA), piOrg, uiStride, piPred, uiStride, puRect.width, puRect.height, bUseHadamard);
     2303#endif
    22902304      distParam.bApplyWeight = false;
    22912305      for( Int modeIdx = 0; modeIdx < numModesAvailable; modeIdx++ )
     
    23042318#endif
    23052319
    2306         const Bool bUseFilter=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, uiMode, puRect.width, puRect.height, chFmt, pcCU->getSlice()->getSPS()->getDisableIntraReferenceSmoothing());
     2320        const Bool bUseFilter=TComPrediction::filteringIntraReferenceSamples(COMPONENT_Y, uiMode, puRect.width, puRect.height, chFmt, sps.getDisableIntraReferenceSmoothing());
    23072321
    23082322        predIntraAng( COMPONENT_Y, uiMode, piOrg, uiStride, piPred, uiStride, tuRecurseWithPU, bAboveAvail, bLeftAvail, bUseFilter, TComPrediction::UseDPCMForFirstPassIntraEstimation(tuRecurseWithPU, uiMode) );
     
    24162430        xSetIntraResultLumaQT( pcRecoYuv, tuRecurseWithPU );
    24172431
    2418         if (pcCU->getSlice()->getPPS()->getUseCrossComponentPrediction())
     2432        if (pps.getUseCrossComponentPrediction())
    24192433        {
    24202434          const Int xOffset = tuRecurseWithPU.getRect( COMPONENT_Y ).x0;
     
    24922506        xSetIntraResultLumaQT( pcRecoYuv, tuRecurseWithPU );
    24932507
    2494         if (pcCU->getSlice()->getPPS()->getUseCrossComponentPrediction())
     2508        if (pps.getUseCrossComponentPrediction())
    24952509        {
    24962510          const Int xOffset = tuRecurseWithPU.getRect( COMPONENT_Y ).x0;
     
    27602774Void TEncSearch::xEncPCM (TComDataCU* pcCU, UInt uiAbsPartIdx, Pel* pOrg, Pel* pPCM, Pel* pPred, Pel* pResi, Pel* pReco, UInt uiStride, UInt uiWidth, UInt uiHeight, const ComponentID compID )
    27612775{
    2762   const UInt uiReconStride = pcCU->getPic()->getPicYuvRec()->getStride(compID);
    2763   const UInt uiPCMBitDepth = pcCU->getSlice()->getSPS()->getPCMBitDepth(toChannelType(compID));
     2776  const UInt uiReconStride   = pcCU->getPic()->getPicYuvRec()->getStride(compID);
     2777  const UInt uiPCMBitDepth   = pcCU->getSlice()->getSPS()->getPCMBitDepth(toChannelType(compID));
     2778#if SVC_EXTENSION
     2779  const Int  channelBitDepth = pcCU->getSlice()->getBitDepth(toChannelType(compID));
     2780#else
     2781  const Int  channelBitDepth = pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID));
     2782#endif
    27642783  Pel* pRecoPic = pcCU->getPic()->getPicYuvRec()->getAddr(compID, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu()+uiAbsPartIdx);
    27652784
    2766   const Int pcmShiftRight=(g_bitDepth[toChannelType(compID)] - Int(uiPCMBitDepth));
     2785  const Int pcmShiftRight=(channelBitDepth - Int(uiPCMBitDepth));
    27672786
    27682787  assert(pcmShiftRight >= 0);
     
    28492868
    28502869
    2851   m_pcRdCost->setDistParam( cDistParam, g_bitDepth[CHANNEL_TYPE_LUMA],
     2870#if SVC_EXTENSION
     2871  m_pcRdCost->setDistParam( cDistParam, pcCU->getSlice()->getBitDepth(CHANNEL_TYPE_LUMA),
     2872#else
     2873  m_pcRdCost->setDistParam( cDistParam, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA),
     2874#endif
    28522875                            pcYuvOrg->getAddr( COMPONENT_Y, uiAbsPartIdx ), pcYuvOrg->getStride(COMPONENT_Y),
    28532876                            m_tmpYuvPred .getAddr( COMPONENT_Y, uiAbsPartIdx ), m_tmpYuvPred.getStride(COMPONENT_Y),
     
    37973820#endif
    37983821  {
    3799     xPredInterBlk( COMPONENT_Y, pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, true );
     3822#if SVC_EXTENSION
     3823    xPredInterBlk( COMPONENT_Y, pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, true, pcCU->getSlice()->getBitDepth(CHANNEL_TYPE_LUMA) );
     3824#else
     3825    xPredInterBlk( COMPONENT_Y, pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, true, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) );
     3826#endif
    38003827  }
    38013828  else
    38023829  {
    3803     xPredInterBlk( COMPONENT_Y, pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, false );
     3830#if SVC_EXTENSION
     3831    xPredInterBlk( COMPONENT_Y, pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, false, pcCU->getSlice()->getBitDepth(CHANNEL_TYPE_LUMA) );
     3832#else
     3833    xPredInterBlk( COMPONENT_Y, pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, false, pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) );
     3834#endif
    38043835  }
    38053836
     
    38153846
    38163847  // calc distortion
    3817 
    3818   uiCost = m_pcRdCost->getDistPart( g_bitDepth[CHANNEL_TYPE_LUMA], pcTemplateCand->getAddr(COMPONENT_Y, uiPartAddr), pcTemplateCand->getStride(COMPONENT_Y), pcOrgYuv->getAddr(COMPONENT_Y, uiPartAddr), pcOrgYuv->getStride(COMPONENT_Y), iSizeX, iSizeY, COMPONENT_Y, DF_SAD );
     3848#if SVC_EXTENSION
     3849  uiCost = m_pcRdCost->getDistPart( pcCU->getSlice()->getBitDepth(CHANNEL_TYPE_LUMA), pcTemplateCand->getAddr(COMPONENT_Y, uiPartAddr), pcTemplateCand->getStride(COMPONENT_Y), pcOrgYuv->getAddr(COMPONENT_Y, uiPartAddr), pcOrgYuv->getStride(COMPONENT_Y), iSizeX, iSizeY, COMPONENT_Y, DF_SAD );
     3850#else
     3851  uiCost = m_pcRdCost->getDistPart( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA), pcTemplateCand->getAddr(COMPONENT_Y, uiPartAddr), pcTemplateCand->getStride(COMPONENT_Y), pcOrgYuv->getAddr(COMPONENT_Y, uiPartAddr), pcOrgYuv->getStride(COMPONENT_Y), iSizeX, iSizeY, COMPONENT_Y, DF_SAD );
     3852#endif
    38193853  uiCost = (UInt) m_pcRdCost->calcRdCost( m_auiMVPIdxCost[iMVPIdx][iMVPNum], uiCost, false, DF_SAD );
    38203854  return uiCost;
     
    38633897                             iRoiWidth,
    38643898                             iRoiHeight,
    3865                              pcYuv->getStride(COMPONENT_Y) );
     3899                             pcYuv->getStride(COMPONENT_Y),
     3900#if SVC_EXTENSION
     3901                             pcCU->getSlice()->getBitDepth(CHANNEL_TYPE_LUMA) );
     3902#else
     3903                             pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) );
     3904#endif
    38663905
    38673906  Pel*        piRefY      = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxPred )->getPicYuvRec()->getAddr( COMPONENT_Y, pcCU->getCtuRsAddr(), pcCU->getZorderIdxInCtu() + uiPartAddr );
     
    40034042      setDistParamComp(COMPONENT_Y);
    40044043
    4005       m_cDistParam.bitDepth = g_bitDepth[CHANNEL_TYPE_LUMA];
     4044      m_cDistParam.bitDepth = pcPatternKey->getBitDepthY();
    40064045      uiSad = m_cDistParam.DistFunc( &m_cDistParam );
    40074046
     
    44384477                          pcPatternKey->getROIYWidth(),
    44394478                          pcPatternKey->getROIYHeight(),
    4440                           iRefStride );
     4479                          iRefStride,
     4480                          pcPatternKey->getBitDepthY());
    44414481
    44424482  //  Half-pel refinement
     
    44694509  const UInt cuHeightPixels     = pcCU->getHeight( 0 );
    44704510  const Int  numValidComponents = pcCU->getPic()->getNumberValidComponents();
     4511#if !SVC_EXTENSION
     4512  const TComSPS &sps=*(pcCU->getSlice()->getSPS());
     4513#endif
    44714514
    44724515  // The pcCU is not marked as skip-mode at this point, and its m_pcTrCoeff, m_pcArlCoeff, m_puhCbf, m_puhTrIdx will all be 0.
     
    44874530      const UInt csx=pcYuvOrg->getComponentScaleX(compID);
    44884531      const UInt csy=pcYuvOrg->getComponentScaleY(compID);
    4489       distortion += m_pcRdCost->getDistPart( g_bitDepth[toChannelType(compID)], pcYuvRec->getAddr(compID), pcYuvRec->getStride(compID), pcYuvOrg->getAddr(compID),
     4532#if SVC_EXTENSION
     4533      distortion += m_pcRdCost->getDistPart( pcCU->getSlice()->getBitDepth(toChannelType(compID)), pcYuvRec->getAddr(compID), pcYuvRec->getStride(compID), pcYuvOrg->getAddr(compID),
     4534#else
     4535      distortion += m_pcRdCost->getDistPart( sps.getBitDepth(toChannelType(compID)), pcYuvRec->getAddr(compID), pcYuvRec->getStride(compID), pcYuvOrg->getAddr(compID),
     4536#endif
    44904537                                               pcYuvOrg->getStride(compID), cuWidthPixels >> csx, cuHeightPixels >> csy, compID);
    44914538    }
     
    45874634  m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[ pcCU->getDepth( 0 ) ][ CI_TEMP_BEST ] );
    45884635
    4589   pcYuvRec->addClip ( pcYuvPred, pcYuvResiBest, 0, cuWidthPixels );
     4636#if SVC_EXTENSION
     4637  pcYuvRec->addClip ( pcYuvPred, pcYuvResiBest, 0, cuWidthPixels, pcCU->getSlice()->getBitDepths() );
     4638#else
     4639  pcYuvRec->addClip ( pcYuvPred, pcYuvResiBest, 0, cuWidthPixels, sps.getBitDepths() );
     4640#endif
    45904641
    45914642  // update with clipped distortion and cost (previously unclipped reconstruction values were used)
     
    45954646  {
    45964647    const ComponentID compID=ComponentID(comp);
    4597     finalDistortion += m_pcRdCost->getDistPart( g_bitDepth[toChannelType(compID)], pcYuvRec->getAddr(compID ), pcYuvRec->getStride(compID ), pcYuvOrg->getAddr(compID ), pcYuvOrg->getStride(compID), cuWidthPixels >> pcYuvOrg->getComponentScaleX(compID), cuHeightPixels >> pcYuvOrg->getComponentScaleY(compID), compID);
     4648#if SVC_EXTENSION
     4649    finalDistortion += m_pcRdCost->getDistPart( pcCU->getSlice()->getBitDepth(toChannelType(compID)), pcYuvRec->getAddr(compID ), pcYuvRec->getStride(compID ), pcYuvOrg->getAddr(compID ), pcYuvOrg->getStride(compID), cuWidthPixels >> pcYuvOrg->getComponentScaleX(compID), cuHeightPixels >> pcYuvOrg->getComponentScaleY(compID), compID);
     4650#else
     4651    finalDistortion += m_pcRdCost->getDistPart( sps.getBitDepth(toChannelType(compID)), pcYuvRec->getAddr(compID ), pcYuvRec->getStride(compID ), pcYuvOrg->getAddr(compID ), pcYuvOrg->getStride(compID), cuWidthPixels >> pcYuvOrg->getComponentScaleX(compID), cuHeightPixels >> pcYuvOrg->getComponentScaleY(compID), compID);
     4652#endif
    45984653  }
    45994654
     
    46854740      checkTransformSkip[i]=false;
    46864741      const ComponentID compID=ComponentID(i);
     4742#if SVC_EXTENSION
     4743      const Int channelBitDepth=pcCU->getSlice()->getBitDepth(toChannelType(compID));
     4744#else
     4745      const Int channelBitDepth=pcCU->getSlice()->getSPS()->getBitDepth(toChannelType(compID));
     4746#endif
    46874747      pcCoeffCurr[compID]    = m_ppcQTTempCoeff[compID][uiQTTempAccessLayer] + rTu.getCoefficientOffset(compID);
    46884748#if ADAPTIVE_QP_SELECTION
     
    48414901                                                        true);
    48424902
    4843                   nonCoeffDist = m_pcRdCost->getDistPart( g_bitDepth[toChannelType(compID)], m_pcQTTempTComYuv[uiQTTempAccessLayer].getAddrPix( compID, tuCompRect.x0, tuCompRect.y0 ),
    4844                                                                                               m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride( compID ), pcResi->getAddrPix( compID, tuCompRect.x0, tuCompRect.y0 ),
    4845                                                                                               pcResi->getStride(compID), tuCompRect.width, tuCompRect.height, compID); // initialized with zero residual destortion
     4903                  nonCoeffDist = m_pcRdCost->getDistPart( channelBitDepth, m_pcQTTempTComYuv[uiQTTempAccessLayer].getAddrPix( compID, tuCompRect.x0, tuCompRect.y0 ),
     4904                                                          m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride( compID ), pcResi->getAddrPix( compID, tuCompRect.x0, tuCompRect.y0 ),
     4905                                                          pcResi->getStride(compID), tuCompRect.width, tuCompRect.height, compID); // initialized with zero residual destortion
    48464906                }
    48474907                else
    48484908                {
    4849                   nonCoeffDist = m_pcRdCost->getDistPart( g_bitDepth[toChannelType(compID)], m_pTempPel, tuCompRect.width, pcResi->getAddrPix( compID, tuCompRect.x0, tuCompRect.y0 ),
    4850                                                                                               pcResi->getStride(compID), tuCompRect.width, tuCompRect.height, compID); // initialized with zero residual destortion
     4909                  nonCoeffDist = m_pcRdCost->getDistPart( channelBitDepth, m_pTempPel, tuCompRect.width, pcResi->getAddrPix( compID, tuCompRect.x0, tuCompRect.y0 ),
     4910                                                          pcResi->getStride(compID), tuCompRect.width, tuCompRect.height, compID); // initialized with zero residual destortion
    48514911                }
    48524912
     
    49064966                }
    49074967
    4908                 currCompDist = m_pcRdCost->getDistPart( g_bitDepth[toChannelType(compID)], m_pcQTTempTComYuv[uiQTTempAccessLayer].getAddrPix( compID, tuCompRect.x0, tuCompRect.y0 ),
     4968                currCompDist = m_pcRdCost->getDistPart( channelBitDepth, m_pcQTTempTComYuv[uiQTTempAccessLayer].getAddrPix( compID, tuCompRect.x0, tuCompRect.y0 ),
    49094969                                                        m_pcQTTempTComYuv[uiQTTempAccessLayer].getStride(compID),
    49104970                                                        pcResi->getAddrPix( compID, tuCompRect.x0, tuCompRect.y0 ),
     
    55255585  const ChromaFormat chFmt = m_filteredBlock[0][0].getChromaFormat();
    55265586
    5527   m_if.filterHor(COMPONENT_Y, srcPtr, srcStride, m_filteredBlockTmp[0].getAddr(COMPONENT_Y), intStride, width+1, height+filterSize, 0, false, chFmt);
    5528   m_if.filterHor(COMPONENT_Y, srcPtr, srcStride, m_filteredBlockTmp[2].getAddr(COMPONENT_Y), intStride, width+1, height+filterSize, 2, false, chFmt);
     5587  m_if.filterHor(COMPONENT_Y, srcPtr, srcStride, m_filteredBlockTmp[0].getAddr(COMPONENT_Y), intStride, width+1, height+filterSize, 0, false, chFmt, pattern->getBitDepthY());
     5588  m_if.filterHor(COMPONENT_Y, srcPtr, srcStride, m_filteredBlockTmp[2].getAddr(COMPONENT_Y), intStride, width+1, height+filterSize, 2, false, chFmt, pattern->getBitDepthY());
    55295589
    55305590  intPtr = m_filteredBlockTmp[0].getAddr(COMPONENT_Y) + halfFilterSize * intStride + 1;
    55315591  dstPtr = m_filteredBlock[0][0].getAddr(COMPONENT_Y);
    5532   m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width+0, height+0, 0, false, true, chFmt);
     5592  m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width+0, height+0, 0, false, true, chFmt, pattern->getBitDepthY());
    55335593
    55345594  intPtr = m_filteredBlockTmp[0].getAddr(COMPONENT_Y) + (halfFilterSize-1) * intStride + 1;
    55355595  dstPtr = m_filteredBlock[2][0].getAddr(COMPONENT_Y);
    5536   m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width+0, height+1, 2, false, true, chFmt);
     5596  m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width+0, height+1, 2, false, true, chFmt, pattern->getBitDepthY());
    55375597
    55385598  intPtr = m_filteredBlockTmp[2].getAddr(COMPONENT_Y) + halfFilterSize * intStride;
    55395599  dstPtr = m_filteredBlock[0][2].getAddr(COMPONENT_Y);
    5540   m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width+1, height+0, 0, false, true, chFmt);
     5600  m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width+1, height+0, 0, false, true, chFmt, pattern->getBitDepthY());
    55415601
    55425602  intPtr = m_filteredBlockTmp[2].getAddr(COMPONENT_Y) + (halfFilterSize-1) * intStride;
    55435603  dstPtr = m_filteredBlock[2][2].getAddr(COMPONENT_Y);
    5544   m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width+1, height+1, 2, false, true, chFmt);
     5604  m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width+1, height+1, 2, false, true, chFmt, pattern->getBitDepthY());
    55455605}
    55465606
     
    55865646    srcPtr += 1;
    55875647  }
    5588   m_if.filterHor(COMPONENT_Y, srcPtr, srcStride, intPtr, intStride, width, extHeight, 1, false, chFmt);
     5648  m_if.filterHor(COMPONENT_Y, srcPtr, srcStride, intPtr, intStride, width, extHeight, 1, false, chFmt, pattern->getBitDepthY());
    55895649
    55905650  // Horizontal filter 3/4
     
    55995659    srcPtr += 1;
    56005660  }
    5601   m_if.filterHor(COMPONENT_Y, srcPtr, srcStride, intPtr, intStride, width, extHeight, 3, false, chFmt);
     5661  m_if.filterHor(COMPONENT_Y, srcPtr, srcStride, intPtr, intStride, width, extHeight, 3, false, chFmt, pattern->getBitDepthY());
    56025662
    56035663  // Generate @ 1,1
     
    56085668    intPtr += intStride;
    56095669  }
    5610   m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 1, false, true, chFmt);
     5670  m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 1, false, true, chFmt, pattern->getBitDepthY());
    56115671
    56125672  // Generate @ 3,1
    56135673  intPtr = m_filteredBlockTmp[1].getAddr(COMPONENT_Y) + (halfFilterSize-1) * intStride;
    56145674  dstPtr = m_filteredBlock[3][1].getAddr(COMPONENT_Y);
    5615   m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 3, false, true, chFmt);
     5675  m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 3, false, true, chFmt, pattern->getBitDepthY());
    56165676
    56175677  if (halfPelRef.getVer() != 0)
     
    56245684      intPtr += intStride;
    56255685    }
    5626     m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 2, false, true, chFmt);
     5686    m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 2, false, true, chFmt, pattern->getBitDepthY());
    56275687
    56285688    // Generate @ 2,3
     
    56335693      intPtr += intStride;
    56345694    }
    5635     m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 2, false, true, chFmt);
     5695    m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 2, false, true, chFmt, pattern->getBitDepthY());
    56365696  }
    56375697  else
     
    56405700    intPtr = m_filteredBlockTmp[1].getAddr(COMPONENT_Y) + halfFilterSize * intStride;
    56415701    dstPtr = m_filteredBlock[0][1].getAddr(COMPONENT_Y);
    5642     m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 0, false, true, chFmt);
     5702    m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 0, false, true, chFmt, pattern->getBitDepthY());
    56435703
    56445704    // Generate @ 0,3
    56455705    intPtr = m_filteredBlockTmp[3].getAddr(COMPONENT_Y) + halfFilterSize * intStride;
    56465706    dstPtr = m_filteredBlock[0][3].getAddr(COMPONENT_Y);
    5647     m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 0, false, true, chFmt);
     5707    m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 0, false, true, chFmt, pattern->getBitDepthY());
    56485708  }
    56495709
     
    56615721      intPtr += intStride;
    56625722    }
    5663     m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 1, false, true, chFmt);
     5723    m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 1, false, true, chFmt, pattern->getBitDepthY());
    56645724
    56655725    // Generate @ 3,2
     
    56745734      intPtr += intStride;
    56755735    }
    5676     m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 3, false, true, chFmt);
     5736    m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 3, false, true, chFmt, pattern->getBitDepthY());
    56775737  }
    56785738  else
     
    56855745      intPtr += intStride;
    56865746    }
    5687     m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 1, false, true, chFmt);
     5747    m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 1, false, true, chFmt, pattern->getBitDepthY());
    56885748
    56895749    // Generate @ 3,0
     
    56945754      intPtr += intStride;
    56955755    }
    5696     m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 3, false, true, chFmt);
     5756    m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 3, false, true, chFmt, pattern->getBitDepthY());
    56975757  }
    56985758
     
    57045764    intPtr += intStride;
    57055765  }
    5706   m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 1, false, true, chFmt);
     5766  m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 1, false, true, chFmt, pattern->getBitDepthY());
    57075767
    57085768  // Generate @ 3,3
    57095769  intPtr = m_filteredBlockTmp[3].getAddr(COMPONENT_Y) + (halfFilterSize-1) * intStride;
    57105770  dstPtr = m_filteredBlock[3][3].getAddr(COMPONENT_Y);
    5711   m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 3, false, true, chFmt);
     5771  m_if.filterVer(COMPONENT_Y, intPtr, intStride, dstPtr, dstStride, width, height, 3, false, true, chFmt, pattern->getBitDepthY());
    57125772}
    57135773
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.cpp

    r1260 r1287  
    171171
    172172  // store lambda
    173   m_pcRdCost ->setLambda( dLambda );
     173#if SVC_EXTENSION
     174  m_pcRdCost ->setLambda( dLambda, slice->getBitDepths() );
     175#else
     176  m_pcRdCost ->setLambda( dLambda, slice->getSPS()->getBitDepths() );
     177#endif
    174178
    175179  // for RDO
     
    187191    {
    188192      dLambdas[0] = dLambda * 1.1;
    189       m_pcRdCost->setLambda( dLambdas[0] );
     193      m_pcRdCost->setLambda( dLambdas[0], slice->getBitDepths() );
    190194
    191195      m_pcRdCost->setDistortionWeight(compID, tmpWeight * 1.15);
     
    227231 \param iGOPid        POC offset for hierarchical structure
    228232 \param rpcSlice      slice header class
    229  \param pSPS          SPS associated with the slice
    230  \param pPPS          PPS associated with the slice
    231233 \param isField       true for field coding
    232234 */
    233 #if SVC_EXTENSION
     235
    234236Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, Bool isField )
    235 #else
    236 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, const TComSPS* pSPS, const TComPPS *pPPS, Bool isField )
    237 #endif
    238237{
    239238  Double dQP;
     
    351350  {
    352351#if SVC_EXTENSION
    353     if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getQpBDOffsetY() ) && (rpcSlice->getPPS()->getTransquantBypassEnableFlag())))
     352    if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getQpBDOffset(CHANNEL_TYPE_LUMA) ) && (rpcSlice->getPPS()->getTransquantBypassEnableFlag())))
    354353#else
    355354    if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA) ) && (rpcSlice->getPPS()->getTransquantBypassEnableFlag())))
     
    393392
    394393#if FULL_NBIT
    395     Int    bitdepth_luma_qp_scale = 6 * (g_bitDepth[CHANNEL_TYPE_LUMA] - 8);
     394#if SVC_EXTENSION
     395    Int    bitdepth_luma_qp_scale = 6 * (rpcSlice->getBitDepth(CHANNEL_TYPE_LUMA) - 8);
     396#else
     397    Int    bitdepth_luma_qp_scale = 6 * (rpcSlice->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 8);
     398#endif
    396399#else
    397400    Int    bitdepth_luma_qp_scale = 0;
     
    425428
    426429#if SVC_EXTENSION
    427     iQP = max( -rpcSlice->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );
    428 #else
    429     iQP = max( -pSPS->getQpBDOffset(CHANNEL_TYPE_LUMA), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );
     430    iQP = max( -rpcSlice->getQpBDOffset(CHANNEL_TYPE_LUMA), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );
     431#else
     432    iQP = max( -rpcSlice->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );
    430433#endif
    431434
     
    486489    dQP = xGetQPValueAccordingToLambda( dLambda );
    487490#if SVC_EXTENSION
    488     iQP = max( -rpcSlice->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );
    489 #else
    490     iQP = max( -pSPS->getQpBDOffset(CHANNEL_TYPE_LUMA), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );
     491    iQP = max( -rpcSlice->getQpBDOffset(CHANNEL_TYPE_LUMA), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );
     492#else
     493    iQP = max( -rpcSlice->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );
    491494#endif
    492495  }
     
    499502  rpcSlice->setSliceChromaQpDelta( COMPONENT_Cb, 0 );
    500503  rpcSlice->setSliceChromaQpDelta( COMPONENT_Cr, 0 );
    501   rpcSlice->setUseChromaQpAdj( pPPS->getChromaQpAdjTableSize() > 0 );
     504  rpcSlice->setUseChromaQpAdj( rpcSlice->getPPS()->getChromaQpAdjTableSize() > 0 );
    502505  rpcSlice->setNumRefIdx(REF_PIC_LIST_0,m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive);
    503506  rpcSlice->setNumRefIdx(REF_PIC_LIST_1,m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive);
     
    644647  Double dFrameLambda;
    645648#if FULL_NBIT
    646   Int    SHIFT_QP = 12 + 6 * (g_bitDepth[CHANNEL_TYPE_LUMA] - 8);
     649#if SVC_EXTENSION
     650  Int    SHIFT_QP = 12 + 6 * (pcSlice->getBitDepth(CHANNEL_TYPE_LUMA) - 8);
     651#else
     652  Int    SHIFT_QP = 12 + 6 * (pcSlice->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 8);
     653#endif
    647654#else
    648655  Int    SHIFT_QP = 12;
     
    706713Void TEncSlice::calCostSliceI(TComPic* pcPic)
    707714{
    708   UInt    ctuRsAddr;
    709   UInt    startCtuTsAddr;
    710   UInt    boundingCtuTsAddr;
    711   Int     iSumHad, shift = g_bitDepth[CHANNEL_TYPE_LUMA]-8, offset = (shift>0)?(1<<(shift-1)):0;;
    712   Double  iSumHadSlice = 0;
    713 
    714   pcPic->getSlice(getSliceIdx())->setSliceSegmentBits(0);
    715   TComSlice* pcSlice            = pcPic->getSlice(getSliceIdx());
     715  Double            iSumHadSlice      = 0;
     716  TComSlice * const pcSlice           = pcPic->getSlice(getSliceIdx());
     717  const TComSPS    &sps               = *(pcSlice->getSPS());
     718#if SVC_EXTENSION
     719  const Int         shift             = pcSlice->getBitDepth(CHANNEL_TYPE_LUMA)-8;
     720#else
     721  const Int         shift             = sps.getBitDepth(CHANNEL_TYPE_LUMA)-8;
     722#endif
     723  const Int         offset            = (shift>0)?(1<<(shift-1)):0;
     724
     725  pcSlice->setSliceSegmentBits(0);
     726
     727  UInt startCtuTsAddr, boundingCtuTsAddr;
    716728  xDetermineStartAndBoundingCtuTsAddr ( startCtuTsAddr, boundingCtuTsAddr, pcPic, false );
    717729
    718   UInt ctuTsAddr;
    719   ctuRsAddr = pcPic->getPicSym()->getCtuTsToRsAddrMap( startCtuTsAddr);
    720   for( ctuTsAddr = startCtuTsAddr; ctuTsAddr < boundingCtuTsAddr; ctuRsAddr = pcPic->getPicSym()->getCtuTsToRsAddrMap(++ctuTsAddr) )
     730  for( UInt ctuTsAddr = startCtuTsAddr, ctuRsAddr = pcPic->getPicSym()->getCtuTsToRsAddrMap( startCtuTsAddr);
     731       ctuTsAddr < boundingCtuTsAddr;
     732      ctuRsAddr = pcPic->getPicSym()->getCtuTsToRsAddrMap(++ctuTsAddr) )
    721733  {
    722734    // initialize CU encoder
     
    725737
    726738#if SVC_EXTENSION
    727     Int height  = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getPicHeightInLumaSamples() - ctuRsAddr / pcPic->getFrameWidthInCtus() * pcSlice->getSPS()->getMaxCUHeight() );
    728     Int width   = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getPicWidthInLumaSamples() - ctuRsAddr % pcPic->getFrameWidthInCtus() * pcSlice->getSPS()->getMaxCUWidth() );
    729 #else
    730     Int height  = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - ctuRsAddr / pcPic->getFrameWidthInCtus() * pcSlice->getSPS()->getMaxCUHeight() );
    731     Int width   = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - ctuRsAddr % pcPic->getFrameWidthInCtus() * pcSlice->getSPS()->getMaxCUWidth() );
    732 #endif
    733 
    734     iSumHad = m_pcCuEncoder->updateCtuDataISlice(pCtu, width, height);
     739    Int height  = min( sps.getMaxCUHeight(),pcSlice->getPicHeightInLumaSamples() - ctuRsAddr / pcPic->getFrameWidthInCtus() * sps.getMaxCUHeight() );
     740    Int width   = min( sps.getMaxCUWidth(),pcSlice->getPicWidthInLumaSamples() - ctuRsAddr % pcPic->getFrameWidthInCtus() * sps.getMaxCUWidth() );
     741#else
     742    Int height  = min( sps.getMaxCUHeight(),sps.getPicHeightInLumaSamples() - ctuRsAddr / pcPic->getFrameWidthInCtus() * sps.getMaxCUHeight() );
     743    Int width   = min( sps.getMaxCUWidth(), sps.getPicWidthInLumaSamples()  - ctuRsAddr % pcPic->getFrameWidthInCtus() * sps.getMaxCUWidth() );
     744#endif
     745
     746    Int iSumHad = m_pcCuEncoder->updateCtuDataISlice(pCtu, width, height);
    735747
    736748    (m_pcRateCtrl->getRCPic()->getLCU(ctuRsAddr)).m_costIntra=(iSumHad+offset)>>shift;
     
    901913
    902914#if SVC_EXTENSION
    903         estQP     = Clip3( -pcSlice->getQpBDOffsetY(), MAX_QP, estQP );
     915        estQP     = Clip3( -pcSlice->getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, estQP );
     916
     917        m_pcRdCost->setLambda(estLambda, pcSlice->getBitDepths());
    904918#else
    905919        estQP     = Clip3( -pcSlice->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA), MAX_QP, estQP );
    906 #endif
    907 
    908         m_pcRdCost->setLambda(estLambda);
     920
     921        m_pcRdCost->setLambda(estLambda, pcSlice->getSPS()->getBitDepths());
     922#endif       
    909923
    910924#if RDOQ_CHROMA_LAMBDA
     
    10001014        actualQP = pCtu->getQP( 0 );
    10011015      }
    1002       m_pcRdCost->setLambda(oldLambda);
     1016#if SVC_EXTENSION
     1017      m_pcRdCost->setLambda(oldLambda, pcSlice->getBitDepths());
     1018#else
     1019      m_pcRdCost->setLambda(oldLambda, pcSlice->getSPS()->getBitDepths());
     1020#endif
    10031021      m_pcRateCtrl->getRCPic()->updateAfterCTU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda,
    10041022                                                pCtu->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() );
     
    11581176
    11591177#if SVC_EXTENSION
    1160         m_pcEntropyCoder->encodeSAOBlkParam(saoblkParam, m_ppcTEncTop[pcSlice->getLayerIdx()]->getSAO()->getSaoMaxOffsetQVal(), sliceEnabled, leftMergeAvail, aboveMergeAvail);
    1161 #else
    1162         m_pcEntropyCoder->encodeSAOBlkParam(saoblkParam, sliceEnabled, leftMergeAvail, aboveMergeAvail);
     1178        m_pcEntropyCoder->encodeSAOBlkParam(saoblkParam, pcPic->getPicSym()->getSlice(0)->getBitDepths(), sliceEnabled, leftMergeAvail, aboveMergeAvail);
     1179#else
     1180        m_pcEntropyCoder->encodeSAOBlkParam(saoblkParam, pcPic->getPicSym()->getSPS().getBitDepths(), sliceEnabled, leftMergeAvail, aboveMergeAvail);
    11631181#endif
    11641182      }
     
    13641382{
    13651383  xCalcACDCParamSlice(pcSlice);
    1366   WPACDCParam * temp_weightACDCParam;
    1367 
    1368   pcSlice->getWpAcDcParam(temp_weightACDCParam);
    1369   g_refWeightACDCParam = (void *) temp_weightACDCParam;
    13701384}
    13711385#endif //SVC_EXTENSION
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.h

    r1259 r1287  
    120120
    121121  /// preparation of slice encoding (reference marking, QP and lambda)
    122 #if SVC_EXTENSION
    123   Void    initEncSlice        ( TComPic*  pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, Bool isField );
    124   Void    estimateILWpParam   ( TComSlice* pcSlice );
    125 #else
    126122  Void    initEncSlice        ( TComPic*  pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd,
    127                                 Int iGOPid,   TComSlice*& rpcSlice, const TComSPS* pSPS, const TComPPS *pPPS, Bool isField );
    128 #endif
    129 
     123                                Int iGOPid,   TComSlice*& rpcSlice, Bool isField );
    130124  Void    resetQP             ( TComPic* pic, Int sliceQP, Double lambda );
    131125  // compress and encode slice
     
    145139  SliceType getEncCABACTableIdx() const           { return m_encCABACTableIdx;        }
    146140
     141#if SVC_EXTENSION
     142  Void    estimateILWpParam   ( TComSlice* pcSlice );
     143#endif
     144
    147145private:
    148146  Double  xGetQPValueAccordingToLambda ( Double lambda );
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp

    r1285 r1287  
    283283  {
    284284#if SVC_EXTENSION
    285     getTrQuant()->setFlatScalingList(m_cVPS.getChromaFormatIdc(&m_cSPS, m_layerId), maxLog2TrDynamicRange);
     285    getTrQuant()->setFlatScalingList( m_cVPS.getChromaFormatIdc(&m_cSPS, m_layerId), maxLog2TrDynamicRange, m_cVPS.getBitDepths(&m_cSPS, m_layerId) );
    286286#else
    287     getTrQuant()->setFlatScalingList(m_cSPS.getChromaFormatIdc(), maxLog2TrDynamicRange);
     287    getTrQuant()->setFlatScalingList(m_cSPS.getChromaFormatIdc(), maxLog2TrDynamicRange, m_cSPS.getBitDepths());
    288288#endif
    289289    getTrQuant()->setUseScalingList(false);
     
    305305
    306306      // infer the scaling list from the reference layer
    307       getTrQuant()->setScalingList( &m_ppcTEncTop[m_cVPS.getLayerIdxInVps(refLayerId)]->getSPS()->getScalingList(), m_cSPS.getChromaFormatIdc(), maxLog2TrDynamicRange );
     307      getTrQuant()->setScalingList( &m_ppcTEncTop[m_cVPS.getLayerIdxInVps(refLayerId)]->getSPS()->getScalingList(), m_cSPS.getChromaFormatIdc(), maxLog2TrDynamicRange, m_cVPS.getBitDepths(&m_cSPS, m_layerId) );
    308308    }
    309309    else
     
    314314    m_cPPS.setScalingListPresentFlag(false);
    315315
    316     getTrQuant()->setScalingList(&(m_cSPS.getScalingList()), m_cSPS.getChromaFormatIdc(), maxLog2TrDynamicRange);
     316    getTrQuant()->setScalingList(&(m_cSPS.getScalingList()), m_cSPS.getChromaFormatIdc(), maxLog2TrDynamicRange, m_cSPS.getBitDepths());
    317317#if SVC_EXTENSION
    318318    }
     
    334334
    335335      // infer the scaling list from the reference layer
    336       getTrQuant()->setScalingList( &m_ppcTEncTop[m_cVPS.getLayerIdxInVps(refLayerId)]->getSPS()->getScalingList(), m_cSPS.getChromaFormatIdc(), maxLog2TrDynamicRange );
     336      getTrQuant()->setScalingList( &m_ppcTEncTop[m_cVPS.getLayerIdxInVps(refLayerId)]->getSPS()->getScalingList(), m_cSPS.getChromaFormatIdc(), maxLog2TrDynamicRange, m_cVPS.getBitDepths(&m_cSPS, m_layerId) );
    337337    }
    338338    else
     
    349349    m_cSPS.setScalingListPresentFlag(m_cSPS.getScalingList().checkDefaultScalingList());
    350350    m_cPPS.setScalingListPresentFlag(false);
    351     getTrQuant()->setScalingList(&(m_cSPS.getScalingList()), m_cSPS.getChromaFormatIdc(), maxLog2TrDynamicRange);
     351    getTrQuant()->setScalingList(&(m_cSPS.getScalingList()), m_cSPS.getChromaFormatIdc(), maxLog2TrDynamicRange, m_cSPS.getBitDepths());
    352352#if SVC_EXTENSION
    353353    }
     
    720720
    721721          UInt refLayerId = m_cVPS.getRefLayerId(m_layerId, i);
    722           Bool sameBitDepths = ( g_bitDepthLayer[CHANNEL_TYPE_LUMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_LUMA][refLayerId] ) && ( g_bitDepthLayer[CHANNEL_TYPE_CHROMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_CHROMA][refLayerId] );
     722
     723          const Int bitDepthLuma = m_cVPS.getBitDepth(CHANNEL_TYPE_LUMA, &m_cSPS, m_layerId);
     724          const Int bitDepthChroma = m_cVPS.getBitDepth(CHANNEL_TYPE_CHROMA, &m_cSPS, m_layerId);
     725          const Int refBitDepthLuma = m_cVPS.getBitDepth(CHANNEL_TYPE_LUMA, pcEncTopBase->getSPS(), refLayerId);
     726          const Int refBitDepthChroma = m_cVPS.getBitDepth(CHANNEL_TYPE_CHROMA, pcEncTopBase->getSPS(), refLayerId);
     727
     728          Bool sameBitDepths = ( bitDepthLuma == refBitDepthLuma ) && ( bitDepthChroma == refBitDepthChroma );
    723729
    724730          if( m_iSourceWidth == pcEncTopBase->getSourceWidth() && m_iSourceHeight == pcEncTopBase->getSourceHeight() && equalOffsets && zeroPhase )
     
    767773
    768774          UInt refLayerId = m_cVPS.getRefLayerId(m_layerId, i);
    769           Bool sameBitDepths = ( g_bitDepthLayer[CHANNEL_TYPE_LUMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_LUMA][refLayerId] ) && ( g_bitDepthLayer[CHANNEL_TYPE_CHROMA][m_layerId] == g_bitDepthLayer[CHANNEL_TYPE_CHROMA][refLayerId] );
     775
     776          const Int bitDepthLuma = m_cVPS.getBitDepth(CHANNEL_TYPE_LUMA, &m_cSPS, m_layerId);
     777          const Int bitDepthChroma = m_cVPS.getBitDepth(CHANNEL_TYPE_CHROMA, &m_cSPS, m_layerId);
     778          const Int refBitDepthLuma = m_cVPS.getBitDepth(CHANNEL_TYPE_LUMA, pcEncTopBase->getSPS(), refLayerId);
     779          const Int refBitDepthChroma = m_cVPS.getBitDepth(CHANNEL_TYPE_CHROMA, pcEncTopBase->getSPS(), refLayerId);
     780
     781          Bool sameBitDepths = ( bitDepthLuma == refBitDepthLuma ) && ( bitDepthChroma == refBitDepthChroma );
    770782
    771783          if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !sameBitDepths
     
    858870  profileTierLevel.setLowerBitRateConstraintFlag(m_lowerBitRateConstraintFlag);
    859871
    860   if ((m_profile == Profile::MAIN10) && (g_bitDepth[CHANNEL_TYPE_LUMA] == 8) && (g_bitDepth[CHANNEL_TYPE_CHROMA] == 8))
     872  if ((m_profile == Profile::MAIN10) && (m_bitDepth[CHANNEL_TYPE_LUMA] == 8) && (m_bitDepth[CHANNEL_TYPE_CHROMA] == 8))
    861873  {
    862874    /* The above constraint is equal to Profile::MAIN */
     
    914926    m_cSPS.setBitDepth    (ChannelType(channelType), m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_cVPS.getLayerIdxInVps( m_layerId ) ) )->getBitDepthVps(ChannelType(channelType))            );
    915927    m_cSPS.setQpBDOffset  (ChannelType(channelType), (6 * (m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_cVPS.getLayerIdxInVps( m_layerId ) ) )->getBitDepthVps(ChannelType(channelType)) - 8)));
     928#if O0043_BEST_EFFORT_DECODING
     929    m_cSPS.setStreamBitDepth(ChannelType(channelType), m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_cVPS.getLayerIdxInVps( m_layerId ) ) )->getBitDepthVps(ChannelType(channelType)) );
     930#endif
    916931#else
    917     m_cSPS.setBitDepth    (ChannelType(channelType), g_bitDepth[channelType]            );
    918     m_cSPS.setQpBDOffset  (ChannelType(channelType), (6 * (g_bitDepth[channelType] - 8)));
     932#if O0043_BEST_EFFORT_DECODING
     933    m_cSPS.setStreamBitDepth(ChannelType(channelType), m_bitDepth[channelType] );
     934#endif
     935    m_cSPS.setQpBDOffset  (ChannelType(channelType), (6 * (m_bitDepth[channelType] - 8)));
    919936#endif
    920937    m_cSPS.setPCMBitDepth (ChannelType(channelType), m_PCMBitDepth[channelType]         );
     
    940957  for (Int i = 0; i < min(m_cSPS.getMaxTLayers(),(UInt) MAX_TLAYER); i++ )
    941958  {
    942 #if SVC_EXTENSION
    943     assert(i < MAX_TLAYER);
    944 #endif
    945959    m_cSPS.setMaxDecPicBuffering(m_maxDecPicBuffering[i], i);
    946960    m_cSPS.setNumReorderPics(m_numReorderPics[i], i);
     
    14871501{
    14881502  RepFormat *repFormat = m_cVPS.getVpsRepFormat( m_cSPS.getUpdateRepFormatFlag() ? m_cSPS.getUpdateRepFormatIndex() : m_cVPS.getVpsRepFormatIdx( m_cVPS.getLayerIdxInVps(m_layerId) ) );
    1489   Int bitDepthY,bitDepthC;
    1490 
    1491   bitDepthY   = repFormat->getBitDepthVpsLuma();
    1492   bitDepthC   = repFormat->getBitDepthVpsChroma();
    14931503 
    14941504  if( m_layerId > 0 )
    14951505  {
    1496     g_bitDepth[CHANNEL_TYPE_LUMA]   = bitDepthY;
    1497     g_bitDepth[CHANNEL_TYPE_CHROMA] = bitDepthC;
    14981506    g_uiMaxCUWidth  = m_cSPS.getMaxCUWidth();
    14991507    g_uiMaxCUHeight = m_cSPS.getMaxCUHeight();
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.h

    r1259 r1287  
    116116  static Int              m_iPPSIdCnt;                    ///< next Id number for PPS   
    117117  TEncTop**               m_ppcTEncTop;
    118   TEncTop*                getLayerEnc(UInt layerIdx)       { return m_ppcTEncTop[layerIdx]; }
     118  TEncTop*                getLayerEnc(UInt layerIdx)      { return m_ppcTEncTop[layerIdx]; }
    119119  TComPic*                m_cIlpPic[MAX_NUM_REF];                    ///<  Inter layer Prediction picture =  upsampled picture
    120120  Bool                    m_bMFMEnabledFlag;
     
    276276               std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff);
    277277
    278   Void printSummary(Bool isField) { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded, isField, m_printMSEBasedSequencePSNR, m_printSequenceMSE); }
     278  Void printSummary(Bool isField) { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded, isField, m_printMSEBasedSequencePSNR, m_printSequenceMSE, m_cSPS.getBitDepths()); }
    279279#endif //#if SVC_EXTENSION
    280280};
  • branches/SHM-dev/source/Lib/TLibEncoder/WeightPredAnalysis.cpp

    r1260 r1287  
    215215    for ( Int refIdxTemp = 0; refIdxTemp < slice->getNumRefIdx(eRefPicList); refIdxTemp++ )
    216216    {
    217       WPACDCParam *currWeightACDCParam, *refWeightACDCParam;
    218       slice->getWpAcDcParam(currWeightACDCParam);
    219       slice->getRefPic(eRefPicList, refIdxTemp)->getSlice(0)->getWpAcDcParam(refWeightACDCParam);
     217      WPACDCParam *currWeightACDCParam = slice->getWpAcDcParam();
     218      WPACDCParam *refWeightACDCParam  = slice->getRefPic(eRefPicList, refIdxTemp)->getSlice(0)->getWpAcDcParam();
    220219
    221220#if SVC_EXTENSION
     
    226225      if( validILRPic )
    227226      {
    228         refWeightACDCParam = (WPACDCParam *)g_refWeightACDCParam;
     227        refWeightACDCParam = slice->getWpAcDcParam();
    229228      }
    230229#endif
     
    233232      {
    234233        const ComponentID compID        = ComponentID(comp);
    235         const Int         range         = bUseHighPrecisionWeighting ? (1<<g_bitDepth[toChannelType(compID)])/2 : 128;
    236         const Int         realLog2Denom = log2Denom + (bUseHighPrecisionWeighting ? RExt__PREDICTION_WEIGHTING_ANALYSIS_DC_PRECISION : (g_bitDepth[toChannelType(compID)] - 8));
     234#if SVC_EXTENSION
     235        const Int         bitDepth      = slice->getBitDepth(toChannelType(compID));
     236#else
     237        const Int         bitDepth      = slice->getSPS()->getBitDepth(toChannelType(compID));
     238#endif
     239        const Int         range         = bUseHighPrecisionWeighting ? (1<<bitDepth)/2 : 128;
     240        const Int         realLog2Denom = log2Denom + (bUseHighPrecisionWeighting ? RExt__PREDICTION_WEIGHTING_ANALYSIS_DC_PRECISION : (bitDepth - 8));
    237241        const Int         realOffset    = ((Int)1<<(realLog2Denom-1));
    238242
     
    249253          refAC = ( refAC * currWeightACDCParam[comp].iSamples ) /refWeightACDCParam[comp].iSamples;
    250254
     255          const Int bitDepthLuma = slice->getBitDepth(CHANNEL_TYPE_LUMA);
     256          const Int refBitDepthLuma  = slice->getRefPic(eRefPicList, refIdxTemp)->getSlice(0)->getBitDepth(CHANNEL_TYPE_LUMA);
     257          const Int delta = bitDepthLuma - refBitDepthLuma;
     258
    251259          // jonint upsampling bitshift
    252           refAC <<= (g_bitDepthLayer[CHANNEL_TYPE_LUMA][currLayerId] - g_bitDepthLayer[CHANNEL_TYPE_LUMA][refLayerId]);
    253           refDC <<= (g_bitDepthLayer[CHANNEL_TYPE_LUMA][currLayerId] - g_bitDepthLayer[CHANNEL_TYPE_LUMA][refLayerId]);
     260          refAC <<= delta;
     261          refDC <<= delta;
    254262        }
    255263#else
     
    345353        const Int          iWidth     = pPic->getWidth(compID);
    346354        const Int          iHeight    = pPic->getHeight(compID);
    347         const Int          bitDepth   = g_bitDepth[toChannelType(compID)];
     355#if SVC_EXTENSION
     356        const Int          bitDepth   = slice->getBitDepth(toChannelType(compID));
     357#else
     358        const Int          bitDepth   = slice->getSPS()->getBitDepth(toChannelType(compID));
     359#endif
    348360
    349361        // calculate SAD costs with/without wp for luma
Note: See TracChangeset for help on using the changeset viewer.