Commit 8697b7ab authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

add default reverb sizes in renderer and initial commandline support

parent a3b55c8a
Loading
Loading
Loading
Loading
Loading
+67 −1
Original line number Diff line number Diff line
@@ -200,6 +200,9 @@ typedef struct
    IVAS_RENDER_FRAMESIZE render_framesize;
    uint16_t directivityPatternId[RENDERER_MAX_ISM_INPUTS];
    AcousticEnvironmentSequence aeSequence;
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE
    IVAS_ROOM_SIZE_T reverbRoomSize;
#endif
} CmdlnArgs;

typedef enum
@@ -230,7 +233,12 @@ typedef enum
    CmdLnOptionId_framing,
    CmdLnOptionId_syncMdDelay,
    CmdLnOptionId_directivityPatternId,
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE
    CmdLnOptionId_acousticEnvironmentId,
    CmdLnOptionId_roomSize,
#else
    CmdLnOptionId_acousticEnvironmentId
#endif
} CmdLnOptionId;

static const CmdLnParser_Option cliOptions[] = {
@@ -396,6 +404,14 @@ static const CmdLnParser_Option cliOptions[] = {
        .matchShort = "aeid",
        .description = "Acoustic environment ID (number > 0) alternatively, it can be\na text file where each line contains \"ID duration\" for\nBINAURAL_ROOM_REVERB output.",
    },
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE
    {
        .id = CmdLnOptionId_roomSize,
        .match = "room_size",
        .matchShort = "rsz",
        .description = "Selects default reverb based on a room size (S - small | M - medium | L - large)",
    }
#endif
};


@@ -1080,7 +1096,11 @@ int main(
    }

/* === Configure === */
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE
    if ( ( error = IVAS_REND_InitConfig( hIvasRend, args.reverbRoomSize, args.outConfig.audioConfig ) ) != IVAS_ERR_OK )
#else
    if ( ( error = IVAS_REND_InitConfig( hIvasRend, args.outConfig.audioConfig ) ) != IVAS_ERR_OK )
#endif
    {
        fprintf( stderr, "\nError in Renderer Config Init: %s\n", ivas_error_to_string( error ) );
        goto cleanup;
@@ -2551,6 +2571,39 @@ static bool parseAcousticEnvironmentIds(

    return true;
}
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE


static bool parseReverbRoomSize(
    char *value,
    IVAS_ROOM_SIZE_T *reverbRoomSize )
{
    if ( strlen( value ) != 1 )
    {
        fprintf( stderr, "Error: Unsupported room size selector %s!\n\n", value );
        return false;
    }

    to_upper( value );
    switch ( value[0] )
    {
        case 'S':
            *reverbRoomSize = IVAS_ROOM_SIZE_SMALL;
            break;
        case 'M':
            *reverbRoomSize = IVAS_ROOM_SIZE_MEDIUM;
            break;
        case 'L':
            *reverbRoomSize = IVAS_ROOM_SIZE_LARGE;
            break;
        default:
            fprintf( stderr, "Error: Unsupported room size selector %s!\n\n", value );
            return false;
    }

    return true;
}
#endif


static bool checkRequiredArgs(
@@ -2672,6 +2725,10 @@ static CmdlnArgs defaultArgs(
    args.aeSequence.pValidity = NULL;
    args.aeSequence.selected = 0;
    args.aeSequence.frameCounter = 0;
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE

    args.reverbRoomSize = IVAS_ROOM_SIZE_AUTO;
#endif

    return args;
}
@@ -2857,6 +2914,15 @@ static void parseOption(
            args->syncMdDelay = strtof( optionValues[0], NULL );
#endif
            break;
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE
        case CmdLnOptionId_roomSize:
            assert( numOptionValues == 1 );
            if ( !parseReverbRoomSize( optionValues[0], &args->reverbRoomSize ) )
            {
                fprintf( stderr, "Error: Unsupported room size selector %s!\n\n", optionValues[0] );
            }
            break;
#endif
        default:
            assert( 0 && "This should be unreachable - all command line options should be explicitly handled." );
            break;
+127 −1
Original line number Diff line number Diff line
@@ -93,6 +93,9 @@ typedef struct
    const int16_t *pSplitRendBFI;
    const SPLIT_REND_WRAPPER *pSplitRendWrapper;
    const COMBINED_ORIENTATION_HANDLE *pCombinedOrientationData;
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE
    const IVAS_DefaultReverbSize *pSelectedRoomReverbSize;
#endif
} rendering_context;

/* Common base for input structs */
@@ -228,6 +231,9 @@ struct IVAS_REND

    int8_t rendererConfigEnabled;
    RENDER_CONFIG_DATA *hRendererConfig; /* Renderer config pointer */
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE
    IVAS_DefaultReverbSize selectedRoomReverbSize;
#endif

    int16_t num_subframes;
    hrtf_handles hHrtfs;
@@ -1242,6 +1248,9 @@ static rendering_context getRendCtx(
    ctx.pSplitRendBFI = &hIvasRend->splitRendBFI;
    ctx.pSplitRendWrapper = hIvasRend->splitRendWrapper;
    ctx.pCombinedOrientationData = &hIvasRend->hCombinedOrientationData;
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE
    ctx.pSelectedRoomReverbSize = &hIvasRend->selectedRoomReverbSize;
#endif

    return ctx;
}
@@ -3798,6 +3807,85 @@ static ivas_error isar_pre_rend_init(

    return IVAS_ERR_OK;
}
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE
static IVAS_DefaultReverbSize getDefaultReverbSize(
    input_ism *ismInputs,
    input_masa *masaInputs,
    input_mc *mcInputs,
    input_sba *sbaInputs )
{
    bool combinedFormat;
    int16_t i;
    int16_t nActiveInputsIsm, nActiveInputsMc, nActiveInputsSba, nActiveInputsMasa;
    IVAS_DefaultReverbSize selectedReverb;
    selectedReverb = DEFAULT_REVERB_MEDIUM;

    combinedFormat = false;
    nActiveInputsIsm = 0;
    nActiveInputsMc = 0;
    nActiveInputsMasa = 0;
    nActiveInputsSba = 0;

    for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; i++ )
    {
        if ( ismInputs[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID )
        {
            nActiveInputsIsm++;
        }
    }
    for ( i = 0; i < RENDERER_MAX_MASA_INPUTS; i++ )
    {
        if ( mcInputs[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID )
        {
            nActiveInputsMasa++;
        }
    }
    for ( i = 0; i < RENDERER_MAX_MC_INPUTS; i++ )
    {
        if ( mcInputs[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID )
        {
            nActiveInputsMc++;
        }
    }
    for ( i = 0; i < RENDERER_MAX_SBA_INPUTS; i++ )
    {
        if ( mcInputs[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID )
        {
            nActiveInputsSba++;
        }
    }

    /* ISM present with MASA/SBA inputs; treat as combined format */
    if ( nActiveInputsIsm && ( nActiveInputsMasa || nActiveInputsSba ) )
    {
        combinedFormat = true;
    }

    if ( combinedFormat )
    {
        selectedReverb = DEFAULT_REVERB_MEDIUM;
    }
    else
    {
        /* Only set large if ISM is present alone */
        if ( nActiveInputsIsm && !nActiveInputsMc )
        {
            selectedReverb = DEFAULT_REVERB_LARGE;
        }
        /* if only MC is present, medium will not be overridden by the subsequent block */
        else if ( nActiveInputsMc )
        {
            selectedReverb = DEFAULT_REVERB_MEDIUM;
        }
        else if ( nActiveInputsMasa || nActiveInputsSba )
        {
            selectedReverb = DEFAULT_REVERB_SMALL;
        }
    }

    return selectedReverb;
}
#endif


/*-------------------------------------------------------------------*
@@ -3897,6 +3985,15 @@ ivas_error IVAS_REND_AddInput(

    /* set global maximum delay after adding an input */
    setMaxGlobalDelayNs( hIvasRend );
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE

    /* select default reverb size after adding an input */
    ivas_render_config_change_defaults( hIvasRend->hRendererConfig,
                                        getDefaultReverbSize( hIvasRend->inputsIsm,
                                                              hIvasRend->inputsMasa,
                                                              hIvasRend->inputsMc,
                                                              hIvasRend->inputsSba ) );
#endif

    return IVAS_ERR_OK;
}
@@ -4472,11 +4569,17 @@ ivas_error IVAS_REND_FeedInputMasaMetadata(

ivas_error IVAS_REND_InitConfig(
    IVAS_REND_HANDLE hIvasRend, /* i/o: Renderer handle     */
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE
    const IVAS_ROOM_SIZE_T roomReverbSize, /* i/o: Reverb room size    */
#endif
    const AUDIO_CONFIG outAudioConfig /* i  : output audioConfig  */
)
{
    ivas_error error;
    bool rendererConfigEnabled;
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE
    IVAS_DefaultReverbSize selectedRoomReverbSize;
#endif

    rendererConfigEnabled = ( getAudioConfigType( outAudioConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL );

@@ -4499,6 +4602,29 @@ ivas_error IVAS_REND_InitConfig(
        {
            return error;
        }
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE
        switch ( roomReverbSize )
        {
            case IVAS_ROOM_SIZE_SMALL:
                selectedRoomReverbSize = DEFAULT_REVERB_SMALL;
                break;
            case IVAS_ROOM_SIZE_MEDIUM:
                selectedRoomReverbSize = DEFAULT_REVERB_MEDIUM;
                break;
            case IVAS_ROOM_SIZE_LARGE:
                selectedRoomReverbSize = DEFAULT_REVERB_LARGE;
                break;
            case IVAS_ROOM_SIZE_AUTO:
            default:
                selectedRoomReverbSize = DEFAULT_REVERB_LARGE;
                break; /* will be setup in IVAS_REND_AddInput() */
        }
        if ( ( error = ivas_render_config_change_defaults( hIvasRend->hRendererConfig, selectedRoomReverbSize ) ) != IVAS_ERR_OK )
        {
            return error;
        }

#endif
    }
    else
    {
+3 −0
Original line number Diff line number Diff line
@@ -249,6 +249,9 @@ ivas_error IVAS_REND_FeedInputMasaMetadata(

ivas_error IVAS_REND_InitConfig(
    IVAS_REND_HANDLE hIvasRend,                     /* i/o: Renderer handle                                     */
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE
    const IVAS_ROOM_SIZE_T reverbRoomSize,          /* i/o: Reverb room size                                    */
#endif
    const IVAS_AUDIO_CONFIG outAudioConfig          /* i  : output audioConfig                                  */
);