avfilter/afade+acrossfade: allow skipping fade on inputs

New fade curve value 'nofade' passes audio samples as-is.
Primarily useful in carrying out acrossfade without fades.
This commit is contained in:
Gyan Doshi 2019-01-23 13:35:23 +05:30
parent e0ad7d5741
commit 3224d6691c
2 changed files with 8 additions and 1 deletions

View File

@ -958,6 +958,8 @@ select double-exponential seat
select double-exponential sigmoid
@item losi
select logistic sigmoid
@item nofade
no fade applied
@end table
@end table

View File

@ -51,7 +51,7 @@ typedef struct AudioFadeContext {
int curve0, int curve1);
} AudioFadeContext;
enum CurveType { TRI, QSIN, ESIN, HSIN, LOG, IPAR, QUA, CUB, SQU, CBR, PAR, EXP, IQSIN, IHSIN, DESE, DESI, LOSI, NB_CURVES };
enum CurveType { TRI, QSIN, ESIN, HSIN, LOG, IPAR, QUA, CUB, SQU, CBR, PAR, EXP, IQSIN, IHSIN, DESE, DESI, LOSI, NONE, NB_CURVES };
#define OFFSET(x) offsetof(AudioFadeContext, x)
#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
@ -153,6 +153,9 @@ static double fade_gain(int curve, int64_t index, int64_t range)
gain = (A - B) / (C - B);
}
break;
case NONE:
gain = 1.0;
break;
}
return gain;
@ -260,6 +263,7 @@ static const AVOption afade_options[] = {
{ "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" },
{ "losi", "logistic sigmoid", 0, AV_OPT_TYPE_CONST, {.i64 = LOSI }, 0, 0, FLAGS, "curve" },
{ "nofade", "no fade; keep audio as-is", 0, AV_OPT_TYPE_CONST, {.i64 = NONE }, 0, 0, FLAGS, "curve" },
{ NULL }
};
@ -380,6 +384,7 @@ static const AVOption acrossfade_options[] = {
{ "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" },
{ "losi", "logistic sigmoid", 0, AV_OPT_TYPE_CONST, {.i64 = LOSI }, 0, 0, FLAGS, "curve" },
{ "nofade", "no fade; keep audio as-is", 0, AV_OPT_TYPE_CONST, {.i64 = NONE }, 0, 0, FLAGS, "curve" },
{ "curve2", "set fade curve type for 2nd stream", OFFSET(curve2), AV_OPT_TYPE_INT, {.i64 = TRI }, 0, NB_CURVES - 1, FLAGS, "curve" },
{ "c2", "set fade curve type for 2nd stream", OFFSET(curve2), AV_OPT_TYPE_INT, {.i64 = TRI }, 0, NB_CURVES - 1, FLAGS, "curve" },
{ NULL }