Loading lib_rend/lib_rend.c +16 −9 Original line number Diff line number Diff line Loading @@ -65,6 +65,10 @@ #define MAX_BUFFER_LENGTH ( MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS ) #endif /* REND_STATIC_MEM_OPT */ #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 ) #endif Loading Loading @@ -2326,10 +2330,13 @@ 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 != NULL ) ? inputMc->tdRendWrapper.binaural_latency_ns : 0 ); inputMc->tdRendWrapper.binaural_latency_ns ); inputMc->binauralDelaySmp = (int16_t) roundf( (float) binauralDelayNs * *inputMc->base.ctx.pOutSampleRate / 1000000000.f ); assert( ( inputMc->binauralDelaySmp < L_FRAME48k >> 2 ) && "Invalid delay for LFE binaural rendering!" ); if ( inputMc->binauralDelaySmp > MAX_BIN_DELAY_SAMPLES ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid delay for LFE binaural rendering!)" ); } #endif /* FIX_194_LFE_DELAY_EXTREND */ return IVAS_ERR_OK; Loading Loading @@ -2449,7 +2456,7 @@ static ivas_error setRendInputActiveMc( } #ifdef FIX_194_LFE_DELAY_EXTREND if ( ( error = allocateMcLfeDelayBuffer( &inputMc->lfeDelayBuffer, L_FRAME48k >> 2 ) ) != IVAS_ERR_OK ) if ( ( error = allocateMcLfeDelayBuffer( &inputMc->lfeDelayBuffer, MAX_BIN_DELAY_SAMPLES ) ) != IVAS_ERR_OK ) { return error; } Loading @@ -2476,7 +2483,7 @@ static ivas_error setRendInputActiveMc( initRotGains( inputMc->rot_gains_prev ); inputMc->lfeRouting = defaultLfeRouting( inConfig, inputMc->customLsInput, outConfig, *inputMc->base.ctx.pCustomLsOut ); #ifdef FIX_194_LFE_DELAY_EXTREND set_zero( inputMc->lfeDelayBuffer, L_FRAME48k >> 2 ); set_zero( inputMc->lfeDelayBuffer, MAX_BIN_DELAY_SAMPLES ); #endif #ifdef SPLIT_REND_WITH_HEAD_ROT Loading Loading @@ -6388,25 +6395,25 @@ static ivas_error renderLfeToBinaural( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for temporary LFE to Binaural buffer" ); } /* 1. read from the LFE delay buffer and acc. to temp buffer 2. read remaining samples from the input LFE channel and acc. to temp buffer */ /* 1. read from the LFE delay buffer into temp buffer 2. read remaining samples from the input LFE channel into temp buffer */ readPtr = mcInput->lfeDelayBuffer; writePtr = tmpLfeBuffer; for ( i = 0; i < mcInput->binauralDelaySmp; i++ ) { *writePtr++ += gain * ( *readPtr++ ); *writePtr++ = gain * ( *readPtr++ ); } readPtr = getSmplPtr( mcInput->base.inputBuffer, lfe_idx, 0 ); for ( ; i < ( mcInput->base.inputBuffer.config.numSamplesPerChannel - mcInput->binauralDelaySmp ); i++ ) { *writePtr++ += gain * ( *readPtr++ ); *writePtr++ = gain * ( *readPtr++ ); } /* save leftover samples in the LFE delay buffer for next frame */ writePtr = mcInput->lfeDelayBuffer; for ( i = 0; i < mcInput->binauralDelaySmp; i++ ) { *writePtr++ += gain * ( *readPtr++ ); *writePtr++ = gain * ( *readPtr++ ); } #endif /* FIX_194_LFE_DELAY_EXTREND */ Loading Loading
lib_rend/lib_rend.c +16 −9 Original line number Diff line number Diff line Loading @@ -65,6 +65,10 @@ #define MAX_BUFFER_LENGTH ( MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL * MAX_INPUT_CHANNELS ) #endif /* REND_STATIC_MEM_OPT */ #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 ) #endif Loading Loading @@ -2326,10 +2330,13 @@ 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 != NULL ) ? inputMc->tdRendWrapper.binaural_latency_ns : 0 ); inputMc->tdRendWrapper.binaural_latency_ns ); inputMc->binauralDelaySmp = (int16_t) roundf( (float) binauralDelayNs * *inputMc->base.ctx.pOutSampleRate / 1000000000.f ); assert( ( inputMc->binauralDelaySmp < L_FRAME48k >> 2 ) && "Invalid delay for LFE binaural rendering!" ); if ( inputMc->binauralDelaySmp > MAX_BIN_DELAY_SAMPLES ) { return IVAS_ERROR( IVAS_ERR_WRONG_PARAMS, "Invalid delay for LFE binaural rendering!)" ); } #endif /* FIX_194_LFE_DELAY_EXTREND */ return IVAS_ERR_OK; Loading Loading @@ -2449,7 +2456,7 @@ static ivas_error setRendInputActiveMc( } #ifdef FIX_194_LFE_DELAY_EXTREND if ( ( error = allocateMcLfeDelayBuffer( &inputMc->lfeDelayBuffer, L_FRAME48k >> 2 ) ) != IVAS_ERR_OK ) if ( ( error = allocateMcLfeDelayBuffer( &inputMc->lfeDelayBuffer, MAX_BIN_DELAY_SAMPLES ) ) != IVAS_ERR_OK ) { return error; } Loading @@ -2476,7 +2483,7 @@ static ivas_error setRendInputActiveMc( initRotGains( inputMc->rot_gains_prev ); inputMc->lfeRouting = defaultLfeRouting( inConfig, inputMc->customLsInput, outConfig, *inputMc->base.ctx.pCustomLsOut ); #ifdef FIX_194_LFE_DELAY_EXTREND set_zero( inputMc->lfeDelayBuffer, L_FRAME48k >> 2 ); set_zero( inputMc->lfeDelayBuffer, MAX_BIN_DELAY_SAMPLES ); #endif #ifdef SPLIT_REND_WITH_HEAD_ROT Loading Loading @@ -6388,25 +6395,25 @@ static ivas_error renderLfeToBinaural( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Failed to allocate memory for temporary LFE to Binaural buffer" ); } /* 1. read from the LFE delay buffer and acc. to temp buffer 2. read remaining samples from the input LFE channel and acc. to temp buffer */ /* 1. read from the LFE delay buffer into temp buffer 2. read remaining samples from the input LFE channel into temp buffer */ readPtr = mcInput->lfeDelayBuffer; writePtr = tmpLfeBuffer; for ( i = 0; i < mcInput->binauralDelaySmp; i++ ) { *writePtr++ += gain * ( *readPtr++ ); *writePtr++ = gain * ( *readPtr++ ); } readPtr = getSmplPtr( mcInput->base.inputBuffer, lfe_idx, 0 ); for ( ; i < ( mcInput->base.inputBuffer.config.numSamplesPerChannel - mcInput->binauralDelaySmp ); i++ ) { *writePtr++ += gain * ( *readPtr++ ); *writePtr++ = gain * ( *readPtr++ ); } /* save leftover samples in the LFE delay buffer for next frame */ writePtr = mcInput->lfeDelayBuffer; for ( i = 0; i < mcInput->binauralDelaySmp; i++ ) { *writePtr++ += gain * ( *readPtr++ ); *writePtr++ = gain * ( *readPtr++ ); } #endif /* FIX_194_LFE_DELAY_EXTREND */ Loading