Changeset 466 in SHVCSoftware for branches/SHM-4.0-dev/source/Lib/TLibEncoder


Ignore:
Timestamp:
13 Nov 2013, 23:25:47 (11 years ago)
Author:
nokia
Message:

Integration of O0194: Support different bit-depth values for different layers, enable weighted prediction for ILR for color gamut scalability.

Location:
branches/SHM-4.0-dev/source/Lib/TLibEncoder
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncCavlc.cpp

    r464 r466  
    359359  {
    360360    WRITE_FLAG(pcVUI->getTilesFixedStructureFlag(),             "tiles_fixed_structure_flag");
     361#if M0464_TILE_BOUNDARY_ALIGNED_FLAG
     362    if ( pcSPS->getLayerId() > 0 )
     363    {
     364      WRITE_FLAG( pcVUI->getTileBoundariesAlignedFlag( ) ? 1 : 0 , "tile_boundaries_aligned_flag" );
     365    }
     366#endif
    361367    WRITE_FLAG(pcVUI->getMotionVectorsOverPicBoundariesFlag(),  "motion_vectors_over_pic_boundaries_flag");
    362368    WRITE_FLAG(pcVUI->getRestrictedRefPicListsFlag(),           "restricted_ref_pic_lists_flag");
     
    448454#endif
    449455  WRITE_CODE( pcSPS->getVPSId (),          4,       "sps_video_parameter_set_id" );
    450 #if SVC_EXTENSION
     456#if SPS_SUB_LAYER_INFO
    451457  if(pcSPS->getLayerId() == 0)
    452458  {
     
    454460    WRITE_CODE( pcSPS->getMaxTLayers() - 1,  3,       "sps_max_sub_layers_minus1" );
    455461    WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0,                             "sps_temporal_id_nesting_flag" );
    456 #if SVC_EXTENSION
     462#if SPS_SUB_LAYER_INFO
    457463  }
    458464#endif
     
    664670  WRITE_FLAG( 0, "inter_view_mv_vert_constraint_flag" );
    665671#endif
     672#if SCALED_REF_LAYER_OFFSETS
    666673  if( pcSPS->getLayerId() > 0 )
    667674  {
     
    676683    }
    677684  }
     685#endif
    678686#if M0463_VUI_EXT_ILP_REF
    679687  ////   sps_extension_vui_parameters( )
     
    820828}
    821829
    822 #if SVC_EXTENSION
    823830#if VPS_EXTNS
    824831Void TEncCavlc::codeVPSExtension (TComVPS *vps)
     
    836843  }
    837844
     845#if VPS_SPLIT_FLAG
    838846  for(j = 0; j < vps->getNumScalabilityTypes() - vps->getSplittingFlag(); j++)
     847#else
     848  for(j = 0; j < vps->getNumScalabilityTypes(); j++)
     849#endif
    839850  {
    840851    WRITE_CODE( vps->getDimensionIdLen(j) - 1, 3,      "dimension_id_len_minus1[j]" );
     
    860871      WRITE_CODE( vps->getLayerIdInNuh(i),     6,      "layer_id_in_nuh[i]" );
    861872    }
    862 
    863     if( !vps->getSplittingFlag() )
    864     {
    865       for(j = 0; j < vps->getNumScalabilityTypes(); j++)
    866       {
    867         UInt bits = vps->getDimensionIdLen(j);
    868         WRITE_CODE( vps->getDimensionId(i, j),   bits,   "dimension_id[i][j]" );
    869       }
     873#if VPS_SPLIT_FLAG
     874    if(!vps->getSplittingFlag())
     875#endif
     876    for(j = 0; j < vps->getNumScalabilityTypes(); j++)
     877    {
     878      UInt bits = vps->getDimensionIdLen(j);
     879      WRITE_CODE( vps->getDimensionId(i, j),   bits,   "dimension_id[i][j]" );
    870880    }
    871881  }
     
    883893  }
    884894#endif
     895#if VPS_MOVE_DIR_DEPENDENCY_FLAG
    885896#if VPS_EXTN_DIRECT_REF_LAYERS
    886897  for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     
    891902    }
    892903  }
     904#endif
    893905#endif
    894906#if JCTVC_M0203_INTERLAYER_PRED_IDC
     
    914926#if VPS_EXTN_PROFILE_INFO
    915927  // Profile-tier-level signalling
     928#if VPS_PROFILE_OUTPUT_LAYERS
    916929  WRITE_CODE( vps->getNumLayerSets() - 1   , 10, "vps_number_layer_sets_minus1" );     
    917930  WRITE_CODE( vps->getNumProfileTierLevel() - 1,  6, "vps_num_profile_tier_level_minus1");
    918931  for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++)
     932#else
     933  for(Int idx = 1; idx <= vps->getNumLayerSets() - 1; idx++)
     934#endif
    919935  {
    920936    WRITE_FLAG( vps->getProfilePresentFlag(idx),       "vps_profile_present_flag[i]" );
    921937    if( !vps->getProfilePresentFlag(idx) )
    922938    {
     939#if VPS_PROFILE_OUTPUT_LAYERS
    923940      WRITE_CODE( vps->getProfileLayerSetRef(idx) - 1, 6, "profile_ref_minus1[i]" );
     941#else
     942      WRITE_UVLC( vps->getProfileLayerSetRef(idx) - 1, "vps_profile_layer_set_ref_minus1[i]" );
     943#endif
    924944    }
    925945    codePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 );
     
    927947#endif
    928948
     949#if VPS_PROFILE_OUTPUT_LAYERS
    929950  Int numOutputLayerSets = vps->getNumOutputLayerSets() ;
    930951  WRITE_FLAG(  (numOutputLayerSets > vps->getNumLayerSets()), "more_output_layer_sets_than_default_flag" );
     
    961982    WRITE_CODE( vps->getProfileLevelTierIdx(i), numBits, "profile_level_tier_idx[i]" );     
    962983  }
    963  
     984#else
     985#if VPS_EXTN_OP_LAYER_SETS
     986  // Target output layer signalling
     987  WRITE_UVLC( vps->getNumOutputLayerSets(),            "vps_num_output_layer_sets");
     988  for(i = 0; i < vps->getNumOutputLayerSets(); i++)
     989  {
     990#if VPS_OUTPUT_LAYER_SET_IDX
     991    assert(vps->getOutputLayerSetIdx(i) > 0);
     992    WRITE_UVLC( vps->getOutputLayerSetIdx(i) - 1,           "vps_output_layer_set_idx_minus1[i]");
     993#else
     994    WRITE_UVLC( vps->getOutputLayerSetIdx(i),           "vps_output_layer_set_idx[i]");
     995#endif
     996    Int lsIdx = vps->getOutputLayerSetIdx(i);
     997    for(j = 0; j <= vps->getMaxLayerId(); j++)
     998    {
     999      if(vps->getLayerIdIncludedFlag(lsIdx, j))
     1000      {
     1001        WRITE_FLAG( vps->getOutputLayerFlag(lsIdx, j), "vps_output_layer_flag[lsIdx][j]");
     1002      }
     1003    }
     1004  }
     1005#endif
     1006#endif
     1007
    9641008#if REPN_FORMAT_IN_VPS
    9651009  WRITE_FLAG( vps->getRepFormatIdxPresentFlag(), "rep_format_idx_present_flag");
     
    9881032
    9891033#if JCTVC_M0458_INTERLAYER_RPS_SIG
    990   WRITE_FLAG(vps->getMaxOneActiveRefLayerFlag(), "max_one_active_ref_layer_flag");
     1034      WRITE_FLAG(vps->getMaxOneActiveRefLayerFlag(), "max_one_active_ref_layer_flag");
    9911035#endif
    9921036#if O0215_PHASE_ALIGNMENT
     
    9941038#endif
    9951039#if N0147_IRAP_ALIGN_FLAG
    996   WRITE_FLAG(vps->getCrossLayerIrapAlignFlag(), "cross_layer_irap_aligned_flag");
     1040      WRITE_FLAG(vps->getCrossLayerIrapAlignFlag(), "cross_layer_irap_aligned_flag");
    9971041#endif
     1042#if !VPS_MOVE_DIR_DEPENDENCY_FLAG
     1043#if VPS_EXTN_DIRECT_REF_LAYERS
     1044  for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++)
     1045  {
     1046    for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++)
     1047    {
     1048      WRITE_FLAG(vps->getDirectDependencyFlag(layerCtr, refLayerCtr), "direct_dependency_flag[i][j]" );
     1049    }
     1050  }
     1051#endif
     1052#endif
    9981053#if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS
    9991054  WRITE_UVLC( vps->getDirectDepTypeLen()-2,                           "direct_dep_type_len_minus2");
     
    11291184}
    11301185#endif
    1131 #endif //SVC_EXTENSION
    11321186
    11331187Void TEncCavlc::codeSliceHeader         ( TComSlice* pcSlice )
     
    11751229  if ( !pcSlice->getDependentSliceSegmentFlag() )
    11761230  {
    1177 #if SVC_EXTENSION
     1231
    11781232#if POC_RESET_FLAG
    11791233    Int iBits = 0;
     
    11951249    }
    11961250#else
     1251#if SH_DISCARDABLE_FLAG
    11971252    if (pcSlice->getPPS()->getNumExtraSliceHeaderBits()>0)
    11981253    {
     
    12051260      WRITE_FLAG(0, "slice_reserved_undetermined_flag[]");
    12061261    }
    1207 #endif
    1208 #else //SVC_EXTENSION
     1262#else
    12091263    for (Int i = 0; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++)
    12101264    {
     
    12121266      WRITE_FLAG(0, "slice_reserved_undetermined_flag[]");
    12131267    }
    1214 #endif //SVC_EXTENSION
     1268#endif
     1269#endif
    12151270
    12161271    WRITE_UVLC( pcSlice->getSliceType(),       "slice_type" );
  • branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r464 r466  
    753753    pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR));
    754754#if SVC_EXTENSION
     755#if ILR_RESTR && ILR_RESTR_FIX
     756    Int interLayerPredLayerIdcTmp[MAX_VPS_LAYER_ID_PLUS1];
     757    Int activeNumILRRefIdxTmp = 0;
     758#endif
    755759    if (m_layerId > 0)
    756760    {
    757       Int interLayerPredLayerIdcTmp[MAX_VPS_LAYER_ID_PLUS1];
    758       Int activeNumILRRefIdxTmp = 0;
    759 
    760761      for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
    761762      {
     
    768769        pcSlice->setBaseColPic( *cListPic, refLayerIdc );
    769770
     771#if ILR_RESTR && ILR_RESTR_FIX
    770772        // Apply temporal layer restriction to inter-layer prediction
    771773        Int maxTidIlRefPicsPlus1 = m_pcEncTop->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getLayerId());
     
    778780          continue; // ILP is not valid due to temporal layer restriction
    779781        }
    780 
     782#endif
     783
     784#if SCALED_REF_LAYER_OFFSETS
    781785        const Window &scalEL = m_pcEncTop->getScaledRefLayerWindow(refLayerIdc);
    782786
     
    786790        Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
    787791        Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
    788 
     792#else
     793        const Window &confBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getConformanceWindow();
     794        const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow();
     795
     796        Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();
     797        Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();
     798
     799        Int widthEL   = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();
     800        Int heightEL  = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();
     801#endif
    789802        g_mvScalingFactor[refLayerIdc][0] = widthEL  == widthBL  ? 4096 : Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
    790803        g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);
     
    810823      }
    811824
     825#if ILR_RESTR && ILR_RESTR_FIX
    812826      // Update the list of active inter-layer pictures
    813827      for ( Int i = 0; i < activeNumILRRefIdxTmp; i++)
     
    821835        pcSlice->setInterLayerPredEnabledFlag(false);
    822836      }
     837#endif
    823838     
    824839      if( pocCurr % m_pcCfg->getIntraPeriod() == 0 )
     
    16011616          pcSlice->setSliceSegmentCurStartCUAddr  ( startCUAddrSlice      );
    16021617          pcSlice->setSliceBits(0);
    1603 #if SVC_EXTENSION
    1604           // copy reference list modification info from the first slice, assuming that this information is the same across all slices in the picture
    1605           memcpy( pcSlice->getRefPicListModification(), pcPic->getSlice(0)->getRefPicListModification(), sizeof(TComRefPicListModification) );
    1606 #endif
    16071618          uiNumSlices ++;
    16081619        }
  • branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncSearch.cpp

    r442 r466  
    41194119
    41204120  // prediction pattern
     4121#if O0194_WEIGHTED_PREDICTION_CGS
     4122  // Bug Fix (It did not check WP for BSlices)
     4123  if ( pcCU->getSlice()->getPPS()->getUseWP())
     4124#else
    41214125  if ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType()==P_SLICE )
     4126#endif
    41224127  {
    41234128    xPredInterLumaBlk( pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, true );
     
    41284133  }
    41294134
     4135#if O0194_WEIGHTED_PREDICTION_CGS
     4136  if ( pcCU->getSlice()->getPPS()->getUseWP())
     4137  ///< Bug Fix (It did not check WP for BSlices)
     4138#else
    41304139  if ( pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType()==P_SLICE )
     4140#endif
    41314141  {
    41324142    xWeightedPredictionUni( pcCU, pcTemplateCand, uiPartAddr, iSizeX, iSizeY, eRefPicList, pcTemplateCand, iRefIdx );
  • branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncSlice.cpp

    r442 r466  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2013, ITU/ISO/IEC
     
    5151  m_apcPicYuvPred = NULL;
    5252  m_apcPicYuvResi = NULL;
    53  
     53
    5454  m_pdRdPicLambda = NULL;
    5555  m_pdRdPicQp     = NULL;
     
    6969}
    7070
    71 Void TEncSlice::initCtxMem(  UInt i )               
    72 {   
     71Void TEncSlice::initCtxMem(  UInt i )
     72{
    7373  for (std::vector<TEncSbac*>::iterator j = CTXMem.begin(); j != CTXMem.end(); j++)
    7474  {
    7575    delete (*j);
    7676  }
    77   CTXMem.clear(); 
    78   CTXMem.resize(i); 
     77  CTXMem.clear();
     78  CTXMem.resize(i);
    7979}
    8080
     
    8787    m_apcPicYuvPred->create( iWidth, iHeight, iMaxCUWidth, iMaxCUHeight, uhTotalDepth );
    8888  }
    89  
     89
    9090  // create residual picture
    9191  if( m_apcPicYuvResi == NULL )
     
    105105    m_apcPicYuvPred  = NULL;
    106106  }
    107  
     107
    108108  // destroy residual picture
    109109  if ( m_apcPicYuvResi )
     
    113113    m_apcPicYuvResi  = NULL;
    114114  }
    115  
     115
    116116  // free lambda and QP arrays
    117117  if ( m_pdRdPicLambda ) { xFree( m_pdRdPicLambda ); m_pdRdPicLambda = NULL; }
     
    139139#if SVC_EXTENSION
    140140  m_ppcTEncTop        = pcEncTop->getLayerEnc();
    141 #endif 
     141#endif
    142142  m_pcGOPEncoder      = pcEncTop->getGOPEncoder();
    143143  m_pcCuEncoder       = pcEncTop->getCuEncoder();
    144144  m_pcPredSearch      = pcEncTop->getPredSearch();
    145  
     145
    146146  m_pcEntropyCoder    = pcEncTop->getEntropyCoder();
    147147  m_pcCavlcCoder      = pcEncTop->getCavlcCoder();
     
    149149  m_pcBinCABAC        = pcEncTop->getBinCABAC();
    150150  m_pcTrQuant         = pcEncTop->getTrQuant();
    151  
     151
    152152  m_pcBitCounter      = pcEncTop->getBitCounter();
    153153  m_pcRdCost          = pcEncTop->getRdCost();
    154154  m_pppcRDSbacCoder   = pcEncTop->getRDSbacCoder();
    155155  m_pcRDGoOnSbacCoder = pcEncTop->getRDGoOnSbacCoder();
    156  
     156
    157157  // create lambda and QP arrays
    158158  m_pdRdPicLambda     = (Double*)xMalloc( Double, m_pcCfg->getDeltaQpRD() * 2 + 1 );
     
    187187  Double dQP;
    188188  Double dLambda;
    189  
     189
    190190  rpcSlice = pcPic->getSlice(0);
    191191  rpcSlice->setSPS( pSPS );
     
    202202  rpcSlice->setPicOutputFlag( true );
    203203  rpcSlice->setPOC( pocCurr );
    204  
     204
    205205  // depth computation based on GOP size
    206206  Int depth;
     
    230230    }
    231231  }
    232  
     232
    233233  // slice type
    234234  SliceType eSliceType;
    235  
     235
    236236  eSliceType=B_SLICE;
    237237  eSliceType = (pocLast == 0 || pocCurr % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
    238  
     238
    239239  rpcSlice->setSliceType    ( eSliceType );
    240  
     240
    241241  // ------------------------------------------------------------------------------------------------------------------
    242242  // Non-referenced frame marking
    243243  // ------------------------------------------------------------------------------------------------------------------
    244  
     244
    245245  if(pocLast == 0)
    246246  {
     
    252252  }
    253253  rpcSlice->setReferenced(true);
    254  
     254
    255255  // ------------------------------------------------------------------------------------------------------------------
    256256  // QP setting
    257257  // ------------------------------------------------------------------------------------------------------------------
    258  
     258
    259259  dQP = m_pcCfg->getQP();
    260260  if(eSliceType!=I_SLICE)
    261261  {
    262262#if REPN_FORMAT_IN_VPS
    263     if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getQpBDOffsetY() ) && (rpcSlice->getSPS()->getUseLossless()))) 
    264 #else
    265     if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getSPS()->getQpBDOffsetY() ) && (rpcSlice->getSPS()->getUseLossless()))) 
     263    if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getQpBDOffsetY() ) && (rpcSlice->getSPS()->getUseLossless())))
     264#else
     265    if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getSPS()->getQpBDOffsetY() ) && (rpcSlice->getSPS()->getUseLossless())))
    266266#endif
    267267    {
     
    269269    }
    270270  }
    271  
     271
    272272  // modify QP
    273273  Int* pdQPs = m_pcCfg->getdQPs();
     
    285285  // Lambda computation
    286286  // ------------------------------------------------------------------------------------------------------------------
    287  
     287
    288288  Int iQP;
    289289  Double dOrigQP = dQP;
     
    294294    // compute QP value
    295295    dQP = dOrigQP + ((iDQpIdx+1)>>1)*(iDQpIdx%2 ? -1 : 1);
    296    
     296
    297297    // compute lambda value
    298298    Int    NumberBFrames = ( m_pcCfg->getGOPSize() - 1 );
     
    326326#endif
    327327    }
    328    
     328
    329329    // if hadamard is used in ME process
    330330    if ( !m_pcCfg->getUseHADME() && rpcSlice->getSliceType( ) != I_SLICE )
     
    332332      dLambda *= 0.95;
    333333    }
    334    
     334
    335335#if REPN_FORMAT_IN_VPS
    336336    iQP = max( -rpcSlice->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );
     
    343343    m_piRdPicQp    [iDQpIdx] = iQP;
    344344  }
    345  
     345
    346346  // obtain dQP = 0 case
    347347  dLambda = m_pdRdPicLambda[0];
    348348  dQP     = m_pdRdPicQp    [0];
    349349  iQP     = m_piRdPicQp    [0];
    350  
     350
    351351  if( rpcSlice->getSliceType( ) != I_SLICE )
    352352  {
     
    359359    Int nCurLayer = rpcSlice->getLayerId();
    360360    Double gamma = xCalEnhLambdaFactor( m_ppcTEncTop[nCurLayer-1]->getQP() - m_ppcTEncTop[nCurLayer]->getQP() ,
    361       1.0 * m_ppcTEncTop[nCurLayer]->getSourceWidth() * m_ppcTEncTop[nCurLayer]->getSourceHeight() 
     361      1.0 * m_ppcTEncTop[nCurLayer]->getSourceWidth() * m_ppcTEncTop[nCurLayer]->getSourceHeight()
    362362      / m_ppcTEncTop[nCurLayer-1]->getSourceWidth() / m_ppcTEncTop[nCurLayer-1]->getSourceHeight() );
    363363    dLambda *= gamma;
     
    392392#endif
    393393
    394 #if RDOQ_CHROMA_LAMBDA 
     394#if RDOQ_CHROMA_LAMBDA
    395395// for RDOQ
    396   m_pcTrQuant->setLambda( dLambda, dLambda / weight );   
     396  m_pcTrQuant->setLambda( dLambda, dLambda / weight );
    397397#else
    398398  m_pcTrQuant->setLambda( dLambda );
     
    401401#if SAO_CHROMA_LAMBDA
    402402// For SAO
    403   rpcSlice   ->setLambda( dLambda, dLambda / weight ); 
     403  rpcSlice   ->setLambda( dLambda, dLambda / weight );
    404404#else
    405405  rpcSlice   ->setLambda( dLambda );
    406406#endif
    407  
     407
    408408#if HB_LAMBDA_FOR_LDC
    409409  // restore original slice type
    410410  eSliceType = (pocLast == 0 || pocCurr % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
    411  
     411
    412412#if SVC_EXTENSION
    413413  if(m_pcCfg->getLayerId() > 0)
     
    418418  rpcSlice->setSliceType        ( eSliceType );
    419419#endif
    420  
     420
    421421  if (m_pcCfg->getUseRecalculateQPAccordingToLambda())
    422422  {
    423423    dQP = xGetQPValueAccordingToLambda( dLambda );
    424424#if REPN_FORMAT_IN_VPS
    425     iQP = max( -rpcSlice->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );   
    426 #else
    427     iQP = max( -pSPS->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );   
     425    iQP = max( -rpcSlice->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );
     426#else
     427    iQP = max( -pSPS->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) );
    428428#endif
    429429  }
     
    438438  rpcSlice->setNumRefIdx(REF_PIC_LIST_0,m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive);
    439439  rpcSlice->setNumRefIdx(REF_PIC_LIST_1,m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive);
    440  
     440
    441441  if ( m_pcCfg->getDeblockingFilterMetric() )
    442442  {
     
    479479
    480480  rpcSlice->setDepth            ( depth );
    481  
     481
    482482  pcPic->setTLayer( m_pcCfg->getGOPEntry(iGOPid).m_temporalId );
    483483#if TEMP_SCALABILITY_FIX
     
    493493  assert( m_apcPicYuvPred );
    494494  assert( m_apcPicYuvResi );
    495  
     495
    496496  pcPic->setPicYuvPred( m_apcPicYuvPred );
    497497  pcPic->setPicYuvResi( m_apcPicYuvResi );
     
    557557#endif
    558558
    559 #if RDOQ_CHROMA_LAMBDA 
     559#if RDOQ_CHROMA_LAMBDA
    560560  // for RDOQ
    561561  m_pcTrQuant->setLambda( lambda, lambda / weight );
     
    665665#endif
    666666
    667 #if RDOQ_CHROMA_LAMBDA 
     667#if RDOQ_CHROMA_LAMBDA
    668668  // for RDOQ
    669   m_pcTrQuant->setLambda( lambda, lambda / weight );   
     669  m_pcTrQuant->setLambda( lambda, lambda / weight );
    670670#else
    671671  m_pcTrQuant->setLambda( lambda );
     
    674674#if SAO_CHROMA_LAMBDA
    675675  // For SAO
    676   pcSlice   ->setLambda( lambda, lambda / weight ); 
     676  pcSlice   ->setLambda( lambda, lambda / weight );
    677677#else
    678678  pcSlice   ->setLambda( lambda );
     
    692692  Int iMaxSR = m_pcCfg->getSearchRange();
    693693  Int iNumPredDir = pcSlice->isInterP() ? 1 : 2;
    694  
     694
    695695  for (Int iDir = 0; iDir <= iNumPredDir; iDir++)
    696696  {
     
    726726  }
    727727#endif
    728  
     728
    729729  TComSlice* pcSlice        = rpcPic->getSlice(getSliceIdx());
    730730  Double     dPicRdCostBest = MAX_DOUBLE;
    731731  UInt       uiQpIdxBest = 0;
    732  
     732
    733733  Double dFrameLambda;
    734734#if FULL_NBIT
     
    737737  Int    SHIFT_QP = 12;
    738738#endif
    739  
     739
    740740  // set frame lambda
    741741  if (m_pcCfg->getGOPSize() > 1)
     
    748748  }
    749749  m_pcRdCost      ->setFrameLambda(dFrameLambda);
    750  
     750
    751751  // for each QP candidate
    752752  for ( UInt uiQpIdx = 0; uiQpIdx < 2 * m_pcCfg->getDeltaQpRD() + 1; uiQpIdx++ )
     
    776776#endif
    777777
    778 #if RDOQ_CHROMA_LAMBDA 
     778#if RDOQ_CHROMA_LAMBDA
    779779    // for RDOQ
    780780    m_pcTrQuant   ->setLambda( m_pdRdPicLambda[uiQpIdx], m_pdRdPicLambda[uiQpIdx] / weight );
     
    784784#if SAO_CHROMA_LAMBDA
    785785    // For SAO
    786     pcSlice       ->setLambda              ( m_pdRdPicLambda[uiQpIdx], m_pdRdPicLambda[uiQpIdx] / weight ); 
     786    pcSlice       ->setLambda              ( m_pdRdPicLambda[uiQpIdx], m_pdRdPicLambda[uiQpIdx] / weight );
    787787#else
    788788    pcSlice       ->setLambda              ( m_pdRdPicLambda[uiQpIdx] );
    789789#endif
    790    
     790
    791791    // try compress
    792792    compressSlice   ( rpcPic );
    793    
     793
    794794    Double dPicRdCost;
    795795    UInt64 uiPicDist        = m_uiPicDist;
    796796    UInt64 uiALFBits        = 0;
    797    
     797
    798798    m_pcGOPEncoder->preLoopFilterPicAll( rpcPic, uiPicDist, uiALFBits );
    799    
     799
    800800    // compute RD cost and choose the best
    801801    dPicRdCost = m_pcRdCost->calcRdCost64( m_uiPicTotalBits + uiALFBits, uiPicDist, true, DF_SSE_FRAME);
    802    
     802
    803803    if ( dPicRdCost < dPicRdCostBest )
    804804    {
     
    807807    }
    808808  }
    809  
     809
    810810  // set best values
    811811  pcSlice       ->setSliceQp             ( m_piRdPicQp    [uiQpIdxBest] );
     
    832832#endif
    833833
    834 #if RDOQ_CHROMA_LAMBDA 
    835   // for RDOQ 
    836   m_pcTrQuant   ->setLambda( m_pdRdPicLambda[uiQpIdxBest], m_pdRdPicLambda[uiQpIdxBest] / weight ); 
     834#if RDOQ_CHROMA_LAMBDA
     835  // for RDOQ
     836  m_pcTrQuant   ->setLambda( m_pdRdPicLambda[uiQpIdxBest], m_pdRdPicLambda[uiQpIdxBest] / weight );
    837837#else
    838838  m_pcTrQuant   ->setLambda              ( m_pdRdPicLambda[uiQpIdxBest] );
     
    840840#if SAO_CHROMA_LAMBDA
    841841  // For SAO
    842   pcSlice       ->setLambda              ( m_pdRdPicLambda[uiQpIdxBest], m_pdRdPicLambda[uiQpIdxBest] / weight ); 
     842  pcSlice       ->setLambda              ( m_pdRdPicLambda[uiQpIdxBest], m_pdRdPicLambda[uiQpIdxBest] / weight );
    843843#else
    844844  pcSlice       ->setLambda              ( m_pdRdPicLambda[uiQpIdxBest] );
     
    862862
    863863  UInt uiEncCUOrder;
    864   uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU()); 
     864  uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());
    865865  for( uiEncCUOrder = uiStartCUAddr/rpcPic->getNumPartInCU();
    866866       uiEncCUOrder < (uiBoundingCUAddr+(rpcPic->getNumPartInCU()-1))/rpcPic->getNumPartInCU();
     
    898898  TComSlice* pcSlice            = rpcPic->getSlice(getSliceIdx());
    899899  xDetermineStartAndBoundingCUAddr ( uiStartCUAddr, uiBoundingCUAddr, rpcPic, false );
    900  
     900
    901901  // initialize cost values
    902902  m_uiPicTotalBits  = 0;
    903903  m_dPicRdCost      = 0;
    904904  m_uiPicDist       = 0;
    905  
     905
    906906  // set entropy coder
    907907  if( m_pcCfg->getUseSBACRD() )
     
    921921    m_pcEntropyCoder->setBitstream    ( m_pcBitCounter );
    922922  }
    923  
     923
    924924  //------------------------------------------------------------------------------
    925925  //  Weighted Prediction parameters estimation.
     
    930930    xCalcACDCParamSlice(pcSlice);
    931931  }
     932#if O0194_WEIGHTED_PREDICTION_CGS
     933  else{
     934    // Calculate for the base layer to be used in EL as Inter layer reference
     935    xCalcACDCParamSlice(pcSlice);
     936    wpACDCParam * temp_weightACDCParam;
     937
     938    pcSlice->getWpAcDcParam(temp_weightACDCParam);
     939    g_refWeightACDCParam = (void *) temp_weightACDCParam;
     940  }
     941#endif
    932942
    933943  Bool bWp_explicit = (pcSlice->getSliceType()==P_SLICE && pcSlice->getPPS()->getUseWP()) || (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPred());
     
    10211031        m_pcBufferSbacCoders[uiTileCol].loadContexts( CTXMem[1] );
    10221032        Int iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles();
    1023         uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU()); 
     1033        uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());
    10241034        uiLin     = uiCUAddr / uiWidthInLCUs;
    10251035        uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(rpcPic->getPicSym()->getCUOrderMap(uiCUAddr))*iNumSubstreamsPerTile
     
    10981108          pcCUTR = rpcPic->getCU( uiCUAddr - uiWidthInCU + 1 );
    10991109        }
    1100         if ( ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) || 
     1110        if ( ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) ||
    11011111             (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getSliceCurStartCUAddr()) ||
    11021112             ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))
     
    11371147      m_pcEntropyCoder->setEntropyCoder ( m_pcRDGoOnSbacCoder, pcSlice );
    11381148      m_pcEntropyCoder->setBitstream( &pcBitCounters[uiSubStrm] );
    1139      
     1149
    11401150      ((TEncBinCABAC*)m_pcRDGoOnSbacCoder->getEncBinIf())->setBinCountingEnableFlag(true);
    11411151
     
    12421252        m_pcRdCost->setLambda(oldLambda);
    12431253#if RATE_CONTROL_INTRA
    1244         m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, 
     1254        m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda,
    12451255          pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() );
    12461256#else
     
    12501260#endif
    12511261#endif
    1252      
     1262
    12531263      // restore entropy coder to an initial stage
    12541264      m_pcEntropyCoder->setEntropyCoder ( m_pppcRDSbacCoder[0][CI_CURR_BEST], pcSlice );
     
    12751285      {
    12761286         ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]->load( m_pppcRDSbacCoder[0][CI_CURR_BEST] );
    1277        
     1287
    12781288         //Store probabilties of second LCU in line into buffer
    12791289         if ( ( uiCol == uiTileLCUX+1) && (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && m_pcCfg->getWaveFrontsynchro())
     
    13251335
    13261336#if RATE_CONTROL_INTRA
    1327         m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, 
     1337        m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda,
    13281338          pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() );
    13291339#else
     
    13501360      }
    13511361    }
    1352    
     1362
    13531363    m_uiPicTotalBits += pcCU->getTotalBits();
    13541364    m_dPicRdCost     += pcCU->getTotalCost();
     
    14011411    m_pcEntropyCoder->setEntropyCoder ( m_pcSbacCoder, pcSlice );
    14021412  }
    1403  
     1413
    14041414  m_pcCuEncoder->setBitCounter( NULL );
    14051415  m_pcBitCounter = NULL;
     
    14271437      m_pcBufferSbacCoders[ui].load(m_pcSbacCoder); //init. state
    14281438    }
    1429    
     1439
    14301440    for (Int iSubstrmIdx=0; iSubstrmIdx < iNumSubstreams; iSubstrmIdx++)
    14311441    {
     
    15241534        }
    15251535        if ( (true/*bEnforceSliceRestriction*/ &&
    1526              ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) || 
     1536             ((pcCUTR==NULL) || (pcCUTR->getSlice()==NULL) ||
    15271537             (pcCUTR->getSCUAddr()+uiMaxParts-1 < pcSlice->getSliceCurStartCUAddr()) ||
    15281538             ((rpcPic->getPicSym()->getTileIdxMap( pcCUTR->getAddr() ) != rpcPic->getPicSym()->getTileIdxMap(uiCUAddr)))
     
    15791589    }
    15801590
    1581     TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr );   
     1591    TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr );
    15821592    if ( pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) )
    15831593    {
     
    16131623        if (allowMergeLeft)
    16141624        {
    1615           m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(mergeLeft); 
     1625          m_pcEntropyCoder->m_pcEntropyCoderIf->codeSaoMerge(mergeLeft);
    16161626        }
    16171627        else
     
    16761686#if ENC_DEC_TRACE
    16771687    g_bJustDoIt = g_bEncDecTraceDisable;
    1678 #endif   
     1688#endif
    16791689    if( m_pcCfg->getUseSBACRD() )
    16801690    {
    16811691       pcSbacCoders[uiSubStrm].load(m_pcSbacCoder);   //load back status of the entropy coder after encoding the LCU into relevant bitstream entropy coder
    1682        
     1692
    16831693
    16841694       //Store probabilties of second LCU in line into buffer
     
    17331743  UInt uiNumberOfCUsInFrame = rpcPic->getNumCUsInFrame();
    17341744  uiBoundingCUAddrSlice     = uiNumberOfCUsInFrame;
    1735   if (bEncodeSlice) 
     1745  if (bEncodeSlice)
    17361746  {
    17371747    UInt uiCUAddrIncrement;
     
    17691779      uiBoundingCUAddrSlice    = uiNumberOfCUsInFrame*rpcPic->getNumPartInCU();
    17701780      break;
    1771     } 
     1781    }
    17721782    // WPP: if a slice does not start at the beginning of a CTB row, it must end within the same CTB row
    17731783    if (pcSlice->getPPS()->getNumSubstreams() > 1 && (uiStartCUAddrSlice % (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU()) != 0))
     
    18091819      uiBoundingCUAddrSlice    = uiNumberOfCUsInFrame*rpcPic->getNumPartInCU();
    18101820      break;
    1811     } 
     1821    }
    18121822    // WPP: if a slice does not start at the beginning of a CTB row, it must end within the same CTB row
    18131823    if (pcSlice->getPPS()->getNumSubstreams() > 1 && (uiStartCUAddrSlice % (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU()) != 0))
     
    18191829
    18201830  Bool tileBoundary = false;
    1821   if ((m_pcCfg->getSliceMode() == FIXED_NUMBER_OF_LCU || m_pcCfg->getSliceMode() == FIXED_NUMBER_OF_BYTES) && 
     1831  if ((m_pcCfg->getSliceMode() == FIXED_NUMBER_OF_LCU || m_pcCfg->getSliceMode() == FIXED_NUMBER_OF_BYTES) &&
    18221832      (m_pcCfg->getNumRowsMinus1() > 0 || m_pcCfg->getNumColumnsMinus1() > 0))
    18231833  {
     
    18321842    }
    18331843    tileBoundingCUAddrSlice = lcuEncAddr*rpcPic->getNumPartInCU();
    1834    
     1844
    18351845    if (tileBoundingCUAddrSlice < uiBoundingCUAddrSlice)
    18361846    {
     
    18451855  startCUAddrSliceSegment    = pcSlice->getSliceSegmentCurStartCUAddr();
    18461856  boundingCUAddrSliceSegment = uiNumberOfCUsInFrame;
    1847   if (bEncodeSlice) 
     1857  if (bEncodeSlice)
    18481858  {
    18491859    UInt uiCUAddrIncrement;
     
    18801890      boundingCUAddrSliceSegment    = uiNumberOfCUsInFrame*rpcPic->getNumPartInCU();
    18811891      break;
    1882     } 
     1892    }
    18831893    // WPP: if a slice segment does not start at the beginning of a CTB row, it must end within the same CTB row
    18841894    if (pcSlice->getPPS()->getNumSubstreams() > 1 && (startCUAddrSliceSegment % (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU()) != 0))
     
    19191929      boundingCUAddrSliceSegment    = uiNumberOfCUsInFrame*rpcPic->getNumPartInCU();
    19201930      break;
    1921     } 
     1931    }
    19221932    // WPP: if a slice segment does not start at the beginning of a CTB row, it must end within the same CTB row
    19231933    if (pcSlice->getPPS()->getNumSubstreams() > 1 && (startCUAddrSliceSegment % (rpcPic->getFrameWidthInCU()*rpcPic->getNumPartInCU()) != 0))
     
    19271937    pcSlice->setSliceSegmentCurEndCUAddr( boundingCUAddrSliceSegment );
    19281938  }
    1929   if ((m_pcCfg->getSliceSegmentMode() == FIXED_NUMBER_OF_LCU || m_pcCfg->getSliceSegmentMode() == FIXED_NUMBER_OF_BYTES) && 
     1939  if ((m_pcCfg->getSliceSegmentMode() == FIXED_NUMBER_OF_LCU || m_pcCfg->getSliceSegmentMode() == FIXED_NUMBER_OF_BYTES) &&
    19301940    (m_pcCfg->getNumRowsMinus1() > 0 || m_pcCfg->getNumColumnsMinus1() > 0))
    19311941  {
     
    19791989  }
    19801990  UInt uiRealStartAddress = rpcPic->getPicSym()->getPicSCUEncOrder(uiExternalAddress*rpcPic->getNumPartInCU()+uiInternalAddress);
    1981  
     1991
    19821992  pcSlice->setSliceSegmentCurStartCUAddr(uiRealStartAddress);
    19831993  startCUAddrSliceSegment=uiRealStartAddress;
    1984  
     1994
    19851995  //calculate real slice start address
    19861996  uiInternalAddress = rpcPic->getPicSym()->getPicSCUAddr(pcSlice->getSliceCurStartCUAddr()) % rpcPic->getNumPartInCU();
     
    20072017  }
    20082018  uiRealStartAddress = rpcPic->getPicSym()->getPicSCUEncOrder(uiExternalAddress*rpcPic->getNumPartInCU()+uiInternalAddress);
    2009  
     2019
    20102020  pcSlice->setSliceCurStartCUAddr(uiRealStartAddress);
    20112021  uiStartCUAddrSlice=uiRealStartAddress;
    2012  
     2022
    20132023  // Make a joint decision based on reconstruction and dependent slice bounds
    20142024  startCUAddr    = max(uiStartCUAddrSlice   , startCUAddrSliceSegment   );
     
    20222032    if ( (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_LCU && m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_LCU)
    20232033      || (m_pcCfg->getSliceMode()==0 && m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_LCU)
    2024       || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_LCU && m_pcCfg->getSliceSegmentMode()==0) 
     2034      || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_LCU && m_pcCfg->getSliceSegmentMode()==0)
    20252035      || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_LCU)
    2026       || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceSegmentMode()==0) 
     2036      || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceSegmentMode()==0)
    20272037      || (m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceMode()==0)
    20282038      || tileBoundary
  • branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncTop.cpp

    r460 r466  
    8888  m_bMFMEnabledFlag = false;
    8989#endif
     90#if SCALED_REF_LAYER_OFFSETS
    9091  m_numScaledRefLayerOffsets = 0;
     92#endif
     93#endif
    9194#if POC_RESET_FLAG
    9295  m_pocAdjustmentValue     = 0;
    9396#endif
    94 #endif //SVC_EXTENSION
    9597}
    9698
     
    173175    }
    174176  }
    175 
    176 #if LAYER_CTB
    177   memcpy(g_auiLayerZscanToRaster[m_layerId], g_auiZscanToRaster, sizeof( g_auiZscanToRaster ) );
    178   memcpy(g_auiLayerRasterToZscan[m_layerId], g_auiRasterToZscan, sizeof( g_auiRasterToZscan ) );
    179   memcpy(g_auiLayerRasterToPelX[m_layerId],  g_auiRasterToPelX,  sizeof( g_auiRasterToPelX ) );
    180   memcpy(g_auiLayerRasterToPelY[m_layerId],  g_auiRasterToPelY,  sizeof( g_auiRasterToPelY ) );
    181 #endif
    182177}
    183178
     
    876871#if SVC_EXTENSION
    877872  m_cSPS.setLayerId(m_layerId);
     873#endif
    878874#if REF_IDX_MFM
    879875#if !M0457_COL_PICTURE_SIGNALING
     
    881877#endif
    882878#endif
     879#if SCALED_REF_LAYER_OFFSETS
    883880  m_cSPS.setNumScaledRefLayerOffsets(m_numScaledRefLayerOffsets);
    884881  for(Int i = 0; i < m_cSPS.getNumScaledRefLayerOffsets(); i++)
     
    886883    m_cSPS.getScaledRefLayerWindow(i) = m_scaledRefLayerWindow[i];
    887884  }
    888 #endif //SVC_EXTENSION
     885#endif
    889886  ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL();
    890887  profileTierLevel.setLevelIdc(m_level);
  • branches/SHM-4.0-dev/source/Lib/TLibEncoder/TEncTop.h

    r460 r466  
    140140  Int                     m_ilSampleOnlyPred;
    141141#endif
     142#if SCALED_REF_LAYER_OFFSETS
    142143  UInt                    m_numScaledRefLayerOffsets;
    143144  Window                  m_scaledRefLayerWindow[MAX_LAYERS];
     145#endif
    144146#if POC_RESET_FLAG
    145147  Int                     m_pocAdjustmentValue;
    146148#endif
    147 #endif //SVC_EXTENSION
     149#endif
    148150protected:
    149151  Void  xGetNewPicBuffer  ( TComPic*& rpcPic );           ///< get picture buffer which will be processed
     
    207209  Int                     getNumPicRcvd         () { return m_iNumPicRcvd;            }
    208210  Void                    setNumPicRcvd         ( Int num ) { m_iNumPicRcvd = num;      }
     211#if SCALED_REF_LAYER_OFFSETS
    209212  Void                    setNumScaledRefLayerOffsets(Int x) { m_numScaledRefLayerOffsets = x; }
    210213  UInt                    getNumScaledRefLayerOffsets() { return m_numScaledRefLayerOffsets; }
    211214  Window&  getScaledRefLayerWindow(Int x)            { return m_scaledRefLayerWindow[x]; }
    212 #endif //SVC_EXTENSION
     215#endif
     216#endif
    213217
    214218  // -------------------------------------------------------------------------------------------------------------------
  • branches/SHM-4.0-dev/source/Lib/TLibEncoder/WeightPredAnalysis.cpp

    r313 r466  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license. 
     4 * granted under this license.
    55 *
    66 * Copyright (c) 2010-2013, ITU/ISO/IEC
     
    5151  for ( Int iList =0 ; iList<2 ; iList++ )
    5252  {
    53     for ( Int iRefIdx=0 ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) 
     53    for ( Int iRefIdx=0 ; iRefIdx<MAX_NUM_REF ; iRefIdx++ )
    5454    {
    5555      for ( Int comp=0 ; comp<3 ;comp++ )
     
    7474  TComPicYuv*   pPic = slice->getPic()->getPicYuvOrg();
    7575  Int   iSample  = 0;
     76#if O0194_WEIGHTED_PREDICTION_CGS
     77  // Define here to assign the parameter of "iSample"
     78  wpACDCParam weightACDCParam[3];
     79#endif
    7680
    7781  // calculate DC/AC value for Y
     
    8185  pOrg = pPic->getLumaAddr();
    8286  Int64  iOrgACY  = xCalcACValueSlice(slice, pOrg, iOrgNormDCY);
     87#if O0194_WEIGHTED_PREDICTION_CGS
     88  weightACDCParam[0].iSamples = iSample;
     89#endif
    8390
    8491  // calculate DC/AC value for Cb
     
    8895  pOrg = pPic->getCbAddr();
    8996  Int64  iOrgACCb  = xCalcACValueUVSlice(slice, pOrg, iOrgNormDCCb);
     97#if O0194_WEIGHTED_PREDICTION_CGS
     98  weightACDCParam[1].iSamples = iSample;
     99#endif
    90100
    91101  // calculate DC/AC value for Cr
     
    95105  pOrg = pPic->getCrAddr();
    96106  Int64  iOrgACCr  = xCalcACValueUVSlice(slice, pOrg, iOrgNormDCCr);
    97 
     107#if O0194_WEIGHTED_PREDICTION_CGS
     108  weightACDCParam[2].iSamples = iSample;
     109#endif
     110
     111#if !O0194_WEIGHTED_PREDICTION_CGS
    98112  wpACDCParam weightACDCParam[3];
     113#endif
    99114  weightACDCParam[0].iAC = iOrgACY;
    100115  weightACDCParam[0].iDC = iOrgNormDCY;
     
    138153  for ( Int iList=0 ; iList<2 ; iList++ )
    139154  {
    140     for ( Int iRefIdx=0 ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) 
    141     {
    142       for ( Int iComp=0 ; iComp<3 ;iComp++ ) 
     155    for ( Int iRefIdx=0 ; iRefIdx<MAX_NUM_REF ; iRefIdx++ )
     156    {
     157      for ( Int iComp=0 ; iComp<3 ;iComp++ )
    143158      {
    144159        wpScalingParam  *pwp = &(m_wp[iList][iRefIdx][iComp]);
     
    154169    for ( Int iList=0 ; iList<2 ; iList++ )
    155170    {
    156       for ( Int iRefIdx=0 ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) 
     171      for ( Int iRefIdx=0 ; iRefIdx<MAX_NUM_REF ; iRefIdx++ )
    157172      {
    158         for ( Int iComp=0 ; iComp<3 ;iComp++ ) 
     173        for ( Int iComp=0 ; iComp<3 ;iComp++ )
    159174        {
    160175          wpScalingParam  *pwp = &(m_wp[iList][iRefIdx][iComp]);
     
    195210  // selecting whether WP is used, or not
    196211  xSelectWP(slice, m_wp, iDenom);
    197  
     212
    198213  slice->setWpScaling( m_wp );
    199214
     
    216231      slice->getWpAcDcParam(currWeightACDCParam);
    217232      slice->getRefPic(eRefPicList, refIdxTemp)->getSlice(0)->getWpAcDcParam(refWeightACDCParam);
     233#if O0194_WEIGHTED_PREDICTION_CGS
     234      if (slice->getRefPic(eRefPicList, refIdxTemp)->isILR(1)){
     235        refWeightACDCParam = (wpACDCParam *)g_refWeightACDCParam;
     236      }
     237#endif
    218238
    219239      for ( Int comp = 0; comp < 3; comp++ )
     
    229249        Int64 refDC = refWeightACDCParam[comp].iDC;
    230250        Int64 refAC = refWeightACDCParam[comp].iAC;
     251#if O0194_WEIGHTED_PREDICTION_CGS
     252        if (slice->getRefPic(eRefPicList, refIdxTemp)->isILR(1)){
     253          refAC *= (double)currWeightACDCParam[comp].iSamples/refWeightACDCParam[comp].iSamples;
     254#if O0194_JOINT_US_BITSHIFT
     255          refAC *= (1<<(g_bitDepthYLayer[1]-g_bitDepthYLayer[0]));
     256          refDC *= (1<<(g_bitDepthYLayer[1]-g_bitDepthYLayer[0]));
     257#endif
     258         }
     259#endif
    231260
    232261        // calculating iWeight and iOffset params
     
    234263        Int weight = (Int)( 0.5 + dWeight * (Double)(1<<log2Denom) );
    235264        Int offset = (Int)( ((currDC<<log2Denom) - ((Int64)weight * refDC) + (Int64)realOffset) >> realLog2Denom );
     265#if O0194_WEIGHTED_PREDICTION_CGS
     266        if (slice->getRefPic(eRefPicList, refIdxTemp)->isILR(1)){
     267        }
     268        else{
     269          dWeight = 1;
     270          offset  = 0;
     271        }
     272        weight = (Int)( 0.5 + dWeight * (Double)(1<<log2Denom) );
     273#endif
    236274
    237275        // Chroma offset range limitation
     
    253291        if(deltaWeight > 127 || deltaWeight < -128)
    254292          return (false);
     293#if O0194_WEIGHTED_PREDICTION_CGS
     294        // make sure the reference frames other than ILR are not using weighted prediction
     295        if (!(slice->getRefPic(eRefPicList, refIdxTemp)->isILR(1))){
     296          continue;
     297        }
     298#endif
    255299
    256300        m_wp[refList][refIdxTemp][comp].bPresentFlag = true;
     
    264308}
    265309
    266 /** select whether weighted pred enables or not. 
     310/** select whether weighted pred enables or not.
    267311 * \param TComSlice *slice
    268312 * \param wpScalingParam
     
    325369}
    326370
    327 /** calculate DC value of original image for luma. 
     371/** calculate DC value of original image for luma.
    328372 * \param TComSlice *slice
    329373 * \param Pel *pPel
     
    345389}
    346390
    347 /** calculate AC value of original image for luma. 
     391/** calculate AC value of original image for luma.
    348392 * \param TComSlice *slice
    349393 * \param Pel *pPel
     
    363407}
    364408
    365 /** calculate DC value of original image for chroma. 
     409/** calculate DC value of original image for chroma.
    366410 * \param TComSlice *slice
    367411 * \param Pel *pPel
     
    383427}
    384428
    385 /** calculate AC value of original image for chroma. 
     429/** calculate AC value of original image for chroma.
    386430 * \param TComSlice *slice
    387431 * \param Pel *pPel
     
    401445}
    402446
    403 /** calculate DC value. 
     447/** calculate DC value.
    404448 * \param Pel *pPel
    405449 * \param Int iWidth
     
    423467}
    424468
    425 /** calculate AC value. 
     469/** calculate AC value.
    426470 * \param Pel *pPel
    427471 * \param Int iWidth
     
    446490}
    447491
    448 /** calculate SAD values for both WP version and non-WP version. 
     492/** calculate SAD values for both WP version and non-WP version.
    449493 * \param Pel *pOrgPel
    450494 * \param Pel *pRefPel
Note: See TracChangeset for help on using the changeset viewer.