Commit afc8d3fc authored by vaillancour's avatar vaillancour
Browse files

Adding debugging code for copy 32 to 16

parent af8d0b89
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -792,12 +792,7 @@ ivas_error config_acelp1(
    Word16 i, bits, nb_subfr;
    Word16 flag_hardcoded, coder_type_sw, fix_first;
    Word32 core_brate;
#ifdef DEBUGGING
#ifdef REMOVE_IVAS_UNUSED_PARAMETERS_WARNING
    (void) active_cnt;
    (void) core_brate_inpI;
#endif
#endif

    ivas_error error;

    error = IVAS_ERR_OK;
+11 −3
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#ifndef OPTIONS_H
#define OPTIONS_H


/* clang-format off */

/* ################### Start DEBUGGING switches ######################## */
@@ -45,10 +46,17 @@
#pragma warning(disable:4310)     /* cast truncates constant value this affects mainly constants tables*/
#endif

/*#define DEBUGGING*/                             /* Allows debugging message to be printed out during runtime */
#define DEBUGGING                             /* Allows debugging message to be printed out during runtime */
#ifdef DEBUGGING
#define DEBUG_MODE_INFO /* define to output most important parameters to the subdirectory "res/" */
#define DEBUG_MODE_INFO_TWEAK /* enable command line switch to specify subdirectory for debug info output inside "./res/" */
#include "debug.h"
#define DEBUG_VA
#define DEBUG_VA_OVF_IN_COPY /* To print overflows in copy 32 to 16 */
#ifdef DEBUG_VA_OVF_IN_COPY
//#define PTFE {fprintf(stderr, "OVF in; %s; at Ln; %d; at frame; %d;\n", __FUNCTION__, __LINE__, frame); }
#define PTFE {fprintf(stderr, "OVF in\t %s\t at Ln\t %d\tat frame\t %dn", __FUNCTION__, __LINE__, frame); }
#endif
//#define DEBUG_MODE_INFO /* define to output most important parameters to the subdirectory "res/" */
//#define DEBUG_MODE_INFO_TWEAK /* enable command line switch to specify subdirectory for debug info output inside "./res/" */
/*#define DBG_WAV_WRITER*/ /* enable dbgwrite_wav() function for generating ".wav" files */
#endif

+5 −0
Original line number Diff line number Diff line
@@ -9654,7 +9654,12 @@ void Copy_Scale_sig_16_32_no_sat(
    const Word16 exp0 /* i  : exponent: x = round(x << exp)   Qx ?exp  */
);
#ifdef DEBUG_VA_OVF_IN_COPY
int Copy_Scale_sig_32_16(
#else
void Copy_Scale_sig_32_16(
#endif
    const Word32 x[], /* i  : signal to scale i             Qx        */
    Word16 y[],       /* o  : scaled signal output            Qx        */
    const Word16 lg,  /* i  : size of x[]                     Q0        */
+40 −1
Original line number Diff line number Diff line
@@ -797,7 +797,11 @@ void Copy_Scale_sig_16_32_no_sat(
    }
}

#ifdef DEBUG_VA_OVF_IN_COPY
int Copy_Scale_sig_32_16(
#else
void Copy_Scale_sig_32_16(
#endif
    const Word32 x[], /* i  : signal to scale input           Qx        */
    Word16 y[],       /* o  : scaled signal output            Qx        */
    const Word16 lg,  /* i  : size of x[]                     Q0        */
@@ -808,21 +812,53 @@ void Copy_Scale_sig_32_16(
    Word16 tmp;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    float max_OVF = -32728;
    Word16 max_tmp = -1111;
    Word16 max_i = -1111;
    Word32 max_xn = -1111;
    move32();
#endif

#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Print_OVf = 0;
#endif
    tmp = add( 16, exp0 );
    IF( tmp != 0 )
    {
        FOR( i = 0; i < lg; i++ )
        {
#ifdef BASOP_NOGLOB
#ifdef DEBUG_VA_OVF_IN_COPY
            y[i] = round_fx_sat( L_shl_o( x[i], tmp, &Overflow ) );
            if ( Overflow )
            {
                if ( Print_OVf == 0 )
                {
                    Print_OVf = 1;
                }
                if (max_OVF < fabsf((float)x[i] * powf(2, (float)(tmp - 16)) / 32767.0f) )
                {
                    max_OVF = fabsf((float)x[i] * powf(2, (float)(tmp - 16)) / 32767.0f);
                    max_xn = x[i];
                    max_tmp = tmp;
                    max_i = i;
                }
                Overflow = 0;
            }
#else
            y[i] = round_fx_o( L_shl_o( x[i], tmp, &Overflow ), &Overflow );
#endif
#else
            y[i] = round_fx( L_shl( x[i], tmp ) );
#endif
            move16();
        }
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
        if ( Print_OVf == 1 )
        {
            //printf( "\n\nMAX OVF with x[%d] =;%d;tmp =;%d;%.2f; x MAX_16; ",max_i, max_xn, max_tmp, max_OVF);
            printf( "\n\nMAX OVF with x[%d] =\t%d\ttmp =\t%d\t%.2f\t x MAX_16\t ",max_i, max_xn, max_tmp, max_OVF);
        }
#endif
    }
    ELSE
    {
@@ -836,6 +872,9 @@ void Copy_Scale_sig_32_16(
            move16();
        }
    }
#ifdef DEBUG_VA_OVF_IN_COPY
    return Print_OVf;
#endif
}

/*-------------------------------------------------------------------*
+18 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@
#include "ivas_cnst.h"
#include "ivas_prot.h"
#include "ivas_rom_com.h"
#include "debug.h"
#include "wmc_auto.h"

#ifdef IVAS_FLOAT_FIXED
@@ -2128,7 +2129,11 @@ ivas_error acelp_core_dec_ivas_fx(
            move16();
#endif
#ifdef MSAN_FIX
#ifdef DEBUG_VA_OVF_IN_COPY
            if (Copy_Scale_sig_32_16(synth_fx, synth_fx16, output_frame, 0)) PTFE
#else
            Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 );
#endif
#else
            Copy_Scale_sig_32_16( synth_fx, synth_fx16, L_FRAME48k, 0 );
#endif
@@ -2206,7 +2211,11 @@ ivas_error acelp_core_dec_ivas_fx(
        {
            Copy_Scale_sig_16_32( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( 2 * st->Q_exc - ( st->prev_Q_bwe_exc - 16 ) ) );
            non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame );
#ifdef DEBUG_VA_OVF_IN_COPY
            if (Copy_Scale_sig_32_16(bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, -(2 * st->Q_exc - (st->prev_Q_bwe_exc - 16)))) PTFE
#else
             Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, -( 2 * st->Q_exc - ( st->prev_Q_bwe_exc - 16 ) ) );
#endif
        }
        test();
        if ( st->core_brate == FRAME_NO_DATA || EQ_32( st->core_brate, SID_2k40 ) )
@@ -2243,10 +2252,18 @@ ivas_error acelp_core_dec_ivas_fx(
    {
        IF( save_hb_synth_fx16 )
        {
#ifdef DEBUG_VA_OVF_IN_COPY
            if (Copy_Scale_sig_32_16(save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0)) PTFE
#else
            Copy_Scale_sig_32_16( save_hb_synth_fx, save_hb_synth_fx16, L_FRAME48k, 0 );
#endif
        }
#ifdef MSAN_FIX
#ifdef DEBUG_VA_OVF_IN_COPY
        if (Copy_Scale_sig_32_16(synth_fx, synth_fx16, output_frame, 0)) PTFE
#else
        Copy_Scale_sig_32_16( synth_fx, synth_fx16, output_frame, 0 );
#endif
#else
        Copy_Scale_sig_32_16( synth_fx, synth_fx16, L_FRAME48k, 0 );
#endif
Loading