Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2022-03-13 14:31:29 +0300
committerPaul B Mahol <onemda@gmail.com>2022-03-13 19:28:24 +0300
commit447ca90bcf05aeba1a9621133b67884600f2f1e1 (patch)
treec2d1c05abc08c38bc092e527211b82a9045073b6 /libavfilter/af_afftdn.c
parent546afd0d497b8d8a7140f3c4fd202034658414e5 (diff)
avfilter/af_afftdn: use define for sfm flags mask and size
Instead of hardcoding values.
Diffstat (limited to 'libavfilter/af_afftdn.c')
-rw-r--r--libavfilter/af_afftdn.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/libavfilter/af_afftdn.c b/libavfilter/af_afftdn.c
index acef2057ed..4c2686f7c2 100644
--- a/libavfilter/af_afftdn.c
+++ b/libavfilter/af_afftdn.c
@@ -31,6 +31,8 @@
#define C (M_LN10 * 0.1)
#define NB_PROFILE_BANDS (15)
+#define SFM_FLAGS_SIZE (512)
+#define SFM_FLAGS_MASK (SFM_FLAGS_SIZE - 1)
enum OutModes {
IN_MODE,
@@ -77,7 +79,7 @@ typedef struct DeNoiseChannel {
double sfm_threshold;
double sfm_alpha;
double sfm_results[3];
- int sfm_fail_flags[512];
+ int sfm_fail_flags[SFM_FLAGS_SIZE];
int sfm_fail_total;
double noise_reduction;
double last_noise_reduction;
@@ -412,7 +414,7 @@ static void process_frame(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch,
for (int i = 0; i < NB_PROFILE_BANDS; i++)
dnch->noise_band_auto_var[i] *= sum;
} else if (dnch->sfm_results[2] >= dnch->sfm_threshold) {
- dnch->sfm_fail_flags[s->block_count & 0x1FF] = 1;
+ dnch->sfm_fail_flags[s->block_count & SFM_FLAGS_MASK] = 1;
dnch->sfm_fail_total += 1;
}
}
@@ -703,13 +705,13 @@ static int config_input(AVFilterLink *inlink)
dnch->sfm_threshold = 0.8;
dnch->sfm_alpha = 0.05;
- for (i = 0; i < 512; i++)
+ for (i = 0; i < SFM_FLAGS_SIZE; i++)
dnch->sfm_fail_flags[i] = 0;
dnch->sfm_fail_total = 0;
j = FFMAX((int)(10.0 * (1.3 - dnch->sfm_threshold)), 1);
- for (i = 0; i < 512; i += j) {
+ for (i = 0; i < SFM_FLAGS_SIZE; i += j) {
dnch->sfm_fail_flags[i] = 1;
dnch->sfm_fail_total += 1;
}
@@ -1023,13 +1025,13 @@ static int filter_channel(AVFilterContext *ctx, void *arg, int jobnr, int nb_job
double *dst = dnch->out_samples;
if (s->track_noise) {
- int i = s->block_count & 0x1FF;
+ int i = s->block_count & SFM_FLAGS_MASK;
if (dnch->sfm_fail_flags[i])
dnch->sfm_fail_total--;
dnch->sfm_fail_flags[i] = 0;
dnch->sfm_threshold *= 1.0 - dnch->sfm_alpha;
- dnch->sfm_threshold += dnch->sfm_alpha * (0.5 + (1.0 / 640) * dnch->sfm_fail_total);
+ dnch->sfm_threshold += dnch->sfm_alpha * ((1.0 / SFM_FLAGS_SIZE) * dnch->sfm_fail_total);
}
for (int m = 0; m < s->window_length; m++)