Commit b5bbda93 authored by sagnowski's avatar sagnowski
Browse files

Merge branch 'main' into 2173-ubsan-in-jbm-pcmdsp-apa-fx-c

parents 3ef7c662 120c6cd3
Loading
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -316,8 +316,12 @@ void hp20_fx_32_opt(
    prescale = s_min( prescale, diff );

    prescale = sub( 1 + HP20_FX_COEFF_SCALE, prescale );

#ifdef FIX_2086_ENABLE_HP20_OPT_FOR_ENC
    if ( EQ_16( prescale_current_frame, 1 + HP20_FX_COEFF_SCALE - 31 ) || // signal_fx buffer contains only zeros, so use the mem_fx scale_factor instead
         LT_16( prescale_current_frame, prescale ) )                      // To avoid overflow in the subsequent shr() scaling for W_y1, W_y2, x2, and x1 calculations before the for loop.
#else
    if ( EQ_16( prescale_current_frame, 1 + HP20_FX_COEFF_SCALE - 31 ) ) // signal_fx buffer contains only zeros, so use the mem_fx scale_factor instead
#endif
    {
        prescale_current_frame = prescale;
    }
+7 −3
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@
#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_2086_ENABLE_HP20_OPT_FOR_ENC                     /* FhG: Enable hp20_fx_32_opt() for Encoder */
#define FIX_1793_DEC_MC_TO_MONO_SCALING_ISSUE                /* FhG: Use dynamic Q factor for synth_fx and synthFB_fx to prevent overflow */
#define FIX_2170_ASSERT_IN_FFT3                              /* Eri: Assert in fft3_fx from EVS, adding _sat */
#define FIX_2082_FP_LEFTOVERS_OMASA_DEC                      /* Nokia: fix for issue 2082, cleaning remaining floating point code */
@@ -94,8 +94,10 @@
#define FIX_2176_ASSERT_DEC_MAP_PARAMS_DIRAC2STEREO          /* FhG: Reduce hStereoDft->q_smooth_buf_fx by one to prevent overflow in the subframe_band_nrg[][] calculation */
#define FIX_2015_PREMPH_SAT_ALT                              /* VA: saturation can happen during preemphasis filtering due to a too aggressive scaling factor, allows preemphis to get 1 more bit headroom */
#define FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE       /* Nokia: Fixes float  to fx conversion in decoder app with object edit file interface */
#define FIX_2070_JBM_TC_CHANNEL_RESCALING_ISSUE              /* Eri/Orange: scale_sig32 problem on p_tc_fx[] */

#define FIX_2173_UBSAN_IN_JBM_PCMDSP_APA
#define FIX_2173_UBSAN_IN_JBM_PCMDSP_APA                     /* FhG: Fix UBSAN problems in jbm_pcmdsp_apa_fx.c */
#define FIX_1947_DEC_HIGH_MLD_FOR_STEREO2MONO                /* FhG: Make Q-factor of synth_16_fx and output_16_fx dynamic to prevent overflow in HQ_CORE mode */
/* ################### End FIXES switches ########################### */

/* #################### Start BASOP porting switches ############################ */
@@ -124,7 +126,7 @@
#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 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
@@ -135,6 +137,7 @@
#define FIX_1411_IGF_CRASH_BW_SWITCHING                 /* FhG: Fix for issue 1411: fixes crash that can happen for IGF with BW switching and DTX*/
#define NONBE_MDCT_ST_DTX_FIX_SUBOPT_SPATIAL_CNG       /* FhG: Fix MDCT-Stereo comfort noise for certain noise types */
#define NONBE_1344_REND_MASA_LOW_FS                     /* Nokia: Issue 1344: Fix sanitizer errors when using IVAS_rend to render MASA with lower sampling rates */
#define NONBE_1412_AVOID_ROUNDING_AZ_ELEV               /* FhG:  Avoid rounding when passing azimuth and elevation to efap_determine_gains() */

// 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)
@@ -144,6 +147,7 @@
#define FIX_1372_OSBA_OBJECT_EDITING                    /* VA: issue 1372: Fix OSBA object-editing in BINAURAL_ROOM_IR */
#define FIX_2140_OBJECT_EDITING_SANITIZER_ISSUES        /* Nokia: Issue 2140, fixes three different sanitizer issues persisting in object editing code. */
#define NONBE_FIX_1172_OBJ_EDIT_JBM                     /* VA: issue 1172: fix OMASA object editing in JBM */
#define FIX_2193_ISM_GAINS_WITH_OE                      /* FhG: fix issue 2193: use edited angles in ISM gain calculation */

/* #################### End BASOP porting switches ############################ */

+8 −2
Original line number Diff line number Diff line
@@ -643,8 +643,14 @@ ivas_error ivas_core_dec_fx(
            ivas_hq_core_dec_fx( st, synth_16_fx[n], &Q_synth, output_frame, NORMAL_HQ_CORE, core_switching_flag[n], output_16_fx[n], &Q_output );

            Copy_Scale_sig_16_32_DEPREC( output_16_fx[n], output_32_fx[n], L_FRAME48k, sub( Q11, Q_output ) ); // Q11
#ifdef FIX_1947_DEC_HIGH_MLD_FOR_STEREO2MONO
            st->Q_syn_factor = s_min( 0, s_min( Q_synth, Q_output ) );
            Scale_sig( synth_16_fx[n], output_frame, sub( st->Q_syn_factor, Q_synth ) ); // st->Q_syn_factor
            Scale_sig( output_16_fx[n], L_FRAME48k, sub( st->Q_syn_factor, Q_output ) ); // st->Q_syn_factor
#else
            Scale_sig( synth_16_fx[n], output_frame, negate( Q_synth ) );                       // Q0
            Scale_sig( output_16_fx[n], L_FRAME48k, negate( Q_output ) );                       // Q0
#endif
        }

        /*---------------------------------------------------------------------*
+21 −2
Original line number Diff line number Diff line
@@ -942,7 +942,9 @@ void ivas_ism_dec_digest_tc_fx(
        ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && st_ivas->hDecoderConfig->Opt_Headrotation == 0 ) )
    {
        Word16 i;
#ifndef NONBE_1412_AVOID_ROUNDING_AZ_ELEV
        Word32 azimuth_fx, elevation_fx;
#endif

        /* we have a full frame interpolator, adapt it */
        /* for BE testing */
@@ -1011,9 +1013,11 @@ void ivas_ism_dec_digest_tc_fx(
            }
            ELSE
            {
#ifndef NONBE_1412_AVOID_ROUNDING_AZ_ELEV
                // TODO tmu review when #215 is resolved
                azimuth_fx = L_shr( L_add( st_ivas->hIsmMetaData[i]->edited_azimuth_fx, 2097152 ), Q22 );     // Q0 ,2097152 = .5f in Q22
                elevation_fx = L_shr( L_add( st_ivas->hIsmMetaData[i]->edited_elevation_fx, 2097152 ), Q22 ); // Q0 ,2097152 = .5f in Q22
#endif

                test();
                test();
@@ -1029,6 +1033,9 @@ void ivas_ism_dec_digest_tc_fx(
                      ( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) && EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) ) &&
                    st_ivas->hCombinedOrientationData == NULL )
                {
#ifdef NONBE_1412_AVOID_ROUNDING_AZ_ELEV
                    Word32 elevation_fx = st_ivas->hIsmMetaData[i]->edited_elevation_fx;
#endif
                    if ( st_ivas->hIntSetup.is_planar_setup )
                    {
                        /* If no elevation support in output format, then rendering should be done with zero elevation */
@@ -1038,10 +1045,17 @@ void ivas_ism_dec_digest_tc_fx(

                    IF( st_ivas->hEFAPdata != NULL )
                    {
#ifndef NONBE_1412_AVOID_ROUNDING_AZ_ELEV
                        azimuth_fx = L_shl( azimuth_fx, Q22 );     // Q22
                        elevation_fx = L_shl( elevation_fx, Q22 ); // Q22
#endif


#ifdef NONBE_1412_AVOID_ROUNDING_AZ_ELEV
                        efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIsmMetaData[i]->edited_azimuth_fx, elevation_fx, EFAP_MODE_EFAP );
#else
                        efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], azimuth_fx, elevation_fx, EFAP_MODE_EFAP );
#endif
                        // TODO: align Q values properly
                        IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q29 ) )
                        {
@@ -1055,8 +1069,13 @@ void ivas_ism_dec_digest_tc_fx(
                         EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) )
                {
                    /*get HOA gets for direction (ACN/SN3D)*/
#ifdef FIX_2193_ISM_GAINS_WITH_OE
                    Word16 azi = round_fx( L_shr( st_ivas->hIsmMetaData[i]->edited_azimuth_fx, Q22 - Q16 ) );   // Q0
                    Word16 ele = round_fx( L_shr( st_ivas->hIsmMetaData[i]->edited_elevation_fx, Q22 - Q16 ) ); // Q0
#else
                    Word16 azi = shr( extract_h( st_ivas->hIsmMetaData[i]->azimuth_fx ), 22 - 16 );                                                                            // Q0
                    Word16 ele = shr( extract_h( st_ivas->hIsmMetaData[i]->elevation_fx ), 22 - 16 );                                                                          // Q0
#endif

                    ivas_dirac_dec_get_response_fx( azi, ele, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIntSetup.ambisonics_order, Q30 );

+21 −2
Original line number Diff line number Diff line
@@ -804,6 +804,10 @@ ivas_error ivas_jbm_dec_tc_fx(
            {
                Scale_sig32( p_output_fx[n], output_frame, sub( Q11, output_q ) ); // Q11
            }
#ifdef NONBE_1324_TC_BUFFER_MEMOERY_KEEP
            st_ivas->hCPE[0]->q_output_mem_fx[0] = output_q;
            st_ivas->hCPE[0]->q_output_mem_fx[1] = output_q;
#endif
        }
    }
    ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
@@ -2155,10 +2159,12 @@ ivas_error ivas_jbm_dec_render_fx(
                    FOR( i = 0; i < nchan_in; i++ )
                    {
                        scale_sig32( p_output_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor
#ifndef FIX_1330_JBM_MEMORY
                        IF( st_ivas->hDecoderConfig->Opt_tsm )
                        {
                            scale_sig32( p_tc_fx[i], *nSamplesRendered, negate( sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ) ); // Q = *st_ivas->hCrendWrapper->p_io_qfactor
                        }
#endif
                    }
                }
                ELSE
@@ -2171,22 +2177,34 @@ ivas_error ivas_jbm_dec_render_fx(

                IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
                {
#ifdef FIX_1330_JBM_MEMORY
                    IF( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData,
                                                                           &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK )
#else
                    IF( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData,
                                                                           &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : p_tc_fx, p_output_fx, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK )
#endif
                    {
                        return error;
                    }
                }
                ELSE
                {
#ifdef FIX_1330_JBM_MEMORY
                    IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData,
                                                                            &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, p_output_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ),
                               IVAS_ERR_OK ) )
#else
                    IF( NE_32( ( error = ivas_rend_crendProcessSubframe_fx( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData,
                                                                            &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output_fx : p_tc_fx, p_output_fx, *nSamplesRendered, output_Fs, 0 ) ),
                               IVAS_ERR_OK ) )
#endif
                    {
                        return error;
                    }

                    // Todo main-pc update: This might be needed also in the split rendering path
#ifndef FIX_1330_JBM_MEMORY
                    IF( st_ivas->hDecoderConfig->Opt_tsm )
                    {
                        IF( NE_16( exp, *st_ivas->hCrendWrapper->p_io_qfactor ) )
@@ -2197,7 +2215,7 @@ ivas_error ivas_jbm_dec_render_fx(
                            }
                        }
                    }

#endif
                    ivas_binaural_add_LFE_fx( st_ivas, *nSamplesRendered, p_tc_fx, p_output_fx );
                }

@@ -2215,12 +2233,13 @@ ivas_error ivas_jbm_dec_render_fx(
                {
                    scale_sig32( p_output_fx[i], *nSamplesRendered, sub( Q11, *st_ivas->hCrendWrapper->p_io_qfactor ) ); // Q11
                }

#ifndef FIX_1330_JBM_MEMORY
                IF( st_ivas->hDecoderConfig->Opt_tsm && crendInPlaceRotation )
                {
                    n = 0;
                    move16();
                }
#endif

                FOR( i = n; i < nchan_in; i++ )
                {
Loading