Commit 1b43912b authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Fix for crash observed with test_renderer cases

parent 1c43063a
Loading
Loading
Loading
Loading
Loading
+9 −10
Original line number Diff line number Diff line
@@ -368,11 +368,11 @@ void limiter_process_fx(
    Word32 releaseHeuristic;
    Word16 apply_limiting, apply_strong_limiting;
    Word32 **output;
    Word16 num_channels, q_fact_gain, div32, release_constant, compare_value;
    Word32 sampling_rate;
    Word16 gain, frame_gain, fact, fact_2, exp_pow, exp_pow_2, result;
    Word16 num_channels, q_fact_gain, div32, compare_value;
    Word32 sampling_rate, release_constant;
    Word16 gain, frame_gain, fact, fact_2, exp_pow, exp_pow_2 = 0, result;
    Word32 mul;
    Word32 mul_2;

    /* return early if given nonsensical values */
    IF ( hLimiter == NULL || output_frame <= 0 )
    {
@@ -452,7 +452,7 @@ void limiter_process_fx(
    }
    else
    {
        releaseHeuristic = max( 0, L_sub( releaseHeuristic, 53687091 ) );
        releaseHeuristic = max( 0, L_sub( releaseHeuristic, 5368709 ) );
        /* Unoptimized code for reference */
        /*releaseHeuristic = max( 0.f, releaseHeuristic - ( (float) 0.5f * output_frame / sampling_rate / adaptiveReleaseWindowLengthInSeconds ) );
         *                                                            ^
@@ -496,10 +496,8 @@ void limiter_process_fx(
        result = extract_l( Pow2( 14, fact ) );
        div32 = divide3232( L_lshl( 1, ( 14 - exp_pow + 1 ) ), L_mult( result, sample_num ) );
        /*For powf(0.01f,x)*/
        mul_2 = L_mult( -13607, div32 ) >> 10; // Q16
        fact_2 = L_Extract_lc( mul_2, &exp_pow_2 );
        release_constant = extract_l( Pow2( 2, fact_2 ) ); //-(Q2+exp_pow_2)

        fact_2 = shr(norm_l(div32 ),1)  ;
        release_constant = pow_10( L_lshl( -div32, fact_2  ), &exp_pow_2 );
        /* Unoptimized code for reference */
        /* releaseTimeInSeconds = 0.005f * powf(200.f, releaseHeuristic); <-- Map heuristic value (0; 1) exponentially to range (0.005; 1)
         * release_constant = powf( 0.01f, 1.0f / ( releaseTimeInSeconds * sampling_rate ) );
@@ -518,7 +516,8 @@ void limiter_process_fx(
            }
            else
            {
                gain = add(extract_l(L_lshr( L_mult( release_constant , sub( gain, frame_gain ) ), ( Q2 - exp_pow_2 ) )) , frame_gain);//q14
                Word16 temp = extract_l( L_lshl( Mpy_32_16_r( release_constant, sub( gain, frame_gain ) ), ( 15 - (exp_pow_2) ) ) );
                gain = add( temp, frame_gain ); // q14
            }

            for ( c = 0; c < num_channels; c++ )