Commit 22e767ac authored by Nicolas Roussin's avatar Nicolas Roussin
Browse files

Merge branch 'main' into 2142-implement-basop-w_min-and-w_max-functions

parents 6a11f5d1 ba2aad75
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 −1
Original line number Diff line number Diff line
@@ -113,10 +113,13 @@
#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 */
#define FIX_1383_HEAD_TRACK_SANITIZER                   /* Nok: issue 1383: Fix head tracking struc values reading in renderer */

// object-editing feature porting
#define TMP_FIX_SPLIT_REND                              // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions)
+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;
}

+105 −1
Original line number Diff line number Diff line
@@ -668,10 +668,80 @@ static void ivas_omasa_dmx_fx(
    }
    set16_fx( data_e, 0, 4 );
    set16_fx( in_e, 0, 960 );
#ifdef NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING
    max_e = 0;
#endif

    FOR( i = 0; i < nchan_ism; i++ )
    {
#ifdef NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING
        IF( EQ_16( nchan_transport, 1 ) )
        {
            FOR( j = 0; j < input_frame; j++ )
            {
                data_out_f_fx[0][j] = L_add_sat( data_out_f_fx[0][j], data_in_f_fx[i][j] );
                move32();
            }
        }
        ELSE
        {
            azimuth_fx = extract_l( L_shr( ism_azimuth_fx[i], Q22 ) );     // Q0
            elevation_fx = extract_l( L_shr( ism_elevation_fx[i], Q22 ) ); // Q0

            ivas_ism_get_stereo_gains_fx( azimuth_fx, elevation_fx, &gains_fx[0], &gains_fx[1] );

            /* Downmix using the panning gains */
            FOR( j = 0; j < nchan_transport; j++ )
            {
                test();
                IF( abs_s( gains_fx[j] ) > 0 || L_abs( prev_gains_fx[i][j] ) > 0 )
                {
                    FOR( k = 0; k < input_frame; k++ )
                    {
                        g1_fx = interpolator_fx[k]; // Q15
                        move16();
                        scale = BASOP_Util_Add_MantExp( 16384, 1, negate( g1_fx ), 0, &g2_fx );

                        tmp1 = mult( g1_fx, gains_fx[j] );
                        tmp2 = mult( g2_fx, (Word16) L_shr( prev_gains_fx[i][j], 16 ) ); // Q: ( ( ( 15 - scale ) + ( Q31 - Q16 ) ) - Q15 ) -> ( 15 - scale )
                        scale = BASOP_Util_Add_MantExp( tmp1, 0, tmp2, scale, &tmp1 );

                        L_tmp = data_in_f_fx[i][k]; // data_in_q
                        move32();
                        tmp_e = sub( 31, *data_in_q );
                        move16();

                        L_tmp = Mpy_32_16_1( L_tmp, tmp1 );
                        scale = add( scale, tmp_e );

                        data_out_f_fx[j][k] = BASOP_Util_Add_Mant32Exp( data_out_f_fx[j][k], data_e[j], L_tmp, scale, &in_e[k] );
                        move32();
                    }
                    max_e = in_e[0];
                    move16();
                    FOR( l = 1; l < L_FRAME48k; l++ )
                    {
                        IF( LT_16( max_e, in_e[l] ) )
                        {
                            max_e = in_e[l];
                            move16();
                        }
                    }

                    FOR( l = 0; l < L_FRAME48k; l++ )
                    {
                        data_out_f_fx[j][l] = L_shr( data_out_f_fx[j][l], sub( max_e, in_e[l] ) ); // exponent: max_e, Q: ( 15 - max_e )
                        move32();
                    }
                    data_e[j] = max_e;
                    move16();
                }

                prev_gains_fx[i][j] = L_deposit_h( gains_fx[j] ); // Q31
                move32();
            }
        }
#else
        azimuth_fx = extract_l( L_shr( ism_azimuth_fx[i], Q22 ) );     // Q0
        elevation_fx = extract_l( L_shr( ism_elevation_fx[i], Q22 ) ); // Q0

@@ -727,13 +797,17 @@ static void ivas_omasa_dmx_fx(
            prev_gains_fx[i][j] = L_deposit_h( gains_fx[j] ); // Q31
            move32();
        }
#endif
    }

#ifdef NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING
    IF( NE_16( nchan_transport, 1 ) )
    {
        max_e = data_e[0];
        move16();
        FOR( i = 1; i < nchan_transport; i++ )
        {
        if ( LT_16( max_e, data_e[i] ) )
            IF( LT_16( max_e, data_e[i] ) )
            {
                max_e = data_e[i];
                move16();
@@ -748,12 +822,42 @@ static void ivas_omasa_dmx_fx(
                move32();
            }
        }
    }
#else
    max_e = data_e[0];
    move16();
    FOR( i = 1; i < nchan_transport; i++ )
    {
        IF( LT_16( max_e, data_e[i] ) )
        {
            max_e = data_e[i];
            move16();
        }
    }

    FOR( i = 0; i < nchan_transport; i++ )
    {
        FOR( j = 0; j < input_frame; j++ )
        {
            data_out_f_fx[i][j] = L_shr( data_out_f_fx[i][j], sub( max_e, data_e[i] ) ); // exponent: max_e, Q: ( 15 - max_e )
            move32();
        }
    }
#endif

    FOR( i = 0; i < nchan_transport; i++ )
    {
        Copy32( data_out_f_fx[i], data_in_f_fx[i], input_frame );
#ifdef NONBE_1362_FIX_OMASA_TO_MASA1_RENDERING
        IF( NE_16( nchan_transport, 1 ) )
        {
            *data_in_q = sub( 31, max_e );
            move16();
        }
#else
        *data_in_q = sub( 31, max_e );
        move16();
#endif
    }

    return;
+7 −0
Original line number Diff line number Diff line
@@ -1515,6 +1515,12 @@ ivas_error combine_external_and_head_orientations_rend(

    sr_pose_pred_axis = DEFAULT_AXIS;

#ifdef FIX_1383_HEAD_TRACK_SANITIZER
    IF( hHeadTrackData->headRotEnabled )
    {
        headRotQuaternions = hHeadTrackData->headPositions;
        listenerPos = hHeadTrackData->Pos;
#else
    IF( hHeadTrackData != NULL )
    {
        IF( hHeadTrackData->headRotEnabled )
@@ -1522,6 +1528,7 @@ ivas_error combine_external_and_head_orientations_rend(
            headRotQuaternions = hHeadTrackData->headPositions;
            listenerPos = hHeadTrackData->Pos;
        }
#endif
        sr_pose_pred_axis = hHeadTrackData->sr_pose_pred_axis;
    }
    ELSE IF( hExtOrientationData != NULL )