Commit 5651c7d1 authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Merge remote-tracking branch 'origin/main' into...

Merge remote-tracking branch 'origin/main' into 2159_basop_port_mr_2199_omasa_prerender_to_masa1tc_fix
parents 4c6d2153 bcd23367
Loading
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -74,6 +74,11 @@
#define IVAS_MIN16B_FLT ( -32768.0f )
#define IVAS_MAX16B_FX  32767
#define IVAS_MIN16B_FX  ( -32768 )

#ifdef NONBE_1359_FIX_IVASREND_OMASA_BINAURAL_LOUDNESS
#define OMASA_TDREND_MATCHING_GAIN_DB ( -2.0f )
#endif

#if !defined( DEBUGGING ) && !defined( WMOPS )
static
#endif
@@ -1262,20 +1267,41 @@ int main(
        }
    }

#ifndef NONBE_1359_FIX_IVASREND_OMASA_BINAURAL_LOUDNESS
    /* Set the total number of objects */
#endif
    if ( args.inConfig.numAudioObjects > 0 )
    {
#ifdef NONBE_1359_FIX_IVASREND_OMASA_BINAURAL_LOUDNESS
        /* Set the total number of objects */
#endif
        if ( ( error = IVAS_REND_SetTotalNumberOfObjects( hIvasRend, args.inConfig.numAudioObjects ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError in IVAS_REND_SetTotalNumberOfObjects(): %s\n", ivas_error_to_string( error ) );
            goto cleanup;
        }

#ifdef NONBE_1359_FIX_IVASREND_OMASA_BINAURAL_LOUDNESS
        /* Set the metadata delay for objects */
#endif
        Word32 var1 = (Word32) ( args.syncMdDelay );
        IF( ( error = IVAS_REND_SetIsmMetadataDelay( hIvasRend, var1 ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError in IVAS_REND_SetIsmMetadataDelay(): %s\n", ivas_error_to_string( error ) );
            goto cleanup;
        }

#ifdef NONBE_1359_FIX_IVASREND_OMASA_BINAURAL_LOUDNESS

        /* For OMASA input and BINAURAL output, apply a gain to objects to match the loudness with MASA part */
        if ( args.inConfig.numMasaBuses > 0 && args.outConfig.audioConfig == IVAS_AUDIO_CONFIG_BINAURAL )
        {
            for ( i = 0; i < args.inConfig.numAudioObjects; ++i )
            {
                args.inConfig.audioObjects[i].gain_dB += OMASA_TDREND_MATCHING_GAIN_DB;
            }
        }
#endif
    }

    IVAS_REND_LfePanMtx lfePanMatrix;
+4 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@
#define FIX_2164_ASSERT_IN_OMASA_PREPROC_FOR_EDIT            /* Nokia: Issue 2164: Prevent overflow when calculating equalization coefficient for editing before clamping to safe range */
#define FIX_BASOP_ASSERT_IN_TONAL_MDCT_PLC                   /* FhG: fix for issue 2165 - using saturating addition in tonal MDCT PLC function */
#define OPT_2146_BASOP_UTIL_ADD_MANT32EXP                    /* Dlb: optimized version of BASOP_Util_Add_Mant32Exp() */
#define FIX_2166_ASSERT_OSBA_PLC_STEREO_OUT                  /* FhG: fix for issue 2166 - add missing averaging factor 0.5 in for the sum of energies in function stereo_dft_dmx_swb_nrg_fx()*/

#define FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE                /* FhG: Use dynamic Q factor for synth_fx and synthFB_fx to prevent overflow */
/* ################### End FIXES switches ########################### */
@@ -112,9 +113,12 @@
#define FIX_NCHAN_BUFFERS                               /* VA: issue 1322: Correct the number of float buffers (channels) at the decoder */
#define FIX_RENDERER_STACK                              /* VA: issue 1322: reduction of renderers' buffers size */
#define JBM_MEMORY_OPT                                  /* VA: issue 916: optimization of RAM in the JBM decoder */
/*#define NONBE_1324_TC_BUFFER_MEMOERY_KEEP*/           /* VA: issue 1324: do not reset TSM memory in JBM bitrate switching */
#define FIX_1370_EXTERNAL_ORIENTATION_CHECK             /* Nokia: add sanity check for Euler angles for external orientations */
#define FIX_1413_IGF_INIT_PRINTOUT                      /* FhG: use correct variable for IGF initiliazation */
#define CODE_IMPROVEMENTS
#define NONBE_1359_FIX_IVASREND_OMASA_BINAURAL_LOUDNESS /* Nokia: issue 1339: Apply scaling to the object-part of OMASA for binaural rendering in IVAS_rend. */

#define NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING         /* Nokia: Fix OMASA to MASA1 rendering in IVAS_rend */

// object-editing feature porting
+34 −0
Original line number Diff line number Diff line
@@ -3638,6 +3638,10 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx(
    const Word16 n_samples_granularity     /* i  : new granularity of the renderer/buffer  */
)
{
#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP
    Word16 ch_idx, num_tc_buffer_mem, n_samples_still_available;
    Word32 tc_buffer_mem[MAX_INTERN_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES - 1];
#endif
#ifdef JBM_MEMORY_OPT
    ivas_error error;
#else
@@ -3649,6 +3653,28 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx(
    hTcBuffer = st_ivas->hTcBuffer;
    move16();

#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP
    num_tc_buffer_mem = 0;
    move16();
    n_samples_still_available = 0;
    move16();

    IF( st_ivas->hDecoderConfig->Opt_tsm )
    {
        /* save samples of the TC buffer from the previous frame */
        num_tc_buffer_mem = s_min( hTcBuffer->nchan_transport_internal, nchan_transport_internal );
        n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered );

        /* what is remaining from last frame needs always be smaller than the new granularity */
        assert( n_samples_still_available < n_samples_granularity );

        FOR( ch_idx = 0; ch_idx < num_tc_buffer_mem; ch_idx++ )
        {
            Copy32( hTcBuffer->tc_buffer_old_fx[ch_idx] + hTcBuffer->n_samples_flushed, tc_buffer_mem[ch_idx], n_samples_still_available );
        }
    }

#endif
    /* if granularity changes, adapt subframe_nb_slots */
    IF( NE_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) )
    {
@@ -3759,6 +3785,14 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx(
    }
#endif

#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP
    /* propagate samples of the TC buffer from the previous frame */
    FOR( ch_idx = 0; ch_idx < num_tc_buffer_mem; ch_idx++ )
    {
        Copy32( tc_buffer_mem[ch_idx], hTcBuffer->tc_buffer_old_fx[ch_idx], n_samples_still_available );
    }

#endif
    return IVAS_ERR_OK;
}

+5 −5
Original line number Diff line number Diff line
@@ -344,9 +344,8 @@ void ivas_osba_stereo_add_channels_fx(
    IF( EQ_16( ism_mode, ISM_SBA_MODE_DISC ) )
    {
        Word32 gain = gain_bed_fx;
        test();
        move32();

        // TODO: Enable gain editing feature (NE_32 ( gain, ONE_IN_Q_gain ) )
        test();
        IF( NE_32( gain, ONE_IN_Q29 ) && GT_32( gain, 0 ) )
        {
@@ -354,7 +353,8 @@ void ivas_osba_stereo_add_channels_fx(
            {
                FOR( i = 0; i < n_samples_to_render; i++ )
                {
                    Word32 tmp1 = Mpy_32_32( tc_fx[n + nchan_ism][i], gain ); // Q11 + Q29 - 31 = Q9
                    Word32 tmp1;
                    tmp1 = Mpy_32_32( tc_fx[n + nchan_ism][i], gain );    // Q11 + Q29 - 31 = Q9
                    tmp1 = L_shl( tmp1, 2 );                              // Q9 --> Q11
                    output_fx[n][i] = L_add_sat( output_fx[n][i], tmp1 ); // Q11
                }
+22 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@

*******************************************************************************************************/

#include "enh32.h"
#include <assert.h>
#include <stdint.h>
#include "options.h"
@@ -886,6 +887,27 @@ ivas_error ivas_sba_dec_render_fx(

        ivas_spar_dec_upmixer_sf_fx( st_ivas, output_fx_local, nchan_internal );

        test();
        IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
        {
            Word32 gain = st_ivas->hSbaIsmData->gain_bed_fx; // Q29
            move32();

            test();
            IF( NE_32( gain, ONE_IN_Q29 ) && NE_32( gain, 0 ) )
            {
                FOR( ch = 0; ch < nchan_out; ch++ )
                {
                    FOR( Word16 i = 0; i < n_samples_sf; i++ )
                    {
                        Word32 tmp1;
                        tmp1 = Mpy_32_32( output_fx_local[ch][i], gain ); // Q11 + Q29 - 31 = Q9
                        output_fx_local[ch][i] = L_shl( tmp1, 2 );        // Q9 --> Q11
                    }
                }
            }
        }

        FOR( ch = 0; ch < nchan_out; ch++ )
        {
            output_fx_local[ch] = output_fx_local[ch] + n_samples_sf; /*Q11*/
Loading