2013-01-17 21:53:27 +00:00
|
|
|
/*
|
2015-07-23 22:13:17 +00:00
|
|
|
* Copyright (c) 2013-2015 Paul B Mahol
|
2013-01-17 21:53:27 +00:00
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* fade audio filter
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libavutil/opt.h"
|
|
|
|
#include "audio.h"
|
|
|
|
#include "avfilter.h"
|
2018-01-18 10:17:03 +00:00
|
|
|
#include "filters.h"
|
2013-01-17 21:53:27 +00:00
|
|
|
#include "internal.h"
|
|
|
|
|
2017-05-12 18:00:49 +00:00
|
|
|
typedef struct AudioFadeContext {
|
2013-01-17 21:53:27 +00:00
|
|
|
const AVClass *class;
|
|
|
|
int type;
|
2015-07-23 22:13:17 +00:00
|
|
|
int curve, curve2;
|
2017-05-17 20:59:11 +00:00
|
|
|
int64_t nb_samples;
|
2013-01-17 21:53:27 +00:00
|
|
|
int64_t start_sample;
|
2013-04-19 00:50:23 +00:00
|
|
|
int64_t duration;
|
|
|
|
int64_t start_time;
|
2015-07-23 22:13:17 +00:00
|
|
|
int overlap;
|
|
|
|
int cf0_eof;
|
|
|
|
int crossfade_is_over;
|
|
|
|
int64_t pts;
|
2013-01-17 21:53:27 +00:00
|
|
|
|
|
|
|
void (*fade_samples)(uint8_t **dst, uint8_t * const *src,
|
|
|
|
int nb_samples, int channels, int direction,
|
2017-05-17 20:59:11 +00:00
|
|
|
int64_t start, int64_t range, int curve);
|
2015-07-23 22:13:17 +00:00
|
|
|
void (*crossfade_samples)(uint8_t **dst, uint8_t * const *cf0,
|
|
|
|
uint8_t * const *cf1,
|
|
|
|
int nb_samples, int channels,
|
|
|
|
int curve0, int curve1);
|
2013-01-17 21:53:27 +00:00
|
|
|
} AudioFadeContext;
|
|
|
|
|
2020-11-18 10:10:39 +00:00
|
|
|
enum CurveType { NONE = -1, TRI, QSIN, ESIN, HSIN, LOG, IPAR, QUA, CUB, SQU, CBR, PAR, EXP, IQSIN, IHSIN, DESE, DESI, LOSI, SINC, ISINC, NB_CURVES };
|
2013-01-17 21:53:27 +00:00
|
|
|
|
|
|
|
#define OFFSET(x) offsetof(AudioFadeContext, x)
|
|
|
|
#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
|
2020-12-11 21:56:22 +00:00
|
|
|
#define TFLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
|
2013-01-17 21:53:27 +00:00
|
|
|
|
|
|
|
static int query_formats(AVFilterContext *ctx)
|
|
|
|
{
|
|
|
|
static const enum AVSampleFormat sample_fmts[] = {
|
|
|
|
AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16P,
|
|
|
|
AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32P,
|
|
|
|
AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP,
|
|
|
|
AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBLP,
|
|
|
|
AV_SAMPLE_FMT_NONE
|
|
|
|
};
|
2021-08-09 23:25:31 +00:00
|
|
|
int ret = ff_set_common_all_channel_counts(ctx);
|
2015-04-03 17:55:18 +00:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2013-01-17 21:53:27 +00:00
|
|
|
|
2021-08-09 23:25:31 +00:00
|
|
|
ret = ff_set_common_formats_from_list(ctx, sample_fmts);
|
2015-04-03 17:55:18 +00:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2013-01-17 21:53:27 +00:00
|
|
|
|
2021-08-09 23:25:31 +00:00
|
|
|
return ff_set_common_all_samplerates(ctx);
|
2013-01-17 21:53:27 +00:00
|
|
|
}
|
|
|
|
|
2017-05-17 20:59:11 +00:00
|
|
|
static double fade_gain(int curve, int64_t index, int64_t range)
|
2013-01-17 21:53:27 +00:00
|
|
|
{
|
2015-11-25 03:56:28 +00:00
|
|
|
#define CUBE(a) ((a)*(a)*(a))
|
2013-01-17 21:53:27 +00:00
|
|
|
double gain;
|
|
|
|
|
2015-06-14 17:08:43 +00:00
|
|
|
gain = av_clipd(1.0 * index / range, 0, 1.0);
|
2013-01-17 21:53:27 +00:00
|
|
|
|
|
|
|
switch (curve) {
|
|
|
|
case QSIN:
|
|
|
|
gain = sin(gain * M_PI / 2.0);
|
|
|
|
break;
|
2015-06-14 20:24:18 +00:00
|
|
|
case IQSIN:
|
2015-11-25 03:56:28 +00:00
|
|
|
/* 0.6... = 2 / M_PI */
|
|
|
|
gain = 0.6366197723675814 * asin(gain);
|
2015-06-14 20:24:18 +00:00
|
|
|
break;
|
2013-01-17 21:53:27 +00:00
|
|
|
case ESIN:
|
2015-11-25 03:56:28 +00:00
|
|
|
gain = 1.0 - cos(M_PI / 4.0 * (CUBE(2.0*gain - 1) + 1));
|
2013-01-17 21:53:27 +00:00
|
|
|
break;
|
|
|
|
case HSIN:
|
|
|
|
gain = (1.0 - cos(gain * M_PI)) / 2.0;
|
|
|
|
break;
|
2015-06-14 20:24:18 +00:00
|
|
|
case IHSIN:
|
2015-11-25 03:56:28 +00:00
|
|
|
/* 0.3... = 1 / M_PI */
|
|
|
|
gain = 0.3183098861837907 * acos(1 - 2 * gain);
|
2015-06-14 20:24:18 +00:00
|
|
|
break;
|
|
|
|
case EXP:
|
2015-11-25 03:56:28 +00:00
|
|
|
/* -11.5... = 5*ln(0.1) */
|
|
|
|
gain = exp(-11.512925464970227 * (1 - gain));
|
2013-01-17 21:53:27 +00:00
|
|
|
break;
|
2015-06-14 20:24:18 +00:00
|
|
|
case LOG:
|
2015-11-25 03:56:28 +00:00
|
|
|
gain = av_clipd(1 + 0.2 * log10(gain), 0, 1.0);
|
2015-06-14 20:24:18 +00:00
|
|
|
break;
|
2013-01-17 21:53:27 +00:00
|
|
|
case PAR:
|
2015-06-14 20:24:18 +00:00
|
|
|
gain = 1 - sqrt(1 - gain);
|
|
|
|
break;
|
|
|
|
case IPAR:
|
2013-01-17 21:53:27 +00:00
|
|
|
gain = (1 - (1 - gain) * (1 - gain));
|
|
|
|
break;
|
|
|
|
case QUA:
|
|
|
|
gain *= gain;
|
|
|
|
break;
|
|
|
|
case CUB:
|
2015-11-25 03:56:28 +00:00
|
|
|
gain = CUBE(gain);
|
2013-01-17 21:53:27 +00:00
|
|
|
break;
|
|
|
|
case SQU:
|
|
|
|
gain = sqrt(gain);
|
|
|
|
break;
|
|
|
|
case CBR:
|
|
|
|
gain = cbrt(gain);
|
|
|
|
break;
|
2015-06-14 20:24:18 +00:00
|
|
|
case DESE:
|
2015-11-25 03:56:28 +00:00
|
|
|
gain = gain <= 0.5 ? cbrt(2 * gain) / 2: 1 - cbrt(2 * (1 - gain)) / 2;
|
2015-06-14 20:24:18 +00:00
|
|
|
break;
|
|
|
|
case DESI:
|
2015-11-25 03:56:28 +00:00
|
|
|
gain = gain <= 0.5 ? CUBE(2 * gain) / 2: 1 - CUBE(2 * (1 - gain)) / 2;
|
2015-06-14 20:24:18 +00:00
|
|
|
break;
|
2018-10-07 15:38:22 +00:00
|
|
|
case LOSI: {
|
|
|
|
const double a = 1. / (1. - 0.787) - 1;
|
|
|
|
double A = 1. / (1.0 + exp(0 -((gain-0.5) * a * 2.0)));
|
|
|
|
double B = 1. / (1.0 + exp(a));
|
|
|
|
double C = 1. / (1.0 + exp(0-a));
|
|
|
|
gain = (A - B) / (C - B);
|
|
|
|
}
|
|
|
|
break;
|
2020-11-18 10:10:39 +00:00
|
|
|
case SINC:
|
|
|
|
gain = gain >= 1.0 ? 1.0 : sin(M_PI * (1.0 - gain)) / (M_PI * (1.0 - gain));
|
|
|
|
break;
|
|
|
|
case ISINC:
|
|
|
|
gain = gain <= 0.0 ? 0.0 : 1.0 - sin(M_PI * gain) / (M_PI * gain);
|
|
|
|
break;
|
2019-01-23 08:05:23 +00:00
|
|
|
case NONE:
|
|
|
|
gain = 1.0;
|
|
|
|
break;
|
2013-01-17 21:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return gain;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define FADE_PLANAR(name, type) \
|
|
|
|
static void fade_samples_## name ##p(uint8_t **dst, uint8_t * const *src, \
|
|
|
|
int nb_samples, int channels, int dir, \
|
2017-05-17 20:59:11 +00:00
|
|
|
int64_t start, int64_t range, int curve) \
|
2013-01-17 21:53:27 +00:00
|
|
|
{ \
|
|
|
|
int i, c; \
|
|
|
|
\
|
|
|
|
for (i = 0; i < nb_samples; i++) { \
|
|
|
|
double gain = fade_gain(curve, start + i * dir, range); \
|
|
|
|
for (c = 0; c < channels; c++) { \
|
|
|
|
type *d = (type *)dst[c]; \
|
|
|
|
const type *s = (type *)src[c]; \
|
|
|
|
\
|
|
|
|
d[i] = s[i] * gain; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define FADE(name, type) \
|
|
|
|
static void fade_samples_## name (uint8_t **dst, uint8_t * const *src, \
|
|
|
|
int nb_samples, int channels, int dir, \
|
2017-05-17 20:59:11 +00:00
|
|
|
int64_t start, int64_t range, int curve) \
|
2013-01-17 21:53:27 +00:00
|
|
|
{ \
|
|
|
|
type *d = (type *)dst[0]; \
|
|
|
|
const type *s = (type *)src[0]; \
|
|
|
|
int i, c, k = 0; \
|
|
|
|
\
|
|
|
|
for (i = 0; i < nb_samples; i++) { \
|
|
|
|
double gain = fade_gain(curve, start + i * dir, range); \
|
|
|
|
for (c = 0; c < channels; c++, k++) \
|
|
|
|
d[k] = s[k] * gain; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
FADE_PLANAR(dbl, double)
|
|
|
|
FADE_PLANAR(flt, float)
|
|
|
|
FADE_PLANAR(s16, int16_t)
|
|
|
|
FADE_PLANAR(s32, int32_t)
|
|
|
|
|
|
|
|
FADE(dbl, double)
|
|
|
|
FADE(flt, float)
|
|
|
|
FADE(s16, int16_t)
|
|
|
|
FADE(s32, int32_t)
|
|
|
|
|
2015-07-23 22:13:17 +00:00
|
|
|
static int config_output(AVFilterLink *outlink)
|
2013-01-17 21:53:27 +00:00
|
|
|
{
|
2015-07-23 22:13:17 +00:00
|
|
|
AVFilterContext *ctx = outlink->src;
|
2013-10-02 11:09:06 +00:00
|
|
|
AudioFadeContext *s = ctx->priv;
|
2013-01-17 21:53:27 +00:00
|
|
|
|
2015-07-23 22:13:17 +00:00
|
|
|
switch (outlink->format) {
|
2013-10-02 11:09:06 +00:00
|
|
|
case AV_SAMPLE_FMT_DBL: s->fade_samples = fade_samples_dbl; break;
|
|
|
|
case AV_SAMPLE_FMT_DBLP: s->fade_samples = fade_samples_dblp; break;
|
|
|
|
case AV_SAMPLE_FMT_FLT: s->fade_samples = fade_samples_flt; break;
|
|
|
|
case AV_SAMPLE_FMT_FLTP: s->fade_samples = fade_samples_fltp; break;
|
|
|
|
case AV_SAMPLE_FMT_S16: s->fade_samples = fade_samples_s16; break;
|
|
|
|
case AV_SAMPLE_FMT_S16P: s->fade_samples = fade_samples_s16p; break;
|
|
|
|
case AV_SAMPLE_FMT_S32: s->fade_samples = fade_samples_s32; break;
|
|
|
|
case AV_SAMPLE_FMT_S32P: s->fade_samples = fade_samples_s32p; break;
|
2013-01-17 21:53:27 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 11:09:06 +00:00
|
|
|
if (s->duration)
|
2015-07-23 22:13:17 +00:00
|
|
|
s->nb_samples = av_rescale(s->duration, outlink->sample_rate, AV_TIME_BASE);
|
2020-12-11 21:56:22 +00:00
|
|
|
s->duration = 0;
|
2013-10-02 11:09:06 +00:00
|
|
|
if (s->start_time)
|
2015-07-23 22:13:17 +00:00
|
|
|
s->start_sample = av_rescale(s->start_time, outlink->sample_rate, AV_TIME_BASE);
|
2020-12-11 21:56:22 +00:00
|
|
|
s->start_time = 0;
|
2015-07-23 22:13:17 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if CONFIG_AFADE_FILTER
|
|
|
|
|
|
|
|
static const AVOption afade_options[] = {
|
2020-12-11 21:56:22 +00:00
|
|
|
{ "type", "set the fade direction", OFFSET(type), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, TFLAGS, "type" },
|
|
|
|
{ "t", "set the fade direction", OFFSET(type), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, TFLAGS, "type" },
|
|
|
|
{ "in", "fade-in", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, TFLAGS, "type" },
|
|
|
|
{ "out", "fade-out", 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, TFLAGS, "type" },
|
|
|
|
{ "start_sample", "set number of first sample to start fading", OFFSET(start_sample), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, TFLAGS },
|
|
|
|
{ "ss", "set number of first sample to start fading", OFFSET(start_sample), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, INT64_MAX, TFLAGS },
|
|
|
|
{ "nb_samples", "set number of samples for fade duration", OFFSET(nb_samples), AV_OPT_TYPE_INT64, {.i64 = 44100}, 1, INT64_MAX, TFLAGS },
|
|
|
|
{ "ns", "set number of samples for fade duration", OFFSET(nb_samples), AV_OPT_TYPE_INT64, {.i64 = 44100}, 1, INT64_MAX, TFLAGS },
|
2021-02-21 12:38:14 +00:00
|
|
|
{ "start_time", "set time to start fading", OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0 }, 0, INT64_MAX, TFLAGS },
|
|
|
|
{ "st", "set time to start fading", OFFSET(start_time), AV_OPT_TYPE_DURATION, {.i64 = 0 }, 0, INT64_MAX, TFLAGS },
|
|
|
|
{ "duration", "set fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0 }, 0, INT64_MAX, TFLAGS },
|
|
|
|
{ "d", "set fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0 }, 0, INT64_MAX, TFLAGS },
|
2020-12-11 21:56:22 +00:00
|
|
|
{ "curve", "set fade curve type", OFFSET(curve), AV_OPT_TYPE_INT, {.i64 = TRI }, NONE, NB_CURVES - 1, TFLAGS, "curve" },
|
|
|
|
{ "c", "set fade curve type", OFFSET(curve), AV_OPT_TYPE_INT, {.i64 = TRI }, NONE, NB_CURVES - 1, TFLAGS, "curve" },
|
|
|
|
{ "nofade", "no fade; keep audio as-is", 0, AV_OPT_TYPE_CONST, {.i64 = NONE }, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "tri", "linear slope", 0, AV_OPT_TYPE_CONST, {.i64 = TRI }, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "qsin", "quarter of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = QSIN }, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "esin", "exponential sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = ESIN }, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "hsin", "half of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = HSIN }, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64 = LOG }, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "ipar", "inverted parabola", 0, AV_OPT_TYPE_CONST, {.i64 = IPAR }, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "qua", "quadratic", 0, AV_OPT_TYPE_CONST, {.i64 = QUA }, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "cub", "cubic", 0, AV_OPT_TYPE_CONST, {.i64 = CUB }, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "squ", "square root", 0, AV_OPT_TYPE_CONST, {.i64 = SQU }, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "cbr", "cubic root", 0, AV_OPT_TYPE_CONST, {.i64 = CBR }, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "par", "parabola", 0, AV_OPT_TYPE_CONST, {.i64 = PAR }, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "exp", "exponential", 0, AV_OPT_TYPE_CONST, {.i64 = EXP }, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "iqsin", "inverted quarter of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = IQSIN}, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "ihsin", "inverted half of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = IHSIN}, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "dese", "double-exponential seat", 0, AV_OPT_TYPE_CONST, {.i64 = DESE }, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "desi", "double-exponential sigmoid", 0, AV_OPT_TYPE_CONST, {.i64 = DESI }, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "losi", "logistic sigmoid", 0, AV_OPT_TYPE_CONST, {.i64 = LOSI }, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "sinc", "sine cardinal function", 0, AV_OPT_TYPE_CONST, {.i64 = SINC }, 0, 0, TFLAGS, "curve" },
|
|
|
|
{ "isinc", "inverted sine cardinal function", 0, AV_OPT_TYPE_CONST, {.i64 = ISINC}, 0, 0, TFLAGS, "curve" },
|
2015-07-23 22:13:17 +00:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
AVFILTER_DEFINE_CLASS(afade);
|
|
|
|
|
|
|
|
static av_cold int init(AVFilterContext *ctx)
|
|
|
|
{
|
|
|
|
AudioFadeContext *s = ctx->priv;
|
|
|
|
|
|
|
|
if (INT64_MAX - s->nb_samples < s->start_sample)
|
|
|
|
return AVERROR(EINVAL);
|
2013-01-17 21:53:27 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-10 00:30:30 +00:00
|
|
|
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
|
2013-01-17 21:53:27 +00:00
|
|
|
{
|
2013-10-02 11:09:06 +00:00
|
|
|
AudioFadeContext *s = inlink->dst->priv;
|
2013-01-17 21:53:27 +00:00
|
|
|
AVFilterLink *outlink = inlink->dst->outputs[0];
|
2013-03-10 00:30:30 +00:00
|
|
|
int nb_samples = buf->nb_samples;
|
|
|
|
AVFrame *out_buf;
|
2014-10-21 09:43:56 +00:00
|
|
|
int64_t cur_sample = av_rescale_q(buf->pts, inlink->time_base, (AVRational){1, inlink->sample_rate});
|
2013-01-17 21:53:27 +00:00
|
|
|
|
2013-10-02 11:09:06 +00:00
|
|
|
if ((!s->type && (s->start_sample + s->nb_samples < cur_sample)) ||
|
2015-10-08 20:26:20 +00:00
|
|
|
( s->type && (cur_sample + nb_samples < s->start_sample)))
|
2013-01-17 21:53:27 +00:00
|
|
|
return ff_filter_frame(outlink, buf);
|
|
|
|
|
2013-03-10 00:30:30 +00:00
|
|
|
if (av_frame_is_writable(buf)) {
|
2013-01-17 21:53:27 +00:00
|
|
|
out_buf = buf;
|
|
|
|
} else {
|
2018-01-03 21:47:40 +00:00
|
|
|
out_buf = ff_get_audio_buffer(outlink, nb_samples);
|
2013-01-17 21:53:27 +00:00
|
|
|
if (!out_buf)
|
|
|
|
return AVERROR(ENOMEM);
|
2013-04-03 11:10:00 +00:00
|
|
|
av_frame_copy_props(out_buf, buf);
|
2013-01-17 21:53:27 +00:00
|
|
|
}
|
|
|
|
|
2013-10-02 11:09:06 +00:00
|
|
|
if ((!s->type && (cur_sample + nb_samples < s->start_sample)) ||
|
|
|
|
( s->type && (s->start_sample + s->nb_samples < cur_sample))) {
|
2013-01-17 21:53:27 +00:00
|
|
|
av_samples_set_silence(out_buf->extended_data, 0, nb_samples,
|
2017-04-22 08:57:18 +00:00
|
|
|
out_buf->channels, out_buf->format);
|
2013-01-17 21:53:27 +00:00
|
|
|
} else {
|
|
|
|
int64_t start;
|
|
|
|
|
2013-10-02 11:09:06 +00:00
|
|
|
if (!s->type)
|
|
|
|
start = cur_sample - s->start_sample;
|
2013-01-17 21:53:27 +00:00
|
|
|
else
|
2013-10-02 11:09:06 +00:00
|
|
|
start = s->start_sample + s->nb_samples - cur_sample;
|
2013-01-17 21:53:27 +00:00
|
|
|
|
2013-10-02 11:09:06 +00:00
|
|
|
s->fade_samples(out_buf->extended_data, buf->extended_data,
|
2017-04-22 08:57:18 +00:00
|
|
|
nb_samples, buf->channels,
|
2013-10-02 11:09:06 +00:00
|
|
|
s->type ? -1 : 1, start,
|
|
|
|
s->nb_samples, s->curve);
|
2013-01-17 21:53:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (buf != out_buf)
|
2013-03-10 00:30:30 +00:00
|
|
|
av_frame_free(&buf);
|
2013-01-17 21:53:27 +00:00
|
|
|
|
|
|
|
return ff_filter_frame(outlink, out_buf);
|
|
|
|
}
|
|
|
|
|
2020-12-11 21:56:22 +00:00
|
|
|
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
|
|
|
|
char *res, int res_len, int flags)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return config_output(ctx->outputs[0]);
|
|
|
|
}
|
|
|
|
|
2013-01-17 21:53:27 +00:00
|
|
|
static const AVFilterPad avfilter_af_afade_inputs[] = {
|
|
|
|
{
|
|
|
|
.name = "default",
|
|
|
|
.type = AVMEDIA_TYPE_AUDIO,
|
|
|
|
.filter_frame = filter_frame,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const AVFilterPad avfilter_af_afade_outputs[] = {
|
|
|
|
{
|
2015-07-23 22:13:17 +00:00
|
|
|
.name = "default",
|
|
|
|
.type = AVMEDIA_TYPE_AUDIO,
|
|
|
|
.config_props = config_output,
|
2013-01-17 21:53:27 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-04-19 16:33:56 +00:00
|
|
|
const AVFilter ff_af_afade = {
|
2013-01-17 21:53:27 +00:00
|
|
|
.name = "afade",
|
|
|
|
.description = NULL_IF_CONFIG_SMALL("Fade in/out input audio."),
|
|
|
|
.query_formats = query_formats,
|
|
|
|
.priv_size = sizeof(AudioFadeContext),
|
|
|
|
.init = init,
|
2021-08-12 11:05:31 +00:00
|
|
|
FILTER_INPUTS(avfilter_af_afade_inputs),
|
|
|
|
FILTER_OUTPUTS(avfilter_af_afade_outputs),
|
2013-01-17 21:53:27 +00:00
|
|
|
.priv_class = &afade_class,
|
2020-12-11 21:56:22 +00:00
|
|
|
.process_command = process_command,
|
2013-05-25 13:08:13 +00:00
|
|
|
.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
|
2013-01-17 21:53:27 +00:00
|
|
|
};
|
2015-07-23 22:13:17 +00:00
|
|
|
|
|
|
|
#endif /* CONFIG_AFADE_FILTER */
|
|
|
|
|
|
|
|
#if CONFIG_ACROSSFADE_FILTER
|
|
|
|
|
|
|
|
static const AVOption acrossfade_options[] = {
|
|
|
|
{ "nb_samples", "set number of samples for cross fade duration", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 44100}, 1, INT32_MAX/10, FLAGS },
|
|
|
|
{ "ns", "set number of samples for cross fade duration", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 44100}, 1, INT32_MAX/10, FLAGS },
|
2021-02-21 12:38:14 +00:00
|
|
|
{ "duration", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0 }, 0, 60000000, FLAGS },
|
|
|
|
{ "d", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0 }, 0, 60000000, FLAGS },
|
2015-09-08 23:25:49 +00:00
|
|
|
{ "overlap", "overlap 1st stream end with 2nd stream start", OFFSET(overlap), AV_OPT_TYPE_BOOL, {.i64 = 1 }, 0, 1, FLAGS },
|
|
|
|
{ "o", "overlap 1st stream end with 2nd stream start", OFFSET(overlap), AV_OPT_TYPE_BOOL, {.i64 = 1 }, 0, 1, FLAGS },
|
2020-11-18 10:10:39 +00:00
|
|
|
{ "curve1", "set fade curve type for 1st stream", OFFSET(curve), AV_OPT_TYPE_INT, {.i64 = TRI }, NONE, NB_CURVES - 1, FLAGS, "curve" },
|
|
|
|
{ "c1", "set fade curve type for 1st stream", OFFSET(curve), AV_OPT_TYPE_INT, {.i64 = TRI }, NONE, NB_CURVES - 1, FLAGS, "curve" },
|
|
|
|
{ "nofade", "no fade; keep audio as-is", 0, AV_OPT_TYPE_CONST, {.i64 = NONE }, 0, 0, FLAGS, "curve" },
|
2016-01-26 22:27:04 +00:00
|
|
|
{ "tri", "linear slope", 0, AV_OPT_TYPE_CONST, {.i64 = TRI }, 0, 0, FLAGS, "curve" },
|
|
|
|
{ "qsin", "quarter of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = QSIN }, 0, 0, FLAGS, "curve" },
|
|
|
|
{ "esin", "exponential sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = ESIN }, 0, 0, FLAGS, "curve" },
|
|
|
|
{ "hsin", "half of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = HSIN }, 0, 0, FLAGS, "curve" },
|
|
|
|
{ "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64 = LOG }, 0, 0, FLAGS, "curve" },
|
|
|
|
{ "ipar", "inverted parabola", 0, AV_OPT_TYPE_CONST, {.i64 = IPAR }, 0, 0, FLAGS, "curve" },
|
|
|
|
{ "qua", "quadratic", 0, AV_OPT_TYPE_CONST, {.i64 = QUA }, 0, 0, FLAGS, "curve" },
|
|
|
|
{ "cub", "cubic", 0, AV_OPT_TYPE_CONST, {.i64 = CUB }, 0, 0, FLAGS, "curve" },
|
|
|
|
{ "squ", "square root", 0, AV_OPT_TYPE_CONST, {.i64 = SQU }, 0, 0, FLAGS, "curve" },
|
|
|
|
{ "cbr", "cubic root", 0, AV_OPT_TYPE_CONST, {.i64 = CBR }, 0, 0, FLAGS, "curve" },
|
|
|
|
{ "par", "parabola", 0, AV_OPT_TYPE_CONST, {.i64 = PAR }, 0, 0, FLAGS, "curve" },
|
|
|
|
{ "exp", "exponential", 0, AV_OPT_TYPE_CONST, {.i64 = EXP }, 0, 0, FLAGS, "curve" },
|
|
|
|
{ "iqsin", "inverted quarter of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = IQSIN}, 0, 0, FLAGS, "curve" },
|
|
|
|
{ "ihsin", "inverted half of sine wave", 0, AV_OPT_TYPE_CONST, {.i64 = IHSIN}, 0, 0, FLAGS, "curve" },
|
|
|
|
{ "dese", "double-exponential seat", 0, AV_OPT_TYPE_CONST, {.i64 = DESE }, 0, 0, FLAGS, "curve" },
|
|
|
|
{ "desi", "double-exponential sigmoid", 0, AV_OPT_TYPE_CONST, {.i64 = DESI }, 0, 0, FLAGS, "curve" },
|
2018-10-07 15:38:22 +00:00
|
|
|
{ "losi", "logistic sigmoid", 0, AV_OPT_TYPE_CONST, {.i64 = LOSI }, 0, 0, FLAGS, "curve" },
|
2020-11-18 10:10:39 +00:00
|
|
|
{ "sinc", "sine cardinal function", 0, AV_OPT_TYPE_CONST, {.i64 = SINC }, 0, 0, FLAGS, "curve" },
|
|
|
|
{ "isinc", "inverted sine cardinal function", 0, AV_OPT_TYPE_CONST, {.i64 = ISINC}, 0, 0, FLAGS, "curve" },
|
|
|
|
{ "curve2", "set fade curve type for 2nd stream", OFFSET(curve2), AV_OPT_TYPE_INT, {.i64 = TRI }, NONE, NB_CURVES - 1, FLAGS, "curve" },
|
|
|
|
{ "c2", "set fade curve type for 2nd stream", OFFSET(curve2), AV_OPT_TYPE_INT, {.i64 = TRI }, NONE, NB_CURVES - 1, FLAGS, "curve" },
|
2015-07-23 22:13:17 +00:00
|
|
|
{ NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
AVFILTER_DEFINE_CLASS(acrossfade);
|
|
|
|
|
|
|
|
#define CROSSFADE_PLANAR(name, type) \
|
|
|
|
static void crossfade_samples_## name ##p(uint8_t **dst, uint8_t * const *cf0, \
|
|
|
|
uint8_t * const *cf1, \
|
|
|
|
int nb_samples, int channels, \
|
|
|
|
int curve0, int curve1) \
|
|
|
|
{ \
|
|
|
|
int i, c; \
|
|
|
|
\
|
|
|
|
for (i = 0; i < nb_samples; i++) { \
|
|
|
|
double gain0 = fade_gain(curve0, nb_samples - 1 - i, nb_samples); \
|
|
|
|
double gain1 = fade_gain(curve1, i, nb_samples); \
|
|
|
|
for (c = 0; c < channels; c++) { \
|
|
|
|
type *d = (type *)dst[c]; \
|
|
|
|
const type *s0 = (type *)cf0[c]; \
|
|
|
|
const type *s1 = (type *)cf1[c]; \
|
|
|
|
\
|
|
|
|
d[i] = s0[i] * gain0 + s1[i] * gain1; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CROSSFADE(name, type) \
|
|
|
|
static void crossfade_samples_## name (uint8_t **dst, uint8_t * const *cf0, \
|
|
|
|
uint8_t * const *cf1, \
|
|
|
|
int nb_samples, int channels, \
|
|
|
|
int curve0, int curve1) \
|
|
|
|
{ \
|
|
|
|
type *d = (type *)dst[0]; \
|
|
|
|
const type *s0 = (type *)cf0[0]; \
|
|
|
|
const type *s1 = (type *)cf1[0]; \
|
|
|
|
int i, c, k = 0; \
|
|
|
|
\
|
|
|
|
for (i = 0; i < nb_samples; i++) { \
|
|
|
|
double gain0 = fade_gain(curve0, nb_samples - 1 - i, nb_samples); \
|
|
|
|
double gain1 = fade_gain(curve1, i, nb_samples); \
|
|
|
|
for (c = 0; c < channels; c++, k++) \
|
|
|
|
d[k] = s0[k] * gain0 + s1[k] * gain1; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
CROSSFADE_PLANAR(dbl, double)
|
|
|
|
CROSSFADE_PLANAR(flt, float)
|
|
|
|
CROSSFADE_PLANAR(s16, int16_t)
|
|
|
|
CROSSFADE_PLANAR(s32, int32_t)
|
|
|
|
|
|
|
|
CROSSFADE(dbl, double)
|
|
|
|
CROSSFADE(flt, float)
|
|
|
|
CROSSFADE(s16, int16_t)
|
|
|
|
CROSSFADE(s32, int32_t)
|
|
|
|
|
2018-01-18 10:17:03 +00:00
|
|
|
static int activate(AVFilterContext *ctx)
|
2015-07-23 22:13:17 +00:00
|
|
|
{
|
|
|
|
AudioFadeContext *s = ctx->priv;
|
|
|
|
AVFilterLink *outlink = ctx->outputs[0];
|
2018-01-18 10:17:03 +00:00
|
|
|
AVFrame *in = NULL, *out, *cf[2] = { NULL };
|
|
|
|
int ret = 0, nb_samples, status;
|
|
|
|
int64_t pts;
|
2015-07-23 22:13:17 +00:00
|
|
|
|
2018-05-05 19:24:41 +00:00
|
|
|
FF_FILTER_FORWARD_STATUS_BACK_ALL(outlink, ctx);
|
|
|
|
|
2015-07-23 22:13:17 +00:00
|
|
|
if (s->crossfade_is_over) {
|
2018-01-18 10:17:03 +00:00
|
|
|
ret = ff_inlink_consume_frame(ctx->inputs[1], &in);
|
2019-10-30 18:07:19 +00:00
|
|
|
if (ret > 0) {
|
|
|
|
in->pts = s->pts;
|
|
|
|
s->pts += av_rescale_q(in->nb_samples,
|
|
|
|
(AVRational){ 1, outlink->sample_rate }, outlink->time_base);
|
|
|
|
return ff_filter_frame(outlink, in);
|
|
|
|
} else if (ret < 0) {
|
2018-01-18 10:17:03 +00:00
|
|
|
return ret;
|
|
|
|
} else if (ff_inlink_acknowledge_status(ctx->inputs[1], &status, &pts)) {
|
|
|
|
ff_outlink_set_status(ctx->outputs[0], status, pts);
|
|
|
|
return 0;
|
2019-10-15 22:45:26 +00:00
|
|
|
} else if (!ret) {
|
|
|
|
if (ff_outlink_frame_wanted(ctx->outputs[0])) {
|
2018-01-18 10:17:03 +00:00
|
|
|
ff_inlink_request_frame(ctx->inputs[1]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-07-23 22:13:17 +00:00
|
|
|
|
2018-11-03 17:13:23 +00:00
|
|
|
if (ff_inlink_queued_samples(ctx->inputs[0]) > s->nb_samples) {
|
|
|
|
nb_samples = ff_inlink_queued_samples(ctx->inputs[0]) - s->nb_samples;
|
2015-07-23 22:13:17 +00:00
|
|
|
if (nb_samples > 0) {
|
2018-01-18 10:17:03 +00:00
|
|
|
ret = ff_inlink_consume_samples(ctx->inputs[0], nb_samples, nb_samples, &in);
|
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
2015-07-23 22:13:17 +00:00
|
|
|
}
|
|
|
|
}
|
2018-01-18 10:17:03 +00:00
|
|
|
in->pts = s->pts;
|
|
|
|
s->pts += av_rescale_q(in->nb_samples,
|
|
|
|
(AVRational){ 1, outlink->sample_rate }, outlink->time_base);
|
|
|
|
return ff_filter_frame(outlink, in);
|
2019-10-15 14:55:13 +00:00
|
|
|
} else if (ff_inlink_queued_samples(ctx->inputs[0]) >= s->nb_samples &&
|
2019-10-31 09:22:05 +00:00
|
|
|
ff_inlink_queued_samples(ctx->inputs[1]) >= s->nb_samples && s->cf0_eof) {
|
2015-07-23 22:13:17 +00:00
|
|
|
if (s->overlap) {
|
|
|
|
out = ff_get_audio_buffer(outlink, s->nb_samples);
|
2018-01-18 10:17:03 +00:00
|
|
|
if (!out)
|
|
|
|
return AVERROR(ENOMEM);
|
|
|
|
|
|
|
|
ret = ff_inlink_consume_samples(ctx->inputs[0], s->nb_samples, s->nb_samples, &cf[0]);
|
|
|
|
if (ret < 0) {
|
2015-07-23 22:13:17 +00:00
|
|
|
av_frame_free(&out);
|
2018-01-18 10:17:03 +00:00
|
|
|
return ret;
|
2015-07-23 22:13:17 +00:00
|
|
|
}
|
|
|
|
|
2018-01-18 10:17:03 +00:00
|
|
|
ret = ff_inlink_consume_samples(ctx->inputs[1], s->nb_samples, s->nb_samples, &cf[1]);
|
|
|
|
if (ret < 0) {
|
|
|
|
av_frame_free(&out);
|
|
|
|
return ret;
|
|
|
|
}
|
2015-07-23 22:13:17 +00:00
|
|
|
|
|
|
|
s->crossfade_samples(out->extended_data, cf[0]->extended_data,
|
|
|
|
cf[1]->extended_data,
|
2018-01-18 10:17:03 +00:00
|
|
|
s->nb_samples, out->channels,
|
2015-07-23 22:13:17 +00:00
|
|
|
s->curve, s->curve2);
|
|
|
|
out->pts = s->pts;
|
|
|
|
s->pts += av_rescale_q(s->nb_samples,
|
|
|
|
(AVRational){ 1, outlink->sample_rate }, outlink->time_base);
|
2018-01-18 10:17:03 +00:00
|
|
|
s->crossfade_is_over = 1;
|
|
|
|
av_frame_free(&cf[0]);
|
|
|
|
av_frame_free(&cf[1]);
|
|
|
|
return ff_filter_frame(outlink, out);
|
2015-07-23 22:13:17 +00:00
|
|
|
} else {
|
|
|
|
out = ff_get_audio_buffer(outlink, s->nb_samples);
|
2018-01-18 10:17:03 +00:00
|
|
|
if (!out)
|
|
|
|
return AVERROR(ENOMEM);
|
|
|
|
|
|
|
|
ret = ff_inlink_consume_samples(ctx->inputs[0], s->nb_samples, s->nb_samples, &cf[0]);
|
|
|
|
if (ret < 0) {
|
2015-07-23 22:13:17 +00:00
|
|
|
av_frame_free(&out);
|
2018-01-18 10:17:03 +00:00
|
|
|
return ret;
|
2015-07-23 22:13:17 +00:00
|
|
|
}
|
|
|
|
|
2018-01-18 10:17:03 +00:00
|
|
|
s->fade_samples(out->extended_data, cf[0]->extended_data, s->nb_samples,
|
|
|
|
outlink->channels, -1, s->nb_samples - 1, s->nb_samples, s->curve);
|
2015-07-23 22:13:17 +00:00
|
|
|
out->pts = s->pts;
|
|
|
|
s->pts += av_rescale_q(s->nb_samples,
|
|
|
|
(AVRational){ 1, outlink->sample_rate }, outlink->time_base);
|
2018-01-18 10:17:03 +00:00
|
|
|
av_frame_free(&cf[0]);
|
2015-07-23 22:13:17 +00:00
|
|
|
ret = ff_filter_frame(outlink, out);
|
|
|
|
if (ret < 0)
|
2018-01-18 10:17:03 +00:00
|
|
|
return ret;
|
2015-07-23 22:13:17 +00:00
|
|
|
|
2018-01-18 10:17:03 +00:00
|
|
|
out = ff_get_audio_buffer(outlink, s->nb_samples);
|
|
|
|
if (!out)
|
|
|
|
return AVERROR(ENOMEM);
|
|
|
|
|
|
|
|
ret = ff_inlink_consume_samples(ctx->inputs[1], s->nb_samples, s->nb_samples, &cf[1]);
|
|
|
|
if (ret < 0) {
|
|
|
|
av_frame_free(&out);
|
|
|
|
return ret;
|
2015-07-23 22:13:17 +00:00
|
|
|
}
|
|
|
|
|
2018-01-18 10:17:03 +00:00
|
|
|
s->fade_samples(out->extended_data, cf[1]->extended_data, s->nb_samples,
|
|
|
|
outlink->channels, 1, 0, s->nb_samples, s->curve2);
|
2015-07-23 22:13:17 +00:00
|
|
|
out->pts = s->pts;
|
2018-01-18 10:17:03 +00:00
|
|
|
s->pts += av_rescale_q(s->nb_samples,
|
2015-07-23 22:13:17 +00:00
|
|
|
(AVRational){ 1, outlink->sample_rate }, outlink->time_base);
|
2018-01-18 10:17:03 +00:00
|
|
|
s->crossfade_is_over = 1;
|
|
|
|
av_frame_free(&cf[1]);
|
|
|
|
return ff_filter_frame(outlink, out);
|
2015-07-23 22:13:17 +00:00
|
|
|
}
|
2018-01-18 10:17:03 +00:00
|
|
|
} else if (ff_outlink_frame_wanted(ctx->outputs[0])) {
|
2018-11-03 17:13:23 +00:00
|
|
|
if (!s->cf0_eof && ff_outlink_get_status(ctx->inputs[0])) {
|
2015-07-23 22:13:17 +00:00
|
|
|
s->cf0_eof = 1;
|
|
|
|
}
|
2018-11-03 17:13:23 +00:00
|
|
|
if (ff_outlink_get_status(ctx->inputs[1])) {
|
2018-01-18 10:17:03 +00:00
|
|
|
ff_outlink_set_status(ctx->outputs[0], AVERROR_EOF, AV_NOPTS_VALUE);
|
|
|
|
return 0;
|
2015-07-23 22:13:17 +00:00
|
|
|
}
|
2018-01-18 10:17:03 +00:00
|
|
|
if (!s->cf0_eof)
|
|
|
|
ff_inlink_request_frame(ctx->inputs[0]);
|
|
|
|
else
|
|
|
|
ff_inlink_request_frame(ctx->inputs[1]);
|
|
|
|
return 0;
|
2015-07-23 22:13:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int acrossfade_config_output(AVFilterLink *outlink)
|
|
|
|
{
|
|
|
|
AVFilterContext *ctx = outlink->src;
|
|
|
|
AudioFadeContext *s = ctx->priv;
|
|
|
|
|
|
|
|
outlink->time_base = ctx->inputs[0]->time_base;
|
|
|
|
|
|
|
|
switch (outlink->format) {
|
|
|
|
case AV_SAMPLE_FMT_DBL: s->crossfade_samples = crossfade_samples_dbl; break;
|
|
|
|
case AV_SAMPLE_FMT_DBLP: s->crossfade_samples = crossfade_samples_dblp; break;
|
|
|
|
case AV_SAMPLE_FMT_FLT: s->crossfade_samples = crossfade_samples_flt; break;
|
|
|
|
case AV_SAMPLE_FMT_FLTP: s->crossfade_samples = crossfade_samples_fltp; break;
|
|
|
|
case AV_SAMPLE_FMT_S16: s->crossfade_samples = crossfade_samples_s16; break;
|
|
|
|
case AV_SAMPLE_FMT_S16P: s->crossfade_samples = crossfade_samples_s16p; break;
|
|
|
|
case AV_SAMPLE_FMT_S32: s->crossfade_samples = crossfade_samples_s32; break;
|
|
|
|
case AV_SAMPLE_FMT_S32P: s->crossfade_samples = crossfade_samples_s32p; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
config_output(outlink);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const AVFilterPad avfilter_af_acrossfade_inputs[] = {
|
|
|
|
{
|
|
|
|
.name = "crossfade0",
|
|
|
|
.type = AVMEDIA_TYPE_AUDIO,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "crossfade1",
|
|
|
|
.type = AVMEDIA_TYPE_AUDIO,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const AVFilterPad avfilter_af_acrossfade_outputs[] = {
|
|
|
|
{
|
|
|
|
.name = "default",
|
|
|
|
.type = AVMEDIA_TYPE_AUDIO,
|
|
|
|
.config_props = acrossfade_config_output,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-04-19 16:33:56 +00:00
|
|
|
const AVFilter ff_af_acrossfade = {
|
2015-07-23 22:13:17 +00:00
|
|
|
.name = "acrossfade",
|
|
|
|
.description = NULL_IF_CONFIG_SMALL("Cross fade two input audio streams."),
|
|
|
|
.query_formats = query_formats,
|
|
|
|
.priv_size = sizeof(AudioFadeContext),
|
2018-01-18 10:17:03 +00:00
|
|
|
.activate = activate,
|
2015-07-23 22:13:17 +00:00
|
|
|
.priv_class = &acrossfade_class,
|
2021-08-12 11:05:31 +00:00
|
|
|
FILTER_INPUTS(avfilter_af_acrossfade_inputs),
|
|
|
|
FILTER_OUTPUTS(avfilter_af_acrossfade_outputs),
|
2015-07-23 22:13:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* CONFIG_ACROSSFADE_FILTER */
|