Ticket #224: tiles_SPS_PPS_bugfix.patch

File tiles_SPS_PPS_bugfix.patch, 13.9 KB (added by shilin.xu, 13 years ago)

This is the patch for this bug

  • source/Lib/TLibCommon/TComPicSym.cpp

     
    9797    m_puiCUOrderMap[i] = i;
    9898    m_puiInverseCUOrderMap[i] = i;
    9999  }
     100
     101  m_apcTComTile = new TComTile*[m_uiNumCUsInFrame];
     102  for( i=0; i<m_uiNumCUsInFrame; i++ )
     103  {
     104    m_apcTComTile[i] = new TComTile;
     105  }
    100106#endif
    101107}
    102108
     
    124130  m_apcTComDataCU = NULL;
    125131
    126132#if TILES
    127   for (i = 0; i < (m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1); i++)
     133  for (i = 0; i < m_uiNumCUsInFrame; i++)
    128134  {
    129135    delete m_apcTComTile[i];
    130136  }
     
    178184  return getCUOrderMap(SCUEncOrder/m_uiNumPartitions)*m_uiNumPartitions + SCUEncOrder%m_uiNumPartitions;
    179185}
    180186
    181 Void TComPicSym::xCreateTComTileArray()
    182 {
    183   m_apcTComTile = new TComTile*[(m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1)];
    184   for( UInt i=0; i<(m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1); i++ )
    185   {
    186     m_apcTComTile[i] = new TComTile;
    187   }
    188 }
    189 
    190187Void TComPicSym::xInitTiles()
    191188{
    192189  UInt  uiTileIdx;
  • source/Lib/TLibCommon/TComPicSym.h

     
    152152  UInt         getInverseCUOrderMap( Int cuAddr )                    { return *(m_puiInverseCUOrderMap + (cuAddr>=m_uiNumCUsInFrame ? m_uiNumCUsInFrame : cuAddr)); }
    153153  UInt         getPicSCUEncOrder( UInt SCUAddr );
    154154  UInt         getPicSCUAddr( UInt SCUEncOrder );
    155   Void         xCreateTComTileArray();
    156155  Void         xInitTiles();
    157156  UInt         xCalculateNxtCUAddr( UInt uiCurrCUAddr );
    158157#if TILES_DECODER
  • source/Lib/TLibDecoder/TDecCAVLC.cpp

     
    202202  pcPPS->setColumnRowInfoPresent(uiCode);
    203203  if( pcPPS->getColumnRowInfoPresent() == 1 )
    204204  {
    205     READ_FLAG ( uiCode, "uniform_spacing_idc" ); 
    206     pcPPS->setUniformSpacingIdr( uiCode );
    207     READ_FLAG ( uiCode, "tile_boundary_independence_idc" ); 
    208     pcPPS->setTileBoundaryIndependenceIdr( uiCode );
    209 
    210205    READ_UVLC ( uiCode, "num_tile_columns_minus1" );   
    211206    pcPPS->setNumColumnsMinus1( uiCode ); 
    212207    READ_UVLC ( uiCode, "num_tile_rows_minus1" ); 
    213     pcPPS->setNumRowsMinus1( uiCode );  
     208    pcPPS->setNumRowsMinus1( uiCode );
    214209
    215     if( pcPPS->getUniformSpacingIdr() == 0 )
     210    if( pcPPS->getNumColumnsMinus1()!=0 || pcPPS->getNumRowsMinus1()!=0 )
    216211    {
    217       UInt* columnWidth = (UInt*)malloc(pcPPS->getNumColumnsMinus1()*sizeof(UInt));
    218       for(UInt i=0; i<pcPPS->getNumColumnsMinus1(); i++)
    219       {
    220         READ_UVLC( uiCode, "column_width" ); 
    221         columnWidth[i] = uiCode; 
    222       }
    223       pcPPS->setColumnWidth(columnWidth);
    224       free(columnWidth);
     212      READ_FLAG ( uiCode, "tile_boundary_independence_idc" ); 
     213      pcPPS->setTileBoundaryIndependenceIdr( uiCode );
     214      READ_FLAG ( uiCode, "uniform_spacing_idc" ); 
     215      pcPPS->setUniformSpacingIdr( uiCode );
    225216
    226       UInt* rowHeight = (UInt*)malloc(pcPPS->getNumRowsMinus1()*sizeof(UInt));
    227       for(UInt i=0; i<pcPPS->getNumRowsMinus1(); i++)
     217      if( pcPPS->getUniformSpacingIdr() != 1 )
    228218      {
    229         READ_UVLC( uiCode, "row_height" ); 
    230         rowHeight[i] = uiCode; 
     219        UInt* columnWidth = (UInt*)malloc(pcPPS->getNumColumnsMinus1()*sizeof(UInt));
     220        for(UInt i=0; i<pcPPS->getNumColumnsMinus1(); i++)
     221        {
     222          READ_UVLC( uiCode, "column_width" ); 
     223          columnWidth[i] = uiCode; 
     224        }
     225        pcPPS->setColumnWidth(columnWidth);
     226        free(columnWidth);
     227
     228        UInt* rowHeight = (UInt*)malloc(pcPPS->getNumRowsMinus1()*sizeof(UInt));
     229        for(UInt i=0; i<pcPPS->getNumRowsMinus1(); i++)
     230        {
     231          READ_UVLC( uiCode, "row_height" ); 
     232          rowHeight[i] = uiCode; 
     233        }
     234        pcPPS->setRowHeight(rowHeight);
     235        free(rowHeight); 
    231236      }
    232       pcPPS->setRowHeight(rowHeight);
    233       free(rowHeight); 
    234237    }
     238    else
     239    {
     240      pcPPS->setTileBoundaryIndependenceIdr(0);
     241      pcPPS->setUniformSpacingIdr(0);
     242    }
    235243  }
    236244#endif
    237245  return;
     
    358366#endif
    359367
    360368#if TILES
    361   READ_FLAG ( uiCode, "uniform_spacing_idc" );
    362   pcSPS->setUniformSpacingIdr( uiCode );
    363   READ_FLAG ( uiCode, "tile_boundary_independence_idc" ); 
    364   pcSPS->setTileBoundaryIndependenceIdr( uiCode );
    365  
    366369  READ_UVLC ( uiCode, "num_tile_columns_minus1" );
    367370  pcSPS->setNumColumnsMinus1( uiCode ); 
    368371  READ_UVLC ( uiCode, "num_tile_rows_minus1" );
    369   pcSPS->setNumRowsMinus1( uiCode );
    370   if( pcSPS->getUniformSpacingIdr() == 0 )
     372  pcSPS->setNumRowsMinus1( uiCode );
     373
     374  if( pcSPS->getNumColumnsMinus1()!=0 || pcSPS->getNumRowsMinus1()!=0 )
    371375  {
    372     UInt* columnWidth = (UInt*)malloc(pcSPS->getNumColumnsMinus1()*sizeof(UInt));
    373     for(UInt i=0; i<pcSPS->getNumColumnsMinus1(); i++)
    374     {
    375       READ_UVLC( uiCode, "column_width" );
    376       columnWidth[i] = uiCode; 
    377     }
    378     pcSPS->setColumnWidth(columnWidth);
    379     free(columnWidth);
     376    READ_FLAG ( uiCode, "tile_boundary_independence_idc" ); 
     377    pcSPS->setTileBoundaryIndependenceIdr( uiCode );
     378    READ_FLAG ( uiCode, "uniform_spacing_idc" );
     379    pcSPS->setUniformSpacingIdr( uiCode );
     380    if( pcSPS->getUniformSpacingIdr() != 1 )
     381    {
     382      UInt* columnWidth = (UInt*)malloc(pcSPS->getNumColumnsMinus1()*sizeof(UInt));
     383      for(UInt i=0; i<pcSPS->getNumColumnsMinus1(); i++)
     384      {
     385        READ_UVLC( uiCode, "column_width" );
     386        columnWidth[i] = uiCode; 
     387      }
     388      pcSPS->setColumnWidth(columnWidth);
     389      free(columnWidth);
    380390 
    381     UInt* rowHeight = (UInt*)malloc(pcSPS->getNumRowsMinus1()*sizeof(UInt));
    382     for(UInt i=0; i<pcSPS->getNumRowsMinus1(); i++)
    383     {
    384       READ_UVLC( uiCode, "row_height" );
    385       rowHeight[i] = uiCode; 
     391      UInt* rowHeight = (UInt*)malloc(pcSPS->getNumRowsMinus1()*sizeof(UInt));
     392      for(UInt i=0; i<pcSPS->getNumRowsMinus1(); i++)
     393      {
     394        READ_UVLC( uiCode, "row_height" );
     395        rowHeight[i] = uiCode; 
     396      }
     397      pcSPS->setRowHeight(rowHeight);
     398      free(rowHeight); 
    386399    }
    387     pcSPS->setRowHeight(rowHeight);
    388     free(rowHeight); 
    389400  }
     401  else
     402  {
     403    pcSPS->setTileBoundaryIndependenceIdr( 0 );
     404    pcSPS->setUniformSpacingIdr( 0 );
     405  }
    390406#endif
    391407
    392408  return;
  • source/Lib/TLibDecoder/TDecTop.cpp

     
    410410        pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() );
    411411        pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() );
    412412
    413         //create the TComTileArray
    414         pcPic->getPicSym()->xCreateTComTileArray();
    415 
    416413        if( pcSlice->getPPS()->getUniformSpacingIdr() == 1)
    417414        {
    418415          //set the width for each tile
     
    473470        pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getSPS()->getNumColumnsMinus1() );
    474471        pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getSPS()->getNumRowsMinus1() );
    475472
    476         //create the TComTileArray
    477         pcPic->getPicSym()->xCreateTComTileArray();
    478 
    479473        //automatically set the column and row boundary if UniformSpacingIdr = 1
    480474        if( pcSlice->getSPS()->getUniformSpacingIdr() == 1 )
    481475        {
  • source/Lib/TLibEncoder/TEncCavlc.cpp

     
    349349  WRITE_FLAG( pcPPS->getColumnRowInfoPresent(),           "tile_info_present_flag" );
    350350  if( pcPPS->getColumnRowInfoPresent() == 1 )
    351351  {
    352     WRITE_FLAG( pcPPS->getUniformSpacingIdr(),                                   "uniform_spacing_idc" );
    353     WRITE_FLAG( pcPPS->getTileBoundaryIndependenceIdr(),                         "tile_boundary_independence_idc" );
    354     WRITE_UVLC( pcPPS->getNumColumnsMinus1(),                                    "num_tile_columns_minus1" );
    355     WRITE_UVLC( pcPPS->getNumRowsMinus1(),                                       "num_tile_rows_minus1" );
    356     if( pcPPS->getUniformSpacingIdr() == 0 )
     352    WRITE_UVLC( pcPPS->getNumColumnsMinus1(),                                      "num_tile_columns_minus1" );
     353    WRITE_UVLC( pcPPS->getNumRowsMinus1(),                                         "num_tile_rows_minus1" );
     354    if( pcPPS->getNumColumnsMinus1()!=0 || pcPPS->getNumRowsMinus1()!=0 )
    357355    {
    358       for(UInt i=0; i<pcPPS->getNumColumnsMinus1(); i++)
     356      WRITE_FLAG( pcPPS->getTileBoundaryIndependenceIdr(),                         "tile_boundary_independence_idc" );
     357      WRITE_FLAG( pcPPS->getUniformSpacingIdr(),                                   "uniform_spacing_idc" );
     358      if( pcPPS->getUniformSpacingIdr() != 1 )
    359359      {
    360         WRITE_UVLC( pcPPS->getColumnWidth(i),                                    "column_width" );
     360        for(UInt i=0; i<pcPPS->getNumColumnsMinus1(); i++)
     361        {
     362          WRITE_UVLC( pcPPS->getColumnWidth(i),                                    "column_width" );
     363        }
     364        for(UInt i=0; i<pcPPS->getNumRowsMinus1(); i++)
     365        {
     366          WRITE_UVLC( pcPPS->getRowHeight(i),                                      "row_height" );
     367        }
    361368      }
    362       for(UInt i=0; i<pcPPS->getNumRowsMinus1(); i++)
    363       {
    364         WRITE_UVLC( pcPPS->getRowHeight(i),                                      "row_height" );
    365       }
    366369    }
    367370  }
    368371#endif
     
    476479#endif
    477480
    478481#if TILES
    479   WRITE_FLAG( pcSPS->getUniformSpacingIdr(),                          "uniform_spacing_idc" );
    480   WRITE_FLAG( pcSPS->getTileBoundaryIndependenceIdr(),                "tile_boundary_independence_idc" );
    481   WRITE_UVLC( pcSPS->getNumColumnsMinus1(),                           "num_tile_columns_minus1" );
    482   WRITE_UVLC( pcSPS->getNumRowsMinus1(),                              "num_tile_rows_minus1" );
    483   if( pcSPS->getUniformSpacingIdr()==0 )
     482  WRITE_UVLC( pcSPS->getNumColumnsMinus1(),                             "num_tile_columns_minus1" );
     483  WRITE_UVLC( pcSPS->getNumRowsMinus1(),                                "num_tile_rows_minus1" );
     484  if( pcSPS->getNumColumnsMinus1()!=0 || pcSPS->getNumRowsMinus1()!=0 )
    484485  {
    485     for(UInt i=0; i<pcSPS->getNumColumnsMinus1(); i++)
     486    WRITE_FLAG( pcSPS->getTileBoundaryIndependenceIdr(),                "tile_boundary_independence_idc" );
     487    WRITE_FLAG( pcSPS->getUniformSpacingIdr(),                          "uniform_spacing_idc" );
     488    if( pcSPS->getUniformSpacingIdr()!=1 )
    486489    {
    487       WRITE_UVLC( pcSPS->getColumnWidth(i),                           "column_width" );
     490      for(UInt i=0; i<pcSPS->getNumColumnsMinus1(); i++)
     491      {
     492        WRITE_UVLC( pcSPS->getColumnWidth(i),                           "column_width" );
     493      }
     494      for(UInt i=0; i<pcSPS->getNumRowsMinus1(); i++)
     495      {
     496        WRITE_UVLC( pcSPS->getRowHeight(i),                             "row_height" );
     497      }
    488498    }
    489     for(UInt i=0; i<pcSPS->getNumRowsMinus1(); i++)
    490     {
    491       WRITE_UVLC( pcSPS->getRowHeight(i),                             "row_height" );
    492     }
    493499  }
    494500#endif
    495501}
  • source/Lib/TLibEncoder/TEncGOP.cpp

     
    370370      pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() );
    371371      pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() );
    372372
    373       //create the TComTileArray
    374       pcPic->getPicSym()->xCreateTComTileArray();
    375 
    376373      if( pcSlice->getPPS()->getUniformSpacingIdr() == 1 )
    377374      {
    378375        //set the width for each tile
     
    433430      pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getSPS()->getNumColumnsMinus1() );
    434431      pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getSPS()->getNumRowsMinus1() );
    435432
    436       //create the TComTileArray
    437       pcPic->getPicSym()->xCreateTComTileArray();
    438 
    439433      if( pcSlice->getSPS()->getUniformSpacingIdr() == 1 )
    440434      {
    441435        //set the width for each tile
  • source/Lib/TLibEncoder/TEncTop.cpp

     
    628628#endif
    629629
    630630#if TILES
    631   m_cSPS.setUniformSpacingIdr( m_iUniformSpacingIdr );
    632   m_cSPS.setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr );
    633631  m_cSPS.setNumColumnsMinus1( m_iNumColumnsMinus1 );
    634632  m_cSPS.setNumRowsMinus1( m_iNumRowsMinus1 );
     633  if( m_iNumColumnsMinus1!=0 || m_iNumRowsMinus1!=0 )
     634  {
     635    m_cSPS.setUniformSpacingIdr( m_iUniformSpacingIdr );
     636    m_cSPS.setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr );
     637  }
     638  else
     639  {
     640    m_cSPS.setUniformSpacingIdr( 0 );
     641    m_cSPS.setTileBoundaryIndependenceIdr( 0 );
     642  }
    635643  if( m_iUniformSpacingIdr == 0 )
    636644  {
    637645    m_cSPS.setColumnWidth( m_puiColumnWidth );
     
    688696Void  TEncTop::xInitPPSforTiles()
    689697{
    690698    m_cPPS.setColumnRowInfoPresent( m_iColumnRowInfoPresent );
    691     m_cPPS.setUniformSpacingIdr( m_iUniformSpacingIdr );
    692     m_cPPS.setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr );
    693699    m_cPPS.setNumColumnsMinus1( m_iNumColumnsMinus1 );
    694700    m_cPPS.setNumRowsMinus1( m_iNumRowsMinus1 );
     701    if( m_iNumColumnsMinus1!=0 || m_iNumRowsMinus1!=0 )
     702    {
     703      m_cPPS.setUniformSpacingIdr( m_iUniformSpacingIdr );
     704      m_cPPS.setTileBoundaryIndependenceIdr( m_iTileBoundaryIndependenceIdr );
     705    }
     706    else
     707    {
     708      m_cPPS.setUniformSpacingIdr( 0 );
     709      m_cPPS.setTileBoundaryIndependenceIdr( 0 );
     710    }
    695711    if( m_iUniformSpacingIdr == 0 )
    696712    {
    697713      m_cPPS.setColumnWidth( m_puiColumnWidth );