History

avfilter/af_afreqshift: add level option

Paul B Mahol committed 5 years ago

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

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

Unified · Split

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