Commit bb3fed41 authored by Nicolas Roussin's avatar Nicolas Roussin
Browse files

Revert some changes and improve code.

parent 28b527da
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -84,5 +84,3 @@ coan_out_*
/scripts
/tests
/pytest.ini
/build
audio.wav
+1 −5
Original line number Diff line number Diff line
@@ -117,12 +117,8 @@ endif()

# configuration options for all platforms
set(WMOPS OFF CACHE BOOL "enable WMOPS")
set(WMOPS_DETAIL OFF CACHE BOOL "enable WMOPS detail")
if(WMOPS)
  add_definitions("-DWMOPS=1")
  if(WMOPS_DETAIL)
    add_definitions("-DWMOPS_DETAIL=1")
  endif()
endif()

project(stereo-evs LANGUAGES C)
@@ -220,7 +216,7 @@ target_link_libraries(ISAR_post_rend lib_basop lib_isar lib_util lib_com)
target_include_directories(ISAR_post_rend PRIVATE lib_basop lib_isar)

add_executable(ambi_converter apps/ambi_converter.c)
target_link_libraries(ambi_converter lib_util lib_com lib_basop lib_debug)
target_link_libraries(ambi_converter lib_util lib_com lib_basop)
if(UNIX)
  target_link_libraries(ambi_converter m)
endif()
+7 −5
Original line number Diff line number Diff line
@@ -56,10 +56,12 @@
#define SUPPORT_JBM_TRACEFILE                   /* Support for JBM tracefile, which is needed for 3GPP objective/subjective testing, but not relevant for real-world implementations */

/*#define WMOPS*/                                    /* Activate complexity and memory counters */
/*#define WMOPS_PER_FRAME*/                     /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */
/*#define WMOPS_DETAIL*/                        /* Output detailed complexity printout for every function. Increases runtime overhead */
/*#define WMOPS_WC_FRAME_ANALYSIS*/             /* Output detailed complexity analysis for the worst-case frame */
/*#define MEM_COUNT_DETAILS*/                   /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */
#ifdef WMOPS
#define WMOPS_PER_FRAME                   /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */
#define WMOPS_DETAIL                       /* Output detailed complexity printout for every function. Increases runtime overhead */
#define WMOPS_WC_FRAME_ANALYSIS             /* Output detailed complexity analysis for the worst-case frame */
/*define MEM_COUNT_DETAILS*/                   /* Output detailed memory analysis for the worst-case frame (writes to the file "mem_analysis.csv") */
#endif

/*#define DISABLE_LIMITER*/

+31 −27
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ static void ivas_dirac_dec_binaural_internal_fx( Decoder_Struct *st_ivas, COMBIN

static void ivas_dirac_dec_decorrelate_slot_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const Word16 num_freq_bands, const Word16 slot, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME] /*q_inp*/[CLDFB_NO_CHANNELS_MAX], Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, const Word16 q_inp, Word32 decRe[][CLDFB_NO_CHANNELS_MAX], Word32 decIm[][CLDFB_NO_CHANNELS_MAX], Word16 *q_out );

static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const Word16 subframe, Word64 *subFrameTotalEne, Word32 *subFrameTotalEne_fx, Word16 *subFrameTotalEne_e, Word32 *IIReneLimiter, Word16 q );
static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const Word16 subframe, Word64 *subFrameTotalEne, Word32 *subFrameTotalEne_fx, Word16 *subFrameTotalEne_e, Word32 *IIReneLimiter, const Word16 q );

static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, const PARAMBIN_REND_CONFIG_HANDLE hConfig, Word32 Rmat[3][3], const Word16 subframe, const Word16 isHeadtracked, const Word32 *subFrameTotalEne, Word16 *subFrameTotalEne_e, const Word32 *IIReneLimiter, const MASA_ISM_DATA_HANDLE hMasaIsmData );

@@ -1398,9 +1398,13 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx(
    IVAS_FORMAT ivas_format;
    Word32 ivas_total_brate;
    Word16 nchan_transport;
#ifdef NONBE_2157_IVAS_DIRAC_DEC_BINAURAL_FORMULATE_INPUT_COVARIANCE_MATRICES
    Word16 rsh0, rsh1, exp0, exp1;
#else
    Word16 exp, exp1;
    Word64 temp64;
    Word32 temp;
#endif
    Word64 temp64;

    ivas_format = hConfig->ivas_format;
    move32();
@@ -1472,11 +1476,13 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx(
    set32_fx( subFrameTotalEne_fx, 0, CLDFB_NO_CHANNELS_MAX );
#endif

    exp = sub( 63, shl( q, 1 ) ); // exp for the energy (inRe_fx * inRe_fx + inIm_fx * inIm_fx) computed below

#ifdef NONBE_2157_IVAS_DIRAC_DEC_BINAURAL_FORMULATE_INPUT_COVARIANCE_MATRICES
    Word32 rsh0 = ceil_log2( hSpatParamRendCom->subframe_nbslots[subframe] ) - 1;
    Word32 rsh1 = ceil_log2( BINAURAL_CHANNELS * hSpatParamRendCom->subframe_nbslots[subframe] ) - 1;
    rsh0 = ceil_log2( hSpatParamRendCom->subframe_nbslots[subframe] ) - 1;
    rsh1 = ceil_log2( BINAURAL_CHANNELS * hSpatParamRendCom->subframe_nbslots[subframe] ) - 1;
    exp0 = add( sub( 63, shl( q, 1 ) ), rsh0 );
    exp1 = add( sub( 63, shl( q, 1 ) ), rsh1 );
#else
    exp = sub( 63, shl( q, 1 ) ); // exp for the energy (inRe_fx * inRe_fx + inIm_fx * inIm_fx) computed below
#endif

    /* Calculate input covariance matrix */
@@ -1628,48 +1634,47 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx(
        /* Temporally smooth cov mtx estimates for resulting mixing matrix stability. The design principle is that
         * the energy history (IIR) must not be more than double of the current frame energy. This provides more
         * robust performance at energy offsets when compared to typical IIR averaging. */
        Word16 num_e, den_e;
        Word32 num, den;
#ifdef NONBE_2157_IVAS_DIRAC_DEC_BINAURAL_FORMULATE_INPUT_COVARIANCE_MATRICES
        Word16 exp;
        Word64 num64, den64;
        Word16 num1_e, den1_e, exp1;
        Word32 num1, den1, div1, div3;
        num64 = W_add( W_shr( hDiracDecBin->ChEne[0][bin], 1 ), W_shr( hDiracDecBin->ChEne[1][bin], 1 ) );         // 2q - rsh0 - 1
        num64 = Mpy_64_32( num64, IIReneLimiterFactor_fx );                                                        // 2q - rsh0 - 1 - 5
        den64 = W_add( W_shr( hDiracDecBin->ChEnePrev[0][bin], 1 ), W_shr( hDiracDecBin->ChEnePrev[1][bin], 1 ) ); // 2q - rsh0 - 1
        den64 = W_max( 1, den64 );
        num1_e = W_norm( num64 );
        den1_e = W_norm( den64 );
        num1 = W_extract_h( W_shl( num64, num1_e ) ); // 2q - rsh0 - 1 - 5 + num1_e - 32
        den1 = W_extract_h( W_shl( den64, den1_e ) ); // 2q - rsh0 - 1 + den1_e - 32
        IIReneLimiter_fx[bin] = div1 = BASOP_Util_Divide3232_Scale_newton( num1, den1, &exp1 );
        exp = add( sub( den1_e, num1_e ), add( 5, exp1 ) );
        num_e = W_norm( num64 );
        den_e = W_norm( den64 );
        num = W_extract_h( W_shl( num64, num_e ) ); // 2q - rsh0 - 1 - 5 + num_e - 32
        den = W_extract_h( W_shl( den64, den_e ) ); // 2q - rsh0 - 1 + den_e - 32
        IIReneLimiter_fx[bin] = BASOP_Util_Divide3232_Scale_newton( num, den, &exp );
        exp = add( sub( den_e, num_e ), add( 5, exp ) );
        IF( L_shr_sat( IIReneLimiter_fx[bin], sub( 31, exp ) ) > 0 )
        {
            IIReneLimiter_fx[bin] = div3 = ONE_IN_Q31; /*Q31*/
            IIReneLimiter_fx[bin] = ONE_IN_Q31; /*Q31*/
            move32();
        }
        ELSE
        {
            IIReneLimiter_fx[bin] = div3 = L_shl( IIReneLimiter_fx[bin], exp ); /*Q31*/
            IIReneLimiter_fx[bin] = L_shl( IIReneLimiter_fx[bin], exp ); /*Q31*/
        }
#else
        Word16 num_e, den_e, exp0;
        Word32 num, den, div0, div2;
        num = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEne_fx[0][bin], hDiracDecBin->ChEne_e[0][bin], hDiracDecBin->ChEne_fx[1][bin], hDiracDecBin->ChEne_e[1][bin], &num_e );
        num = Mpy_32_32( num, IIReneLimiterFactor_fx ); /*Q = (31 - num_e + 26 - 31) = (26 - num_e)*/
        den_e = 0;
        move16();
        den = BASOP_Util_Add_Mant32Exp( hDiracDecBin->ChEnePrev_fx[0][bin], hDiracDecBin->ChEnePrev_e[0][bin], hDiracDecBin->ChEnePrev_fx[1][bin], hDiracDecBin->ChEnePrev_e[1][bin], &den_e );
        den = L_max( 1, den );
        IIReneLimiter_fx[bin] = div0 = BASOP_Util_Divide3232_Scale_cadence( num, den, &exp0 );
        exp = add( sub( num_e, den_e ), add( 5, exp0 ) );
        IIReneLimiter_fx[bin] = BASOP_Util_Divide3232_Scale_cadence( num, den, &exp );
        exp = add( sub( num_e, den_e ), add( 5, exp ) );
        IF( L_shr_sat( IIReneLimiter_fx[bin], sub( 31, exp ) ) > 0 )
        {
            IIReneLimiter_fx[bin] = div2 = ONE_IN_Q31; /*Q31*/
            IIReneLimiter_fx[bin] = ONE_IN_Q31; /*Q31*/
            move32();
        }
        ELSE
        {
            IIReneLimiter_fx[bin] = div2 = L_shl( IIReneLimiter_fx[bin], exp ); /*Q31*/
            IIReneLimiter_fx[bin] = L_shl( IIReneLimiter_fx[bin], exp ); /*Q31*/
        }
#endif

@@ -1754,26 +1759,25 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx(
        }

#ifdef NONBE_2157_IVAS_DIRAC_DEC_BINAURAL_FORMULATE_INPUT_COVARIANCE_MATRICES
        // FIX
        Word16 shl;
        for ( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
        {
            shl = W_norm( hDiracDecBin->ChEne[ch][bin] );
            hDiracDecBin->ChEne_fx[ch][bin] = W_extract_h( W_shl( hDiracDecBin->ChEne[ch][bin], shl ) );
            hDiracDecBin->ChEne_e[ch][bin] = 63 - 2 * q + rsh0 - shl;
            hDiracDecBin->ChEne_e[ch][bin] = sub( exp0, shl );
        }

        shl = W_norm( hDiracDecBin->ChCrossRe[bin] );
        hDiracDecBin->ChCrossRe_fx[bin] = W_extract_h( W_shl( hDiracDecBin->ChCrossRe[bin], shl ) );
        hDiracDecBin->ChCrossRe_e[bin] = 63 - 2 * q + rsh0 - shl;
        hDiracDecBin->ChCrossRe_e[bin] = sub( exp0, shl );

        shl = W_norm( hDiracDecBin->ChCrossIm[bin] );
        hDiracDecBin->ChCrossIm_fx[bin] = W_extract_h( W_shl( hDiracDecBin->ChCrossIm[bin], shl ) );
        hDiracDecBin->ChCrossIm_e[bin] = 63 - 2 * q + rsh0 - shl;
        hDiracDecBin->ChCrossIm_e[bin] = sub( exp0, shl );

        shl = W_norm( subFrameTotalEne[bin] );
        subFrameTotalEne_fx[bin] = W_extract_h( W_shl( subFrameTotalEne[bin], shl ) );
        subFrameTotalEne_e[bin] = 63 - 2 * q + rsh1 - shl;
        subFrameTotalEne_e[bin] = sub( exp1, shl );
#endif
    }