History

avfilter/avf_showcwt: add fm frequency scaler

Paul B Mahol committed 3 years ago

Commit 49719d31 parent 409b29d2 files · +13 −1Browse files

Unified · Split

2 files
  1. doc/filters.texi +1 −0
  2. libavfilter/avf_showcwt.c +12 −1
doc/filters.texi+1−0
@@ -30842,6 +30842,7 @@ Set the frequency scale used. Allowed values are: · 30841 unmodified lines
3084230842 @item sqrt
3084330843 @item cbrt
3084430844 @item qdrt
30845+@item fm
3084530846 @end table
3084630847 Default value is @code{linear}.
3084730848
libavfilter/avf_showcwt.c+12−1
@@ -45,6 +45,7 @@ enum FrequencyScale { · 44 unmodified lines
4545 FSCALE_SQRT,
4646 FSCALE_CBRT,
4747 FSCALE_QDRT,
48+ FSCALE_FM,
4849 NB_FSCALE
4950 };
5051
@@ -144,6 +145,7 @@ static const AVOption showcwt_options[] = { · 93 unmodified lines
144145 { "sqrt", "sqrt", 0, AV_OPT_TYPE_CONST,{.i64=FSCALE_SQRT}, 0, 0, FLAGS, "scale" },
145146 { "cbrt", "cbrt", 0, AV_OPT_TYPE_CONST,{.i64=FSCALE_CBRT}, 0, 0, FLAGS, "scale" },
146147 { "qdrt", "qdrt", 0, AV_OPT_TYPE_CONST,{.i64=FSCALE_QDRT}, 0, 0, FLAGS, "scale" },
148+ { "fm", "fm", 0, AV_OPT_TYPE_CONST,{.i64=FSCALE_FM}, 0, 0, FLAGS, "scale" },
147149 { "iscale", "set intensity scale", OFFSET(intensity_scale),AV_OPT_TYPE_INT, {.i64=0}, 0, NB_ISCALE-1, FLAGS, "iscale" },
148150 { "linear", "linear", 0, AV_OPT_TYPE_CONST,{.i64=ISCALE_LINEAR}, 0, 0, FLAGS, "iscale" },
149151 { "log", "logarithmic", 0, AV_OPT_TYPE_CONST,{.i64=ISCALE_LOG}, 0, 0, FLAGS, "iscale" },
@@ -292,6 +294,10 @@ static float frequency_band(float *frequency_band, · 142 unmodified lines
292294 frequency = frequency * frequency * frequency * frequency;
293295 frequency_derivative *= 4.f * powf(frequency, 3.f / 4.f);
294296 break;
297+ case FSCALE_FM:
298+ frequency = 2.f * powf(frequency, 3.f / 2.f) / 3.f;
299+ frequency_derivative *= sqrtf(frequency);
300+ break;
295301 }
296302
297303 frequency_band[y*2 ] = frequency;
@@ -788,7 +794,8 @@ static int config_output(AVFilterLink *outlink) · 490 unmodified lines
788794 AVFilterContext *ctx = outlink->src;
789795 AVFilterLink *inlink = ctx->inputs[0];
790796 ShowCWTContext *s = ctx->priv;
791− float maximum_frequency = fminf(s->maximum_frequency, inlink->sample_rate * 0.5f);
797+ const float limit_frequency = inlink->sample_rate * 0.5f;
798+ float maximum_frequency = fminf(s->maximum_frequency, limit_frequency);
792799 float minimum_frequency = s->minimum_frequency;
793800 float scale = 1.f, factor;
794801 int ret;
@@ -847,6 +854,10 @@ static int config_output(AVFilterLink *outlink) · 52 unmodified lines
847854 minimum_frequency = powf(minimum_frequency, 0.25f);
848855 maximum_frequency = powf(maximum_frequency, 0.25f);
849856 break;
857+ case FSCALE_FM:
858+ minimum_frequency = powf(9.f * (minimum_frequency * minimum_frequency) / 4.f, 1.f / 3.f);
859+ maximum_frequency = powf(9.f * (maximum_frequency * maximum_frequency) / 4.f, 1.f / 3.f);
860+ break;
850861 }
851862
852863 s->frequency_band = av_calloc(s->frequency_band_count,

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