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
14191419 @item shift
14201420 Specify frequency shift. Allowed range is -INT_MAX to INT_MAX.
14211421 Default value is 0.0.
1422+
1423+@item level
1424+Set output gain applied to final output. Allowed range is from -1.0 to 1.0.
1425+Default value is 1.0.
14221426 @end table
14231427
14241428 @subsection Commands
14251429
1426−This filter supports the above option as @ref{commands}.
1430+This filter supports the all above options as @ref{commands}.
14271431
14281432 @section agate
14291433
@@ -2182,11 +2186,15 @@ The filter accepts the following options: · 752 unmodified lines
21822186 @item shift
21832187 Specify phase shift. Allowed range is from -1.0 to 1.0.
21842188 Default value is 0.0.
2189+
2190+@item level
2191+Set output gain applied to final output. Allowed range is from -1.0 to 1.0.
2192+Default value is 1.0.
21852193 @end table
21862194
21872195 @subsection Commands
21882196
2189−This filter supports the above option as @ref{commands}.
2197+This filter supports the all above options as @ref{commands}.
21902198
21912199 @section apulsator
21922200
libavfilter/af_afreqshift.c+9−4
@@ -32,6 +32,7 @@ typedef struct AFreqShift { · 31 unmodified lines
3232 const AVClass *class;
3333
3434 double shift;
35+ double level;
3536
3637 double c[NB_COEFS];
3738
@@ -85,7 +86,8 @@ static void pfilter_channel(AVFilterContext *ctx, · 47 unmodified lines
8586 double *i2, double *o2)
8687 {
8788 AFreqShift *s = ctx->priv;
88− double *c = s->c;
89+ const double *c = s->c;
90+ const double level = s->level;
8991 double shift = s->shift * M_PI;
9092 double cos_theta = cos(shift);
9193 double sin_theta = sin(shift);
@@ -113,7 +115,7 @@ static void pfilter_channel(AVFilterContext *ctx, · 21 unmodified lines
113115 }
114116 Q = o2[NB_COEFS - 1];
115117
116− dst[n] = I * cos_theta - Q * sin_theta;
118+ dst[n] = (I * cos_theta - Q * sin_theta) * level;
117119 }
118120 }
119121
@@ -125,7 +127,8 @@ static void ffilter_channel(AVFilterContext *ctx, · 5 unmodified lines
125127 double *i2, double *o2)
126128 {
127129 AFreqShift *s = ctx->priv;
128− double *c = s->c;
130+ const double *c = s->c;
131+ const double level = s->level;
129132 double ts = 1. / sample_rate;
130133 double shift = s->shift;
131134 int64_t N = s->in_samples;
@@ -154,7 +157,7 @@ static void ffilter_channel(AVFilterContext *ctx, · 22 unmodified lines
154157 Q = o2[NB_COEFS - 1];
155158
156159 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;
158161 }
159162 }
160163
@@ -345,6 +348,7 @@ static av_cold void uninit(AVFilterContext *ctx) · 184 unmodified lines
345348
346349 static const AVOption afreqshift_options[] = {
347350 { "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 },
348352 { NULL }
349353 };
350354
@@ -384,6 +388,7 @@ AVFilter ff_af_afreqshift = { · 33 unmodified lines
384388
385389 static const AVOption aphaseshift_options[] = {
386390 { "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 },
387392 { NULL }
388393 };
389394

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