Commit 11685f61 authored by sagnowski's avatar sagnowski
Browse files

Fix stack-use-after-scope in rotateFrameMc

parent bc558452
Loading
Loading
Loading
Loading
+60 −7
Original line number Diff line number Diff line
@@ -741,7 +741,11 @@ static ivas_error getNumNonLfeChannelsInSpeakerLayout(

static ivas_error getMcConfigValues(
    IVAS_REND_AudioConfig inConfig,
#ifdef LIB_REND_API_5MS
    const LSSETUP_CUSTOM_STRUCT *pInCustomLs,
#else
    LSSETUP_CUSTOM_STRUCT inCustomLs,
#endif
    const float **azimuth,
    const float **elevation,
    int16_t *lfe_idx,
@@ -754,6 +758,22 @@ static ivas_error getMcConfigValues(
    switch ( inConfig )
    {
        case IVAS_REND_AUDIO_CONFIG_LS_CUSTOM:
#ifdef LIB_REND_API_5MS
            *azimuth = (const float *) &pInCustomLs->ls_azimuth;
            *elevation = (const float *) &pInCustomLs->ls_elevation;
            if ( pInCustomLs->num_lfe > 0 )
            {
                *lfe_idx = pInCustomLs->lfe_idx[0];
            }
            for ( i = 0; i < pInCustomLs->num_spk; i++ )
            {
                if ( pInCustomLs->ls_elevation[i] != 0 )
                {
                    *is_planar = 0;
                    break;
                }
            }
#else
            *azimuth = (const float *) &inCustomLs.ls_azimuth;
            *elevation = (const float *) &inCustomLs.ls_elevation;
            if ( inCustomLs.num_lfe > 0 )
@@ -768,6 +788,7 @@ static ivas_error getMcConfigValues(
                    break;
                }
            }
#endif
            break;
        case IVAS_REND_AUDIO_CONFIG_MONO:
        case IVAS_REND_AUDIO_CONFIG_STEREO:
@@ -4519,7 +4540,11 @@ static void renderBufferChannel(
static ivas_error rotateFrameMc(
    IVAS_REND_AudioBuffer inAudio,            /* i  : Input Audio buffer               */
    IVAS_REND_AudioConfig inConfig,           /* i  : Input Audio config               */
#ifdef LIB_REND_API_5MS
    const LSSETUP_CUSTOM_STRUCT *pInCustomLs, /* i  : Input Custom LS setup            */
#else
    LSSETUP_CUSTOM_STRUCT inCustomLs, /* i  : Input Custom LS setup            */
#endif
    const IVAS_REND_HeadRotData *headRotData,                    /* i  : Head rotation data               */
    const COMBINED_ORIENTATION_HANDLE *hCombinedOrientationData, /* i  : Combined head and external orientations */
    rotation_gains gains_prev,                                   /* i/o: Previous frame rotation gains    */
@@ -4572,10 +4597,20 @@ static ivas_error rotateFrameMc(
    }
    else
    {
#ifdef LIB_REND_API_5MS
        nchan = pInCustomLs->num_spk + pInCustomLs->num_lfe;
#else
        nchan = inCustomLs.num_spk + inCustomLs.num_lfe;
#endif
    }

    if ( ( error = getMcConfigValues( inConfig, inCustomLs, &ls_azimuth, &ls_elevation, &lfe_idx, &is_planar_setup ) ) != IVAS_ERR_OK )
    if ( ( error = getMcConfigValues( inConfig,
#ifdef LIB_REND_API_5MS
                                      pInCustomLs,
#else
                                      inCustomLs,
#endif
                                      &ls_azimuth, &ls_elevation, &lfe_idx, &is_planar_setup ) ) != IVAS_ERR_OK )
    {
        return error;
    }
@@ -5431,7 +5466,13 @@ static ivas_error renderMcToBinaural(
            tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) );
            set_zero( tmpRotBuffer.data, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels );

            if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, mcInput->customLsInput, mcInput->base.ctx.pHeadRotData,
            if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig,
#ifdef LIB_REND_API_5MS
                                          &mcInput->customLsInput,
#else
                                          mcInput->customLsInput,
#endif
                                          mcInput->base.ctx.pHeadRotData,
                                          mcInput->base.ctx.pCombinedOrientationData,
                                          mcInput->rot_gains_prev, mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK )
            {
@@ -5534,7 +5575,13 @@ static ivas_error renderMcToBinauralRoom(
            tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) );
            set_zero( tmpRotBuffer.data, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels );

            if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, mcInput->customLsInput, mcInput->base.ctx.pHeadRotData,
            if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig,
#ifdef LIB_REND_API_5MS
                                          &mcInput->customLsInput,
#else
                                          mcInput->customLsInput,
#endif
                                          mcInput->base.ctx.pHeadRotData,
                                          mcInput->base.ctx.pCombinedOrientationData,
                                          mcInput->rot_gains_prev, mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK )
            {
@@ -5626,7 +5673,13 @@ static ivas_error renderMcCustomLsToBinauralRoom(
        tmpRotBuffer.data = malloc( tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels * sizeof( float ) );
        set_zero( tmpRotBuffer.data, tmpRotBuffer.config.numSamplesPerChannel * tmpRotBuffer.config.numChannels );

        if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig, mcInput->customLsInput, mcInput->base.ctx.pHeadRotData,
        if ( ( error = rotateFrameMc( mcInput->base.inputBuffer, mcInput->base.inConfig,
#ifdef LIB_REND_API_5MS
                                      &mcInput->customLsInput,
#else
                                      mcInput->customLsInput,
#endif
                                      mcInput->base.ctx.pHeadRotData,
                                      mcInput->base.ctx.pCombinedOrientationData,
                                      mcInput->rot_gains_prev, mcInput->efapInWrapper.hEfap, tmpRotBuffer ) ) != IVAS_ERR_OK )
        {