Commit f9e867d3 authored by vaillancour's avatar vaillancour
Browse files

Adapting the solution depening of max position

parent 4599af5b
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -1365,7 +1365,9 @@ void non_linearity(
    int16_t en_abs = 0;
    float v_fac = 0, ths;
    int16_t nframes;

#ifdef NONBE_1328_FIX_NON_LINEARITY
    float sc_factor;
#endif
    if ( L_frame == L_FRAME16k )
    {
        nframes = 5;
@@ -1411,7 +1413,10 @@ void non_linearity(
    }

#ifdef NONBE_1328_FIX_NON_LINEARITY
    if ( *prev_scale <= 0.0 || *prev_scale > 256.0f * scale )
    sc_factor = (float) ( 1 << ( 13 - norm_s( j + 1 ) ) ); /* Adapt the scaling factor allowed depending of max position  */
    sc_factor = max( sc_factor, 2.0f );

    if ( *prev_scale <= 0.0 || *prev_scale > sc_factor * scale )
#else
    if ( *prev_scale <= 0.0 || *prev_scale > 1024.0f * scale )
#endif
@@ -1471,8 +1476,14 @@ void non_linearity(
        scale = 0.67f;
    }

#ifdef NONBE_1328_FIX_NON_LINEARITY
    sc_factor = (float) ( 1 << ( 12 - norm_s( j - length / 2 + 1 ) ) ); /* allowed intra frame jump is smaller */
    sc_factor = max( sc_factor, 2.0f );

    if ( *prev_scale <= 0.0 || *prev_scale > sc_factor * scale )
#else
    if ( *prev_scale <= 0.0 || *prev_scale > 1024.0f * scale )
#endif
    {
        scale_step = 1.0;
        *prev_scale = scale;