Changeset 713 in SHVCSoftware for trunk/source/Lib/TLibEncoder


Ignore:
Timestamp:
21 Apr 2014, 04:44:16 (12 years ago)
Author:
seregin
Message:

merge with SHM-6-dev

Location:
trunk
Files:
20 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/source

  • trunk/source/Lib/TLibEncoder/AnnexBwrite.h

    r595 r713  
    5858
    5959    static const Char start_code_prefix[] = {0,0,0,1};
    60     if (it == au.begin() || nalu.m_nalUnitType == NAL_UNIT_SPS || nalu.m_nalUnitType == NAL_UNIT_PPS)
     60    if (it == au.begin() || nalu.m_nalUnitType == NAL_UNIT_VPS || nalu.m_nalUnitType == NAL_UNIT_SPS || nalu.m_nalUnitType == NAL_UNIT_PPS)
    6161    {
    6262      /* From AVC, When any of the following conditions are fulfilled, the
  • trunk/source/Lib/TLibEncoder/NALwrite.cpp

    r595 r713  
    9191  vector<uint8_t>& rbsp   = nalu.m_Bitstream.getFIFO();
    9292
    93 #if P0130_EOB
    94   if (rbsp.size() == 0) return;
    95 #endif
     93  if (rbsp.size() == 0)
     94  {
     95    return;
     96  }
    9697
    9798  for (vector<uint8_t>::iterator it = rbsp.begin(); it != rbsp.end();)
  • trunk/source/Lib/TLibEncoder/SEIwrite.cpp

    r644 r713  
    8787    fprintf( g_hTrace, "=========== Tone Mapping Info SEI message ===========\n");
    8888    break;
     89#if Q0074_SEI_COLOR_MAPPING
     90  case SEI::COLOR_MAPPING_INFO:
     91    fprintf( g_hTrace, "=========== Color Mapping Info SEI message ===========\n");
     92    break;
     93#endif
    8994  case SEI::SOP_DESCRIPTION:
    9095    fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");
     
    172177    xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei));
    173178    break;
     179#if Q0074_SEI_COLOR_MAPPING
     180  case SEI::COLOR_MAPPING_INFO:
     181    xWriteSEIColorMappingInfo(*static_cast<const SEIColorMappingInfo*>(&sei));
     182    break;
     183#endif
    174184  case SEI::SOP_DESCRIPTION:
    175185    xWriteSEISOPDescription(*static_cast<const SEISOPDescription*>(&sei));
     
    333343Void SEIWriter::xWriteSEIActiveParameterSets(const SEIActiveParameterSets& sei)
    334344{
    335   WRITE_CODE(sei.activeVPSId,     4, "active_vps_id");
    336   WRITE_FLAG(sei.m_fullRandomAccessFlag, "full_random_access_flag");
    337   WRITE_FLAG(sei.m_noParamSetUpdateFlag, "no_param_set_update_flag");
     345  WRITE_CODE(sei.activeVPSId,     4,         "active_video_parameter_set_id");
     346  WRITE_FLAG(sei.m_selfContainedCvsFlag,     "self_contained_cvs_flag");
     347  WRITE_FLAG(sei.m_noParameterSetUpdateFlag, "no_parameter_set_update_flag");
    338348  WRITE_UVLC(sei.numSpsIdsMinus1,    "num_sps_ids_minus1");
    339349
    340   assert (sei.activeSeqParamSetId.size() == (sei.numSpsIdsMinus1 + 1));
    341 
    342   for (Int i = 0; i < sei.activeSeqParamSetId.size(); i++)
    343   {
    344     WRITE_UVLC(sei.activeSeqParamSetId[i], "active_seq_param_set_id");
    345   }
    346 
    347   UInt uiBits = m_pcBitIf->getNumberOfWrittenBits();
    348   UInt uiAlignedBits = ( 8 - (uiBits&7) ) % 8; 
    349   if(uiAlignedBits)
    350   {
    351     WRITE_FLAG(1, "alignment_bit" );
    352     uiAlignedBits--;
    353     while(uiAlignedBits--)
    354     {
    355       WRITE_FLAG(0, "alignment_bit" );
    356     }
    357   }
     350  assert (sei.activeSeqParameterSetId.size() == (sei.numSpsIdsMinus1 + 1));
     351
     352  for (Int i = 0; i < sei.activeSeqParameterSetId.size(); i++)
     353  {
     354    WRITE_UVLC(sei.activeSeqParameterSetId[i], "active_seq_parameter_set_id");
     355  }
     356  xWriteByteAlign();
    358357}
    359358
     
    550549        {
    551550          WRITE_CODE( sei.m_cameraIsoSpeedValue,    32,    "camera_iso_speed_value" );
     551        }
     552        WRITE_CODE( sei.m_exposureIndexIdc,     8,    "exposure_index_idc" );
     553        if( sei.m_exposureIndexIdc == 255) //Extended_ISO
     554        {
     555          WRITE_CODE( sei.m_exposureIndexValue,     32,    "exposure_index_value" );
    552556        }
    553557        WRITE_FLAG( sei.m_exposureCompensationValueSignFlag,           "exposure_compensation_value_sign_flag" );
     
    572576}
    573577
     578#if Q0074_SEI_COLOR_MAPPING
     579Void SEIWriter::xWriteSEIColorMappingInfo(const SEIColorMappingInfo& sei)
     580{
     581  WRITE_UVLC( sei.m_colorMapId,                    "colour_map_id" );
     582  WRITE_FLAG( sei.m_colorMapCancelFlag,            "colour_map_cancel_flag" );
     583  if( !sei.m_colorMapCancelFlag )
     584  {
     585    WRITE_FLAG( sei.m_colorMapPersistenceFlag,            "colour_map_persistence_flag" );
     586    WRITE_FLAG( sei.m_colorMap_video_signal_type_present_flag,            "colour_map_video_signal_type_present_flag" );
     587    if ( sei.m_colorMap_video_signal_type_present_flag )
     588    {
     589      WRITE_FLAG( sei.m_colorMap_video_full_range_flag,       "colour_map_video_full_range_flag" );
     590      WRITE_CODE( sei.m_colorMap_primaries,                 8,      "colour_map_primaries" );
     591      WRITE_CODE( sei.m_colorMap_transfer_characteristics,  8,      "colour_map_transfer_characteristics" );
     592      WRITE_CODE( sei.m_colorMap_matrix_coeffs,             8,      "colour_map_matrix_coeffs" );
     593    }
     594  }
     595
     596  WRITE_CODE( sei.m_colour_map_coded_data_bit_depth,  5,  "colour_map_coded_data_bit_depth" );
     597  WRITE_CODE( sei.m_colour_map_target_bit_depth,  5,      "colour_map_target_bit_depth" );
     598  WRITE_UVLC( sei.m_colorMapModelId,                      "colour_map_model_id" );
     599
     600  assert( sei.m_colorMapModelId == 0 );
     601 
     602  for( Int i=0 ; i<3 ; i++ )
     603  {
     604    WRITE_CODE( sei.m_num_input_pivots[i] - 1,         8,      "num_input_pivots_minus1[i]" );
     605    for( Int j=0 ; j<sei.m_num_input_pivots[i] ; j++ )
     606    {
     607      WRITE_CODE( sei.m_coded_input_pivot_value[i][j],  (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "coded_input_pivot_value[i][j]" );
     608      WRITE_CODE( sei.m_target_input_pivot_value[i][j], (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "target_input_pivot_value[i][j]" );
     609    }
     610  }
     611
     612  WRITE_FLAG( sei.m_matrix_flag,            "matrix_flag" );
     613  if( sei.m_matrix_flag )
     614  {
     615    WRITE_CODE( sei.m_log2_matrix_denom, 4, "log2_matrix_denom" );
     616    for( Int i=0 ; i<3 ; i++ )
     617    {
     618      for( Int j=0 ; j<3 ; j++ )
     619      {
     620        WRITE_SVLC( sei.m_matrix_coef[i][j],  "matrix_coef[i][j]" );
     621      }
     622    }
     623  }
     624
     625  for( Int i=0 ; i<3 ; i++ )
     626  {
     627    WRITE_CODE( sei.m_num_output_pivots[i] - 1,         8,      "num_output_pivots_minus1[i]" );
     628    for( Int j=0 ; j<sei.m_num_output_pivots[i] ; j++ )
     629    {
     630      WRITE_CODE( sei.m_coded_output_pivot_value[i][j],  (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "coded_output_pivot_value[i][j]" );
     631      WRITE_CODE( sei.m_target_output_pivot_value[i][j], (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "target_output_pivot_value[i][j]" );
     632    }
     633  }
     634
     635  xWriteByteAlign();
     636}
     637#endif
     638
    574639Void SEIWriter::xWriteSEIDisplayOrientation(const SEIDisplayOrientation &sei)
    575640{
     
    633698    for (UInt i = (sei.m_defaultOpFlag ? 1 : 0); i <= sei.m_nestingNumOpsMinus1; i++)
    634699    {
     700      WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" );
    635701      WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3,  "nesting_max_temporal_id"       );
    636702      WRITE_UVLC( sei.m_nestingOpIdx[i],                  "nesting_op_idx"                );
  • trunk/source/Lib/TLibEncoder/SEIwrite.h

    r644 r713  
    7272  Void xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei);
    7373  Void xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei);
     74#if Q0074_SEI_COLOR_MAPPING
     75  Void xWriteSEIColorMappingInfo(const SEIColorMappingInfo& sei);
     76#endif
    7477  Void xWriteSEISOPDescription(const SEISOPDescription& sei);
    7578#if O0164_MULTI_LAYER_HRD
  • trunk/source/Lib/TLibEncoder/TEncCavlc.cpp

    r649 r713  
    154154
    155155
    156 Void TEncCavlc::codePPS( TComPPS* pcPPS )
     156Void TEncCavlc::codePPS( TComPPS* pcPPS
     157#if Q0048_CGS_3D_ASYMLUT
     158  , TEnc3DAsymLUT * pc3DAsymLUT
     159#endif
     160  )
    157161{
    158162#if ENC_DEC_TRACE 
     
    268272    {
    269273      WRITE_FLAG( pcPPS->getPocResetInfoPresentFlag() ? 1 : 0, "poc_reset_info_present_flag" );
     274#if Q0048_CGS_3D_ASYMLUT
     275      UInt uiPos = getNumberOfWrittenBits();
     276      WRITE_FLAG( pcPPS->getCGSFlag() , "colour_mapping_enabled_flag" );
     277      if( pcPPS->getCGSFlag() )
     278      {
     279        assert( pc3DAsymLUT != NULL );
     280        xCode3DAsymLUT( pc3DAsymLUT );
     281      }
     282      pc3DAsymLUT->setPPSBit( getNumberOfWrittenBits() - uiPos );
     283#endif
    270284#endif
    271285    }
     
    495509  if (conf.getWindowEnabledFlag())
    496510  {
     511#if REPN_FORMAT_IN_VPS
     512    WRITE_UVLC( conf.getWindowLeftOffset(),   "conf_win_left_offset"   );
     513    WRITE_UVLC( conf.getWindowRightOffset(),  "conf_win_right_offset"  );
     514    WRITE_UVLC( conf.getWindowTopOffset(),    "conf_win_top_offset"    );
     515    WRITE_UVLC( conf.getWindowBottomOffset(), "conf_win_bottom_offset" );
     516#else
    497517    WRITE_UVLC( conf.getWindowLeftOffset()   / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_left_offset" );
    498518    WRITE_UVLC( conf.getWindowRightOffset()  / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_right_offset" );
    499519    WRITE_UVLC( conf.getWindowTopOffset()    / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_top_offset" );
    500520    WRITE_UVLC( conf.getWindowBottomOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_bottom_offset" );
     521#endif
    501522  }
    502523
     
    777798    }
    778799  }
    779 #if !VPS_EXTNS
    780   WRITE_FLAG( 0,                     "vps_extension_flag" );
    781 #else
    782   WRITE_FLAG( 1,                     "vps_extension_flag" );
    783   if(1) // Should be conditioned on the value of vps_extension_flag
     800#if VPS_EXTNS
     801  // When MaxLayersMinus1 is greater than 0, vps_extension_flag shall be equal to 1.
     802  if( pcVPS->getMaxLayers() > 1 )
     803  {
     804    assert( pcVPS->getVpsExtensionFlag() == true );
     805  }
     806
     807  WRITE_FLAG( pcVPS->getVpsExtensionFlag() ? 1 : 0,                     "vps_extension_flag" );
     808
     809  if( pcVPS->getVpsExtensionFlag() )
    784810  {
    785811    while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 )
     
    797823    WRITE_FLAG( 0,                     "vps_extension2_flag" );   // Flag value of 1 reserved
    798824  }
     825#else
     826  WRITE_FLAG( 0,                     "vps_extension_flag" );
    799827#endif 
    800828  //future extensions here..
     
    9961024  }
    9971025#else
    998   Int numOutputLayerSets = vps->getNumOutputLayerSets() ;
    999   assert( numOutputLayerSets - (Int)vps->getNumLayerSets() >= 0 );
     1026  Int numOutputLayerSets = vps->getNumOutputLayerSets();
     1027  Int numAddOutputLayerSets = numOutputLayerSets - (Int)vps->getNumLayerSets();
     1028
     1029  // The value of num_add_output_layer_sets shall be in the range of 0 to 1023, inclusive.
     1030  assert( numAddOutputLayerSets >= 0 && numAddOutputLayerSets < 1024 );
     1031
     1032#if Q0165_NUM_ADD_OUTPUT_LAYER_SETS
     1033  if( vps->getNumLayerSets() > 1 )
     1034  {
     1035    WRITE_UVLC( numAddOutputLayerSets, "num_add_output_layer_sets" );
     1036    WRITE_CODE( vps->getDefaultTargetOutputLayerIdc(), 2, "default_target_output_layer_idc" );
     1037  }
     1038#else
    10001039  WRITE_UVLC( numOutputLayerSets - vps->getNumLayerSets(), "num_add_output_layer_sets" );
    10011040#endif
     1041#endif
     1042
     1043#if !Q0165_NUM_ADD_OUTPUT_LAYER_SETS
    10021044  if( numOutputLayerSets > 1 )
    10031045  {
     
    10121054#endif
    10131055  }
     1056#endif
    10141057
    10151058  for(i = 1; i < numOutputLayerSets; i++)
     
    10591102      WRITE_FLAG(vps->getAltOuputLayerFlag(i), "alt_output_layer_flag[i]");
    10601103    }
     1104
     1105#if Q0165_OUTPUT_LAYER_SET
     1106    assert( NumOutputLayersInOutputLayerSet[i]>0 );
     1107#endif
     1108
    10611109#endif
    10621110  }
     
    10721120
    10731121#if REPN_FORMAT_IN_VPS
     1122#if Q0195_REP_FORMAT_CLEANUP 
     1123  // The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive.
     1124  assert( vps->getVpsNumRepFormats() > 0 && vps->getVpsNumRepFormats() <= 256 );
     1125 
     1126  WRITE_UVLC( vps->getVpsNumRepFormats() - 1, "vps_num_rep_formats_minus1" );
     1127
     1128  for(i = 0; i < vps->getVpsNumRepFormats(); i++)
     1129  {
     1130    // Write rep_format_structures
     1131    codeRepFormat( vps->getVpsRepFormat(i) );
     1132  }
     1133
     1134  if( vps->getVpsNumRepFormats() > 1 )
     1135  {
     1136    WRITE_FLAG( vps->getRepFormatIdxPresentFlag(), "rep_format_idx_present_flag");
     1137  }
     1138  else
     1139  {
     1140    // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0
     1141    assert( !vps->getRepFormatIdxPresentFlag() );
     1142  }
     1143
     1144  if( vps->getRepFormatIdxPresentFlag() )
     1145  {
     1146    for(i = 1; i < vps->getMaxLayers(); i++)
     1147    {
     1148      Int numBits = 1;
     1149      while ((1 << numBits) < (vps->getVpsNumRepFormats()))
     1150      {
     1151        numBits++;
     1152      }
     1153      WRITE_CODE( vps->getVpsRepFormatIdx(i), numBits, "vps_rep_format_idx[i]" );
     1154    }
     1155  }
     1156#else
    10741157  WRITE_FLAG( vps->getRepFormatIdxPresentFlag(), "rep_format_idx_present_flag");
    10751158
    10761159  if( vps->getRepFormatIdxPresentFlag() )
    10771160  {
     1161    // The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive.
     1162    assert( vps->getVpsNumRepFormats() > 0 && vps->getVpsNumRepFormats() <= 256 );
     1163
    10781164#if O0096_REP_FORMAT_INDEX
    10791165#if !VPS_EXTN_UEV_CODING
     
    11151201    }
    11161202  }
     1203#endif
    11171204#endif
    11181205
     
    11811268
    11821269#if P0307_VPS_NON_VUI_EXTENSION
     1270  // The value of vps_non_vui_extension_length shall be in the range of 0 to 4096, inclusive.
     1271  assert( vps->getVpsNonVuiExtLength() >= 0 && vps->getVpsNonVuiExtLength() <= 4096 );
     1272
    11831273  WRITE_UVLC( vps->getVpsNonVuiExtLength(), "vps_non_vui_extension_length" );
    11841274#if P0307_VPS_NON_VUI_EXT_UPDATE
     
    12161306#else
    12171307#if P0307_REMOVE_VPS_VUI_OFFSET
    1218   WRITE_FLAG( 1,                     "vps_vui_present_flag" );
    12191308  vps->setVpsVuiPresentFlag(true);
     1309  WRITE_FLAG( vps->getVpsVuiPresentFlag() ? 1 : 0,                     "vps_vui_present_flag" );
    12201310#endif
    12211311  if(vps->getVpsVuiPresentFlag())   // Should be conditioned on the value of vps_vui_present_flag
     
    12381328#endif
    12391329#if REPN_FORMAT_IN_VPS
    1240 Void  TEncCavlc::codeRepFormat      ( RepFormat *repFormat )
     1330Void  TEncCavlc::codeRepFormat( RepFormat *repFormat )
    12411331{
    12421332#if REPN_FORMAT_CONTROL_FLAG
    1243    WRITE_FLAG ( repFormat->getChromaAndBitDepthVpsPresentFlag(), "chroma_and_bit_depth_vps_presenet_flag");
    1244 
    1245    WRITE_CODE ( repFormat->getPicWidthVpsInLumaSamples (), 16, "pic_width_in_luma_samples" );   
    1246    WRITE_CODE ( repFormat->getPicHeightVpsInLumaSamples(), 16, "pic_height_in_luma_samples" ); 
    1247 
    1248    if ( repFormat->getChromaAndBitDepthVpsPresentFlag() )
    1249    {
    1250      WRITE_CODE( repFormat->getChromaFormatVpsIdc(), 2, "chroma_format_idc" );   
    1251 
    1252      if( repFormat->getChromaFormatVpsIdc() == 3 )
    1253      {
    1254        WRITE_FLAG( repFormat->getSeparateColourPlaneVpsFlag(), "separate_colour_plane_flag");     
    1255      }
    1256 
    1257      assert( repFormat->getBitDepthVpsLuma() >= 8 );
    1258      assert( repFormat->getBitDepthVpsChroma() >= 8 );
    1259      WRITE_CODE( repFormat->getBitDepthVpsLuma() - 8,   4, "bit_depth_luma_minus8" );           
    1260      WRITE_CODE( repFormat->getBitDepthVpsChroma() - 8, 4, "bit_depth_chroma_minus8" );
    1261    }
     1333  WRITE_CODE( repFormat->getPicWidthVpsInLumaSamples (), 16, "pic_width_vps_in_luma_samples" );   
     1334  WRITE_CODE( repFormat->getPicHeightVpsInLumaSamples(), 16, "pic_height_vps_in_luma_samples" ); 
     1335  WRITE_FLAG( repFormat->getChromaAndBitDepthVpsPresentFlag(), "chroma_and_bit_depth_vps_present_flag" );
     1336
     1337  if( repFormat->getChromaAndBitDepthVpsPresentFlag() )
     1338  {
     1339    WRITE_CODE( repFormat->getChromaFormatVpsIdc(), 2, "chroma_format_vps_idc" );   
     1340
     1341    if( repFormat->getChromaFormatVpsIdc() == 3 )
     1342    {
     1343      WRITE_FLAG( repFormat->getSeparateColourPlaneVpsFlag(), "separate_colour_plane_vps_flag" );     
     1344    }
     1345
     1346    assert( repFormat->getBitDepthVpsLuma() >= 8 );
     1347    assert( repFormat->getBitDepthVpsChroma() >= 8 );
     1348    WRITE_CODE( repFormat->getBitDepthVpsLuma() - 8,   4, "bit_depth_vps_luma_minus8" );           
     1349    WRITE_CODE( repFormat->getBitDepthVpsChroma() - 8, 4, "bit_depth_vps_chroma_minus8" );
     1350  }
    12621351#else
    12631352  WRITE_CODE( repFormat->getChromaFormatVpsIdc(), 2, "chroma_format_idc" );   
     
    12751364  WRITE_CODE( repFormat->getBitDepthVpsLuma() - 8,   4, "bit_depth_luma_minus8" );           
    12761365  WRITE_CODE( repFormat->getBitDepthVpsChroma() - 8, 4, "bit_depth_chroma_minus8" );
    1277 #endif
    1278 
     1366#endif
    12791367}
    12801368#endif
     
    13751463        if( vps->getBitRatePresentVpsFlag() )
    13761464        {
    1377           WRITE_FLAG( vps->getBitRatePresentFlag( i, j),        "bit_rate_present_vps_flag[i][j]" );
     1465          WRITE_FLAG( vps->getBitRatePresentFlag( i, j),        "bit_rate_present_flag[i][j]" );
    13781466        }
    13791467        if( vps->getPicRatePresentVpsFlag() )
    13801468        {
    1381           WRITE_FLAG( vps->getPicRatePresentFlag( i, j),        "pic_rate_present_vps_flag[i][j]" );
     1469          WRITE_FLAG( vps->getPicRatePresentFlag( i, j),        "pic_rate_present_flag[i][j]" );
    13821470        }
    13831471        if( vps->getBitRatePresentFlag(i, j) )
     
    14661554#endif
    14671555#if HIGHER_LAYER_IRAP_SKIP_FLAG
     1556  // When single_layer_for_non_irap_flag is equal to 0, higher_layer_irap_skip_flag shall be equal to 0
     1557  if( !vps->getSingleLayerForNonIrapFlag() )
     1558  {
     1559    assert( !vps->getHigherLayerIrapSkipFlag() );
     1560  }
     1561
    14681562  WRITE_FLAG(vps->getHigherLayerIrapSkipFlag(), "higher_layer_irap_skip_flag" );
    14691563#endif
     
    15641658    for(i = 1; i < vps->getMaxLayers(); i++)
    15651659    {
    1566       if(vps->getNumRefLayers(vps->getLayerIdInNuh(i)) == 0)
    1567       {
    1568         if ((vps->getSPSId(i) == 0) && (vps->getPPSId(i) == 0))
     1660      if( vps->getNumRefLayers(vps->getLayerIdInNuh(i)) == 0 )
     1661      {
     1662        if( (vps->getSPSId(i) == 0) && (vps->getPPSId(i) == 0) )
    15691663        {
    15701664          vps->setBaseLayerPSCompatibilityFlag(i, 1);
    1571           WRITE_FLAG(vps->getBaseLayerPSCompatibilityFlag(i), "base_layer_parameter_set_compatibility_flag" );
    15721665        }
    15731666        else
     
    15751668          vps->setBaseLayerPSCompatibilityFlag(i, 0);
    15761669        }
     1670        WRITE_FLAG(vps->getBaseLayerPSCompatibilityFlag(i), "base_layer_parameter_set_compatibility_flag" );
    15771671      }
    15781672    }
     
    16121706  if ( pcSlice->getRapPicFlag() )
    16131707  {
    1614 #if NO_OUTPUT_OF_PRIOR_PICS
    1615     WRITE_FLAG( pcSlice->getNoOutputOfPriorPicsFlag(), "no_output_of_prior_pics_flag" );
     1708#if SETTING_NO_OUT_PIC_PRIOR
     1709    WRITE_FLAG( pcSlice->getNoOutputPriorPicsFlag() ? 1 : 0, "no_output_of_prior_pics_flag" );
    16161710#else
    16171711    WRITE_FLAG( 0, "no_output_of_prior_pics_flag" );
     
    26162710  return true;
    26172711}
     2712
     2713#if Q0048_CGS_3D_ASYMLUT
     2714Void TEncCavlc::xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT )
     2715{
     2716  assert( pc3DAsymLUT->getCurOctantDepth() < 4 );
     2717  WRITE_CODE( pc3DAsymLUT->getCurOctantDepth() , 2 , "cm_octant_depth" );
     2718  assert( pc3DAsymLUT->getCurYPartNumLog2() < 4 );
     2719  WRITE_CODE( pc3DAsymLUT->getCurYPartNumLog2() , 2 , "cm_y_part_num_log2" );
     2720  assert( pc3DAsymLUT->getInputBitDepthY() < 16 );
     2721  WRITE_CODE( pc3DAsymLUT->getInputBitDepthY() - 8 , 3 , "cm_input_bit_depth_minus8" );
     2722  WRITE_SVLC(pc3DAsymLUT->getInputBitDepthC()-pc3DAsymLUT->getInputBitDepthY(), "cm_input_bit_depth_chroma delta");
     2723  assert( pc3DAsymLUT->getOutputBitDepthY() < 16 );
     2724  WRITE_CODE( pc3DAsymLUT->getOutputBitDepthY() - 8 , 3 , "cm_output_bit_depth_minus8" );
     2725  WRITE_SVLC(pc3DAsymLUT->getOutputBitDepthC()-pc3DAsymLUT->getOutputBitDepthY(), "cm_output_bit_depth_chroma_delta");
     2726  assert( pc3DAsymLUT->getResQuantBit() < 4 );
     2727  WRITE_CODE( pc3DAsymLUT->getResQuantBit() , 2 , "cm_res_quant_bit" );
     2728
     2729  xCode3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() );
     2730}
     2731
     2732Void TEncCavlc::xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength )
     2733{
     2734  UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth();
     2735  if( nDepth < pc3DAsymLUT->getCurOctantDepth() )
     2736    WRITE_FLAG( uiOctantSplit , "split_octant_flag" );
     2737  Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2();
     2738  if( uiOctantSplit )
     2739  {
     2740    Int nHalfLength = nLength >> 1;
     2741    for( Int l = 0 ; l < 2 ; l++ )
     2742    {
     2743      for( Int m = 0 ; m < 2 ; m++ )
     2744      {
     2745        for( Int n = 0 ; n < 2 ; n++ )
     2746        {
     2747          xCode3DAsymLUTOctant( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength );
     2748        }
     2749      }
     2750    }
     2751  }
     2752  else
     2753  {
     2754    for( Int l = 0 ; l < nYPartNum ; l++ )
     2755    {
     2756      for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ )
     2757      {
     2758        SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx );
     2759        UInt uiCodeVertex = sRes.Y != 0 || sRes.U != 0 || sRes.V != 0;
     2760        WRITE_FLAG( uiCodeVertex , "coded_vertex_flag" );
     2761        if( uiCodeVertex )
     2762        {
     2763          WRITE_SVLC( sRes.Y , "resY" );
     2764          WRITE_SVLC( sRes.U , "resU" );
     2765          WRITE_SVLC( sRes.V , "resV" );
     2766        }
     2767      }
     2768    }
     2769  }
     2770}
     2771#endif
    26182772//! \}
  • trunk/source/Lib/TLibEncoder/TEncCavlc.h

    r644 r713  
    4848#include "TEncEntropy.h"
    4949#include "SyntaxElementWriter.h"
     50#if Q0048_CGS_3D_ASYMLUT
     51#include "../TLibCommon/TCom3DAsymLUT.h"
     52#include "TEnc3DAsymLUT.h"
     53#endif
    5054
    5155//! \ingroup TLibEncoder
     
    5357
    5458class TEncTop;
     59#if Q0048_CGS_3D_ASYMLUT
     60class TCom3DAsymLUT;
     61#endif
    5562
    5663// ====================================================================================================================
     
    9097  Void  codeVUI                 ( TComVUI *pcVUI, TComSPS* pcSPS );
    9198  Void  codeSPS                 ( TComSPS* pcSPS );
    92   Void  codePPS                 ( TComPPS* pcPPS );
     99  Void  codePPS                 ( TComPPS* pcPPS
     100#if Q0048_CGS_3D_ASYMLUT
     101    , TEnc3DAsymLUT * pc3DAsymLUT
     102#endif
     103    );
    93104  Void  codeSliceHeader         ( TComSlice* pcSlice );
    94105  Void  codePTL                 ( TComPTL* pcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1);
     
    162173  Void  codeVpsDpbSizeTable      (TComVPS *vps);
    163174#endif
     175#if Q0048_CGS_3D_ASYMLUT
     176protected:
     177  Void xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT );
     178  Void xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength );
     179#endif
    164180#endif //SVC_EXTENSION
    165181
  • trunk/source/Lib/TLibEncoder/TEncCfg.h

    r644 r713  
    235235  Int       m_cameraIsoSpeedIdc;
    236236  Int       m_cameraIsoSpeedValue;
     237  Int       m_exposureIndexIdc;
     238  Int       m_exposureIndexValue;
    237239  Int       m_exposureCompensationValueSignFlag;
    238240  Int       m_exposureCompensationValueNumerator;
     
    246248  Int*      m_codedPivotValue;
    247249  Int*      m_targetPivotValue;
     250#if Q0074_SEI_COLOR_MAPPING
     251  Char*     m_seiColorMappingFile;
     252#endif
    248253  Int       m_framePackingSEIEnabled;
    249254  Int       m_framePackingSEIType;
     
    362367  UInt      m_bottomRightTileIndex[1024];
    363368  UInt      m_ilcIdc[1024];
     369#endif
     370#if Q0048_CGS_3D_ASYMLUT
     371  Int  m_nCGSFlag;
     372  Int  m_nCGSMaxOctantDepth;
     373  Int  m_nCGSMaxYPartNumLog2;
     374  Int  m_nCGSLUTBit;
    364375#endif
    365376#endif //SVC_EXTENSION
     
    639650  Void  setTMISEICameraIsoSpeedValue(Int b)                  {  m_cameraIsoSpeedValue = b;  }
    640651  Int   getTMISEICameraIsoSpeedValue()                       {  return m_cameraIsoSpeedValue;  }
     652  Void  setTMISEIExposureIndexIdc(Int b)                     {  m_exposureIndexIdc = b;  }
     653  Int   getTMISEIExposurIndexIdc()                           {  return m_exposureIndexIdc;  }
     654  Void  setTMISEIExposureIndexValue(Int b)                   {  m_exposureIndexValue = b;  }
     655  Int   getTMISEIExposurIndexValue()                         {  return m_exposureIndexValue;  }
    641656  Void  setTMISEIExposureCompensationValueSignFlag(Int b)    {  m_exposureCompensationValueSignFlag = b;  }
    642657  Int   getTMISEIExposureCompensationValueSignFlag()         {  return m_exposureCompensationValueSignFlag;  }
     
    655670  Void  setTMISEIExtendedWhiteLevelLumaCodeValue(Int b)      {  m_extendedWhiteLevelLumaCodeValue =b;  }
    656671  Int   getTMISEIExtendedWhiteLevelLumaCodeValue()           {  return m_extendedWhiteLevelLumaCodeValue;  }
     672#if Q0074_SEI_COLOR_MAPPING
     673  Void  setColorMappingInfoSEIFile( Char* nameFile )         {  m_seiColorMappingFile = nameFile; }
     674  Char* getColorMappingInfoSEIFile()                         {  return m_seiColorMappingFile; }
     675#endif
    657676  Void  setFramePackingArrangementSEIEnabled(Int b)      { m_framePackingSEIEnabled = b; }
    658677  Int   getFramePackingArrangementSEIEnabled()           { return m_framePackingSEIEnabled; }
     
    898917  UInt  getIlcIdc(UInt b)                                  { return m_ilcIdc[b]; }
    899918#endif
     919#if Q0048_CGS_3D_ASYMLUT
     920  Void      setCGSFlag(Int n)             { m_nCGSFlag = n;    }
     921  Int       getCGSFlag()                  { return m_nCGSFlag; }
     922  Void      setCGSMaxOctantDepth(Int n)   { m_nCGSMaxOctantDepth = n;    }
     923  Int       getCGSMaxOctantDepth()        { return m_nCGSMaxOctantDepth; }
     924  Void      setCGSMaxYPartNumLog2(Int n)  { m_nCGSMaxYPartNumLog2 = n;    }
     925  Int       getCGSMaxYPartNumLog2()       { return m_nCGSMaxYPartNumLog2; }
     926  Void      setCGSLUTBit(Int n)           { m_nCGSLUTBit = n;    }
     927  Int       getCGSLUTBit()                { return m_nCGSLUTBit; }
     928#endif
    900929#endif
    901930};
  • trunk/source/Lib/TLibEncoder/TEncEntropy.cpp

    r644 r713  
    7979}
    8080
     81#if Q0048_CGS_3D_ASYMLUT
     82Void TEncEntropy::encodePPS( TComPPS* pcPPS, TEnc3DAsymLUT * pc3DAsymLUT  )
     83{
     84  m_pcEntropyCoderIf->codePPS( pcPPS, pc3DAsymLUT );
     85  return;
     86}
     87#else
    8188Void TEncEntropy::encodePPS( TComPPS* pcPPS )
    8289{
     
    8491  return;
    8592}
     93#endif
    8694
    8795Void TEncEntropy::encodeSPS( TComSPS* pcSPS )
  • trunk/source/Lib/TLibEncoder/TEncEntropy.h

    r644 r713  
    5050class TEncCavlc;
    5151class SEI;
     52#if Q0048_CGS_3D_ASYMLUT
     53class TEnc3DAsymLUT;
     54#endif
    5255
    5356// ====================================================================================================================
     
    7073  virtual Void  codeVPS                 ( TComVPS* pcVPS )                                      = 0;
    7174  virtual Void  codeSPS                 ( TComSPS* pcSPS )                                      = 0;
    72   virtual Void  codePPS                 ( TComPPS* pcPPS )                                      = 0;
     75  virtual Void  codePPS                 ( TComPPS* pcPPS
     76#if Q0048_CGS_3D_ASYMLUT
     77    , TEnc3DAsymLUT * pc3DAsymLUT
     78#endif
     79    )                                      = 0;
    7380  virtual Void  codeSliceHeader         ( TComSlice* pcSlice )                                  = 0;
    7481
     
    156163  // SPS
    157164  Void encodeSPS               ( TComSPS* pcSPS );
    158   Void encodePPS               ( TComPPS* pcPPS );
     165  Void encodePPS               ( TComPPS* pcPPS
     166#if Q0048_CGS_3D_ASYMLUT
     167    , TEnc3DAsymLUT * pc3DAsymLUT
     168#endif
     169    );
    159170  Void encodeSplitFlag         ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, Bool bRD = false );
    160171  Void encodeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false );
  • trunk/source/Lib/TLibEncoder/TEncGOP.cpp

    r644 r713  
    7575  m_iNumPicCoded        = 0; //Niko
    7676  m_bFirst              = true;
     77#if ALLOW_RECOVERY_POINT_AS_RAP
     78  m_iLastRecoveryPicPOC = 0;
     79#endif
    7780 
    7881  m_pcCfg               = NULL;
     
    103106  m_pcPredSearch        = NULL;
    104107#endif
     108#if Q0048_CGS_3D_ASYMLUT
     109  m_temp = NULL;
     110  m_pColorMappedPic = NULL;
     111#endif
    105112  return;
    106113}
     
    108115TEncGOP::~TEncGOP()
    109116{
     117#if Q0048_CGS_3D_ASYMLUT
     118  if(m_pColorMappedPic)
     119  {
     120    m_pColorMappedPic->destroy();
     121    delete m_pColorMappedPic;
     122    m_pColorMappedPic = NULL;               
     123  }
     124  if(m_temp)
     125  {
     126    free_mem2DintWithPad(m_temp, m_iTap>>1, 0);
     127    m_temp = NULL;
     128  }
     129#endif
    110130}
    111131
     
    157177  m_pcPredSearch         = pcTEncTop->getPredSearch();                       ///< encoder search class
    158178#endif
     179#if Q0048_CGS_3D_ASYMLUT
     180  if( pcTEncTop->getLayerId() )
     181  {
     182    m_Enc3DAsymLUTPicUpdate.create( m_pcCfg->getCGSMaxOctantDepth() , g_bitDepthYLayer[pcTEncTop->getLayerId()-1] , g_bitDepthCLayer[pcTEncTop->getLayerId()-1] , g_bitDepthYLayer[pcTEncTop->getLayerId()] , g_bitDepthCLayer[pcTEncTop->getLayerId()] , m_pcCfg->getCGSMaxYPartNumLog2() /*, m_pcCfg->getCGSPhaseAlignment()*/ );
     183    m_Enc3DAsymLUTPPS.create(   m_pcCfg->getCGSMaxOctantDepth() , g_bitDepthYLayer[pcTEncTop->getLayerId()-1] , g_bitDepthCLayer[pcTEncTop->getLayerId()-1] , g_bitDepthYLayer[pcTEncTop->getLayerId()] , g_bitDepthCLayer[pcTEncTop->getLayerId()] , m_pcCfg->getCGSMaxYPartNumLog2() /*, m_pcCfg->getCGSPhaseAlignment()*/ );
     184    if(!m_pColorMappedPic)
     185    {
     186      m_pColorMappedPic = new TComPicYuv;
     187      m_pColorMappedPic->create( m_ppcTEncTop[0]->getSourceWidth(), m_ppcTEncTop[0]->getSourceHeight(), CHROMA_420, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL );
     188    }
     189  }
     190#endif
    159191}
    160192
     
    163195  SEIActiveParameterSets *seiActiveParameterSets = new SEIActiveParameterSets();
    164196  seiActiveParameterSets->activeVPSId = m_pcCfg->getVPS()->getVPSId();
    165   seiActiveParameterSets->m_fullRandomAccessFlag = false;
    166   seiActiveParameterSets->m_noParamSetUpdateFlag = false;
     197  seiActiveParameterSets->m_selfContainedCvsFlag = false;
     198  seiActiveParameterSets->m_noParameterSetUpdateFlag = false;
    167199  seiActiveParameterSets->numSpsIdsMinus1 = 0;
    168   seiActiveParameterSets->activeSeqParamSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1);
    169   seiActiveParameterSets->activeSeqParamSetId[0] = sps->getSPSId();
     200  seiActiveParameterSets->activeSeqParameterSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1);
     201  seiActiveParameterSets->activeSeqParameterSetId[0] = sps->getSPSId();
    170202  return seiActiveParameterSets;
    171203}
    172 
    173204
    174205SEIFramePacking* TEncGOP::xCreateSEIFramePacking()
     
    271302       seiToneMappingInfo->m_cameraIsoSpeedValue = m_pcCfg->getTMISEICameraIsoSpeedValue();
    272303       assert( seiToneMappingInfo->m_cameraIsoSpeedValue !=0 );
     304       seiToneMappingInfo->m_exposureIndexIdc = m_pcCfg->getTMISEIExposurIndexIdc();
     305       seiToneMappingInfo->m_exposureIndexValue = m_pcCfg->getTMISEIExposurIndexValue();
     306       assert( seiToneMappingInfo->m_exposureIndexValue !=0 );
    273307       seiToneMappingInfo->m_exposureCompensationValueSignFlag = m_pcCfg->getTMISEIExposureCompensationValueSignFlag();
    274308       seiToneMappingInfo->m_exposureCompensationValueNumerator = m_pcCfg->getTMISEIExposureCompensationValueNumerator();
     
    293327}
    294328
     329#if Q0074_SEI_COLOR_MAPPING
     330SEIColorMappingInfo*  TEncGOP::xCreateSEIColorMappingInfo( Char* file )
     331{
     332  SEIColorMappingInfo *seiColorMappingInfo = new SEIColorMappingInfo();
     333
     334  FILE* fic = fopen( file, "r" );
     335
     336  Int iVal, retval;
     337
     338  retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMapId );
     339  retval = fscanf( fic, "%d", &iVal );
     340  seiColorMappingInfo->m_colorMapCancelFlag = iVal;
     341  if( !seiColorMappingInfo->m_colorMapCancelFlag )
     342  {
     343    retval = fscanf( fic, "%d", &iVal );
     344    seiColorMappingInfo->m_colorMapPersistenceFlag = iVal;
     345    retval = fscanf( fic, "%d", &iVal );
     346    seiColorMappingInfo->m_colorMap_video_signal_type_present_flag = iVal;
     347    if( seiColorMappingInfo->m_colorMap_video_signal_type_present_flag )
     348    {
     349      retval = fscanf( fic, "%d", &iVal );
     350      seiColorMappingInfo->m_colorMap_video_full_range_flag = iVal;
     351      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMap_primaries );
     352      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMap_transfer_characteristics );
     353      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMap_matrix_coeffs );
     354    }
     355  }
     356
     357  retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colour_map_coded_data_bit_depth );
     358  retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colour_map_target_bit_depth );
     359  retval = fscanf( fic, "%d", &iVal );
     360  seiColorMappingInfo->m_colorMapModelId = iVal;
     361
     362  assert( seiColorMappingInfo->m_colorMapModelId == 0 );
     363 
     364  for( Int i=0 ; i<3 ; i++ )
     365  {
     366    retval = fscanf( fic, "%d", &seiColorMappingInfo->m_num_input_pivots[i] );
     367    seiColorMappingInfo->m_coded_input_pivot_value[i]   = new Int[ seiColorMappingInfo->m_num_input_pivots[i] ];
     368    seiColorMappingInfo->m_target_input_pivot_value[i]  = new Int[ seiColorMappingInfo->m_num_input_pivots[i] ];
     369    for( Int j=0 ; j<seiColorMappingInfo->m_num_input_pivots[i] ; j++ )
     370    {
     371      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_coded_input_pivot_value[i][j] );
     372      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_target_input_pivot_value[i][j] );
     373    }
     374  }
     375
     376  retval = fscanf( fic, "%d", &iVal );
     377  seiColorMappingInfo->m_matrix_flag = iVal;
     378  if( seiColorMappingInfo->m_matrix_flag )
     379  {
     380    retval = fscanf( fic, "%d", &seiColorMappingInfo->m_log2_matrix_denom );
     381    for( Int i=0 ; i<3 ; i++ )
     382    {
     383      for( Int j=0 ; j<3 ; j++ )
     384      {
     385        retval = fscanf( fic, "%d", &seiColorMappingInfo->m_matrix_coef[i][j] );
     386      }
     387    }
     388  }
     389
     390  for( Int i=0 ; i<3 ; i++ )
     391  {
     392    retval = fscanf( fic, "%d", &seiColorMappingInfo->m_num_output_pivots[i] );
     393    seiColorMappingInfo->m_coded_output_pivot_value[i]   = new Int[ seiColorMappingInfo->m_num_output_pivots[i] ];
     394    seiColorMappingInfo->m_target_output_pivot_value[i]  = new Int[ seiColorMappingInfo->m_num_output_pivots[i] ];
     395    for( Int j=0 ; j<seiColorMappingInfo->m_num_output_pivots[i] ; j++ )
     396    {
     397      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_coded_output_pivot_value[i][j] );
     398      retval = fscanf( fic, "%d", &seiColorMappingInfo->m_target_output_pivot_value[i][j] );
     399    }
     400  }
     401
     402  fclose( fic );
     403
     404  if( retval != 1 )
     405  {
     406    printf("Error: can't read color mapping information\n");
     407  }
     408
     409  return seiColorMappingInfo;
     410}
     411#endif
     412
    295413Void TEncGOP::xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps)
    296414{
     
    359477    delete sei;
    360478  }
     479#if Q0074_SEI_COLOR_MAPPING
     480  if(m_pcCfg->getColorMappingInfoSEIFile())
     481  {
     482    SEIColorMappingInfo *sei = xCreateSEIColorMappingInfo( m_pcCfg->getColorMappingInfoSEIFile() );
     483     
     484#if SVC_EXTENSION
     485    nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, m_layerId);  // temporalId = 0 ?
     486#else
     487    nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
     488#endif
     489    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     490#if O0164_MULTI_LAYER_HRD
     491    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
     492#else
     493    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     494#endif
     495    writeRBSPTrailingBits(nalu.m_Bitstream);
     496    accessUnit.push_back(new NALUnitEBSP(nalu));
     497    delete sei;
     498  }
     499#endif
    361500
    362501#if SVC_EXTENSION
     
    435574  UInt *accumNalsDU = NULL;
    436575  SEIDecodingUnitInfo decodingUnitInfoSEI;
     576#if EFFICIENT_FIELD_IRAP
     577  Int IRAPGOPid = -1;
     578  Bool IRAPtoReorder = false;
     579  Bool swapIRAPForward = false;
     580  if(isField)
     581  {
     582    Int pocCurr;
     583#if SVC_EXTENSION
     584    for ( Int iGOPid=iPicIdInGOP; iGOPid < iPicIdInGOP+1; iGOPid++ )
     585#else
     586    for ( Int iGOPid=0; iGOPid < m_iGopSize; iGOPid++ )
     587#endif   
     588    {
     589      // determine actual POC
     590      if(iPOCLast == 0) //case first frame or first top field
     591      {
     592        pocCurr=0;
     593      }
     594      else if(iPOCLast == 1 && isField) //case first bottom field, just like the first frame, the poc computation is not right anymore, we set the right value
     595      {
     596        pocCurr = 1;
     597      }
     598      else
     599      {
     600        pocCurr = iPOCLast - iNumPicRcvd + m_pcCfg->getGOPEntry(iGOPid).m_POC - isField;
     601      }
     602
     603      // check if POC corresponds to IRAP
     604      NalUnitType tmpUnitType = getNalUnitType(pocCurr, m_iLastIDR, isField);
     605      if(tmpUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && tmpUnitType <= NAL_UNIT_CODED_SLICE_CRA) // if picture is an IRAP
     606      {
     607        if(pocCurr%2 == 0 && iGOPid < m_iGopSize-1 && m_pcCfg->getGOPEntry(iGOPid).m_POC == m_pcCfg->getGOPEntry(iGOPid+1).m_POC-1)
     608        { // if top field and following picture in enc order is associated bottom field
     609          IRAPGOPid = iGOPid;
     610          IRAPtoReorder = true;
     611          swapIRAPForward = true;
     612          break;
     613        }
     614        if(pocCurr%2 != 0 && iGOPid > 0 && m_pcCfg->getGOPEntry(iGOPid).m_POC == m_pcCfg->getGOPEntry(iGOPid-1).m_POC+1)
     615        {
     616          // if picture is an IRAP remember to process it first
     617          IRAPGOPid = iGOPid;
     618          IRAPtoReorder = true;
     619          swapIRAPForward = false;
     620          break;
     621        }
     622      }
     623    }
     624  }
     625#endif
    437626#if SVC_EXTENSION
    438627  for ( Int iGOPid=iPicIdInGOP; iGOPid < iPicIdInGOP+1; iGOPid++ )
     
    441630#endif
    442631  {
     632#if EFFICIENT_FIELD_IRAP
     633    if(IRAPtoReorder)
     634    {
     635      if(swapIRAPForward)
     636      {
     637        if(iGOPid == IRAPGOPid)
     638        {
     639          iGOPid = IRAPGOPid +1;
     640        }
     641        else if(iGOPid == IRAPGOPid +1)
     642        {
     643          iGOPid = IRAPGOPid;
     644        }
     645      }
     646      else
     647      {
     648        if(iGOPid == IRAPGOPid -1)
     649        {
     650          iGOPid = IRAPGOPid;
     651        }
     652        else if(iGOPid == IRAPGOPid)
     653        {
     654          iGOPid = IRAPGOPid -1;
     655        }
     656      }
     657    }
     658#endif
    443659    UInt uiColDir = 1;
    444660    //-- For time output for each slice
     
    510726    if(pocCurr>=m_pcCfg->getFramesToBeEncoded())
    511727    {
     728#if EFFICIENT_FIELD_IRAP
     729      if(IRAPtoReorder)
     730      {
     731        if(swapIRAPForward)
     732        {
     733          if(iGOPid == IRAPGOPid)
     734          {
     735            iGOPid = IRAPGOPid +1;
     736            IRAPtoReorder = false;
     737          }
     738          else if(iGOPid == IRAPGOPid +1)
     739          {
     740            iGOPid --;
     741          }
     742        }
     743        else
     744        {
     745          if(iGOPid == IRAPGOPid)
     746          {
     747            iGOPid = IRAPGOPid -1;
     748          }
     749          else if(iGOPid == IRAPGOPid -1)
     750          {
     751            iGOPid = IRAPGOPid;
     752            IRAPtoReorder = false;
     753          }
     754        }
     755      }
     756#endif
    512757      continue;
    513758    }
     
    8031048        Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth();
    8041049        Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight();
    805 
     1050#if Q0200_CONFORMANCE_BL_SIZE
     1051        Int chromaFormatIdc = pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getChromaFormatIdc();
     1052        const Window &confBL = pcSlice->getBaseColPic(refLayerIdc)->getConformanceWindow();
     1053        widthBL  -= ( confBL.getWindowLeftOffset() + confBL.getWindowRightOffset() ) * TComSPS::getWinUnitX( chromaFormatIdc );
     1054        heightBL -= ( confBL.getWindowTopOffset() + confBL.getWindowBottomOffset() ) * TComSPS::getWinUnitY( chromaFormatIdc );
     1055#endif
    8061056        Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
    8071057        Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     
    8131063        g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL;
    8141064
     1065#if Q0048_CGS_3D_ASYMLUT
     1066        TComPicYuv* pBaseColRec = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec();
     1067        if( pcSlice->getPPS()->getCGSFlag() )
     1068        {
     1069          if(g_posScalingFactor[refLayerIdc][0] < (1<<16) || g_posScalingFactor[refLayerIdc][1] < (1<<16)) //if(pcPic->isSpatialEnhLayer(refLayerIdc))
     1070          {
     1071            //downsampling;
     1072            downScalePic(pcPic->getPicYuvOrg(), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvOrg());
     1073            //pcSlice->getBaseColPic(refLayerIdc)->getPicYuvOrg()->dump("ds.yuv", true, true);
     1074            m_Enc3DAsymLUTPPS.setDsOrigPic(pcSlice->getBaseColPic(refLayerIdc)->getPicYuvOrg());
     1075            m_Enc3DAsymLUTPicUpdate.setDsOrigPic(pcSlice->getBaseColPic(refLayerIdc)->getPicYuvOrg());
     1076          }
     1077          else
     1078          {
     1079            m_Enc3DAsymLUTPPS.setDsOrigPic(pcPic->getPicYuvOrg());
     1080            m_Enc3DAsymLUTPicUpdate.setDsOrigPic(pcPic->getPicYuvOrg());
     1081          }
     1082
     1083          Bool bSignalPPS = m_bSeqFirst;
     1084          bSignalPPS |= m_pcCfg->getGOPSize() > 1 ? pocCurr % m_pcCfg->getIntraPeriod() == 0 : pocCurr % m_pcCfg->getFrameRate() == 0;
     1085          xDetermin3DAsymLUT( pcSlice , pcPic , refLayerIdc , m_pcCfg , bSignalPPS );
     1086          m_Enc3DAsymLUTPPS.colorMapping( pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(),  m_pColorMappedPic );
     1087          pBaseColRec = m_pColorMappedPic;
     1088        }
     1089#endif
    8151090#if SVC_UPSAMPLING
    8161091        if( pcPic->isSpatialEnhLayer(refLayerIdc))
    8171092        {
    818 /*#if O0098_SCALED_REF_LAYER_ID
    819           Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc));
    820 #else
    821           Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc);
    822 #endif*/
    8231093#if P0312_VERT_PHASE_ADJ
    8241094          //when PhasePositionEnableFlag is equal to 1, set vertPhasePositionFlag to 0 if BL is top field and 1 if bottom
     
    8301100#if O0215_PHASE_ALIGNMENT
    8311101#if O0194_JOINT_US_BITSHIFT
    832           m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
     1102#if Q0048_CGS_3D_ASYMLUT
     1103          m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
     1104#else
     1105          m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
     1106#endif
     1107#else
     1108#if Q0048_CGS_3D_ASYMLUT
     1109          m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
    8331110#else
    8341111          m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
    8351112#endif
     1113#endif
    8361114#else
    8371115#if O0194_JOINT_US_BITSHIFT
     1116#if Q0048_CGS_3D_ASYMLUT
     1117          m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
     1118#else
    8381119          m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
     1120#endif
     1121#else
     1122#if Q0048_CGS_3D_ASYMLUT
     1123          m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
    8391124#else
    8401125          m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
    8411126#endif
    8421127#endif
     1128#endif
    8431129        }
    8441130        else
    8451131        {
     1132#if Q0048_CGS_3D_ASYMLUT
     1133          pcPic->setFullPelBaseRec( refLayerIdc, pBaseColRec );
     1134#else
    8461135          pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() );
     1136#endif
    8471137        }
    8481138        pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) );
     
    8561146      }
    8571147
    858 #if !O0225_TID_BASED_IL_RPS_DERIV
     1148#if !O0225_TID_BASED_IL_RPS_DERIV || Q0060_MAX_TID_REF_EQUAL_TO_ZERO
    8591149      pcSlice->setActiveNumILRRefIdx( activeNumILRRefIdxTmp );
    8601150#endif
     
    9321222    }
    9331223
    934     // Do decoding refresh marking if any
    935 #if NO_CLRAS_OUTPUT_FLAG
    936     pcSlice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic, m_pcEncTop->getNoClrasOutputFlag());
    937 #else
    938     pcSlice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic);
    939 #endif
    940     m_pcEncTop->selectReferencePictureSet(pcSlice, pocCurr, iGOPid);
    941     pcSlice->getRPS()->setNumberOfLongtermPictures(0);
     1224#if EFFICIENT_FIELD_IRAP
    9421225#if FIX1172
    9431226    if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     
    9541237    pcSlice->setAssociatedIRAPPOC(m_associatedIRAPPOC);
    9551238#endif
    956 
     1239#endif
     1240    // Do decoding refresh marking if any
     1241#if NO_CLRAS_OUTPUT_FLAG
     1242    pcSlice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic, m_pcEncTop->getNoClrasOutputFlag());
     1243#else
     1244    pcSlice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic);
     1245#endif
     1246    m_pcEncTop->selectReferencePictureSet(pcSlice, pocCurr, iGOPid);
     1247    pcSlice->getRPS()->setNumberOfLongtermPictures(0);
     1248#if EFFICIENT_FIELD_IRAP
     1249#else
     1250#if FIX1172
     1251    if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     1252      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     1253      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP
     1254      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL
     1255      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP
     1256      || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA )  // IRAP picture
     1257    {
     1258      m_associatedIRAPType = pcSlice->getNalUnitType();
     1259      m_associatedIRAPPOC = pocCurr;
     1260    }
     1261    pcSlice->setAssociatedIRAPType(m_associatedIRAPType);
     1262    pcSlice->setAssociatedIRAPPOC(m_associatedIRAPPOC);
     1263#endif
     1264#endif
     1265
     1266#if ALLOW_RECOVERY_POINT_AS_RAP
     1267    if ((pcSlice->checkThatAllRefPicsAreAvailable(rcListPic, pcSlice->getRPS(), false, m_iLastRecoveryPicPOC, m_pcCfg->getDecodingRefreshType() == 3) != 0) || (pcSlice->isIRAP())
     1268#if EFFICIENT_FIELD_IRAP
     1269      || (isField && pcSlice->getAssociatedIRAPType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getAssociatedIRAPType() <= NAL_UNIT_CODED_SLICE_CRA && pcSlice->getAssociatedIRAPPOC() == pcSlice->getPOC()+1)
     1270#endif
     1271      )
     1272    {
     1273      pcSlice->createExplicitReferencePictureSetFromReference(rcListPic, pcSlice->getRPS(), pcSlice->isIRAP(), m_iLastRecoveryPicPOC, m_pcCfg->getDecodingRefreshType() == 3);
     1274    }
     1275#else
    9571276    if ((pcSlice->checkThatAllRefPicsAreAvailable(rcListPic, pcSlice->getRPS(), false) != 0) || (pcSlice->isIRAP()))
    9581277    {
    9591278      pcSlice->createExplicitReferencePictureSetFromReference(rcListPic, pcSlice->getRPS(), pcSlice->isIRAP());
    9601279    }
     1280#endif
    9611281#if ALIGNED_BUMPING
    9621282    pcSlice->checkLeadingPictureRestrictions(rcListPic);
     
    17432063      assert( pcSlice->getPPS()->getPPSId() == 0 || pcSlice->getPPS()->getPPSId() == m_layerId || m_pcEncTop->getVPS()->getRecursiveRefLayerFlag(m_layerId, pcSlice->getPPS()->getPPSId()) );
    17442064#endif
    1745       m_pcEntropyCoder->encodePPS(pcSlice->getPPS());
     2065      m_pcEntropyCoder->encodePPS(pcSlice->getPPS()
     2066#if Q0048_CGS_3D_ASYMLUT
     2067        , & m_Enc3DAsymLUTPPS
     2068#endif
     2069        );
    17462070      writeRBSPTrailingBits(nalu.m_Bitstream);
    17472071      accessUnit.push_back(new NALUnitEBSP(nalu));
     
    17762100      m_bSeqFirst = false;
    17772101    }
     2102#if Q0048_CGS_3D_ASYMLUT
     2103    else if( m_pcCfg->getCGSFlag() && pcSlice->getLayerId() && pcSlice->getCGSOverWritePPS() )
     2104    {
     2105#if SVC_EXTENSION
     2106      OutputNALUnit nalu(NAL_UNIT_PPS, 0, m_layerId);
     2107#endif
     2108
     2109      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     2110      m_pcEntropyCoder->encodePPS(pcSlice->getPPS() , &m_Enc3DAsymLUTPPS );
     2111      writeRBSPTrailingBits(nalu.m_Bitstream);
     2112      accessUnit.push_back(new NALUnitEBSP(nalu));
     2113    }
     2114#endif
    17782115
    17792116    if (writeSOP) // write SOP description SEI (if enabled) at the beginning of GOP
     
    18492186      pictureTimingSEI.m_auCpbRemovalDelay = std::min<Int>(std::max<Int>(1, m_totalCoded - m_lastBPSEI), static_cast<Int>(pow(2, static_cast<double>(pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getCpbRemovalDelayLengthMinus1()+1)))); // Syntax element signalled as minus, hence the .
    18502187#if POC_RESET_FLAG
    1851       pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(0) + pocCurr - m_totalCoded;
    1852 #else
    1853       pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(0) + pcSlice->getPOC() - m_totalCoded;
     2188      pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(pcSlice->getSPS()->getMaxTLayers()-1) + pocCurr - m_totalCoded;
     2189#else
     2190      pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(pcSlice->getSPS()->getMaxTLayers()-1) + pcSlice->getPOC() - m_totalCoded;
     2191#endif
     2192#if EFFICIENT_FIELD_IRAP
     2193      if(IRAPGOPid > 0 && IRAPGOPid < m_iGopSize)
     2194      {
     2195        // if pictures have been swapped there is likely one more picture delay on their tid. Very rough approximation
     2196        pictureTimingSEI.m_picDpbOutputDelay ++;
     2197      }
    18542198#endif
    18552199      Int factor = pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2;
     
    19752319#endif
    19762320      sei_recovery_point.m_brokenLinkFlag    = false;
     2321#if ALLOW_RECOVERY_POINT_AS_RAP
     2322      if(m_pcCfg->getDecodingRefreshType() == 3)
     2323      {
     2324        m_iLastRecoveryPicPOC = pocCurr;
     2325      }
     2326#endif
    19772327
    19782328#if O0164_MULTI_LAYER_HRD
     
    21102460          }
    21112461          m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     2462
     2463#if SETTING_NO_OUT_PIC_PRIOR
     2464          if (pcSlice->isIRAP())
     2465          {
     2466            if (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP)
     2467            {
     2468              pcSlice->setNoRaslOutputFlag(true);
     2469            }
     2470            //the inference for NoOutputPriorPicsFlag
     2471            if (!m_bFirst && pcSlice->isIRAP() && pcSlice->getNoRaslOutputFlag())
     2472            {
     2473              if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)
     2474              {
     2475                pcSlice->setNoOutputPriorPicsFlag(true);
     2476              }
     2477            }
     2478          }
     2479#endif
     2480
    21122481          tmpBitsBeforeWriting = m_pcEntropyCoder->getNumberOfWrittenBits();
    21132482          m_pcEntropyCoder->encodeSliceHeader(pcSlice);
     
    26573026
    26583027      delete[] pcSubstreamsOut;
     3028
     3029#if EFFICIENT_FIELD_IRAP
     3030    if(IRAPtoReorder)
     3031    {
     3032      if(swapIRAPForward)
     3033      {
     3034        if(iGOPid == IRAPGOPid)
     3035        {
     3036          iGOPid = IRAPGOPid +1;
     3037          IRAPtoReorder = false;
     3038        }
     3039        else if(iGOPid == IRAPGOPid +1)
     3040        {
     3041          iGOPid --;
     3042        }
     3043      }
     3044      else
     3045      {
     3046        if(iGOPid == IRAPGOPid)
     3047        {
     3048          iGOPid = IRAPGOPid -1;
     3049        }
     3050        else if(iGOPid == IRAPGOPid -1)
     3051        {
     3052          iGOPid = IRAPGOPid;
     3053          IRAPtoReorder = false;
     3054        }
     3055      }
     3056    }
     3057#endif
    26593058  }
    26603059  delete pcBitstreamRedirect;
     
    29183317    case NAL_UNIT_CODED_SLICE_CRA:        return "CRA";
    29193318    case NAL_UNIT_CODED_SLICE_RADL_R:     return "RADL_R";
     3319    case NAL_UNIT_CODED_SLICE_RADL_N:     return "RADL_N";
    29203320    case NAL_UNIT_CODED_SLICE_RASL_R:     return "RASL_R";
     3321    case NAL_UNIT_CODED_SLICE_RASL_N:     return "RASL_N";
    29213322    case NAL_UNIT_VPS:                    return "VPS";
    29223323    case NAL_UNIT_SPS:                    return "SPS";
     
    30803481         pcSlice->getTLayer(),
    30813482         c,
    3082          NaluToStr( pcSlice->getNalUnitType() ).data().
     3483         NaluToStr( pcSlice->getNalUnitType() ).data(),
    30833484         pcSlice->getSliceQp(),
    30843485         uibits );
     
    31343535    printf("]");
    31353536  }
     3537#if Q0048_CGS_3D_ASYMLUT
     3538  pcPic->setFrameBit( (Int)uibits );
     3539  if( m_layerId && pcSlice->getPPS()->getCGSFlag() )
     3540  {
     3541    m_Enc3DAsymLUTPicUpdate.updatePicCGSBits( pcSlice , m_Enc3DAsymLUTPPS.getPPSBit() );
     3542  }
     3543#endif
    31363544}
    31373545
     
    33163724    return NAL_UNIT_CODED_SLICE_IDR_W_RADL;
    33173725  }
     3726#if EFFICIENT_FIELD_IRAP
     3727  if(isField && pocCurr == 1)
     3728  {
     3729    // to avoid the picture becoming an IRAP
     3730    return NAL_UNIT_CODED_SLICE_TRAIL_R;
     3731  }
     3732#endif
     3733
     3734#if ALLOW_RECOVERY_POINT_AS_RAP
     3735  if(m_pcCfg->getDecodingRefreshType() != 3 && (pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0)
     3736#else
    33183737  if ((pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0)
     3738#endif
    33193739  {
    33203740    if (m_pcCfg->getDecodingRefreshType() == 1)
     
    38284248#endif
    38294249
     4250#if Q0048_CGS_3D_ASYMLUT
     4251Void TEncGOP::xDetermin3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS )
     4252{
     4253  Int nCGSFlag = pSlice->getPPS()->getCGSFlag();
     4254  m_Enc3DAsymLUTPPS.setPPSBit( 0 );
     4255  Double dErrorUpdatedPPS = 0 , dErrorPPS = 0;
     4256  dErrorUpdatedPPS = m_Enc3DAsymLUTPicUpdate.derive3DAsymLUT( pSlice , pCurPic , refLayerIdc , pCfg , bSignalPPS , m_pcEncTop->getElRapSliceTypeB() );
     4257  if( bSignalPPS )
     4258  {
     4259    m_Enc3DAsymLUTPPS.copy3DAsymLUT( &m_Enc3DAsymLUTPicUpdate );
     4260    pSlice->setCGSOverWritePPS( 1 ); // regular PPS update
     4261  }
     4262  else if( nCGSFlag )
     4263  {
     4264    dErrorPPS = m_Enc3DAsymLUTPPS.estimateDistWithCur3DAsymLUT( pCurPic , refLayerIdc );
     4265    Double dFactor = pCfg->getIntraPeriod() == 1 ? 0.99 : 0.9;
     4266    pSlice->setCGSOverWritePPS( dErrorUpdatedPPS < dFactor * dErrorPPS );
     4267    if( pSlice->getCGSOverWritePPS() )
     4268    {
     4269      m_Enc3DAsymLUTPPS.copy3DAsymLUT( &m_Enc3DAsymLUTPicUpdate );
     4270    }
     4271  }
     4272  pSlice->getPPS()->setCGSOutputBitDepthY( m_Enc3DAsymLUTPPS.getOutputBitDepthY() );
     4273  pSlice->getPPS()->setCGSOutputBitDepthC( m_Enc3DAsymLUTPPS.getOutputBitDepthC() );
     4274}
     4275
     4276Void TEncGOP::downScalePic( TComPicYuv* pcYuvSrc, TComPicYuv* pcYuvDest)
     4277{
     4278  Int inputBitDepth = g_bitDepthYLayer[m_layerId];
     4279  Int outputBitDepth = g_bitDepthYLayer[m_layerId];
     4280  {
     4281    pcYuvSrc->setBorderExtension(false);
     4282    pcYuvSrc->extendPicBorder   (); // extend the border.
     4283    pcYuvSrc->setBorderExtension(false);
     4284
     4285    Int iWidth = pcYuvSrc->getWidth();
     4286    Int iHeight =pcYuvSrc->getHeight();
     4287
     4288    if(!m_temp)
     4289      initDs(iWidth, iHeight, m_pcCfg->getIntraPeriod()>1);
     4290
     4291    filterImg(pcYuvSrc->getLumaAddr(), pcYuvSrc->getStride(), pcYuvDest->getLumaAddr(), pcYuvDest->getStride(), iHeight, iWidth,  inputBitDepth-outputBitDepth, 0);
     4292    filterImg(pcYuvSrc->getCbAddr(), pcYuvSrc->getCStride(), pcYuvDest->getCbAddr(), pcYuvDest->getCStride(), iHeight>>1, iWidth>>1, inputBitDepth-outputBitDepth, 1);
     4293    filterImg(pcYuvSrc->getCrAddr(), pcYuvSrc->getCStride(), pcYuvDest->getCrAddr(), pcYuvDest->getCStride(), iHeight>>1, iWidth>>1, inputBitDepth-outputBitDepth, 2); 
     4294  }
     4295}
     4296const int TEncGOP::m_phase_filter_0_t0[4][13]={
     4297  {0,  2,  -3,  -9,   6,  39,  58,  39,   6,  -9,  -3,  2,  0}, 
     4298  {0, 0,  0,  -2,  8,-20, 116, 34, -10,  2,  0, 0,  0},                      //{0,  1,  -1,  -8,  -1,  31,  57,  47,  13,  -7,  -5,  1,  0},  //
     4299  {0,  1,   0,  -7,  -5,  22,  53,  53,  22,  -5,  -7,  0,  1}, 
     4300  {0,  0,   1,  -5,  -7,  13,  47,  57,  31,  -1,  -8,-1,  1} 
     4301};
     4302
     4303const int TEncGOP::m_phase_filter_0_t1[4][13]={
     4304  {0,  4,  0,  -12, 0,  40,  64,  40, 0, -12,  0,  4,  0},
     4305  {0, 0,  0,  -2,  8,-20, 116,34,-10,  2,  0, 0,  0},                      //{0,  1,  -1,  -8,  -1,  31,  57,  47,  13,  -7,  -5,  1,  0},  //
     4306  {0,  1,   0,  -7,  -5,  22,  53,  53,  22,  -5,  -7,  0,  1}, 
     4307  {0,  0,   1,  -5,  -7,  13,  47,  57,  31,  -1,  -8,-1,  1} 
     4308};
     4309const int TEncGOP::m_phase_filter_0_t1_chroma[4][13]={
     4310  {0,  0,  0,   0,  0,   0,  128, 0,  0,  0,  0,  0,  0},
     4311  {0, 0,  0,  -2,  8,-20, 116,34,-10,  2,  0, 0,  0},                      //{0,  1,  -1,  -8,  -1,  31,  57,  47,  13,  -7,  -5,  1,  0},  //
     4312  {0,  1,   0,  -7,  -5,  22,  53,  53,  22,  -5,  -7,  0,  1}, 
     4313  {0,  0,   1,  -5,  -7,  13,  47,  57,  31,  -1,  -8,-1,  1} 
     4314};
     4315
     4316const int TEncGOP::m_phase_filter_1[8][13]={
     4317  {0,   0,  5,  -6,  -10,37,  76,  37,-10,   -6, 5,  0,   0},   
     4318  {0,  -1,  5,  -3,  -12,29,  75,  45,  -7,   -8, 5,  0,   0},   
     4319  {0,  -1,  4,  -1,  -13,22,  73,  52,  -3,  -10, 4,  1,   0},   
     4320  {0,  -1,  4,   1,  -13,14,  70,  59,   2,  -12, 3,  2,  -1}, 
     4321  {0,  -1,  3,   2,  -13, 8,  65,  65,   8,  -13, 2,  3,  -1},   
     4322  {0,  -1,  2,   3,  -12, 2,  59,  70,  14,  -13, 1,  4,  -1},   
     4323  {0,   0,  1,   4,  -10,-3,  52,  73,  22,  -13,-1,  4,  -1},   
     4324  {0,   0,  0,   5,   -8,-7,  45,  75,  29,  -12,-3,  5,  -1}   
     4325};
     4326
     4327Void TEncGOP::filterImg(
     4328    Pel           *src,
     4329    Int           iSrcStride,
     4330    Pel           *dst,
     4331    Int           iDstStride,
     4332    Int           height1, 
     4333    Int           width1, 
     4334    Int           shift,
     4335    Int           plane)
     4336{
     4337  Int length = m_iTap;
     4338  Int height2,width2;
     4339  Int k,iSum;
     4340  Int i0, div_i0, i1;
     4341  Int j0, div_j0, j1;
     4342  const Int *p_filter;
     4343  Pel *p_src, *p_dst;
     4344  Pel *p_src_line, *p_dst_line;
     4345  Int **p_temp, *p_tmp;
     4346  Int shift2 = 2*7+shift;
     4347  Int shift_round = (1 << (shift2 - 1));
     4348  Int iMax = (1<<(g_bitDepthY-shift))-1;
     4349  height2 = (height1 * m_iM) / m_iN;
     4350  width2  = (width1  * m_iM) / m_iN;
     4351
     4352  m_phase_filter = plane? m_phase_filter_chroma : m_phase_filter_luma;
     4353
     4354  // horizontal filtering
     4355  p_src_line = src;
     4356  for(j1 = 0; j1 < height1; j1++)
     4357  {
     4358    i0=-m_iN;
     4359    p_tmp = m_temp[j1];
     4360   
     4361    for(i1 = 0; i1 < width2; i1++)
     4362    {
     4363      i0      += m_iN;
     4364      div_i0   = (i0 / m_iM);
     4365      p_src    =  p_src_line + ( div_i0 - (length >> 1));
     4366      p_filter = m_phase_filter[i0 - div_i0 * m_iM]; // phase_filter[i0 % M]
     4367      iSum     = 0;
     4368      for(k = 0; k < length; k++)
     4369      {
     4370        iSum += (*p_src++) * (*p_filter++);
     4371      }
     4372      *p_tmp++ = iSum;
     4373    }
     4374    p_src_line +=  iSrcStride;
     4375  }
     4376
     4377  // pad temp (vertical)
     4378  for (k=-(length>>1); k<0; k++)
     4379    memcpy(m_temp[k], m_temp[0], width2*sizeof(int));
     4380  for (k=height1; k<(height1+(length>>1)); k++)
     4381    memcpy(m_temp[k], m_temp[k-1], (width2)* sizeof(int));
     4382
     4383  // vertical filtering
     4384  j0 = (plane == 0) ? -m_iN : -(m_iN-1);
     4385 
     4386  p_dst_line = dst;
     4387  for(j1 = 0; j1 < height2; j1++)
     4388  {
     4389    j0      += m_iN;
     4390    div_j0   = (j0 / m_iM);
     4391    p_dst = p_dst_line;
     4392    p_temp   = &m_temp[div_j0 - (length>>1)];
     4393    p_filter = m_phase_filter[j0 - div_j0 * m_iM]; // phase_filter[j0 % M]
     4394    for(i1 = 0; i1 < width2;i1++)
     4395    {
     4396      iSum=0;
     4397      for(k = 0; k < length; k++)
     4398      {
     4399        iSum += p_temp[k][i1] * p_filter[k];
     4400      }
     4401      iSum=((iSum + shift_round) >> shift2);
     4402      *p_dst++ = (short)(iSum > iMax ? iMax : (iSum < 0 ? 0 : iSum));
     4403    }
     4404    p_dst_line += iDstStride;
     4405  }
     4406}
     4407
     4408Void TEncGOP::initDs(Int iWidth, Int iHeight, Int iType)
     4409{
     4410  m_iTap = 13;
     4411  if(g_posScalingFactor[0][0] == (1<<15))
     4412  {
     4413    m_iM = 4;
     4414    m_iN = 8;
     4415    m_phase_filter_luma = iType? m_phase_filter_0_t1 : m_phase_filter_0_t0;
     4416    m_phase_filter_chroma = m_phase_filter_0_t1_chroma;
     4417  }
     4418  else
     4419  {
     4420    m_iM = 8;
     4421    m_iN = 12;
     4422    m_phase_filter_luma = m_phase_filter_chroma =  m_phase_filter_1;
     4423    m_phase_filter = m_phase_filter_1;
     4424  }
     4425
     4426  get_mem2DintWithPad (&m_temp, iHeight, iWidth*m_iM/m_iN,   m_iTap>>1, 0);
     4427}
     4428
     4429Int TEncGOP::get_mem2DintWithPad(Int ***array2D, Int dim0, Int dim1, Int iPadY, Int iPadX)
     4430{
     4431  Int i;
     4432  Int *curr = NULL;
     4433  Int iHeight, iWidth;
     4434
     4435  iHeight = dim0+2*iPadY;
     4436  iWidth = dim1+2*iPadX;
     4437  (*array2D) = (Int**)malloc(iHeight*sizeof(Int*));
     4438  *(*array2D) = (Int* )xMalloc(Int, iHeight*iWidth);
     4439
     4440  (*array2D)[0] += iPadX;
     4441  curr = (*array2D)[0];
     4442  for(i = 1 ; i < iHeight; i++)
     4443  {
     4444    curr += iWidth;
     4445    (*array2D)[i] = curr;
     4446  }
     4447  (*array2D) = &((*array2D)[iPadY]);
     4448
     4449  return 0;
     4450}
     4451
     4452Void TEncGOP::free_mem2DintWithPad(Int **array2D, Int iPadY, Int iPadX)
     4453{
     4454  if (array2D)
     4455  {
     4456    if (*array2D)
     4457      xFree(array2D[-iPadY]-iPadX);
     4458    else
     4459      printf("free_mem2DintWithPad: trying to free unused memory\r\nPress Any Key\r\n");
     4460
     4461    free (&array2D[-iPadY]);
     4462  }
     4463  else
     4464  {
     4465    printf("free_mem2DintWithPad: trying to free unused memory\r\nPress Any Key\r\n");
     4466  }
     4467}
     4468#endif
    38304469#endif //SVC_EXTENSION
    38314470
  • trunk/source/Lib/TLibEncoder/TEncGOP.h

    r644 r713  
    5454#include "TEncSbac.h"
    5555#include "SEIwrite.h"
     56#if Q0048_CGS_3D_ASYMLUT
     57#include "TEnc3DAsymLUT.h"
     58#endif
    5659
    5760#include "TEncAnalyze.h"
     
    8285  Int                     m_iNumPicCoded;
    8386  Bool                    m_bFirst;
     87#if ALLOW_RECOVERY_POINT_AS_RAP
     88  Int                     m_iLastRecoveryPicPOC;
     89#endif
    8490 
    8591  //  Access channel
     
    132138  TEncSearch*             m_pcPredSearch;                       ///< encoder search class
    133139#endif 
     140#if Q0048_CGS_3D_ASYMLUT
     141  TEnc3DAsymLUT           m_Enc3DAsymLUTPicUpdate;
     142  TEnc3DAsymLUT           m_Enc3DAsymLUTPPS;
     143  TComPicYuv*             m_pColorMappedPic;
     144
     145  Int m_iTap;
     146  const Int (*m_phase_filter)[13];
     147  const Int (*m_phase_filter_luma)[13];
     148  const Int (*m_phase_filter_chroma)[13];
     149  Int m_iM, m_iN;
     150  static const Int m_phase_filter_0_t0[4][13];
     151  static const Int m_phase_filter_0_t1[4][13];
     152  static const Int m_phase_filter_0_t1_chroma[4][13];
     153  static const Int m_phase_filter_1[8][13];
     154  Int   **m_temp;
     155#endif
    134156#endif
    135157 
     
    187209
    188210  SEIToneMappingInfo*     xCreateSEIToneMappingInfo();
     211#if Q0074_SEI_COLOR_MAPPING
     212  SEIColorMappingInfo*    xCreateSEIColorMappingInfo( Char* file );
     213#endif
    189214
    190215  Void xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps);
     
    214239  SEIScalableNesting* xCreateBspNestingSEI(TComSlice *pcSlice);
    215240#endif
     241#if Q0048_CGS_3D_ASYMLUT
     242  Void xDetermin3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS );
     243  Void downScalePic( TComPicYuv* pcYuvSrc, TComPicYuv* pcYuvDest);
     244  Void downScaleComponent2x2( const Pel* pSrc, Pel* pDest, const Int iSrcStride, const Int iDestStride, const Int iSrcWidth, const Int iSrcHeight, const Int inputBitDepth, const Int outputBitDepth );
     245  inline Short  xClip( Short x , Int bitdepth );
     246  Void initDs(Int iWidth, Int iHeight, Int iType);
     247  Void filterImg(
     248    Pel           *src,
     249    Int           iSrcStride,
     250    Pel           *dst,
     251    Int           iDstStride,
     252    Int           height1, 
     253    Int           width1, 
     254    Int           shift,
     255    Int           plane);
     256
     257  Int get_mem2DintWithPad(Int ***array2D, Int dim0, Int dim1, Int iPadY, Int iPadX);
     258  Void free_mem2DintWithPad(Int **array2D, Int iPadY, Int iPadX);
     259#endif
    216260#endif //SVC_EXTENSION
    217261};// END CLASS DEFINITION TEncGOP
  • trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp

    r644 r713  
    952952        for (y=0; y<endY; y++)
    953953        {
     954#if SAO_SGN_FUNC
     955          signLeft = (Char)sgn(srcLine[startX] - srcLine[startX-1]);
     956#else
    954957          signLeft = (Char)m_sign[srcLine[startX] - srcLine[startX-1]];
     958#endif
    955959          for (x=startX; x<endX; x++)
    956960          {
     961#if SAO_SGN_FUNC
     962            signRight =  (Char)sgn(srcLine[x] - srcLine[x+1]);
     963#else
    957964            signRight =  (Char)m_sign[srcLine[x] - srcLine[x+1]];
     965#endif
    958966            edgeType  =  signRight + signLeft;
    959967            signLeft  = -signRight;
     
    975983            for(y=0; y<skipLinesB[typeIdx]; y++)
    976984            {
     985#if SAO_SGN_FUNC
     986              signLeft = (Char)sgn(srcLine[startX] - srcLine[startX-1]);
     987#else
    977988              signLeft = (Char)m_sign[srcLine[startX] - srcLine[startX-1]];
     989#endif
    978990              for (x=startX; x<endX; x++)
    979991              {
     992#if SAO_SGN_FUNC
     993                signRight =  (Char)sgn(srcLine[x] - srcLine[x+1]);
     994#else
    980995                signRight =  (Char)m_sign[srcLine[x] - srcLine[x+1]];
     996#endif
    981997                edgeType  =  signRight + signLeft;
    982998                signLeft  = -signRight;
     
    10261042#endif
    10271043        {
     1044#if SAO_SGN_FUNC
     1045          signUpLine[x] = (Char)sgn(srcLine[x] - srcLineAbove[x]);
     1046#else
    10281047          signUpLine[x] = (Char)m_sign[srcLine[x] - srcLineAbove[x]];
     1048#endif
    10291049        }
    10301050
     
    10401060#endif
    10411061          {
     1062#if SAO_SGN_FUNC
     1063            signDown  = (Char)sgn(srcLine[x] - srcLineBelow[x]);
     1064#else
    10421065            signDown  = (Char)m_sign[srcLine[x] - srcLineBelow[x]];
     1066#endif
    10431067            edgeType  = signDown + signUpLine[x];
    10441068            signUpLine[x]= -signDown;
     
    10651089              for (x=startX; x<endX; x++)
    10661090              {
     1091#if SAO_SGN_FUNC
     1092                edgeType = sgn(srcLine[x] - srcLineBelow[x]) + sgn(srcLine[x] - srcLineAbove[x]);
     1093#else
    10671094                edgeType = m_sign[srcLine[x] - srcLineBelow[x]] + m_sign[srcLine[x] - srcLineAbove[x]];
     1095#endif
    10681096                diff [edgeType] += (orgLine[x] - srcLine[x]);
    10691097                count[edgeType] ++;
     
    11081136        for (x=startX; x<endX+1; x++)
    11091137        {
     1138#if SAO_SGN_FUNC
     1139          signUpLine[x] = (Char)sgn(srcLineBelow[x] - srcLine[x-1]);
     1140#else
    11101141          signUpLine[x] = (Char)m_sign[srcLineBelow[x] - srcLine[x-1]];
     1142#endif
    11111143        }
    11121144
     
    11221154        for(x=firstLineStartX; x<firstLineEndX; x++)
    11231155        {
     1156#if SAO_SGN_FUNC
     1157          edgeType = sgn(srcLine[x] - srcLineAbove[x-1]) - signUpLine[x+1];
     1158#else
    11241159          edgeType = m_sign[srcLine[x] - srcLineAbove[x-1]] - signUpLine[x+1];
     1160#endif
    11251161          diff [edgeType] += (orgLine[x] - srcLine[x]);
    11261162          count[edgeType] ++;
     
    11371173          for (x=startX; x<endX; x++)
    11381174          {
     1175#if SAO_SGN_FUNC
     1176            signDown = (Char)sgn(srcLine[x] - srcLineBelow[x+1]);
     1177#else
    11391178            signDown = (Char)m_sign[srcLine[x] - srcLineBelow[x+1]] ;
     1179#endif
    11401180            edgeType = signDown + signUpLine[x];
    11411181            diff [edgeType] += (orgLine[x] - srcLine[x]);
     
    11441184            signDownLine[x+1] = -signDown;
    11451185          }
     1186#if SAO_SGN_FUNC
     1187          signDownLine[startX] = (Char)sgn(srcLineBelow[startX] - srcLine[startX-1]);
     1188#else
    11461189          signDownLine[startX] = (Char)m_sign[srcLineBelow[startX] - srcLine[startX-1]];
     1190#endif
    11471191
    11481192          signTmpLine  = signUpLine;
     
    11681212              for (x=startX; x< endX; x++)
    11691213              {
     1214#if SAO_SGN_FUNC
     1215                edgeType = sgn(srcLine[x] - srcLineBelow[x+1]) + sgn(srcLine[x] - srcLineAbove[x-1]);
     1216#else
    11701217                edgeType = m_sign[srcLine[x] - srcLineBelow[x+1]] + m_sign[srcLine[x] - srcLineAbove[x-1]];
     1218#endif
    11711219                diff [edgeType] += (orgLine[x] - srcLine[x]);
    11721220                count[edgeType] ++;
     
    12061254        for (x=startX-1; x<endX; x++)
    12071255        {
     1256#if SAO_SGN_FUNC
     1257          signUpLine[x] = (Char)sgn(srcLineBelow[x] - srcLine[x+1]);
     1258#else
    12081259          signUpLine[x] = (Char)m_sign[srcLineBelow[x] - srcLine[x+1]];
     1260#endif
    12091261        }
    12101262
     
    12251277        for(x=firstLineStartX; x<firstLineEndX; x++)
    12261278        {
     1279#if SAO_SGN_FUNC
     1280          edgeType = sgn(srcLine[x] - srcLineAbove[x+1]) - signUpLine[x-1];
     1281#else
    12271282          edgeType = m_sign[srcLine[x] - srcLineAbove[x+1]] - signUpLine[x-1];
     1283#endif
    12281284          diff [edgeType] += (orgLine[x] - srcLine[x]);
    12291285          count[edgeType] ++;
     
    12401296          for(x=startX; x<endX; x++)
    12411297          {
     1298#if SAO_SGN_FUNC
     1299            signDown = (Char)sgn(srcLine[x] - srcLineBelow[x-1]);
     1300#else
    12421301            signDown = (Char)m_sign[srcLine[x] - srcLineBelow[x-1]] ;
     1302#endif
    12431303            edgeType = signDown + signUpLine[x];
    12441304
     
    12481308            signUpLine[x-1] = -signDown;
    12491309          }
     1310#if SAO_SGN_FUNC
     1311          signUpLine[endX-1] = (Char)sgn(srcLineBelow[endX-1] - srcLine[endX]);
     1312#else
    12501313          signUpLine[endX-1] = (Char)m_sign[srcLineBelow[endX-1] - srcLine[endX]];
     1314#endif
    12511315          srcLine  += srcStride;
    12521316          orgLine  += orgStride;
     
    12671331              for (x=startX; x<endX; x++)
    12681332              {
     1333#if SAO_SGN_FUNC
     1334                edgeType = sgn(srcLine[x] - srcLineBelow[x-1]) + sgn(srcLine[x] - srcLineAbove[x+1]);
     1335#else
    12691336                edgeType = m_sign[srcLine[x] - srcLineBelow[x-1]] + m_sign[srcLine[x] - srcLineAbove[x+1]];
     1337#endif
    12701338                diff [edgeType] += (orgLine[x] - srcLine[x]);
    12711339                count[edgeType] ++;
  • trunk/source/Lib/TLibEncoder/TEncSbac.cpp

    r644 r713  
    248248}
    249249
    250 Void TEncSbac::codePPS( TComPPS* pcPPS )
     250Void TEncSbac::codePPS( TComPPS* pcPPS
     251#if Q0048_CGS_3D_ASYMLUT
     252  , TEnc3DAsymLUT * pc3DAsymLUT
     253#endif
     254  )
    251255{
    252256  assert (0);
  • trunk/source/Lib/TLibEncoder/TEncSbac.h

    r644 r713  
    9292  Void  codeVPS                 ( TComVPS* pcVPS );
    9393  Void  codeSPS                 ( TComSPS* pcSPS     );
    94   Void  codePPS                 ( TComPPS* pcPPS     );
     94  Void  codePPS                 ( TComPPS* pcPPS     
     95#if Q0048_CGS_3D_ASYMLUT
     96    , TEnc3DAsymLUT * pc3DAsymLUT
     97#endif
     98    );
    9599  Void  codeSliceHeader         ( TComSlice* pcSlice );
    96100  Void  codeTilesWPPEntryPoint( TComSlice* pSlice );
    97 #if POC_RESET_IDC_SIGNALLING
    98   Void  codeSliceHeaderExtn     ( TComSlice* pSlice, Int shBitsWrittenTillNow );
    99 #endif
    100101  Void  codeTerminatingBit      ( UInt uilsLast      );
    101102  Void  codeSliceFinish         ();
     
    108109
    109110#if SVC_EXTENSION
     111#if POC_RESET_IDC_SIGNALLING
     112  Void  codeSliceHeaderExtn     ( TComSlice* pSlice, Int shBitsWrittenTillNow );
     113#endif
    110114  Void codeSAOOffsetParam(Int compIdx, SAOOffset& ctbParam, Bool sliceEnabled, UInt* saoMaxOffsetQVal);
    111115  Void codeSAOBlkParam(SAOBlkParam& saoBlkParam
  • trunk/source/Lib/TLibEncoder/TEncSearch.cpp

    r595 r713  
    23982398{
    23992399  UInt    uiDepth        = pcCU->getDepth(0);
    2400   UInt    uiNumPU        = pcCU->getNumPartInter();
     2400  UInt    uiNumPU        = pcCU->getNumPartitions();
    24012401  UInt    uiInitTrDepth  = pcCU->getPartitionSize(0) == SIZE_2Nx2N ? 0 : 1;
    24022402  UInt    uiWidth        = pcCU->getWidth (0) >> uiInitTrDepth;
     
    31303130  TComMv        cMvTemp[2][33];
    31313131 
    3132   Int           iNumPart    = pcCU->getNumPartInter();
     3132  Int           iNumPart    = pcCU->getNumPartitions();
    31333133  Int           iNumPredDir = pcCU->getSlice()->isInterP() ? 1 : 2;
    31343134 
     
    46124612   
    46134613    m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST] );
    4614 #if 0 // check
    4615     {
    4616       m_pcEntropyCoder->resetBits();
    4617       m_pcEntropyCoder->encodeCoeff( pcCU, 0, pcCU->getDepth(0), pcCU->getWidth(0), pcCU->getHeight(0) );
    4618       const UInt uiBitsForCoeff = m_pcEntropyCoder->getNumberOfWrittenBits();
    4619       m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_CURR_BEST] );
    4620       if( uiBitsForCoeff != uiBits )
    4621         assert( 0 );
    4622     }
    4623 #endif
     4614   
    46244615    uiBits = 0;
    46254616    {
  • trunk/source/Lib/TLibEncoder/TEncSlice.cpp

    r644 r713  
    225225  Int depth;
    226226  {
     227#if FIX_FIELD_DEPTH   
     228    Int poc = rpcSlice->getPOC();
     229    if(isField)
     230    {
     231      poc = (poc/2)%(m_pcCfg->getGOPSize()/2);
     232    }
     233    else
     234    {
     235      poc = poc%m_pcCfg->getGOPSize();   
     236    }
     237#else
    227238    Int poc = rpcSlice->getPOC()%m_pcCfg->getGOPSize();
     239#endif
    228240    if ( poc == 0 )
    229241    {
     
    248260      }
    249261    }
     262#if FIX_FIELD_DEPTH 
     263#if HARMONIZE_GOP_FIRST_FIELD_COUPLE
     264    if(poc != 0)
     265    {
     266#endif
     267    if(isField && rpcSlice->getPOC()%2 == 1)
     268    {
     269      depth ++;
     270    }
     271#if HARMONIZE_GOP_FIRST_FIELD_COUPLE
     272  }
     273#endif
     274#endif
    250275  }
    251276
     
    254279
    255280  eSliceType=B_SLICE;
     281#if EFFICIENT_FIELD_IRAP
     282  if(!(isField && pocLast == 1))
     283  {
     284#endif // EFFICIENT_FIELD_IRAP
     285#if ALLOW_RECOVERY_POINT_AS_RAP
     286  if(m_pcCfg->getDecodingRefreshType() == 3)
     287  {
     288    eSliceType = (pocLast == 0 || pocCurr % m_pcCfg->getIntraPeriod() == 0             || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
     289  }
     290  else
     291  {
    256292  eSliceType = (pocLast == 0 || (pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
     293  }
     294#else
     295  eSliceType = (pocLast == 0 || (pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
     296#endif
     297#if EFFICIENT_FIELD_IRAP
     298  }
     299#endif
    257300
    258301  rpcSlice->setSliceType    ( eSliceType );
     
    423466#if HB_LAMBDA_FOR_LDC
    424467  // restore original slice type
     468 
     469#if EFFICIENT_FIELD_IRAP
     470  if(!(isField && pocLast == 1))
     471  {
     472#endif // EFFICIENT_FIELD_IRAP
     473#if ALLOW_RECOVERY_POINT_AS_RAP
     474  if(m_pcCfg->getDecodingRefreshType() == 3)
     475  {
     476    eSliceType = (pocLast == 0 || (pocCurr)           % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
     477
     478  }
     479  else
     480  {
    425481  eSliceType = (pocLast == 0 || (pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
     482  }
     483#else
     484  eSliceType = (pocLast == 0 || (pocCurr - isField) % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType;
     485#endif
     486#if EFFICIENT_FIELD_IRAP
     487  }
     488#endif // EFFICIENT_FIELD_IRAP
    426489
    427490#if SVC_EXTENSION
     
    544607  // store lambda
    545608  slice->setSliceQp( sliceQP );
     609#if ADAPTIVE_QP_SELECTION
    546610  slice->setSliceQpBase ( sliceQP );
     611#endif
    547612  m_pcRdCost ->setLambda( lambda );
    548613  // for RDO
     
    10411106
    10421107      m_pcRateCtrl->setRCQP( estQP );
     1108#if ADAPTIVE_QP_SELECTION
    10431109      pcCU->getSlice()->setSliceQpBase( estQP );
     1110#endif
    10441111    }
    10451112
  • trunk/source/Lib/TLibEncoder/TEncTop.cpp

    r644 r713  
    795795          Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] );
    796796
    797           if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets || !sameBitDepths )
     797          if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets || !sameBitDepths
     798#if Q0048_CGS_3D_ASYMLUT
     799            || m_cPPS.getCGSFlag() > 0
     800#endif
     801#if LAYER_CTB
     802            || pcEncTopBase->getSPS()->getMaxCUWidth() != m_cSPS.getMaxCUWidth() || pcEncTopBase->getSPS()->getMaxCUHeight() != m_cSPS.getMaxCUHeight() || pcEncTopBase->getSPS()->getMaxCUDepth() != m_cSPS.getMaxCUDepth()
     803#endif
     804            )
    798805#else
    799806          if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets )
     
    857864          Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] );
    858865
    859           if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets || !sameBitDepths )
     866          if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets || !sameBitDepths
     867#if Q0048_CGS_3D_ASYMLUT
     868            || m_cPPS.getCGSFlag() > 0
     869#endif
     870#if LAYER_CTB
     871            || pcEncTopBase->getSPS()->getMaxCUWidth() != m_cSPS.getMaxCUWidth() || pcEncTopBase->getSPS()->getMaxCUHeight() != m_cSPS.getMaxCUHeight() || pcEncTopBase->getSPS()->getMaxCUDepth() != m_cSPS.getMaxCUDepth()
     872#endif
     873)
    860874#else
    861875          if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets )
     
    11881202  }
    11891203#endif
     1204#if Q0048_CGS_3D_ASYMLUT
     1205  m_cPPS.setCGSFlag( m_nCGSFlag );
     1206#endif
    11901207}
    11911208
  • trunk/source/Lib/TLibEncoder/TEncTop.h

    r644 r713  
    273273
    274274  /// encode several number of pictures until end-of-sequence
    275   Void encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
     275  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
    276276              std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff);
    277277
Note: See TracChangeset for help on using the changeset viewer.