Signed-off-by: Kyle Swanson <k@ylo.ph>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
... | ... |
@@ -72,7 +72,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) |
72 | 72 |
dst += channels; |
73 | 73 |
src += channels; |
74 | 74 |
s->index++; |
75 |
- if (s->index >= inlink->sample_rate) |
|
75 |
+ if (s->index >= inlink->sample_rate / s->freq) |
|
76 | 76 |
s->index = 0; |
77 | 77 |
} |
78 | 78 |
|
... | ... |
@@ -125,11 +125,11 @@ static int config_input(AVFilterLink *inlink) |
125 | 125 |
const double offset = 1. - s->depth / 2.; |
126 | 126 |
int i; |
127 | 127 |
|
128 |
- s->table = av_malloc_array(inlink->sample_rate, sizeof(*s->table)); |
|
128 |
+ s->table = av_malloc_array(inlink->sample_rate / s->freq, sizeof(*s->table)); |
|
129 | 129 |
if (!s->table) |
130 | 130 |
return AVERROR(ENOMEM); |
131 | 131 |
|
132 |
- for (i = 0; i < inlink->sample_rate; i++) { |
|
132 |
+ for (i = 0; i < inlink->sample_rate / s->freq; i++) { |
|
133 | 133 |
double env = s->freq * i / inlink->sample_rate; |
134 | 134 |
env = sin(2 * M_PI * fmod(env + 0.25, 1.0)); |
135 | 135 |
s->table[i] = env * (1 - fabs(offset)) + offset; |