Changeset 880 in SHVCSoftware for branches


Ignore:
Timestamp:
29 Aug 2014, 23:48:19 (10 years ago)
Author:
seregin
Message:

port rev 4061 from RExt to solve WPP problem related to ticket #35, macro is WPP_FIX

Location:
branches/SHM-dev/source/Lib
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/Lib/TLibCommon/TComPic.cpp

    r869 r880  
    400400#endif
    401401
     402#if WPP_FIX
     403UInt TComPic::getSubstreamForLCUAddr(const UInt uiLCUAddr, const Bool bAddressInRaster, TComSlice *pcSlice)
     404{
     405  const Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
     406  UInt uiSubStrm;
     407
     408  if (iNumSubstreams > 1) // wavefronts, and possibly tiles being used.
     409  {
     410    TComPicSym &picSym=*(getPicSym());
     411    const UInt uiLCUAddrRaster = bAddressInRaster?uiLCUAddr : picSym.getCUOrderMap(uiLCUAddr);
     412    const UInt uiWidthInLCUs  = picSym.getFrameWidthInCU();
     413    const UInt uiTileIndex=picSym.getTileIdxMap(uiLCUAddrRaster);
     414    const UInt widthInTiles=(picSym.getNumColumnsMinus1()+1);
     415    TComTile *pTile=picSym.getTComTile(uiTileIndex);
     416    const UInt uiTileStartLCU = pTile->getFirstCUAddr();
     417    const UInt uiTileLCUY = uiTileStartLCU / uiWidthInLCUs;
     418    // independent tiles => substreams are "per tile".  iNumSubstreams has already been multiplied.
     419    const UInt uiLin = uiLCUAddrRaster / uiWidthInLCUs;
     420          UInt uiStartingSubstreamForTile=(uiTileLCUY*widthInTiles) + (pTile->getTileHeight()*(uiTileIndex%widthInTiles));
     421    uiSubStrm = uiStartingSubstreamForTile + (uiLin-uiTileLCUY);
     422  }
     423  else
     424  {
     425    // dependent tiles => substreams are "per frame".
     426    uiSubStrm = 0;//uiLin % iNumSubstreams; // x modulo 1 = 0 !
     427  }
     428  return uiSubStrm;
     429}
     430#endif
     431
     432
    402433//! \}
  • branches/SHM-dev/source/Lib/TLibCommon/TComPic.h

    r820 r880  
    223223  Void setCurrAuFlag(Bool x) {m_currAuFlag = x; }
    224224#endif
     225#if WPP_FIX
     226  UInt          getSubstreamForLCUAddr(const UInt uiLCUAddr, const Bool bAddressInRaster, TComSlice *pcSlice);
     227#endif
    225228};// END CLASS DEFINITION TComPic
    226229
  • branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h

    r877 r880  
    274274  AUX_ID            = 3,
    275275};
     276
     277#define WPP_FIX                          1
    276278
    277279/// normative encoder constraints --------
  • branches/SHM-dev/source/Lib/TLibDecoder/TDecSlice.cpp

    r834 r880  
    146146  UInt uiTilesAcross   = rpcPic->getPicSym()->getNumColumnsMinus1()+1;
    147147  TComSlice*  pcSlice = rpcPic->getSlice(rpcPic->getCurrSliceIdx());
     148#if !WPP_FIX
    148149  Int  iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
     150#endif
    149151
    150152  // delete decoders if already allocated in previous slice
     
    193195  UInt uiWidthInLCUs  = rpcPic->getPicSym()->getFrameWidthInCU();
    194196  //UInt uiHeightInLCUs = rpcPic->getPicSym()->getFrameHeightInCU();
     197
     198#if WPP_FIX
     199  UInt uiTileCol;
     200  UInt uiTileLCUX;
     201  const Bool depSliceSegmentsEnabled = rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceSegmentsEnabledFlag();
     202  const UInt startTileIdx=rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr);
     203  TComTile *pCurrentTile=rpcPic->getPicSym()->getTComTile(startTileIdx);
     204  UInt uiTileStartLCU = pCurrentTile->getFirstCUAddr(); // Code tidy
     205
     206  // The first LCU of the slice is the first coded substream, but the global substream number, as calculated by getSubstreamForLCUAddr may be higher.
     207  // This calculates the common offset for all substreams in this slice.
     208  const UInt subStreamOffset=rpcPic->getSubstreamForLCUAddr(iStartCUAddr, true, pcSlice);
     209#else
    195210  UInt uiCol=0, uiLin=0, uiSubStrm=0;
    196211
     
    201216  Bool depSliceSegmentsEnabled = rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceSegmentsEnabledFlag();
    202217  uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr();
     218#endif
    203219  if( depSliceSegmentsEnabled )
    204220  {
     221#if WPP_FIX
     222    if( (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->isNextSlice()) && iStartCUAddr != uiTileStartLCU)  // Code tidy // Is this a dependent slice segment and not the start of a tile?
     223#else
    205224    if( (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->isNextSlice()) &&
    206225       iStartCUAddr != rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr())
     226#endif
    207227    {
    208228      if(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())
    209229      {
     230#if WPP_FIX
     231        uiTileCol = startTileIdx % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // Code tidy
     232#else
    210233        uiTileCol = rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1);
     234#endif
    211235        m_pcBufferSbacDecoders[uiTileCol].loadContexts( CTXMem[1]  );//2.LCU
     236#if WPP_FIX
     237        if ( pCurrentTile->getTileWidth() < 2)
     238        {
     239          CTXMem[0]->loadContexts(pcSbacDecoder); // If tile width is less than 2, need to ensure CTX states get initialised to un-adapted CABAC. Set here, to load a few lines later (!)
     240        }
     241#else
    212242        if ( (iStartCUAddr%uiWidthInLCUs+1) >= uiWidthInLCUs  )
    213243        {
     
    219249          }
    220250        }
     251#endif
    221252      }
    222253      pcSbacDecoder->loadContexts(CTXMem[0] ); //end of depSlice-1
     254#if WPP_FIX
     255      pcSbacDecoders[0].loadContexts(pcSbacDecoder); // The first substream used for the slice will always be 0. (The original code was equivalent)
     256#else
    223257      pcSbacDecoders[uiSubStrm].loadContexts(pcSbacDecoder);
     258#endif
    224259    }
    225260    else
     
    239274    uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr();
    240275    uiTileLCUX = uiTileStartLCU % uiWidthInLCUs;
     276#if WPP_FIX
     277    UInt uiCol     = iCUAddr % uiWidthInLCUs;
     278    UInt uiSubStrm=rpcPic->getSubstreamForLCUAddr(iCUAddr, true, pcSlice)-subStreamOffset;
     279#else
    241280    uiCol     = iCUAddr % uiWidthInLCUs;
    242281    // The 'line' is now relative to the 1st line in the slice, not the 1st line in the picture.
    243282    uiLin     = (iCUAddr/uiWidthInLCUs)-(iStartCUAddr/uiWidthInLCUs);
     283#endif
    244284    // inherit from TR if necessary, select substream to use.
    245285    if( (pcSlice->getPPS()->getNumSubstreams() > 1) || ( depSliceSegmentsEnabled  && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) ))
    246286    {
     287#if !WPP_FIX
    247288      // independent tiles => substreams are "per tile".  iNumSubstreams has already been multiplied.
    248289      iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles();
    249290      uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(iCUAddr)*iNumSubstreamsPerTile
    250291                  + uiLin%iNumSubstreamsPerTile;
     292#endif
    251293      m_pcEntropyDecoder->setBitstream( ppcSubstreams[uiSubStrm] );
    252294      // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line.
     
    280322      pcSbacDecoder->load(&pcSbacDecoders[uiSubStrm]);  //this load is used to simplify the code (avoid to change all the call to pcSbacDecoders)
    281323    }
     324#if !WPP_FIX
    282325    else if ( pcSlice->getPPS()->getNumSubstreams() <= 1 )
    283326    {
     
    285328      iNumSubstreamsPerTile = 1;
    286329    }
     330#endif
    287331
    288332    if ( (iCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr()) && // 1st in tile.
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp

    r878 r880  
    24272427  }
    24282428  UInt numEntryPointOffsets = 0, offsetLenMinus1 = 0, maxOffset = 0;
     2429#if !WPP_FIX
    24292430  Int  numZeroSubstreamsAtStartOfSlice  = 0;
     2431#endif
    24302432  UInt *entryPointOffset = NULL;
    24312433  if ( pSlice->getPPS()->getTilesEnabledFlag() )
     
    24542456    UInt* pSubstreamSizes               = pSlice->getSubstreamSizes();
    24552457    Int maxNumParts                       = pSlice->getPic()->getNumPartInCU();
     2458#if WPP_FIX
     2459    Int  numZeroSubstreamsAtStartOfSlice  = pSlice->getPic()->getSubstreamForLCUAddr(pSlice->getSliceSegmentCurStartCUAddr()/maxNumParts, false, pSlice);
     2460    Int  subStreamOfLastSegmentOfSlice    = pSlice->getPic()->getSubstreamForLCUAddr((pSlice->getSliceSegmentCurEndCUAddr()/maxNumParts)-1, false, pSlice);
     2461    numEntryPointOffsets                  = subStreamOfLastSegmentOfSlice-numZeroSubstreamsAtStartOfSlice;
     2462#else
    24562463    numZeroSubstreamsAtStartOfSlice       = pSlice->getSliceSegmentCurStartCUAddr()/maxNumParts/pSlice->getPic()->getFrameWidthInCU();
    24572464    Int  numZeroSubstreamsAtEndOfSlice    = pSlice->getPic()->getFrameHeightInCU()-1 - ((pSlice->getSliceSegmentCurEndCUAddr()-1)/maxNumParts/pSlice->getPic()->getFrameWidthInCU());
    24582465    numEntryPointOffsets                  = pSlice->getPPS()->getNumSubstreams() - numZeroSubstreamsAtStartOfSlice - numZeroSubstreamsAtEndOfSlice - 1;
     2466#endif
    24592467    pSlice->setNumEntryPointOffsets(numEntryPointOffsets);
    24602468    entryPointOffset           = new UInt[numEntryPointOffsets];
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r877 r880  
    20862086
    20872087    // Allocate some coders, now we know how many tiles there are.
     2088#if WPP_FIX
     2089    const Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
     2090#else
    20882091    Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
     2092#endif
    20892093
    20902094    //generate the Coding Order Map and Inverse Coding Order Map
     
    27992803            m_pcEntropyCoder->setEntropyCoder ( m_pcSbacCoder, pcSlice );
    28002804            m_pcEntropyCoder->resetEntropy    ();
     2805#if WPP_FIX
     2806            for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ )
     2807#else
    28012808            for ( UInt ui = 0 ; ui < pcSlice->getPPS()->getNumSubstreams() ; ui++ )
     2809#endif
    28022810            {
    28032811              m_pcEntropyCoder->setEntropyCoder ( &pcSbacCoders[ui], pcSlice );
     
    28112819            m_pcSbacCoder->init( (TEncBinIf*)m_pcBinCABAC );
    28122820            {
     2821#if WPP_FIX
     2822              for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ )
     2823#else
    28132824              for ( UInt ui = 0 ; ui < pcSlice->getPPS()->getNumSubstreams() ; ui++ )
     2825#endif
    28142826              {
    28152827                m_pcEntropyCoder->setEntropyCoder ( &pcSbacCoders[ui], pcSlice );
     
    28382850
    28392851          pcSlice->setTileOffstForMultES( uiOneBitstreamPerSliceLength );
    2840             pcSlice->setTileLocationCount ( 0 );
     2852          pcSlice->setTileLocationCount ( 0 );
    28412853          m_pcSliceEncoder->encodeSlice(pcPic, pcSubstreamsOut);
    28422854
     
    28652877
    28662878              Bool bNextSubstreamInNewTile = ((ui+1) < iNumSubstreams)&& ((ui+1)%uiNumSubstreamsPerTile == 0);
     2879#if WPP_FIX
     2880              if (bNextSubstreamInNewTile &&  !pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag() )
     2881#else
    28672882              if (bNextSubstreamInNewTile)
     2883#endif
    28682884              {
    28692885                pcSlice->setTileLocation(ui/uiNumSubstreamsPerTile, pcSlice->getTileOffstForMultES()+(uiTotalCodedSize>>3));
    28702886              }
     2887#if WPP_FIX
     2888              if (ui+1 < iNumSubstreams)
     2889              {
     2890                puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits() + (pcSubstreamsOut[ui].countStartCodeEmulations()<<3);
     2891              }
     2892#else
    28712893              if (ui+1 < pcSlice->getPPS()->getNumSubstreams())
    28722894              {
    28732895                puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits() + (pcSubstreamsOut[ui].countStartCodeEmulations()<<3);
    28742896              }
     2897#endif
    28752898            }
    28762899
     
    28892912            // Substreams...
    28902913            TComOutputBitstream *pcOut = pcBitstreamRedirect;
    2891           Int offs = 0;
     2914#if WPP_FIX
     2915            Int numZeroSubstreamsAtStartOfSlice = 0;
     2916            Int numSubstreamsToCode = pcSlice->getPPS()->getNumSubstreams();
     2917            if (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())
     2918            {
     2919              Int  maxNumParts                      = pcPic->getNumPartInCU();
     2920              numZeroSubstreamsAtStartOfSlice  = pcPic->getSubstreamForLCUAddr(pcSlice->getSliceSegmentCurStartCUAddr()/maxNumParts, false, pcSlice);
     2921              // 1st line present for WPP.
     2922              numSubstreamsToCode  = pcSlice->getNumEntryPointOffsets()+1;
     2923            }
     2924            for ( UInt ui = 0 ; ui < numSubstreamsToCode; ui++ )
     2925            {
     2926              pcOut->addSubstream(&pcSubstreamsOut[ui+numZeroSubstreamsAtStartOfSlice]);
     2927            }
     2928#else
     2929            Int offs = 0;
    28922930          Int nss = pcSlice->getPPS()->getNumSubstreams();
    28932931          if (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())
     
    29012939            pcOut->addSubstream(&pcSubstreamsOut[ui+offs]);
    29022940            }
     2941#endif
    29032942          }
    29042943
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.cpp

    r713 r880  
    836836Void TEncSlice::compressSlice( TComPic*& rpcPic )
    837837{
     838#if !WPP_FIX
    838839  UInt  uiCUAddr;
     840#endif
    839841  UInt   uiStartCUAddr;
    840842  UInt   uiBoundingCUAddr;
     
    907909  TEncSbac**** ppppcRDSbacCoders    = pcEncTop->getRDSbacCoders();
    908910  TComBitCounter* pcBitCounters     = pcEncTop->getBitCounters();
     911#if WPP_FIX
     912  const Int  iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
     913  const UInt uiTilesAcross  = rpcPic->getPicSym()->getNumColumnsMinus1()+1;
     914#else
    909915  Int  iNumSubstreams = 1;
    910916  UInt uiTilesAcross  = 0;
     
    912918  iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
    913919  uiTilesAcross = rpcPic->getPicSym()->getNumColumnsMinus1()+1;
     920#endif
    914921  delete[] m_pcBufferSbacCoders;
    915922  delete[] m_pcBufferBinCoderCABACs;
     
    943950  UInt uiWidthInLCUs  = rpcPic->getPicSym()->getFrameWidthInCU();
    944951  //UInt uiHeightInLCUs = rpcPic->getPicSym()->getFrameHeightInCU();
     952#if WPP_FIX
     953  UInt      uiTileCol               = 0;
     954  Bool      depSliceSegmentsEnabled = pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag();
     955  UInt      uiCUAddr                = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());
     956  UInt      currentTileIdx          = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr);
     957  TComTile *pCurrentTile            = rpcPic->getPicSym()->getTComTile(currentTileIdx);
     958  UInt      uiTileStartLCU          = pCurrentTile->getFirstCUAddr();
     959#else
    945960  UInt uiCol=0, uiLin=0, uiSubStrm=0;
    946961  UInt uiTileCol      = 0;
     
    950965  uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());
    951966  uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr();
     967#endif
    952968  if( depSliceSegmentsEnabled )
    953969  {
    954970    if((pcSlice->getSliceSegmentCurStartCUAddr()!= pcSlice->getSliceCurStartCUAddr())&&(uiCUAddr != uiTileStartLCU))
    955971    {
     972#if WPP_FIX
     973      UInt uiSubStrm=0;
     974#endif
    956975      if( m_pcCfg->getWaveFrontsynchro() )
    957976      {
     977#if WPP_FIX
     978        uiTileCol = currentTileIdx % (rpcPic->getPicSym()->getNumColumnsMinus1()+1);
     979         m_pcBufferSbacCoders[uiTileCol].loadContexts( CTXMem[1] );
     980         //uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());
     981         uiSubStrm=rpcPic->getSubstreamForLCUAddr(uiCUAddr, true, pcSlice);
     982         if ( pCurrentTile->getTileWidth() < 2)
     983         {
     984           CTXMem[0]->loadContexts(m_pcSbacCoder);
     985         }
     986#else
    958987        uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1);
    959988        m_pcBufferSbacCoders[uiTileCol].loadContexts( CTXMem[1] );
     
    9721001          }
    9731002        }
     1003#endif
    9741004      }
    9751005      m_pppcRDSbacCoder[0][CI_CURR_BEST]->loadContexts( CTXMem[0] );
     
    9981028    uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in?
    9991029    uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr();
     1030#if WPP_FIX
     1031    UInt uiTileLCUX = uiTileStartLCU % uiWidthInLCUs;
     1032    //UInt uiSliceStartLCU = pcSlice->getSliceCurStartCUAddr();
     1033    UInt uiCol     = uiCUAddr % uiWidthInLCUs;
     1034    UInt uiSubStrm=rpcPic->getSubstreamForLCUAddr(uiCUAddr, true, pcSlice);
     1035
     1036    if ( ((iNumSubstreams > 1) || depSliceSegmentsEnabled ) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro())
     1037#else
    10001038    uiTileLCUX = uiTileStartLCU % uiWidthInLCUs;
    10011039    //UInt uiSliceStartLCU = pcSlice->getSliceCurStartCUAddr();
     
    10151053    }
    10161054    if ( ((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled ) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro())
     1055#endif
    10171056    {
    10181057      // We'll sync if the TR is available.
     
    11381177    ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]->load( m_pppcRDSbacCoder[0][CI_CURR_BEST] );
    11391178    //Store probabilties of second LCU in line into buffer
     1179#if WPP_FIX
     1180    if ( ( uiCol == uiTileLCUX+1) && (depSliceSegmentsEnabled || (iNumSubstreams > 1)) && m_pcCfg->getWaveFrontsynchro())
     1181#else
    11401182    if ( ( uiCol == uiTileLCUX+1) && (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && m_pcCfg->getWaveFrontsynchro())
     1183#endif
    11411184    {
    11421185      m_pcBufferSbacCoders[uiTileCol].loadContexts(ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]);
     
    11771220    m_uiPicDist      += pcCU->getTotalDistortion();
    11781221  }
     1222#if WPP_FIX
     1223  if ((iNumSubstreams > 1) && !depSliceSegmentsEnabled)
     1224#else
    11791225  if ((pcSlice->getPPS()->getNumSubstreams() > 1) && !depSliceSegmentsEnabled)
     1226#endif
    11801227  {
    11811228    pcSlice->setNextSlice( true );
     
    12391286  TEncTop* pcEncTop = (TEncTop*) m_pcCfg;
    12401287  TEncSbac* pcSbacCoders = pcEncTop->getSbacCoders(); //coder for each substream
     1288#if WPP_FIX
     1289  const Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
     1290#else
    12411291  Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
     1292#endif
    12421293  UInt uiBitsOriginallyInSubstreams = 0;
    12431294  {
     
    12681319                                                                                               an encoding order index, so we need to convert the index (uiStartCUAddr)
    12691320                                                                                               into the real raster scan address (uiCUAddr) via the CUOrderMap */
     1321#if WPP_FIX
     1322  UInt currentTileIdx=rpcPic->getPicSym()->getTileIdxMap(uiCUAddr);
     1323  TComTile *pCurrentTile=rpcPic->getPicSym()->getTComTile(currentTileIdx);
     1324  uiTileStartLCU = pCurrentTile->getFirstCUAddr();
     1325#else
    12701326  uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr();
     1327#endif
    12711328  if( depSliceSegmentsEnabled )
    12721329  {
     1330#if WPP_FIX
     1331    if( pcSlice->isNextSlice()|| uiCUAddr == uiTileStartLCU)
     1332#else
    12731333    if( pcSlice->isNextSlice()||
    12741334        uiCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr())
     1335#endif
    12751336    {
    12761337      if(m_pcCfg->getWaveFrontsynchro())
     
    12841345      if(m_pcCfg->getWaveFrontsynchro())
    12851346      {
     1347#if WPP_FIX
     1348        uiTileCol = currentTileIdx % (rpcPic->getPicSym()->getNumColumnsMinus1()+1);
     1349#else
    12861350        uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1);
     1351#endif
    12871352        m_pcBufferSbacCoders[uiTileCol].loadContexts( CTXMem[1] );
     1353#if WPP_FIX
     1354        uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());
     1355        uiSubStrm=rpcPic->getSubstreamForLCUAddr(uiCUAddr, true, pcSlice);
     1356        if ( pCurrentTile->getTileWidth() < 2)
     1357        {
     1358          CTXMem[0]->loadContexts(m_pcSbacCoder);
     1359        }
     1360#else
    12881361        Int iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles();
    12891362        uiLin     = uiCUAddr / uiWidthInLCUs;
     
    12991372          }
    13001373        }
     1374#endif
    13011375      }
    13021376      pcSbacCoders[uiSubStrm].loadContexts( CTXMem[0] );
     
    13151389    uiCol     = uiCUAddr % uiWidthInLCUs;
    13161390    uiLin     = uiCUAddr / uiWidthInLCUs;
     1391#if WPP_FIX
     1392    uiSubStrm=rpcPic->getSubstreamForLCUAddr(uiCUAddr, true, pcSlice);
     1393#else
    13171394    if (pcSlice->getPPS()->getNumSubstreams() > 1)
    13181395    {
     
    13271404      uiSubStrm = uiLin % iNumSubstreams;
    13281405    }
     1406#endif
    13291407
    13301408    m_pcEntropyCoder->setBitstream( &pcSubstreams[uiSubStrm] );
    13311409    // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line.
     1410#if WPP_FIX
     1411    if (((iNumSubstreams > 1) || depSliceSegmentsEnabled) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro())
     1412#else
    13321413    if (((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro())
     1414#endif
    13331415    {
    13341416      // We'll sync if the TR is available.
     
    13681450        // When tiles are independent, we have "substreams per tile".  Each substream has already been terminated, and we no longer
    13691451        // have to perform it here.
     1452#if WPP_FIX
     1453        if (iNumSubstreams <= 1)
     1454#else
    13701455        if (pcSlice->getPPS()->getNumSubstreams() > 1)
    13711456        {
     
    13731458        }
    13741459        else
     1460#endif
    13751461        {
    13761462          SliceType sliceType  = pcSlice->getSliceType();
     
    14481534    pcSbacCoders[uiSubStrm].load(m_pcSbacCoder);   //load back status of the entropy coder after encoding the LCU into relevant bitstream entropy coder
    14491535    //Store probabilties of second LCU in line into buffer
     1536#if WPP_FIX
     1537    if ( (depSliceSegmentsEnabled || (iNumSubstreams > 1)) && (uiCol == uiTileLCUX+1) && m_pcCfg->getWaveFrontsynchro())
     1538#else
    14501539    if ( (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (uiCol == uiTileLCUX+1) && m_pcCfg->getWaveFrontsynchro())
     1540#endif
    14511541    {
    14521542      m_pcBufferSbacCoders[uiTileCol].loadContexts( &pcSbacCoders[uiSubStrm] );
     
    14801570}
    14811571
     1572#if WPP_FIX
     1573Void TEncSlice::calculateBoundingCUAddrForSlice(UInt &uiStartCUAddrSlice, UInt &uiBoundingCUAddrSlice, Bool &bReachedTileBoundary, TComPic*& rpcPic, Bool bEncodeSlice, Int sliceMode, Int sliceArgument, UInt uiSliceCurEndCUAddr)
     1574{
     1575  TComSlice* pcSlice = rpcPic->getSlice(getSliceIdx());
     1576  UInt uiNumberOfCUsInFrame = rpcPic->getNumCUsInFrame();
     1577  const UInt scaleCUAddr = rpcPic->getNumPartInCU(); // due to fine granularity slices all addresses are scaled.
     1578  uiBoundingCUAddrSlice=0;
     1579  bReachedTileBoundary=false;
     1580
     1581  switch (sliceMode)
     1582  {
     1583  case FIXED_NUMBER_OF_LCU:
     1584    {
     1585      UInt uiCUAddrIncrement    = sliceArgument;
     1586      uiBoundingCUAddrSlice     = ((uiStartCUAddrSlice + uiCUAddrIncrement) < uiNumberOfCUsInFrame*scaleCUAddr) ? (uiStartCUAddrSlice + uiCUAddrIncrement) : uiNumberOfCUsInFrame*scaleCUAddr;
     1587    }
     1588    break;
     1589  case FIXED_NUMBER_OF_BYTES:
     1590    if (bEncodeSlice)
     1591      uiBoundingCUAddrSlice     = uiSliceCurEndCUAddr;
     1592    else
     1593      uiBoundingCUAddrSlice     = uiNumberOfCUsInFrame*scaleCUAddr;
     1594    break;
     1595  case FIXED_NUMBER_OF_TILES:
     1596    {
     1597      UInt tileIdx              = rpcPic->getPicSym()->getTileIdxMap( rpcPic->getPicSym()->getCUOrderMap(uiStartCUAddrSlice/scaleCUAddr) );
     1598      UInt uiCUAddrIncrement    = 0;
     1599      UInt tileTotalCount       = (rpcPic->getPicSym()->getNumColumnsMinus1()+1) * (rpcPic->getPicSym()->getNumRowsMinus1()+1);
     1600
     1601      for(UInt tileIdxIncrement = 0; tileIdxIncrement < sliceArgument; tileIdxIncrement++)
     1602      {
     1603        if((tileIdx + tileIdxIncrement) < tileTotalCount)
     1604        {
     1605          UInt tileWidthInLcu   = rpcPic->getPicSym()->getTComTile(tileIdx + tileIdxIncrement)->getTileWidth();
     1606          UInt tileHeightInLcu  = rpcPic->getPicSym()->getTComTile(tileIdx + tileIdxIncrement)->getTileHeight();
     1607          uiCUAddrIncrement    += (tileWidthInLcu * tileHeightInLcu * scaleCUAddr);
     1608        }
     1609      }
     1610
     1611      uiBoundingCUAddrSlice     = ((uiStartCUAddrSlice + uiCUAddrIncrement) < uiNumberOfCUsInFrame*scaleCUAddr) ? (uiStartCUAddrSlice + uiCUAddrIncrement) : uiNumberOfCUsInFrame*scaleCUAddr;
     1612    }
     1613    break;
     1614  default:
     1615    uiBoundingCUAddrSlice       = uiNumberOfCUsInFrame*scaleCUAddr;
     1616    break;
     1617  }
     1618
     1619  // Adjust for tiles and wavefronts.
     1620  if ((sliceMode == FIXED_NUMBER_OF_LCU || sliceMode == FIXED_NUMBER_OF_BYTES) &&
     1621    (m_pcCfg->getNumRowsMinus1() > 0 || m_pcCfg->getNumColumnsMinus1() > 0))
     1622  {
     1623    const UInt lcuEncAddrStart = (uiStartCUAddrSlice+scaleCUAddr-1)/scaleCUAddr;
     1624    const UInt lcuAddr = rpcPic->getPicSym()->getCUOrderMap(lcuEncAddrStart);
     1625    const UInt startTileIdx = rpcPic->getPicSym()->getTileIdxMap(lcuAddr);
     1626    const Bool bWavefrontsEnabled = m_pcCfg->getWaveFrontsynchro();
     1627
     1628    TComTile *pStartingTile = rpcPic->getPicSym()->getTComTile(startTileIdx);
     1629    const UInt uiTileStartLCUEncAddr      = rpcPic->getPicSym()->getInverseCUOrderMap(pStartingTile->getFirstCUAddr());
     1630    const UInt uiTileStartWidth           = pStartingTile->getTileWidth();
     1631    const UInt uiTileStartHeight          = pStartingTile->getTileHeight();
     1632    const UInt uiTileLastLCUEncAddr_excl  = uiTileStartLCUEncAddr + uiTileStartWidth*uiTileStartHeight;
     1633    const UInt tileBoundingCUAddrSlice    = uiTileLastLCUEncAddr_excl * scaleCUAddr;
     1634
     1635    const UInt lcuColumnOfStartingTile=((lcuEncAddrStart-uiTileStartLCUEncAddr)%uiTileStartWidth);
     1636    if (bWavefrontsEnabled && lcuColumnOfStartingTile!=0)
     1637    {
     1638      // WPP: if a slice does not start at the beginning of a CTB row, it must end within the same CTB row
     1639      const UInt numberOfLCUsToEndOfRow=uiTileStartWidth-lcuColumnOfStartingTile;
     1640      const UInt wavefrontTileBoundingCUAddrSlice = (lcuEncAddrStart+numberOfLCUsToEndOfRow)*scaleCUAddr;
     1641      if (wavefrontTileBoundingCUAddrSlice < uiBoundingCUAddrSlice)
     1642      {
     1643        uiBoundingCUAddrSlice = wavefrontTileBoundingCUAddrSlice;
     1644      }
     1645    }
     1646
     1647    if (tileBoundingCUAddrSlice < uiBoundingCUAddrSlice)
     1648    {
     1649      uiBoundingCUAddrSlice = tileBoundingCUAddrSlice;
     1650      bReachedTileBoundary = true;
     1651    }
     1652  }
     1653  else if (pcSlice->getPPS()->getNumSubstreams() > 1 && (uiStartCUAddrSlice % (rpcPic->getFrameWidthInCU()*scaleCUAddr) != 0))
     1654  {
     1655    // WPP: if a slice does not start at the beginning of a CTB row, it must end within the same CTB row
     1656    uiBoundingCUAddrSlice = min(uiBoundingCUAddrSlice, uiStartCUAddrSlice - (uiStartCUAddrSlice % (rpcPic->getFrameWidthInCU()*scaleCUAddr)) + (rpcPic->getFrameWidthInCU()*scaleCUAddr));
     1657  }
     1658
     1659  //calculate real slice start address (fine granularity slices)
     1660  {
     1661    UInt uiInternalAddress = rpcPic->getPicSym()->getPicSCUAddr(uiStartCUAddrSlice) % scaleCUAddr;
     1662    UInt uiExternalAddress = rpcPic->getPicSym()->getPicSCUAddr(uiStartCUAddrSlice) / scaleCUAddr;
     1663    UInt uiPosX = ( uiExternalAddress % rpcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ];
     1664    UInt uiPosY = ( uiExternalAddress / rpcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ];
     1665#if REPN_FORMAT_IN_VPS
     1666    UInt uiWidth = pcSlice->getPicWidthInLumaSamples();
     1667    UInt uiHeight = pcSlice->getPicHeightInLumaSamples();
     1668#else
     1669    UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples();
     1670    UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples();
     1671#endif
     1672    while((uiPosX>=uiWidth||uiPosY>=uiHeight)&&!(uiPosX>=uiWidth&&uiPosY>=uiHeight))
     1673    {
     1674      uiInternalAddress++;
     1675      if(uiInternalAddress>=scaleCUAddr)
     1676      {
     1677        uiInternalAddress=0;
     1678        uiExternalAddress = rpcPic->getPicSym()->getCUOrderMap(rpcPic->getPicSym()->getInverseCUOrderMap(uiExternalAddress)+1);
     1679      }
     1680      uiPosX = ( uiExternalAddress % rpcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ];
     1681      uiPosY = ( uiExternalAddress / rpcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ];
     1682    }
     1683    UInt uiRealStartAddress = rpcPic->getPicSym()->getPicSCUEncOrder(uiExternalAddress*scaleCUAddr+uiInternalAddress);
     1684
     1685    uiStartCUAddrSlice=uiRealStartAddress;
     1686  }
     1687}
     1688
     1689/** Determines the starting and bounding LCU address of current slice / dependent slice
     1690* \param bEncodeSlice Identifies if the calling function is compressSlice() [false] or encodeSlice() [true]
     1691* \returns Updates uiStartCUAddr, uiBoundingCUAddr with appropriate LCU address
     1692*/
     1693Void TEncSlice::xDetermineStartAndBoundingCUAddr  ( UInt& startCUAddr, UInt& boundingCUAddr, TComPic*& rpcPic, Bool bEncodeSlice )
     1694{
     1695  TComSlice* pcSlice = rpcPic->getSlice(getSliceIdx());
     1696
     1697  // Non-dependent slice
     1698  UInt uiStartCUAddrSlice   = pcSlice->getSliceCurStartCUAddr();
     1699  Bool bTileBoundarySlice   = false;
     1700  UInt uiBoundingCUAddrSlice;
     1701  calculateBoundingCUAddrForSlice(uiStartCUAddrSlice, uiBoundingCUAddrSlice, bTileBoundarySlice, rpcPic, bEncodeSlice, m_pcCfg->getSliceMode(), m_pcCfg->getSliceArgument(), pcSlice->getSliceCurEndCUAddr());
     1702  pcSlice->setSliceCurEndCUAddr( uiBoundingCUAddrSlice );
     1703  pcSlice->setSliceCurStartCUAddr(uiStartCUAddrSlice);
     1704
     1705  // Dependent slice
     1706  UInt startCUAddrSliceSegment    = pcSlice->getSliceSegmentCurStartCUAddr();
     1707  Bool bTileBoundarySliceSegment  = false;
     1708  UInt boundingCUAddrSliceSegment;
     1709  calculateBoundingCUAddrForSlice(startCUAddrSliceSegment, boundingCUAddrSliceSegment, bTileBoundarySliceSegment, rpcPic, bEncodeSlice, m_pcCfg->getSliceSegmentMode(), m_pcCfg->getSliceSegmentArgument(), pcSlice->getSliceSegmentCurEndCUAddr());
     1710  pcSlice->setSliceSegmentCurEndCUAddr( boundingCUAddrSliceSegment );
     1711  pcSlice->setSliceSegmentCurStartCUAddr(startCUAddrSliceSegment);
     1712
     1713  // Make a joint decision based on reconstruction and dependent slice bounds
     1714  startCUAddr    = max(uiStartCUAddrSlice   , startCUAddrSliceSegment   );
     1715  boundingCUAddr = min(uiBoundingCUAddrSlice, boundingCUAddrSliceSegment);
     1716
     1717
     1718  if (!bEncodeSlice)
     1719  {
     1720    // For fixed number of LCU within an entropy and reconstruction slice we already know whether we will encounter end of entropy and/or reconstruction slice
     1721    // first. Set the flags accordingly.
     1722    if ( (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_LCU && m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_LCU)
     1723      || (m_pcCfg->getSliceMode()==0 && m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_LCU)
     1724      || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_LCU && m_pcCfg->getSliceSegmentMode()==0)
     1725      || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_LCU)
     1726      || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceSegmentMode()==0)
     1727      || (m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceMode()==0)
     1728      || bTileBoundarySlice || bTileBoundarySliceSegment )
     1729    {
     1730      if (uiBoundingCUAddrSlice < boundingCUAddrSliceSegment)
     1731      {
     1732        pcSlice->setNextSlice       ( true );
     1733        pcSlice->setNextSliceSegment( false );
     1734      }
     1735      else if (uiBoundingCUAddrSlice > boundingCUAddrSliceSegment)
     1736      {
     1737        pcSlice->setNextSlice       ( false );
     1738        pcSlice->setNextSliceSegment( true );
     1739      }
     1740      else
     1741      {
     1742        pcSlice->setNextSlice       ( true );
     1743        pcSlice->setNextSliceSegment( true );
     1744      }
     1745    }
     1746    else
     1747    {
     1748      pcSlice->setNextSlice       ( false );
     1749      pcSlice->setNextSliceSegment( false );
     1750    }
     1751  }
     1752}
     1753#else
    14821754/** Determines the starting and bounding LCU address of current slice / dependent slice
    14831755 * \param bEncodeSlice Identifies if the calling function is compressSlice() [false] or encodeSlice() [true]
     
    18162088  }
    18172089}
     2090#endif
    18182091
    18192092Double TEncSlice::xGetQPValueAccordingToLambda ( Double lambda )
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.h

    r595 r880  
    150150  Void      setCtxMem( TEncSbac* sb, Int b )   { CTXMem[b] = sb; }
    151151
     152#if WPP_FIX
     153  Void     calculateBoundingCUAddrForSlice(UInt &uiStartCUAddrSlice, UInt &uiBoundingCUAddrSlice, Bool &bReachedTileBoundary, TComPic*& rpcPic, Bool bEncodeSlice, Int sliceMode, Int sliceArgument, UInt uiSliceCurEndCUAddr);
     154#endif
     155
    152156private:
    153157  Double  xGetQPValueAccordingToLambda ( Double lambda );
Note: See TracChangeset for help on using the changeset viewer.