FFmpeg: libavfilter/af_afftdn.c Source File
Go to the documentation of this file. 1 /*
2 * Copyright (c) 2018 The FFmpeg Project
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
22
31
32 #define C (M_LN10 * 0.1)
33 #define SOLVE_SIZE (5)
34 #define NB_PROFILE_BANDS (15)
35
41 };
42
48 };
49
56 };
57
64 };
65
88
93
104
107
121
134
136
141
143
145
149
157
158 #define OFFSET(x) offsetof(AudioFFTDeNoiseContext, x)
159 #define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
160 #define AFR AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
161
215 };
216
218
222 {
223 double d1, d2, d3;
224
225 d1 =
a /
s->band_centre[band];
226 d1 = 10.0 * log(1.0 + d1 * d1) /
M_LN10;
227 d2 =
b /
s->band_centre[band];
228 d2 = 10.0 * log(1.0 + d2 * d2) /
M_LN10;
229 d3 =
s->band_centre[band] /
c;
230 d3 = 10.0 * log(1.0 + d3 * d3) /
M_LN10;
231
232 return -d1 + d2 - d3;
233 }
234
236 {
237 for (
int i = 0;
i <
size - 1;
i++) {
238 for (
int j =
i + 1; j <
size; j++) {
240
242 for (
int k =
i + 1; k <
size; k++) {
244 }
245 }
246 }
247 }
248
250 {
251 for (
int i = 0;
i <
size - 1;
i++) {
252 for (
int j =
i + 1; j <
size; j++) {
254 vector[j] -=
d * vector[
i];
255 }
256 }
257
259
260 for (
int i =
size - 2;
i >= 0;
i--) {
261 double d = vector[
i];
262 for (
int j =
i + 1; j <
size; j++)
265 }
266 }
267
270 int band)
271 {
272 double product, sum,
f;
274
277
279 sum = 0.0;
282 s->vector_b[j] = sum;
283 }
284
287 f = 15.0 + log(
f / 1.5) / log(1.5);
288 sum = 0.0;
289 product = 1.0;
291 sum += product *
s->vector_b[j];
293 }
294
295 return sum;
296 }
297
299 {
301 return (
b *
a - 1.0) / (
b +
a - 2.0);
303 return (
b *
a - 2.0 *
a + 1.0) / (
b -
a);
304 return 1.0;
305 }
306
308 double floor,
int len,
double *rnum,
double *rden)
309 {
310 double num = 0., den = 0.;
312
313 for (
int n = 0; n <
len; n++) {
314 const double v = spectral[n];
316 num += log(v);
317 den += v;
319 }
320 }
321
323
326
328
329 *rnum = num;
330 *rden = den;
331 }
332
334
336 {
338
339 for (
int n = 0; n <
size; n++) {
340 const double p =
S[n] -
mean;
341
343 }
344
346 }
347
351 double *prior, double *prior_band_excit, int track_noise)
352 {
354 const double *abs_var = dnch->
abs_var;
356 const double rratio = 1. - ratio;
357 const int *bin2band =
s->bin2band;
362 double *gain = dnch->
gain;
363
364 for (
int i = 0;
i <
s->bin_count;
i++) {
365 double sqr_new_gain, new_gain,
power, mag, mag_abs_var, new_mag_abs_var;
366
367 noisy_data[
i] = mag =
hypot(fft_data[
i].
re, fft_data[
i].
im);
369 mag_abs_var =
power / abs_var[
i];
370 new_mag_abs_var = ratio * prior[
i] + rratio *
fmax(mag_abs_var - 1.0, 0.0);
371 new_gain = new_mag_abs_var / (1.0 + new_mag_abs_var);
372 sqr_new_gain = new_gain * new_gain;
373 prior[
i] = mag_abs_var * sqr_new_gain;
376 }
377
378 if (track_noise) {
379 double flatness, num, den;
380
382
383 flatness = num / den;
384 if (flatness > 0.8) {
386 const double new_floor =
av_clipd(10.0 * log10(den) - 100.0 +
offset, -90., -20.);
387
390 }
391 }
392
393 for (
int i = 0;
i <
s->number_of_bands;
i++) {
396 }
397
398 for (
int i = 0;
i <
s->bin_count;
i++)
400
401 for (
int i = 0;
i <
s->number_of_bands;
i++) {
402 band_excit[
i] =
fmax(band_excit[
i],
403 s->band_alpha[
i] * band_excit[
i] +
404 s->band_beta[
i] * prior_band_excit[
i]);
405 prior_band_excit[
i] = band_excit[
i];
406 }
407
408 for (
int j = 0,
i = 0; j <
s->number_of_bands; j++) {
409 for (
int k = 0; k <
s->number_of_bands; k++) {
411 }
412 }
413
414 for (
int i = 0;
i <
s->bin_count;
i++)
415 dnch->
amt[
i] = band_amt[bin2band[
i]];
416
417 for (
int i = 0;
i <
s->bin_count;
i++) {
418 if (dnch->
amt[
i] > abs_var[
i]) {
421 const double limit = sqrt(abs_var[
i] / dnch->
amt[
i]);
422
424 } else {
426 }
427 }
428
429 memcpy(smoothed_gain, gain,
s->bin_count *
sizeof(*smoothed_gain));
430 if (
s->gain_smooth > 0) {
431 const int r =
s->gain_smooth;
432
433 for (
int i =
r;
i <
s->bin_count -
r;
i++) {
434 const double gc = gain[
i];
435 double num = 0., den = 0.;
436
437 for (
int j = -
r; j <=
r; j++) {
438 const double g = gain[
i + j];
439 const double d = 1. -
fabs(
g - gc);
440
443 }
444
445 smoothed_gain[
i] = num / den;
446 }
447 }
448
449 for (
int i = 0;
i <
s->bin_count;
i++) {
450 const double new_gain = smoothed_gain[
i];
451
452 fft_data[
i].
re *= new_gain;
453 fft_data[
i].
im *= new_gain;
454 }
455 }
456
458 {
459 double d = x / 7500.0;
460
461 return 13.0 * atan(7.6
E-4 * x) + 3.5 * atan(
d *
d);
462 }
463
465 {
466 if (band == -1)
467 return lrint(
s->band_centre[0] / 1.5);
468
469 return s->band_centre[band];
470 }
471
473 {
475
478 } else {
479 i =
lrint(
s->band_centre[band] / 1.224745);
480 }
481
482 return FFMIN(
i,
s->sample_rate / 2);
483 }
484
487 {
488 double band_noise, d2, d3, d4, d5;
489 int i = 0, j = 0, k = 0;
490
491 d5 = 0.0;
493 for (
int m = j; m <
s->bin_count; m++) {
494 if (m == j) {
496 d5 = band_noise;
499 } else {
501 }
504 k++;
505 }
506 d3 = (j - m) / d2;
508 dnch->
rel_var[m] =
exp((d5 * d3 + band_noise * d4) *
C);
509 }
510
513 }
514
516 {
518 char *custom_noise_str, *p, *
arg, *saveptr =
NULL;
521
522 if (!
s->band_noise_str)
523 return;
524
525 custom_noise_str = p =
av_strdup(
s->band_noise_str);
526 if (!p)
527 return;
528
531
533 break;
534
536
540 break;
541 }
542
544 }
545
547 memcpy(dnch->
band_noise, band_noise,
sizeof(band_noise));
548 }
549
551 {
554
555 if (
s->track_residual)
557
559 if (update_auto_var) {
562 }
563
564 if (
s->track_residual) {
566 update_var = 1;
570 }
572 update_var = 1;
576 }
577
579
580 if (update_var) {
582
583 for (
int i = 0;
i <
s->bin_count;
i++) {
586 }
587 }
588 }
589
591 {
593
595 mean += band_noise[
i];
597
599 band_noise[
i] -=
mean;
600 }
601
603 {
606 double wscale, sar, sum, sdiv;
607 int i, j, k, m, n,
ret;
608
612
613 s->channels =
inlink->ch_layout.nb_channels;
614 s->sample_rate =
inlink->sample_rate;
615 s->sample_advance =
s->sample_rate / 80;
616 s->window_length = 3 *
s->sample_advance;
617 s->fft_length2 = 1 << (32 -
ff_clz(
s->window_length));
618 s->fft_length =
s->fft_length2;
619 s->buffer_length =
s->fft_length * 2;
620 s->bin_count =
s->fft_length2 / 2 + 1;
621
622 s->band_centre[0] = 80;
624 s->band_centre[
i] =
lrint(1.5 *
s->band_centre[
i - 1] + 5.0);
625 if (
s->band_centre[
i] < 1000) {
626 s->band_centre[
i] = 10 * (
s->band_centre[
i] / 10);
627 }
else if (
s->band_centre[
i] < 5000) {
628 s->band_centre[
i] = 50 * ((
s->band_centre[
i] + 20) / 50);
629 }
else if (
s->band_centre[
i] < 15000) {
630 s->band_centre[
i] = 100 * ((
s->band_centre[
i] + 45) / 100);
631 } else {
632 s->band_centre[
i] = 1000 * ((
s->band_centre[
i] + 495) / 1000);
633 }
634 }
635
641 }
642 }
643
645
649 s->matrix_b[
i++] = pow(k, j);
650
654 s->matrix_c[
i++] = pow(j, k);
655
656 s->window =
av_calloc(
s->window_length,
sizeof(*
s->window));
657 s->bin2band =
av_calloc(
s->bin_count,
sizeof(*
s->bin2band));
658 if (!
s->window || !
s->bin2band)
660
661 sdiv =
s->band_multiplier;
662 for (
i = 0;
i <
s->bin_count;
i++)
664
665 s->number_of_bands =
s->bin2band[
s->bin_count - 1] + 1;
666
667 s->band_alpha =
av_calloc(
s->number_of_bands,
sizeof(*
s->band_alpha));
668 s->band_beta =
av_calloc(
s->number_of_bands,
sizeof(*
s->band_beta));
669 if (!
s->band_alpha || !
s->band_beta)
671
672 for (
int ch = 0; ch <
inlink->ch_layout.nb_channels; ch++) {
675
676 switch (
s->noise_type) {
680 break;
684 break;
688 break;
691 break;
692 default:
694 }
695
697
721
741 }
742
743 for (
int ch = 0; ch <
inlink->ch_layout.nb_channels; ch++) {
747 double p1, p2;
748
749 p1 = pow(0.1, 2.5 / sdiv);
750 p2 = pow(0.1, 1.0 / sdiv);
751 j = 0;
752 for (m = 0; m <
s->number_of_bands; m++) {
753 for (n = 0; n <
s->number_of_bands; n++) {
754 if (n < m) {
756 } else if (n > m) {
758 } else {
760 }
761 }
762 }
763
764 for (m = 0; m <
s->number_of_bands; m++) {
766 prior_band_excit[m] = 0.0;
767 }
768
769 for (m = 0; m <
s->bin_count; m++)
771
772 j = 0;
773 for (m = 0; m <
s->number_of_bands; m++) {
774 for (n = 0; n <
s->number_of_bands; n++)
776 }
777
780 for (
int i = 0;
i <
s->number_of_bands;
i++) {
781 if (
i <
lrint(12.0 * sdiv)) {
783 } else {
784 dnch->
band_excit[
i] = pow(0.1, 2.5 - 0.2 * (
i / sdiv - 14.0));
785 }
787 }
788
789 for (
int i = 0;
i <
s->buffer_length;
i++)
791
792 j = 0;
793 for (
int i = 0;
i <
s->number_of_bands;
i++)
794 for (
int k = 0; k <
s->number_of_bands; k++)
796 }
797
798 j = 0;
799 sar =
s->sample_advance /
s->sample_rate;
800 for (
int i = 0;
i <
s->bin_count;
i++) {
801 if ((
i ==
s->fft_length2) || (
s->bin2band[
i] > j)) {
802 double d6 = (
i - 1) *
s->sample_rate /
s->fft_length;
803 double d7 =
fmin(0.008 + 2.2 / d6, 0.03);
804 s->band_alpha[j] =
exp(-sar / d7);
805 s->band_beta[j] = 1.0 -
s->band_alpha[j];
807 }
808 }
809
813
814 wscale = sqrt(8.0 / (9.0 *
s->fft_length));
815 sum = 0.0;
816 for (
int i = 0;
i <
s->window_length;
i++) {
817 double d10 = sin(
i *
M_PI /
s->window_length);
818 d10 *= wscale * d10;
820 sum += d10 * d10;
821 }
822
823 s->window_weight = 0.5 * sum;
824 s->floor = (1LL << 48) *
exp(-23.025558369790467) *
s->window_weight;
825 s->sample_floor =
s->floor *
exp(4.144600506562284);
826
827 for (
int ch = 0; ch <
inlink->ch_layout.nb_channels; ch++) {
829
833
835 }
836
841 if (
s->noise_band_edge[j] >
lrint(1.1 *
s->noise_band_edge[j - 1]))
844 }
846
847 return 0;
848 }
849
851 {
857 }
858 }
859
863 {
865 double mag2, var = 0.0, avr = 0.0, avi = 0.0;
866 int edge, j, k, n, edgemax;
867
868 for (
int i = 0;
i <
s->window_length;
i++)
870
871 for (
int i =
s->window_length; i < s->fft_length2;
i++)
873
875
876 edge =
s->noise_band_edge[0];
877 j = edge;
878 k = 0;
879 n = j;
881 for (
int i = j;
i <= edgemax;
i++) {
882 if ((
i == j) && (
i < edgemax)) {
883 if (j > edge) {
888 }
889 k++;
890 edge = j;
891 j =
s->noise_band_edge[k];
893 j++;
894 }
895 var = 0.0;
896 avr = 0.0;
897 avi = 0.0;
898 }
903
904 mag2 =
fmax(mag2,
s->sample_floor);
905
906 var += mag2;
907 n++;
908 }
909
914 }
915
918 double *sample_noise)
919 {
920 for (
int i = 0;
i <
s->noise_band_count;
i++) {
928 }
931 sample_noise[
i] = sample_noise[
i - 1];
932 }
933 }
934
937 double *sample_noise)
938 {
941 double sum = 0.0;
942
944 temp[m] = sample_noise[m];
945
947 sum = 0.0;
949 sum +=
s->matrix_b[
i++] *
temp[n];
950 s->vector_b[m] = sum;
951 }
954 sum = 0.0;
956 sum +=
s->matrix_c[
i++] *
s->vector_b[n];
958 }
959
961
964 new_band_noise[m] =
temp[m];
965 new_band_noise[m] =
av_clipd(new_band_noise[m], -24.0, 24.0);
967 }
969 memcpy(dnch->
band_noise, new_band_noise,
sizeof(new_band_noise));
970 }
971
973 {
978 const int window_length =
s->window_length;
979 const double *
window =
s->window;
980
981 for (int ch = start; ch < end; ch++) {
985 float *fft_in = dnch->
fft_in;
986
987 for (
int m = 0; m < window_length; m++)
988 fft_in[m] =
window[m] *
src[m] * (1LL << 23);
989
990 for (
int m = window_length; m <
s->fft_length2; m++)
991 fft_in[m] = 0;
992
994
999
1001
1002 for (int m = 0; m < window_length; m++)
1003 dst[m] +=
s->window[m] * fft_in[m] / (1LL << 23);
1004 }
1005
1006 return 0;
1007 }
1008
1010 {
1014 const int output_mode =
ctx->is_disabled ?
IN_MODE :
s->output_mode;
1015 const int offset =
s->window_length -
s->sample_advance;
1017
1018 for (
int ch = 0; ch <
s->channels; ch++) {
1019 float *
src = (
float *)
s->winframe->extended_data[ch];
1020
1021 memmove(
src, &
src[
s->sample_advance],
offset *
sizeof(
float));
1024 }
1025
1026 if (
s->track_noise) {
1027 double average = 0.0,
min = DBL_MAX,
max = -DBL_MAX;
1028
1029 for (
int ch = 0; ch <
inlink->ch_layout.nb_channels; ch++) {
1031
1035 }
1036
1037 average /=
inlink->ch_layout.nb_channels;
1038
1039 for (
int ch = 0; ch <
inlink->ch_layout.nb_channels; ch++) {
1041
1042 switch (
s->noise_floor_link) {
1047 default:
1048 break;
1049 }
1050
1053 }
1054 }
1055
1057 for (
int ch = 0; ch <
inlink->ch_layout.nb_channels; ch++) {
1059
1061 }
1063 s->sample_noise = 1;
1064 s->sample_noise_blocks = 0;
1065 }
1066
1067 if (
s->sample_noise) {
1068 for (
int ch = 0; ch <
inlink->ch_layout.nb_channels; ch++) {
1070
1072 }
1073 s->sample_noise_blocks++;
1074 }
1075
1077 for (
int ch = 0; ch <
inlink->ch_layout.nb_channels; ch++) {
1080
1081 if (
s->sample_noise_blocks <= 0)
1082 break;
1086 }
1087 s->sample_noise = 0;
1088 s->sample_noise_blocks = 0;
1090 }
1091
1094
1097 } else {
1102 }
1103
1105 }
1106
1107 for (
int ch = 0; ch <
inlink->ch_layout.nb_channels; ch++) {
1110 const float *orig = (
const float *)
s->winframe->extended_data[ch];
1111 float *dst = (
float *)
out->extended_data[ch];
1112
1113 switch (output_mode) {
1115 for (
int m = 0; m <
out->nb_samples; m++)
1116 dst[m] = orig[m];
1117 break;
1119 for (
int m = 0; m <
out->nb_samples; m++)
1121 break;
1123 for (
int m = 0; m <
out->nb_samples; m++)
1124 dst[m] = orig[m] -
src[m];
1125 break;
1126 default:
1131 }
1132 memmove(
src,
src +
s->sample_advance, (
s->window_length -
s->sample_advance) *
sizeof(*
src));
1133 memset(
src + (
s->window_length -
s->sample_advance), 0,
s->sample_advance *
sizeof(*
src));
1134 }
1135
1139 }
1140
1142 {
1148
1150
1156
1159 return 0;
1160 }
1161
1164
1166 }
1167
1169 {
1171
1177
1179 for (
int ch = 0; ch <
s->channels; ch++) {
1199 }
1201 }
1202 }
1203
1205 char *res,
int res_len,
int flags)
1206 {
1209
1213
1214 if (!strcmp(cmd, "sample_noise") || !strcmp(cmd, "sn"))
1215 return 0;
1216
1217 for (
int ch = 0; ch <
s->channels; ch++) {
1219
1223
1225 }
1226
1227 return 0;
1228 }
1229
1231 {
1235 },
1236 };
1237
1239 {
1242 },
1243 };
1244
1249 .priv_class = &afftdn_class,
1258 };
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
@ AV_SAMPLE_FMT_FLTP
float, planar
double noise_band_auto_var[NB_PROFILE_BANDS]
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static void process_frame(AVFilterContext *ctx, AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, AVComplexFloat *fft_data, double *prior, double *prior_band_excit, int track_noise)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static int activate(AVFilterContext *ctx)
static const AVFilterPad inputs[]
#define FILTER_SINGLE_SAMPLEFMT(sample_fmt_)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
static void solve(double *matrix, double *vector, int size)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static void sample_noise_block(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, AVFrame *in, int ch)
const char * name
Filter name.
int nb_channels
Number of channels in this layout.
A link between two filters.
double vector_b[SOLVE_SIZE]
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently...
double noise_band_norm[NB_PROFILE_BANDS]
static void factor(double *array, int size)
double noise_band_avr[NB_PROFILE_BANDS]
static int config_input(AVFilterLink *inlink)
static SDL_Window * window
static double freq2bark(double x)
double band_noise[NB_PROFILE_BANDS]
AVChannelLayout ch_layout
Channel layout of the audio data.
static av_always_inline float scale(float x, float s)
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
double last_noise_reduction
static const AVOption afftdn_options[]
double matrix_a[SOLVE_SIZE *SOLVE_SIZE]
static __device__ float floor(float a)
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
double noise_band_sample[NB_PROFILE_BANDS]
#define FILTER_INPUTS(array)
static int get_band_edge(AudioFFTDeNoiseContext *s, int band)
int av_sscanf(const char *string, const char *format,...)
See libc sscanf manual for more information.
Describe the class of an AVClass context structure.
static __device__ float fabs(float a)
int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
Take samples from the link's FIFO and update the link's stats.
double matrix_b[SOLVE_SIZE *NB_PROFILE_BANDS]
static int filter_channel(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static void set_band_parameters(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static void init_sample_noise(DeNoiseChannel *dnch)
static void read_custom_noise(AudioFFTDeNoiseContext *s, int ch)
double last_residual_floor
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const AVFilterPad outputs[]
static int output_frame(AVFilterLink *inlink, AVFrame *in)
double fmin(double, double)
static av_const double hypot(double x, double y)
double matrix_c[SOLVE_SIZE *NB_PROFILE_BANDS]
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
static void finish_sample_noise(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, double *sample_noise)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
FF_FILTER_FORWARD_WANTED(outlink, inlink)
static double limit_gain(double a, double b)
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
#define AV_LOG_INFO
Standard information.
static av_cold void uninit(AVFilterContext *ctx)
int nb_samples
number of audio samples (per channel) described by this frame
#define i(width, name, range_min, range_max)
double noise_band_avi[NB_PROFILE_BANDS]
uint8_t ** extended_data
pointers to the data planes/channels.
double * prior_band_excit
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
const char * name
Pad name.
int ff_inlink_queued_samples(AVFilterLink *link)
void * av_calloc(size_t nmemb, size_t size)
static double limit(double x)
static int array[MAX_W *MAX_W]
static double get_band_noise(AudioFFTDeNoiseContext *s, int band, double a, double b, double c)
@ AV_TX_FLOAT_RDFT
Real to complex and complex to real DFTs.
double fmax(double, double)
static float power(float r, float g, float b, float max)
static void set_parameters(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, int update_var, int update_auto_var)
static double process_get_band_noise(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, int band)
static int noise(AVBSFContext *ctx, AVPacket *pkt)
static void spectral_flatness(AudioFFTDeNoiseContext *s, const double *const spectral, double floor, int len, double *rnum, double *rden)
static float mean(const float *input, int size)
double noise_band_var[NB_PROFILE_BANDS]
int band_centre[NB_PROFILE_BANDS]
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
char * av_strdup(const char *s)
Duplicate a string.
AVFILTER_DEFINE_CLASS(afftdn)
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
FF_FILTER_FORWARD_STATUS(inlink, outlink)
#define FILTER_OUTPUTS(array)
static double floor_offset(const double *S, int size, double mean)
int noise_band_edge[NB_PROFILE_BANDS+2]
static void reduce_mean(double *band_noise)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
#define flags(name, subs,...)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
static void set_noise_profile(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, double *sample_noise)
static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
static int get_band_centre(AudioFFTDeNoiseContext *s, int band)
const AVFilter ff_af_afftdn
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
Generated on Wed Aug 24 2022 21:41:57 for FFmpeg by
doxygen
1.8.17