42 int64_t start,
int range,
int curve);
47 #define OFFSET(x) offsetof(AudioFadeContext, x)
48 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
55 {
"start_sample",
"set expression of sample to start fading",
OFFSET(start_sample),
AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX,
FLAGS },
85 afade->
class = &afade_class;
131 gain =
FFMAX(0.0,
FFMIN(1.0, 1.0 * index / range));
135 gain = sin(gain *
M_PI / 2.0);
138 gain = 1.0 - cos(
M_PI / 4.0 * (pow(2.0*gain - 1, 3) + 1));
141 gain = (1.0 - cos(gain *
M_PI)) / 2.0;
144 gain = pow(0.1, (1 - gain) * 5.0);
147 gain = (1 - (1 - gain) * (1 - gain));
153 gain = gain * gain * gain;
166 #define FADE_PLANAR(name, type) \
167 static void fade_samples_## name ##p(uint8_t **dst, uint8_t * const *src, \
168 int nb_samples, int channels, int dir, \
169 int64_t start, int range, int curve) \
173 for (i = 0; i < nb_samples; i++) { \
174 double gain = fade_gain(curve, start + i * dir, range); \
175 for (c = 0; c < channels; c++) { \
176 type *d = (type *)dst[c]; \
177 const type *s = (type *)src[c]; \
179 d[i] = s[i] * gain; \
184 #define FADE(name, type) \
185 static void fade_samples_## name (uint8_t **dst, uint8_t * const *src, \
186 int nb_samples, int channels, int dir, \
187 int64_t start, int range, int curve) \
189 type *d = (type *)dst[0]; \
190 const type *s = (type *)src[0]; \
193 for (i = 0; i < nb_samples; i++) { \
194 double gain = fade_gain(curve, start + i * dir, range); \
195 for (c = 0; c < channels; c++, k++) \
196 d[k] = s[k] * gain; \
243 if ((!afade->type && (afade->start_sample + afade->nb_samples < cur_sample)) ||
244 ( afade->type && (cur_sample + afade->nb_samples < afade->start_sample)))
253 out_buf->pts = buf->pts;
256 if ((!afade->type && (cur_sample + nb_samples < afade->start_sample)) ||
257 ( afade->type && (afade->start_sample + afade->nb_samples < cur_sample))) {
259 out_buf->audio->channels, out_buf->format);
264 start = cur_sample - afade->start_sample;
266 start = afade->start_sample + afade->nb_samples - cur_sample;
268 afade->fade_samples(out_buf->extended_data, buf->extended_data,
270 afade->type ? -1 : 1, start,
271 afade->nb_samples, afade->curve);
304 .
inputs = avfilter_af_afade_inputs,
305 .
outputs = avfilter_af_afade_outputs,
306 .priv_class = &afade_class,