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


Ignore:
Timestamp:
30 Jun 2014, 06:13:06 (10 years ago)
Author:
seregin
Message:

merge with SHM-6-dev branch

Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/source

  • trunk/source/Lib/TLibEncoder/SEIwrite.cpp

    r713 r815  
    8787    fprintf( g_hTrace, "=========== Tone Mapping Info SEI message ===========\n");
    8888    break;
     89#if P0050_KNEE_FUNCTION_SEI
     90  case SEI::KNEE_FUNCTION_INFO:
     91    fprintf( g_hTrace, "=========== Knee Function Information SEI message ===========\n");
     92    break;
     93#endif
    8994#if Q0074_SEI_COLOR_MAPPING
    9095  case SEI::COLOR_MAPPING_INFO:
     
    123128  case SEI::BSP_HRD:
    124129    fprintf( g_hTrace, "=========== Bitstream parition HRD parameters SEI message ===========\n");
     130    break;
     131#endif
     132#if Q0078_ADD_LAYER_SETS
     133  case SEI::OUTPUT_LAYER_SET_NESTING:
     134    fprintf(g_hTrace, "=========== Output layer set nesting SEI message ===========\n");
     135    break;
     136  case SEI::VPS_REWRITING:
     137    fprintf(g_hTrace, "=========== VPS rewriting SEI message ===========\n");
    125138    break;
    126139#endif
     
    177190    xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei));
    178191    break;
     192#if P0050_KNEE_FUNCTION_SEI
     193  case SEI::KNEE_FUNCTION_INFO:
     194    xWriteSEIKneeFunctionInfo(*static_cast<const SEIKneeFunctionInfo*>(&sei));
     195    break;
     196#endif
    179197#if Q0074_SEI_COLOR_MAPPING
    180198  case SEI::COLOR_MAPPING_INFO:
     
    217235   case SEI::BSP_HRD:
    218236     xWriteSEIBspHrd(*static_cast<const SEIBspHrd*>(&sei), sps, nestingSei);
     237     break;
     238#endif
     239#if Q0078_ADD_LAYER_SETS
     240   case SEI::OUTPUT_LAYER_SET_NESTING:
     241     xWriteSEIOutputLayerSetNesting(bs, *static_cast<const SEIOutputLayerSetNesting*>(&sei), vps, sps);
     242     break;
     243   case SEI::VPS_REWRITING:
     244     xWriteSEIVPSRewriting(*static_cast<const SEIVPSRewriting*>(&sei));
     245     break;
     246#endif
     247#if Q0189_TMVP_CONSTRAINTS
     248   case SEI::TMVP_CONSTRAINTS:
     249     xWriteSEITMVPConstraints(*static_cast<const SEITMVPConstrains*>(&sei));
     250     break;
     251#endif
     252#if Q0247_FRAME_FIELD_INFO
     253   case SEI::FRAME_FIELD_INFO:
     254     xWriteSEIFrameFieldInfo(*static_cast<const SEIFrameFieldInfo*>(&sei));
    219255     break;
    220256#endif
     
    575611  xWriteByteAlign();
    576612}
    577 
     613#if P0050_KNEE_FUNCTION_SEI
     614Void SEIWriter::xWriteSEIKneeFunctionInfo(const SEIKneeFunctionInfo &sei)
     615{
     616  WRITE_UVLC( sei.m_kneeId, "knee_function_id" );
     617  WRITE_FLAG( sei.m_kneeCancelFlag, "knee_function_cancel_flag" );
     618  if ( !sei.m_kneeCancelFlag )
     619  {
     620    WRITE_FLAG( sei.m_kneePersistenceFlag, "knee_function_persistence_flag" );
     621    WRITE_FLAG( sei.m_kneeMappingFlag, "mapping_flag" );
     622    WRITE_CODE( (UInt)sei.m_kneeInputDrange , 32,  "input_d_range" );
     623    WRITE_CODE( (UInt)sei.m_kneeInputDispLuminance, 32,  "input_disp_luminance" );
     624    WRITE_CODE( (UInt)sei.m_kneeOutputDrange, 32,  "output_d_range" );
     625    WRITE_CODE( (UInt)sei.m_kneeOutputDispLuminance, 32,  "output_disp_luminance" );
     626    WRITE_UVLC( sei.m_kneeNumKneePointsMinus1, "num_knee_points_minus1" );
     627    for(Int i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ )
     628    {
     629      WRITE_CODE( (UInt)sei.m_kneeInputKneePoint[i], 10,"input_knee_point" );
     630      WRITE_CODE( (UInt)sei.m_kneeOutputKneePoint[i], 10, "output_knee_point" );
     631    }
     632  }
     633  xWriteByteAlign();
     634}
     635#endif
    578636#if Q0074_SEI_COLOR_MAPPING
    579637Void SEIWriter::xWriteSEIColorMappingInfo(const SEIColorMappingInfo& sei)
     
    815873#endif
    816874
     875#if Q0189_TMVP_CONSTRAINTS
     876Void SEIWriter::xWriteSEITMVPConstraints (const SEITMVPConstrains &sei)
     877{
     878  WRITE_UVLC( sei.prev_pics_not_used_flag ,    "prev_pics_not_used_flag"  );
     879  WRITE_UVLC( sei.no_intra_layer_col_pic_flag ,    "no_intra_layer_col_pic_flag"  );
     880  xWriteByteAlign();
     881}
     882#endif
     883
     884#if Q0247_FRAME_FIELD_INFO
     885Void SEIWriter::xWriteSEIFrameFieldInfo  (const SEIFrameFieldInfo &sei)
     886{
     887  WRITE_CODE( sei.m_ffinfo_picStruct , 4,             "ffinfo_pic_struct" );
     888  WRITE_CODE( sei.m_ffinfo_sourceScanType, 2,         "ffinfo_source_scan_type" );
     889  WRITE_FLAG( sei.m_ffinfo_duplicateFlag ? 1 : 0,     "ffinfo_duplicate_flag" );
     890  xWriteByteAlign();
     891}
     892#endif
     893
    817894#if O0164_MULTI_LAYER_HRD
    818895Void SEIWriter::xWriteSEIBspNesting(TComBitIf& bs, const SEIBspNesting &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei)
     
    893970    for (UInt i = 0; i <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; i++)
    894971    {
     972#if HRD_BPB
     973      UInt nl=0;
    895974      for (UInt j = 0; j < sei.m_vpsMaxLayers; j++)
    896975      {
    897976        if (sei.m_layerIdIncludedFlag[lsIdx][j])
    898977        {
     978          nl++;
     979        }
     980      }
     981      for (UInt j = 0; j < nl; j++)
     982      {
     983#else
     984      for (UInt j = 0; j < sei.m_vpsMaxLayers; j++)
     985      {
     986        if (sei.m_layerIdIncludedFlag[lsIdx][j])
     987        {
     988#endif
    899989          WRITE_FLAG( sei.m_seiLayerInBspFlag[lsIdx][i][j], "sei_layer_in_bsp_flag[lsIdx][i][j]" );
    900990        }
    901       }
     991#if !HRD_BPB
     992      }
     993#endif
    902994    }
    903995    WRITE_UVLC( sei.m_seiNumBspSchedCombinationsMinus1[lsIdx], "sei_num_bsp_sched_combinations_minus1[i]");
     
    9881080#endif
    9891081
     1082#if Q0078_ADD_LAYER_SETS
     1083
     1084Void SEIWriter::xWriteSEIOutputLayerSetNesting(TComBitIf& bs, const SEIOutputLayerSetNesting &sei, TComVPS *vps, TComSPS *sps)
     1085{
     1086  WRITE_FLAG(sei.m_olsFlag, "ols_flag");
     1087  WRITE_UVLC(sei.m_numOlsIndicesMinus1, "num_ols_indices_minus1");
     1088
     1089  for (Int i = 0; i <= sei.m_numOlsIndicesMinus1; i++)
     1090  {
     1091    WRITE_UVLC(sei.m_olsIdx[i], "ols_idx[i]");
     1092  }
     1093
     1094  while (m_pcBitIf->getNumberOfWrittenBits() % 8 != 0)
     1095  {
     1096    WRITE_FLAG(0, "ols_nesting_zero_bit");
     1097  }
     1098
     1099  // write nested SEI messages
     1100  for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++)
     1101  {
     1102    writeSEImessage(bs, *(*it), vps, sps);
     1103  }
     1104}
     1105
     1106Void SEIWriter::xWriteSEIVPSRewriting(const SEIVPSRewriting &sei)
     1107{
     1108  //sei.nalu->
     1109}
     1110
     1111#endif
     1112
    9901113#endif //SVC_EXTENSION
    9911114
  • trunk/source/Lib/TLibEncoder/SEIwrite.h

    r713 r815  
    7272  Void xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei);
    7373  Void xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei);
     74#if P0050_KNEE_FUNCTION_SEI
     75  Void xWriteSEIKneeFunctionInfo(const SEIKneeFunctionInfo &sei);
     76#endif
    7477#if Q0074_SEI_COLOR_MAPPING
    7578  Void xWriteSEIColorMappingInfo(const SEIColorMappingInfo& sei);
     
    9295  Void xWriteSEISubBitstreamProperty(const SEISubBitstreamProperty &sei);
    9396#endif
     97#if Q0189_TMVP_CONSTRAINTS
     98Void xWriteSEITMVPConstraints (const SEITMVPConstrains &sei);
     99#endif
     100#if Q0247_FRAME_FIELD_INFO
     101  Void xWriteSEIFrameFieldInfo  (const SEIFrameFieldInfo &sei);
     102#endif
    94103#if O0164_MULTI_LAYER_HRD
    95104  Void xWriteSEIBspNesting(TComBitIf& bs, const SEIBspNesting &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei);
     
    98107  Void xCodeHrdParameters( TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 );
    99108#endif
     109#if Q0078_ADD_LAYER_SETS
     110  Void xWriteSEIOutputLayerSetNesting(TComBitIf& bs, const SEIOutputLayerSetNesting &sei, TComVPS *vps, TComSPS *sps);
     111  Void xWriteSEIVPSRewriting(const SEIVPSRewriting &sei);
     112#endif
    100113#endif //SVC_EXTENSION
    101114};
  • trunk/source/Lib/TLibEncoder/TEnc3DAsymLUT.cpp

    r713 r815  
    276276  Int nStrideILRY = pRecPic->getStride();
    277277  Int nStrideILRC = pRecPic->getCStride();
    278   Int nWidth = m_pDsOrigPic->getWidth();   //should exclude the padding;
    279   Int nHeight= m_pDsOrigPic->getHeight();
    280278  xReset3DArray( m_pColorInfo , xGetYSize() , xGetUSize() , xGetVSize() );
    281279  xReset3DArray( m_pColorInfoC , xGetYSize() , xGetUSize() , xGetVSize() );
    282280
    283281  //alignment padding
    284   Pel *pU = pRecPic->getCbAddr();
    285   Pel *pV = pRecPic->getCrAddr();
    286   pU[(nWidth>>1)] = pU[(nWidth>>1)-1];
    287   pV[(nWidth>>1)] = pV[(nWidth>>1)-1];
    288   memcpy(pU-nStrideILRC, pU, ((nWidth>>1)+1)*sizeof(Pel));
    289   memcpy(pV-nStrideILRC, pV, ((nWidth>>1)+1)*sizeof(Pel));
    290   pU += nStrideILRC+ (nWidth>>1);
    291   pV += nStrideILRC+ (nWidth>>1);
    292 
    293   for( Int y = 1 ; y < (nHeight>>1) ; y ++ )
    294   {
    295     *pU = pU[-1];
    296     *pV = pV[-1];
    297     pU += nStrideILRC;
    298     pV += nStrideILRC;
    299   }
    300   memcpy(pU-(nWidth>>1), pU-(nWidth>>1)-nStrideILRC, ((nWidth>>1)+1)*sizeof(Pel));
    301   memcpy(pV-(nWidth>>1), pV-(nWidth>>1)-nStrideILRC, ((nWidth>>1)+1)*sizeof(Pel));
    302 
    303   for( Int i = 0 ; i < nHeight ; i++ )
    304   {
    305     Int posSrcY = i * nStrideSrcY;
    306     Int posIRLY = i * nStrideILRY;
    307     Int posSrcUV = ( i >> 1 ) * nStrideSrcC;
    308     Int posIRLUV = ( i >> 1 ) * nStrideILRC;
    309     for( Int j = 0 ; j < nWidth ; j++ , posSrcY++ , posIRLY++ , posSrcUV += !( j & 0x01 ) , posIRLUV += !( j & 0x01 ) )
     282  pRecPic->setBorderExtension( false );
     283  pRecPic->extendPicBorder();
     284
     285  TComSlice * pSlice = pCurPic->getSlice(pCurPic->getCurrSliceIdx());
     286  UInt refLayerId = pSlice->getVPS()->getRefLayerId(pSlice->getLayerId(), refLayerIdc);
     287  const Window &scalEL = pSlice->getSPS()->getScaledRefLayerWindowForLayer(refLayerId);
     288  TComPicYuv *pcRecPicBL = pSlice->getBaseColPic(refLayerIdc)->getPicYuvRec();
     289  // borders of down-sampled picture
     290  Int leftDS =  (scalEL.getWindowLeftOffset()*g_posScalingFactor[refLayerIdc][0]+(1<<15))>>16;
     291  Int rightDS = pcRecPicBL->getWidth() - 1 + (((scalEL.getWindowRightOffset())*g_posScalingFactor[refLayerIdc][0]+(1<<15))>>16);
     292  Int topDS = (((scalEL.getWindowTopOffset())*g_posScalingFactor[refLayerIdc][1]+(1<<15))>>16);
     293  Int bottomDS = pcRecPicBL->getHeight() - 1 + (((scalEL.getWindowBottomOffset())*g_posScalingFactor[refLayerIdc][1]+(1<<15))>>16);
     294  // overlapped region
     295  Int left = max( 0 , leftDS );
     296  Int right = min( pcRecPicBL->getWidth() - 1 , rightDS );
     297  Int top = max( 0 , topDS );
     298  Int bottom = min( pcRecPicBL->getHeight() - 1 , bottomDS );
     299  // since we do data collection only for overlapped region, the border extension is good enough
     300
     301  for( Int i = top ; i <= bottom ; i++ )
     302  {
     303    Int iDS = i-topDS;
     304    Int jDS = left-leftDS;
     305    Int posSrcY = iDS * nStrideSrcY + jDS;
     306    Int posIRLY = i * nStrideILRY + left;
     307    Int posSrcUV = ( iDS >> 1 ) * nStrideSrcC + (jDS>>1);
     308    Int posIRLUV = ( i >> 1 ) * nStrideILRC + (left>>1);
     309    for( Int j = left ; j <= right ; j++ , posSrcY++ , posIRLY++ , posSrcUV += !( j & 0x01 ) , posIRLUV += !( j & 0x01 ) )
    310310    {
    311311      Int Y = pSrcY[posSrcY];
  • trunk/source/Lib/TLibEncoder/TEncCavlc.cpp

    r713 r815  
    256256  WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag");
    257257#if P0166_MODIFIED_PPS_EXTENSION
    258   WRITE_FLAG( 1, "pps_extension_flag" );
    259   if( 1 ) //pps_extension_flag
     258  WRITE_FLAG( pcPPS->getExtensionFlag() ? 1 : 0, "pps_extension_flag" );
     259
     260  if( pcPPS->getExtensionFlag() )
    260261  {
    261262#if !POC_RESET_IDC
     
    638639  }
    639640
    640 #if SPS_EXTENSION
    641   WRITE_FLAG( 1, "sps_extension_flag" );
    642   if( 1 )   // if( sps_extension_flag )
     641#if SVC_EXTENSION
     642  WRITE_FLAG( pcSPS->getExtensionFlag() ? 1 : 0, "sps_extension_flag" );
     643
     644  if( pcSPS->getExtensionFlag() )
    643645  {
    644646#if O0142_CONDITIONAL_SPS_EXTENSION
     
    661663#endif
    662664}
    663 #if SPS_EXTENSION
     665
     666#if SVC_EXTENSION
    664667Void TEncCavlc::codeSPSExtension( TComSPS* pcSPS )
    665668{
     
    688691  }
    689692}
    690 #endif
     693#endif //SVC_EXTENSION
     694
    691695Void TEncCavlc::codeVPS( TComVPS* pcVPS )
    692696{
     
    703707  WRITE_CODE( pcVPS->getVPSId(),                    4,        "vps_video_parameter_set_id" );
    704708  WRITE_CODE( 3,                                    2,        "vps_reserved_three_2bits" );
    705 #if VPS_RENAME
     709#if SVC_EXTENSION
    706710  WRITE_CODE( pcVPS->getMaxLayers() - 1,            6,        "vps_max_layers_minus1" );           
    707711#else
     
    734738  }
    735739
    736 #if VPS_RENAME
     740#if SVC_EXTENSION
    737741  assert( pcVPS->getNumHrdParameters() <= MAX_VPS_LAYER_SETS_PLUS1 );
    738742  assert( pcVPS->getMaxLayerId() < MAX_VPS_LAYER_ID_PLUS1 );
     
    741745#endif
    742746  WRITE_CODE( pcVPS->getMaxLayerId(), 6,                       "vps_max_layer_id" );
     747#if Q0078_ADD_LAYER_SETS
     748  WRITE_UVLC(pcVPS->getVpsNumLayerSetsMinus1(),                "vps_num_layer_sets_minus1");
     749  for (UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx++)
     750#else
    743751  WRITE_UVLC( pcVPS->getNumLayerSets() - 1,                 "vps_num_layer_sets_minus1" );
    744   for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getNumLayerSets() - 1 ); opsIdx ++ )
     752  for (UInt opsIdx = 1; opsIdx <= (pcVPS->getNumLayerSets() - 1); opsIdx++)
     753#endif
    745754  {
    746755    // Operation point set
     
    798807    }
    799808  }
    800 #if VPS_EXTNS
     809#if SVC_EXTENSION
    801810  // When MaxLayersMinus1 is greater than 0, vps_extension_flag shall be equal to 1.
    802811  if( pcVPS->getMaxLayers() > 1 )
     
    832841
    833842#if SVC_EXTENSION
    834 #if VPS_EXTNS
    835843Void TEncCavlc::codeVPSExtension (TComVPS *vps)
    836844{
     
    846854#if !P0307_REMOVE_VPS_VUI_OFFSET
    847855#if O0109_MOVE_VPS_VUI_FLAG
    848 #if !VPS_VUI
    849   WRITE_FLAG( 0,                     "vps_vui_present_flag" );
    850   vps->setVpsVuiPresentFlag(false);
    851 #else
    852856  WRITE_FLAG( 1,                     "vps_vui_present_flag" );
    853857  vps->setVpsVuiPresentFlag(true);
    854 #endif
    855858  if ( vps->getVpsVuiPresentFlag() )
    856859  {
     
    879882  }
    880883
    881 #if SPL_FLG_CHK
     884  // The value of dimBitOffset[ NumScalabilityTypes ] is set equal to 6.
    882885  if(vps->getSplittingFlag())
    883886  {
     
    889892    assert(splDimSum<=6);
    890893  }
    891 #endif
    892894
    893895  WRITE_FLAG( vps->getNuhLayerIdPresentFlag(),         "vps_nuh_layer_id_present_flag" );
     
    957959    }
    958960#endif
    959 #if N0120_MAX_TID_REF_PRESENT_FLAG
    960961   WRITE_FLAG( vps->getMaxTidRefPresentFlag(), "max_tid_ref_present_flag");
    961962   if (vps->getMaxTidRefPresentFlag())
     
    976977     }
    977978   }
    978 #else
    979   for( i = 0; i < vps->getMaxLayers() - 1; i++)
    980   {
    981 #if O0225_MAX_TID_FOR_REF_LAYERS
    982        for( j = i+1; j <= vps->getMaxLayers() - 1; j++)
    983        {
    984          if(vps->getDirectDependencyFlag(j, i))
    985          {
    986            WRITE_CODE(vps->getMaxTidIlRefPicsPlus1(i,j), 3, "max_tid_il_ref_pics_plus1[i][j]" );
    987          }
    988        }
    989 #else
    990     WRITE_CODE(vps->getMaxTidIlRefPicsPlus1(i), 3, "max_tid_il_ref_pics_plus1[i]" );
    991 #endif
    992   }
    993 #endif
    994 #if ILP_SSH_SIG
    995     WRITE_FLAG( vps->getIlpSshSignalingEnabledFlag(), "all_ref_layers_active_flag" );
    996 #endif
     979   WRITE_FLAG( vps->getIlpSshSignalingEnabledFlag(), "all_ref_layers_active_flag" );
    997980#if VPS_EXTN_PROFILE_INFO
    998981  // Profile-tier-level signalling
     
    1016999#endif
    10171000
     1001#if Q0078_ADD_LAYER_SETS
     1002  if (vps->getNumIndependentLayers() > 1)
     1003  {
     1004    WRITE_UVLC( vps->getNumAddLayerSets(), "num_add_layer_sets" );
     1005    for (i = 0; i < vps->getNumAddLayerSets(); i++)
     1006    {
     1007      for (j = 1; j < vps->getNumIndependentLayers(); j++)
     1008      {
     1009        int len = 1;
     1010        while ((1 << len) < (vps->getNumLayersInTreePartition(j) + 1))
     1011        {
     1012          len++;
     1013        }
     1014        WRITE_CODE(vps->getHighestLayerIdxPlus1(i, j), len, "highest_layer_idx_plus1[i][j]");
     1015      }
     1016    }
     1017  }
     1018#endif
     1019
    10181020#if !VPS_EXTN_UEV_CODING
    10191021  Int numOutputLayerSets = vps->getNumOutputLayerSets() ;
     
    10271029  Int numAddOutputLayerSets = numOutputLayerSets - (Int)vps->getNumLayerSets();
    10281030
    1029   // The value of num_add_output_layer_sets shall be in the range of 0 to 1023, inclusive.
     1031  // The value of num_add_olss shall be in the range of 0 to 1023, inclusive.
    10301032  assert( numAddOutputLayerSets >= 0 && numAddOutputLayerSets < 1024 );
    10311033
     
    10331035  if( vps->getNumLayerSets() > 1 )
    10341036  {
    1035     WRITE_UVLC( numAddOutputLayerSets, "num_add_output_layer_sets" );
    1036     WRITE_CODE( vps->getDefaultTargetOutputLayerIdc(), 2, "default_target_output_layer_idc" );
     1037    WRITE_UVLC( numAddOutputLayerSets, "num_add_olss" );
     1038    WRITE_CODE( vps->getDefaultTargetOutputLayerIdc(), 2, "default_output_layer_idc" );
    10371039  }
    10381040#else
     
    10651067        numBits++;
    10661068      }
    1067       WRITE_CODE( vps->getOutputLayerSetIdx(i) - 1, numBits, "output_layer_set_idx_minus1");
     1069      WRITE_CODE( vps->getOutputLayerSetIdx(i) - 1, numBits, "layer_set_idx_for_ols_minus1");
    10681070#if P0295_DEFAULT_OUT_LAYER_IDC
    10691071    }
     1072#if Q0078_ADD_LAYER_SETS
     1073    if ( i > vps->getVpsNumLayerSetsMinus1() || vps->getDefaultTargetOutputLayerIdc() >= 2 ) //Instead of == 2, >= 2 is used to follow the agreement that value 3 should be interpreted as 2
     1074#else
    10701075    if ( i > (vps->getNumLayerSets() - 1) || vps->getDefaultTargetOutputLayerIdc() >= 2 ) //Instead of == 2, >= 2 is used to follow the agreement that value 3 should be interpreted as 2
     1076#endif
    10711077    {
    10721078#endif
     
    12171223  WRITE_FLAG(vps->getPhaseAlignFlag(), "cross_layer_phase_alignment_flag" );
    12181224#endif
    1219 #if N0147_IRAP_ALIGN_FLAG && !IRAP_ALIGN_FLAG_IN_VPS_VUI
     1225#if !IRAP_ALIGN_FLAG_IN_VPS_VUI
    12201226  WRITE_FLAG(vps->getCrossLayerIrapAlignFlag(), "cross_layer_irap_aligned_flag");
    12211227#endif
     
    12861292
    12871293#if !O0109_MOVE_VPS_VUI_FLAG
    1288 #if !VPS_VUI
    1289   WRITE_FLAG( 0,                     "vps_vui_present_flag" );
    1290 #else
    12911294  WRITE_FLAG( 1,                     "vps_vui_present_flag" );
    12921295  if(1)   // Should be conditioned on the value of vps_vui_present_flag
     
    13031306    codeVPSVUI(vps); 
    13041307  }
    1305 #endif
    13061308#else
    13071309#if P0307_REMOVE_VPS_VUI_OFFSET
     
    13261328#endif // 0109_MOVE_VPS_FLAG
    13271329}
    1328 #endif
     1330
    13291331#if REPN_FORMAT_IN_VPS
    13301332Void  TEncCavlc::codeRepFormat( RepFormat *repFormat )
     
    13711373{
    13721374#if DPB_PARAMS_MAXTLAYERS
     1375#if BITRATE_PICRATE_SIGNALLING
     1376    Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumLayerSets()];
     1377    for(Int i = 0; i < vps->getNumLayerSets(); i++)
     1378#else
    13731379    Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumOutputLayerSets()];
    13741380    for(Int i = 1; i < vps->getNumOutputLayerSets(); i++)
     1381#endif
    13751382    {
    13761383        UInt maxSLMinus1 = 0;
     
    13801387        Int optLsIdx = i;
    13811388#endif
     1389#if BITRATE_PICRATE_SIGNALLING
     1390        optLsIdx = i;
     1391#endif
    13821392        for(Int k = 0; k < vps->getNumLayersInIdList(optLsIdx); k++ ) {
    13831393            Int  lId = vps->getLayerSetLayerIdList(optLsIdx, k);
     
    13851395        }
    13861396        MaxSubLayersInLayerSetMinus1[ i ] = maxSLMinus1;
    1387     }
    1388 #endif
     1397#if BITRATE_PICRATE_SIGNALLING
     1398        vps->setMaxSLayersInLayerSetMinus1(i,MaxSubLayersInLayerSetMinus1[ i ]);
     1399#endif
     1400    }
     1401#endif
     1402   
    13891403   
    13901404  for(Int i = 1; i < vps->getNumOutputLayerSets(); i++)
     
    13951409    WRITE_FLAG( vps->getSubLayerFlagInfoPresentFlag( i ), "sub_layer_flag_info_present_flag[i]");
    13961410#if DPB_PARAMS_MAXTLAYERS
     1411#if BITRATE_PICRATE_SIGNALLING
     1412    for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ vps->getOutputLayerSetIdx( i ) ]; j++)
     1413#else
    13971414    for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ i ]; j++)
     1415#endif
    13981416#else
    13991417    for(Int j = 0; j < vps->getMaxTLayers(); j++)
     
    14071425      {
    14081426#if CHANGE_NUMSUBDPB_IDX
     1427#if RESOLUTION_BASED_DPB
    14091428        for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++)
     1429#else
     1430        for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++)
     1431#endif
    14101432#else
    14111433        for(Int k = 0; k < vps->getNumSubDpbs(i); k++)
     
    14301452}
    14311453#endif
    1432 #if VPS_VUI
     1454
    14331455Void TEncCavlc::codeVPSVUI (TComVPS *vps)
    14341456{
     
    14511473  }
    14521474#endif
    1453 #if VPS_VUI_BITRATE_PICRATE
    14541475  WRITE_FLAG( vps->getBitRatePresentVpsFlag(),        "bit_rate_present_vps_flag" );
    14551476  WRITE_FLAG( vps->getPicRatePresentVpsFlag(),        "pic_rate_present_vps_flag" );
     
    14571478  if( vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag() )
    14581479  {
     1480#if Q0078_ADD_LAYER_SETS
     1481    for( i = 0; i <= vps->getVpsNumLayerSetsMinus1(); i++ )
     1482#else
    14591483    for( i = 0; i < vps->getNumLayerSets(); i++ )
    1460     {
     1484#endif
     1485    {
     1486#if BITRATE_PICRATE_SIGNALLING
     1487      for( j = 0; j <= vps->getMaxSLayersInLayerSetMinus1(i); j++ )
     1488#else
    14611489      for( j = 0; j < vps->getMaxTLayers(); j++ )
     1490#endif
    14621491      {
    14631492        if( vps->getBitRatePresentVpsFlag() )
     
    14821511    }
    14831512  }
    1484 #endif
    14851513#if VPS_VUI_VIDEO_SIGNAL_MOVE
    14861514  WRITE_FLAG( vps->getVideoSigPresentVpsFlag(), "video_signal_info_idx_present_flag" );
     
    15191547    }
    15201548#endif
    1521 #if TILE_BOUNDARY_ALIGNED_FLAG
     1549
    15221550    for(i = 1; i < vps->getMaxLayers(); i++)
    15231551    {
     
    15341562      }
    15351563    } 
    1536 #endif
    15371564#if VPS_VUI_TILES_NOT_IN_USE__FLAG
    15381565  }
     
    16271654        codeHrdParameters(vps->getBspHrd(i), i==0 ? 1 : vps->getBspCprmsPresentFlag(i), vps->getMaxTLayers()-1);
    16281655      }
     1656#if Q0078_ADD_LAYER_SETS
     1657      for( UInt h = 1; h <= vps->getVpsNumLayerSetsMinus1(); h++ )
     1658#else
    16291659      for( UInt h = 1; h <= (vps->getNumLayerSets()-1); h++ )
     1660#endif
    16301661      {
    16311662        WRITE_UVLC( vps->getNumBitstreamPartitions(h), "num_bitstream_partitions[i]");
     
    16421673        if (vps->getNumBitstreamPartitions(h))
    16431674        {
     1675#if Q0182_MULTI_LAYER_HRD_UPDATE
     1676          WRITE_UVLC(vps->getNumBspSchedCombinations(h) - 1, "num_bsp_sched_combinations_minus1[h]");
     1677#else
    16441678          WRITE_UVLC( vps->getNumBspSchedCombinations(h), "num_bsp_sched_combinations[h]");
     1679#endif
    16451680          for( i = 0; i < vps->getNumBspSchedCombinations(h); i++ )
    16461681          {
     
    16731708#endif
    16741709}
    1675 #endif
    16761710#endif //SVC_EXTENSION
    16771711
     
    18111845      }
    18121846#else
     1847#if POC_RESET_IDC_ENCODER
     1848      Int picOrderCntLSB;
     1849      if( pcSlice->getPocResetIdc() == 2 )  // i.e. the LSB is reset
     1850      {
     1851        picOrderCntLSB = pcSlice->getPicOrderCntLsb();  // This will be the LSB value w.r.t to the previous POC reset period.
     1852      }
     1853      else
     1854      {
     1855        picOrderCntLSB = (pcSlice->getPOC() + (1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1);
     1856      }
     1857#else
    18131858      Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1);
     1859#endif
    18141860#endif
    18151861      WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb");
     
    19401986
    19411987#if SVC_EXTENSION
    1942 #if ILP_SSH_SIG
    1943 #if ILP_SSH_SIG_FIX
    19441988    if((pcSlice->getLayerId() > 0) && !(pcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (pcSlice->getNumILRRefIdx() > 0) )
    1945 #else
    1946     if((pcSlice->getLayerId() > 0) && pcSlice->getVPS()->getIlpSshSignalingEnabledFlag() && (pcSlice->getNumILRRefIdx() > 0) )
    1947 #endif
    1948 #else
    1949     if((pcSlice->getLayerId() > 0)  &&  (pcSlice->getNumILRRefIdx() > 0) )
    1950 #endif
    19511989    {
    19521990      WRITE_FLAG(pcSlice->getInterLayerPredEnabledFlag(),"inter_layer_pred_enabled_flag");
     
    19642002            WRITE_CODE(pcSlice->getActiveNumILRRefIdx() - 1, numBits,"num_inter_layer_ref_pics_minus1");
    19652003          }       
    1966 #if ILP_NUM_REF_CHK
     2004
    19672005          if( pcSlice->getNumILRRefIdx() != pcSlice->getActiveNumILRRefIdx() )
    19682006          {
    1969 #endif
    1970           for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
    1971           {
    1972             WRITE_CODE(pcSlice->getInterLayerPredLayerIdc(i),numBits,"inter_layer_pred_layer_idc[i]");   
     2007            for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
     2008            {
     2009              WRITE_CODE(pcSlice->getInterLayerPredLayerIdc(i),numBits,"inter_layer_pred_layer_idc[i]");   
     2010            }
    19732011          }
    1974 #if ILP_NUM_REF_CHK
    1975           }
    1976 #endif
    19772012        }
    19782013      }
     
    22942329{
    22952330  Int tmpBitsBeforeWriting = getNumberOfWrittenBits();
     2331  Int maxPocLsb = 1 << slice->getSPS()->getBitsForPOC();
    22962332  if(slice->getPPS()->getSliceHeaderExtensionPresentFlag())
    22972333  {
     
    23362372    {
    23372373      UInt lengthVal = 1;
    2338       UInt tempVal = slice->getPocMsbVal() + 1;
     2374      UInt tempVal = (slice->getPocMsbVal() / maxPocLsb) + 1;
    23392375      assert ( tempVal );
    23402376      while( 1 != tempVal )
     
    23732409    if( slice->getPocMsbValPresentFlag() )
    23742410    {
    2375       WRITE_UVLC( slice->getPocMsbVal(),                                      "poc_msb_val" );
     2411      assert( slice->getPocMsbVal() % maxPocLsb == 0 );
     2412      WRITE_UVLC( slice->getPocMsbVal() / maxPocLsb,                                      "poc_msb_val" );
    23762413    }
    23772414    for (Int i = 0; i < shExtnAdditionalBits; i++)
    23782415    {
     2416#if Q0146_SSH_EXT_DATA_BIT
     2417      WRITE_FLAG( 1, "slice_segment_header_extension_data_bit");
     2418#else
    23792419      WRITE_FLAG( 1, "slice_segment_header_extension_reserved_bit");
     2420#endif
    23802421    }
    23812422  }
  • trunk/source/Lib/TLibEncoder/TEncCavlc.h

    r713 r815  
    159159  Void codeDFSvlc       ( Int   iCode, const Char *pSymbolName );
    160160
    161 #if SPS_EXTENSION
    162   Void codeSPSExtension         ( TComSPS* pcSPS );
    163 #if VPS_EXTNS
    164   Void  codeVPSExtension        ( TComVPS* pcVPS );
    165 #endif
    166 #if VPS_VUI
    167   Void codeVPSVUI               (TComVPS *vps);
    168 #endif
     161#if SVC_EXTENSION
     162  Void codeSPSExtension        ( TComSPS* pcSPS );
     163  Void codeVPSExtension        ( TComVPS* pcVPS );
     164  Void codeVPSVUI              ( TComVPS *vps   );
    169165#if REPN_FORMAT_IN_VPS
    170   Void  codeRepFormat           ( RepFormat *repFormat );
     166  Void  codeRepFormat          ( RepFormat *repFormat );
    171167#endif
    172168#if VPS_DPB_SIZE_TABLE
    173   Void  codeVpsDpbSizeTable      (TComVPS *vps);
     169  Void  codeVpsDpbSizeTable    (TComVPS *vps);
    174170#endif
    175171#if Q0048_CGS_3D_ASYMLUT
  • trunk/source/Lib/TLibEncoder/TEncCfg.h

    r713 r815  
    248248  Int*      m_codedPivotValue;
    249249  Int*      m_targetPivotValue;
     250#if P0050_KNEE_FUNCTION_SEI
     251  Bool      m_kneeSEIEnabled;
     252  Int       m_kneeSEIId;
     253  Bool      m_kneeSEICancelFlag;
     254  Bool      m_kneeSEIPersistenceFlag;
     255  Bool      m_kneeSEIMappingFlag;
     256  Int       m_kneeSEIInputDrange;
     257  Int       m_kneeSEIInputDispLuminance;
     258  Int       m_kneeSEIOutputDrange;
     259  Int       m_kneeSEIOutputDispLuminance;
     260  Int       m_kneeSEINumKneePointsMinus1;
     261  Int*      m_kneeSEIInputKneePoint;
     262  Int*      m_kneeSEIOutputKneePoint;
     263#endif
    250264#if Q0074_SEI_COLOR_MAPPING
    251265  Char*     m_seiColorMappingFile;
     
    262276  Int       m_SOPDescriptionSEIEnabled;
    263277  Int       m_scalableNestingSEIEnabled;
     278#if Q0189_TMVP_CONSTRAINTS
     279  Int       m_TMVPConstraintsSEIEnabled;
     280#endif
    264281  //====== Weighted Prediction ========
    265282  Bool      m_useWeightedPred;       //< Use of Weighting Prediction (P_SLICE)
     
    348365  Bool      m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1];
    349366#endif
    350 #if N0120_MAX_TID_REF_CFG
    351367  Int       m_maxTidIlRefPicsPlus1;
    352 #endif
    353368#if AUXILIARY_PICTURES
    354369  ChromaFormat m_chromaFormatIDC;
     
    670685  Void  setTMISEIExtendedWhiteLevelLumaCodeValue(Int b)      {  m_extendedWhiteLevelLumaCodeValue =b;  }
    671686  Int   getTMISEIExtendedWhiteLevelLumaCodeValue()           {  return m_extendedWhiteLevelLumaCodeValue;  }
     687#if P0050_KNEE_FUNCTION_SEI
     688  Void  setKneeSEIEnabled(Int b)                             { m_kneeSEIEnabled = b; }
     689  Bool  getKneeSEIEnabled()                                  { return m_kneeSEIEnabled; }
     690  Void  setKneeSEIId(Int b)                                  { m_kneeSEIId = b; }
     691  Int   getKneeSEIId()                                       { return m_kneeSEIId; }
     692  Void  setKneeSEICancelFlag(Bool b)                         { m_kneeSEICancelFlag=b; }
     693  Bool  getKneeSEICancelFlag()                               { return m_kneeSEICancelFlag; }
     694  Void  setKneeSEIPersistenceFlag(Bool b)                    { m_kneeSEIPersistenceFlag = b; }
     695  Bool  getKneeSEIPersistenceFlag()                          { return m_kneeSEIPersistenceFlag; }
     696  Void  setKneeSEIMappingFlag(Bool b)                        { m_kneeSEIMappingFlag = b; }
     697  Bool  getKneeSEIMappingFlag()                              { return m_kneeSEIMappingFlag; }
     698  Void  setKneeSEIInputDrange(Int b)                         { m_kneeSEIInputDrange = b; }
     699  Int   getKneeSEIInputDrange()                              { return m_kneeSEIInputDrange; }
     700  Void  setKneeSEIInputDispLuminance(Int b)                  { m_kneeSEIInputDispLuminance = b; }
     701  Int   getKneeSEIInputDispLuminance()                       { return m_kneeSEIInputDispLuminance; }
     702  Void  setKneeSEIOutputDrange(Int b)                        { m_kneeSEIOutputDrange = b; }
     703  Int   getKneeSEIOutputDrange()                             { return m_kneeSEIOutputDrange; }
     704  Void  setKneeSEIOutputDispLuminance(Int b)                 { m_kneeSEIOutputDispLuminance = b; }
     705  Int   getKneeSEIOutputDispLuminance()                      { return m_kneeSEIOutputDispLuminance; }
     706  Void  setKneeSEINumKneePointsMinus1(Int b)                 { m_kneeSEINumKneePointsMinus1 = b; }
     707  Int   getKneeSEINumKneePointsMinus1()                      { return m_kneeSEINumKneePointsMinus1; }
     708  Void  setKneeSEIInputKneePoint(Int *p)                     { m_kneeSEIInputKneePoint = p; }
     709  Int*  getKneeSEIInputKneePoint()                           { return m_kneeSEIInputKneePoint; }
     710  Void  setKneeSEIOutputKneePoint(Int *p)                    { m_kneeSEIOutputKneePoint = p; }
     711  Int*  getKneeSEIOutputKneePoint()                          { return m_kneeSEIOutputKneePoint; }
     712#endif
    672713#if Q0074_SEI_COLOR_MAPPING
    673714  Void  setColorMappingInfoSEIFile( Char* nameFile )         {  m_seiColorMappingFile = nameFile; }
     
    695736  Int   getSOPDescriptionSEIEnabled()                     { return m_SOPDescriptionSEIEnabled; }
    696737  Void  setScalableNestingSEIEnabled(Int b)                { m_scalableNestingSEIEnabled = b; }
     738#if Q0189_TMVP_CONSTRAINTS
     739  void setTMVPConstraintsSEIEnabled(Int b)                { m_TMVPConstraintsSEIEnabled = b; }
     740#endif
    697741  Int   getScalableNestingSEIEnabled()                     { return m_scalableNestingSEIEnabled; }
     742#if Q0189_TMVP_CONSTRAINTS
     743  Int   getTMVPConstraintsSEIEnabled()                {  return m_TMVPConstraintsSEIEnabled; }
     744#endif
    698745  Void      setUseWP               ( Bool b )    { m_useWeightedPred   = b;    }
    699746  Void      setWPBiPred            ( Bool b )    { m_useWeightedBiPred = b;    }
     
    877924  Void      setMotionPredEnabledFlag        (Int i,Bool flag)               { m_motionPredEnabledFlag[i] = flag;  }
    878925#endif
    879 #if N0120_MAX_TID_REF_CFG
    880926  Int       getMaxTidIlRefPicsPlus1         ()                              { return m_maxTidIlRefPicsPlus1; }
    881927  Void      setMaxTidIlRefPicsPlus1         (Int num)                       { m_maxTidIlRefPicsPlus1 = num;  }
    882 #endif
    883928#if LAYERS_NOT_PRESENT_SEI
    884929  Void  setLayersNotPresentSEIEnabled(Int b)             { m_layersNotPresentSEIEnabled = b; }
  • trunk/source/Lib/TLibEncoder/TEncCu.cpp

    r595 r815  
    696696#if (ENCODER_FAST_MODE)
    697697        if( rpcBestCU->getSlice()->getSliceType() == I_SLICE ||
     698          rpcBestCU->getPredictionMode(0) == MODE_NONE ||  // if there is no valid inter prediction
    698699          !testInter ||
    699700          rpcBestCU->getCbf( 0, TEXT_LUMA     ) != 0   ||
     
    701702          rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0     ) // avoid very complex intra if it is unlikely
    702703#else
    703           if( rpcBestCU->getSlice()->getSliceType() == I_SLICE ||
    704             rpcBestCU->getCbf( 0, TEXT_LUMA     ) != 0   ||
    705             rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) != 0   ||
    706             rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0     ) // avoid very complex intra if it is unlikely
    707 #endif
     704        if( rpcBestCU->getSlice()->getSliceType() == I_SLICE ||
     705          rpcBestCU->getCbf( 0, TEXT_LUMA     ) != 0   ||
     706          rpcBestCU->getCbf( 0, TEXT_CHROMA_U ) != 0   ||
     707          rpcBestCU->getCbf( 0, TEXT_CHROMA_V ) != 0     ) // avoid very complex intra if it is unlikely
     708#endif
     709        {
     710          xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
     711          rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
     712          if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth )
    708713          {
    709             xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
    710           rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    711             if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth )
     714            if( rpcTempCU->getWidth(0) > ( 1 << rpcTempCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) )
    712715            {
    713               if( rpcTempCU->getWidth(0) > ( 1 << rpcTempCU->getSlice()->getSPS()->getQuadtreeTULog2MinSize() ) )
    714               {
    715                 xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN   );
     716              xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_NxN   );
    716717              rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
    717               }
    718718            }
    719719          }
     720        }
    720721
    721722        // test PCM
     
    734735#if (ENCODER_FAST_MODE)
    735736#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    736       if(pcPic->getLayerId() > 0 && !m_disableILP)
    737 #else
    738       if(pcPic->getLayerId() > 0)
    739 #endif
    740       {
    741         for(Int refLayer = 0; refLayer < pcSlice->getActiveNumILRRefIdx(); refLayer++)
    742         { 
    743            xCheckRDCostILRUni( rpcBestCU, rpcTempCU, pcSlice->getInterLayerPredLayerIdc(refLayer));
    744            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
     737        if(pcPic->getLayerId() > 0 && !m_disableILP)
     738#else
     739        if(pcPic->getLayerId() > 0)
     740#endif
     741        {
     742          for(Int refLayer = 0; refLayer < pcSlice->getActiveNumILRRefIdx(); refLayer++)
     743          { 
     744            xCheckRDCostILRUni( rpcBestCU, rpcTempCU, pcSlice->getVPS()->getRefLayerId( pcSlice->getLayerId(), pcSlice->getInterLayerPredLayerIdc(refLayer) ) );
     745            rpcTempCU->initEstData( uiDepth, iQP, bIsLosslessMode );
     746          }
    745747        }
    746       }
    747748#endif
    748749
     
    821822
    822823  if ( m_pcEncCfg->getCUTransquantBypassFlagForceValue() )
    823     {
     824  {
    824825    iMaxQP = iMinQP; // If all blocks are forced into using transquant bypass, do not loop here.
    825     }
     826  }
    826827
    827828  for (Int iQP=iMinQP; iQP<=iMaxQP; iQP++)
     
    14761477  rpcTempCU->setPredModeSubParts  ( MODE_INTER, 0, uhDepth );
    14771478 
     1479#if SVC_EXTENSION
     1480#if AMP_MRG
     1481  rpcTempCU->setMergeAMP (true);
     1482  Bool ret = m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], false, bUseMRG );
     1483#else 
     1484  Bool ret = m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] );
     1485#endif
     1486
     1487  if( !ret )
     1488  {
     1489    return;
     1490  }
     1491#else
    14781492#if AMP_MRG
    14791493  rpcTempCU->setMergeAMP (true);
     
    14811495#else 
    14821496  m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] );
     1497#endif
    14831498#endif
    14841499
  • trunk/source/Lib/TLibEncoder/TEncGOP.cpp

    r713 r815  
    9292  m_bRefreshPending     = 0;
    9393  m_pocCRA            = 0;
     94#if POC_RESET_IDC_ENCODER
     95  m_pocCraWithoutReset = 0;
     96  m_associatedIrapPocBeforeReset = 0;
     97#endif
    9498  m_numLongTermRefPicSPS = 0;
    9599  ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps));
     
    103107  m_associatedIRAPPOC  = 0;
    104108#endif
    105 #if SVC_UPSAMPLING
     109#if SVC_EXTENSION
    106110  m_pcPredSearch        = NULL;
    107 #endif
    108111#if Q0048_CGS_3D_ASYMLUT
    109112  m_temp = NULL;
    110113  m_pColorMappedPic = NULL;
    111114#endif
     115#if POC_RESET_IDC_ENCODER
     116  m_lastPocPeriodId = -1;
     117#endif
     118#endif //SVC_EXTENSION
    112119  return;
    113120}
     
    173180#if SVC_EXTENSION
    174181  m_ppcTEncTop           = pcTEncTop->getLayerEnc();
    175 #endif
    176 #if SVC_UPSAMPLING
    177182  m_pcPredSearch         = pcTEncTop->getPredSearch();                       ///< encoder search class
    178 #endif
    179183#if Q0048_CGS_3D_ASYMLUT
    180184  if( pcTEncTop->getLayerId() )
     
    185189    {
    186190      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
     191      m_pColorMappedPic->create( m_ppcTEncTop[0]->getSourceWidth(), m_ppcTEncTop[0]->getSourceHeight(), m_ppcTEncTop[0]->getChromaFormatIDC(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL );
     192    }
     193  }
     194#endif
     195#endif //SVC_EXTENSION
    191196}
    192197
     
    327332}
    328333
     334#if P0050_KNEE_FUNCTION_SEI
     335SEIKneeFunctionInfo* TEncGOP::xCreateSEIKneeFunctionInfo()
     336{
     337  SEIKneeFunctionInfo *seiKneeFunctionInfo = new SEIKneeFunctionInfo();
     338  seiKneeFunctionInfo->m_kneeId = m_pcCfg->getKneeSEIId();
     339  seiKneeFunctionInfo->m_kneeCancelFlag = m_pcCfg->getKneeSEICancelFlag();
     340  if ( !seiKneeFunctionInfo->m_kneeCancelFlag )
     341  {
     342    seiKneeFunctionInfo->m_kneePersistenceFlag = m_pcCfg->getKneeSEIPersistenceFlag();
     343    seiKneeFunctionInfo->m_kneeMappingFlag = m_pcCfg->getKneeSEIMappingFlag();
     344    seiKneeFunctionInfo->m_kneeInputDrange = m_pcCfg->getKneeSEIInputDrange();
     345    seiKneeFunctionInfo->m_kneeInputDispLuminance = m_pcCfg->getKneeSEIInputDispLuminance();
     346    seiKneeFunctionInfo->m_kneeOutputDrange = m_pcCfg->getKneeSEIOutputDrange();
     347    seiKneeFunctionInfo->m_kneeOutputDispLuminance = m_pcCfg->getKneeSEIOutputDispLuminance();
     348
     349    seiKneeFunctionInfo->m_kneeNumKneePointsMinus1 = m_pcCfg->getKneeSEINumKneePointsMinus1();
     350    Int* piInputKneePoint  = m_pcCfg->getKneeSEIInputKneePoint();
     351    Int* piOutputKneePoint = m_pcCfg->getKneeSEIOutputKneePoint();
     352    if(piInputKneePoint&&piOutputKneePoint)
     353    {
     354      seiKneeFunctionInfo->m_kneeInputKneePoint.resize(seiKneeFunctionInfo->m_kneeNumKneePointsMinus1+1);
     355      seiKneeFunctionInfo->m_kneeOutputKneePoint.resize(seiKneeFunctionInfo->m_kneeNumKneePointsMinus1+1);
     356      for(Int i=0; i<=seiKneeFunctionInfo->m_kneeNumKneePointsMinus1; i++)
     357      {
     358        seiKneeFunctionInfo->m_kneeInputKneePoint[i] = piInputKneePoint[i];
     359        seiKneeFunctionInfo->m_kneeOutputKneePoint[i] = piOutputKneePoint[i];
     360       }
     361    }
     362  }
     363  return seiKneeFunctionInfo;
     364}
     365#endif
     366
    329367#if Q0074_SEI_COLOR_MAPPING
    330368SEIColorMappingInfo*  TEncGOP::xCreateSEIColorMappingInfo( Char* file )
     
    477515    delete sei;
    478516  }
     517#if P0050_KNEE_FUNCTION_SEI
     518  if(m_pcCfg->getKneeSEIEnabled())
     519  {
     520    SEIKneeFunctionInfo *sei = xCreateSEIKneeFunctionInfo();
     521
     522    nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
     523    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     524#if O0164_MULTI_LAYER_HRD
     525    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
     526#else
     527    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     528#endif
     529    writeRBSPTrailingBits(nalu.m_Bitstream);
     530    accessUnit.push_back(new NALUnitEBSP(nalu));
     531    delete sei;
     532  }
     533#endif
    479534#if Q0074_SEI_COLOR_MAPPING
    480535  if(m_pcCfg->getColorMappingInfoSEIFile())
     
    554609  TEncSbac* pcSbacCoders = NULL;
    555610  TComOutputBitstream* pcSubstreamsOut = NULL;
     611#if Q0108_TSA_STSA
     612  Int flagTSTA = 0;
     613#endif
    556614
    557615  xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut, isField );
     
    855913    }
    856914#endif
     915#if POC_RESET_IDC_ENCODER
     916    pcSlice->setPocValueBeforeReset( pocCurr );
     917    // Check if the current picture is to be assigned as a reset picture
     918    determinePocResetIdc(pocCurr, pcSlice);
     919
     920    // If reset, do the following steps:
     921    if( pcSlice->getPocResetIdc() )
     922    {
     923      updatePocValuesOfPics(pocCurr, pcSlice);
     924    }
     925    else
     926    {
     927      // Check the base layer picture is IDR. If so, just set current POC equal to 0 (alignment of POC)
     928      if( ( m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == 2) && ( pocCurr % m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshInterval() == 0 ) )       
     929      {
     930        m_pcEncTop->setPocAdjustmentValue( pocCurr );
     931      }
     932      // else
     933      {
     934        // Just subtract POC by the current cumulative POC delta
     935        pcSlice->setPOC( pocCurr - m_pcEncTop->getPocAdjustmentValue() );
     936      }
     937
     938      Int maxPocLsb = 1 << pcSlice->getSPS()->getBitsForPOC();
     939      pcSlice->setPocMsbVal( pcSlice->getPOC() - ( pcSlice->getPOC() & (maxPocLsb-1) ) );
     940    }
     941    // Update the POC of current picture, pictures in the DPB, including references inside the reference pictures
     942
     943#endif
     944
    857945#if O0149_CROSS_LAYER_BLA_FLAG
    858946    if( m_layerId == 0 && (getNalUnitType(pocCurr, m_iLastIDR, isField) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR, isField) == NAL_UNIT_CODED_SLICE_IDR_N_LP) )
     
    10121100    if (m_layerId > 0)
    10131101    {
    1014     Int interLayerPredLayerIdcTmp[MAX_VPS_LAYER_ID_PLUS1];
    1015     Int activeNumILRRefIdxTmp = 0;
     1102      Int interLayerPredLayerIdcTmp[MAX_VPS_LAYER_ID_PLUS1];
     1103      Int activeNumILRRefIdxTmp = 0;
    10161104
    10171105      for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
    10181106      {
    10191107        UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i);
     1108        UInt refLayerId = pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc);
    10201109#if VPS_EXTN_DIRECT_REF_LAYERS
    10211110        TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(refLayerIdc)->getListPic();
     
    10411130
    10421131#if O0098_SCALED_REF_LAYER_ID
    1043         const Window &scalEL = m_pcEncTop->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc));
     1132        const Window &scalEL = m_pcEncTop->getScaledRefLayerWindowForLayer(refLayerId);
    10441133#else
    10451134        const Window &scalEL = m_pcEncTop->getScaledRefLayerWindow(refLayerIdc);
     
    10881177        }
    10891178#endif
    1090 #if SVC_UPSAMPLING
    1091         if( pcPic->isSpatialEnhLayer(refLayerIdc))
    1092         {
     1179#if SVC_EXTENSION
     1180        if( pcPic->isSpatialEnhLayer(refLayerIdc) )
     1181        {
     1182          // check for the sample prediction picture type
     1183          if( m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag(refLayerId) )
     1184          {
    10931185#if P0312_VERT_PHASE_ADJ
    1094           //when PhasePositionEnableFlag is equal to 1, set vertPhasePositionFlag to 0 if BL is top field and 1 if bottom
    1095           if( scalEL.getVertPhasePositionEnableFlag() )
    1096           {
    1097             pcSlice->setVertPhasePositionFlag( pcSlice->getPOC()%2, refLayerIdc );
    1098           }
     1186            //when PhasePositionEnableFlag is equal to 1, set vertPhasePositionFlag to 0 if BL is top field and 1 if bottom
     1187            if( scalEL.getVertPhasePositionEnableFlag() )
     1188            {
     1189              pcSlice->setVertPhasePositionFlag( pcSlice->getPOC()%2, refLayerIdc );
     1190            }
    10991191#endif
    11001192#if O0215_PHASE_ALIGNMENT
    11011193#if O0194_JOINT_US_BITSHIFT
    11021194#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() );
     1195            m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
     1196#else
     1197            m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getVPS()->getPhaseAlignFlag() );
    11061198#endif
    11071199#else
    11081200#if Q0048_CGS_3D_ASYMLUT
    1109           m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
    1110 #else
    1111           m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
     1201            m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
     1202#else
     1203            m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
    11121204#endif
    11131205#endif
     
    11151207#if O0194_JOINT_US_BITSHIFT
    11161208#if Q0048_CGS_3D_ASYMLUT
    1117           m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
    1118 #else
    1119           m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
     1209            m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
     1210#else
     1211            m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
    11201212#endif
    11211213#else
    11221214#if Q0048_CGS_3D_ASYMLUT
    1123           m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
    1124 #else
    1125           m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
    1126 #endif
    1127 #endif
    1128 #endif
     1215            m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
     1216#else
     1217            m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
     1218#endif
     1219#endif
     1220#endif
     1221          }
    11291222        }
    11301223        else
     
    11371230        }
    11381231        pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) );
    1139 #endif
     1232#endif //SVC_EXTENSION
    11401233      }
    11411234
     
    11541247        pcSlice->setInterLayerPredEnabledFlag(false);
    11551248      }
    1156      
     1249
    11571250      if( pocCurr % m_pcCfg->getIntraPeriod() == 0 )
    11581251      {
    1159 #if N0147_IRAP_ALIGN_FLAG
    11601252        if(pcSlice->getVPS()->getCrossLayerIrapAlignFlag())
    11611253        {
     
    11721264        }
    11731265        else
    1174 #endif
    1175         pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_CRA);
    1176 
    1177 #if IDR_ALIGNMENT
    1178         TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(0)->getListPic();
    1179         TComPic* picLayer0 = pcSlice->getRefPic(*cListPic, pcSlice->getPOC() );
    1180         if( picLayer0->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || picLayer0->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP )
    1181         {
    1182           pcSlice->setNalUnitType(picLayer0->getSlice(0)->getNalUnitType());
    1183         }
    1184         else
    1185         {
     1266        {
     1267#if !ALIGN_IRAP_BUGFIX
    11861268          pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_CRA);
    1187         }
    1188 #endif
    1189       }
    1190      
     1269#endif
     1270        }
     1271      }
     1272
    11911273      if( pcSlice->getActiveNumILRRefIdx() == 0 && pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
    11921274      {
     
    11961278      {
    11971279        if( (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) &&
    1198            (pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) &&
    1199            pcSlice->getSliceType() == B_SLICE )
     1280          (pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) &&
     1281          pcSlice->getSliceType() == B_SLICE )
    12001282        {
    12011283          pcSlice->setSliceType(P_SLICE);
    12021284        }
    1203       }
     1285      }     
    12041286    }
    12051287#endif //#if SVC_EXTENSION
     
    12071289    {
    12081290      if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_R &&
     1291#if SVC_EXTENSION
     1292        ( m_iGopSize != 1 || m_ppcTEncTop[m_layerId]->getIntraPeriod() > 1 ) )
     1293#else
    12091294          !(m_iGopSize == 1 && pcSlice->getSliceType() == I_SLICE))
     1295#endif
    12101296        // Add this condition to avoid POC issues with encoder_intra_main.cfg configuration (see #1127 in bug tracker)
    12111297      {
     
    12321318    {
    12331319      m_associatedIRAPType = pcSlice->getNalUnitType();
     1320#if POC_RESET_IDC_ENCODER
     1321      m_associatedIRAPPOC = pcSlice->getPOC();
     1322      m_associatedIrapPocBeforeReset = pocCurr;
     1323#else
    12341324      m_associatedIRAPPOC = pocCurr;
     1325#endif
    12351326    }
    12361327    pcSlice->setAssociatedIRAPType(m_associatedIRAPType);
    12371328    pcSlice->setAssociatedIRAPPOC(m_associatedIRAPPOC);
     1329#if POC_RESET_IDC_ENCODER
     1330    pcSlice->setAssociatedIrapPocBeforeReset(m_associatedIrapPocBeforeReset);
     1331#endif
    12381332#endif
    12391333#endif
     
    12431337#else
    12441338    pcSlice->decodingRefreshMarking(m_pocCRA, m_bRefreshPending, rcListPic);
     1339#endif
     1340#if POC_RESET_IDC_ENCODER
     1341    // m_pocCRA may have been update here; update m_pocCraWithoutReset
     1342    m_pocCraWithoutReset = m_pocCRA + m_pcEncTop->getPocAdjustmentValue();
    12451343#endif
    12461344    m_pcEncTop->selectReferencePictureSet(pcSlice, pocCurr, iGOPid);
     
    12801378#endif
    12811379#if ALIGNED_BUMPING
     1380#if POC_RESET_IDC_ENCODER
     1381    pcSlice->checkLeadingPictureRestrictions(rcListPic, true);
     1382#else
    12821383    pcSlice->checkLeadingPictureRestrictions(rcListPic);
     1384#endif
    12831385#endif
    12841386    pcSlice->applyReferencePictureSet(rcListPic, pcSlice->getRPS());
     
    12931395      if(pcSlice->isTemporalLayerSwitchingPoint(rcListPic) || pcSlice->getSPS()->getTemporalIdNestingFlag())
    12941396      {
    1295 #if ALIGN_TSA_STSA_PICS
     1397#if !Q0108_TSA_STSA
    12961398        if( pcSlice->getLayerId() > 0 )
    12971399        {
     
    13921494        if(isSTSA==true)
    13931495        {   
    1394 #if ALIGN_TSA_STSA_PICS
     1496#if !Q0108_TSA_STSA
    13951497          if( pcSlice->getLayerId() > 0 )
    13961498          {
     
    14611563      }
    14621564    }
     1565#if Q0108_TSA_STSA
     1566    else if( ( pcSlice->getTLayer() == 0 && pcSlice->getLayerId() > 0)    // only for enhancement layer and with temporal layer 0
     1567       && !( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N     
     1568          || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R
     1569          || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N
     1570          || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R
     1571          || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL
     1572          || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP
     1573          || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA
     1574          )
     1575        )
     1576    {
     1577        Bool isSTSA=true;
     1578        for(Int ii=iGOPid+1; ii < m_pcCfg->getGOPSize() && isSTSA; ii++)
     1579        {
     1580          Int lTid= m_pcCfg->getGOPEntry(ii).m_temporalId;
     1581          if(lTid==pcSlice->getTLayer())
     1582          {
     1583            TComReferencePictureSet* nRPS = pcSlice->getSPS()->getRPSList()->getReferencePictureSet(ii);
     1584            for(Int jj=0; jj<nRPS->getNumberOfPictures(); jj++)
     1585            {
     1586              if(nRPS->getUsed(jj))
     1587              {
     1588                Int tPoc=m_pcCfg->getGOPEntry(ii).m_POC+nRPS->getDeltaPOC(jj);
     1589                Int kk=0;
     1590                for(kk=0; kk<m_pcCfg->getGOPSize(); kk++)
     1591                {
     1592                  if(m_pcCfg->getGOPEntry(kk).m_POC==tPoc)
     1593                  {
     1594                    break;
     1595                  }
     1596                }
     1597                Int tTid=m_pcCfg->getGOPEntry(kk).m_temporalId;
     1598                if(tTid >= pcSlice->getTLayer())
     1599                {
     1600                  isSTSA = false;
     1601                  break;
     1602                }
     1603              }
     1604            }
     1605          }
     1606        }
     1607        if(isSTSA==true)
     1608        {   
     1609#if !Q0108_TSA_STSA
     1610          if( pcSlice->getLayerId() > 0 )
     1611          {
     1612            Bool oneRefLayerSTSA = false, oneRefLayerNotSTSA = false;
     1613            for( Int i = 0; i < pcSlice->getLayerId(); i++)
     1614            {
     1615              TComList<TComPic *> *cListPic = m_ppcTEncTop[i]->getListPic();
     1616              TComPic *lowerLayerPic = pcSlice->getRefPic(*cListPic, pcSlice->getPOC());
     1617              if( lowerLayerPic && pcSlice->getVPS()->getDirectDependencyFlag(pcSlice->getLayerId(), i) )
     1618              {
     1619                if( ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N ) ||
     1620                    ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_R )
     1621                  )
     1622                {
     1623                  if(pcSlice->getTemporalLayerNonReferenceFlag() )
     1624                  {
     1625                    pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_N);
     1626                  }
     1627                  else
     1628                  {
     1629                    pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_R );
     1630                  }
     1631                  oneRefLayerSTSA = true;
     1632                }
     1633                else
     1634                {
     1635                  oneRefLayerNotSTSA = true;
     1636                }
     1637              }
     1638            }
     1639            assert( !( oneRefLayerNotSTSA && oneRefLayerSTSA ) ); // Only one variable should be true - failure of this assert means
     1640                                                                  // that two independent reference layers that are not dependent on
     1641                                                                  // each other, but are reference for current layer have inconsistency
     1642            if( oneRefLayerNotSTSA /*&& !oneRefLayerSTSA*/ )          // No reference layer is STSA - set current as TRAIL
     1643            {
     1644              if(pcSlice->getTemporalLayerNonReferenceFlag() )
     1645              {
     1646                pcSlice->setNalUnitType( NAL_UNIT_CODED_SLICE_TRAIL_N );
     1647              }
     1648              else
     1649              {
     1650                pcSlice->setNalUnitType( NAL_UNIT_CODED_SLICE_TRAIL_R );
     1651              }
     1652            }
     1653            else  // This means there is no reference layer picture for current picture in this AU
     1654            {
     1655              if(pcSlice->getTemporalLayerNonReferenceFlag() )
     1656              {
     1657                pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_N);
     1658              }
     1659              else
     1660              {
     1661                pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_R );
     1662              }
     1663            }
     1664          }
     1665#else
     1666          if(pcSlice->getTemporalLayerNonReferenceFlag())
     1667          {
     1668            pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_N);
     1669            flagTSTA = 1;
     1670          }
     1671          else
     1672          {
     1673            pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_R);
     1674            flagTSTA = 1;
     1675          }
     1676#endif
     1677        }
     1678    }
     1679#endif
     1680
    14631681    arrangeLongtermPicturesInRPS(pcSlice, rcListPic);
    14641682    TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();
     
    14711689    if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
    14721690    {
    1473 #if POC_RESET_FLAG
    1474       if ( pocCurr > 0          && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL())
     1691#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
     1692      if ( pocCurr > 0 && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL())
    14751693#else
    14761694      if (pcSlice->getPOC()>0  && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL())
     
    14801698        pcSlice->setInterLayerPredEnabledFlag(0);
    14811699      }
    1482       if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
     1700#if Q0108_TSA_STSA
     1701     if( ( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA ) || flagTSTA == 1 )
     1702#else
     1703     if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
     1704#endif
    14831705      {
    14841706        pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getActiveNumILRRefIdx());
     
    14891711        pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getNumRefIdx(REF_PIC_LIST_0)+pcSlice->getActiveNumILRRefIdx());
    14901712        pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getNumRefIdx(REF_PIC_LIST_1)+pcSlice->getActiveNumILRRefIdx());
     1713      }
     1714
     1715      // check for the reference pictures whether there is at least one either temporal picture or ILRP with sample prediction type
     1716      if( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - pcSlice->getActiveNumILRRefIdx() == 0 && pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - pcSlice->getActiveNumILRRefIdx() == 0 )
     1717      {
     1718        Bool foundSamplePredPicture = false;               
     1719
     1720        for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
     1721        {
     1722          if( m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag( pcSlice->getVPS()->getRefLayerId( m_layerId, pcSlice->getInterLayerPredLayerIdc(i) ) ) )
     1723          {
     1724            foundSamplePredPicture = true;
     1725            break;
     1726          }
     1727        }
     1728
     1729        if( !foundSamplePredPicture )
     1730        {
     1731          pcSlice->setSliceType(I_SLICE);
     1732          pcSlice->setInterLayerPredEnabledFlag(0);
     1733          pcSlice->setActiveNumILRRefIdx(0);
     1734        }
    14911735      }
    14921736    }
     
    15201764      //  Set reference list
    15211765      pcSlice->setRefPicList ( rcListPic );
    1522 #endif //SVC_EXTENSION
     1766#endif
    15231767      pcSlice->setRefPicListModificationSvc();
    15241768      pcSlice->setRefPicList( rcListPic, false, m_pcEncTop->getIlpList());
     
    15321776
    15331777        for(Int colIdx = 0; colIdx < pcSlice->getNumRefIdx( RefPicList(1 - ColFromL0Flag) ); colIdx++)
    1534         {
    1535           if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->isILR(m_layerId)
     1778        {
     1779          RefPicList refList = RefPicList(1 - ColFromL0Flag);
     1780          TComPic* refPic = pcSlice->getRefPic(refList, colIdx);
     1781
     1782          // It is a requirement of bitstream conformance when the collocated picture, used for temporal motion vector prediction, is an inter-layer reference picture,
     1783          // VpsInterLayerMotionPredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture.
     1784          if( refPic->isILR(m_layerId) && m_ppcTEncTop[m_layerId]->getMotionPredEnabledFlag( refPic->getLayerId() )
    15361785#if MFM_ENCCONSTRAINT
    1537             && pcSlice->getBaseColPic( *m_ppcTEncTop[pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->getLayerId()]->getListPic() )->checkSameRefInfo() == true
     1786            && pcSlice->getBaseColPic( *m_ppcTEncTop[refPic->getLayerId()]->getListPic() )->checkSameRefInfo() == true
    15381787#endif
    15391788            )
     
    15491798          ColFromL0Flag = 1 - ColFromL0Flag;
    15501799          for(Int colIdx = 0; colIdx < pcSlice->getNumRefIdx( RefPicList(1 - ColFromL0Flag) ); colIdx++)
    1551           {
    1552             if( pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->isILR(m_layerId)
     1800          {
     1801            RefPicList refList = RefPicList(1 - ColFromL0Flag);
     1802            TComPic* refPic = pcSlice->getRefPic(refList, colIdx);
     1803
     1804            // It is a requirement of bitstream conformance when the collocated picture, used for temporal motion vector prediction, is an inter-layer reference picture,
     1805            // VpsInterLayerMotionPredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture.
     1806            if( refPic->isILR(m_layerId) && m_ppcTEncTop[m_layerId]->getMotionPredEnabledFlag( refPic->getLayerId() )
    15531807#if MFM_ENCCONSTRAINT
    1554               && pcSlice->getBaseColPic( *m_ppcTEncTop[pcSlice->getRefPic( RefPicList(1 - ColFromL0Flag), colIdx)->getLayerId()]->getListPic() )->checkSameRefInfo() == true
     1808              && pcSlice->getBaseColPic( *m_ppcTEncTop[refPic->getLayerId()]->getListPic() )->checkSameRefInfo() == true
    15551809#endif
    15561810              )
     
    16501904      pcSlice->setEnableTMVPFlag(0);
    16511905    }
     1906
     1907#if SVC_EXTENSION
     1908    if( m_layerId > 0 && !pcSlice->isIntra() )
     1909    {
     1910      Int colFromL0Flag = 1;
     1911      Int colRefIdx = 0;
     1912
     1913      // check whether collocated picture is valid
     1914      if( pcSlice->getEnableTMVPFlag() )
     1915      {
     1916        colFromL0Flag = pcSlice->getColFromL0Flag();
     1917        colRefIdx = pcSlice->getColRefIdx();
     1918
     1919        TComPic* refPic = pcSlice->getRefPic(RefPicList(1-colFromL0Flag), colRefIdx);
     1920
     1921        assert( refPic );
     1922
     1923        // It is a requirement of bitstream conformance when the collocated picture, used for temporal motion vector prediction, is an inter-layer reference picture,
     1924        // VpsInterLayerMotionPredictionEnabled[ LayerIdxInVps[ currLayerId ] ][ LayerIdxInVps[ rLId ] ] shall be equal to 1, where rLId is set equal to nuh_layer_id of the inter-layer picture.
     1925        if( refPic->isILR(m_layerId) && !m_ppcTEncTop[m_layerId]->getMotionPredEnabledFlag(refPic->getLayerId()) )
     1926        {
     1927          pcSlice->setEnableTMVPFlag(false);
     1928          pcSlice->setMFMEnabledFlag(false);
     1929          colRefIdx = 0;
     1930        }
     1931      }
     1932
     1933      // remove motion only ILRP from the end of the colFromL0Flag reference picture list
     1934      RefPicList refList = RefPicList(colFromL0Flag);
     1935      Int numRefIdx = pcSlice->getNumRefIdx(refList);
     1936
     1937      if( numRefIdx > 0 )
     1938      {
     1939        for( Int refIdx = pcSlice->getNumRefIdx(refList) - 1; refIdx > 0; refIdx-- )
     1940        {
     1941          TComPic* refPic = pcSlice->getRefPic(refList, refIdx);
     1942
     1943          if( !refPic->isILR(m_layerId) || ( refPic->isILR(m_layerId) && m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag( refPic->getLayerId() ) ) )
     1944          {
     1945            break;
     1946          }
     1947          else
     1948          {
     1949            assert( numRefIdx > 1 );
     1950            numRefIdx--;             
     1951          }
     1952        }
     1953
     1954        pcSlice->setNumRefIdx( refList, numRefIdx );
     1955      }
     1956
     1957      // remove motion only ILRP from the end of the (1-colFromL0Flag) reference picture list up to colRefIdx
     1958      refList = RefPicList(1 - colFromL0Flag);
     1959      numRefIdx = pcSlice->getNumRefIdx(refList);
     1960
     1961      if( numRefIdx > 0 )
     1962      {
     1963        for( Int refIdx = pcSlice->getNumRefIdx(refList) - 1; refIdx > colRefIdx; refIdx-- )
     1964        {
     1965          TComPic* refPic = pcSlice->getRefPic(refList, refIdx);
     1966
     1967          if( !refPic->isILR(m_layerId) || ( refPic->isILR(m_layerId) && m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag( refPic->getLayerId() ) ) )
     1968          {
     1969            break;
     1970          }
     1971          else
     1972          {
     1973            assert( numRefIdx > 1 );
     1974            numRefIdx--;             
     1975          }
     1976        }
     1977
     1978        pcSlice->setNumRefIdx( refList, numRefIdx );
     1979      }
     1980
     1981      assert( pcSlice->getNumRefIdx(REF_PIC_LIST_0) > 0 && ( pcSlice->isInterP() || (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) > 0) ) );
     1982    }
     1983#endif
     1984
    16521985    /////////////////////////////////////////////////////////////////////////////////////////////////// Compress a slice
    16531986    //  Slice compression
     
    17002033
    17012034      Int sliceQP = m_pcCfg->getInitialQP();
    1702 #if POC_RESET_FLAG
     2035#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
    17032036      if ( ( pocCurr == 0 && m_pcCfg->getInitialQP() > 0 ) || ( frameLevel == 0 && m_pcCfg->getForceIntraQP() ) ) // QP is specified
    17042037#else
     
    19832316    {
    19842317#if SVC_EXTENSION
    1985 #if VPS_NUH_LAYER_ID
    1986       OutputNALUnit nalu(NAL_UNIT_VPS, 0, 0        ); // The value of nuh_layer_id of VPS NAL unit shall be equal to 0.
    1987 #else
    1988       OutputNALUnit nalu(NAL_UNIT_VPS, 0, m_layerId);
    1989 #endif
     2318      OutputNALUnit nalu( NAL_UNIT_VPS, 0, 0 ); // The value of nuh_layer_id of VPS NAL unit shall be equal to 0.
    19902319#if AVC_BASE
    19912320      if( ( m_layerId == 1 && m_pcEncTop->getVPS()->getAvcBaseLayerFlag() ) || ( m_layerId == 0 && !m_pcEncTop->getVPS()->getAvcBaseLayerFlag() ) )
     
    20212350      nalu = NALUnit(NAL_UNIT_SPS);
    20222351#endif
     2352#if Q0078_ADD_LAYER_SETS
     2353      if (m_pcEncTop->getVPS()->getNumDirectRefLayers(m_layerId) == 0 && m_pcEncTop->getVPS()->getNumAddLayerSets() > 0)
     2354      {
     2355        nalu.m_layerId = 0; // For independent base layer rewriting
     2356      }
     2357#endif
    20232358      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    20242359      if (m_bSeqFirst)
     
    20582393#else
    20592394      nalu = NALUnit(NAL_UNIT_PPS);
     2395#endif
     2396#if Q0078_ADD_LAYER_SETS
     2397      if (m_pcEncTop->getVPS()->getNumDirectRefLayers(m_layerId) == 0 && m_pcEncTop->getVPS()->getNumAddLayerSets() > 0)
     2398      {
     2399        nalu.m_layerId = 0; // For independent base layer rewriting
     2400      }
    20602401#endif
    20612402      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     
    21552496      writeSOP = false;
    21562497    }
     2498#if Q0189_TMVP_CONSTRAINTS
     2499   if( m_pcEncTop->getTMVPConstraintsSEIEnabled() == 1 &&
     2500      (m_pcEncTop->getTMVPModeId() == 1 || m_pcEncTop->getTMVPModeId() == 2) &&
     2501      pcSlice->getLayerId() >0 &&
     2502      (pcSlice->getNalUnitType() ==  NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcSlice->getNalUnitType() ==  NAL_UNIT_CODED_SLICE_IDR_N_LP))
     2503   {
     2504      OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
     2505      SEITMVPConstrains seiTMVPConstrains;
     2506      m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     2507      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     2508      seiTMVPConstrains.no_intra_layer_col_pic_flag = 1;
     2509      seiTMVPConstrains.prev_pics_not_used_flag = 1;
     2510#if   O0164_MULTI_LAYER_HRD
     2511      m_seiWriter.writeSEImessage( nalu.m_Bitstream, seiTMVPConstrains, m_pcEncTop->getVPS(), pcSlice->getSPS() );
     2512#else
     2513      m_seiWriter.writeSEImessage( nalu.m_Bitstream, seiTMVPConstrains, pcSlice->getSPS() );
     2514#endif
     2515      writeRBSPTrailingBits(nalu.m_Bitstream);
     2516      accessUnit.push_back(new NALUnitEBSP(nalu));
     2517   }
     2518#endif
     2519#if Q0247_FRAME_FIELD_INFO
     2520    if(  pcSlice->getLayerId()> 0 &&
     2521     ( (m_pcCfg->getProgressiveSourceFlag() && m_pcCfg->getInterlacedSourceFlag()) || m_pcCfg->getFrameFieldInfoPresentFlag()))
     2522    {
     2523      OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
     2524      SEIFrameFieldInfo seiFFInfo;
     2525      m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     2526      m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     2527      seiFFInfo.m_ffinfo_picStruct = (isField && pcSlice->getPic()->isTopField())? 1 : isField? 2 : 0;
     2528#if   O0164_MULTI_LAYER_HRD
     2529      m_seiWriter.writeSEImessage( nalu.m_Bitstream, seiFFInfo, m_pcEncTop->getVPS(), pcSlice->getSPS() );
     2530#else
     2531      m_seiWriter.writeSEImessage( nalu.m_Bitstream, seiFFInfo, pcSlice->getSPS() );
     2532#endif
     2533      writeRBSPTrailingBits(nalu.m_Bitstream);
     2534      accessUnit.push_back(new NALUnitEBSP(nalu));
     2535    }
     2536#endif
    21572537
    21582538    if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) &&
     
    21852565      }
    21862566      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 .
    2187 #if POC_RESET_FLAG
     2567#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
    21882568      pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(pcSlice->getSPS()->getMaxTLayers()-1) + pocCurr - m_totalCoded;
    21892569#else
     
    23132693      SEIRecoveryPoint sei_recovery_point;
    23142694      sei_recovery_point.m_recoveryPocCnt    = 0;
    2315 #if POC_RESET_FLAG
     2695#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
    23162696      sei_recovery_point.m_exactMatchingFlag = ( pocCurr == 0 ) ? (true) : (false);
    23172697#else
     
    30683448#endif
    30693449}
     3450
     3451#if POC_RESET_IDC_ENCODER
     3452Void TEncGOP::determinePocResetIdc(Int const pocCurr, TComSlice *const slice)
     3453{
     3454  // If one picture in the AU is IDR, and another picture is not IDR, set the poc_reset_idc to 1 or 2
     3455  // If BL picture in the AU is IDR, and another picture is not IDR, set the poc_reset_idc to 2
     3456  // If BL picture is IRAP, and another picture is non-IRAP, then the poc_reset_idc is equal to 1 or 2.
     3457  if( slice->getSliceIdx() == 0 ) // First slice - compute, copy for other slices
     3458  {
     3459    Int needReset = false;
     3460    Int resetDueToBL = false;
     3461    if( slice->getVPS()->getMaxLayers() > 1 )
     3462    {
     3463      // If IRAP is refreshed in this access unit for base layer
     3464      if( (m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == 1 || m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == 2)
     3465        && ( pocCurr % m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshInterval() == 0 )
     3466        )
     3467      {
     3468        // Check if the IRAP refresh interval of any layer does not match that of the base layer
     3469        for(Int i = 1; i < slice->getVPS()->getMaxLayers(); i++)
     3470        {
     3471          Bool refreshIntervalFlag = ( pocCurr % m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshInterval() == 0 );
     3472          Bool refreshTypeFlag     = ( m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshType() );
     3473          if( !(refreshIntervalFlag && refreshTypeFlag) )
     3474          {
     3475            needReset = true;
     3476            resetDueToBL = true;
     3477            break;
     3478          }
     3479        }
     3480      }
     3481    }
     3482   
     3483    if( !needReset )// No need reset due to base layer IRAP
     3484    {
     3485      // Check if EL IDRs results in POC Reset
     3486      for(Int i = 1; i < slice->getVPS()->getMaxLayers() && !needReset; i++)
     3487      {
     3488        Bool idrFlag = ( (m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshType() == 2)
     3489                        && ( pocCurr % m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshInterval() == 0 )
     3490                        );
     3491        for(Int j = 0; j < slice->getVPS()->getMaxLayers(); j++)
     3492        {
     3493          if( j == i )
     3494          {
     3495            continue;
     3496          }
     3497          Bool idrOtherPicFlag = ( (m_ppcTEncTop[j]->getGOPEncoder()->getIntraRefreshType() == 2)
     3498                                  && ( pocCurr % m_ppcTEncTop[j]->getGOPEncoder()->getIntraRefreshInterval() == 0 )
     3499                                  );
     3500
     3501          if( idrFlag != idrOtherPicFlag )
     3502          {
     3503            needReset = true;
     3504            break;
     3505          }
     3506        }
     3507      }
     3508    }
     3509    if( needReset )
     3510    {
     3511      if( m_ppcTEncTop[0]->getGOPEncoder()->getIntraRefreshType() == 2 )  // BL IDR refresh, assuming BL picture present
     3512      {
     3513        if( resetDueToBL )
     3514        {
     3515          slice->setPocResetIdc( 2 ); // Full reset needed
     3516        }
     3517        else
     3518        {
     3519          slice->setPocResetIdc( 1 ); // Due to IDR in EL
     3520        }
     3521      }
     3522      else
     3523      {
     3524        slice->setPocResetIdc( 1 ); // Only MSB reset
     3525      }
     3526
     3527      // Start a new POC reset period
     3528      if (m_layerId == 0)   // Assuming BL picture is always present at encoder; for other AU structures, need to change this
     3529      {
     3530        Int periodId = rand() % 64;
     3531        m_lastPocPeriodId = (periodId == m_lastPocPeriodId) ? (periodId + 1) % 64 : periodId ;
     3532      }
     3533      else
     3534      {
     3535        m_lastPocPeriodId = m_ppcTEncTop[0]->getGOPEncoder()->getLastPocPeriodId();
     3536      }
     3537      slice->setPocResetPeriodId(m_lastPocPeriodId);
     3538    }
     3539    else
     3540    {
     3541      slice->setPocResetIdc( 0 );
     3542    }
     3543  }
     3544}
     3545
     3546Void TEncGOP::updatePocValuesOfPics(Int const pocCurr, TComSlice *const slice)
     3547{
     3548
     3549  Int pocAdjustValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
     3550
     3551  // New POC reset period
     3552  Int maxPocLsb, pocLsbVal, pocMsbDelta, pocLsbDelta, deltaPocVal;
     3553
     3554  maxPocLsb   = 1 << slice->getSPS()->getBitsForPOC();
     3555  pocLsbVal   = (slice->getPocResetIdc() == 3)
     3556                ? slice->getPocLsbVal()
     3557                : pocAdjustValue % maxPocLsb;
     3558  pocMsbDelta = pocAdjustValue - pocLsbVal;
     3559  pocLsbDelta = (slice->getPocResetIdc() == 2 || ( slice->getPocResetIdc() == 3 && slice->getFullPocResetFlag() ))
     3560                ? pocLsbVal
     3561                : 0;
     3562  deltaPocVal = pocMsbDelta  + pocLsbDelta;
     3563 
     3564  // Decrement value of associatedIrapPoc of the TEncGop object
     3565  this->m_associatedIRAPPOC -= deltaPocVal;
     3566
     3567  // Decrememnt the value of m_pocCRA
     3568  this->m_pocCRA -= deltaPocVal;
     3569
     3570  // Iterate through all pictures in the DPB
     3571  TComList<TComPic*>::iterator  iterPic = getListPic()->begin(); 
     3572  while( iterPic != getListPic()->end() )
     3573  {
     3574    TComPic *dpbPic = *iterPic;
     3575   
     3576    if( dpbPic->getReconMark() )
     3577    {
     3578      for(Int i = dpbPic->getNumAllocatedSlice() - 1; i >= 0; i--)
     3579      {
     3580        TComSlice *dpbPicSlice = dpbPic->getSlice( i );
     3581        TComReferencePictureSet *dpbPicRps = dpbPicSlice->getRPS();
     3582
     3583        // Decrement POC of slice
     3584        dpbPicSlice->setPOC( dpbPicSlice->getPOC() - deltaPocVal );
     3585
     3586        // Decrement POC value stored in the RPS of each such slice
     3587        for( Int j = dpbPicRps->getNumberOfPictures() - 1; j >= 0; j-- )
     3588        {
     3589          dpbPicRps->setPOC( j, dpbPicRps->getPOC(j) - deltaPocVal );
     3590        }
     3591
     3592        // Decrement value of refPOC
     3593        dpbPicSlice->decrementRefPocValues( deltaPocVal );
     3594
     3595        // Update value of associatedIrapPoc of each slice
     3596        dpbPicSlice->setAssociatedIRAPPOC( dpbPicSlice->getAssociatedIRAPPOC() - deltaPocVal );
     3597      }
     3598    }
     3599    iterPic++;
     3600  }
     3601 
     3602  // Actual POC value before reset
     3603  Int adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
     3604
     3605  // Set MSB value before reset
     3606  Int tempLsbVal = adjustedPocValue & (maxPocLsb - 1);
     3607  slice->setPocMsbVal( adjustedPocValue - tempLsbVal);
     3608
     3609  // Set LSB value before reset - this is needed in the case of resetIdc = 2
     3610  slice->setPicOrderCntLsb( tempLsbVal );
     3611
     3612  // Cumulative delta
     3613  m_pcEncTop->setPocAdjustmentValue( m_pcEncTop->getPocAdjustmentValue() + deltaPocVal );
     3614
     3615  // New LSB value, after reset
     3616  adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
     3617  Int newLsbVal = adjustedPocValue & (maxPocLsb - 1);
     3618
     3619  // Set value of POC current picture after RESET
     3620  if( slice->getPocResetIdc() == 1 )
     3621  {
     3622    slice->setPOC( newLsbVal );
     3623  }
     3624  else if( slice->getPocResetIdc() == 2 )
     3625  {
     3626    slice->setPOC( 0 );
     3627  }
     3628  else if( slice->getPocResetIdc() == 3 )
     3629  {
     3630    Int picOrderCntMsb = slice->getCurrMsb( newLsbVal,
     3631                                        slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal(),
     3632                                        0,
     3633                                        maxPocLsb );
     3634    slice->setPOC( picOrderCntMsb + newLsbVal );
     3635  }
     3636  else
     3637  {
     3638    assert(0);
     3639  }
     3640}
     3641#endif
     3642
    30703643
    30713644#if !SVC_EXTENSION
     
    35164089      if( pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->isILR(m_layerId) )
    35174090      {
     4091#if POC_RESET_IDC_ENCODER
     4092        printf( "%d(%d)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() );
     4093#else
    35184094        printf( "%d(%d)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR(), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() );
     4095#endif
    35194096      }
    35204097      else
    35214098      {
     4099#if POC_RESET_IDC_ENCODER
     4100        printf ("%d", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex));
     4101#else
    35224102        printf ("%d", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR());
     4103#endif
    35234104      }
    35244105#endif
     
    37474328    }
    37484329  }
     4330
     4331#if POC_RESET_IDC_ENCODER
     4332  if(m_pocCraWithoutReset > 0 && this->m_associatedIRAPType == NAL_UNIT_CODED_SLICE_CRA)
     4333  {
     4334    if(pocCurr < m_pocCraWithoutReset)
     4335#else
    37494336  if(m_pocCRA>0)
    37504337  {
    37514338    if(pocCurr<m_pocCRA)
     4339#endif
    37524340    {
    37534341      // All leading pictures are being marked as TFD pictures here since current encoder uses all
     
    42874875
    42884876    if(!m_temp)
     4877    {
    42894878      initDs(iWidth, iHeight, m_pcCfg->getIntraPeriod()>1);
     4879    }
    42904880
    42914881    filterImg(pcYuvSrc->getLumaAddr(), pcYuvSrc->getStride(), pcYuvDest->getLumaAddr(), pcYuvDest->getStride(), iHeight, iWidth,  inputBitDepth-outputBitDepth, 0);
     
    42944884  }
    42954885}
    4296 const int TEncGOP::m_phase_filter_0_t0[4][13]={
     4886const Int TEncGOP::m_phase_filter_0_t0[4][13]={
    42974887  {0,  2,  -3,  -9,   6,  39,  58,  39,   6,  -9,  -3,  2,  0}, 
    42984888  {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},  //
     
    43014891};
    43024892
    4303 const int TEncGOP::m_phase_filter_0_t1[4][13]={
     4893const Int TEncGOP::m_phase_filter_0_t1[4][13]={
    43044894  {0,  4,  0,  -12, 0,  40,  64,  40, 0, -12,  0,  4,  0},
    43054895  {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},  //
     
    43074897  {0,  0,   1,  -5,  -7,  13,  47,  57,  31,  -1,  -8,-1,  1} 
    43084898};
    4309 const int TEncGOP::m_phase_filter_0_t1_chroma[4][13]={
     4899const Int TEncGOP::m_phase_filter_0_t1_chroma[4][13]={
    43104900  {0,  0,  0,   0,  0,   0,  128, 0,  0,  0,  0,  0,  0},
    43114901  {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},  //
     
    43144904};
    43154905
    4316 const int TEncGOP::m_phase_filter_1[8][13]={
     4906const Int TEncGOP::m_phase_filter_1[8][13]={
    43174907  {0,   0,  5,  -6,  -10,37,  76,  37,-10,   -6, 5,  0,   0},   
    43184908  {0,  -1,  5,  -3,  -12,29,  75,  45,  -7,   -8, 5,  0,   0},   
     
    43254915};
    43264916
     4917#if CGS_GCC_NO_VECTORIZATION 
     4918#ifdef __GNUC__
     4919#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
     4920#if GCC_VERSION > 40600
     4921__attribute__((optimize("no-tree-vectorize")))
     4922#endif
     4923#endif
     4924#endif
    43274925Void TEncGOP::filterImg(
    43284926    Pel           *src,
     
    43774975  // pad temp (vertical)
    43784976  for (k=-(length>>1); k<0; k++)
    4379     memcpy(m_temp[k], m_temp[0], width2*sizeof(int));
     4977  {
     4978    memcpy(m_temp[k], m_temp[0], width2*sizeof(Int));
     4979  }
    43804980  for (k=height1; k<(height1+(length>>1)); k++)
    4381     memcpy(m_temp[k], m_temp[k-1], (width2)* sizeof(int));
     4981  {
     4982    memcpy(m_temp[k], m_temp[k-1], (width2)* sizeof(Int));
     4983  }
    43824984
    43834985  // vertical filtering
     
    44005002      }
    44015003      iSum=((iSum + shift_round) >> shift2);
    4402       *p_dst++ = (short)(iSum > iMax ? iMax : (iSum < 0 ? 0 : iSum));
     5004      *p_dst++ = (Short)(iSum > iMax ? iMax : (iSum < 0 ? 0 : iSum));
    44035005    }
    44045006    p_dst_line += iDstStride;
     
    44555057  {
    44565058    if (*array2D)
     5059    {
    44575060      xFree(array2D[-iPadY]-iPadX);
     5061    }
    44585062    else
     5063    {
    44595064      printf("free_mem2DintWithPad: trying to free unused memory\r\nPress Any Key\r\n");
     5065    }
    44605066
    44615067    free (&array2D[-iPadY]);
  • trunk/source/Lib/TLibEncoder/TEncGOP.h

    r713 r815  
    113113  Bool                    m_bRefreshPending;
    114114  Int                     m_pocCRA;
     115#if POC_RESET_IDC_ENCODER
     116  Int                     m_pocCraWithoutReset;
     117  Int                     m_associatedIrapPocBeforeReset;
     118#endif
    115119  std::vector<Int>        m_storedStartCUAddrForEncodingSlice;
    116120  std::vector<Int>        m_storedStartCUAddrForEncodingSliceSegment;
     
    135139  UInt                    m_layerId;     
    136140  TEncTop**               m_ppcTEncTop;
    137 #if SVC_UPSAMPLING
    138141  TEncSearch*             m_pcPredSearch;                       ///< encoder search class
    139 #endif 
    140142#if Q0048_CGS_3D_ASYMLUT
    141143  TEnc3DAsymLUT           m_Enc3DAsymLUTPicUpdate;
     
    154156  Int   **m_temp;
    155157#endif
     158#if POC_RESET_IDC_ENCODER
     159  Int   m_lastPocPeriodId;
     160#endif
    156161#endif
    157162 
     
    172177#else
    173178  Void  compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff );
     179#endif
     180#if POC_RESET_IDC_ENCODER
     181  Void  determinePocResetIdc( Int const pocCurr, TComSlice *const slice);
     182  Int   getIntraRefreshInterval()  { return m_pcCfg->getIntraPeriod(); }
     183  Int   getIntraRefreshType()      { return m_pcCfg->getDecodingRefreshType(); }
     184  // Int   getIntraRefreshInterval ()  { return (m_pcCfg) ? m_pcCfg->getIntraPeriod() : 0;  }
     185  Int   getLastPocPeriodId()      { return m_lastPocPeriodId; }
     186  Void  setLastPocPeriodId(Int x) { m_lastPocPeriodId = x;    }
     187  Void  updatePocValuesOfPics( Int const pocCurr, TComSlice *const slice);
    174188#endif
    175189  Void  xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect);
     
    209223
    210224  SEIToneMappingInfo*     xCreateSEIToneMappingInfo();
     225#if P0050_KNEE_FUNCTION_SEI
     226  SEIKneeFunctionInfo*    xCreateSEIKneeFunctionInfo();
     227#endif
    211228#if Q0074_SEI_COLOR_MAPPING
    212229  SEIColorMappingInfo*    xCreateSEIColorMappingInfo( Char* file );
  • trunk/source/Lib/TLibEncoder/TEncPic.cpp

    r595 r815  
    126126 * \return Void
    127127 */
     128#if SVC_EXTENSION
    128129#if AUXILIARY_PICTURES
    129 #if SVC_UPSAMPLING
    130130Void TEncPic::create( Int iWidth, Int iHeight, ChromaFormat chromaFormat, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth, 
    131131                      Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, TComSPS* pcSps, Bool bIsVirtual )
    132 
    133 #else
    134 
    135 Void TEncPic::create( Int iWidth, Int iHeight, ChromaFormat chromaFormat, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth,
    136                       Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, Bool bIsVirtual )
    137 #endif
    138132{
    139 #if SVC_UPSAMPLING
    140133  TComPic::create( iWidth, iHeight, chromaFormat, uiMaxWidth, uiMaxHeight, uiMaxDepth, 
    141134                   conformanceWindow, defaultDisplayWindow, numReorderPics, pcSps, bIsVirtual );
    142135#else
    143   TComPic::create( iWidth, iHeight, chromaFormat, uiMaxWidth, uiMaxHeight, uiMaxDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, bIsVirtual );
     136Void TEncPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth, 
     137                      Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, TComSPS* pcSps, Bool bIsVirtual )
     138{
     139  TComPic::create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, 
     140                   conformanceWindow, defaultDisplayWindow, numReorderPics, pcSps, bIsVirtual );
    144141#endif
    145142  m_uiMaxAQDepth = uiMaxAQDepth;
     
    153150  }
    154151}
    155 #else
    156 #if SVC_UPSAMPLING
    157 Void TEncPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth, 
    158                       Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, TComSPS* pcSps, Bool bIsVirtual )
    159 
    160 #else
     152#else  //SVC_EXTENSION
    161153Void TEncPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth, 
    162154                      Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, Bool bIsVirtual )
    163 #endif
    164155{
    165 #if SVC_UPSAMPLING
    166   TComPic::create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, 
    167                    conformanceWindow, defaultDisplayWindow, numReorderPics, pcSps, bIsVirtual );
    168 #else
    169156  TComPic::create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, 
    170157                   conformanceWindow, defaultDisplayWindow, numReorderPics, bIsVirtual );
    171 #endif
    172158  m_uiMaxAQDepth = uiMaxAQDepth;
    173159  if ( uiMaxAQDepth > 0 )
     
    180166  }
    181167}
    182 #endif
     168#endif //SVC_EXTENSION
    183169
    184170/** Clean up
  • trunk/source/Lib/TLibEncoder/TEncPic.h

    r595 r815  
    4141#include "TLibCommon/CommonDef.h"
    4242#include "TLibCommon/TComPic.h"
    43 #if SVC_UPSAMPLING
     43#if SVC_EXTENSION
    4444#include "TLibCommon/TComSlice.h"
    4545#endif
     
    105105  virtual ~TEncPic();
    106106
     107#if SVC_EXTENSION
    107108#if AUXILIARY_PICTURES
    108 #if SVC_UPSAMPLING
    109109  Void          create( Int iWidth, Int iHeight, ChromaFormat chromaFormat, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth, 
    110110                      Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, TComSPS* pcSps, Bool bIsVirtual=false );
    111111#else
    112   Void          create( Int iWidth, Int iHeight, ChromaFormat chromaFormat, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth,
    113                           Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, Bool bIsVirtual = false );
    114 
    115 #endif
    116 #else
    117 #if SVC_UPSAMPLING
    118112  Void          create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth,   
    119113                        Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, TComSPS* pcSps, Bool bIsVirtual = false );
    120 #else
     114#endif
     115#else  //SVC_EXTENSION
    121116  Void          create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, UInt uiMaxAQDepth,   
    122117                        Window &conformanceWindow, Window &defaultDisplayWindow, Int *numReorderPics, Bool bIsVirtual = false );
    123 #endif
    124 #endif
     118#endif //SVC_EXTENSION
     119
    125120  virtual Void  destroy();
    126121
  • trunk/source/Lib/TLibEncoder/TEncSearch.cpp

    r713 r815  
    31023102 * \returns Void
    31033103 */
     3104#if SVC_EXTENSION
     3105#if AMP_MRG
     3106Bool TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes, Bool bUseMRG )
     3107#else
     3108Bool TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes )
     3109#endif
     3110#else
    31043111#if AMP_MRG
    31053112Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes, Bool bUseMRG )
    31063113#else
    31073114Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bUseRes )
     3115#endif
    31083116#endif
    31093117{
     
    32153223#endif
    32163224
     3225#if SVC_EXTENSION
     3226      Bool doneUniPred = false;
     3227#endif
     3228
    32173229    //  Uni-directional prediction
    32183230    for ( Int iRefList = 0; iRefList < iNumPredDir; iRefList++ )
     
    32223234      for ( Int iRefIdxTemp = 0; iRefIdxTemp < pcCU->getSlice()->getNumRefIdx(eRefPicList); iRefIdxTemp++ )
    32233235      {
     3236#if SVC_EXTENSION
     3237        TComPic* pcPic = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxTemp );
     3238       
     3239        // motion search only for the ILRP with sample prediction type
     3240        if( pcPic->isILR( pcCU->getLayerId() ) && !pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getLayerId(), pcPic->getLayerId() ) )
     3241        {
     3242          continue;
     3243        }
     3244
    32243245#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    3225         if (pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxTemp )->isILR(pcCU->getLayerId()) && m_disableILP)
     3246        if( pcPic->isILR(pcCU->getLayerId()) && m_disableILP )
    32263247        {
    32273248          continue;
    32283249        }
    32293250#endif
    3230 #if (ENCODER_FAST_MODE)
    3231         TComPic* pcPic    = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxTemp );
     3251#if (ENCODER_FAST_MODE)       
    32323252        if( pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N) )
    32333253        {
    32343254          continue;
    32353255        }
     3256#endif
     3257        doneUniPred = true;
    32363258#endif
    32373259
     
    33423364      }
    33433365    }
     3366
     3367#if SVC_EXTENSION
     3368    if( pcCU->getLayerId() && !doneUniPred )
     3369    {
     3370      // there is no valid reference pictures for inter prediction
     3371      return false;
     3372    }
     3373#endif
     3374
    33443375    //  Bi-directional prediction
    33453376#if REF_IDX_ME_ZEROMV
     
    34623493#if (ENCODER_FAST_MODE)
    34633494          Bool testRefIdx = true;
    3464           pcPic           = pcCU->getSlice()->getRefPic( RefPicList(iRefList) , iRefIdxTemp );
     3495          pcPic = pcCU->getSlice()->getRefPic( RefPicList(iRefList) , iRefIdxTemp );
     3496
     3497          // motion search only for the ILRP with sample prediction type
     3498          if( pcPic->isILR( pcCU->getLayerId() ) && !pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getLayerId(), pcPic->getLayerId() ) )
     3499          {
     3500            continue;
     3501          }
     3502
    34653503          if(pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N))
    34663504          {
     
    37813819  setWpScalingDistParam( pcCU, -1, REF_PIC_LIST_X );
    37823820
     3821#if SVC_EXTENSION
     3822  return true;
     3823#else
    37833824  return;
     3825#endif
    37843826}
    37853827
     
    59676009Bool TEncSearch::predInterSearchILRUni( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, UInt refLayerId )
    59686010{
    5969     rpcPredYuv->clear();
    5970     rpcRecoYuv->clear();
    5971 
    5972     Int           iNumPredDir = pcCU->getSlice()->isInterP() ? 1 : 2;
    5973 
    5974     TComMv        cMv[2];
    5975     TComMv        cMvPred[2][33];
    5976     TComMv        cMvTemp[2][33];
    5977     TComMv        TempMv;
    5978 
    5979     Int           iRefIdx[2]={0,0};
    5980 
    5981     Int           aaiMvpIdx[2][33];
    5982     Int           aaiMvpNum[2][33];
    5983 
    5984     UInt          uiMbBits[3] = {1, 1, 0};
    5985     UInt          uiLastMode = 0;
    5986 
    5987     UInt          uiCost[2]   = { MAX_UINT, MAX_UINT };     //uni, rdCost
    5988     UInt          uiCostTemp;
    5989     UInt          biPDistTemp = MAX_INT;
    5990     UInt          uiBitsTemp;
    5991 
    5992     PartSize      ePartSize = pcCU->getPartitionSize( 0 );  //2Nx2N
    5993     Int           iPartIdx  = 0;                            //one PU in CU
    5994     UInt          uiPartAddr;
    5995     Int           iRoiWidth, iRoiHeight;
    5996     Bool          bILRSearched = false;
    5997 
    5998     xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits);
    5999     pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
    6000 
    6001     for( Int iRefList = 0; iRefList < iNumPredDir; iRefList++)  //list
    6002     {
    6003         if(bILRSearched)
    6004            continue;
    6005 
    6006         RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
    6007 
    6008         Int  iRefIdxTemp = -1;
    6009         Bool foundILR    = false;
    6010 
    6011         for( Int refIdx = 0; refIdx < pcCU->getSlice()->getNumRefIdx(eRefPicList); refIdx++ )
    6012         {
    6013             if( pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->isILR(pcCU->getLayerId()) && pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->getLayerId() == refLayerId )
    6014             {
    6015                 iRefIdxTemp = refIdx;
    6016                 foundILR    = true;
    6017                 bILRSearched = true;
    6018                 break;
    6019             }
    6020         }
    6021 
    6022         if(!foundILR)  //no ILR in eRefPiclist
    6023         {
    6024             continue; 
    6025         }
    6026 
    6027         uiBitsTemp = uiMbBits[iRefList];
    6028         if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 )
    6029         {
    6030             uiBitsTemp += iRefIdxTemp+1;
    6031             if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--;
    6032         }
    6033 
    6034         xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp);
    6035         aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->getMVPIdx(eRefPicList, uiPartAddr);
    6036         aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->getMVPNum(eRefPicList, uiPartAddr);
    6037 
    6038         uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS];
    6039 
    6040         xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
    6041         xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
    6042 
    6043         if( uiCostTemp < uiCost[iRefList] )
    6044         {
    6045             uiCost[iRefList] = uiCostTemp;
    6046 
    6047             cMv[iRefList]     = cMvTemp[iRefList][iRefIdxTemp];
    6048             iRefIdx[iRefList] = iRefIdxTemp;
    6049 
    6050             pcCU->getCUMvField(eRefPicList)->setAllMv( cMv[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
    6051             pcCU->getCUMvField(eRefPicList)->setAllRefIdx( iRefIdx[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
    6052         }
    6053     }
    6054 
    6055     if( uiCost[0] == MAX_UINT && uiCost[1] == MAX_UINT )  //no ILR in both list0 and list1
    6056     {
    6057         return false;
    6058     }
    6059 
    6060     //  Clear Motion Field
    6061     pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx );
    6062     pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx );
    6063     pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( TComMv(),      ePartSize, uiPartAddr, 0, iPartIdx );
    6064     pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( TComMv(),      ePartSize, uiPartAddr, 0, iPartIdx );
    6065 
    6066     pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6067     pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6068     pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6069     pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6070 
    6071     if( uiCost[0] <= uiCost[1] )  //list0 ILR
    6072     {
    6073         pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv    ( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx );
    6074         pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx );
    6075 
    6076         TempMv = cMv[0] - cMvPred[0][iRefIdx[0]];
    6077         pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx );
    6078 
    6079         pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
    6080 
    6081         pcCU->setMVPIdxSubParts( aaiMvpIdx[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6082         pcCU->setMVPNumSubParts( aaiMvpNum[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6083     }
    6084     else if( uiCost[1] < uiCost[0] )  //list1 ILR
    6085     {
    6086         pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv    ( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx );
    6087         pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx );
    6088 
    6089         TempMv = cMv[1] - cMvPred[1][iRefIdx[1]];
    6090         pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx );
    6091 
    6092         pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
    6093 
    6094         pcCU->setMVPIdxSubParts( aaiMvpIdx[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6095         pcCU->setMVPNumSubParts( aaiMvpNum[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
    6096     }
    6097     else
    6098     {
    6099         assert(0);
    6100     }
    6101 
    6102     pcCU->setMergeFlagSubParts( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
    6103 
    6104     motionCompensation ( pcCU, rpcPredYuv, REF_PIC_LIST_X, iPartIdx );
    6105     setWpScalingDistParam( pcCU, -1, REF_PIC_LIST_X );
    6106 
    6107     return true;
     6011  rpcPredYuv->clear();
     6012  rpcRecoYuv->clear();
     6013
     6014  Int           iNumPredDir = pcCU->getSlice()->isInterP() ? 1 : 2;
     6015
     6016  TComMv        cMv[2];
     6017  TComMv        cMvPred[2][33];
     6018  TComMv        cMvTemp[2][33];
     6019  TComMv        TempMv;
     6020
     6021  Int           iRefIdx[2]={0,0};
     6022
     6023  Int           aaiMvpIdx[2][33];
     6024  Int           aaiMvpNum[2][33];
     6025
     6026  UInt          uiMbBits[3] = {1, 1, 0};
     6027  UInt          uiLastMode = 0;
     6028
     6029  UInt          uiCost[2]   = { MAX_UINT, MAX_UINT };     //uni, rdCost
     6030  UInt          uiCostTemp;
     6031  UInt          biPDistTemp = MAX_INT;
     6032  UInt          uiBitsTemp;
     6033
     6034  PartSize      ePartSize = pcCU->getPartitionSize( 0 );  //2Nx2N
     6035  Int           iPartIdx  = 0;                            //one PU in CU
     6036  UInt          uiPartAddr;
     6037  Int           iRoiWidth, iRoiHeight;
     6038  Bool          bILRSearched = false;
     6039
     6040  xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits);
     6041  pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight );
     6042
     6043  for( Int iRefList = 0; iRefList < iNumPredDir; iRefList++)  //list
     6044  {
     6045    if(bILRSearched)
     6046    {
     6047      continue;
     6048    }
     6049
     6050    RefPicList  eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
     6051
     6052    Int  iRefIdxTemp = -1;
     6053    Bool foundILR    = false;
     6054
     6055    for( Int refIdx = 0; refIdx < pcCU->getSlice()->getNumRefIdx(eRefPicList); refIdx++ )
     6056    {
     6057      TComPic* refPic = pcCU->getSlice()->getRefPic(eRefPicList, refIdx);
     6058
     6059      // ILRP has to be for the sample prediction type
     6060      if( refPic->isILR(pcCU->getLayerId()) && refPic->getLayerId() == refLayerId && pcCU->getSlice()->getVPS()->isSamplePredictionType( pcCU->getLayerId(), refLayerId ) )
     6061      {
     6062        iRefIdxTemp = refIdx;
     6063        foundILR    = true;
     6064        bILRSearched = true;
     6065        break;
     6066      }
     6067    }
     6068
     6069    if(!foundILR)  //no ILR in eRefPiclist
     6070    {
     6071      continue; 
     6072    }   
     6073
     6074    uiBitsTemp = uiMbBits[iRefList];
     6075    if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 )
     6076    {
     6077      uiBitsTemp += iRefIdxTemp+1;
     6078      if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--;
     6079    }
     6080
     6081    xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp);
     6082    aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->getMVPIdx(eRefPicList, uiPartAddr);
     6083    aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->getMVPNum(eRefPicList, uiPartAddr);
     6084
     6085    uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS];
     6086
     6087    xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );
     6088    xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp);
     6089
     6090    if( uiCostTemp < uiCost[iRefList] )
     6091    {
     6092      uiCost[iRefList] = uiCostTemp;
     6093
     6094      cMv[iRefList]     = cMvTemp[iRefList][iRefIdxTemp];
     6095      iRefIdx[iRefList] = iRefIdxTemp;
     6096
     6097      pcCU->getCUMvField(eRefPicList)->setAllMv( cMv[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
     6098      pcCU->getCUMvField(eRefPicList)->setAllRefIdx( iRefIdx[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );
     6099    }
     6100  }
     6101
     6102  if( uiCost[0] == MAX_UINT && uiCost[1] == MAX_UINT )  //no ILR in both list0 and list1
     6103  {
     6104    return false;
     6105  }
     6106
     6107  //  Clear Motion Field
     6108  pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx );
     6109  pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx );
     6110  pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd    ( TComMv(),      ePartSize, uiPartAddr, 0, iPartIdx );
     6111  pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd    ( TComMv(),      ePartSize, uiPartAddr, 0, iPartIdx );
     6112
     6113  pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6114  pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6115  pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6116  pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6117
     6118  if( uiCost[0] <= uiCost[1] )  //list0 ILR
     6119  {
     6120    pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv    ( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx );
     6121    pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx );
     6122
     6123    TempMv = cMv[0] - cMvPred[0][iRefIdx[0]];
     6124    pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx );
     6125
     6126    pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
     6127
     6128    pcCU->setMVPIdxSubParts( aaiMvpIdx[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6129    pcCU->setMVPNumSubParts( aaiMvpNum[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6130  }
     6131  else if( uiCost[1] < uiCost[0] )  //list1 ILR
     6132  {
     6133    pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv    ( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx );
     6134    pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx );
     6135
     6136    TempMv = cMv[1] - cMvPred[1][iRefIdx[1]];
     6137    pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx );
     6138
     6139    pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) );
     6140
     6141    pcCU->setMVPIdxSubParts( aaiMvpIdx[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6142    pcCU->setMVPNumSubParts( aaiMvpNum[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr));
     6143  }
     6144  else
     6145  {
     6146    assert(0);
     6147  }
     6148
     6149  pcCU->setMergeFlagSubParts( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) );
     6150
     6151  motionCompensation ( pcCU, rpcPredYuv, REF_PIC_LIST_X, iPartIdx );
     6152  setWpScalingDistParam( pcCU, -1, REF_PIC_LIST_X );
     6153
     6154  return true;
    61086155}
    61096156#endif
  • trunk/source/Lib/TLibEncoder/TEncSearch.h

    r595 r815  
    126126
    127127#if SVC_EXTENSION
    128   TEncTop**       m_ppcTEncTop;
    129128#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    130129  Bool            m_disableILP;
    131130#endif
    132 #endif //SVC_EXTENAION
     131#endif //SVC_EXTENSION
    133132
    134133public:
     
    194193 
    195194  /// encoder estimation - inter prediction (non-skip)
     195#if SVC_EXTENSION
     196  Bool predInterSearch          ( TComDataCU* pcCU,
     197#else
    196198  Void predInterSearch          ( TComDataCU* pcCU,
     199#endif
    197200                                  TComYuv*    pcOrgYuv,
    198201                                  TComYuv*&   rpcPredYuv,
  • trunk/source/Lib/TLibEncoder/TEncTop.cpp

    r713 r815  
    8989#endif
    9090  m_numScaledRefLayerOffsets = 0;
    91 #if POC_RESET_FLAG
     91#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
    9292  m_pocAdjustmentValue     = 0;
    9393#endif
     
    810810
    811811            //only for scalable extension
    812 #if SCALABILITY_MASK_E0104
    813             assert( m_cVPS.getScalabilityMask(2) == true );
    814 #else
    815             assert( m_cVPS.getScalabilityMask(1) == true );
    816 #endif
     812            assert( m_cVPS.getScalabilityMask( SCALABILITY_ID ) == true );
    817813          }
    818814        }
     
    820816#endif
    821817
     818#if SVC_EXTENSION
    822819#if AUXILIARY_PICTURES
    823 #if SVC_UPSAMPLING
    824820      pcEPic->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 ,
    825821                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, &m_cSPS);
    826822#else
    827       pcEPic->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 ,
    828                       m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics);
    829 #endif
    830 #else
    831 #if SVC_UPSAMPLING
    832823      pcEPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 ,
    833824                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, &m_cSPS);
    834 #else
     825#endif
     826#else  //SVC_EXTENSION
    835827      pcEPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, m_cPPS.getMaxCuDQPDepth()+1 ,
    836828                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics);
    837 #endif
    838 #endif
     829#endif //SVC_EXTENSION
    839830      rpcPic = pcEPic;
    840831    }
     
    879870
    880871            //only for scalable extension
    881 #if SCALABILITY_MASK_E0104
    882             assert( m_cVPS.getScalabilityMask(2) == true );
    883 #else
    884             assert( m_cVPS.getScalabilityMask(1) == true );
    885 #endif
     872            assert( m_cVPS.getScalabilityMask( SCALABILITY_ID ) == true );
    886873          }
    887874        }
     
    889876#endif
    890877
     878#if SVC_EXTENSION
    891879#if AUXILIARY_PICTURES
    892 #if SVC_UPSAMPLING
    893880      rpcPic->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    894881                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, &m_cSPS);
    895882#else
    896       rpcPic->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    897                       m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics);
    898 #endif
    899 #else
    900 #if SVC_UPSAMPLING
    901883      rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    902884                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics, &m_cSPS);
    903 #else
     885#endif
     886#else  //SVC_EXTENSION
    904887      rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth,
    905888                      m_conformanceWindow, m_defaultDisplayWindow, m_numReorderPics);
    906 #endif
    907 #endif
     889#endif //SVC_EXTENSION
    908890    }
    909891    m_cListPic.pushBack( rpcPic );
     
    922904{
    923905#if SVC_EXTENSION
     906  m_cSPS.setExtensionFlag( m_layerId > 0 ? true : false );
     907
     908#if Q0078_ADD_LAYER_SETS
     909  if (getNumDirectRefLayers() == 0 && getNumAddLayerSets() > 0)
     910  {
     911    m_cSPS.setLayerId(0); // layer ID 0 for independent layers
     912  }
     913  else
     914  {
     915    m_cSPS.setLayerId(m_layerId);
     916  }
     917#else
    924918  m_cSPS.setLayerId(m_layerId);
     919#endif
    925920  m_cSPS.setNumScaledRefLayerOffsets(m_numScaledRefLayerOffsets);
    926921  for(Int i = 0; i < m_cSPS.getNumScaledRefLayerOffsets(); i++)
     
    10821077Void TEncTop::xInitPPS()
    10831078{
    1084 #if SCALINGLIST_INFERRING
    1085   m_cPPS.setLayerId( m_layerId );
    1086 #endif
    1087 
    10881079  m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred );
    10891080  Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false;
     
    11811172  }
    11821173#if SVC_EXTENSION
    1183   if (!m_layerId)
     1174#if SCALINGLIST_INFERRING
     1175  m_cPPS.setLayerId( m_layerId );
     1176#endif
     1177
     1178#if Q0078_ADD_LAYER_SETS
     1179  if (getNumDirectRefLayers() == 0 && getNumAddLayerSets() > 0)
     1180  {
     1181    m_cPPS.setLayerId(0); // layer ID 0 for independent layers
     1182  }
     1183#endif
     1184
     1185  if( m_layerId > 0 )
     1186  {
     1187    m_cPPS.setListsModificationPresentFlag(true);
     1188    m_cPPS.setExtensionFlag(true);
     1189  }
     1190  else
    11841191  {
    11851192    m_cPPS.setListsModificationPresentFlag(false);
    1186   }
    1187   else
    1188   {
    1189     m_cPPS.setListsModificationPresentFlag(true);
    1190   }
    1191 
    1192   m_cPPS.setPPSId         ( m_iPPSIdCnt         );
    1193   m_cPPS.setSPSId         ( m_iSPSIdCnt         );
    1194 #endif
     1193    m_cPPS.setExtensionFlag(false);
     1194  }
     1195
     1196  m_cPPS.setPPSId( m_iPPSIdCnt );
     1197  m_cPPS.setSPSId( m_iSPSIdCnt );
    11951198#if POC_RESET_FLAG
    11961199  m_cPPS.setNumExtraSliceHeaderBits( 2 );
     
    12051208  m_cPPS.setCGSFlag( m_nCGSFlag );
    12061209#endif
     1210#if POC_RESET_IDC_ENCODER
     1211  m_cPPS.setPocResetInfoPresentFlag( true );
     1212  m_cPPS.setExtensionFlag( true );
     1213  m_cPPS.setSliceHeaderExtensionPresentFlag( true );
     1214#endif
     1215#endif //SVC_EXTENSION
    12071216}
    12081217
     
    15821591      {
    15831592        m_cIlpPic[j] = new  TComPic;
    1584 #if SVC_UPSAMPLING
    15851593#if AUXILIARY_PICTURES
    15861594        m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true);
    15871595#else
    15881596        m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true);
    1589 #endif
    1590 #else
    1591         m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    15921597#endif
    15931598        for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++)
     
    16491654      {
    16501655        m_cIlpPic[j] = new  TComPic;
    1651 #if SVC_UPSAMPLING
    16521656#if AUXILIARY_PICTURES
    16531657        m_cIlpPic[j]->create(picWidth, picHeight, m_chromaFormatIDC, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true);
    16541658#else
    16551659        m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true);
    1656 #endif
    1657 #else
    1658         m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true);
    16591660#endif
    16601661        for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++)
  • trunk/source/Lib/TLibEncoder/TEncTop.h

    r713 r815  
    142142  Bool                    m_vertPhasePositionEnableFlag[MAX_LAYERS];
    143143#endif
    144 #if POC_RESET_FLAG
     144#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
    145145  Int                     m_pocAdjustmentValue;
    146146#endif
     
    153153#if O0194_WEIGHTED_PREDICTION_CGS
    154154  Bool                    m_interLayerWeightedPredFlag;
     155#endif
     156#if Q0078_ADD_LAYER_SETS
     157  int                     m_numAddLayerSets;
    155158#endif
    156159#endif //SVC_EXTENSION
     
    254257  TEncTop*  getRefLayerEnc(UInt refLayerIdc);
    255258#endif
    256 #if POC_RESET_FLAG
     259#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
    257260  Int       getPocAdjustmentValue()      { return m_pocAdjustmentValue;}
    258261  Void      setPocAdjustmentValue(Int x) { m_pocAdjustmentValue = x;   }
     
    268271  Void setNoOutputOfPriorPicsFlags(Bool x)   { m_noOutputOfPriorPicsFlags = x;   }
    269272#endif
     273#if Q0078_ADD_LAYER_SETS
     274  Void setNumAddLayerSets(Int x)             { m_numAddLayerSets = x; }
     275  Int  getNumAddLayerSets()                  { return m_numAddLayerSets; }
     276#endif
    270277#else //SVC_EXTENSION
    271278  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
Note: See TracChangeset for help on using the changeset viewer.