From 5564ba49a16f82e3ccb98cd008d824bcbc2ada13 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Fri, 28 Apr 2023 23:16:28 +0200 Subject: [PATCH] avfilter/af_adynamicequalizer: refactor code to gain small speedup --- libavfilter/af_adynamicequalizer.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/libavfilter/af_adynamicequalizer.c b/libavfilter/af_adynamicequalizer.c index 77c98ed105..e741b55ead 100644 --- a/libavfilter/af_adynamicequalizer.c +++ b/libavfilter/af_adynamicequalizer.c @@ -199,16 +199,25 @@ static int filter_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jo if (detection > 0) state[5] = fmax(state[5], detect); - if (direction == 0 && mode == 0 && detect < threshold) - detect = 1. / av_clipd(1. + makeup + (threshold - detect) * ratio, 1., range); - else if (direction == 0 && mode == 1 && detect < threshold) - detect = av_clipd(1. + makeup + (threshold - detect) * ratio, 1., range); - else if (direction == 1 && mode == 0 && detect > threshold) - detect = 1. / av_clipd(1. + makeup + (detect - threshold) * ratio, 1., range); - else if (direction == 1 && mode == 1 && detect > threshold) - detect = av_clipd(1. + makeup + (detect - threshold) * ratio, 1., range); - else - detect = 1.; + if (direction == 0) { + if (detect < threshold) { + if (mode == 0) + detect = 1. / av_clipd(1. + makeup + (threshold - detect) * ratio, 1., range); + else + detect = av_clipd(1. + makeup + (threshold - detect) * ratio, 1., range); + } else { + detect = 1.; + } + } else { + if (detect > threshold) { + if (mode == 0) + detect = 1. / av_clipd(1. + makeup + (detect - threshold) * ratio, 1., range); + else + detect = av_clipd(1. + makeup + (detect - threshold) * ratio, 1., range); + } else { + detect = 1.; + } + } if (direction == 0) { if (detect > state[4]) {