Changeset 296 in 3DVCSoftware for trunk/source/Lib/TLibDecoder/TDecTop.cpp


Ignore:
Timestamp:
20 Feb 2013, 22:07:43 (11 years ago)
Author:
tech
Message:

Reintegrated branch 5.1-dev0 rev. 295.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibDecoder/TDecTop.cpp

    r210 r296  
    5959    m_aaiCodedScale       [ uiId ] = new Int [ MAX_VIEW_NUM ];
    6060  }
     61
     62#if MERL_VSP_C0152
     63  xCreateLUTs( (UInt)MAX_VIEW_NUM, (UInt)MAX_VIEW_NUM, m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
     64  m_iLog2Precision   = LOG2_DISP_PREC_LUT;
     65  m_uiBitDepthForLUT = 8; // fixed
     66#endif
    6167}
    6268
     
    7278  delete [] m_aiViewOrderIndex;
    7379  delete [] m_aiViewReceived;
     80
     81#if MERL_VSP_C0152
     82  xDeleteArray( m_adBaseViewShiftLUT, MAX_VIEW_NUM, MAX_VIEW_NUM, 2 );
     83  xDeleteArray( m_aiBaseViewShiftLUT, MAX_VIEW_NUM, MAX_VIEW_NUM, 2 );
     84#endif
    7485}
    7586
     
    8596  m_uiMaxViewId             = 0;
    8697}
     98
     99#if MERL_VSP_C0152
     100Void
     101CamParsCollector::xCreateLUTs( UInt uiNumberSourceViews, UInt uiNumberTargetViews, Double****& radLUT, Int****& raiLUT)
     102{
     103  //AOF( m_uiBitDepthForLUT == 8 );
     104  //AOF(radLUT == NULL && raiLUT == NULL );
     105
     106  uiNumberSourceViews = Max( 1, uiNumberSourceViews );
     107  uiNumberTargetViews = Max( 1, uiNumberTargetViews );
     108
     109  radLUT         = new Double***[ uiNumberSourceViews ];
     110  raiLUT         = new Int   ***[ uiNumberSourceViews ];
     111
     112  for( UInt uiSourceView = 0; uiSourceView < uiNumberSourceViews; uiSourceView++ )
     113  {
     114    radLUT        [ uiSourceView ] = new Double**[ uiNumberTargetViews ];
     115    raiLUT        [ uiSourceView ] = new Int   **[ uiNumberTargetViews ];
     116
     117    for( UInt uiTargetView = 0; uiTargetView < uiNumberTargetViews; uiTargetView++ )
     118    {
     119      radLUT        [ uiSourceView ][ uiTargetView ]      = new Double*[ 2 ];
     120      radLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Double [ 257 ];
     121      radLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Double [ 257 ];
     122
     123      raiLUT        [ uiSourceView ][ uiTargetView ]      = new Int*   [ 2 ];
     124      raiLUT        [ uiSourceView ][ uiTargetView ][ 0 ] = new Int    [ 257 ];
     125      raiLUT        [ uiSourceView ][ uiTargetView ][ 1 ] = new Int    [ 257 ];
     126    }
     127  }
     128}
     129
     130Void
     131  CamParsCollector::xInitLUTs( UInt uiSourceView, UInt uiTargetView, Int iScale, Int iOffset, Double****& radLUT, Int****& raiLUT)
     132{
     133  Int     iLog2DivLuma   = m_uiBitDepthForLUT + m_uiCamParsCodedPrecision + 1 - m_iLog2Precision;   AOF( iLog2DivLuma > 0 );
     134  Int     iLog2DivChroma = iLog2DivLuma + 1;
     135
     136  iOffset <<= m_uiBitDepthForLUT;
     137
     138  Double dScale  = (Double) iScale  / (( Double ) ( 1 << iLog2DivLuma ));
     139  Double dOffset = (Double) iOffset / (( Double ) ( 1 << iLog2DivLuma ));
     140
     141  // offsets including rounding offsets
     142  Int64 iOffsetLuma   = iOffset + ( ( 1 << iLog2DivLuma   ) >> 1 );
     143  Int64 iOffsetChroma = iOffset + ( ( 1 << iLog2DivChroma ) >> 1 );
     144
     145
     146  for( UInt uiDepthValue = 0; uiDepthValue < 256; uiDepthValue++ )
     147  {
     148
     149    // real-valued look-up tables
     150    Double  dShiftLuma      = ( (Double)uiDepthValue * dScale + dOffset ) * Double( 1 << m_iLog2Precision );
     151    Double  dShiftChroma    = dShiftLuma / 2;
     152    radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = dShiftLuma;
     153    radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = dShiftChroma;
     154
     155    // integer-valued look-up tables
     156    Int64   iTempScale      = (Int64)uiDepthValue * iScale;
     157    Int64   iShiftLuma      = ( iTempScale + iOffsetLuma   ) >> iLog2DivLuma;
     158    Int64   iShiftChroma    = ( iTempScale + iOffsetChroma ) >> iLog2DivChroma;
     159    raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ uiDepthValue ] = (Int)iShiftLuma;
     160    raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ uiDepthValue ] = (Int)iShiftChroma;
     161
     162    // maximum deviation
     163    //dMaxDispDev     = Max( dMaxDispDev,    fabs( Double( (Int) iTestScale   ) - dShiftLuma * Double( 1 << iLog2DivLuma ) ) / Double( 1 << iLog2DivLuma ) );
     164    //dMaxRndDispDvL  = Max( dMaxRndDispDvL, fabs( Double( (Int) iShiftLuma   ) - dShiftLuma   ) );
     165    //dMaxRndDispDvC  = Max( dMaxRndDispDvC, fabs( Double( (Int) iShiftChroma ) - dShiftChroma ) );
     166  }
     167
     168  radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
     169  radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = radLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
     170  raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 0 ][ 255 ];
     171  raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 256 ] = raiLUT[ uiSourceView ][ uiTargetView ][ 1 ][ 255 ];
     172}
     173#endif // end MERL_VSP_C0152
    87174
    88175Void
     
    167254        m_aaiCodedScale [ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedScale () [ uiBaseId ];
    168255        m_aaiCodedOffset[ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedOffset() [ uiBaseId ];
     256#if MERL_VSP_C0152
     257        xInitLUTs( uiBaseId, uiViewId, m_aaiCodedScale[ uiBaseId ][ uiViewId ], m_aaiCodedOffset[ uiBaseId ][ uiViewId ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT);
     258        xInitLUTs( uiViewId, uiBaseId, m_aaiCodedScale[ uiViewId ][ uiBaseId ], m_aaiCodedOffset[ uiViewId ][ uiBaseId ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT);
     259#endif
    169260      }
    170261      else
     
    174265        m_aaiCodedScale [ uiViewId ][ uiBaseId ]  = pcSlice->getSPS()->getInvCodedScale () [ uiBaseId ];
    175266        m_aaiCodedOffset[ uiViewId ][ uiBaseId ]  = pcSlice->getSPS()->getInvCodedOffset() [ uiBaseId ];
     267#if MERL_VSP_C0152
     268        xInitLUTs( uiBaseId, uiViewId, m_aaiCodedScale[ uiBaseId ][ uiViewId ], m_aaiCodedOffset[ uiBaseId ][ uiViewId ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
     269        xInitLUTs( uiViewId, uiBaseId, m_aaiCodedScale[ uiViewId ][ uiBaseId ], m_aaiCodedOffset[ uiViewId ][ uiBaseId ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
     270#endif
    176271      }
    177272    }
     
    188283        m_aaiCodedScale [ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedScale () [ uiBaseId ];
    189284        m_aaiCodedOffset[ uiViewId ][ uiBaseId ]  = pcSlice->getInvCodedOffset() [ uiBaseId ];
     285#if MERL_VSP_C0152
     286        xInitLUTs( uiBaseId, uiViewId, m_aaiCodedScale[ uiBaseId ][ uiViewId ], m_aaiCodedOffset[ uiBaseId ][ uiViewId ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
     287        xInitLUTs( uiViewId, uiBaseId, m_aaiCodedScale[ uiViewId ][ uiBaseId ], m_aaiCodedOffset[ uiViewId ][ uiBaseId ], m_adBaseViewShiftLUT, m_aiBaseViewShiftLUT );
     288#endif
    190289      }
    191290    }
     
    254353  m_iMaxRefPicNum = 0;
    255354  m_uiValidPS = 0;
    256 #if SONY_COLPIC_AVAILABILITY
    257   m_iViewOrderIdx = 0;
    258 #endif
    259355#if ENC_DEC_TRACE
    260   g_hTrace = fopen( "TraceDec.txt", "wb" );
     356  if(!g_hTrace) g_hTrace = fopen( "TraceDec.txt", "wb" );
    261357  g_bJustDoIt = g_bEncDecTraceDisable;
    262358  g_nSymbolCounter = 0;
     
    277373{
    278374#if ENC_DEC_TRACE
    279   fclose( g_hTrace );
     375  if(g_hTrace) fclose( g_hTrace );
     376  g_hTrace=NULL;
    280377#endif
    281378}
     
    301398  m_cDepthMapGenerator.destroy();
    302399#endif
    303 #if HHI_INTER_VIEW_RESIDUAL_PRED
     400#if H3D_IVRP
    304401  m_cResidualGenerator.destroy();
    305402#endif
     403
    306404}
    307405
     
    317415                    , &m_cDepthMapGenerator
    318416#endif
    319 #if HHI_INTER_VIEW_RESIDUAL_PRED
     417#if H3D_IVRP
    320418                    , &m_cResidualGenerator
    321419#endif
     
    331429#endif
    332430#endif
    333 #if HHI_INTER_VIEW_RESIDUAL_PRED
     431#if H3D_IVRP
    334432  m_cResidualGenerator.init( &m_cTrQuant, &m_cDepthMapGenerator );
    335433#endif
     
    367465}
    368466
    369 #if HHI_INTER_VIEW_RESIDUAL_PRED
     467#if H3D_IVRP
    370468Void
    371469TDecTop::deleteExtraPicBuffers( Int iPoc )
     
    427525  xUpdateGopSize(pcSlice);
    428526 
    429 #if H0567_DPB_PARAMETERS_PER_TEMPORAL_LAYER
    430527  m_iMaxRefPicNum = pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getTLayer())+pcSlice->getSPS()->getNumReorderPics(pcSlice->getTLayer()) + 1; // +1 to have space for the picture currently being decoded
    431 #else
    432   m_iMaxRefPicNum = pcSlice->getSPS()->getMaxNumberOfReferencePictures()+pcSlice->getSPS()->getNumReorderFrames() + 1; // +1 to have space for the picture currently being decoded
    433 #endif
    434528
    435529#if DEPTH_MAP_GENERATION
     
    618712  }
    619713
    620 #if !LCU_SYNTAX_ALF
    621   // create ALF temporary buffer
    622   m_cAdaptiveLoopFilter.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
    623 #endif
    624714  m_cSAO.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
    625715  m_cLoopFilter.        create( g_uiMaxCUDepth );
    626716}
    627717
    628 #if SKIPFRAME_BUGFIX
    629718Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay )
    630 #else
    631 Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int iSkipFrame, Int iPOCLastDisplay )
    632 #endif
    633719{
    634720  TComPic*&   pcPic         = m_pcPic;
     
    687773  }
    688774
    689 #if SONY_COLPIC_AVAILABILITY
    690   m_apcSlicePilot->setViewOrderIdx( m_apcSlicePilot->getSPS()->getViewOrderIdx());
    691 #endif
    692 
    693 #if NAL_REF_FLAG
    694775  m_apcSlicePilot->setReferenced(nalu.m_nalRefFlag);
     776  m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId);
     777
     778  // ALF CU parameters should be part of the slice header -> needs to be fixed
     779#if MTK_DEPTH_MERGE_TEXTURE_CANDIDATE_C0137
     780  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder, m_cGopDecoder.getAlfCuCtrlParam(), m_cGopDecoder.getAlfParamSet(),m_apcSlicePilot->getVPS()->getDepthFlag(nalu.m_layerId));
    695781#else
    696   m_apcSlicePilot->setReferenced(nalu.m_nalRefIDC != NAL_REF_IDC_PRIORITY_LOWEST);
    697 #endif
    698   m_apcSlicePilot->setTLayerInfo(nalu.m_temporalId);
    699 
    700   // ALF CU parameters should be part of the slice header -> needs to be fixed
    701 #if LCU_SYNTAX_ALF
    702782  m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder, m_cGopDecoder.getAlfCuCtrlParam(), m_cGopDecoder.getAlfParamSet());
    703 #else
    704   m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder, m_cGopDecoder.getAlfCuCtrlParam() );
    705783#endif
    706784  // byte align
     
    718796  if (m_apcSlicePilot->isNextSlice() && m_apcSlicePilot->getPOC()!=m_prevPOC && !m_bFirstSliceInSequence)
    719797  {
    720 #if START_DECODING_AT_CRA
    721798    if (m_prevPOC >= m_pocRandomAccess)
    722799    {
     
    725802    }
    726803    m_prevPOC = m_apcSlicePilot->getPOC();
    727 #else
    728     m_prevPOC = m_apcSlicePilot->getPOC();
    729     return true;
    730 #endif
    731804  }
    732805  // actual decoding starts here
     
    748821  }
    749822  //detect lost reference picture and insert copy of earlier frame.
    750 #if START_DECODING_AT_CRA
    751823  while(m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true, m_pocRandomAccess) > 0)
    752 #else
    753   while(m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), true) > 0)
    754 #endif
    755824  {
    756825    xCreateLostPicture(m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPS(), false)-1);
     
    764833    xGetNewPicBuffer (m_apcSlicePilot, pcPic);
    765834
    766 #if SONY_COLPIC_AVAILABILITY
    767     pcPic->setViewOrderIdx( m_apcSlicePilot->getSPS()->getViewOrderIdx() );
    768 #endif
    769 
     835#if INTER_VIEW_VECTOR_SCALING_C0115
     836    pcPic->setViewOrderIdx( m_apcSlicePilot->getVPS()->getViewOrderIdx(nalu.m_layerId) );    // will be changed to view_id
     837#endif
    770838    /* transfer any SEI messages that have been received to the picture */
    771839    pcPic->setSEIs(m_SEIs);
     
    787855    }
    788856#endif
    789 #if HHI_INTER_VIEW_RESIDUAL_PRED
     857#if H3D_IVRP
    790858    m_cResidualGenerator.create( true, m_apcSlicePilot->getSPS()->getPicWidthInLumaSamples(), m_apcSlicePilot->getSPS()->getPicHeightInLumaSamples(), g_uiMaxCUDepth, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiBitDepth + g_uiBitIncrement );
    791859#endif
     
    800868  UInt i, j, p;
    801869
    802 #if !REMOVE_TILE_DEPENDENCE
    803   //set the TileBoundaryIndependenceIdr
    804   if(pcSlice->getPPS()->getTileBehaviorControlPresentFlag() == 1)
    805   {
    806     pcPic->getPicSym()->setTileBoundaryIndependenceIdr( pcSlice->getPPS()->getTileBoundaryIndependenceIdr() );
    807   }
    808   else
    809   {
    810     pcPic->getPicSym()->setTileBoundaryIndependenceIdr( pcSlice->getPPS()->getSPS()->getTileBoundaryIndependenceIdr() );
    811   }
    812 #endif
    813870
    814871  if( pcSlice->getPPS()->getColumnRowInfoPresent() == 1 )
     
    9921049#endif
    9931050
    994 #if SONY_COLPIC_AVAILABILITY
     1051#if INTER_VIEW_VECTOR_SCALING_C0115
    9951052#if VIDYO_VPS_INTEGRATION
    996     pcSlice->setViewOrderIdx( pcSlice->getVPS()->getViewOrderIdx(nalu.m_layerId) );
     1053    pcSlice->setViewOrderIdx( pcSlice->getVPS()->getViewOrderIdx(nalu.m_layerId) );        // will be changed to view_id
    9971054#else
    9981055    pcSlice->setViewOrderIdx( pcPic->getViewOrderIdx() );
    9991056#endif
     1057#endif
     1058
     1059#if INTER_VIEW_VECTOR_SCALING_C0115
     1060    pcSlice->setIVScalingFlag( pcSlice->getVPS()->getIVScalingFlag());
    10001061#endif
    10011062
     
    11111172#endif
    11121173
     1174#if MERL_VSP_C0152 // set BW LUT
     1175  if( m_pcCamParsCollector ) // Initialize the LUT elements
     1176  {
     1177    m_pcCamParsCollector->setSlice( pcSlice );
     1178  }
     1179  if( pcSlice->getViewId() !=0 )
     1180  {
     1181    TComPic* pcBaseTxtPic = m_tAppDecTop->getPicFromView(  0, pcSlice->getPOC(), false );  // get base view reconstructed texture
     1182    TComPic* pcBaseDepthPic = m_tAppDecTop->getPicFromView(  0, pcSlice->getPOC(), true ); // get base view reconstructed depth
     1183     pcSlice->setRefPicBaseTxt(pcBaseTxtPic);
     1184     pcSlice->setRefPicBaseDepth(pcBaseDepthPic);
     1185  }
     1186  getTAppDecTop()->setBWVSPLUT( pcSlice, pcSlice->getViewId(),  pcSlice->getPOC() ); // get the LUT for backward warping
     1187#endif
     1188
    11131189  //  Decode a picture
    11141190  m_cGopDecoder.decompressGop(nalu.m_Bitstream, pcPic, false);
     
    11491225{
    11501226  TComSPS* sps = new TComSPS();
    1151 #if RPS_IN_SPS
    11521227  TComRPSList* rps = new TComRPSList();
    11531228  sps->setRPSList(rps);
    1154 #endif
    1155 #if HHI_MPI
     1229#if HHI_MPI || OL_QTLIMIT_PREDCODING_B0068
    11561230  m_cEntropyDecoder.decodeSPS( sps, m_isDepth );
    11571231#else
     
    11591233#endif
    11601234  m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
    1161 #if LCU_SYNTAX_ALF
    11621235  m_cAdaptiveLoopFilter.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
    1163 #endif
    11641236}
    11651237
    11661238Void TDecTop::xDecodePPS()
    11671239{
    1168 #if !RPS_IN_SPS
    1169   TComRPSList* rps = new TComRPSList();
    1170 #endif
    11711240  TComPPS* pps = new TComPPS();
    1172 #if !RPS_IN_SPS
    1173   pps->setRPSList(rps);
    1174 #endif
    1175 #if TILES_OR_ENTROPY_SYNC_IDC
    11761241  m_cEntropyDecoder.decodePPS( pps, &m_parameterSetManagerDecoder );
    1177 #else
    1178   m_cEntropyDecoder.decodePPS( pps );
    1179 #endif
    11801242  m_parameterSetManagerDecoder.storePrefetchedPPS( pps );
    11811243
     
    12301292    case NAL_UNIT_CODED_SLICE:
    12311293    case NAL_UNIT_CODED_SLICE_IDR:
    1232 #if H0566_TLA
    12331294#if !QC_REM_IDV_B0046
    12341295    case NAL_UNIT_CODED_SLICE_IDV:
     
    12361297    case NAL_UNIT_CODED_SLICE_CRA:
    12371298    case NAL_UNIT_CODED_SLICE_TLA:
    1238 #else
    1239     case NAL_UNIT_CODED_SLICE_CDR:
    1240 #endif
    12411299      return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay);
    12421300      break;
     
    12591317  sps = pSPSV0;
    12601318  m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
    1261 #if LCU_SYNTAX_ALF
    12621319  m_cAdaptiveLoopFilter.create( sps->getPicWidthInLumaSamples(), sps->getPicHeightInLumaSamples(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
    1263 #endif
    12641320}
    12651321
     
    12961352  else if (m_pocRandomAccess == MAX_INT) // start of random access point, m_pocRandomAccess has not been set yet.
    12971353  {
    1298 #if H0566_TLA
    12991354    if( m_apcSlicePilot->getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_CRA )
    1300 #else
    1301     if( m_apcSlicePilot->getNalUnitTypeBaseViewMvc() == NAL_UNIT_CODED_SLICE_CDR )
    1302 #endif
    13031355    {
    13041356      m_pocRandomAccess = m_apcSlicePilot->getPOC(); // set the POC random access since we need to skip the reordered pictures in CRA.
     
    13101362    else
    13111363    {
    1312 #if START_DECODING_AT_CRA
    13131364      static bool warningMessage = false;
    13141365      if(!warningMessage)
     
    13181369      }
    13191370      return true;
    1320 #else
    1321       printf("\nUnsafe random access point. Decoder may crash.");
    1322       m_pocRandomAccess = 0;
    1323 #endif
    13241371    }
    13251372  }
     
    13421389  m_cSAO.allocSaoParam(pAPS->getSaoParam());
    13431390  pAPS->createAlfParam();
    1344 #if !LCU_SYNTAX_ALF
    1345   m_cAdaptiveLoopFilter.allocALFParam(pAPS->getAlfParam());
    1346 #endif
    13471391}
    13481392
Note: See TracChangeset for help on using the changeset viewer.