Commit 267f5c24 authored by vaclav's avatar vaclav
Browse files

fix: BWD output not employed at high bitrates

parent eeefa69a
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -170,12 +170,15 @@
#define FIX_122_MC_DECODER_COMPLEXITY                   /* FhG: Issue 122, significant decrease of worst case MC decoder complexity */
#define FIX_531_BWS_ISM_BFI                             /* VA: issue 531: fix MemorySanitizer: use-of-uninitialized-value in ISM2 rate switching with frame errors */
#define FIX_395_CNG_BW                                  /* Eri: Issue 395 - CNG bandwidth issue for unified stereo */
#define FIX_529_BWD_ISSUE                               /* VA: issue 529: fix Bandwidth Detector not working reliably for Music and Generic Audio */

#define EXTERNAL_ORIENTATIONS                           /* Nokia: Contribution 41: (external) orientation information handling */

#define MASA_PREREND                                    /* Nokia: Contribution 42: Support for IVAS_rend to merge MASA + other format to MASA */

#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 */

+39 −8
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

@@ -89,7 +96,8 @@ void bw_detect(

    bwd_count_wider_bw = BWD_COUNT_WIDER_BW;
#ifdef FIX_529_BWD_ISSUE
    if ( st->ini_frame > 0 && ( st->element_mode == IVAS_CPE_MDCT || ivas_format == ISM_FORMAT ) && ( st->element_brate >= IVAS_48k || mct_on ) )
    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
@@ -583,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 )
@@ -640,6 +654,14 @@ void set_bw_stereo(
{
    Encoder_State **sts = hCPE->hCoreCoder;

#ifdef FIX_529_BWD_ISSUE
    if ( sts[0]->element_brate > BWD_MAX_BRATE_WIDER_BW_MDCT || sts[1]->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 */
@@ -685,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;
            }
@@ -695,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 )
    {