Commit 1f19268f authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'ltv_crash_fixes_acelp_core_bug_fix' into 'main'

LTV crash Fixes, bug-fix in acelp_core_dec_ivas_fx

See merge request !315
parents e729163a 8881f1e2
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -4763,6 +4763,18 @@ Word16 matrix_product_fx(
    Word32 *Z_fx                                                    /* o  : resulting matrix after the matrix multiplication                                       */
);

Word16 matrix_product_q30_fx(
    const Word32 *X_fx,   /* i  : left hand matrix                                                                       */
    const Word16 rowsX,   /* i  : number of rows of the left hand matrix                                                 */
    const Word16 colsX,   /* i  : number of columns of the left hand matrix                                              */
    const Word16 transpX, /* i  : flag indicating the transposition of the left hand matrix prior to the multiplication  */
    const Word32 *Y_fx,   /* i  : right hand matrix                                                                      */
    const Word16 rowsY,   /* i  : number of rows of the right hand matrix                                                */
    const Word16 colsY,   /* i  : number of columns of the right hand matrix                                             */
    const Word16 transpY, /* i  : flag indicating the transposition of the right hand matrix prior to the multiplication */
    Word32 *Z_fx          /* o  : resulting matrix after the matrix multiplication                                       */
);

Word16 matrix_product_mant_exp(
  const Word32 *X_fx,    /* i  : left hand matrix                                                                       */
  const Word16 *X_e,     /* i  : left hand matrix                                                                       */
+1 −1
Original line number Diff line number Diff line
@@ -509,7 +509,7 @@ void tdm_bit_alloc(
            IF( coder_type == INACTIVE )
            {
                Word32 res_fix = 0;
                res_fix = Mpy_32_32(644245094, ( element_brate_wo_meta - 500 ) );
                res_fix = Mpy_32_32(644245095, ( element_brate_wo_meta - 500 ) );
                res_fix = ( ( res_fix / 100 ) * 100 );
                *total_brate_sec = max( *total_brate_sec, res_fix );

+121 −0
Original line number Diff line number Diff line
@@ -1354,6 +1354,127 @@ Word16 matrix_product_fx(
    return EXIT_SUCCESS;
}

Word16 matrix_product_q30_fx(
    const Word32 *X_fx,   /* i  : left hand matrix                                                                       */
    const Word16 rowsX,   /* i  : number of rows of the left hand matrix                                                 */
    const Word16 colsX,   /* i  : number of columns of the left hand matrix                                              */
    const Word16 transpX, /* i  : flag indicating the transposition of the left hand matrix prior to the multiplication  */
    const Word32 *Y_fx,   /* i  : right hand matrix                                                                      */
    const Word16 rowsY,   /* i  : number of rows of the right hand matrix                                                */
    const Word16 colsY,   /* i  : number of columns of the right hand matrix                                             */
    const Word16 transpY, /* i  : flag indicating the transposition of the right hand matrix prior to the multiplication */
    Word32 *Z_fx          /* o  : resulting matrix after the matrix multiplication                                       */
)
{
    Word16 i, j, k;
    Word32 *Zp_fx = Z_fx;
    Word64 W_tmp;

    /* Processing */
    test();
    test();
    test();
    IF( EQ_16( transpX, 1 ) && EQ_16( transpY, 0 ) ) /* We use X transpose */
    {
        IF( NE_16( rowsX, rowsY ) )
        {
            return EXIT_FAILURE;
        }
        FOR( j = 0; j < colsY; ++j )
        {
            FOR( i = 0; i < colsX; ++i )
            {
                //( *Zp_fx ) = 0;
                W_tmp = 0;
                move64();
                FOR( k = 0; k < rowsX; ++k )
                {
                    //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) );
                    W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) );//Q56
                }
                W_tmp = W_shl( W_tmp, 6 );
                ( *Zp_fx ) = L_sub(W_round64_L( W_tmp ), 64); //adjusting for precision
                Zp_fx++;
            }
        }
    }
    ELSE IF( EQ_16( transpX, 0 ) && EQ_16( transpY, 1 ) ) /* We use Y transpose */
    {
        IF( NE_16( colsX, colsY ) )
        {
            return EXIT_FAILURE;
        }
        FOR( j = 0; j < rowsY; ++j )
        {
            FOR( i = 0; i < rowsX; ++i )
            {
                //( *Zp_fx ) = 0;
                W_tmp = 0;
                move64();
                FOR( k = 0; k < colsX; ++k )
                {
                    //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) );
                    W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) ); // Q56
                }
                W_tmp = W_shl( W_tmp, 6 );
                ( *Zp_fx ) = L_sub( W_round64_L( W_tmp ), 64 ); // adjusting for precision
                Zp_fx++;
            }
        }
    }
    ELSE IF( EQ_16( transpX, 1 ) && EQ_16( transpY, 1 ) ) /* We use both transpose */
    {
        IF( NE_16( rowsX, colsY ) )
        {
            return EXIT_FAILURE;
        }
        FOR( j = 0; j < rowsY; ++j )
        {
            FOR( i = 0; i < colsX; ++i )
            {
                //( *Zp_fx ) = 0;
                W_tmp = 0;
                move64();
                FOR( k = 0; k < colsX; ++k )
                {
                    //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) );
                    W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) ); // Q56
                }

                W_tmp = W_shl( W_tmp, 6 );
                ( *Zp_fx ) = L_sub( W_round64_L( W_tmp ), 64 ); // adjusting for precision
                Zp_fx++;
            }
        }
    }
    ELSE /* Regular case */
    {
        IF( NE_16( colsX, rowsY ) )
        {
            return EXIT_FAILURE;
        }

        FOR( j = 0; j < colsY; ++j )
        {
            FOR( i = 0; i < rowsX; ++i )
            {
                //( *Zp_fx ) = 0;
                W_tmp = 0;
                move64();
                FOR( k = 0; k < colsX; ++k )
                {
                    //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) );
                    W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) ); // Q56
                }
                W_tmp = W_shl( W_tmp, 6 );
                ( *Zp_fx ) = L_sub( W_round64_L( W_tmp ), 64 ); // adjusting for precision
                Zp_fx++;
            }
        }
    }

    return EXIT_SUCCESS;
}
/*takes input matrices in mantissa and exponent forms*/
Word16 matrix_product_mant_exp(
    const Word32 *X_fx,   /* i  : left hand matrix                                                                       */
+2 −1
Original line number Diff line number Diff line
@@ -9287,7 +9287,8 @@ void IMDCT_ivas_fx(
    const Word16 FB_flag,
    Decoder_State *st,
    const Word16 fullbandScale,
    Word16 *acelp_zir_fx);
    Word16 *acelp_zir_fx,
    Word16 q_win);

void v_mult16_fixed(
    const Word16 x1[], /* i  : Input vector 1                                   */
+2 −2
Original line number Diff line number Diff line
@@ -1869,9 +1869,9 @@ ivas_error acelp_core_dec_ivas_fx(
                              psyn_fx, synth_fx16, st->Q_exc, st->Q_syn2, st->hBWE_zero->delay_syn_hf_fx, &tmp_exp,
                              st->hBWE_zero->mem_hp_interp_fx, st->extl, st->CNG_mode, st->element_mode );
#ifdef MSAN_FIX
            Copy_Scale_sig_16_32(synth_fx16, synth_fx, 0, output_frame);
            Copy_Scale_sig_16_32(synth_fx16, synth_fx, output_frame, 0);
#else
            Copy_Scale_sig_16_32(synth_fx16, synth_fx, 0, L_FRAME48k);
            Copy_Scale_sig_16_32(synth_fx16, synth_fx, L_FRAME48k, 0);
#endif

            IF( st->hBWE_FD != NULL )
Loading