Commit 584d51b1 authored by vaclav's avatar vaclav
Browse files

HARM_DTX, HARM_PREPROC

parent 8c4042de
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -124,6 +124,8 @@
#define REMOVE_UNUSED_CODE_IVAS_DEC                     /* VA: remove unused code in ivas_jbm_dec_tc_fx() */
#define FIX_2294_CLANG_18_WARNINGS_ENC                  /* VA: Fix some encoder clang-18 warnings, desc. in 2294 */
#define REMOVE_CAM_FROM_IVAS                            /* VA: basop issue 210: remove obsoelte CAM code from IVAS */
#define HARM_DTX                                        /* VA: basop issue 2339: Remove duplicated code in the core-coder DTX  */
#define HARM_PREPROC

/* #################### End BE switches ################################## */

+4 −0
Original line number Diff line number Diff line
@@ -332,7 +332,11 @@ void amr_wb_enc_fx(
        move16();
    }

#ifdef HARM_DTX
    dtx_fx( st, -1, -1, vad_flag_dtx, inp, Q_new );
#else
    dtx_fx( st, vad_flag_dtx, inp, Q_new );
#endif

    /*----------------------------------------------------------------*
     * Noise energy down-ward update and total noise energy estimation
+41 −12
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ static void update_SID_cnt_fx( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate,


/*==================================================================================*/
/* FUNCTION : dtx_ivas_fx()                                                              */
/* FUNCTION : dtx_fx()                                                              */
/*----------------------------------------------------------------------------------*/
/* PURPOSE :  Discontinuous transmission operation                                  */
/*----------------------------------------------------------------------------------*/
@@ -58,25 +58,28 @@ static void update_SID_cnt_fx( DTX_ENC_HANDLE hDtxEnc, const Word32 core_brate,
/* _ (Word16*)  qener         : frame_ener/lt_ener_voiced/lt_ener_noise buf qformat */
/* _ (Encoder_State_Fx) st_fx : encoder state structure                             */
/*----------------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------------*/
/* RETURN ARGUMENTS :                                                               */
/* _ None                                                                           */
/*==================================================================================*/

#ifdef HARM_DTX
void dtx_fx(
#else
void dtx_ivas_fx(
#endif
    Encoder_State *st_fx,               /* i/o: encoder state structure                  */
    const Word32 last_ivas_total_brate, /* i  : last IVAS total bitrate                  Q0*/
    const Word32 ivas_total_brate,      /* i  : IVAS total bitrate                       Q0*/
    const Word16 vad,                   /* i  : vad flag for DTX                         Q0*/
    const Word16 speech[],              /* i  : Pointer to the speech frame              Q_speech*/
    Word16 Q_speech                     /* i  : Q factor for speech                      */
    const Word16 Q_speech               /* i  : Q factor for speech                      */
)
{
    Word16 alpha, i, j, Q_speech2;
    Word32 L_tmp;
    DTX_ENC_HANDLE hDtxEnc = st_fx->hDtxEnc;
    TD_CNG_ENC_HANDLE hTdCngEnc = st_fx->hTdCngEnc;

    Word16 last_br_cng_flag, last_br_flag, br_dtx_flag;
    Word32 total_brate_ref;

@@ -100,7 +103,7 @@ void dtx_ivas_fx(
        test();
        test();
        test();

        test();
        last_br_flag = ( st_fx->element_mode == EVS_MONO && LE_32( st_fx->last_total_brate, MAX_BRATE_DTX_EVS ) ) ||
                       ( st_fx->element_mode != EVS_MONO && LE_32( last_ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) ||
                       LT_32( ( st_fx->lp_noise_32fx ), DTX_THR * 16777216 );
@@ -114,6 +117,7 @@ void dtx_ivas_fx(

        st_fx->cng_type = FD_CNG;
        move16();

        test();
        test();
        test();
@@ -123,6 +127,7 @@ void dtx_ivas_fx(
            move16();
        }
    }

    test();
    test();
    test();
@@ -142,12 +147,14 @@ void dtx_ivas_fx(
        {
            st_fx->total_brate = st_fx->last_total_brate_cng;
            move32();

            test();
            if ( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) )
            {
                st_fx->Opt_SC_VBR = 0;
                move16();
            }

            st_fx->rf_mode = st_fx->last_rf_mode_cng;
            move16();
            st_fx->bwidth = st_fx->last_bwidth_cng;
@@ -155,13 +162,14 @@ void dtx_ivas_fx(
            st_fx->codec_mode = st_fx->last_codec_mode_cng;
            move16();
        }

        test();
        test();
        IF( LE_32( st_fx->last_core_brate, SID_2k40 ) && NE_32( st_fx->last_total_brate, st_fx->total_brate ) && last_br_flag )

        {
            st_fx->total_brate = st_fx->last_total_brate;
            move32();

            test();
            if ( !( EQ_32( st_fx->total_brate, ACELP_7k20 ) && st_fx->Opt_SC_VBR ) )
            {
@@ -179,10 +187,12 @@ void dtx_ivas_fx(
                st_fx->Opt_RF_ON = 1;
                move16();
            }

            st_fx->rf_mode = st_fx->Opt_RF_ON;
            move16();
            st_fx->bwidth = st_fx->last_bwidth;
            move32();

            IF( st_fx->element_mode > EVS_MONO )
            {
                st_fx->codec_mode = MODE1;
@@ -213,6 +223,7 @@ void dtx_ivas_fx(
                      ( ( st_fx->element_mode != EVS_MONO ) && LE_32( ivas_total_brate, MAX_BRATE_DTX_IVAS ) ) ||
                      LT_16( extract_h( st_fx->lp_noise_32fx ), DTX_THR * 256 );
    }

    test();
    test();
    test();
@@ -272,12 +283,14 @@ void dtx_ivas_fx(
            st_fx->core_brate = SID_2k40;
            move32();
        }

        test();
        test();
        IF( ( ( st_fx->last_core != ACELP_CORE ) || EQ_16( st_fx->cng_type, FD_CNG ) ) && EQ_16( st_fx->dtx_sce_sba, 1 ) )
        {
            st_fx->cng_type = FD_CNG;
            move16();

            test();
            test();
            test();
@@ -320,6 +333,7 @@ void dtx_ivas_fx(
                move16();
            }
        }

        /* reset the bitstream (IVAS format signalling was already written) */
        test();
        IF( NE_16( st_fx->element_mode, IVAS_CPE_MDCT ) && st_fx->hBstr != NULL )
@@ -337,7 +351,7 @@ void dtx_ivas_fx(
    /*------------------------------------------------------------------------*
     * Reset counters when in active frame (not in SID or FRAME_NO_DATA frame)
     *------------------------------------------------------------------------*/
    /* NB core bit rate can be "-1"  at startup , so one can not use   core_brate_fx <=2400 */

    test();
    test();
    IF( ( NE_32( st_fx->core_brate, SID_2k40 ) ) && ( NE_32( st_fx->core_brate, SID_1k75 ) ) && ( st_fx->core_brate != FRAME_NO_DATA ) )
@@ -428,6 +442,7 @@ void dtx_ivas_fx(
                    move16();
                }
            }

            st_fx->last_total_brate_cng = -1;
            move16();
        }
@@ -436,6 +451,7 @@ void dtx_ivas_fx(
            st_fx->cng_type = LP_CNG;
            move16();
        }

        st_fx->active_cnt = add( st_fx->active_cnt, 1 );
        move16();
        st_fx->active_cnt = s_min( st_fx->active_cnt, 200 );
@@ -445,6 +461,7 @@ void dtx_ivas_fx(
    /*------------------------------------------------------------------------*
     * Update speech and background noise long-term energy
     *------------------------------------------------------------------------*/

    IF( hDtxEnc != NULL )
    {
        hDtxEnc->frame_ener_fx = L_deposit_l( 0 );
@@ -467,7 +484,6 @@ void dtx_ivas_fx(
            }

            /* Active speech (voiced) */

            IF( EQ_16( st_fx->clas, VOICED_CLAS ) )
            {
                alpha = ALPHA_ENER_SLOW_FX; /*Q15 */
@@ -524,7 +540,6 @@ void dtx_ivas_fx(
    test();
    IF( st_fx->Opt_DTX_ON && ( EQ_32( st_fx->core_brate, SID_2k40 ) || ( st_fx->core_brate == FRAME_NO_DATA ) ) )
    {

        st_fx->bwidth = st_fx->last_bwidth;
        move16();
        test();
@@ -561,7 +576,6 @@ void dtx_ivas_fx(
        IF( EQ_16( st_fx->codec_mode, MODE2 ) )
        {
            Word16 n, bits_frame_nominal;

            UWord16 lsb;
            Word16 tmpbandwidthMin;

@@ -575,17 +589,20 @@ void dtx_ivas_fx(
                    BREAK;
                }
            }
            IF( EQ_16( n, FRAME_SIZE_NB ) )
            if ( n == FRAME_SIZE_NB )
            {
                assert( !"Bitrate not supported: not part of EVS" );
            }

            tmpbandwidthMin = FrameSizeConfig[n].bandwidth_min;
            move16();

            if ( EQ_16( st_fx->rf_mode, 1 ) )
            {
                tmpbandwidthMin = WB;
                move16();
            }

            st_fx->bwidth = s_max( s_min( st_fx->bwidth, FrameSizeConfig[n].bandwidth_max ), tmpbandwidthMin );
            move16();
        }
@@ -594,6 +611,7 @@ void dtx_ivas_fx(
    return;
}

#ifndef HARM_DTX
/*==================================================================================*/
/* FUNCTION : dtx_fx()                                                              */
/*----------------------------------------------------------------------------------*/
@@ -1052,6 +1070,7 @@ void dtx_fx(

    return;
}
#endif

/*---------------------------------------------------------------------*
 * update_SID_cnt()
@@ -1201,6 +1220,12 @@ static void update_SID_cnt_fx(
}


/*-------------------------------------------------------------------*
 * dtx_hangover_control()
 *
 *
 *-------------------------------------------------------------------*/

void dtx_hangover_control_fx(
    Encoder_State *st_fx,      /* i/o: encoder state structure                  */
    const Word16 lsp_new_fx[M] /* i  : current frame LSPs                       Q15*/
@@ -1480,6 +1505,7 @@ void dtx_hangover_control_fx(
    return;
}


/*-------------------------------------------------------------------*
 * td_cng_enc_init_fx()
 *
@@ -1491,6 +1517,7 @@ void td_cng_enc_init_fx(
    const Word16 Opt_DTX_ON,     /* i  : flag indicating DTX operation       Q0*/
    const Word16 max_bwidth      /* i  : maximum encoded bandwidth           Q0*/
)
#ifndef HARM_DTX
{

    hTdCngEnc->cng_seed = RANDOM_INITSEED;
@@ -1580,8 +1607,8 @@ void td_cng_enc_init_ivas_fx(
    const Word16 Opt_DTX_ON,     /* i  : flag indicating DTX operation       Q0*/
    const Word16 max_bwidth      /* i  : maximum encoded bandwidth           Q0*/
)
#endif
{

    hTdCngEnc->cng_seed = RANDOM_INITSEED;
    move16();
    hTdCngEnc->cng_ener_seed = RANDOM_INITSEED;
@@ -1672,6 +1699,7 @@ void td_cng_enc_init_ivas_fx(
    return;
}


/*-------------------------------------------------------------------*
 * dtx_enc_init_fx()
 *
@@ -1734,5 +1762,6 @@ void dtx_enc_init_fx(
            move16();
        }
    }

    return;
}
+4 −0
Original line number Diff line number Diff line
@@ -686,6 +686,9 @@ ivas_error init_encoder_fx(
            return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) );
        }

#ifdef HARM_DTX
        td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth );
#else
        IF( st->element_mode == EVS_MONO )
        {
            td_cng_enc_init_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth );
@@ -694,6 +697,7 @@ ivas_error init_encoder_fx(
        {
            td_cng_enc_init_ivas_fx( st->hTdCngEnc, st->Opt_DTX_ON, st->max_bwidth );
        }
#endif
    }
    ELSE
    {
+72 −137

File changed.

Preview size limit exceeded, changes collapsed.

Loading