Commit 1f4a2099 authored by vaclav's avatar vaclav
Browse files

FIX_1135_EXT_RENDERER_HANDLES

parent ebb2b986
Loading
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -169,6 +169,10 @@ typedef struct
    char customHrtfFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
    char renderConfigFilePath[RENDERER_MAX_CLI_ARG_LENGTH];
    int8_t orientation_tracking;
#ifdef FIX_1135_EXT_RENDERER_HANDLES
    int16_t Opt_Headrotation;
    int16_t Opt_ExternalOrientation;
#endif
    int16_t nonDiegeticPan;
    float nonDiegeticPanGain;
    IVAS_REND_COMPLEXITY_LEVEL complexityLevel;
@@ -882,7 +886,11 @@ int main(

    const int16_t frameSize_smpls = (int16_t) ( ( args.render_framesize ) * args.sampleRate * 5 / ( 1000 ) );

#ifdef FIX_1135_EXT_RENDERER_HANDLES
    if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, !isEmptyString( args.customHrtfFilePath ), args.nonDiegeticPan, args.nonDiegeticPanGain, args.Opt_Headrotation, args.Opt_ExternalOrientation, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK )
#else
    if ( ( error = IVAS_REND_Open( &hIvasRend, args.sampleRate, args.outConfig.audioConfig, !isEmptyString( args.customHrtfFilePath ), args.nonDiegeticPan, args.nonDiegeticPanGain, (int16_t) args.render_framesize ) ) != IVAS_ERR_OK )
#endif
    {
        fprintf( stderr, "Error opening renderer handle: %s\n", ivas_error_to_string( error ) );
        exit( -1 );
@@ -2510,7 +2518,12 @@ static CmdlnArgs defaultArgs(
    clearString( args.renderConfigFilePath );
    clearString( args.externalOrientationFilePath );

#ifdef FIX_1135_EXT_RENDERER_HANDLES
    args.Opt_Headrotation = 0;
    args.Opt_ExternalOrientation = 0;
#endif
    args.orientation_tracking = IVAS_HEAD_ORIENT_TRK_NONE;

    args.nonDiegeticPan = 0;
    args.nonDiegeticPanGain = 0.f;

@@ -2598,6 +2611,9 @@ static void parseOption(
            break;
        case CmdLnOptionId_trajFile:
            assert( numOptionValues == 1 );
#ifdef FIX_1135_EXT_RENDERER_HANDLES
            args->Opt_Headrotation = 1;
#endif
            strncpy( args->headRotationFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 );
            break;
        case CmdLnOptionId_outputMetadata:
@@ -2618,6 +2634,9 @@ static void parseOption(
            break;
        case CmdLnOptionId_exteriorOrientationFile:
            assert( numOptionValues == 1 );
#ifdef FIX_1135_EXT_RENDERER_HANDLES
            args->Opt_ExternalOrientation = 1;
#endif
            strncpy( args->externalOrientationFilePath, optionValues[0], RENDERER_MAX_CLI_ARG_LENGTH - 1 );
            break;
        case CmdLnOptionId_customHrtfFile:
@@ -2742,6 +2761,13 @@ static CmdlnArgs parseCmdlnArgs(
        exit( -1 ); /* Error printout handled by failing function */
    }

#ifdef FIX_1135_EXT_RENDERER_HANDLES
    if ( args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
    {
        args.Opt_Headrotation = TRUE;
    }
#endif

    return args;
}

+1 −0
Original line number Diff line number Diff line
@@ -162,6 +162,7 @@
//#define FIX_CREND_FIX_POINT_HRTF_FILE_FORMAT          /* Orange issue 1031 : new fix point hrtf binary file format */
//#define FIX_CREND_SIMPLIFY_CODE                         /* Ora : simplify line code in crend */
#define FLOAT_FIX_POINT_HRTF_FILE_FORMAT                /* allows reading floation or fix point hrtf binary file format */
#define FIX_1135_EXT_RENDERER_HANDLES                   /* VA: issue 1135: Memory usage reduction in external renderer: Allocate only handles that are really needed. */

/* #################### End BE switches ################################## */

+1 −1
Original line number Diff line number Diff line
@@ -990,7 +990,7 @@ typedef struct decoder_config_structure
    int16_t Opt_non_diegetic_pan;                /* indicates diegetic or not */
    float non_diegetic_pan_gain;                 /* non diegetic panning gain*/
    int16_t Opt_AMR_WB;                          /* flag indicating AMR-WB IO mode */
    int16_t Opt_ExternalOrientation;             /* indiates whether external orientations are used */
    int16_t Opt_ExternalOrientation;             /* indicates whether external orientations are used */
    int16_t Opt_dpid_on;                         /* indicates whether Directivity pattern option is used */
    int16_t Opt_aeid_on;                         /* indicates whether Acoustic environment option is used */
#ifdef DEBUGGING
+2 −0
Original line number Diff line number Diff line
@@ -489,11 +489,13 @@ ivas_error IVAS_DEC_Configure(
        hDecoderConfig->render_framesize = renderFramesize;
    }

#ifndef FIX_1135_EXT_RENDERER_HANDLES
    if ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
    {
        hDecoderConfig->Opt_Headrotation = TRUE;
    }

#endif
    /* Set decoder parameters to initial values */
    if ( ( error = ivas_init_decoder_front( st_ivas ) ) != IVAS_ERR_OK )
    {
+112 −14
Original line number Diff line number Diff line
@@ -204,7 +204,11 @@ struct IVAS_REND
    AUDIO_CONFIG outputConfig;
    EFAP_WRAPPER efapOutWrapper;
    IVAS_LSSETUP_CUSTOM_STRUCT customLsOut;
#ifdef FIX_1135_EXT_RENDERER_HANDLES
    SPLIT_REND_WRAPPER *splitRendWrapper;
#else
    SPLIT_REND_WRAPPER splitRendWrapper;
#endif
    IVAS_REND_AudioBuffer splitRendEncBuffer;

    IVAS_REND_HeadRotData headRotData;
@@ -1218,7 +1222,11 @@ static rendering_context getRendCtx(
    ctx.pHeadRotData = &hIvasRend->headRotData;
    ctx.hhRendererConfig = &hIvasRend->hRendererConfig;
    ctx.pSplitRendBFI = &hIvasRend->splitRendBFI;
#ifdef FIX_1135_EXT_RENDERER_HANDLES
    ctx.pSplitRendWrapper = hIvasRend->splitRendWrapper;
#else
    ctx.pSplitRendWrapper = &hIvasRend->splitRendWrapper;
#endif
    ctx.pCombinedOrientationData = &hIvasRend->hCombinedOrientationData;

    return ctx;
@@ -2754,13 +2762,18 @@ static void clearInputMasa(
 *------------------------------------------------------------------------*/

ivas_error IVAS_REND_Open(
    IVAS_REND_HANDLE *phIvasRend,
    const int32_t outputSampleRate,
    const AUDIO_CONFIG outConfig,
    const bool asHrtfBinary,
    const int16_t nonDiegeticPan,
    const float nonDiegeticPanGain,
    const int16_t num_subframes )
    IVAS_REND_HANDLE *phIvasRend,      /* i/o: Pointer to renderer handle                          */
    const int32_t outputSampleRate,    /* i  : output sampling rate                                */
    const IVAS_AUDIO_CONFIG outConfig, /* i  : output audio config                                 */
    const bool asHrtfBinary,           /* i  : load hrtf binary file                               */
    const int16_t nonDiegeticPan,      /* i  : non-diegetic object flag                            */
    const float nonDiegeticPanGain,    /* i  : non-diegetic panning gain                           */
#ifdef FIX_1135_EXT_RENDERER_HANDLES
    const int16_t Opt_Headrotation,        /* i  : indicates whether head-rotation is used             */
    const int16_t Opt_ExternalOrientation, /* i  : indicates whether external orientations are used    */
#endif
    const int16_t num_subframes /* i  : number of subframes                                 */
)
{
    int16_t i;
    int16_t j;
@@ -2814,22 +2827,46 @@ ivas_error IVAS_REND_Open(
    }

    /* Initialize headrotation data */
#ifdef FIX_1135_EXT_RENDERER_HANDLES
    hIvasRend->headRotData.headRotEnabled = 0;
    if ( Opt_Headrotation )
    {
#endif
        if ( ( error = initHeadRotation( hIvasRend ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#ifdef FIX_1135_EXT_RENDERER_HANDLES
    }
#endif

    /* Initialize external orientation data */
#ifdef FIX_1135_EXT_RENDERER_HANDLES
    hIvasRend->hExternalOrientationData = NULL;
    if ( Opt_ExternalOrientation )
    {
#endif
        if ( ( error = ivas_external_orientation_open( &( hIvasRend->hExternalOrientationData ), num_subframes ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#ifdef FIX_1135_EXT_RENDERER_HANDLES
    }
#endif

    /* Initilize combined orientation data */
#ifdef FIX_1135_EXT_RENDERER_HANDLESaa
    hIvasRend->hCombinedOrientationData = NULL;
    if ( Opt_Headrotation || Opt_ExternalOrientation )
    {
#endif
        if ( ( error = ivas_combined_orientation_open( &( hIvasRend->hCombinedOrientationData ), outputSampleRate, num_subframes ) ) != IVAS_ERR_OK )
        {
            return error;
        }
#ifdef FIX_1135_EXT_RENDERER_HANDLESaa
    }
#endif

    /* Initialize EFAP */
    if ( ( error = initEfap( &hIvasRend->efapOutWrapper, outConfig, &hIvasRend->customLsOut ) ) != IVAS_ERR_OK )
@@ -2838,9 +2875,28 @@ ivas_error IVAS_REND_Open(
    }

    /* Initialize inputs */

#ifdef FIX_1135_EXT_RENDERER_HANDLES
    if ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
    {
        if ( ( hIvasRend->splitRendWrapper = (SPLIT_REND_WRAPPER *) malloc( sizeof( SPLIT_REND_WRAPPER ) ) ) == NULL )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for IVAS decoder handle" );
        }

        isar_init_split_rend_handles( hIvasRend->splitRendWrapper );
        hIvasRend->splitRendEncBuffer.data = NULL;
    }
    else
    {
        hIvasRend->splitRendWrapper = NULL;
    }
#else
    isar_init_split_rend_handles( &hIvasRend->splitRendWrapper );
    hIvasRend->splitRendEncBuffer.data = NULL;

#endif

    for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i )
    {
        initRendInputBase( &hIvasRend->inputsIsm[i].base, IVAS_AUDIO_CONFIG_INVALID, 0, getRendCtx( hIvasRend ), NULL, 0 );
@@ -3445,7 +3501,11 @@ ivas_error IVAS_REND_AddInput(
        int16_t cldfb_in_flag;
        cldfb_in_flag = getCldfbRendFlag( hIvasRend, getAudioConfigType( inConfig ) );

#ifdef FIX_1135_EXT_RENDERER_HANDLES
        if ( ( error = ivas_pre_rend_init( hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ivas_pre_rend_init( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
@@ -3863,7 +3923,11 @@ ivas_error IVAS_REND_GetDelay(
    {
        if ( hIvasRend->inputsSba[i].base.inConfig != IVAS_AUDIO_CONFIG_INVALID )
        {
#ifdef FIX_1135_EXT_RENDERER_HANDLES
            if ( hIvasRend->splitRendWrapper->hBinHrSplitPreRend != NULL )
#else
            if ( hIvasRend->splitRendWrapper.hBinHrSplitPreRend != NULL )
#endif
            {
                if ( hIvasRend->hRendererConfig->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV )
                {
@@ -4362,9 +4426,17 @@ int16_t IVAS_REND_FeedRenderConfig(
    {
        int16_t cldfb_in_flag;
        cldfb_in_flag = getCldfbRendFlag( hIvasRend, IVAS_REND_AUDIO_CONFIG_TYPE_UNKNOWN );
#ifdef FIX_1135_EXT_RENDERER_HANDLES
        ISAR_PRE_REND_close( hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer );
#else
        ISAR_PRE_REND_close( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer );
#endif

#ifdef FIX_1135_EXT_RENDERER_HANDLES
        if ( ( error = ivas_pre_rend_init( hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ivas_pre_rend_init( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer, &hIvasRend->hRendererConfig->split_rend_config, hIvasRend->headRotData, hIvasRend->sampleRateOut, hIvasRend->outputConfig, cldfb_in_flag, hIvasRend->num_subframes ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
@@ -4521,6 +4593,13 @@ ivas_error IVAS_REND_SetOrientationTrackingMode(
    const IVAS_HEAD_ORIENT_TRK_T orientation_tracking /* i  : Head orientation tracking type */
)
{
#ifdef FIX_1135_EXT_RENDERER_HANDLES
    if ( hIvasRend->headRotData.headRotEnabled == 0 )
    {
        return IVAS_HEAD_ORIENT_TRK_NONE;
    }
#endif

    return ivas_orient_trk_SetTrackingType( hIvasRend->headRotData.hOrientationTracker, orientation_tracking );
}

@@ -7371,10 +7450,19 @@ static ivas_error getSamplesInternal(
         ( hIvasRend->outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
    {
        int16_t num_poses_orig;
#ifdef FIX_1135_EXT_RENDERER_HANDLES
        num_poses_orig = hIvasRend->splitRendWrapper->multiBinPoseData.num_poses;
#else
        num_poses_orig = hIvasRend->splitRendWrapper.multiBinPoseData.num_poses;
#endif
        outAudio = hIvasRend->splitRendEncBuffer;
#ifdef FIX_1135_EXT_RENDERER_HANDLES
        ISAR_PRE_REND_GetMultiBinPoseData( &hIvasRend->hRendererConfig->split_rend_config, &hIvasRend->splitRendWrapper->multiBinPoseData, hIvasRend->headRotData.sr_pose_pred_axis );
        assert( num_poses_orig == hIvasRend->splitRendWrapper->multiBinPoseData.num_poses && "number of poses should not change dynamically" );
#else
        ISAR_PRE_REND_GetMultiBinPoseData( &hIvasRend->hRendererConfig->split_rend_config, &hIvasRend->splitRendWrapper.multiBinPoseData, hIvasRend->headRotData.sr_pose_pred_axis );
        assert( num_poses_orig == hIvasRend->splitRendWrapper.multiBinPoseData.num_poses && "number of poses should not change dynamically" );
#endif

        /* Clear output buffer for split rendering bitstream */
        set_zero( outAudio.data, outAudio.config.numChannels * outAudio.config.numSamplesPerChannel );
@@ -7439,7 +7527,11 @@ static ivas_error getSamplesInternal(
            }
        }

#ifdef FIX_1135_EXT_RENDERER_HANDLES
        if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( hIvasRend->splitRendWrapper,
#else
        if ( ( error = ISAR_PRE_REND_MultiBinToSplitBinaural( &hIvasRend->splitRendWrapper,
#endif
                                                              hIvasRend->headRotData.headPositions[0],
                                                              hIvasRend->hRendererConfig->split_rend_config.splitRendBitRate,
                                                              hIvasRend->hRendererConfig->split_rend_config.codec,
@@ -7611,7 +7703,13 @@ void IVAS_REND_Close(
    ivas_limiter_close( &hIvasRend->hLimiter );

    /* Split binaural rendering */
#ifdef FIX_1135_EXT_RENDERER_HANDLES
    ISAR_PRE_REND_close( hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer );
    free( hIvasRend->splitRendWrapper );
    hIvasRend->splitRendWrapper = NULL;
#else
    ISAR_PRE_REND_close( &hIvasRend->splitRendWrapper, &hIvasRend->splitRendEncBuffer );
#endif

    closeHeadRotation( hIvasRend );

Loading