Commit 98b77ad9 authored by Marek Szczerba's avatar Marek Szczerba
Browse files

Refactoring of binaural output configuration. BINAURAL_HRIR_REVERB as a...

Refactoring of binaural output configuration. BINAURAL_HRIR_REVERB as a separate output configuration.
parent 3a1651ba
Loading
Loading
Loading
Loading
+51 −4
Original line number Diff line number Diff line
@@ -229,7 +229,11 @@ int main(
    if ( arg.hrtfReaderEnabled )
    {
        /* sanity check */
#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_HRIR && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_BRIR && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_HRIR_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 +255,11 @@ int main(
    if ( arg.enableHeadRotation )
    {
        /* sanity check */
#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_HRIR && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_BRIR && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_HRIR_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 +279,11 @@ int main(
    if ( arg.enableReferenceRotation )
    {
        /* sanity check */
#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_HRIR && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_BRIR && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_HRIR_REVERB )
#else
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM )
#endif
        {
            fprintf( stderr, "\nError: Reference rotation file cannot be used in this output configuration.\n\n" );
            goto cleanup;
@@ -298,7 +310,11 @@ int main(
    if ( arg.enableReferenceVectorTracking )
    {
        /* sanity check */
#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_HRIR && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_BRIR && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_HRIR_REVERB )
#else
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM )
#endif
        {
            fprintf( stderr, "\nError: Reference vector trajectory file cannot be used in this output configuration.\n\n" );
            goto cleanup;
@@ -338,7 +354,11 @@ int main(
    if ( arg.renderConfigEnabled )
    {
        /* sanity check */
#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_HRIR && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_BRIR && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_HRIR_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 +481,17 @@ int main(
        IVAS_RENDER_CONFIG_DATA renderConfig;

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

@@ -713,6 +741,20 @@ static IVAS_DEC_AUDIO_CONFIG cmdline2config(
    {
        output_config = IVAS_DEC_OUTPUT_HOA3;
    }
#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
    else if ( strcmp( argv_to_upper, "BINAURAL_HRIR" ) == 0 )
    {
        output_config = IVAS_DEC_OUTPUT_BINAURAL_HRIR;
    }
    else if ( strcmp( argv_to_upper, "BINAURAL_BRIR" ) == 0 )
    {
        output_config = IVAS_DEC_OUTPUT_BINAURAL_BRIR;
    }
    else if ( strcmp( argv_to_upper, "BINAURAL_HRIR_REVERB" ) == 0 )
    {
        output_config = IVAS_DEC_OUTPUT_BINAURAL_HRIR_REVERB;
    }
#else
    else if ( strcmp( argv_to_upper, "BINAURAL" ) == 0 )
    {
        output_config = IVAS_DEC_OUTPUT_BINAURAL;
@@ -721,6 +763,7 @@ static IVAS_DEC_AUDIO_CONFIG cmdline2config(
    {
        output_config = IVAS_DEC_OUTPUT_BINAURAL_ROOM;
    }
#endif
        else
        {
            output_config = IVAS_DEC_OUTPUT_LS_CUSTOM;
@@ -1152,7 +1195,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 FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
    fprintf( stdout, "                       HOA2, HOA3, BINAURAL_HRIR, BINAURAL_BRIR, BINAURAL_HRIR_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" );
+64 −0
Original line number Diff line number Diff line
@@ -213,25 +213,41 @@ static const CmdLnParser_Option cliOptions[] = {
        .id = CmdLnOptionId_trajFile,
        .match = "trajectory_file",
        .matchShort = "tf",
#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
        .description = "Head rotation trajectory file for simulation of head tracking (only for binaural 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 FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
        .description = "Reference rotation trajectory file for simulation of head tracking (only for binaural 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 FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
        .description = "Custom HRTF file for binaural rendering (only for binaural 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 FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
        .description = "Binaural renderer configuration file (only for binaural outputs)",
#else
        .description = "Binaural renderer configuration file (only for BINAURAL and BINAURAL_ROOM outputs)",
#endif
    },
    {
        .id = CmdLnOptionId_noDiegeticPan,
@@ -243,7 +259,11 @@ static const CmdLnParser_Option cliOptions[] = {
        .id = CmdLnOptionId_orientationTracking,
        .match = "tracking_type",
        .matchShort = "otr",
#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
        .description = "Head orientation tracking type: 'none', 'ref', 'avg' or `ref_vec` or `ref_vec_lev` (only for binaural outputs)",
#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 +303,11 @@ static const CmdLnParser_Option cliOptions[] = {
        .id = CmdLnOptionId_referenceVectorFile,
        .match = "reference_vector_file",
        .matchShort = "rvf",
#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
        .description = "Reference vector trajectory file for simulation of head tracking (only for binaural outputs)",
#else
        .description = "Reference vector trajectory file for simulation of head tracking (only for BINAURAL and BINAURAL_ROOM outputs)",
#endif
    },
};

@@ -683,9 +707,17 @@ int main(
        IVAS_RENDER_CONFIG_DATA renderConfig;

        /* sanity check */
#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
        if ( ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_HRIR ) && ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_BRIR ) && ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_HRIR_REVERB ) )
#else
        if ( ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM ) && ( args.outConfig.audioConfig != IVAS_REND_AUDIO_CONFIG_BINAURAL ) )
#endif
        {
#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
            fprintf( stderr, "\nExternal Renderer Config is only supported for binaural output configurations. 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 );
        }

@@ -701,6 +733,15 @@ int main(
            exit( -1 );
        }

#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
        if ( args.outConfig.audioConfig == IVAS_REND_AUDIO_CONFIG_BINAURAL_HRIR_REVERB )
        {
            renderConfig.room_acoustics.late_reverb_on = TRUE;
            renderConfig.room_acoustics.override = TRUE;
            renderConfig.room_acoustics.use_brir = FALSE;
        }
#endif

        if ( ( error = IVAS_REND_FeedRenderConfig( hIvasRend, renderConfig ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_FeedRenderConfig failed\n" );
@@ -1404,8 +1445,13 @@ static bool parseOrientationTracking(
static IVAS_REND_AudioConfig parseAudioConfig(
    const char *configString )
{
#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
    char charBuf[21];
    charBuf[20] = '\0';
#else
    char charBuf[14];
    charBuf[13] = '\0';
#endif

    strncpy( charBuf, configString, sizeof( charBuf ) - 1 );
    charBuf[sizeof( charBuf ) - 1] = '\0';
@@ -1478,6 +1524,17 @@ static IVAS_REND_AudioConfig parseAudioConfig(
                return IVAS_REND_AUDIO_CONFIG_UNKNOWN;
        }
    }
#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
    if ( strcmp( charBuf, "BINAURAL_HRIR" ) == 0 )
    {
        return IVAS_REND_AUDIO_CONFIG_BINAURAL_HRIR;
    }
    if ( strcmp( charBuf, "BINAURAL_BRIR" ) == 0 )
    {
        return IVAS_REND_AUDIO_CONFIG_BINAURAL_BRIR;
    }
    if ( strcmp( charBuf, "BINAURAL_HRIR_REVERB" ) == 0 )
#else
    if ( strcmp( charBuf, "BINAURAL_ROOM" ) == 0 )
    {
        return IVAS_REND_AUDIO_CONFIG_BINAURAL_ROOM;
@@ -1486,6 +1543,7 @@ static IVAS_REND_AudioConfig parseAudioConfig(
    {
        return IVAS_REND_AUDIO_CONFIG_BINAURAL;
    }
#endif

    return IVAS_REND_AUDIO_CONFIG_UNKNOWN;
}
@@ -2504,8 +2562,14 @@ static void printSupportedAudioConfigs()
        "HOA3",
        "ISMx (input only)",
        "MASAx (input only)",
#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
        "BINAURAL_HRIR (output only)",
        "BINAURAL_BRIR (output only)",
        "BINAURAL_HRIR_REVERB (output only)",
#else
        "BINAURAL (output only)",
        "BINAURAL_ROOM (output only)",
#endif
    };

    fprintf( stdout, "Supported audio formats:\n" );
+6 −0
Original line number Diff line number Diff line
@@ -100,8 +100,14 @@ typedef enum
    AUDIO_CONFIG_HOA2,                          /* ambisonics, order 2          */
    AUDIO_CONFIG_HOA3,                          /* ambisonics, order 3          */
    AUDIO_CONFIG_OBA,                           /* object based audio           */
#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
    AUDIO_CONFIG_BINAURAL_HRIR,                 /* binaural with HRIR           */
    AUDIO_CONFIG_BINAURAL_BRIR,                 /* binaural with BRIR           */
    AUDIO_CONFIG_BINAURAL_HRIR_REVERB,          /* binaural with HRIR + reverb  */
#else
    AUDIO_CONFIG_BINAURAL,                      /* binaural with HRIR           */
    AUDIO_CONFIG_BINAURAL_ROOM,                 /* binaural with HRIR and BRIR  */
#endif
    AUDIO_CONFIG_ISM1,                          /* ISM1                         */
    AUDIO_CONFIG_ISM2,                          /* ISM2                         */
    AUDIO_CONFIG_ISM3,                          /* ISM3                         */
+1 −0
Original line number Diff line number Diff line
@@ -177,6 +177,7 @@
#define FIX_357_DTX_32K                                 /* Eri: issue 357 - Forced LP-CNG at 32k */   
#define FIX_435_ISM_MERGE_BUG                           /* Eri: Merge bug fix for ISM NULL metadata and tcx_only cases */
#define FIX_355_REFACTOR_PARAMBIN_TO_5MS                /* Nokia: Fixes issue 355 by refactoring parametric binauralizer code to 5 ms mode */
#define FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG         /* Phi: issue 196 - refactoring renderer output configuration */

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
+4 −0
Original line number Diff line number Diff line
@@ -234,7 +234,11 @@ ivas_error ivas_dec(
            }
            else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM )
            {
#ifdef FIX_196_REFACTOR_RENDERER_OUTPUT_CONFIG
                if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_BRIR, NULL, NULL, NULL, NULL, output, output_Fs ) ) != IVAS_ERR_OK )
#else
                if ( ( error = ivas_rend_crendProcess( st_ivas->hCrendWrapper, AUDIO_CONFIG_7_1_4, AUDIO_CONFIG_BINAURAL_ROOM, NULL, NULL, NULL, NULL, output, output_Fs ) ) != IVAS_ERR_OK )
#endif
                {
                    return error;
                }
Loading