Commit ee8d5826 authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Port changes from float MR 2417.

parent 41953b39
Loading
Loading
Loading
Loading
Loading
+47 −13
Original line number Diff line number Diff line
@@ -1179,6 +1179,53 @@ int main(
        fprintf( stderr, "\nError in Renderer Config Init: %s\n", ivas_error_to_string( error ) );
        goto cleanup;
    }
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE

    if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
    {
        /* Set reverb room size if specified or select based automatically based on default per input formats */
        IVAS_ROOM_SIZE_T selectedReverbRoomSize = args.reverbRoomSize;
        if ( selectedReverbRoomSize == IVAS_ROOM_SIZE_AUTO )
        {
            bool combinedFormat = false;
            selectedReverbRoomSize = IVAS_ROOM_SIZE_MEDIUM;

            /* ISM present with MASA/SBA inputs; treat as combined format */
            if ( args.inConfig.numAudioObjects > 0 && ( args.inConfig.numMasaBuses > 0 || args.inConfig.numAmbisonicsBuses > 0 ) )
            {
                combinedFormat = true;
            }

            if ( combinedFormat )
            {
                selectedReverbRoomSize = IVAS_ROOM_SIZE_MEDIUM;
            }
            else
            {
                /* Only set large if ISM is present alone, MASA and Ambisonic have been checked above */
                if ( args.inConfig.numAudioObjects > 0 && args.inConfig.numMultiChannelBuses == 0 )
                {
                    selectedReverbRoomSize = IVAS_ROOM_SIZE_LARGE;
                }
                /* if only MC is present, set medium; Will not be overridden by the subsequent block */
                else if ( args.inConfig.numMultiChannelBuses > 0 )
                {
                    selectedReverbRoomSize = IVAS_ROOM_SIZE_MEDIUM;
                }
                else if ( args.inConfig.numMasaBuses > 0 || args.inConfig.numAmbisonicsBuses > 0 )
                {
                    selectedReverbRoomSize = IVAS_ROOM_SIZE_SMALL;
                }
            }
        }

        if ( ( IVAS_REND_SetReverbRoomSize( hIvasRend, selectedReverbRoomSize ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError setting reverb room size\n" );
            goto cleanup;
        }
    }
#endif


    if ( args.renderConfigFilePath[0] != '\0' )
@@ -1258,19 +1305,6 @@ int main(
        goto cleanup;
    }

#ifdef FIX_1318_ROOM_SIZE_CMD_LINE

    /* Set reverb room size if specified */
    if ( args.reverbRoomSize != IVAS_ROOM_SIZE_AUTO )
    {
        if ( ( IVAS_REND_SetReverbRoomSize( hIvasRend, args.reverbRoomSize ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError setting reverb room size\n" );
            goto cleanup;
        }
    }
#endif

    /* Set up output custom layout configuration */
    if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_LS_CUSTOM )
    {
+1 −107
Original line number Diff line number Diff line
@@ -4391,99 +4391,7 @@ static ivas_error isar_pre_rend_init(

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

    combinedFormat = false;
    nActiveInputsIsm = 0;
    nActiveInputsMasa = 0;
    nActiveInputsMc = 0;
    nActiveInputsSba = 0;
    move16();
    move16();
    move16();
    move16();
    move16();

    FOR( i = 0; i < RENDERER_MAX_ISM_INPUTS; i++ )
    {
        IF( NE_32( ismInputs[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) )
        {
            nActiveInputsIsm = add( nActiveInputsIsm, 1 );
        }
    }
    FOR( i = 0; i < RENDERER_MAX_MASA_INPUTS; i++ )
    {
        IF( NE_32( masaInputs[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) )
        {
            nActiveInputsMasa = add( nActiveInputsMasa, 1 );
        }
    }
    FOR( i = 0; i < RENDERER_MAX_MC_INPUTS; i++ )
    {
        IF( NE_32( mcInputs[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) )
        {
            nActiveInputsMc = add( nActiveInputsMc, 1 );
        }
    }
    FOR( i = 0; i < RENDERER_MAX_SBA_INPUTS; i++ )
    {
        IF( NE_32( sbaInputs[i].base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) )
        {
            nActiveInputsSba = add( nActiveInputsSba, 1 );
        }
    }

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

    IF( combinedFormat )
    {
        selectedReverb = IVAS_ROOM_SIZE_MEDIUM;
        move32();
    }
    ELSE
    {
        /* Only set large if ISM is present alone */
        test();
        IF( nActiveInputsIsm && !nActiveInputsMc )
        {
            selectedReverb = IVAS_ROOM_SIZE_LARGE;
            move32();
        }
        /* if only MC is present, set medium; Will not be overridden by the subsequent block */
        ELSE IF( nActiveInputsMc )
        {
            selectedReverb = IVAS_ROOM_SIZE_MEDIUM;
            move32();
        }
        ELSE IF( nActiveInputsMasa || nActiveInputsSba )
        {
            selectedReverb = IVAS_ROOM_SIZE_SMALL;
            move32();
        }
    }

    return selectedReverb;
}
#endif

/*-------------------------------------------------------------------*
 * IVAS_REND_AddInput()
@@ -4591,18 +4499,6 @@ ivas_error IVAS_REND_AddInput_fx(

    /* 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 */
    IF( EQ_32( hIvasRend->selectedRoomReverbSize, DEFAULT_REVERB_UNSET ) )
    {
        IVAS_REND_SetReverbRoomSize( hIvasRend,
                                     getDefaultReverbSize( hIvasRend->inputsIsm,
                                                           hIvasRend->inputsMasa,
                                                           hIvasRend->inputsMc,
                                                           hIvasRend->inputsSba ) );
    }
#endif

    return IVAS_ERR_OK;
}
@@ -5896,9 +5792,7 @@ ivas_error IVAS_REND_SetReverbRoomSize(
            BREAK;
        case IVAS_ROOM_SIZE_AUTO:
        default:
            hIvasRend->selectedRoomReverbSize = DEFAULT_REVERB_UNSET;
            move32();
            BREAK; /* will be setup in IVAS_REND_AddInput() */
           assert( 0 && "Room size is not set" );
    }

    IF( hIvasRend->hRendererConfig != NULL )