Commit 6b4dc893 authored by emerit's avatar emerit
Browse files

Merge branch 'main' into...

Merge branch 'main' into 2064-asan-crash-due-to-heap-use-after-free-in-hrtf-loading-with-binaural_room_ir
parents 1edf97b8 fb1274d2
Loading
Loading
Loading
Loading
Loading
+0 −21
Original line number Diff line number Diff line
@@ -14,8 +14,6 @@ SRC_APP = apps
BUILD        = build
OBJDIR       = obj

INCLUDE_SPLIT = 1

SRC_DIRS  = $(sort -u $(SRC_LIBBASOP) $(SRC_LIBCOM) $(SRC_LIBDEBUG) $(SRC_LIBDEC) $(SRC_LIBENC) $(SRC_LIBREND) $(SRC_LIBISAR) $(SRC_LC3PLUS) $(SRC_LIBUTIL) $(SRC_APP)) 

# Name of CLI binaries
@@ -33,7 +31,6 @@ LIB_LIBISAR ?= libisar.a
LIB_LC3PLUS  	?= liblc3plus.a
LIB_LIBUTIL  	?= libivasutil.a


# Default tool settings
CC        ?= gcc
RM        ?= rm -f
@@ -157,12 +154,7 @@ SRCS_LIBENC = $(foreach DIR,$(SRC_LIBENC),$(patsubst $(DIR)/%,%,$(wildcard $(D
SRCS_LIBREND  = $(foreach DIR,$(SRC_LIBREND),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c)))
SRCS_LIBUTIL  = $(foreach DIR,$(SRC_LIBUTIL),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c)))
SRCS_LIBISAR  = $(foreach DIR,$(SRC_LIBISAR),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c)))
ifeq "$(INCLUDE_SPLIT)" "1"
SRCS_LC3PLUS  = $(foreach DIR,$(SRC_LC3PLUS),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c)))
else
# SRCS_LIBREND := $(filter-out $(SRCS_SPLIT_REND),$(SRCS_LIBREND))
# SRCS_LIBUTIL := $(filter-out $(SRCS_SPLIT_REND),$(SRCS_LIBUTIL))
endif

OBJS_LIBBASOP    = $(addprefix $(OBJDIR)/,$(SRCS_LIBBASOP:.c=.o))
OBJS_LIBCOM      = $(addprefix $(OBJDIR)/,$(SRCS_LIBCOM:.c=.o))
@@ -213,11 +205,8 @@ $(LIB_LIBREND): $(OBJS_LIBREND) $(OBJS_LIBISAR)
	$(QUIET_AR)$(AR) rcs $@ $^

$(LIB_LC3PLUS): $(OBJS_LC3PLUS)
ifeq "$(INCLUDE_SPLIT)" "1"
	$(QUIET_AR)$(AR) rcs $@ $^
else

endif
# Dependency on OBJS_LIBCOM added temporarily for unit-test to work
$(LIB_LIBUTIL): $(OBJS_LIBUTIL) $(OBJS_LIBBASOP) $(OBJS_LIBCOM)
	$(QUIET_AR)$(AR) rcs $@ $^
@@ -226,23 +215,13 @@ $(CLI_APIENC): $(OBJS_CLI_APIENC) $(LIB_LIBBASOP) $(LIB_LIBENC) $(LIB_LIBCOM) $(
	$(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIENC) -L. -livasbasop -livasenc -livascom -livasutil -livasdebug $(LDLIBS) -o $(CLI_APIENC)

$(CLI_APIDEC): $(OBJS_CLI_APIDEC) $(LIB_LIBBASOP) $(LIB_LIBDEC) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS) $(LIB_LIBISAR)
ifeq "$(INCLUDE_SPLIT)" "1"
	$(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIDEC) -L. -livasbasop -livasdec -livascom -livasutil -livasdebug -llc3plus $(LDLIBS) -o $(CLI_APIDEC)
else
	$(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APIDEC) -L. -livasbasop -livasdec -livascom -livasutil -livasdebug $(LDLIBS) -o $(CLI_APIDEC)
endif

$(CLI_APIREND): $(OBJS_CLI_APPREND) $(LIB_LIBBASOP) $(LIB_LIBREND) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LIBDEC) $(LIB_LC3PLUS) $(LIB_LIBISAR)
ifeq "$(INCLUDE_SPLIT)" "1"
	$(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APPREND) -L. -livasbasop -livasrend -lisar -livasdec -livasutil -livasdebug -livascom -llc3plus $(LDLIBS) -o $(CLI_APIREND)
else
	$(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APPREND) -L. -livasbasop -livasrend -livasdec -livasutil -livasdebug -livascom $(LDLIBS) -o $(CLI_APIREND)
endif

$(CLI_APIPOSTREND): $(OBJS_CLI_APPPOSTREND) $(LIB_LIBBASOP) $(LIB_LIBISAR) $(LIB_LIBCOM) $(LIB_LIBUTIL) $(LIB_LIBDEBUG) $(LIB_LC3PLUS)
ifeq "$(INCLUDE_SPLIT)" "1"
	$(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_CLI_APPPOSTREND) -L. -livasbasop -lisar -livasutil -livasdebug -livascom -llc3plus $(LDLIBS) -o $(CLI_APIPOSTREND)
endif

libs: $(LIB_LIBBASOP) $(LIB_LIBENC) $(LIB_LIBDEBUG) $(LIB_LIBCOM) $(LIB_LIBDEC) $(LIB_LIBREND) $(LIB_LIBISAR) $(LIB_LC3PLUS) $(LIB_LIBUTIL)

+5 −0
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@
#define FIX_1970_SBA_CRASH                                   /* Dlb: Fix for issue 1970, SBA crash */

#define FIX_1978_SAT_MISSING_IN_GAIN_ENC                     /* VA:  Fix add saturation missing that lead to a crash in P800-10 */
#define FIX_1981_MAXIMUM_EXP_FX                              /* FhG: Fix bug in function to find maximum value in vector */
#define FIX_1981_MAXIMUM_EXP_FX_ZEROMANTISSA                 /* FhG: Fix bug in function to find maximum value in vector:zero-mantissa fix*/

#define FIX_1979_SAT_MISSING_IN_LSF_ENC                      /* VA: Proposal to fix 1979, saturation in lsf_enc, NOkia to review */
#define FIX_1946_CRASH_JBM_PROCESSING                        /* FhG: Increased guard bits of DFT_fx */
@@ -104,6 +106,9 @@

#define FIX_1962_FORMAT_CONV_SPECTRAL_DIFF                   /* FhG: Improved precision of targetEnergy in ivas_ls_setup_conversion_process_mdct_fx() */
#define FIX_2003_CON_TCX_OVERFLOW                            /* FhG: Use a dynamic scaling factor for the synth buffer at the output of con_tcx_ivas_fx() */
#define OPT_TCXLTP_FILTER_LOOP                               /* FhG: optimize loop in tcx_ltp_synth_filter */


/* #################### Start BASOP porting switches ############################ */

#define NONBE_1244_FIX_SWB_BWE_MEMORY                   /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */
+299 −1
Original line number Diff line number Diff line
@@ -492,6 +492,155 @@ static void tcx_ltp_synth_filter(
                step = negate( step );
        }

#ifdef OPT_TCXLTP_FILTER_LOOP
        IF( zir != NULL )
        {
            IF( fade != 0 )
            {
                FOR( j = 0; j < length; j++ )
                {
                    s = L_deposit_l( 0 );
                    s2 = L_deposit_l( 0 );
                    k = 0;
                    move16();
                    FOR( i = 0; i < L; i++ )
                    {
                        s = L_mac_sat( L_mac_sat( s, w0[k], x0[i] ), w1[k], x1[-i] );   /* Qx */
                        s2 = L_mac_sat( L_mac_sat( s2, v0[k], y0[i] ), v1[k], y1[-i] ); /* Qx */
                        k = k + pitch_res;
                    }

                    /* s2 *= ALPHA;
                       normal:      synth_ltp[j] = synth[j] - gain * s2 + gain * s;
                       zir:         synth_ltp[j] = synth[j] - gain * s2 + gain * s - zir[j];
                       fade-in/out: synth_ltp[j] = synth[j] - alpha * gain * s2 + alpha * gain * s; */
                    i = sub_sat( round_fx_sat( s ), mult_r_sat( round_fx_sat( s2 ), ALPHA ) ); /* Qx */
                    k = mult_r( gain, i );                                                     /* Qx */
                    k = mult_r( k, alpha );                                                    /* Qx */
                    k = add_sat( synth[j], k );                                                /* Qx */
                    k = sub_sat( k, zir[j] );                                                  /* Qx */

                    synth_ltp[j] = k; /* Qx */
                    move16();

                    BASOP_SATURATE_WARNING_OFF_EVS;
                    alpha = add_sat( alpha, step );
                    BASOP_SATURATE_WARNING_ON_EVS;

                    x0++;
                    x1++;
                    y0++;
                    y1++;
                }
            }
            ELSE
            {
                FOR( j = 0; j < length; j++ )
                {
                    s = L_deposit_l( 0 );
                    s2 = L_deposit_l( 0 );
                    k = 0;
                    move16();
                    FOR( i = 0; i < L; i++ )
                    {
                        s = L_mac_sat( L_mac_sat( s, w0[k], x0[i] ), w1[k], x1[-i] );   /* Qx */
                        s2 = L_mac_sat( L_mac_sat( s2, v0[k], y0[i] ), v1[k], y1[-i] ); /* Qx */
                        k = k + pitch_res;
                    }

                    /* s2 *= ALPHA;
                       normal:      synth_ltp[j] = synth[j] - gain * s2 + gain * s;
                       zir:         synth_ltp[j] = synth[j] - gain * s2 + gain * s - zir[j];
                       fade-in/out: synth_ltp[j] = synth[j] - alpha * gain * s2 + alpha * gain * s; */
                    i = sub_sat( round_fx_sat( s ), mult_r_sat( round_fx_sat( s2 ), ALPHA ) ); /* Qx */
                    k = mult_r( gain, i );                                                     /* Qx */
                    k = add_sat( synth[j], k );                                                /* Qx */
                    k = sub_sat( k, zir[j] );                                                  /* Qx */

                    synth_ltp[j] = k; /* Qx */
                    move16();

                    x0++;
                    x1++;
                    y0++;
                    y1++;
                }
            }
        }
        ELSE
        {
            IF( fade != 0 )
            {
                FOR( j = 0; j < length; j++ )
                {
                    s = L_deposit_l( 0 );
                    s2 = L_deposit_l( 0 );
                    k = 0;
                    move16();
                    FOR( i = 0; i < L; i++ )
                    {
                        s = L_mac_sat( L_mac_sat( s, w0[k], x0[i] ), w1[k], x1[-i] );   /* Qx */
                        s2 = L_mac_sat( L_mac_sat( s2, v0[k], y0[i] ), v1[k], y1[-i] ); /* Qx */
                        k = k + pitch_res;
                    }

                    /* s2 *= ALPHA;
                       normal:      synth_ltp[j] = synth[j] - gain * s2 + gain * s;
                       zir:         synth_ltp[j] = synth[j] - gain * s2 + gain * s - zir[j];
                       fade-in/out: synth_ltp[j] = synth[j] - alpha * gain * s2 + alpha * gain * s; */
                    i = sub_sat( round_fx_sat( s ), mult_r_sat( round_fx_sat( s2 ), ALPHA ) ); /* Qx */
                    k = mult_r( gain, i );                                                     /* Qx */
                    k = mult_r( k, alpha );
                    k = add_sat( synth[j], k ); /* Qx */

                    synth_ltp[j] = k; /* Qx */
                    move16();

                    BASOP_SATURATE_WARNING_OFF_EVS;
                    alpha = add_sat( alpha, step );
                    BASOP_SATURATE_WARNING_ON_EVS;

                    x0++;
                    x1++;
                    y0++;
                    y1++;
                }
            }
            ELSE
            {
                FOR( j = 0; j < length; j++ )
                {
                    s = L_deposit_l( 0 );
                    s2 = L_deposit_l( 0 );
                    k = 0;
                    move16();
                    FOR( i = 0; i < L; i++ )
                    {
                        s = L_mac_sat( L_mac_sat( s, w0[k], x0[i] ), w1[k], x1[-i] );   /* Qx */
                        s2 = L_mac_sat( L_mac_sat( s2, v0[k], y0[i] ), v1[k], y1[-i] ); /* Qx */
                        k = k + pitch_res;
                    }

                    /* s2 *= ALPHA;
                       normal:      synth_ltp[j] = synth[j] - gain * s2 + gain * s;
                       zir:         synth_ltp[j] = synth[j] - gain * s2 + gain * s - zir[j];
                       fade-in/out: synth_ltp[j] = synth[j] - alpha * gain * s2 + alpha * gain * s; */
                    i = sub_sat( round_fx_sat( s ), mult_r_sat( round_fx_sat( s2 ), ALPHA ) ); /* Qx */
                    k = mult_r( gain, i );                                                     /* Qx */
                    k = add_sat( synth[j], k );                                                /* Qx */

                    synth_ltp[j] = k; /* Qx */
                    move16();


                    x0++;
                    x1++;
                    y0++;
                    y1++;
                }
            }
        }
#else
        FOR( j = 0; j < length; j++ )
        {
            s = L_deposit_l( 0 );
@@ -534,6 +683,7 @@ static void tcx_ltp_synth_filter(
            y0++;
            y1++;
        }
#endif
    }
    ELSE
    {
@@ -579,7 +729,6 @@ static void tcx_ltp_synth_filter32(

        L = tcxLtpFilters[filtIdx].length; /* Q0 */
        move16();

        alpha = 0;
        move16();
        IF( fade != 0 )
@@ -606,6 +755,154 @@ static void tcx_ltp_synth_filter32(
                step = negate( step );
        }

#ifdef OPT_TCXLTP_FILTER_LOOP
        IF( fade != 0 )
        {
            IF( zir != NULL )
            {
                FOR( j = 0; j < length; j++ )
                {
                    s = L_deposit_l( 0 );
                    s2 = L_deposit_l( 0 );
                    k = 0;
                    move16();
                    FOR( i = 0; i < L; i++ )
                    {
                        s = Madd_32_16_r( Madd_32_16_r( s, x0[i], w0[k] ), x1[-i], w1[k] );   /* Qx */
                        s2 = Madd_32_16_r( Madd_32_16_r( s2, y0[i], v0[k] ), y1[-i], v1[k] ); /* Qx */
                        k = k + pitch_res;
                    }

                    /* s2 *= ALPHA;
                       normal:      synth_ltp[j] = synth[j] - gain * s2 + gain * s;
                       zir:         synth_ltp[j] = synth[j] - gain * s2 + gain * s - zir[j];
                       fade-in/out: synth_ltp[j] = synth[j] - alpha * gain * s2 + alpha * gain * s; */
                    L_tmp = L_sub_sat( s, Mpy_32_16_r( s2, ALPHA ) ); /* Qx */
                    L_tmp2 = Mpy_32_16_r( L_tmp, gain );              /* Qx */
                    L_tmp2 = Mpy_32_16_r( L_tmp2, alpha );            /* Qx */
                    L_tmp2 = L_sub_sat( L_tmp2, zir[j] );             /* Qx */
                    L_tmp2 = L_add_sat( synth[j], L_tmp2 );           /* Qx */

                    synth_ltp[j] = L_tmp2; /* Qx */
                    move16();

                    BASOP_SATURATE_WARNING_OFF_EVS;
                    alpha = add_sat( alpha, step );
                    BASOP_SATURATE_WARNING_ON_EVS;

                    x0++;
                    x1++;
                    y0++;
                    y1++;
                }
            }
            ELSE
            {
                FOR( j = 0; j < length; j++ )
                {
                    s = L_deposit_l( 0 );
                    s2 = L_deposit_l( 0 );
                    k = 0;
                    move16();
                    FOR( i = 0; i < L; i++ )
                    {
                        s = Madd_32_16_r( Madd_32_16_r( s, x0[i], w0[k] ), x1[-i], w1[k] );   /* Qx */
                        s2 = Madd_32_16_r( Madd_32_16_r( s2, y0[i], v0[k] ), y1[-i], v1[k] ); /* Qx */
                        k = k + pitch_res;
                    }

                    /* s2 *= ALPHA;
                       normal:      synth_ltp[j] = synth[j] - gain * s2 + gain * s;
                       zir:         synth_ltp[j] = synth[j] - gain * s2 + gain * s - zir[j];
                       fade-in/out: synth_ltp[j] = synth[j] - alpha * gain * s2 + alpha * gain * s; */
                    L_tmp = L_sub_sat( s, Mpy_32_16_r( s2, ALPHA ) ); /* Qx */
                    L_tmp2 = Mpy_32_16_r( L_tmp, gain );              /* Qx */
                    L_tmp2 = Mpy_32_16_r( L_tmp2, alpha );            /* Qx */
                    L_tmp2 = L_add_sat( synth[j], L_tmp2 );           /* Qx */

                    synth_ltp[j] = L_tmp2; /* Qx */
                    move16();

                    BASOP_SATURATE_WARNING_OFF_EVS;
                    alpha = add_sat( alpha, step );
                    BASOP_SATURATE_WARNING_ON_EVS;

                    x0++;
                    x1++;
                    y0++;
                    y1++;
                }
            }
        }
        ELSE
        {
            IF( zir != NULL )
            {
                FOR( j = 0; j < length; j++ )
                {
                    s = L_deposit_l( 0 );
                    s2 = L_deposit_l( 0 );
                    k = 0;
                    move16();
                    FOR( i = 0; i < L; i++ )
                    {
                        s = Madd_32_16_r( Madd_32_16_r( s, x0[i], w0[k] ), x1[-i], w1[k] );   /* Qx */
                        s2 = Madd_32_16_r( Madd_32_16_r( s2, y0[i], v0[k] ), y1[-i], v1[k] ); /* Qx */
                        k = k + pitch_res;
                    }

                    /* s2 *= ALPHA;
                       normal:      synth_ltp[j] = synth[j] - gain * s2 + gain * s;
                       zir:         synth_ltp[j] = synth[j] - gain * s2 + gain * s - zir[j];
                       fade-in/out: synth_ltp[j] = synth[j] - alpha * gain * s2 + alpha * gain * s; */
                    L_tmp = L_sub_sat( s, Mpy_32_16_r( s2, ALPHA ) ); /* Qx */
                    L_tmp2 = Mpy_32_16_r( L_tmp, gain );              /* Qx */
                    L_tmp2 = L_sub_sat( L_tmp2, zir[j] );             /* Qx */
                    L_tmp2 = L_add_sat( synth[j], L_tmp2 );           /* Qx */

                    synth_ltp[j] = L_tmp2; /* Qx */
                    move16();

                    x0++;
                    x1++;
                    y0++;
                    y1++;
                }
            }
            ELSE
            {
                FOR( j = 0; j < length; j++ )
                {
                    s = L_deposit_l( 0 );
                    s2 = L_deposit_l( 0 );
                    k = 0;
                    move16();
                    FOR( i = 0; i < L; i++ )
                    {
                        s = Madd_32_16_r( Madd_32_16_r( s, x0[i], w0[k] ), x1[-i], w1[k] );   /* Qx */
                        s2 = Madd_32_16_r( Madd_32_16_r( s2, y0[i], v0[k] ), y1[-i], v1[k] ); /* Qx */
                        k = k + pitch_res;
                    }

                    /* s2 *= ALPHA;
                       normal:      synth_ltp[j] = synth[j] - gain * s2 + gain * s;
                       zir:         synth_ltp[j] = synth[j] - gain * s2 + gain * s - zir[j];
                       fade-in/out: synth_ltp[j] = synth[j] - alpha * gain * s2 + alpha * gain * s; */
                    L_tmp = L_sub_sat( s, Mpy_32_16_r( s2, ALPHA ) ); /* Qx */
                    L_tmp2 = Mpy_32_16_r( L_tmp, gain );              /* Qx */
                    L_tmp2 = L_add_sat( synth[j], L_tmp2 );           /* Qx */

                    synth_ltp[j] = L_tmp2; /* Qx */
                    move16();

                    x0++;
                    x1++;
                    y0++;
                    y1++;
                }
            }
        }
#else
        FOR( j = 0; j < length; j++ )
        {
            s = L_deposit_l( 0 );
@@ -648,6 +945,7 @@ static void tcx_ltp_synth_filter32(
            y0++;
            y1++;
        }
#endif
    }
    ELSE
    {
+27 −0
Original line number Diff line number Diff line
@@ -2176,6 +2176,32 @@ Word16 maximum_exp_fx(
    const Word16 *exp_vec, /* i  : exponents of input vector                      */
    const Word16 lvec_fx   /* i  : length of input vector                         */
)
#ifdef FIX_1981_MAXIMUM_EXP_FX
{
    Word16 j, ind;
    ind = 0;
    move16();

    FOR( j = 1; j < lvec_fx; j++ )
    {
        Word16 scale = sub( exp_vec[j], exp_vec[ind] );
#ifdef FIX_1981_MAXIMUM_EXP_FX_ZEROMANTISSA
        test();
        if ( vec_fx[j] == 0 || vec_fx[ind] == 0 )
        {
            scale = 0;
            move16();
        }
#endif
        if ( L_mac0_sat( L_shl_sat( L_deposit_l( vec_fx[j] ), scale ), vec_fx[ind], -0x0001 ) > 0 )
        {
            ind = j;
            move16();
        }
    }
    return ind;
}
#else
{
    Word16 j, ind;
    Word16 tmp, exp;
@@ -2201,6 +2227,7 @@ Word16 maximum_exp_fx(

    return ind;
}
#endif


/*---------------------------------------------------------------------*
+4 −4
Original line number Diff line number Diff line
@@ -55,9 +55,9 @@ void open_decoder_LPD_fx(
    fscaleFB = sr2fscale_fx( st->output_Fs );

    /* initializing variables for frame lengths etc. right in the beginning */
    st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 ) );
    st->L_frame = extract_l( Mult_32_16( st->sr_core, INV_FRAME_PER_SEC_Q15 ) );
    move16();
    hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, 0x0290 ) );
    hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, INV_FRAME_PER_SEC_Q15 ) );
    move16();
    IF( st->ini_frame == 0 )
    {
@@ -1159,7 +1159,7 @@ void open_decoder_LPD_ivas_fx(
    move16();

    /* initializing variables for frame lengths etc. right in the beginning */
    st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 ) ); /* 0.02 in Q15 */
    st->L_frame = extract_l( Mult_32_16( st->sr_core, INV_FRAME_PER_SEC_Q15 ) );
    move16();
    if ( st->ini_frame == 0 )
    {
@@ -1169,7 +1169,7 @@ void open_decoder_LPD_ivas_fx(
    }
    IF( st->hTcxDec != NULL )
    {
        st->hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, 0x0290 ) ); /* 0.02 in Q15 */
        st->hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, INV_FRAME_PER_SEC_Q15 ) );
        move16();
        st->output_frame_fx = st->hTcxDec->L_frameTCX; /* Q0 */
        move16();
Loading