Go to the documentation of this file.
33 #define C (M_LN10 * 0.1)
35 #define RRATIO (1.0 - RATIO)
145 #define OFFSET(x) offsetof(AudioFFTDeNoiseContext, x)
146 #define AF AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
147 #define AFR AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
176 d1 =
a /
s->band_centre[band];
177 d1 = 10.0 * log(1.0 + d1 * d1) /
M_LN10;
178 d2 =
b /
s->band_centre[band];
179 d2 = 10.0 * log(1.0 + d2 * d2) /
M_LN10;
180 d3 =
s->band_centre[band] /
c;
181 d3 = 10.0 * log(1.0 + d3 * d3) /
M_LN10;
183 return lrint(-d1 + d2 - d3);
188 for (
int i = 0;
i <
size - 1;
i++) {
189 for (
int j =
i + 1; j <
size; j++) {
193 for (
int k =
i + 1; k <
size; k++) {
200 static void solve(
double *matrix,
double *vector,
int size)
202 for (
int i = 0;
i <
size - 1;
i++) {
203 for (
int j =
i + 1; j <
size; j++) {
204 double d = matrix[j +
i *
size];
205 vector[j] -=
d * vector[
i];
211 for (
int i =
size - 2;
i >= 0;
i--) {
212 double d = vector[
i];
213 for (
int j =
i + 1; j <
size; j++)
214 d -= matrix[
i + j *
size] * vector[j];
215 vector[
i] =
d / matrix[
i +
i *
size];
223 double product, sum,
f;
229 for (
int j = 0; j < 5; j++) {
231 for (
int k = 0; k < 15; k++)
233 s->vector_b[j] = sum;
236 solve(
s->matrix_a,
s->vector_b, 5);
237 f = (0.5 *
s->sample_rate) /
s->band_centre[14];
238 f = 15.0 + log(
f / 1.5) / log(1.5);
241 for (
int j = 0; j < 5; j++) {
242 sum += product *
s->vector_b[j];
253 double d1 = 0.0, d2 = 1.0;
256 for (
int k = start; k < end; k++) {
264 }
else if (d2 < 1.0
E-100) {
273 d2 = log(d2) + 230.2585 *
i;
288 return (
b *
a - 1.0) / (
b +
a - 2.0);
290 return (
b *
a - 2.0 *
a + 1.0) / (
b -
a);
296 double *prior,
double *prior_band_excit,
int track_noise)
298 double d1, d2, d3, gain;
301 d1 = fft_data[0].
re * fft_data[0].
re;
305 gain = d3 / (1.0 + d3);
306 gain *= (gain + M_PI_4 /
fmax(d2, 1.0
E-6));
307 prior[0] = (d2 * gain);
310 dnch->
gain[0] = gain;
312 for (
int i = 1;
i <
s->fft_length2;
i++) {
313 d1 = fft_data[
i].
re * fft_data[
i].
re + fft_data[
i].
im * fft_data[
i].
im;
314 if (d1 >
s->sample_floor)
320 gain = d3 / (1.0 + d3);
321 gain *= (gain + M_PI_4 /
fmax(d2, 1.0
E-6));
322 prior[
i] = d2 * gain;
325 dnch->
gain[
i] = gain;
327 d1 = fft_data[0].
im * fft_data[0].
im;
328 if (d1 >
s->sample_floor)
332 d2 = d1 / dnch->
abs_var[
s->fft_length2];
334 gain = d3 / (1.0 + d3);
335 gain *= gain + M_PI_4 /
fmax(d2, 1.0
E-6);
336 prior[
s->fft_length2] = d2 * gain;
339 dnch->
gain[
s->fft_length2] = gain;
340 if (n >
s->fft_length2 - 2) {
342 i1 =
s->noise_band_count;
345 for (
int i = 0;
i <=
s->noise_band_count;
i++) {
346 if (n > 1.1 *
s->noise_band_edge[
i]) {
352 if (track_noise && (i1 >
s->noise_band_count / 2)) {
353 int j =
FFMIN(n,
s->noise_band_edge[i1]);
356 for (k = i1 - 1; k >= 0; k--) {
357 int i =
s->noise_band_edge[k];
368 double sum = 0.0,
min,
max;
371 for (
i = i1 - 1;
i > k;
i--) {
378 min = 3.0E-4 *
i *
i;
380 min = 3.0E-4 * (8 *
i - 16);
383 max = 2.0E-4 *
i *
i;
385 max = 2.0E-4 * (4 *
i - 4);
388 if (
s->track_residual) {
389 if (
s->last_noise_floor >
s->last_residual_floor + 9) {
392 }
else if (
s->last_noise_floor >
s->last_residual_floor + 6) {
395 }
else if (
s->last_noise_floor >
s->last_residual_floor + 4) {
398 }
else if (
s->last_noise_floor >
s->last_residual_floor + 2) {
401 }
else if (
s->last_noise_floor >
s->last_residual_floor) {
412 for (
int i = 0;
i < 15;
i++)
420 for (
int i = 0;
i <
s->number_of_bands;
i++) {
425 for (
int i = 0;
i <
s->bin_count;
i++) {
429 for (
int i = 0;
i <
s->number_of_bands;
i++) {
432 s->band_beta[
i] * prior_band_excit[
i]);
436 for (
int j = 0,
i = 0; j <
s->number_of_bands; j++) {
437 for (
int k = 0; k <
s->number_of_bands; k++) {
442 for (
int i = 0;
i <
s->bin_count;
i++)
453 if (dnch->
amt[
s->fft_length2] > dnch->
abs_var[
s->fft_length2]) {
454 dnch->
gain[
s->fft_length2] = 1.0;
462 for (
int i = 1;
i <
s->fft_length2;
i++) {
473 gain = dnch->
gain[0];
475 fft_data[0].
re *= gain;
476 gain = dnch->
gain[
s->fft_length2];
478 fft_data[0].
im *= gain;
479 for (
int i = 1;
i <
s->fft_length2;
i++) {
480 gain = dnch->
gain[
i];
482 fft_data[
i].
re *= gain;
483 fft_data[
i].
im *= gain;
489 double d = x / 7500.0;
491 return 13.0 * atan(7.6
E-4 * x) + 3.5 * atan(
d *
d);
497 return lrint(
s->band_centre[0] / 1.5);
499 return s->band_centre[band];
507 i =
lrint(
s->band_centre[14] * 1.224745);
509 i =
lrint(
s->band_centre[band] / 1.224745);
512 return FFMIN(
i,
s->sample_rate / 2);
518 double band_noise, d2, d3, d4, d5;
519 int i = 0, j = 0, k = 0;
523 for (
int m = j; m <=
s->fft_length2; m++) {
538 dnch->
rel_var[m] =
exp((d5 * d3 + band_noise * d4) *
C);
542 for (
i = 0;
i < 15;
i++)
545 for (
i = 0;
i <=
s->fft_length2;
i++) {
554 char *p, *
arg, *saveptr =
NULL;
555 int i,
ret, band_noise[15] = { 0 };
557 if (!
s->band_noise_str)
564 for (
i = 0;
i < 15;
i++) {
576 band_noise[
i] =
av_clip(band_noise[
i], -24, 24);
580 memcpy(dnch->
band_noise, band_noise,
sizeof(band_noise));
585 if (
s->last_noise_floor !=
s->noise_floor)
586 s->last_noise_floor =
s->noise_floor;
588 if (
s->track_residual)
589 s->last_noise_floor =
fmaxf(
s->last_noise_floor,
s->residual_floor);
591 s->max_var =
s->floor *
exp((100.0 +
s->last_noise_floor) *
C);
593 if (
s->track_residual) {
594 s->last_residual_floor =
s->residual_floor;
595 s->last_noise_reduction =
fmax(
s->last_noise_floor -
s->last_residual_floor, 0);
596 s->max_gain =
exp(
s->last_noise_reduction * (0.5 *
C));
597 }
else if (
s->noise_reduction !=
s->last_noise_reduction) {
598 s->last_noise_reduction =
s->noise_reduction;
599 s->last_residual_floor =
av_clipf(
s->last_noise_floor -
s->last_noise_reduction, -80, -20);
600 s->max_gain =
exp(
s->last_noise_reduction * (0.5 *
C));
603 s->gain_scale = 1.0 / (
s->max_gain *
s->max_gain);
605 for (
int ch = 0; ch <
s->channels; ch++) {
616 double wscale, sar, sum, sdiv;
617 int i, j, k, m, n,
ret;
624 s->channels =
inlink->channels;
625 s->sample_rate =
inlink->sample_rate;
626 s->sample_advance =
s->sample_rate / 80;
627 s->window_length = 3 *
s->sample_advance;
628 s->fft_length2 = 1 << (32 -
ff_clz(
s->window_length));
629 s->fft_length =
s->fft_length2 * 2;
630 s->buffer_length =
s->fft_length * 2;
631 s->bin_count =
s->fft_length2 + 1;
633 s->band_centre[0] = 80;
634 for (
i = 1;
i < 15;
i++) {
635 s->band_centre[
i] =
lrint(1.5 *
s->band_centre[
i - 1] + 5.0);
636 if (
s->band_centre[
i] < 1000) {
637 s->band_centre[
i] = 10 * (
s->band_centre[
i] / 10);
638 }
else if (
s->band_centre[
i] < 5000) {
639 s->band_centre[
i] = 50 * ((
s->band_centre[
i] + 20) / 50);
640 }
else if (
s->band_centre[
i] < 15000) {
641 s->band_centre[
i] = 100 * ((
s->band_centre[
i] + 45) / 100);
643 s->band_centre[
i] = 1000 * ((
s->band_centre[
i] + 495) / 1000);
647 for (j = 0; j < 5; j++) {
648 for (k = 0; k < 5; k++) {
649 s->matrix_a[j + k * 5] = 0.0;
650 for (m = 0; m < 15; m++)
651 s->matrix_a[j + k * 5] += pow(m, j + k);
658 for (j = 0; j < 5; j++)
659 for (k = 0; k < 15; k++)
660 s->matrix_b[
i++] = pow(k, j);
663 for (j = 0; j < 15; j++)
664 for (k = 0; k < 5; k++)
665 s->matrix_c[
i++] = pow(j, k);
667 s->window =
av_calloc(
s->window_length,
sizeof(*
s->window));
668 s->bin2band =
av_calloc(
s->bin_count,
sizeof(*
s->bin2band));
669 if (!
s->window || !
s->bin2band)
672 sdiv =
s->sample_rate / 17640.0;
673 for (
i = 0;
i <=
s->fft_length2;
i++)
676 s->number_of_bands =
s->bin2band[
s->fft_length2] + 1;
678 s->band_alpha =
av_calloc(
s->number_of_bands,
sizeof(*
s->band_alpha));
679 s->band_beta =
av_calloc(
s->number_of_bands,
sizeof(*
s->band_beta));
680 if (!
s->band_alpha || !
s->band_beta)
683 for (
int ch = 0; ch <
inlink->channels; ch++) {
687 switch (
s->noise_type) {
689 for (
i = 0;
i < 15;
i++)
697 for (
i = 0;
i < 15;
i++)
710 for (
i = 0;
i < 512;
i++)
716 for (
i = 0;
i < 512;
i += j) {
764 for (
int ch = 0; ch <
inlink->channels; ch++) {
767 double *prior = dnch->
prior;
771 p1 = pow(0.1, 2.5 / sdiv);
772 p2 = pow(0.1, 1.0 / sdiv);
774 for (m = 0; m <
s->number_of_bands; m++) {
775 for (n = 0; n <
s->number_of_bands; n++) {
786 for (m = 0; m <
s->number_of_bands; m++) {
788 prior_band_excit[m] = 0.0;
791 for (m = 0; m <=
s->fft_length2; m++)
795 for (m = 0; m <
s->number_of_bands; m++) {
796 for (n = 0; n <
s->number_of_bands; n++)
802 for (
int i = 0;
i <
s->number_of_bands;
i++) {
803 if (
i <
lrint(12.0 * sdiv)) {
806 dnch->
band_excit[
i] = pow(0.1, 2.5 - 0.2 * (
i / sdiv - 14.0));
811 for (
int i = 0;
i <=
s->fft_length2;
i++)
813 for (
int i = 0;
i <
s->buffer_length;
i++)
817 for (
int i = 0;
i <
s->number_of_bands;
i++)
818 for (
int k = 0; k <
s->number_of_bands; k++)
823 sar =
s->sample_advance /
s->sample_rate;
824 for (
int i = 0;
i <=
s->fft_length2;
i++) {
825 if ((
i ==
s->fft_length2) || (
s->bin2band[
i] > j)) {
826 double d6 = (
i - 1) *
s->sample_rate /
s->fft_length;
827 double d7 =
fmin(0.008 + 2.2 / d6, 0.03);
828 s->band_alpha[j] =
exp(-sar / d7);
829 s->band_beta[j] = 1.0 -
s->band_alpha[j];
834 wscale = sqrt(16.0 / (9.0 *
s->fft_length));
836 for (
int i = 0;
i <
s->window_length;
i++) {
837 double d10 = sin(
i *
M_PI /
s->window_length);
843 s->window_weight = 0.5 * sum;
844 s->floor = (1LL << 48) *
exp(-23.025558369790467) *
s->window_weight;
845 s->sample_floor =
s->floor *
exp(4.144600506562284);
846 s->auto_floor =
s->floor *
exp(6.907667510937141);
852 for (
int j = 1; j < 16; j++) {
854 if (
s->noise_band_edge[j] >
lrint(1.1 *
s->noise_band_edge[j - 1]))
856 s->noise_band_edge[16] =
i;
858 s->noise_band_count =
s->noise_band_edge[16];
869 double d1, d2, d3, d4, d5, d6, d7, d8, d9, d10;
880 for (
i = 1;
i <
len / 4;
i++) {
882 d2 = 0.5 * (in[
i].
re + in[k].
re);
883 d1 = 0.5 * (in[
i].
im - in[k].
im);
884 d4 = 0.5 * (in[
i].
im + in[k].
im);
885 d3 = 0.5 * (in[k].
re - in[
i].
re);
886 in[
i].
re = d2 + d9 * d4 + d6 * d3;
887 in[
i].
im = d1 + d9 * d3 - d6 * d4;
888 in[k].
re = d2 - d9 * d4 - d6 * d3;
889 in[k].
im = -d1 + d9 * d3 - d6 * d4;
891 d9 += d9 * d8 - d6 * d7;
892 d6 += d6 * d8 + d10 * d7;
896 in[0].
re = d2 + in[0].
im;
897 in[0].
im = d2 - in[0].
im;
902 double d1, d2, d3, d4, d5, d6, d7, d8, d9, d10;
912 for (
i = 1;
i <
len / 4;
i++) {
914 d2 = 0.5 * (in[
i].
re + in[k].
re);
915 d1 = 0.5 * (in[
i].
im - in[k].
im);
916 d4 = 0.5 * (in[
i].
re - in[k].
re);
917 d3 = 0.5 * (in[
i].
im + in[k].
im);
918 in[
i].
re = d2 - d9 * d3 - d6 * d4;
919 in[
i].
im = d1 + d9 * d4 - d6 * d3;
920 in[k].
re = d2 + d9 * d3 + d6 * d4;
921 in[k].
im = -d1 + d9 * d4 - d6 * d3;
923 d9 += d9 * d8 - d6 * d7;
924 d6 += d6 * d8 + d10 * d7;
927 in[0].
re = 0.5 * (d2 + in[0].
im);
928 in[0].
im = 0.5 * (d2 - in[0].
im);
933 for (
int i = 0;
i < 15;
i++) {
946 double mag2, var = 0.0, avr = 0.0, avi = 0.0;
947 int edge, j, k, n, edgemax;
949 for (
int i = 0;
i <
s->window_length;
i++) {
954 for (
int i =
s->window_length; i < s->fft_length2;
i++) {
963 edge =
s->noise_band_edge[0];
967 edgemax =
fmin(
s->fft_length2,
s->noise_band_edge[15]);
972 for (
int i = j;
i <= edgemax;
i++) {
973 if ((
i == j) && (
i < edgemax)) {
982 j =
s->noise_band_edge[k];
995 mag2 =
fmax(mag2,
s->sample_floor);
1010 double *sample_noise)
1012 for (
int i = 0;
i <
s->noise_band_count;
i++) {
1021 if (
s->noise_band_count < 15) {
1022 for (
int i =
s->noise_band_count;
i < 15;
i++)
1023 sample_noise[
i] = sample_noise[
i - 1];
1029 double *sample_noise,
1032 int new_band_noise[15];
1034 double sum = 0.0, d1;
1035 float new_noise_floor;
1038 for (
int m = 0; m < 15; m++)
1039 temp[m] = sample_noise[m];
1042 for (
int m = 0; m < 5; m++) {
1044 for (n = 0; n < 15; n++)
1045 sum +=
s->matrix_b[
i++] *
temp[n];
1046 s->vector_b[m] = sum;
1048 solve(
s->matrix_a,
s->vector_b, 5);
1050 for (
int m = 0; m < 15; m++) {
1052 for (n = 0; n < 5; n++)
1053 sum +=
s->matrix_c[
i++] *
s->vector_b[n];
1059 for (
int m = 0; m < 15; m++)
1062 d1 = (
int)(sum / 15.0 - 0.5);
1066 for (d1 -= dnch->
band_noise[7] -
i; d1 > -20.0; d1 -= 1.0)
1069 for (
int m = 0; m < 15; m++)
1072 new_noise_floor = d1 + 2.5;
1076 for (
int m = 0; m < 15; m++) {
1078 new_band_noise[m] =
av_clip(new_band_noise[m], -24, 24);
1082 memcpy(dnch->
band_noise, new_band_noise,
sizeof(new_band_noise));
1086 s->noise_floor = new_noise_floor;
1098 const int start = (in->
channels * jobnr) / nb_jobs;
1099 const int end = (in->
channels * (jobnr+1)) / nb_jobs;
1101 for (
int ch = start; ch < end; ch++) {
1106 if (
s->track_noise) {
1107 int i =
s->block_count & 0x1FF;
1116 for (
int m = 0; m <
s->window_length; m++) {
1117 dnch->
fft_in[m].
re =
s->window[m] *
src[m] * (1LL << 24);
1121 for (
int m =
s->window_length; m < s->fft_length2; m++) {
1137 for (
int m = 0; m <
s->window_length; m++)
1138 dst[m] +=
s->window[m] * dnch->
fft_in[m].
re / (1LL << 24);
1148 if (
s->noise_band_count > 0) {
1149 for (
int i = 0;
i <
s->noise_band_count;
i++) {
1152 if (
s->noise_band_count < 15) {
1153 for (
int i =
s->noise_band_count;
i < 15;
i++)
1154 levels[
i] = levels[
i - 1];
1157 for (
int i = 0;
i < 15;
i++) {
1168 const int output_mode =
ctx->is_disabled ?
IN_MODE :
s->output_mode;
1181 if (
s->track_noise) {
1182 for (
int ch = 0; ch <
inlink->channels; ch++) {
1190 if (
s->noise_floor !=
s->last_noise_floor)
1194 if (
s->sample_noise_start) {
1195 for (
int ch = 0; ch <
inlink->channels; ch++) {
1200 s->sample_noise_start = 0;
1201 s->sample_noise = 1;
1204 if (
s->sample_noise) {
1205 for (
int ch = 0; ch <
inlink->channels; ch++) {
1212 if (
s->sample_noise_end) {
1213 for (
int ch = 0; ch <
inlink->channels; ch++) {
1215 double sample_noise[15];
1221 s->sample_noise = 0;
1222 s->sample_noise_end = 0;
1236 for (
int ch = 0; ch <
inlink->channels; ch++) {
1239 float *orig = (
float *)in->extended_data[ch];
1240 float *dst = (
float *)
out->extended_data[ch];
1242 switch (output_mode) {
1244 for (
int m = 0; m <
s->sample_advance; m++)
1248 for (
int m = 0; m <
s->sample_advance; m++)
1252 for (
int m = 0; m <
s->sample_advance; m++)
1253 dst[m] = orig[m] -
src[m];
1260 memmove(
src,
src +
s->sample_advance, (
s->window_length -
s->sample_advance) *
sizeof(*
src));
1261 memset(
src + (
s->window_length -
s->sample_advance), 0,
s->sample_advance *
sizeof(*
src));
1324 for (
int ch = 0; ch <
s->channels; ch++) {
1351 char *res,
int res_len,
int flags)
1357 if (!strcmp(cmd,
"sample_noise") ||
1358 !strcmp(cmd,
"sn")) {
1359 if (!strcmp(args,
"start")) {
1360 s->sample_noise_start = 1;
1361 s->sample_noise_end = 0;
1362 }
else if (!strcmp(args,
"end") ||
1363 !strcmp(args,
"stop")) {
1364 s->sample_noise_start = 0;
1365 s->sample_noise_end = 1;
1399 .priv_class = &afftdn_class,
void av_audio_fifo_free(AVAudioFifo *af)
Free an AVAudioFifo.
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
static void set_noise_profile(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, double *sample_noise, int new_profile)
@ AV_SAMPLE_FMT_FLTP
float, planar
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
double noise_band_avr[15]
static void process_frame(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, AVComplexFloat *fft_data, double *prior, double *prior_band_excit, int track_noise)
static void calculate_sfm(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, int start, int end)
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.
static void sample_noise_block(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, AVFrame *in, int ch)
const char * name
Filter name.
A link between two filters.
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
int channels
Number of channels.
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...
static void factor(double *array, int size)
static int config_input(AVFilterLink *inlink)
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Context for an Audio FIFO Buffer.
int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples)
Drain data from an AVAudioFifo.
static double freq2bark(double x)
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.
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
static const AVOption afftdn_options[]
int channels
number of audio channels, only used for audio.
int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples)
Write data to an AVAudioFifo.
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().
@ AV_TX_FLOAT_FFT
Standard complex to complex FFT with sample data type AVComplexFloat.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static int output_frame(AVFilterLink *inlink)
float last_noise_reduction
#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.
double noise_band_auto_var[15]
Rational number (pair of numerator and denominator).
AVAudioFifo * av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, int nb_samples)
Allocate an AVAudioFifo.
static void get_auto_noise_levels(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, double *levels)
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)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static void postprocess(AVComplexFloat *in, int len)
static const AVFilterPad outputs[]
float fmaxf(float, float)
double fmin(double, double)
double noise_band_norm[15]
#define AV_NOPTS_VALUE
Undefined timestamp value.
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)
static double limit_gain(double a, double b)
int av_audio_fifo_size(AVAudioFifo *af)
Get the current number of samples in the AVAudioFifo available for reading.
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)
static int get_band_noise(AudioFFTDeNoiseContext *s, int band, double a, double b, double c)
#define i(width, name, range_min, range_max)
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)
Used for passing data between threads.
double noise_band_var[15]
const char * name
Pad name.
double noise_band_sample[15]
void * av_calloc(size_t nmemb, size_t size)
static double limit(double x)
static int array[MAX_W *MAX_W]
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
double fmax(double, double)
static void set_parameters(AudioFFTDeNoiseContext *s)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
#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)
FF_FILTER_FORWARD_STATUS(inlink, outlink)
#define FILTER_OUTPUTS(array)
#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.
float last_residual_floor
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the ff_outlink_frame_wanted() function. If this function returns true
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)
double noise_band_avi[15]
int av_audio_fifo_peek(AVAudioFifo *af, void **data, int nb_samples)
Peek data from an AVAudioFifo.
const AVFilter ff_af_afftdn
static void preprocess(AVComplexFloat *in, int len)
static int process_get_band_noise(AudioFFTDeNoiseContext *s, DeNoiseChannel *dnch, int band)