History

avfilter/avf_showcwt: add sqrt frequency scale

Paul B Mahol committed 3 years ago

Commit 7f23b721 parent 73570122 files · +11 −0Browse files

Showing the changes to libavfilter (1 of 2 files). Show all

Unified · Split

libavfilter/avf_showcwt.c+10−0
@@ -40,6 +40,7 @@ enum FrequencyScale { · 39 unmodified lines
4040 FSCALE_BARK,
4141 FSCALE_MEL,
4242 FSCALE_ERBS,
43+ FSCALE_SQRT,
4344 NB_FSCALE
4445 };
4546
@@ -127,6 +128,7 @@ static const AVOption showcwt_options[] = { · 81 unmodified lines
127128 { "bark", "bark", 0, AV_OPT_TYPE_CONST,{.i64=FSCALE_BARK}, 0, 0, FLAGS, "scale" },
128129 { "mel", "mel", 0, AV_OPT_TYPE_CONST,{.i64=FSCALE_MEL}, 0, 0, FLAGS, "scale" },
129130 { "erbs", "erbs", 0, AV_OPT_TYPE_CONST,{.i64=FSCALE_ERBS}, 0, 0, FLAGS, "scale" },
131+ { "sqrt", "sqrt", 0, AV_OPT_TYPE_CONST,{.i64=FSCALE_SQRT}, 0, 0, FLAGS, "scale" },
130132 { "min", "set minimum frequency", OFFSET(minimum_frequency), AV_OPT_TYPE_FLOAT, {.dbl = 20.}, 1, 2000, FLAGS },
131133 { "max", "set maximum frequency", OFFSET(maximum_frequency), AV_OPT_TYPE_FLOAT, {.dbl = 20000.}, 0, 192000, FLAGS },
132134 { "logb", "set logarithmic basis", OFFSET(logarithmic_basis), AV_OPT_TYPE_FLOAT, {.dbl = 0.0001}, 0, 1, FLAGS },
@@ -241,6 +243,10 @@ static void frequency_band(float *frequency_band, · 108 unmodified lines
241243 frequency = 676170.4f / (47.06538f - expf(frequency * 0.08950404f)) - 14678.49f;
242244 frequency_derivative *= (frequency * frequency + 14990.4 * frequency + 4577850.f) / 160514.f;
243245 break;
246+ case FSCALE_SQRT:
247+ frequency = frequency * frequency;
248+ frequency_derivative *= 2.f * sqrtf(frequency);
249+ break;
244250 }
245251
246252 frequency_band[y*2 ] = frequency;
@@ -680,6 +686,10 @@ static int config_output(AVFilterLink *outlink) · 433 unmodified lines
680686 minimum_frequency = 11.17268f * log(1.f + (46.06538f * minimum_frequency) / (minimum_frequency + 14678.49f));
681687 maximum_frequency = 11.17268f * log(1.f + (46.06538f * maximum_frequency) / (maximum_frequency + 14678.49f));
682688 break;
689+ case FSCALE_SQRT:
690+ minimum_frequency = sqrtf(minimum_frequency);
691+ maximum_frequency = sqrtf(maximum_frequency);
692+ break;
683693 }
684694
685695 frequency_band(s->frequency_band,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t