Changeset 694 in SHVCSoftware for branches/SHM-6-dev/source/Lib/TLibEncoder


Ignore:
Timestamp:
18 Apr 2014, 19:14:51 (11 years ago)
Author:
seregin
Message:

commit the patch implementing JCTVC-Q0074 provided by Bordes Philippe <philippe.bordes@…>

Location:
branches/SHM-6-dev/source/Lib/TLibEncoder
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-6-dev/source/Lib/TLibEncoder/SEIwrite.cpp

    r652 r694  
    8787    fprintf( g_hTrace, "=========== Tone Mapping Info SEI message ===========\n");
    8888    break;
     89#if Q0074_SEI_COLOR_MAPPING
     90  case SEI::COLOR_MAPPING_INFO:
     91    fprintf( g_hTrace, "=========== Color Mapping Info SEI message ===========\n");
     92    break;
     93#endif
    8994  case SEI::SOP_DESCRIPTION:
    9095    fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n");
     
    172177    xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei));
    173178    break;
     179#if Q0074_SEI_COLOR_MAPPING
     180  case SEI::COLOR_MAPPING_INFO:
     181    xWriteSEIColorMappingInfo(*static_cast<const SEIColorMappingInfo*>(&sei));
     182    break;
     183#endif
    174184  case SEI::SOP_DESCRIPTION:
    175185    xWriteSEISOPDescription(*static_cast<const SEISOPDescription*>(&sei));
     
    566576}
    567577
     578#if Q0074_SEI_COLOR_MAPPING
     579Void SEIWriter::xWriteSEIColorMappingInfo(const SEIColorMappingInfo& sei)
     580{
     581  WRITE_UVLC( sei.m_colorMapId,                    "colour_map_id" );
     582  WRITE_FLAG( sei.m_colorMapCancelFlag,            "colour_map_cancel_flag" );
     583  if( !sei.m_colorMapCancelFlag )
     584  {
     585    WRITE_FLAG( sei.m_colorMapPersistenceFlag,            "colour_map_persistence_flag" );
     586    WRITE_FLAG( sei.m_colorMap_video_signal_type_present_flag,            "colour_map_video_signal_type_present_flag" );
     587    if ( sei.m_colorMap_video_signal_type_present_flag )
     588    {
     589      WRITE_FLAG( sei.m_colorMap_video_full_range_flag,       "colour_map_video_full_range_flag" );
     590      WRITE_CODE( sei.m_colorMap_primaries,                 8,      "colour_map_primaries" );
     591      WRITE_CODE( sei.m_colorMap_transfer_characteristics,  8,      "colour_map_transfer_characteristics" );
     592      WRITE_CODE( sei.m_colorMap_matrix_coeffs,             8,      "colour_map_matrix_coeffs" );
     593    }
     594  }
     595
     596  WRITE_CODE( sei.m_colour_map_coded_data_bit_depth,  5,  "colour_map_coded_data_bit_depth" );
     597  WRITE_CODE( sei.m_colour_map_target_bit_depth,  5,      "colour_map_target_bit_depth" );
     598  WRITE_UVLC( sei.m_colorMapModelId,                      "colour_map_model_id" );
     599
     600  assert( sei.m_colorMapModelId == 0 );
     601 
     602  for( Int i=0 ; i<3 ; i++ )
     603  {
     604    WRITE_CODE( sei.m_num_input_pivots[i] - 1,         8,      "num_input_pivots_minus1[i]" );
     605    for( Int j=0 ; j<sei.m_num_input_pivots[i] ; j++ )
     606    {
     607      WRITE_CODE( sei.m_coded_input_pivot_value[i][j],  (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "coded_input_pivot_value[i][j]" );
     608      WRITE_CODE( sei.m_target_input_pivot_value[i][j], (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "target_input_pivot_value[i][j]" );
     609    }
     610  }
     611
     612  WRITE_FLAG( sei.m_matrix_flag,            "matrix_flag" );
     613  if( sei.m_matrix_flag )
     614  {
     615    WRITE_CODE( sei.m_log2_matrix_denom, 4, "log2_matrix_denom" );
     616    for( Int i=0 ; i<3 ; i++ )
     617    {
     618      for( Int j=0 ; j<3 ; j++ )
     619      {
     620        WRITE_SVLC( sei.m_matrix_coef[i][j],  "matrix_coef[i][j]" );
     621      }
     622    }
     623  }
     624
     625  for( Int i=0 ; i<3 ; i++ )
     626  {
     627    WRITE_CODE( sei.m_num_output_pivots[i] - 1,         8,      "num_output_pivots_minus1[i]" );
     628    for( Int j=0 ; j<sei.m_num_output_pivots[i] ; j++ )
     629    {
     630      WRITE_CODE( sei.m_coded_output_pivot_value[i][j],  (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "coded_output_pivot_value[i][j]" );
     631      WRITE_CODE( sei.m_target_output_pivot_value[i][j], (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "target_output_pivot_value[i][j]" );
     632    }
     633  }
     634
     635  xWriteByteAlign();
     636}
     637#endif
     638
    568639Void SEIWriter::xWriteSEIDisplayOrientation(const SEIDisplayOrientation &sei)
    569640{
  • branches/SHM-6-dev/source/Lib/TLibEncoder/SEIwrite.h

    r644 r694  
    7272  Void xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei);
    7373  Void xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei);
     74#if Q0074_SEI_COLOR_MAPPING
     75  Void SEIWriter::xWriteSEIColorMappingInfo(const SEIColorMappingInfo& sei);
     76#endif
    7477  Void xWriteSEISOPDescription(const SEISOPDescription& sei);
    7578#if O0164_MULTI_LAYER_HRD
  • branches/SHM-6-dev/source/Lib/TLibEncoder/TEncCfg.h

    r684 r694  
    248248  Int*      m_codedPivotValue;
    249249  Int*      m_targetPivotValue;
     250#if Q0074_SEI_COLOR_MAPPING
     251  Char*     m_seiColorMappingFile;
     252#endif
    250253  Int       m_framePackingSEIEnabled;
    251254  Int       m_framePackingSEIType;
     
    667670  Void  setTMISEIExtendedWhiteLevelLumaCodeValue(Int b)      {  m_extendedWhiteLevelLumaCodeValue =b;  }
    668671  Int   getTMISEIExtendedWhiteLevelLumaCodeValue()           {  return m_extendedWhiteLevelLumaCodeValue;  }
     672#if Q0074_SEI_COLOR_MAPPING
     673  Void  setColorMappingInfoSEIFile( Char* nameFile )         {  m_seiColorMappingFile = nameFile; }
     674  Char* getColorMappingInfoSEIFile()                         {  return m_seiColorMappingFile; }
     675#endif
    669676  Void  setFramePackingArrangementSEIEnabled(Int b)      { m_framePackingSEIEnabled = b; }
    670677  Int   getFramePackingArrangementSEIEnabled()           { return m_framePackingSEIEnabled; }
  • branches/SHM-6-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r693 r694  
    327327}
    328328
     329#if Q0074_SEI_COLOR_MAPPING
     330SEIColorMappingInfo*  TEncGOP::xCreateSEIColorMappingInfo( Char* file )
     331{
     332  SEIColorMappingInfo *seiColorMappingInfo = new SEIColorMappingInfo();
     333
     334  FILE* fic = fopen( file, "r" );
     335
     336  Int iVal;
     337
     338  fscanf( fic, "%d", &seiColorMappingInfo->m_colorMapId );
     339  fscanf( fic, "%d", &iVal );
     340  seiColorMappingInfo->m_colorMapCancelFlag = iVal;
     341  if( !seiColorMappingInfo->m_colorMapCancelFlag )
     342  {
     343    fscanf( fic, "%d", &iVal );
     344    seiColorMappingInfo->m_colorMapPersistenceFlag = iVal;
     345    fscanf( fic, "%d", &iVal );
     346    seiColorMappingInfo->m_colorMap_video_signal_type_present_flag = iVal;
     347    if( seiColorMappingInfo->m_colorMap_video_signal_type_present_flag )
     348    {
     349      fscanf( fic, "%d", &iVal );
     350      seiColorMappingInfo->m_colorMap_video_full_range_flag = iVal;
     351      fscanf( fic, "%d", &seiColorMappingInfo->m_colorMap_primaries );
     352      fscanf( fic, "%d", &seiColorMappingInfo->m_colorMap_transfer_characteristics );
     353      fscanf( fic, "%d", &seiColorMappingInfo->m_colorMap_matrix_coeffs );
     354    }
     355  }
     356
     357  fscanf( fic, "%d", &seiColorMappingInfo->m_colour_map_coded_data_bit_depth );
     358  fscanf( fic, "%d", &seiColorMappingInfo->m_colour_map_target_bit_depth );
     359  fscanf( fic, "%d", &iVal );
     360  seiColorMappingInfo->m_colorMapModelId = iVal;
     361
     362  assert( seiColorMappingInfo->m_colorMapModelId == 0 );
     363 
     364  for( Int i=0 ; i<3 ; i++ )
     365  {
     366    fscanf( fic, "%d", &seiColorMappingInfo->m_num_input_pivots[i] );
     367    seiColorMappingInfo->m_coded_input_pivot_value[i]   = new Int[ seiColorMappingInfo->m_num_input_pivots[i] ];
     368    seiColorMappingInfo->m_target_input_pivot_value[i]  = new Int[ seiColorMappingInfo->m_num_input_pivots[i] ];
     369    for( Int j=0 ; j<seiColorMappingInfo->m_num_input_pivots[i] ; j++ )
     370    {
     371      fscanf( fic, "%d", &seiColorMappingInfo->m_coded_input_pivot_value[i][j] );
     372      fscanf( fic, "%d", &seiColorMappingInfo->m_target_input_pivot_value[i][j] );
     373    }
     374  }
     375
     376  fscanf( fic, "%d", &iVal );
     377  seiColorMappingInfo->m_matrix_flag = iVal;
     378  if( seiColorMappingInfo->m_matrix_flag )
     379  {
     380    fscanf( fic, "%d", &seiColorMappingInfo->m_log2_matrix_denom );
     381    for( Int i=0 ; i<3 ; i++ )
     382    {
     383      for( Int j=0 ; j<3 ; j++ )
     384      {
     385        fscanf( fic, "%d", &seiColorMappingInfo->m_matrix_coef[i][j] );
     386      }
     387    }
     388  }
     389
     390  for( Int i=0 ; i<3 ; i++ )
     391  {
     392    fscanf( fic, "%d", &seiColorMappingInfo->m_num_output_pivots[i] );
     393    seiColorMappingInfo->m_coded_output_pivot_value[i]   = new Int[ seiColorMappingInfo->m_num_output_pivots[i] ];
     394    seiColorMappingInfo->m_target_output_pivot_value[i]  = new Int[ seiColorMappingInfo->m_num_output_pivots[i] ];
     395    for( Int j=0 ; j<seiColorMappingInfo->m_num_output_pivots[i] ; j++ )
     396    {
     397      fscanf( fic, "%d", &seiColorMappingInfo->m_coded_output_pivot_value[i][j] );
     398      fscanf( fic, "%d", &seiColorMappingInfo->m_target_output_pivot_value[i][j] );
     399    }
     400  }
     401
     402  fclose( fic );
     403
     404  return seiColorMappingInfo;
     405}
     406#endif
     407
    329408Void TEncGOP::xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps)
    330409{
     
    393472    delete sei;
    394473  }
     474#if Q0074_SEI_COLOR_MAPPING
     475  if(m_pcCfg->getColorMappingInfoSEIFile())
     476  {
     477    SEIColorMappingInfo *sei = xCreateSEIColorMappingInfo( m_pcCfg->getColorMappingInfoSEIFile() );
     478     
     479#if SVC_EXTENSION
     480    nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, m_layerId);  // temporalId = 0 ?
     481#else
     482    nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
     483#endif
     484    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     485#if O0164_MULTI_LAYER_HRD
     486    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
     487#else
     488    m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
     489#endif
     490    writeRBSPTrailingBits(nalu.m_Bitstream);
     491    accessUnit.push_back(new NALUnitEBSP(nalu));
     492    delete sei;
     493  }
     494#endif
    395495
    396496#if SVC_EXTENSION
  • branches/SHM-6-dev/source/Lib/TLibEncoder/TEncGOP.h

    r677 r694  
    209209
    210210  SEIToneMappingInfo*     xCreateSEIToneMappingInfo();
     211#if Q0074_SEI_COLOR_MAPPING
     212  SEIColorMappingInfo*    xCreateSEIColorMappingInfo( Char* file );
     213#endif
    211214
    212215  Void xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps);
Note: See TracChangeset for help on using the changeset viewer.