Ignore:
Timestamp:
25 Jun 2015, 16:19:05 (9 years ago)
Author:
seregin
Message:

Patch provided by Hiron Franck <franck.hiron@…> to complete implementation of the CRI (Colour remapping info) with the following features:

  • Management of SEI-CRI messages per picture
  • Management of the persistence of the colour remapping information (parameter “colour_remap_persistence_flag”)
  • Output the remapping picture in display order
  • Maintains the HM like mode (#define SVC_EXTENSION 0)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp

    r1087 r1089  
    146146  m_codedPivotValue = NULL;
    147147  m_targetPivotValue = NULL;
    148 #if Q0074_COLOUR_REMAPPING_SEI
    149   for( Int c=0 ; c<3 ; c++)
    150   {
    151     m_colourRemapSEIPreLutCodedValue[c]   = NULL;
    152     m_colourRemapSEIPreLutTargetValue[c]  = NULL;
    153     m_colourRemapSEIPostLutCodedValue[c]  = NULL;
    154     m_colourRemapSEIPostLutTargetValue[c] = NULL;
    155   }
    156 #endif
    157148}
    158149#endif
     
    193184  free(m_pchReconFile);
    194185  free(m_pchdQPFile);
    195 #if Q0074_COLOUR_REMAPPING_SEI
    196   for( Int c=0 ; c<3 ; c++)
    197   {
    198     if ( m_colourRemapSEIPreLutCodedValue[c] )
    199     {
    200       delete[] m_colourRemapSEIPreLutCodedValue[c];
    201     }
    202     if ( m_colourRemapSEIPreLutTargetValue[c] )
    203     {
    204       delete[] m_colourRemapSEIPreLutTargetValue[c];
    205     }
    206     if ( m_colourRemapSEIPostLutCodedValue[c] )
    207     {
    208       delete[] m_colourRemapSEIPostLutCodedValue[c];
    209     }
    210     if ( m_colourRemapSEIPostLutTargetValue[c] )
    211     {
    212       delete[] m_colourRemapSEIPostLutTargetValue[c];
    213     }
    214   }
    215 #endif
    216186#endif
    217187  free(m_scalingListFile);
     
    885855  Int*    cfg_maxTidIlRefPicsPlus1[MAX_LAYERS];
    886856#if Q0074_COLOUR_REMAPPING_SEI
    887   string* cfg_colourRemapSEIFile[MAX_LAYERS];
     857  string* cfg_colourRemapSEIFileRoot[MAX_LAYERS];
    888858#endif
    889859  Int*    cfg_waveFrontSynchro[MAX_LAYERS];
     
    907877    cfg_fQP[layer]          = &m_acLayerCfg[layer].m_fQP;
    908878#if Q0074_COLOUR_REMAPPING_SEI
    909     cfg_colourRemapSEIFile[layer] = &m_acLayerCfg[layer].m_colourRemapSEIFile;
     879    cfg_colourRemapSEIFileRoot[layer] = &m_acLayerCfg[layer].m_colourRemapSEIFileRoot;
    910880#endif
    911881#if REPN_FORMAT_IN_VPS
     
    10401010  string cfg_dQPFile;
    10411011#if Q0074_COLOUR_REMAPPING_SEI
    1042   string cfg_colourRemapSEIFile;
     1012  string cfg_colourRemapSEIFileRoot;
    10431013#endif
    10441014#endif //SVC_EXTENSION
     
    12181188#endif
    12191189#if Q0074_COLOUR_REMAPPING_SEI
    1220   ("SEIColourRemappingInfoFile%d",                   cfg_colourRemapSEIFile,           string(""), MAX_LAYERS, "Colour Remapping Information SEI parameters file name for layer %d")
     1190  ("SEIColourRemappingInfoFileRoot%d",              cfg_colourRemapSEIFileRoot,           string(""), MAX_LAYERS, "Colour Remapping Information SEI parameters file name for layer %d")
    12211191#endif
    12221192#if O0194_DIFFERENT_BITDEPTH_EL_BL
     
    12931263  ("FrameRate,-fr",                                   m_iFrameRate,                                         0, "Frame rate")
    12941264#if Q0074_COLOUR_REMAPPING_SEI
    1295   ("SEIColourRemappingInfoFile",                      cfg_colourRemapSEIFile, string(""), "Colour Remapping Information SEI parameters file name")
     1265  ("SEIColourRemappingInfoFileRoot",                  cfg_colourRemapSEIFileRoot, string(""), "Colour Remapping Information SEI parameters file name")
    12961266#endif
    12971267#endif //SVC_EXTENSION
     
    18691839  m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
    18701840#if Q0074_COLOUR_REMAPPING_SEI
    1871   m_colourRemapSEIFile = cfg_colourRemapSEIFile.empty() ? NULL : strdup(cfg_colourRemapSEIFile.c_str());
     1841  m_colourRemapSEIFileRoot = cfg_colourRemapSEIFileRoot.empty() ? NULL : strdup(cfg_colourRemapSEIFileRoot.c_str());
    18721842#endif
    18731843#endif //SVC_EXTENSION
     
    30292999  }
    30303000#endif
    3031 #if Q0074_COLOUR_REMAPPING_SEI
    3032 #if !SVC_EXTENSION
    3033   // reading external Colour Remapping Information SEI message parameters from file
    3034   if( m_colourRemapSEIFile )
    3035   {
    3036     FILE* fic;
    3037     Int retval;
    3038     if((fic = fopen(m_colourRemapSEIFile,"r")) == (FILE*)NULL)
    3039     {
    3040       fprintf(stderr, "Can't open Colour Remapping Information SEI parameters file %s\n", m_colourRemapSEIFile);
    3041       exit(EXIT_FAILURE);
    3042     }
    3043 
    3044     retval = fscanf( fic, "%d", &m_colourRemapSEIId );
    3045     retval = fscanf( fic, "%d", &m_colourRemapSEICancelFlag );
    3046     if( !m_colourRemapSEICancelFlag )
    3047     {
    3048       retval = fscanf( fic, "%d", &m_colourRemapSEIPersistenceFlag );
    3049       retval = fscanf( fic, "%d", &m_colourRemapSEIVideoSignalInfoPresentFlag);
    3050       if( m_colourRemapSEIVideoSignalInfoPresentFlag )
    3051       {
    3052         retval = fscanf( fic, "%d", &m_colourRemapSEIFullRangeFlag  );
    3053         retval = fscanf( fic, "%d", &m_colourRemapSEIPrimaries );
    3054         retval = fscanf( fic, "%d", &m_colourRemapSEITransferFunction );
    3055         retval = fscanf( fic, "%d", &m_colourRemapSEIMatrixCoefficients );
    3056       }
    3057 
    3058       retval = fscanf( fic, "%d", &m_colourRemapSEIInputBitDepth );
    3059       retval = fscanf( fic, "%d", &m_colourRemapSEIBitDepth );
    3060  
    3061       for( Int c=0 ; c<3 ; c++ )
    3062       {
    3063         retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutNumValMinus1[c] );
    3064         if( m_colourRemapSEIPreLutNumValMinus1[c]>0 )
    3065         {
    3066           m_colourRemapSEIPreLutCodedValue[c]  = new Int[m_colourRemapSEIPreLutNumValMinus1[c]+1];
    3067           m_colourRemapSEIPreLutTargetValue[c] = new Int[m_colourRemapSEIPreLutNumValMinus1[c]+1];
    3068           for( Int i=0 ; i<=m_colourRemapSEIPreLutNumValMinus1[c] ; i++ )
    3069           {
    3070             retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutCodedValue[c][i] );
    3071             retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutTargetValue[c][i] );
    3072           }
    3073         }
    3074       }
    3075 
    3076       retval = fscanf( fic, "%d", &m_colourRemapSEIMatrixPresentFlag );
    3077       if( m_colourRemapSEIMatrixPresentFlag )
    3078       {
    3079         retval = fscanf( fic, "%d", &m_colourRemapSEILog2MatrixDenom );
    3080         for( Int c=0 ; c<3 ; c++ )
    3081           for( Int i=0 ; i<3 ; i++ )
    3082             retval = fscanf( fic, "%d", &m_colourRemapSEICoeffs[c][i] );
    3083       }
    3084 
    3085       for( Int c=0 ; c<3 ; c++ )
    3086       {
    3087         retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutNumValMinus1[c] );
    3088         if( m_colourRemapSEIPostLutNumValMinus1[c]>0 )
    3089         {
    3090           m_colourRemapSEIPostLutCodedValue[c]  = new Int[m_colourRemapSEIPostLutNumValMinus1[c]+1];
    3091           m_colourRemapSEIPostLutTargetValue[c] = new Int[m_colourRemapSEIPostLutNumValMinus1[c]+1];
    3092           for( Int i=0 ; i<=m_colourRemapSEIPostLutNumValMinus1[c] ; i++ )
    3093           {
    3094             retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutCodedValue[c][i] );
    3095             retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutTargetValue[c][i] );
    3096           }
    3097         }
    3098       }
    3099     }
    3100 
    3101     fclose( fic );
    3102     if( retval != 1 )
    3103     {
    3104       fprintf(stderr, "Error while reading Colour Remapping Information SEI parameters file\n");
    3105       exit(EXIT_FAILURE);
    3106     }
    3107   }
    3108 #else
    3109    // Reading external Colour Remapping Information SEI message parameters from file
    3110   // It seems that TAppEncLayerCfg::parseCfg is not used
    3111   for(UInt layer = 0; layer < m_numLayers; layer++)
    3112   {
    3113     if( cfg_colourRemapSEIFile[layer]->length() )
    3114     {
    3115       FILE* fic;
    3116       Int retval;
    3117       if((fic = fopen(cfg_colourRemapSEIFile[layer]->c_str(),"r")) == (FILE*)NULL)
    3118       {
    3119         fprintf(stderr, "Can't open Colour Remapping Information SEI parameters file %s\n", cfg_colourRemapSEIFile[layer]->c_str());
    3120         exit(EXIT_FAILURE);
    3121       }
    3122       Int tempCode;
    3123       retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIId );
    3124       retval = fscanf( fic, "%d", &tempCode ); m_acLayerCfg[layer].m_colourRemapSEICancelFlag = tempCode ? 1 : 0;
    3125       if( !m_acLayerCfg[layer].m_colourRemapSEICancelFlag )
    3126       {
    3127         retval = fscanf( fic, "%d", &tempCode ); m_acLayerCfg[layer].m_colourRemapSEIPersistenceFlag = tempCode ? 1 : 0;
    3128         retval = fscanf( fic, "%d", &tempCode ); m_acLayerCfg[layer].m_colourRemapSEIVideoSignalInfoPresentFlag = tempCode ? 1 : 0;
    3129         if( m_acLayerCfg[layer].m_colourRemapSEIVideoSignalInfoPresentFlag )
    3130         {
    3131           retval = fscanf( fic, "%d", &tempCode ); m_acLayerCfg[layer].m_colourRemapSEIFullRangeFlag = tempCode ? 1 : 0;
    3132           retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPrimaries );
    3133           retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEITransferFunction );
    3134           retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIMatrixCoefficients );
    3135         }
    3136 
    3137         retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIInputBitDepth );
    3138         retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIBitDepth );
    3139  
    3140         for( Int c=0 ; c<3 ; c++ )
    3141         {
    3142           retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c] );
    3143           if( m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c]>0 )
    3144           {
    3145             m_acLayerCfg[layer].m_colourRemapSEIPreLutCodedValue[c]  = new Int[m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c]+1];
    3146             m_acLayerCfg[layer].m_colourRemapSEIPreLutTargetValue[c] = new Int[m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c]+1];
    3147             for( Int i=0 ; i<=m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c] ; i++ )
    3148             {
    3149               retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPreLutCodedValue[c][i] );
    3150               retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPreLutTargetValue[c][i] );
    3151             }
    3152           }
    3153         }
    3154 
    3155         retval = fscanf( fic, "%d", &tempCode ); m_acLayerCfg[layer].m_colourRemapSEIMatrixPresentFlag = tempCode ? 1 : 0;
    3156         if( m_acLayerCfg[layer].m_colourRemapSEIMatrixPresentFlag )
    3157         {
    3158           retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEILog2MatrixDenom );
    3159           for( Int c=0 ; c<3 ; c++ )
    3160             for( Int i=0 ; i<3 ; i++ )
    3161               retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEICoeffs[c][i] );
    3162         }
    3163 
    3164         for( Int c=0 ; c<3 ; c++ )
    3165         {
    3166           retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c] );
    3167           if( m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c]>0 )
    3168           {
    3169             m_acLayerCfg[layer].m_colourRemapSEIPostLutCodedValue[c]  = new Int[m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c]+1];
    3170             m_acLayerCfg[layer].m_colourRemapSEIPostLutTargetValue[c] = new Int[m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c]+1];
    3171             for( Int i=0 ; i<=m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c] ; i++ )
    3172             {
    3173               retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPostLutCodedValue[c][i] );
    3174               retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPostLutTargetValue[c][i] );
    3175             }
    3176           }
    3177         }
    3178       }
    3179 
    3180       fclose( fic );
    3181       if( retval != 1 )
    3182       {
    3183         fprintf(stderr, "Error while reading Colour Remapping Information SEI parameters file\n");
    3184         exit(EXIT_FAILURE);
    3185       }
    3186     }
    3187   }
    3188 #endif
    3189 #endif
     3001
    31903002#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    31913003  if (m_interLayerConstrainedTileSetsSEIEnabled)
     
    45234335  }
    45244336#endif
    4525 #if Q0074_COLOUR_REMAPPING_SEI
    4526 #if !SVC_EXTENSION
    4527   if ( m_colourRemapSEIFile && !m_colourRemapSEICancelFlag )
    4528   {
    4529     xConfirmPara( m_colourRemapSEIInputBitDepth < 8 || m_colourRemapSEIInputBitDepth > 16 , "colour_remap_input_bit_depth shall be in the range of 8 to 16, inclusive");
    4530     xConfirmPara( m_colourRemapSEIBitDepth < 8 || m_colourRemapSEIBitDepth > 16, "colour_remap_bit_depth shall be in the range of 8 to 16, inclusive");
    4531     for( Int c=0 ; c<3 ; c++)
    4532     {
    4533       xConfirmPara( m_colourRemapSEIPreLutNumValMinus1[c] < 0 || m_colourRemapSEIPreLutNumValMinus1[c] > 32, "pre_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");
    4534       if( m_colourRemapSEIPreLutNumValMinus1[c]>0 )
    4535         for( Int i=0 ; i<=m_colourRemapSEIPreLutNumValMinus1[c] ; i++)
    4536         {
    4537           xConfirmPara( m_colourRemapSEIPreLutCodedValue[c][i] < 0 || m_colourRemapSEIPreLutCodedValue[c][i] > ((1<<m_colourRemapSEIInputBitDepth)-1), "pre_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_input_bit_depth)-1, inclusive");
    4538           xConfirmPara( m_colourRemapSEIPreLutTargetValue[c][i] < 0 || m_colourRemapSEIPreLutTargetValue[c][i] > ((1<<m_colourRemapSEIBitDepth)-1), "pre_lut_target_value[c][i] shall be in the range of 0 to (1<<colour_remap_bit_depth)-1, inclusive");
    4539         }
    4540       xConfirmPara( m_colourRemapSEIPostLutNumValMinus1[c] < 0 || m_colourRemapSEIPostLutNumValMinus1[c] > 32, "post_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");
    4541       if( m_colourRemapSEIPostLutNumValMinus1[c]>0 )
    4542         for( Int i=0 ; i<=m_colourRemapSEIPostLutNumValMinus1[c] ; i++)
    4543         {
    4544           xConfirmPara( m_colourRemapSEIPostLutCodedValue[c][i] < 0 || m_colourRemapSEIPostLutCodedValue[c][i] > ((1<<m_colourRemapSEIBitDepth)-1), "post_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_bit_depth)-1, inclusive");
    4545           xConfirmPara( m_colourRemapSEIPostLutTargetValue[c][i] < 0 || m_colourRemapSEIPostLutTargetValue[c][i] > ((1<<m_colourRemapSEIBitDepth)-1), "post_lut_target_value[c][i] shall be in the range of 0 to (1<<colour_remap_bit_depth)-1, inclusive");
    4546         }
    4547     }
    4548     if ( m_colourRemapSEIMatrixPresentFlag )
    4549     {
    4550       xConfirmPara( m_colourRemapSEILog2MatrixDenom < 0 || m_colourRemapSEILog2MatrixDenom > 15, "log2_matrix_denom shall be in the range of 0 to 15, inclusive");
    4551       for( Int c=0 ; c<3 ; c++)
    4552         for( Int i=0 ; i<3 ; i++)
    4553           xConfirmPara( m_colourRemapSEICoeffs[c][i] < -32768 || m_colourRemapSEICoeffs[c][i] > 32767, "colour_remap_coeffs[c][i] shall be in the range of -32768 and 32767, inclusive");
    4554     }
    4555   }
    4556 #endif
    4557 #endif
    45584337
    45594338#if RC_SHVC_HARMONIZATION
Note: See TracChangeset for help on using the changeset viewer.