Commit c04179e6 authored by multrus's avatar multrus
Browse files

[cleanup] accept FIX_194_LFE_DELAY_EXTREND

parent 62f4e3b4
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -151,7 +151,6 @@
/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */


#define FIX_194_LFE_DELAY_EXTREND                       /* FhG: Issue 194: Fix delay alignment of LFE in external renderer */
#define FIX_582_INDEX_OUT_OF_BOUNDS_SNS_AVQ_DEC         /* FhG: fix an undefined behaviour error in SNS AVQ decoding */
#define FIX_614_ADD_TO_NULL_PTR_DIRAC_SETUP             /* FhG: Issue 614: prevent adding to a null pointer in dirac setup code */
#define UPDATE_REVERB_UTILS                             /* Use CLDFB HRTFs of the appropriate SBA order in get_IR_from_filter_taps() */
+0 −57
Original line number Diff line number Diff line
@@ -61,9 +61,7 @@
#define MAX_CLDFB_BUFFER_LENGTH ( MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS )
#define MAX_BIN_BUFFER_LENGTH   ( MAX_BUFFER_LENGTH_PER_CHANNEL * BINAURAL_CHANNELS )

#ifdef FIX_194_LFE_DELAY_EXTREND
#define MAX_BIN_DELAY_SAMPLES 50 /* Maximum supported rendering latency for binaural IRs */
#endif

#else
#define MAX_BUFFER_LENGTH ( MAX_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS )
@@ -184,10 +182,8 @@ typedef struct
    float nonDiegeticPanGain;
    lfe_routing lfeRouting;
    float *bufferData;
#ifdef FIX_194_LFE_DELAY_EXTREND
    int16_t binauralDelaySmp;
    float *lfeDelayBuffer;
#endif
    MCMASA_ANA_HANDLE hMcMasa;
} input_mc;

@@ -299,7 +295,6 @@ static void freeInputBaseBufferData( float **data )
    return;
}

#ifdef FIX_194_LFE_DELAY_EXTREND
static ivas_error allocateMcLfeDelayBuffer( float **lfeDelayBuffer, const int16_t data_size )
{
    *lfeDelayBuffer = (float *) malloc( data_size * sizeof( float ) );
@@ -322,7 +317,6 @@ static void freeMcLfeDelayBuffer( float **lfeDelayBuffer )
    return;
}

#endif
static IVAS_QUATERNION quaternionInit(
    void )
{
@@ -2179,9 +2173,7 @@ static ivas_error initMcBinauralRendering(
#ifdef SPLIT_REND_WITH_HEAD_ROT
    int16_t i;
#endif
#ifdef FIX_194_LFE_DELAY_EXTREND
    int32_t binauralDelayNs;
#endif
    int32_t outSampleRate;

    /* check if re-initialization */
@@ -2303,7 +2295,6 @@ static ivas_error initMcBinauralRendering(
        }
    }

#ifdef FIX_194_LFE_DELAY_EXTREND
    /* determine binaural delay ( used for aligning LFE to output signal ) */
    binauralDelayNs = max( ( inputMc->crendWrapper != NULL ) ? inputMc->crendWrapper->binaural_latency_ns : 0,
                           inputMc->tdRendWrapper.binaural_latency_ns );
@@ -2314,7 +2305,6 @@ static ivas_error initMcBinauralRendering(
        return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid delay for LFE binaural rendering!)" );
    }

#endif /* FIX_194_LFE_DELAY_EXTREND */
    return IVAS_ERR_OK;
}

@@ -2434,13 +2424,11 @@ static ivas_error setRendInputActiveMc(
        return IVAS_ERR_IO_CONFIG_PAIR_NOT_SUPPORTED;
    }

#ifdef FIX_194_LFE_DELAY_EXTREND
    if ( ( error = allocateMcLfeDelayBuffer( &inputMc->lfeDelayBuffer, MAX_BIN_DELAY_SAMPLES ) ) != IVAS_ERR_OK )
    {
        return error;
    }

#endif
    if ( ( error = allocateInputBaseBufferData( &inputMc->bufferData, MAX_BUFFER_LENGTH ) ) != IVAS_ERR_OK )
    {
        return error;
@@ -2462,9 +2450,7 @@ static ivas_error setRendInputActiveMc(
    initRotGains( inputMc->rot_gains_prev );
#endif
    inputMc->lfeRouting = defaultLfeRouting( inConfig, inputMc->customLsInput, outConfig, *inputMc->base.ctx.pCustomLsOut );
#ifdef FIX_194_LFE_DELAY_EXTREND
    set_zero( inputMc->lfeDelayBuffer, MAX_BIN_DELAY_SAMPLES );
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
    for ( i = 0; i < (int16_t) ( sizeof( inputMc->splitTdRendWrappers ) / sizeof( *inputMc->splitTdRendWrappers ) ); ++i )
@@ -2509,9 +2495,7 @@ static void clearInputMc(

    rendCtx = inputMc->base.ctx;

#ifdef FIX_194_LFE_DELAY_EXTREND
    freeMcLfeDelayBuffer( &inputMc->lfeDelayBuffer );
#endif
    freeInputBaseBufferData( &inputMc->bufferData );
    initRendInputBase( &inputMc->base, IVAS_REND_AUDIO_CONFIG_UNKNOWN, 0, rendCtx,
                       NULL, 0 );
@@ -3702,9 +3686,7 @@ ivas_error IVAS_REND_Open(
        hIvasRend->inputsMc[i].hReverb = NULL;
        hIvasRend->inputsMc[i].tdRendWrapper.hBinRendererTd = NULL;
        hIvasRend->inputsMc[i].bufferData = NULL;
#ifdef FIX_194_LFE_DELAY_EXTREND
        hIvasRend->inputsMc[i].lfeDelayBuffer = NULL;
#endif
        hIvasRend->inputsMc[i].nonDiegeticPan = nonDiegeticPan;
        hIvasRend->inputsMc[i].nonDiegeticPanGain = nonDiegeticPanGain;
        hIvasRend->inputsMc[i].hMcMasa = NULL;
@@ -6377,16 +6359,11 @@ static ivas_error renderLfeToBinaural(
    int16_t pose_idx, num_poses;
#endif
    float gain;
#ifdef FIX_194_LFE_DELAY_EXTREND
    int16_t ear_idx;
    float tmpLfeBuffer[MAX_BUFFER_LENGTH_PER_CHANNEL];
    int16_t frame_size, num_cpy_smpl_cur_frame, num_cpy_smpl_prev_frame;
    const float *lfeInput;
    float *writePtr;
#else
    int16_t i;
    float *readPtr, *writePtr;
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
    assert( ( getAudioConfigType( outConfig ) == IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && "Must be binaural output" );
@@ -6412,7 +6389,6 @@ static ivas_error renderLfeToBinaural(
        return IVAS_ERR_OK;
    }

#ifdef FIX_194_LFE_DELAY_EXTREND
    /* --- Prepare LFE signal to be added to binaural output --- */
    lfeInput = getSmplPtr( mcInput->base.inputBuffer, lfe_idx, 0 );
    frame_size = mcInput->base.inputBuffer.config.numSamplesPerChannel;
@@ -6426,7 +6402,6 @@ static ivas_error renderLfeToBinaural(
    v_multc( lfeInput, gain, tmpLfeBuffer + num_cpy_smpl_prev_frame, num_cpy_smpl_cur_frame );
    /* Save remaining LFE samples of current frame for next frame */
    mvr2r( lfeInput + num_cpy_smpl_cur_frame, mcInput->lfeDelayBuffer, num_cpy_smpl_prev_frame );
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
    /* Copy LFE to left and right binaural channels for all poses */
@@ -6441,51 +6416,19 @@ static ivas_error renderLfeToBinaural(

    for ( pose_idx = 0; pose_idx < num_poses; ++pose_idx )
    {
#ifdef FIX_194_LFE_DELAY_EXTREND
        for ( ear_idx = 0; ear_idx < BINAURAL_CHANNELS; ++ear_idx )
        {
            writePtr = getSmplPtr( outAudio, pose_idx * BINAURAL_CHANNELS + ear_idx, 0 );
            v_add( writePtr, tmpLfeBuffer, writePtr, frame_size );
        }
#else
        readPtr = getSmplPtr( mcInput->base.inputBuffer, lfe_idx, 0 );
        writePtr = getSmplPtr( outAudio, pose_idx * BINAURAL_CHANNELS, 0 );
        for ( i = 0; i < mcInput->base.inputBuffer.config.numSamplesPerChannel; i++ )
        {
            *writePtr++ += gain * ( *readPtr++ );
        }

        readPtr = getSmplPtr( mcInput->base.inputBuffer, lfe_idx, 0 );
        writePtr = getSmplPtr( outAudio, pose_idx * BINAURAL_CHANNELS + 1, 0 );
        for ( i = 0; i < mcInput->base.inputBuffer.config.numSamplesPerChannel; i++ )
        {
            *writePtr++ += gain * ( *readPtr++ );
        }
#endif /* FIX_194_LFE_DELAY_EXTREND */
    }
#else /* SPLIT_REND_WITH_HEAD_ROT */
    /* Copy LFE to left and right ears */
#ifdef FIX_194_LFE_DELAY_EXTREND
    for ( ear_idx = 0; ear_idx < BINAURAL_CHANNELS; ++ear_idx )
    {
        writePtr = getSmplPtr( outAudio, pose_idx * BINAURAL_CHANNELS + ear_idx, 0 );
        v_add( writePtr, tmpLfeBuffer, writePtr, frame_size );
    }
#else
    readPtr = getSmplPtr( mcInput->base.inputBuffer, lfe_idx, 0 );
    writePtr = getSmplPtr( outAudio, 0, 0 );
    for ( i = 0; i < mcInput->base.inputBuffer.config.numSamplesPerChannel; i++ )
    {
        *writePtr++ += gain * ( *readPtr++ );
    }

    readPtr = getSmplPtr( mcInput->base.inputBuffer, lfe_idx, 0 );
    writePtr = getSmplPtr( outAudio, 1, 0 );
    for ( i = 0; i < mcInput->base.inputBuffer.config.numSamplesPerChannel; i++ )
    {
        *writePtr++ += gain * ( *readPtr++ );
    }
#endif /* FIX_194_LFE_DELAY_EXTREND */
#endif /* SPLIT_REND_WITH_HEAD_ROT */

    pop_wmops();