History

avfilter/af_afreqshift: add level option

Paul B Mahol committed 5 years ago

Commit 530d1db1 parent 34773ee2 files · +19 −6Browse files

Unified · Split

2 files
  1. doc/filters.texi +10 −2
  2. libavfilter/af_afreqshift.c +9 −4
doc/filters.texi+10−2
@@ -1419,11 +1419,15 @@ The filter accepts the following options: · 1418 unmodified lines
1419@item shift1419@item shift
1420Specify frequency shift. Allowed range is -INT_MAX to INT_MAX.1420Specify frequency shift. Allowed range is -INT_MAX to INT_MAX.
1421Default value is 0.0.1421Default value is 0.0.
1422
1423@item level
1424Set output gain applied to final output. Allowed range is from -1.0 to 1.0.
1425Default value is 1.0.
1422@end table1426@end table
1423 1427
1424@subsection Commands1428@subsection Commands
1425 1429
1426This filter supports the above option as @ref{commands}.1430This filter supports the all above options as @ref{commands}.
1427 1431
1428@section agate1432@section agate
1429 1433
@@ -2182,11 +2186,15 @@ The filter accepts the following options: · 752 unmodified lines
2182@item shift2186@item shift
2183Specify phase shift. Allowed range is from -1.0 to 1.0.2187Specify phase shift. Allowed range is from -1.0 to 1.0.
2184Default value is 0.0.2188Default value is 0.0.
2189
2190@item level
2191Set output gain applied to final output. Allowed range is from -1.0 to 1.0.
2192Default value is 1.0.
2185@end table2193@end table
2186 2194
2187@subsection Commands2195@subsection Commands
2188 2196
2189This filter supports the above option as @ref{commands}.2197This filter supports the all above options as @ref{commands}.
2190 2198
2191@section apulsator2199@section apulsator
2192 2200
libavfilter/af_afreqshift.c+9−4
@@ -32,6 +32,7 @@ typedef struct AFreqShift { · 31 unmodified lines
32 const AVClass *class;32 const AVClass *class;
33 33
34 double shift;34 double shift;
35 double level;
35 36
36 double c[NB_COEFS];37 double c[NB_COEFS];
37 38
@@ -85,7 +86,8 @@ static void pfilter_channel(AVFilterContext *ctx, · 47 unmodified lines
85 double *i2, double *o2)86 double *i2, double *o2)
86{87{
87 AFreqShift *s = ctx->priv;88 AFreqShift *s = ctx->priv;
88 double *c = s->c;89 const double *c = s->c;
90 const double level = s->level;
89 double shift = s->shift * M_PI;91 double shift = s->shift * M_PI;
90 double cos_theta = cos(shift);92 double cos_theta = cos(shift);
91 double sin_theta = sin(shift);93 double sin_theta = sin(shift);
@@ -113,7 +115,7 @@ static void pfilter_channel(AVFilterContext *ctx, · 21 unmodified lines
113 }115 }
114 Q = o2[NB_COEFS - 1];116 Q = o2[NB_COEFS - 1];
115 117
116 dst[n] = I * cos_theta - Q * sin_theta;118 dst[n] = (I * cos_theta - Q * sin_theta) * level;
117 }119 }
118}120}
119 121
@@ -125,7 +127,8 @@ static void ffilter_channel(AVFilterContext *ctx, · 5 unmodified lines
125 double *i2, double *o2)127 double *i2, double *o2)
126{128{
127 AFreqShift *s = ctx->priv;129 AFreqShift *s = ctx->priv;
128 double *c = s->c;130 const double *c = s->c;
131 const double level = s->level;
129 double ts = 1. / sample_rate;132 double ts = 1. / sample_rate;
130 double shift = s->shift;133 double shift = s->shift;
131 int64_t N = s->in_samples;134 int64_t N = s->in_samples;
@@ -154,7 +157,7 @@ static void ffilter_channel(AVFilterContext *ctx, · 22 unmodified lines
154 Q = o2[NB_COEFS - 1];157 Q = o2[NB_COEFS - 1];
155 158
156 theta = 2. * M_PI * fmod(shift * (N + n) * ts, 1.);159 theta = 2. * M_PI * fmod(shift * (N + n) * ts, 1.);
157 dst[n] = I * cos(theta) - Q * sin(theta);160 dst[n] = (I * cos(theta) - Q * sin(theta)) * level;
158 }161 }
159}162}
160 163
@@ -345,6 +348,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 184 unmodified lines
345 348
346static const AVOption afreqshift_options[] = {349static const AVOption afreqshift_options[] = {
347 { "shift", "set frequency shift", OFFSET(shift), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -INT_MAX, INT_MAX, FLAGS },350 { "shift", "set frequency shift", OFFSET(shift), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -INT_MAX, INT_MAX, FLAGS },
351 { "level", "set output level", OFFSET(level), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.0, 1.0, FLAGS },
348 { NULL }352 { NULL }
349};353};
350 354
@@ -384,6 +388,7 @@ AVFilter ff_af_afreqshift = { · 33 unmodified lines
384 388
385static const AVOption aphaseshift_options[] = {389static const AVOption aphaseshift_options[] = {
386 { "shift", "set phase shift", OFFSET(shift), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -1.0, 1.0, FLAGS },390 { "shift", "set phase shift", OFFSET(shift), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -1.0, 1.0, FLAGS },
391 { "level", "set output level",OFFSET(level), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0.0, 1.0, FLAGS },
387 { NULL }392 { NULL }
388};393};
389 394

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