Commit 22b74eae authored by emerit's avatar emerit
Browse files

Merge branch '2089-Limiter_attack_and_release_constants_differ_from_float_version' into 'main'

[non-BE][split non-BE][allow-regression]Resolve "Limiter release constants wrong for frame length = 10ms"

Closes #2089

See merge request !2358
parents 8d55d2b3 83640fb2
Loading
Loading
Loading
Loading
Loading
+58 −2
Original line number Diff line number Diff line
@@ -41,13 +41,19 @@
#include <assert.h>
#include "ivas_prot_fx.h"


#ifdef FIX_2089_NONBE_LIMITER_CONSTS
#define RELEASE_CNST_20MS   ( 85899345 ) // Q30
#define RELEASE_CNST_2_20MS ( 21474836 ) // Q30
#define RELEASE_CNST_10MS   ( 42949672 ) // Q30
#define RELEASE_CNST_2_10MS ( 10737418 ) // Q30
#define RELEASE_CNST_5MS    ( 21474836 ) // Q30
#define RELEASE_CNST_2_5MS  ( 5368709 )  // Q30
#endif
#define ATTACK_CNST_48k ( 2106670080 ) // Q31
#define ATTACK_CNST_32k ( 2086555136 ) // Q31
#define ATTACK_CNST_16k ( 2027355264 ) // Q31
#define ATTACK_CNST_8k  ( 1913946752 ) // Q31


/*-------------------------------------------------------------------*
 * detect_strong_saturations()
 *
@@ -349,6 +355,55 @@ void limiter_process_fx(
     * keep the gain curve smoother if the threshold is exceeded in many frames
     * in a short span of time.
     */
#ifdef FIX_2089_NONBE_LIMITER_CONSTS
    IF( EQ_32( L_mult0( output_frame, 50 ), hLimiter->sampling_rate ) )
    {
        releaseHeuristic_cnst = RELEASE_CNST_20MS;
        move32();
        releaseHeuristic_cnst_2 = RELEASE_CNST_2_20MS;
        move32();
    }
    ELSE IF( EQ_32( L_mult0( output_frame, 100 ), hLimiter->sampling_rate ) )
    {
        releaseHeuristic_cnst = RELEASE_CNST_10MS;
        move32();
        releaseHeuristic_cnst_2 = RELEASE_CNST_2_10MS;
        move32();
    }
    ELSE IF( EQ_32( L_mult0( output_frame, 200 ), hLimiter->sampling_rate ) )
    {
        releaseHeuristic_cnst = RELEASE_CNST_5MS;
        move32();
        releaseHeuristic_cnst_2 = RELEASE_CNST_2_5MS;
        move32();
    }
    ELSE
    {
#ifdef FIX_2089_NONBE_LIMITER_CONSTS_WITH_DIV
        // computing output_frame/hLimiter->sampling_rate in Q30
        i = norm_s( output_frame );
        c = norm_l( hLimiter->sampling_rate );
        scale = extract_h( L_shl( hLimiter->sampling_rate, c ) );
        idx = shl( output_frame, i );
        IF( GT_16( idx, scale ) )
        {
            idx = shr( idx, 1 );
            i = sub( i, 1 );
        }
        scale = div_s( idx, scale );
        i = sub( sub( c, i ), 1 ); // Q30
        releaseHeuristic_cnst_2 = L_shl( scale, i );
        releaseHeuristic_cnst = L_shl( releaseHeuristic_cnst_2, 2 );
#else
        /* or same default values as previous code version */
        releaseHeuristic_cnst = RELEASE_CNST_5MS;
        move32();
        releaseHeuristic_cnst_2 = RELEASE_CNST_2_5MS;
        move32();
#endif
    }

#else
    SWITCH( output_frame )
    {
        case 960:
@@ -367,6 +422,7 @@ void limiter_process_fx(
            move32();
            BREAK;
    }
#endif
    releaseHeuristic = hLimiter->release_heuristic_fx; /* Q30 */
    move32();

+4 −0
Original line number Diff line number Diff line
@@ -76,6 +76,10 @@
#define FIX_1990_SANITIZER_IN_REVERB_LOAD                    /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */
#define FIX_1999_TEMPORARY_DISABLE_DIST_ATT_CHECK            /* Eri: Issue 1999: Range check on float values of distance attenuation, while the float values are not propagated to this function. The test is not correct, but configurable distance attenuation is not used in Characterization.*/
#define OPT_IGF_GET_WHITE_SPEC_DATA                          /* FhG: optimized version of IGF_getWhiteSpectralData_ivas() */
#define FIX_2089_NONBE_LIMITER_CONSTS                        /* Orange : fix issue 2089 : Limiter attack and release constants differ from float version */
#ifdef FIX_2089_NONBE_LIMITER_CONSTS
#define FIX_2089_NONBE_LIMITER_CONSTS_WITH_DIV               /* Orange : compute release const for other output frame generate by jbm */  
#endif
#define FIX_1785_ASSERT_IN_IVAS_JBM_DEC_RENDER_FX            /* Orange: 10ms Rendering: Assert in ivas_jbm_dec_render_fx() -> scale_sig32 */
#define FIX_2081_REVISE_H1_SCALING                           /* VA: accommodate for H1 overshoot that was causing assert in set_impule. Not BE with MASA on LTV with bitrate switching for only 2 instances */
#define TEMP_FIX_2088_MSAN_INIT_ERROR                        /* Eri: Temporary fix for Issue 2088 - MSAN error. Will come with later port of JBM+Split rendering update */