Commit 6f3c26e1 authored by fotopoulou's avatar fotopoulou
Browse files

fix for BWD and transients under BWD_COUNT_FIX

parent 9a1a7881
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -157,7 +157,7 @@
#endif
//#define DISABLE_BWD_MCT                               /* FhG: Disable bandwidth detection for MCT*/
#define FIX_MDCT_STEREO_BWD_TCX10                       /* FhG: enables bw detection also for TCX10 frames */

#define BWD_COUNT_FIX                                   /* FhG/Dolby: fix for issue of reacting to sudden transiensts in SBA/MCT modes */

/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */
+5 −0
Original line number Diff line number Diff line
@@ -3828,8 +3828,13 @@ void bw_detect(
    const float signal_in[], /* i  : input signal                                */
    float *spectrum,         /* i  : MDCT spectrum                               */
    const float *enerBuffer  /* i  : energy buffer                               */
#ifdef BWD_COUNT_FIX
    ,
    const int16_t mct_on /* i  : flag MCT mode */
#endif
);


void set_bw(
    const int16_t element_mode,  /* i  : element mode                                */
    const int32_t element_brate, /* i  : element bitrate                             */

lib_enc/amr_wb_enc.c

100644 → 100755
+6 −1
Original line number Diff line number Diff line
@@ -342,7 +342,12 @@ void amr_wb_enc(
     * WB, SWB and FB bandwidth detector
     *----------------------------------------------------------------*/

    bw_detect( st, st->input, NULL, NULL );
    bw_detect( st, st->input, NULL, NULL
#ifdef BWD_COUNT_FIX
               ,
               0
#endif
    );

    /* in AMR_WB IO, limit the maximum band-width to WB */
    if ( st->bwidth > WB )

lib_enc/bw_detect.c

100644 → 100755
+80 −19
Original line number Diff line number Diff line
@@ -57,6 +57,9 @@

#define BWD_COUNT_MAX      100
#define BWD_COUNT_WIDER_BW 10
#ifdef BWD_COUNT_FIX
#define BWD_COUNT_WIDER_BW_MDCT 0
#endif

#define CLDFB_ENER_OFFSET 1.6f

@@ -71,6 +74,10 @@ void bw_detect(
    const float signal_in[], /* i  : input signal        */
    float *spectrum,         /* i  : MDCT spectrum       */
    const float *enerBuffer  /* i  : energy buffer       */
#ifdef BWD_COUNT_FIX
    ,
    const int16_t mct_on /* i  : flag MCT mode */
#endif
)
{
    int16_t i, j, k, bw_max, bin_width, n_bins;
@@ -396,6 +403,57 @@ void bw_detect(
             *---------------------------------------------------------------------*/

            /* switching to a higher BW */
#ifdef BWD_COUNT_FIX
            if ( st->element_mode == IVAS_CPE_MDCT && ( st->element_brate > IVAS_64k || mct_on ) )
            {
                if ( st->last_input_bwidth == NB )
                {
                    if ( st->count_WB > BWD_COUNT_WIDER_BW_MDCT )
                    {
                        st->input_bwidth = WB;
                        st->count_WB = BWD_COUNT_MAX;

                        if ( st->count_SWB > BWD_COUNT_WIDER_BW_MDCT )
                        {
                            st->input_bwidth = SWB;
                            st->count_SWB = BWD_COUNT_MAX;

                            if ( st->count_FB > BWD_COUNT_WIDER_BW_MDCT )
                            {
                                st->input_bwidth = FB;
                                st->count_FB = BWD_COUNT_MAX;
                            }
                        }
                    }
                }

                if ( st->last_input_bwidth == WB && st->input_Fs > 16000 )
                {
                    if ( st->count_SWB > BWD_COUNT_WIDER_BW_MDCT )
                    {
                        st->input_bwidth = SWB;
                        st->count_SWB = BWD_COUNT_MAX;

                        if ( st->count_FB > BWD_COUNT_WIDER_BW_MDCT )
                        {
                            st->input_bwidth = FB;
                            st->count_FB = BWD_COUNT_MAX;
                        }
                    }
                }

                if ( st->last_input_bwidth == SWB && st->input_Fs > 32000 )
                {
                    if ( st->count_FB > BWD_COUNT_WIDER_BW_MDCT )
                    {
                        st->input_bwidth = FB;
                        st->count_FB = BWD_COUNT_MAX;
                    }
                }
            }
            else
            {
#endif
                if ( st->last_input_bwidth == NB )
                {
                    if ( st->count_WB > BWD_COUNT_WIDER_BW )
@@ -440,6 +498,9 @@ void bw_detect(
                        st->count_FB = BWD_COUNT_MAX;
                    }
                }
#ifdef BWD_COUNT_FIX
            }
#endif

            /* switching to a lower BW */
            if ( st->last_input_bwidth == FB )
+6 −1
Original line number Diff line number Diff line
@@ -486,7 +486,12 @@ ivas_error pre_proc_front_ivas(

    if ( st->idchan == 0 && element_mode != IVAS_CPE_MDCT )
    {
        bw_detect( st, st->input, NULL, enerBuffer );
        bw_detect( st, st->input, NULL, enerBuffer
#ifdef BWD_COUNT_FIX
                   ,
                   0
#endif
        );
    }

    if ( element_mode != IVAS_CPE_MDCT ) /* in MDCT stereo, set_bw_stereo() is used instead */
Loading