Commit 52a5892f authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

scale only relevant samples in external renderer temporary buffers

parent 94fd13cb
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@
#define FIX_BASOP_2332_ASAN_OVERFLOW_IN_EXT_DIRAC_REND  /* Nokia: basop issue 2332: Uses predefined memory sizes instead computing wrong */
#define FIX_BASOP_2333_MCMASA_ANA_MEMORY_LEAK           /* Nokia: basop issue 2333: Add missing free for direction_vector_e to ivas_mcmasa_ana_fx.c */
#define HARM_COREDECODER_FUNCTIONS                      /* VA: basop issue 2347: Remove various duplicated code in core-decoder  */
#define FIX_BASOP_2351_EXTREND_SCALE                    /* FhG: basop issue 2351: Only scale initialized samples in renderer, related to 2326 */

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

+88 −0
Original line number Diff line number Diff line
@@ -6516,9 +6516,17 @@ static ivas_error renderIsmToBinaural(
    ism_md_subframe_update_ext = extract_l( Mpy_32_32( ismInput->ism_metadata_delay_ms_fx, ONE_BY_SUBFRAME_LEN_MS_Q31 ) );
    copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpTDRendBuffer );

#ifdef FIX_BASOP_2351_EXTREND_SCALE
    FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; ++i )
#else
    FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
#endif
    {
#ifdef FIX_BASOP_2351_EXTREND_SCALE
        Scale_sig32( tmpTDRendBuffer[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */
#else
        Scale_sig32( tmpTDRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */
#endif
    }

    IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ism_md_subframe_update_ext,
@@ -6528,9 +6536,17 @@ static ivas_error renderIsmToBinaural(
        return error;
    }

#ifdef FIX_BASOP_2351_EXTREND_SCALE
    FOR( i = 0; i < outAudio.config.numChannels; ++i )
#else
    FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
#endif
    {
#ifdef FIX_BASOP_2351_EXTREND_SCALE
        Scale_sig32( tmpTDRendBuffer[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */
#else
        Scale_sig32( tmpTDRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */
#endif
    }

    IF( ismInput->hReverb != NULL )
@@ -6793,9 +6809,17 @@ static ivas_error renderIsmToBinauralReverb(
    ism_md_subframe_update_ext = extract_l( Mpy_32_32( ismInput->ism_metadata_delay_ms_fx, ONE_BY_SUBFRAME_LEN_MS_Q31 ) );
    copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpRendBuffer_fx );

#ifdef FIX_BASOP_2351_EXTREND_SCALE
    FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; ++i )
#else
    FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
#endif
    {
#ifdef FIX_BASOP_2351_EXTREND_SCALE
        Scale_sig32( tmpRendBuffer_fx[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */
#else
        Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */
#endif
    }

    IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &ismInput->tdRendWrapper, ismInput->base.inConfig, NULL, ismInput->base.ctx.pCombinedOrientationData, &ismInput->currentPos, ismInput->hReverb, ism_md_subframe_update_ext, *ismInput->base.ctx.pOutSampleRate, outAudio.config.numSamplesPerChannel, tmpRendBuffer_fx, &exp ) ), IVAS_ERR_OK ) )
@@ -6803,9 +6827,17 @@ static ivas_error renderIsmToBinauralReverb(
        return error;
    }

#ifdef FIX_BASOP_2351_EXTREND_SCALE
    FOR( i = 0; i < outAudio.config.numChannels; ++i )
#else
    FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
#endif
    {
#ifdef FIX_BASOP_2351_EXTREND_SCALE
        Scale_sig32( tmpRendBuffer_fx[i], outAudio.config.numSamplesPerChannel, negate( sub( 11, exp ) ) ); /* Q(exp) */
#else
        Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, negate( sub( 11, exp ) ) ); /* Q(exp) */
#endif
    }

    IF( ismInput->hReverb != NULL )
@@ -7104,9 +7136,17 @@ static ivas_error renderIsmToSplitBinaural(
        }


#ifdef FIX_BASOP_2351_EXTREND_SCALE
        FOR( i = 0; i < ismInput->base.inputBuffer.config.numChannels; ++i )
#else
        FOR( i = 0; i < MAX_NUM_OBJECTS; ++i )
#endif
        {
#ifdef FIX_BASOP_2351_EXTREND_SCALE
            Scale_sig32( tmpProcessing[i], ismInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */
#else
            Scale_sig32( tmpProcessing[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */
#endif
        }

        /* Render */
@@ -7118,7 +7158,11 @@ static ivas_error renderIsmToSplitBinaural(

        FOR( i = 0; i < BINAURAL_CHANNELS; ++i )
        {
#ifdef FIX_BASOP_2351_EXTREND_SCALE
            Scale_sig32( tmpProcessing[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */
#else
            Scale_sig32( tmpProcessing[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */
#endif
        }

        IF( ismInput->hReverb != NULL )
@@ -7521,9 +7565,17 @@ static ivas_error renderMcToBinaural(
    {
        copyBufferTo2dArray_fx( mcInput->base.inputBuffer, tmpRendBuffer_fx );

#ifdef FIX_BASOP_2351_EXTREND_SCALE
        FOR( i = 0; i < mcInput->base.inputBuffer.config.numChannels; ++i )
#else
        FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
#endif
        {
#ifdef FIX_BASOP_2351_EXTREND_SCALE
            Scale_sig32( tmpRendBuffer_fx[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */
#else
            Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */
#endif
        }
        IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pCombinedOrientationData, NULL, mcInput->hReverb,
                                                               0, *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer_fx, &exp ) ),
@@ -7532,9 +7584,17 @@ static ivas_error renderMcToBinaural(
            return error;
        }

#ifdef FIX_BASOP_2351_EXTREND_SCALE
        FOR( i = 0; i < outAudio.config.numChannels; ++i )
#else
        FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
#endif
        {
#ifdef FIX_BASOP_2351_EXTREND_SCALE
            Scale_sig32( tmpRendBuffer_fx[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */
#else
            Scale_sig32( tmpRendBuffer_fx[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */
#endif
        }
    }
    ELSE
@@ -7644,9 +7704,17 @@ static ivas_error renderMcToBinauralRoom(
    {
        copyBufferTo2dArray_fx( mcInput->base.inputBuffer, tmpRendBuffer );

#ifdef FIX_BASOP_2351_EXTREND_SCALE
        FOR( i = 0; i < mcInput->base.inputBuffer.config.numChannels; ++i )
#else
        FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
#endif
        {
#ifdef FIX_BASOP_2351_EXTREND_SCALE
            Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numChannels, sub( Q11, exp ) ); /* Q11 */
#else
            Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */
#endif
        }

        IF( NE_32( ( error = ivas_td_binaural_renderer_ext_fx( &mcInput->tdRendWrapper, mcInput->base.inConfig, &mcInput->customLsInput, mcInput->base.ctx.pCombinedOrientationData, NULL, mcInput->hReverb,
@@ -7656,9 +7724,17 @@ static ivas_error renderMcToBinauralRoom(
            return error;
        }

#ifdef FIX_BASOP_2351_EXTREND_SCALE
        FOR( i = 0; i < outAudio.config.numChannels; ++i )
#else
        FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
#endif
        {
#ifdef FIX_BASOP_2351_EXTREND_SCALE
            Scale_sig32( tmpRendBuffer[i], outAudio.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */
#else
            Scale_sig32( tmpRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */
#endif
        }
    }
    ELSE
@@ -8001,9 +8077,17 @@ static ivas_error renderMcToSplitBinaural(
            /* perform rotation in source format to tmpRotBuffer */
            pCombinedOrientationDataLocal = &combinedOrientationDataLocal;

#ifdef FIX_BASOP_2351_EXTREND_SCALE
            FOR( i = 0; i < mcInput->base.inputBuffer.config.numChannels; ++i )
#else
            FOR( i = 0; i < MAX_OUTPUT_CHANNELS; ++i )
#endif
            {
#ifdef FIX_BASOP_2351_EXTREND_SCALE
                Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, sub( Q11, exp ) ); /* Q11 */
#else
                Scale_sig32( tmpRendBuffer[i], L_FRAME48k, sub( Q11, exp ) ); /* Q11 */
#endif
            }
            /* Render */
            IF( ( error = ivas_td_binaural_renderer_ext_fx( ( pos_idx == 0 ) ? &mcInput->tdRendWrapper : &mcInput->splitTdRendWrappers[pos_idx - 1], mcInput->base.inConfig, &mcInput->customLsInput, &pCombinedOrientationDataLocal, NULL, mcInput->hReverb, 0, /* Ism Audio Metadata Delay Sync in ms for External Renderer */ *mcInput->base.ctx.pOutSampleRate, mcInput->base.inputBuffer.config.numSamplesPerChannel, tmpRendBuffer, &exp ) ) != IVAS_ERR_OK )
@@ -8012,7 +8096,11 @@ static ivas_error renderMcToSplitBinaural(
            }
            FOR( i = 0; i < BINAURAL_CHANNELS; ++i )
            {
#ifdef FIX_BASOP_2351_EXTREND_SCALE
                Scale_sig32( tmpRendBuffer[i], mcInput->base.inputBuffer.config.numSamplesPerChannel, negate( sub( Q11, exp ) ) ); /* Q(exp) */
#else
                Scale_sig32( tmpRendBuffer[i], L_FRAME48k, negate( sub( Q11, exp ) ) ); /* Q(exp) */
#endif
            }

            /* Copy rendered audio to tmp storage buffer. Copying directly to output would