Commit 817cd879 authored by vaclav's avatar vaclav
Browse files

Merge branch...

Merge branch '529-bandwidth-detector-not-working-reliably-for-music-and-generic-audio-2' into 'main'

[non-BE] Resolve "Bandwidth Detector not working reliably for Music and Generic Audio 2"

See merge request !707
parents edfab72e af03fd99
Loading
Loading
Loading
Loading
Loading
+160 −157
Original line number Diff line number Diff line
@@ -209,6 +209,9 @@ ivas_error pre_proc_front_ivas(
    const int16_t front_vad_flag,                               /* i  : front-VAD flag to overwrite VAD decision   */
    const int16_t force_front_vad,                              /* i  : flag to force VAD decision                 */
    const int16_t front_vad_dtx_flag,                           /* i  : front-VAD DTX flag to overwrite VAD decision*/
#ifdef FIX_529_BWD_ISSUE
    const IVAS_FORMAT ivas_format,                              /* i  : IVAS format                                */
#endif
    const int32_t ivas_total_brate                              /* i  : IVAS total bitrate                         */
);

+4 −0
Original line number Diff line number Diff line
@@ -155,6 +155,10 @@
#define FIX_547_NAN_IGF_DEC                             /* FhG: issue 547: fix possible nan in IGF decoder */


#define FIX_529_BWD_ISSUE                               /* VA: issue 529: fix Bandwidth Detector not working reliably for Music and Generic Audio */



/* ################## End DEVELOPMENT switches ######################### */
/* clang-format on */

+13 −10
Original line number Diff line number Diff line
@@ -3891,6 +3891,9 @@ void bw_detect(
    const float signal_in[], /* i  : input signal                                */
    float *spectrum,         /* i  : MDCT spectrum                               */
    const float *enerBuffer, /* i  : energy buffer                               */
#ifdef FIX_529_BWD_ISSUE
    const IVAS_FORMAT ivas_format, /* i  : IVAS format                                 */
#endif
    const int16_t mct_on /* i  : flag MCT mode                               */
);

+5 −2
Original line number Diff line number Diff line
@@ -342,8 +342,11 @@ void amr_wb_enc(
     * WB, SWB and FB bandwidth detector
     *----------------------------------------------------------------*/

    bw_detect( st, st->input, NULL, NULL,
               0 );
#ifdef FIX_529_BWD_ISSUE
    bw_detect( st, st->input, NULL, NULL, MONO_FORMAT, 0 );
#else
    bw_detect( st, st->input, NULL, NULL, 0 );
#endif

    /* in AMR_WB IO, limit the maximum band-width to WB */
    if ( st->bwidth > WB )
+42 −4
Original line number Diff line number Diff line
@@ -52,6 +52,13 @@
 * Local constants
 *-------------------------------------------------------------------*/

#ifdef FIX_529_BWD_ISSUE
#define BWD_MIN_BRATE_WIDER_BW_MDCT IVAS_48k
#define BWD_MIN_BRATE_WIDER_BW_ISM  IVAS_32k
#define BWD_MAX_BRATE_WIDER_BW_MDCT IVAS_80k
#define BWD_MAX_BRATE_WIDER_BW_ISM  IVAS_64k
#endif

#define ALPHA_BWD     0.75f
#define BWD_LT_THRESH 0.6f

@@ -72,6 +79,9 @@ void bw_detect(
    const float signal_in[], /* i  : input signal        */
    float *spectrum,         /* i  : MDCT spectrum       */
    const float *enerBuffer, /* i  : energy buffer       */
#ifdef FIX_529_BWD_ISSUE
    const IVAS_FORMAT ivas_format, /* i  : IVAS format         */
#endif
    const int16_t mct_on /* i  : flag MCT mode       */
)
{
@@ -85,7 +95,12 @@ void bw_detect(
    int16_t bwd_count_wider_bw, l_frame;

    bwd_count_wider_bw = BWD_COUNT_WIDER_BW;
#ifdef FIX_529_BWD_ISSUE
    if ( st->ini_frame > 0 && ( ( st->element_mode == IVAS_CPE_MDCT && ( st->element_brate >= BWD_MIN_BRATE_WIDER_BW_MDCT || mct_on ) ) ||
                                ( ivas_format == ISM_FORMAT && st->element_brate >= BWD_MIN_BRATE_WIDER_BW_ISM ) ) )
#else
    if ( st->element_mode == IVAS_CPE_MDCT && ( st->element_brate > IVAS_64k || mct_on ) )
#endif
    {
        bwd_count_wider_bw = BWD_COUNT_WIDER_BW_MDCT;
    }
@@ -576,6 +591,12 @@ void set_bw(
            {
                st->bwidth = SWB;
            }
#ifdef FIX_529_BWD_ISSUE
            else if ( element_brate > BWD_MAX_BRATE_WIDER_BW_ISM )
            {
                st->bwidth = st->max_bwidth;
            }
#endif
        }
        /* element_mode == EVS_MONO */
        else if ( total_brate <= ACELP_9k60 && st->bwidth > WB )
@@ -633,6 +654,14 @@ void set_bw_stereo(
{
    Encoder_State **sts = hCPE->hCoreCoder;

#ifdef FIX_529_BWD_ISSUE
    if ( hCPE->element_brate > BWD_MAX_BRATE_WIDER_BW_MDCT )
    {
        sts[0]->bwidth = sts[0]->max_bwidth;
        sts[1]->bwidth = sts[1]->max_bwidth;
    }
    else
#endif
        if ( hCPE->element_mode == IVAS_CPE_MDCT )
    {
        /* ensure that both CPE channels have the same audio band-width */
@@ -678,8 +707,7 @@ int16_t set_bw_mct(
        for ( ch = 0; ch < CPE_CHANNELS; ch++ )
        {
            st = hCPE[cpe_id]->hCoreCoder[ch];
            if (
                st->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
            if ( st->mct_chan_mode == MCT_CHAN_MODE_IGNORE )
            {
                continue;
            }
@@ -688,6 +716,16 @@ int16_t set_bw_mct(
        }
    }

#ifdef FIX_529_BWD_ISSUE
    for ( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
    {
        if ( hCPE[cpe_id]->element_brate > BWD_MAX_BRATE_WIDER_BW_MDCT )
        {
            mct_bwidth = max( mct_bwidth, hCPE[cpe_id]->hCoreCoder[0]->max_bwidth );
        }
    }
#endif

    bw_changed = 0;
    if ( mct_bwidth != last_mct_bwidth )
    {
Loading