Commit 96be4377 authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Adds external renderer parts into the BASOP conversion.

parent 5f2025b6
Loading
Loading
Loading
Loading
Loading
+76 −0
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[] = {
@@ -400,6 +408,14 @@ static const CmdLnParser_Option cliOptions[] = {
        .description = "Acoustic environment ID( number > 0 ) or a sequence thereof in the format [ID1:duration1,ID2:duration2...] without braces and spaces, with ':' character separating ID from duration and ',' separating ID and duration pairs, where duration is specified in frames for BINAURAL_ROOM_REVERB output configuration.",
#endif
    },
#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
};


@@ -1252,6 +1268,19 @@ 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 )
    {
@@ -2751,6 +2780,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(
@@ -2872,6 +2934,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;
}
@@ -3053,6 +3119,16 @@ static void parseOption(
            /* Metadata Delay to sync with audio delay in ms */
            args->syncMdDelay = (int16_t) strtol( optionValues[0], NULL, 10 );
            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] );
                exit( -1 );
            }
            break;
#endif
        default:
            assert( 0 && "This should be unreachable - all command line options should be explicitly handled." );
            break;
+1 −0
Original line number Diff line number Diff line
@@ -1675,6 +1675,7 @@ typedef enum
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE
typedef enum
{
    DEFAULT_REVERB_UNSET = -1,
    DEFAULT_REVERB_SMALL,
    DEFAULT_REVERB_MEDIUM,
    DEFAULT_REVERB_LARGE
+1 −1
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@
#define NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG       /* FhG: Fix MDCT-Stereo comfort noise for certain noise types */
#define NONBE_1344_REND_MASA_LOW_FS                     /* Nokia: Issue 1344: Fix sanitizer errors when using IVAS_rend to render MASA with lower sampling rates */
#define NONBE_1412_AVOID_ROUNDING_AZ_ELEV               /* FhG:  Avoid rounding when passing azimuth and elevation to efap_determine_gains() */
#define FIX_1318_ROOM_SIZE_CMD_LINE                     /* Philips/Nokia: Default room sizes support */
#define FIX_1318_ROOM_SIZE_CMD_LINE                     /* Philips/Nokia/FhG: Default room sizes support */

// object-editing feature porting
#define TMP_FIX_SPLIT_REND                              // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions)
+12 −0
Original line number Diff line number Diff line
@@ -270,6 +270,18 @@ ivas_error IVAS_REND_FeedRenderConfig(
    IVAS_REND_HANDLE hIvasRend,                     /* i/o: IVAS renderer handle                                */
    const IVAS_RENDER_CONFIG_DATA renderConfig      /* i  : Render configuration struct                         */
);
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE

ivas_error IVAS_REND_GetReverbRoomSize(
    IVAS_REND_HANDLE hIvasRend,                     /* i/o: IVAS renderer handle                                */
    IVAS_ROOM_SIZE_T *reverbRoomSize                /* o  : Reverb room size                                    */
);

ivas_error IVAS_REND_SetReverbRoomSize(
    IVAS_REND_HANDLE hIvasRend,                     /* i/o: IVAS renderer handle                                */
    const IVAS_ROOM_SIZE_T reverbRoomSize           /* i  : Reverb room size                                    */
);
#endif

ivas_error IVAS_REND_FeedSplitBinauralBitstream(
    IVAS_REND_HANDLE hIvasRend,                     /* i/o: Renderer handle                                     */
+203 −0
Original line number Diff line number Diff line
@@ -102,6 +102,9 @@ typedef struct
    const Word16 *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 */
@@ -232,6 +235,9 @@ struct IVAS_REND

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

#ifdef DEBUGGING
    Word32 numClipping; /* Counter of clipped output samples */
@@ -1374,6 +1380,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;
}
@@ -3647,6 +3656,10 @@ ivas_error IVAS_REND_Open(
    move32();
    hIvasRend->efapOutWrapper.pCustomLsSetup = NULL;
    move32();
#ifdef FIX_1318_ROOM_SIZE_CMD_LINE
    hIvasRend->selectedRoomReverbSize = DEFAULT_REVERB_UNSET;
    move32();
#endif
    hIvasRend->num_subframes = num_subframes;
    move16();

@@ -4425,7 +4438,99 @@ 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()
@@ -4565,6 +4670,18 @@ 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;
}
@@ -5788,6 +5905,92 @@ ivas_error IVAS_REND_CombineHeadAndExternalOrientation(
 *
 *---------------------------------------------------------------------*/

#ifdef FIX_1318_ROOM_SIZE_CMD_LINE

/*---------------------------------------------------------------------*
 * IVAS_REND_GetReverbRoomSize()
 *
 *
 *---------------------------------------------------------------------*/
ivas_error IVAS_REND_GetReverbRoomSize(
    IVAS_REND_HANDLE hIvasRend,      /* i/o: Renderer handle                                */
    IVAS_ROOM_SIZE_T *reverbRoomSize /* o  : Reverb room size                               */
)
{
    SWITCH( hIvasRend->selectedRoomReverbSize )
    {
        case DEFAULT_REVERB_SMALL:
            *reverbRoomSize = IVAS_ROOM_SIZE_SMALL;
            move32();
            BREAK;
        case DEFAULT_REVERB_MEDIUM:
            *reverbRoomSize = IVAS_ROOM_SIZE_MEDIUM;
            move32();
            BREAK;
        case DEFAULT_REVERB_LARGE:
            *reverbRoomSize = IVAS_ROOM_SIZE_LARGE;
            move32();
            BREAK;
        case DEFAULT_REVERB_UNSET:
        default:
            *reverbRoomSize = IVAS_ROOM_SIZE_AUTO;
            move32();
            BREAK;
    }

    return IVAS_ERR_OK;
}

/*---------------------------------------------------------------------*
 * IVAS_REND_SetReverbRoomSize()
 *
 *
 *---------------------------------------------------------------------*/
ivas_error IVAS_REND_SetReverbRoomSize(
    IVAS_REND_HANDLE hIvasRend,           /* i/o: Renderer handle                                */
    const IVAS_ROOM_SIZE_T reverbRoomSize /* i  : Reverb room size                               */
)
{
    ivas_error error;

    SWITCH( reverbRoomSize )
    {
        case IVAS_ROOM_SIZE_SMALL:
            hIvasRend->selectedRoomReverbSize = DEFAULT_REVERB_SMALL;
            move32();
            BREAK;
        case IVAS_ROOM_SIZE_MEDIUM:
            hIvasRend->selectedRoomReverbSize = DEFAULT_REVERB_MEDIUM;
            move32();
            BREAK;
        case IVAS_ROOM_SIZE_LARGE:
            hIvasRend->selectedRoomReverbSize = DEFAULT_REVERB_LARGE;
            move32();
            BREAK;
        case IVAS_ROOM_SIZE_AUTO:
        default:
            hIvasRend->selectedRoomReverbSize = DEFAULT_REVERB_UNSET;
            move32();
            BREAK; /* will be setup in IVAS_REND_AddInput() */
    }

    IF( hIvasRend->hRendererConfig != NULL )
    {
        IF( EQ_32( error = ivas_render_config_change_defaults( hIvasRend->hRendererConfig, hIvasRend->selectedRoomReverbSize ), IVAS_ERR_OK ) )
        {
            return error;
        }
    }
    ELSE
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

    return IVAS_ERR_OK;
}
#endif



/*-------------------------------------------------------------------*
 * Local functions