Ignore:
Timestamp:
3 May 2013, 15:34:11 (12 years ago)
Author:
tech
Message:

Update to HM-10.1.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-DEV-0.1-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r331 r362  
    175175}
    176176
    177 /** copy SAO parameter
    178 * \param dst 
    179 * \param src
    180 */
    181 inline Void copySaoOneLcuParam(SaoLcuParam* dst,  SaoLcuParam* src)
    182 {
    183   Int i;
    184   dst->partIdx = src->partIdx;
    185   dst->typeIdx = src->typeIdx;
    186   if (dst->typeIdx != -1)
    187   {
    188     dst->subTypeIdx = src->subTypeIdx ;
    189     dst->length  = src->length;
    190     for (i=0;i<dst->length;i++)
    191     {
    192       dst->offset[i] = src->offset[i];
    193     }
    194   }
    195   else
    196   {
    197     dst->length  = 0;
    198     for (i=0;i<SAO_BO_LEN;i++)
    199     {
    200       dst->offset[i] = 0;
    201     }
    202   }
    203 }
    204 
    205177Void TDecCavlc::parsePPS(TComPPS* pcPPS)
    206178{
     
    400372
    401373  READ_FLAG(     uiCode, "field_seq_flag");                           pcVUI->setFieldSeqFlag(uiCode);
    402   assert(pcVUI->getFieldSeqFlag() == false);        // not supported yet
    403374
    404375  READ_FLAG(uiCode, "frame_field_info_present_flag");                 pcVUI->setFrameFieldInfoPresentFlag(uiCode);
     
    593564
    594565  READ_UVLC(     uiCode, "bit_depth_luma_minus8" );
    595   g_bitDepthY = 8 + uiCode;
    596   pcSPS->setBitDepthY(g_bitDepthY);
     566  pcSPS->setBitDepthY( uiCode + 8 );
    597567  pcSPS->setQpBDOffsetY( (Int) (6*uiCode) );
    598568
    599569  READ_UVLC( uiCode,    "bit_depth_chroma_minus8" );
    600   g_bitDepthC = 8 + uiCode;
    601   pcSPS->setBitDepthC(g_bitDepthC);
     570  pcSPS->setBitDepthC( uiCode + 8 );
    602571  pcSPS->setQpBDOffsetC( (Int) (6*uiCode) );
    603572
     
    608577  for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++)
    609578  {
     579#if L0323_DPB
     580    READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1");
     581    pcSPS->setMaxDecPicBuffering( uiCode + 1, i);
     582#else
    610583    READ_UVLC ( uiCode, "sps_max_dec_pic_buffering");
    611584    pcSPS->setMaxDecPicBuffering( uiCode, i);
     585#endif
    612586    READ_UVLC ( uiCode, "sps_num_reorder_pics" );
    613587    pcSPS->setNumReorderPics(uiCode, i);
     
    628602
    629603  READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" );
    630   UInt log2MinCUSize = uiCode + 3;
     604  Int log2MinCUSize = uiCode + 3;
     605  pcSPS->setLog2MinCodingBlockSize(log2MinCUSize);
    631606  READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" );
    632   UInt uiMaxCUDepthCorrect = uiCode;
    633   pcSPS->setMaxCUWidth  ( 1<<(log2MinCUSize + uiMaxCUDepthCorrect) ); g_uiMaxCUWidth  = 1<<(log2MinCUSize + uiMaxCUDepthCorrect);
    634   pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + uiMaxCUDepthCorrect) ); g_uiMaxCUHeight = 1<<(log2MinCUSize + uiMaxCUDepthCorrect);
     607  pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode);
     608  Int maxCUDepthDelta = uiCode;
     609  pcSPS->setMaxCUWidth  ( 1<<(log2MinCUSize + maxCUDepthDelta) );
     610  pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) );
    635611  READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" );   pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 );
    636612
     
    640616  READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" );    pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 );
    641617  READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" );    pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 );
    642   g_uiAddCUDepth = 0;
    643   while( ( pcSPS->getMaxCUWidth() >> uiMaxCUDepthCorrect ) > ( 1 << ( pcSPS->getQuadtreeTULog2MinSize() + g_uiAddCUDepth )  ) )
    644   {
    645     g_uiAddCUDepth++;
    646   }
    647   pcSPS->setMaxCUDepth( uiMaxCUDepthCorrect+g_uiAddCUDepth  );
    648   g_uiMaxCUDepth  = uiMaxCUDepthCorrect+g_uiAddCUDepth;
    649   // BB: these parameters may be removed completly and replaced by the fixed values
    650   pcSPS->setMinTrDepth( 0 );
    651   pcSPS->setMaxTrDepth( 1 );
     618
     619  Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() );
     620  pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth );
     621
    652622  READ_FLAG( uiCode, "scaling_list_enabled_flag" );                 pcSPS->setScalingListFlag ( uiCode );
    653623  if(pcSPS->getScalingListFlag())
     
    748718  for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++)
    749719  {
     720#if L0323_DPB
     721    READ_UVLC( uiCode,  "vps_max_dec_pic_buffering_minus1[i]" );     pcVPS->setMaxDecPicBuffering( uiCode + 1, i );
     722#else
    750723    READ_UVLC( uiCode,  "vps_max_dec_pic_buffering[i]" );     pcVPS->setMaxDecPicBuffering( uiCode, i );
     724#endif
    751725    READ_UVLC( uiCode,  "vps_num_reorder_pics[i]" );          pcVPS->setNumReorderPics( uiCode, i );
    752726    READ_UVLC( uiCode,  "vps_max_latency_increase[i]" );      pcVPS->setMaxLatencyIncrease( uiCode, i );
     
    10561030        iPOCmsb = iPrevPOCmsb;
    10571031      }
    1058       if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    1059         || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
     1032      if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     1033        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    10601034        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
    10611035      {
     
    10661040
    10671041      TComReferencePictureSet* rps;
     1042      rps = rpcSlice->getLocalRPS();
     1043      rpcSlice->setRPS(rps);
    10681044      READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" );
    10691045      if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header
    10701046      {
    1071         rps = rpcSlice->getLocalRPS();
    10721047        parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets());
    1073         rpcSlice->setRPS(rps);
    10741048      }
    10751049      else // use reference to short-term reference picture set in PPS
     
    10881062          uiCode = 0;
    10891063        }
    1090         rpcSlice->setRPS(sps->getRPSList()->getReferencePictureSet(uiCode));
    1091 
    1092         rps = rpcSlice->getRPS();
     1064        memcpy(rps,sps->getRPSList()->getReferencePictureSet(uiCode),sizeof(TComReferencePictureSet));
    10931065      }
    10941066      if(sps->getLongTermRefsPresent())
     
    11131085        rps->setNumberOfLongtermPictures(numOfLtrp);
    11141086        Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC();
    1115         Int prevLSB = 0, prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;;
     1087        Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;;
    11161088        for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++)
    11171089        {
     
    11401112            READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" );
    11411113            Bool deltaFlag = false;
    1142             //            First LTRP                               || First LTRP from SH           || curr LSB    != prev LSB
    1143             if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) || (pocLsbLt != prevLSB) )
     1114            //            First LTRP                               || First LTRP from SH
     1115            if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) )
    11441116            {
    11451117              deltaFlag = true;
     
    11661138            rps->setCheckLTMSBPresent(j,false); 
    11671139          }
    1168           prevLSB = pocLsbLt;
    11691140          prevDeltaMSB = deltaPocMSBCycleLT;
    11701141        }
     
    11721143        rps->setNumberOfPictures(offset);       
    11731144      } 
    1174       if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA
    1175         || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT
     1145      if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     1146        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    11761147        || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
    11771148      {
     
    14051376        if(!rpcSlice->getDeblockingFilterDisable())
    14061377        {
    1407           READ_SVLC( iCode, "beta_offset_div2" );                       rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode);
    1408           READ_SVLC( iCode, "tc_offset_div2" );                         rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode);
     1378          READ_SVLC( iCode, "slice_beta_offset_div2" );                       rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode);
     1379          assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 &&
     1380                 rpcSlice->getDeblockingFilterBetaOffsetDiv2() <=  6);
     1381          READ_SVLC( iCode, "slice_tc_offset_div2" );                         rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode);
     1382          assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 &&
     1383                 rpcSlice->getDeblockingFilterTcOffsetDiv2() <=  6);
    14091384        }
    14101385      }
     
    14381413  }
    14391414 
    1440   if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )
    1441   {
    14421415    UInt *entryPointOffset          = NULL;
    14431416    UInt numEntryPointOffsets, offsetLenMinus1;
    1444 
     1417  if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )
     1418  {
    14451419    READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets );
    14461420    if (numEntryPointOffsets>0)
     
    14591433#endif
    14601434    }
     1435  }
     1436  else
     1437  {
     1438    rpcSlice->setNumEntryPointOffsets ( 0 );
     1439  }
     1440
     1441  if(pps->getSliceHeaderExtensionPresentFlag())
     1442  {
     1443    READ_UVLC(uiCode,"slice_header_extension_length");
     1444    for(Int i=0; i<uiCode; i++)
     1445    {
     1446      UInt ignore;
     1447      READ_CODE(8,ignore,"slice_header_extension_data_byte");
     1448    }
     1449  }
     1450  m_pcBitstream->readByteAlignment();
     1451
     1452  if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )
     1453  {
     1454    Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation();
     1455    Int  curEntryPointOffset     = 0;
     1456    Int  prevEntryPointOffset    = 0;
     1457    for (UInt idx=0; idx<numEntryPointOffsets; idx++)
     1458    {
     1459      curEntryPointOffset += entryPointOffset[ idx ];
     1460
     1461      Int emulationPreventionByteCount = 0;
     1462      for ( UInt curByteIdx  = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ )
     1463      {
     1464        if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) &&
     1465             m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) <  ( curEntryPointOffset  + endOfSliceHeaderLocation ) )
     1466        {
     1467          emulationPreventionByteCount++;
     1468        }
     1469      }
     1470
     1471      entryPointOffset[ idx ] -= emulationPreventionByteCount;
     1472      prevEntryPointOffset = curEntryPointOffset;
     1473    }
    14611474
    14621475    if ( pps->getTilesEnabledFlag() )
     
    14941507    }
    14951508  }
    1496   else
    1497   {
    1498     rpcSlice->setNumEntryPointOffsets ( 0 );
    1499   }
    1500 
    1501   if(pps->getSliceHeaderExtensionPresentFlag())
    1502   {
    1503     READ_UVLC(uiCode,"slice_header_extension_length");
    1504     for(Int i=0; i<uiCode; i++)
    1505     {
    1506       UInt ignore;
    1507       READ_CODE(8,ignore,"slice_header_extension_data_byte");
    1508     }
    1509   }
    1510   m_pcBitstream->readByteAlignment();
     1509
    15111510  return;
    15121511}
     
    17591758// ====================================================================================================================
    17601759
    1761 
    1762 /** Parse PCM alignment zero bits.
    1763 * \returns Void
    1764 */
    1765 Void TDecCavlc::xReadPCMAlignZero( )
    1766 {
    1767   UInt uiNumberOfBits = m_pcBitstream->getNumBitsUntilByteAligned();
    1768 
    1769   if(uiNumberOfBits)
    1770   {
    1771     UInt uiBits;
    1772     UInt uiSymbol;
    1773 
    1774     for(uiBits = 0; uiBits < uiNumberOfBits; uiBits++)
    1775     {
    1776       xReadFlag( uiSymbol );
    1777       assert( uiSymbol == 0 );
    1778     }
    1779   }
    1780 }
    1781 
    1782 Void TDecCavlc::xReadUnaryMaxSymbol( UInt& ruiSymbol, UInt uiMaxSymbol )
    1783 {
    1784   if (uiMaxSymbol == 0)
    1785   {
    1786     ruiSymbol = 0;
    1787     return;
    1788   }
    1789 
    1790   xReadFlag( ruiSymbol );
    1791 
    1792   if (ruiSymbol == 0 || uiMaxSymbol == 1)
    1793   {
    1794     return;
    1795   }
    1796 
    1797   UInt uiSymbol = 0;
    1798   UInt uiCont;
    1799 
    1800   do
    1801   {
    1802     xReadFlag( uiCont );
    1803     uiSymbol++;
    1804   }
    1805   while( uiCont && (uiSymbol < uiMaxSymbol-1) );
    1806 
    1807   if( uiCont && (uiSymbol == uiMaxSymbol-1) )
    1808   {
    1809     uiSymbol++;
    1810   }
    1811 
    1812   ruiSymbol = uiSymbol;
    1813 }
    1814 
    1815 Void TDecCavlc::xReadExGolombLevel( UInt& ruiSymbol )
    1816 {
    1817   UInt uiSymbol ;
    1818   UInt uiCount = 0;
    1819   do
    1820   {
    1821     xReadFlag( uiSymbol );
    1822     uiCount++;
    1823   }
    1824   while( uiSymbol && (uiCount != 13));
    1825 
    1826   ruiSymbol = uiCount-1;
    1827 
    1828   if( uiSymbol )
    1829   {
    1830     xReadEpExGolomb( uiSymbol, 0 );
    1831     ruiSymbol += uiSymbol+1;
    1832   }
    1833 
    1834   return;
    1835 }
    1836 
    1837 Void TDecCavlc::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount )
    1838 {
    1839   UInt uiSymbol = 0;
    1840   UInt uiBit = 1;
    1841 
    1842 
    1843   while( uiBit )
    1844   {
    1845     xReadFlag( uiBit );
    1846     uiSymbol += uiBit << uiCount++;
    1847   }
    1848 
    1849   uiCount--;
    1850   while( uiCount-- )
    1851   {
    1852     xReadFlag( uiBit );
    1853     uiSymbol += uiBit << uiCount;
    1854   }
    1855 
    1856   ruiSymbol = uiSymbol;
    1857 
    1858   return;
    1859 }
    1860 
    1861 UInt TDecCavlc::xGetBit()
    1862 {
    1863   UInt ruiCode;
    1864   m_pcBitstream->read( 1, ruiCode );
    1865   return ruiCode;
    1866 }
    1867 
    1868 
    18691760/** parse explicit wp tables
    18701761* \param TComSlice* pcSlice
     
    18831774  // decode delta_luma_log2_weight_denom :
    18841775  READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" );     // ue(v): luma_log2_weight_denom
     1776  assert( uiLog2WeightDenomLuma <= 7 );
    18851777  if( bChroma )
    18861778  {
    18871779    READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" );     // se(v): delta_chroma_log2_weight_denom
    18881780    assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0);
     1781    assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7);
    18891782    uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma);
    18901783  }
     
    19251818        Int iDeltaWeight;
    19261819        READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" );  // se(v): delta_luma_weight_l0[i]
     1820        assert( iDeltaWeight >= -128 );
     1821        assert( iDeltaWeight <=  127 );
    19271822        wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom));
    19281823        READ_SVLC( wp[0].iOffset, "luma_offset_lX" );       // se(v): luma_offset_l0[i]
     1824        assert( wp[0].iOffset >= -128 );
     1825        assert( wp[0].iOffset <=  127 );
    19291826      }
    19301827      else
     
    19411838            Int iDeltaWeight;
    19421839            READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" );  // se(v): chroma_weight_l0[i][j]
     1840            assert( iDeltaWeight >= -128 );
     1841            assert( iDeltaWeight <=  127 );
    19431842            wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom));
    19441843
    19451844            Int iDeltaChroma;
    19461845            READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" );  // se(v): delta_chroma_offset_l0[i][j]
     1846            assert( iDeltaChroma >= -512 );
     1847            assert( iDeltaChroma <=  511 );
    19471848            Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) );
    19481849            wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) );
Note: See TracChangeset for help on using the changeset viewer.