diff --git a/lib_com/options.h b/lib_com/options.h index 7b61ed4b4a6cba050fc97b98cb3f1ba9a301671c..c825b037b4c1677a8b485b8603f48816be9ba9bb 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -156,6 +156,7 @@ #define FIX_890_ARRAY_SIZE /* Nokia: issue #890: mismatch in 2D array size declaration and use */ #define BE_FIX_887_GCC_WARNING_ARRAY_SIZE /* VoiceAge: Issue 887: change array size definition to avoid warning with gcc 11.4.0 */ #define FIX_247_EXTERNAL_RENDERER_COMMAND_LINE /* VA: issue 247: harmonize command-line options names of external renderer with the decoder */ +#define BE_893_SIMPLIFY_STRONG_LIMITING_LOGIC /* #################### End BE switches ################################## */ diff --git a/lib_rend/ivas_limiter.c b/lib_rend/ivas_limiter.c index 0953e8a825dc3aecfe8a51b004da4a2400884199..ff6d4f3884b617ce29596b4bafd325c5bd03d470 100644 --- a/lib_rend/ivas_limiter.c +++ b/lib_rend/ivas_limiter.c @@ -51,9 +51,37 @@ static int16_t detect_strong_saturations( const int16_t BER_detect, /* i : BER detect flag */ int16_t *strong_saturation_cnt, /* i/o: counter of strong saturations */ const float max_val, /* i : maximum absolute value */ - float *frame_gain /* i/o: frame gain value */ +#ifdef BE_893_SIMPLIFY_STRONG_LIMITING_LOGIC + const float frame_gain /* i : frame gain value */ +#else + float *frame_gain /* i/o: frame gain value */ +#endif ) { +#ifdef BE_893_SIMPLIFY_STRONG_LIMITING_LOGIC + if ( BER_detect ) + { + *strong_saturation_cnt = 50; + } + else if ( max_val > 3 * IVAS_LIMITER_THRESHOLD && *strong_saturation_cnt > 0 ) + { + /* strong_saturation_cnt stays unchanged. + * `if` condition still needs to be checked to avoid reaching the final `else` clause*/ + } + else if ( max_val > 10 * IVAS_LIMITER_THRESHOLD ) + { + *strong_saturation_cnt += 20; + *strong_saturation_cnt = min( *strong_saturation_cnt, 50 ); + } + else + { + ( *strong_saturation_cnt )--; + *strong_saturation_cnt = max( *strong_saturation_cnt, 0 ); + return 0; + } + + return frame_gain < 0.3f; +#else int16_t apply_strong_limiting; apply_strong_limiting = 0; @@ -92,6 +120,7 @@ static int16_t detect_strong_saturations( } return apply_strong_limiting; +#endif } /*-------------------------------------------------------------------* @@ -325,15 +354,30 @@ void limiter_process( /* Detection of very strong saturations */ if ( strong_saturation_cnt != NULL ) { - apply_strong_limiting = detect_strong_saturations( BER_detect, strong_saturation_cnt, max_val, &frame_gain ); + apply_strong_limiting = detect_strong_saturations( BER_detect, strong_saturation_cnt, max_val, frame_gain ); } +#ifdef BE_893_SIMPLIFY_STRONG_LIMITING_LOGIC + /* Apply strong limiting? */ + if ( apply_strong_limiting ) + { + frame_gain /= 3.0f; + } + /* ...otherwise limit gain reduction to 20dB. Any peaks that require gain reduction + * higher than this are most likely due to bit errors during decoding and should have + * been handled by the strong limiting mechanism */ + else if ( frame_gain < 0.1f ) + { + frame_gain = 0.1f; + } +#else /* Limit gain reduction to 20dB. Any peaks that require gain reduction * higher than this are most likely due to bit errors during decoding */ if ( frame_gain < 0.1f && !apply_strong_limiting ) { frame_gain = 0.1f; } +#endif if ( apply_limiting ) {