Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -50,7 +50,7 @@ enum NoiseType { · 49 unmodified lines | ||
| 50 | 50 | }; |
| 51 | 51 | |
| 52 | 52 | typedef struct DeNoiseChannel { |
| 53 | − int band_noise[NB_PROFILE_BANDS]; | |
| 53 | + double band_noise[NB_PROFILE_BANDS]; | |
| 54 | 54 | double noise_band_auto_var[NB_PROFILE_BANDS]; |
| 55 | 55 | double noise_band_sample[NB_PROFILE_BANDS]; |
| 56 | 56 | double *amt; |
| @@ -181,9 +181,9 @@ static const AVOption afftdn_options[] = { · 124 unmodified lines | ||
| 181 | 181 | |
| 182 | 182 | AVFILTER_DEFINE_CLASS(afftdn); |
| 183 | 183 | |
| 184 | −static int get_band_noise(AudioFFTDeNoiseContext *s, | |
| 185 | − int band, double a, | |
| 186 | − double b, double c) | |
| 184 | +static double get_band_noise(AudioFFTDeNoiseContext *s, | |
| 185 | + int band, double a, | |
| 186 | + double b, double c) | |
| 187 | 187 | { |
| 188 | 188 | double d1, d2, d3; |
| 189 | 189 | |
| @@ -194,7 +194,7 @@ static int get_band_noise(AudioFFTDeNoiseContext *s, · 4 unmodified lines | ||
| 194 | 194 | d3 = s->band_centre[band] / c; |
| 195 | 195 | d3 = 10.0 * log(1.0 + d3 * d3) / M_LN10; |
| 196 | 196 | |
| 197 | − return lrint(-d1 + d2 - d3); | |
| 197 | + return -d1 + d2 - d3; | |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | static void factor(double *array, int size) |
| @@ -230,9 +230,9 @@ static void solve(double *matrix, double *vector, int size) · 29 unmodified lines | ||
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | −static int process_get_band_noise(AudioFFTDeNoiseContext *s, | |
| 234 | − DeNoiseChannel *dnch, | |
| 235 | − int band) | |
| 233 | +static double process_get_band_noise(AudioFFTDeNoiseContext *s, | |
| 234 | + DeNoiseChannel *dnch, | |
| 235 | + int band) | |
| 236 | 236 | { |
| 237 | 237 | double product, sum, f; |
| 238 | 238 | int i = 0; |
| @@ -257,7 +257,7 @@ static int process_get_band_noise(AudioFFTDeNoiseContext *s, · 18 unmodified lines | ||
| 257 | 257 | product *= f; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | − return lrint(sum); | |
| 260 | + return sum; | |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | static void calculate_sfm(AudioFFTDeNoiseContext *s, |
| @@ -537,7 +537,8 @@ static void read_custom_noise(AudioFFTDeNoiseContext *s, int ch) · 273 unmodified lines | ||
| 537 | 537 | { |
| 538 | 538 | DeNoiseChannel *dnch = &s->dnch[ch]; |
| 539 | 539 | char *p, *arg, *saveptr = NULL; |
| 540 | − int i, ret, band_noise[NB_PROFILE_BANDS] = { 0 }; | |
| 540 | + double band_noise[NB_PROFILE_BANDS] = { 0.f }; | |
| 541 | + int ret; | |
| 541 | 542 | |
| 542 | 543 | if (!s->band_noise_str) |
| 543 | 544 | return; |
| @@ -546,19 +547,19 @@ static void read_custom_noise(AudioFFTDeNoiseContext *s, int ch) · 2 unmodified lines | ||
| 546 | 547 | if (!p) |
| 547 | 548 | return; |
| 548 | 549 | |
| 549 | − for (i = 0; i < NB_PROFILE_BANDS; i++) { | |
| 550 | + for (int i = 0; i < NB_PROFILE_BANDS; i++) { | |
| 550 | 551 | if (!(arg = av_strtok(p, "| ", &saveptr))) |
| 551 | 552 | break; |
| 552 | 553 | |
| 553 | 554 | p = NULL; |
| 554 | 555 | |
| 555 | − ret = av_sscanf(arg, "%d", &band_noise[i]); | |
| 556 | + ret = av_sscanf(arg, "%f", &band_noise[i]); | |
| 556 | 557 | if (ret != 1) { |
| 557 | − av_log(s, AV_LOG_ERROR, "Custom band noise must be integer.\n"); | |
| 558 | + av_log(s, AV_LOG_ERROR, "Custom band noise must be float.\n"); | |
| 558 | 559 | break; |
| 559 | 560 | } |
| 560 | 561 | |
| 561 | − band_noise[i] = av_clip(band_noise[i], -24, 24); | |
| 562 | + band_noise[i] = av_clipd(band_noise[i], -24., 24.); | |
| 562 | 563 | } |
| 563 | 564 | |
| 564 | 565 | av_free(p); |
| @@ -594,7 +595,7 @@ static void set_parameters(AudioFFTDeNoiseContext *s) · 29 unmodified lines | ||
| 594 | 595 | } |
| 595 | 596 | } |
| 596 | 597 | |
| 597 | −static void reduce_mean(int *band_noise) | |
| 598 | +static void reduce_mean(double *band_noise) | |
| 598 | 599 | { |
| 599 | 600 | double mean = 0.f; |
| 600 | 601 | |
| @@ -683,7 +684,7 @@ static int config_input(AVFilterLink *inlink) · 82 unmodified lines | ||
| 683 | 684 | switch (s->noise_type) { |
| 684 | 685 | case WHITE_NOISE: |
| 685 | 686 | for (i = 0; i < NB_PROFILE_BANDS; i++) |
| 686 | − dnch->band_noise[i] = 0; | |
| 687 | + dnch->band_noise[i] = 0.; | |
| 687 | 688 | break; |
| 688 | 689 | case VINYL_NOISE: |
| 689 | 690 | for (i = 0; i < NB_PROFILE_BANDS; i++) |
| @@ -956,7 +957,7 @@ static void set_noise_profile(AudioFFTDeNoiseContext *s, · 266 unmodified lines | ||
| 956 | 957 | double *sample_noise, |
| 957 | 958 | int new_profile) |
| 958 | 959 | { |
| 959 | − int new_band_noise[NB_PROFILE_BANDS]; | |
| 960 | + double new_band_noise[NB_PROFILE_BANDS]; | |
| 960 | 961 | double temp[NB_PROFILE_BANDS]; |
| 961 | 962 | double sum = 0.0, d1; |
| 962 | 963 | float new_noise_floor; |
| @@ -995,9 +996,9 @@ static void set_noise_profile(AudioFFTDeNoiseContext *s, · 32 unmodified lines | ||
| 995 | 996 | if (new_profile) { |
| 996 | 997 | av_log(s, AV_LOG_INFO, "bn="); |
| 997 | 998 | for (int m = 0; m < NB_PROFILE_BANDS; m++) { |
| 998 | − new_band_noise[m] = lrint(temp[m]); | |
| 999 | − new_band_noise[m] = av_clip(new_band_noise[m], -24, 24); | |
| 1000 | − av_log(s, AV_LOG_INFO, "%d ", new_band_noise[m]); | |
| 999 | + new_band_noise[m] = temp[m]; | |
| 1000 | + new_band_noise[m] = av_clipd(new_band_noise[m], -24.0, 24.0); | |
| 1001 | + av_log(s, AV_LOG_INFO, "%f ", new_band_noise[m]); | |
| 1001 | 1002 | } |
| 1002 | 1003 | av_log(s, AV_LOG_INFO, "\n"); |
| 1003 | 1004 | memcpy(dnch->band_noise, new_band_noise, sizeof(new_band_noise)); |