Ticket #286: source286.patch

File source286.patch, 10.5 KB (added by fbossen, 11 years ago)
  • source/Lib/TLibEncoder/TEncCu.h

     
    115115  /// CU encoding function
    116116  Void  encodeCU            ( TComDataCU*    pcCU, Bool bForceTerminate = false  );
    117117 
     118  Void setBitCounter        ( TComBitCounter* pcBitCounter ) { m_pcBitCounter = pcBitCounter; }
    118119protected:
    119120#if FINE_GRANULARITY_SLICES
    120121  Void  finishCU            ( TComDataCU*  pcCU, UInt uiAbsPartIdx,           UInt uiDepth        );
  • source/Lib/TLibEncoder/TEncSlice.cpp

     
    10731073      m_pcEntropyCoder->setEntropyCoder ( m_pppcRDSbacCoder[0][CI_CURR_BEST], pcSlice );
    10741074#if OL_USE_WPP
    10751075      m_pcEntropyCoder->setBitstream( &pcBitCounters[uiSubStrm] );
     1076      m_pcCuEncoder->setBitCounter( &pcBitCounters[uiSubStrm] );
     1077      m_pcBitCounter = &pcBitCounters[uiSubStrm];
    10761078#else
    10771079      m_pcEntropyCoder->setBitstream    ( m_pcBitCounter );
    10781080#endif
     
    10851087
    10861088      pppcRDSbacCoder->setBinCountingEnableFlag( false );
    10871089#if FINE_GRANULARITY_SLICES
    1088       if (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE && ( ( pcSlice->getSliceBits() + m_pcBitCounter->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3)
     1090      if (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE && ( ( pcSlice->getSliceBits() + m_pcEntropyCoder->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3)
    10891091      {
    10901092#else
    1091       uiBitsCoded += m_pcBitCounter->getNumberOfWrittenBits();
     1093      uiBitsCoded += m_pcEntropyCoder->getNumberOfWrittenBits();
    10921094      if (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE && ( ( pcSlice->getSliceBits() + uiBitsCoded ) >> 3 ) > m_pcCfg->getSliceArgument())
    10931095      {
    10941096#if TILES
    10951097        if (uiCUAddr == rpcPic->getPicSym()->getCUOrderMap(uiStartCUAddr) && pcSlice->getSliceBits()==0)
    10961098        {
    10971099          // Could not fit even a single LCU within the slice under the defined byte-constraint. Display a warning message and code 1 LCU in the slice.
    1098           fprintf(stdout,"\nSlice overflow warning! codedBits=%6d, limitBytes=%6d", m_pcBitCounter->getNumberOfWrittenBits(), m_pcCfg->getSliceArgument() );
     1100          fprintf(stdout,"\nSlice overflow warning! codedBits=%6d, limitBytes=%6d", m_pcEntropyCoder->getNumberOfWrittenBits(), m_pcCfg->getSliceArgument() );
    10991101          uiEncCUOrder++;
    11001102        }
    11011103#else
    11021104        if (uiCUAddr==uiStartCUAddr && pcSlice->getSliceBits()==0)
    11031105        {
    11041106          // Could not fit even a single LCU within the slice under the defined byte-constraint. Display a warning message and code 1 LCU in the slice.
    1105           fprintf(stdout,"Slice overflow warning! codedBits=%6d, limitBytes=%6d\n", m_pcBitCounter->getNumberOfWrittenBits(), m_pcCfg->getSliceArgument() );
     1107          fprintf(stdout,"Slice overflow warning! codedBits=%6d, limitBytes=%6d\n", m_pcEntropyCoder->getNumberOfWrittenBits(), m_pcCfg->getSliceArgument() );
    11061108          uiCUAddr = uiCUAddr + 1;
    11071109        }
    11081110#endif
     
    11351137#endif
    11361138#endif
    11371139#if !FINE_GRANULARITY_SLICES
    1138         uiBitsCoded -= m_pcBitCounter->getNumberOfWrittenBits();
     1140        uiBitsCoded -= m_pcEntropyCoder->getNumberOfWrittenBits();
    11391141#endif
    11401142        pcSlice->setNextEntropySlice( true );
    11411143        break;
     
    11781180      m_pcCuEncoder->compressCU( pcCU );
    11791181      m_pcCavlcCoder ->setAdaptFlag(true);
    11801182      m_pcCuEncoder->encodeCU( pcCU );
    1181      
    11821183#if FINE_GRANULARITY_SLICES
    1183       if (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE && ( ( pcSlice->getSliceBits()+ m_pcBitCounter->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3)
     1184      if (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE && ( ( pcSlice->getSliceBits()+ m_pcEntropyCoder->getNumberOfWrittenBits() ) ) > m_pcCfg->getSliceArgument()<<3)
    11841185      {
    11851186#else
    1186       uiBitsCoded += m_pcBitCounter->getNumberOfWrittenBits();
     1187      uiBitsCoded += m_pcEntropyCoder->getNumberOfWrittenBits();
    11871188      if (m_pcCfg->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE && ( ( pcSlice->getSliceBits() + uiBitsCoded ) >> 3 ) > m_pcCfg->getSliceArgument())
    11881189      {
    11891190#if TILES
    11901191        if (uiCUAddr == rpcPic->getPicSym()->getCUOrderMap(uiStartCUAddr) && pcSlice->getSliceBits()==0)
    11911192        {
    11921193          // Could not fit even a single LCU within the slice under the defined byte-constraint. Display a warning message and code 1 LCU in the slice.
    1193           fprintf(stdout,"\nSlice overflow warning! codedBits=%6d, limitBytes=%6d", m_pcBitCounter->getNumberOfWrittenBits(), m_pcCfg->getSliceArgument() );
     1194          fprintf(stdout,"\nSlice overflow warning! codedBits=%6d, limitBytes=%6d", m_pcEntropyCoder->getNumberOfWrittenBits(), m_pcCfg->getSliceArgument() );
    11941195          uiEncCUOrder++;
    11951196        }
    11961197#else
    11971198        if (uiCUAddr==uiStartCUAddr && pcSlice->getSliceBits()==0)
    11981199        {
    11991200          // Could not fit even a single LCU within the slice under the defined byte-constraint. Display a warning message and code 1 LCU in the slice.
    1200           fprintf(stdout,"Slice overflow warning! codedBits=%6d, limitBytes=%6d\n", m_pcBitCounter->getNumberOfWrittenBits(), m_pcCfg->getSliceArgument() );
     1201          fprintf(stdout,"Slice overflow warning! codedBits=%6d, limitBytes=%6d\n", m_pcEntropyCoder->getNumberOfWrittenBits(), m_pcCfg->getSliceArgument() );
    12011202          uiCUAddr = uiCUAddr + 1;
    12021203        }
    12031204#endif
     
    12061207        break;
    12071208      }
    12081209#if FINE_GRANULARITY_SLICES
    1209       if (m_pcCfg->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE && pcSlice->getEntropySliceCounter()+ m_pcBitCounter->getNumberOfWrittenBits()> m_pcCfg->getEntropySliceArgument()&&pcSlice->getSliceCurEndCUAddr()!=pcSlice->getEntropySliceCurEndCUAddr())
     1210      if (m_pcCfg->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE && pcSlice->getEntropySliceCounter()+ m_pcEntropyCoder->getNumberOfWrittenBits()> m_pcCfg->getEntropySliceArgument()&&pcSlice->getSliceCurEndCUAddr()!=pcSlice->getEntropySliceCurEndCUAddr())
    12101211      {
    12111212
    12121213#else
     
    12161217        if (uiCUAddr == rpcPic->getPicSym()->getCUOrderMap(uiStartCUAddr))
    12171218        {
    12181219          // Could not fit even a single LCU within the entropy slice under the defined bit/bin-constraint. Display a warning message and code 1 LCU in the entropy slice.
    1219           fprintf(stdout,"\nEntropy Slice overflow warning! codedBits=%6d, limitBits=%6d", m_pcBitCounter->getNumberOfWrittenBits(), m_pcCfg->getEntropySliceArgument() );
     1220          fprintf(stdout,"\nEntropy Slice overflow warning! codedBits=%6d, limitBits=%6d", m_pcEntropyCoder->getNumberOfWrittenBits(), m_pcCfg->getEntropySliceArgument() );
    12201221          uiEncCUOrder++;
    12211222        }
    12221223#else
    12231224        if (uiCUAddr == uiStartCUAddr)
    12241225        {
    12251226          // Could not fit even a single LCU within the entropy slice under the defined bit/bin-constraint. Display a warning message and code 1 LCU in the entropy slice.
    1226           fprintf(stdout,"Entropy Slice overflow warning! codedBits=%6d, limitBits=%6d\n", m_pcBitCounter->getNumberOfWrittenBits(), m_pcCfg->getEntropySliceArgument() );
     1227          fprintf(stdout,"Entropy Slice overflow warning! codedBits=%6d, limitBits=%6d\n", m_pcEntropyCoder->getNumberOfWrittenBits(), m_pcCfg->getEntropySliceArgument() );
    12271228          uiCUAddr = uiCUAddr + 1;
    12281229        }
    12291230#endif
    12301231#endif
    12311232
    12321233#if !FINE_GRANULARITY_SLICES
    1233         uiBitsCoded -= m_pcBitCounter->getNumberOfWrittenBits();
     1234        uiBitsCoded -= m_pcEntropyCoder->getNumberOfWrittenBits();
    12341235#endif
    12351236        pcSlice->setNextEntropySlice( true );
    12361237        break;
     
    13021303#endif
    13031304 
    13041305#if OL_USE_WPP
     1306  m_pcCuEncoder->setBitCounter( NULL );
     1307  m_pcBitCounter = NULL;
    13051308  // Appropriate substream bitstream is switched later.
    13061309#else
    13071310  // set bitstream
  • source/Lib/TLibEncoder/TEncCu.cpp

     
    11371137    m_pcEntropyCoder->encodeSliceFinish();
    11381138  }
    11391139#endif
     1140 
     1141  Int numberOfWrittenBits = 0;
     1142  if (m_pcBitCounter)
     1143  {
     1144    numberOfWrittenBits = m_pcEntropyCoder->getNumberOfWrittenBits();
     1145  }
     1146 
    11401147  // Calculate slice end IF this CU puts us over slice bit size.
    11411148  unsigned iGranularitySize = pcCU->getPic()->getNumPartInCU()>>(pcSlice->getPPS()->getSliceGranularity()<<1);
    11421149  int iGranularityEnd = ((pcCU->getSCUAddr()+uiAbsPartIdx)/iGranularitySize)*iGranularitySize;
     
    11451152    iGranularityEnd+=max(iGranularitySize,(pcCU->getPic()->getNumPartInCU()>>(uiDepth<<1)));
    11461153  }
    11471154  // Set slice end parameter
    1148   if(pcSlice->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE&&!pcSlice->getFinalized()&&pcSlice->getSliceBits()+m_pcBitCounter->getNumberOfWrittenBits()>pcSlice->getSliceArgument()<<3)
     1155  if(pcSlice->getSliceMode()==AD_HOC_SLICES_FIXED_NUMBER_OF_BYTES_IN_SLICE&&!pcSlice->getFinalized()&&pcSlice->getSliceBits()+numberOfWrittenBits>pcSlice->getSliceArgument()<<3)
    11491156  {
    11501157    pcSlice->setEntropySliceCurEndCUAddr(iGranularityEnd);
    11511158    pcSlice->setSliceCurEndCUAddr(iGranularityEnd);
     
    11641171  }
    11651172  else
    11661173  {
    1167     if(pcSlice->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE&&!pcSlice->getFinalized()&&pcSlice->getEntropySliceCounter()+m_pcBitCounter->getNumberOfWrittenBits()>pcSlice->getEntropySliceArgument())
     1174    if(pcSlice->getEntropySliceMode()==SHARP_MULTIPLE_CONSTRAINT_BASED_ENTROPY_SLICE&&!pcSlice->getFinalized()&&pcSlice->getEntropySliceCounter()+numberOfWrittenBits>pcSlice->getEntropySliceArgument())
    11681175    {
    11691176      pcSlice->setEntropySliceCurEndCUAddr(iGranularityEnd);
    11701177      return;
     
    11721179  }
    11731180  if(granularityBoundary)
    11741181  {
    1175     pcSlice->setSliceBits( (UInt)(pcSlice->getSliceBits() + m_pcBitCounter->getNumberOfWrittenBits()) );
     1182    pcSlice->setSliceBits( (UInt)(pcSlice->getSliceBits() + numberOfWrittenBits) );
    11761183    if(m_pcEncCfg->getUseSBACRD())
    11771184    {
    11781185      TEncBinCABAC *pppcRDSbacCoder = (TEncBinCABAC *) m_pppcRDSbacCoder[0][CI_CURR_BEST]->getEncBinIf();
     
    11811188    }
    11821189    else
    11831190    {
    1184       pcSlice->setEntropySliceCounter(pcSlice->getEntropySliceCounter()+m_pcBitCounter->getNumberOfWrittenBits());
     1191      pcSlice->setEntropySliceCounter(pcSlice->getEntropySliceCounter()+numberOfWrittenBits);
    11851192    }
    1186     m_pcBitCounter->resetBits();
     1193    if (m_pcBitCounter)
     1194    {
     1195      m_pcEntropyCoder->resetBits();     
     1196    }
    11871197  }
    11881198}
    11891199#endif