Commit e7529586 authored by Marek Szczerba's avatar Marek Szczerba
Browse files

Contribution 37 - Control metadata for reverb

parent de6eaffe
Loading
Loading
Loading
Loading
+60 −2
Original line number Diff line number Diff line
@@ -76,6 +76,10 @@ static
#define IVAS_PUBLIC_ORIENT_TRK_REF_VEC     ( 3 )
#define IVAS_PUBLIC_ORIENT_TRK_REF_VEC_LEV ( 4 )

#ifdef CONTROL_METADATA_REVERB
#define ACOUSTIC_ENVIRONMENT_ID    0
#endif

typedef struct
{
    char *inputBitstreamFilename;
@@ -229,7 +233,11 @@ int main(
    if ( arg.hrtfReaderEnabled )
    {
        /* sanity check */
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_REVERB )
#else
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM )
#endif
        {
            arg.hrtfReaderEnabled = false;
            fprintf( stderr, "\nError: HRTF binary file cannot be used in this output configuration.\n\n" );
@@ -251,7 +259,11 @@ int main(
    if ( arg.enableHeadRotation )
    {
        /* sanity check */
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_REVERB )
#else
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM )
#endif
        {
            fprintf( stderr, "\nError: Head-rotation file file cannot be used in this output configuration.\n\n" );
            goto cleanup;
@@ -271,7 +283,7 @@ int main(
    if ( arg.enableReferenceRotation )
    {
        /* sanity check */
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM )
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_REVERB )
        {
            fprintf( stderr, "\nError: Reference rotation file cannot be used in this output configuration.\n\n" );
            goto cleanup;
@@ -298,7 +310,7 @@ int main(
    if ( arg.enableReferenceVectorTracking )
    {
        /* sanity check */
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM )
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_REVERB )
        {
            fprintf( stderr, "\nError: Reference vector trajectory file cannot be used in this output configuration.\n\n" );
            goto cleanup;
@@ -338,7 +350,11 @@ int main(
    if ( arg.renderConfigEnabled )
    {
        /* sanity check */
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_REVERB )
#else
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM )
#endif
        {
            fprintf( stderr, "\nError: Renderer configuration file cannot be used in this output configuration.\n\n" );
            goto cleanup;
@@ -461,9 +477,17 @@ int main(
        IVAS_RENDER_CONFIG_DATA renderConfig;

        /* sanity check */
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_REVERB && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL )
#else
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL )
#endif
        {
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
            fprintf( stderr, "\nExternal Renderer Config is supported only for BINAURAL, BINAURAL_ROOM, and BINAURAL_REVERB. Exiting. \n\n" );
#else
            fprintf( stderr, "\nExternal Renderer Config is supported only for BINAURAL and BINAURAL_ROOM. Exiting. \n\n" );
#endif
            goto cleanup;
        }

@@ -473,12 +497,36 @@ int main(
            goto cleanup;
        }

#ifdef CONTROL_METADATA_REVERB
        if ( RenderConfigReader_read( renderConfigReader ) != IVAS_ERR_OK )
#else
        if ( RenderConfigReader_read( renderConfigReader, &renderConfig ) != IVAS_ERR_OK )
#endif
        {
            fprintf( stderr, "Failed to read renderer configuration from file %s\n\n", arg.renderConfigFilename );
            goto cleanup;
        }

#ifdef CONTROL_METADATA_REVERB
        if ( RenderConfigReader_getAcousticEnvironment( renderConfigReader, ACOUSTIC_ENVIRONMENT_ID, &renderConfig.room_acoustics ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", ACOUSTIC_ENVIRONMENT_ID );
            goto cleanup;
        }

#ifdef COMMAND_LINE_OPTION_LATE_REVERB
        if ( arg.outputFormat == IVAS_DEC_OUTPUT_BINAURAL_REVERB )
        {
            renderConfig.room_acoustics.late_reverb_on = true;
            renderConfig.room_acoustics.override = true;
            renderConfig.room_acoustics.use_brir = false;
        }
#else
        renderConfig.room_acoustics.late_reverb_on = true;
        renderConfig.room_acoustics.override = true;
#endif
#endif

        if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
@@ -721,6 +769,12 @@ static IVAS_DEC_AUDIO_CONFIG cmdline2config(
    {
        output_config = IVAS_DEC_OUTPUT_BINAURAL_ROOM;
    }
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
    else if ( strcmp( argv_to_upper, "BINAURAL_REVERB" ) == 0 )
    {
        output_config = IVAS_DEC_OUTPUT_BINAURAL_REVERB;
    }
#endif
    else
    {
        output_config = IVAS_DEC_OUTPUT_LS_CUSTOM;
@@ -1152,7 +1206,11 @@ static void usage_dec( void )
    fprintf( stdout, "Mandatory parameters:\n" );
    fprintf( stdout, "---------------------\n" );
    fprintf( stdout, "OutputConf           : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA,\n" );
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
    fprintf( stdout, "                       HOA2, HOA3, BINAURAL, BINAURAL_ROOM, BINAURAL_REVERB, EXT\n" );
#else
    fprintf( stdout, "                       HOA2, HOA3, BINAURAL, BINAURAL_ROOM, EXT\n" );
#endif
    fprintf( stdout, "                       By default, channel order and loudspeaker positions are equal to the\n" );
    fprintf( stdout, "                       encoder. For loudspeaker outputs, OutputConf can be a custom loudspeaker\n" );
    fprintf( stdout, "                       layout file. See readme.txt for details.\n" );
+72 −0
Original line number Diff line number Diff line
@@ -60,6 +60,10 @@
#define RENDERER_MAX_METADATA_LENGTH      8192
#define RENDERER_MAX_METADATA_LINE_LENGTH 1024

#ifdef CONTROL_METADATA_REVERB
#define ACOUSTIC_ENVIRONMENT_ID 0
#endif

#if !defined( DEBUGGING ) && !defined( WMOPS )
static
#endif
@@ -213,25 +217,41 @@ static const CmdLnParser_Option cliOptions[] = {
        .id = CmdLnOptionId_trajFile,
        .match = "trajectory_file",
        .matchShort = "tf",
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
        .description = "Head rotation trajectory file for simulation of head tracking (only for BINAURAL, BINAURAL_ROOM, and BINAURAL_REVERB outputs)",
#else
        .description = "Head rotation trajectory file for simulation of head tracking (only for BINAURAL and BINAURAL_ROOM outputs)",
#endif
    },
    {
        .id = CmdLnOptionId_refRotFile,
        .match = "reference_rotation_file",
        .matchShort = "rf",
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
        .description = "Reference rotation trajectory file for simulation of head tracking (only for BINAURAL, BINAURAL_ROOM, and BINAURAL_REVERB outputs)",
#else
        .description = "Reference rotation trajectory file for simulation of head tracking (only for BINAURAL and BINAURAL_ROOM outputs)",
#endif
    },
    {
        .id = CmdLnOptionId_customHrtfFile,
        .match = "custom_hrtf",
        .matchShort = "hrtf",
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
        .description = "Custom HRTF file for binaural rendering (only for BINAURAL, BINAURAL_ROOM, and BINAURAL_REVERB outputs)",
#else
        .description = "Custom HRTF file for binaural rendering (only for BINAURAL and BINAURAL_ROOM outputs)",
#endif
    },
    {
        .id = CmdLnOptionId_renderConfigFile,
        .match = "render_config",
        .matchShort = "rc",
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
        .description = "Binaural renderer configuration file (only for BINAURAL, BINAURAL_ROOM, and BINAURAL_REVERB outputs)",
#else
        .description = "Binaural renderer configuration file (only for BINAURAL and BINAURAL_ROOM outputs)",
#endif
    },
    {
        .id = CmdLnOptionId_noDiegeticPan,
@@ -243,7 +263,11 @@ static const CmdLnParser_Option cliOptions[] = {
        .id = CmdLnOptionId_orientationTracking,
        .match = "tracking_type",
        .matchShort = "otr",
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
        .description = "Head orientation tracking type: 'none', 'ref', 'avg' or `ref_vec` or `ref_vec_lev` (only for BINAURAL, BINAURAL_ROOM, and BINAURAL_REVERB)",
#else
        .description = "Head orientation tracking type: 'none', 'ref', 'avg' or `ref_vec` or `ref_vec_lev` (only for BINAURAL and BINAURAL_ROOM)",
#endif
    },
    {
        .id = CmdlnOptionId_lfePosition,
@@ -283,7 +307,11 @@ static const CmdLnParser_Option cliOptions[] = {
        .id = CmdLnOptionId_referenceVectorFile,
        .match = "reference_vector_file",
        .matchShort = "rvf",
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
        .description = "Reference vector trajectory file for simulation of head tracking (only for BINAURAL, BINAURAL_ROOM, and BINAURAL_REVERB outputs)",
#else
        .description = "Reference vector trajectory file for simulation of head tracking (only for BINAURAL and BINAURAL_ROOM outputs)",
#endif
    },
};

@@ -673,7 +701,11 @@ int main(
    }

    /* === Configure === */
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
    if ( ( error = IVAS_REND_InitConfig( hIvasRend, ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) || ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_REVERB ) || ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL ) ) ) != IVAS_ERR_OK )
#else
    if ( ( error = IVAS_REND_InitConfig( hIvasRend, ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) || ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL ) ) ) != IVAS_ERR_OK )
#endif
    {
        fprintf( stderr, "Error in Renderer Config Init\n" );
        exit( -1 );
@@ -684,9 +716,17 @@ int main(
        IVAS_RENDER_CONFIG_DATA renderConfig;

        /* sanity check */
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
        if ( ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) && ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_REVERB ) && ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL ) )
#else
        if ( ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) && ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL ) )
#endif
        {
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
            fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL, BINAURAL_ROOM, or BINAURAL_REVERB is used as output. Exiting. \n" );
#else
            fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL or BINAURAL_ROOM is used as output. Exiting. \n" );
#endif
            exit( -1 );
        }

@@ -696,12 +736,35 @@ int main(
            exit( -1 );
        }

#ifdef CONTROL_METADATA_REVERB
        if ( RenderConfigReader_read( renderConfigReader ) != IVAS_ERR_OK )
#else
        if ( RenderConfigReader_read( renderConfigReader, &renderConfig ) != IVAS_ERR_OK )
#endif
        {
            fprintf( stderr, "Failed to read renderer configuration from file %s\n", args.renderConfigFilePath );
            exit( -1 );
        }

#ifdef CONTROL_METADATA_REVERB
        if ( RenderConfigReader_getAcousticEnvironment( renderConfigReader, ACOUSTIC_ENVIRONMENT_ID, &renderConfig.room_acoustics ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "Failed to get acoustic environment with ID: %d\n\n", ACOUSTIC_ENVIRONMENT_ID );
            exit( -1 );
        }
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
        if ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_REVERB )
        {
            renderConfig.room_acoustics.late_reverb_on = TRUE;
            renderConfig.room_acoustics.override = TRUE;
            renderConfig.room_acoustics.use_brir = FALSE;
        }
#else
        renderConfig.room_acoustics.late_reverb_on = TRUE;
        renderConfig.room_acoustics.override = TRUE;
#endif
#endif

        if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed\n" );
@@ -1482,6 +1545,12 @@ static IVAS_REND_AudioConfig parseAudioConfig(
    {
        return IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM;
    }
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
    if ( strcmp( charBuf, "BINAURAL_REVERB" ) == 0 )
    {
        return IVAS_REND_AUDIO_CONFIG_BINAURAL_REVERB;
    }
#endif
    if ( strcmp( charBuf, "BINAURAL" ) == 0 )
    {
        return IVAS_REND_AUDIO_CONFIG_BINAURAL;
@@ -2506,6 +2575,9 @@ static void printSupportedAudioConfigs()
        "MASAx (input only)",
        "BINAURAL (output only)",
        "BINAURAL_ROOM (output only)",
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
        "BINAURAL_REVERB (output only)",
#endif
    };

    fprintf( stdout, "Supported audio formats:\n" );
+3 −0
Original line number Diff line number Diff line
@@ -102,6 +102,9 @@ typedef enum
    AUDIO_CONFIG_OBA,                           /* object based audio           */
    AUDIO_CONFIG_BINAURAL,                      /* binaural with HRIR           */
    AUDIO_CONFIG_BINAURAL_ROOM,                 /* binaural with HRIR and BRIR  */
#ifdef COMMAND_LINE_OPTION_LATE_REVERB
    AUDIO_CONFIG_BINAURAL_REVERB,               /* binaural with reverberation  */
#endif
    AUDIO_CONFIG_ISM1,                          /* ISM1                         */
    AUDIO_CONFIG_ISM2,                          /* ISM2                         */
    AUDIO_CONFIG_ISM3,                          /* ISM3                         */
+4 −0
Original line number Diff line number Diff line
@@ -133,6 +133,10 @@ typedef enum
    IVAS_ERR_INVALID_INPUT_ID,
    IVAS_ERR_WRONG_NUM_CHANNELS,
    IVAS_ERR_INVALID_BUFFER_SIZE,
#ifdef CONTROL_METADATA_REVERB
    IVAS_ERR_INVALID_RENDER_CONFIG,
    IVAS_ERR_ACOUSTIC_ENVIRONMENT_MISSING,
#endif

    /*----------------------------------------*
     *              unknown error             *
+2 −0
Original line number Diff line number Diff line
@@ -141,6 +141,8 @@
#define DISABLE_ADAP_RES_COD_TMP                        /* temporary fix for IVAS-403, disables adaptive residual coding */
/*#define ITD_WINNER_GAIN_MODIFY */                     /* ITD optimization - WORK IN PROGRESS */
/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */
#define CONTROL_METADATA_REVERB                            /* Philips: renderer configuration change to binary format */
#define COMMAND_LINE_OPTION_LATE_REVERB                 /* Philips: late reverb command line option */
#define FIX_103_RA_PARAMS_PARAM_BIN_REND                /* Issue 103: Digest room acoustics parameters for Parametric Binaural Renderer*/
/*#define SBA_HPF_TUNING_DEC*/

Loading