Showing the changes to libavfilter (1 of 2 files). Show all
Unified · Split
| @@ -32,6 +32,7 @@ typedef struct AFreqShift { · 31 unmodified lines | ||
| 32 | 32 | const AVClass *class; |
| 33 | 33 | |
| 34 | 34 | double shift; |
| 35 | + double level; | |
| 35 | 36 | |
| 36 | 37 | double c[NB_COEFS]; |
| 37 | 38 | |
| @@ -85,7 +86,8 @@ static void pfilter_channel(AVFilterContext *ctx, · 47 unmodified lines | ||
| 85 | 86 | double *i2, double *o2) |
| 86 | 87 | { |
| 87 | 88 | AFreqShift *s = ctx->priv; |
| 88 | − double *c = s->c; | |
| 89 | + const double *c = s->c; | |
| 90 | + const double level = s->level; | |
| 89 | 91 | double shift = s->shift * M_PI; |
| 90 | 92 | double cos_theta = cos(shift); |
| 91 | 93 | double sin_theta = sin(shift); |
| @@ -113,7 +115,7 @@ static void pfilter_channel(AVFilterContext *ctx, · 21 unmodified lines | ||
| 113 | 115 | } |
| 114 | 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 | 127 | double *i2, double *o2) |
| 126 | 128 | { |
| 127 | 129 | AFreqShift *s = ctx->priv; |
| 128 | − double *c = s->c; | |
| 130 | + const double *c = s->c; | |
| 131 | + const double level = s->level; | |
| 129 | 132 | double ts = 1. / sample_rate; |
| 130 | 133 | double shift = s->shift; |
| 131 | 134 | int64_t N = s->in_samples; |
| @@ -154,7 +157,7 @@ static void ffilter_channel(AVFilterContext *ctx, · 22 unmodified lines | ||
| 154 | 157 | Q = o2[NB_COEFS - 1]; |
| 155 | 158 | |
| 156 | 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 | |
| 346 | 349 | static const AVOption afreqshift_options[] = { |
| 347 | 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 | 352 | { NULL } |
| 349 | 353 | }; |
| 350 | 354 | |
| @@ -384,6 +388,7 @@ AVFilter ff_af_afreqshift = { · 33 unmodified lines | ||
| 384 | 388 | |
| 385 | 389 | static const AVOption aphaseshift_options[] = { |
| 386 | 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 | 392 | { NULL } |
| 388 | 393 | }; |
| 389 | 394 | |