diff options
author | Clément Bœsch <ubitux@gmail.com> | 2012-10-21 03:28:19 +0400 |
---|---|---|
committer | Clément Bœsch <ubitux@gmail.com> | 2012-10-21 03:28:19 +0400 |
commit | 273fca9ac071da4078afa61f087e1e90fafd4958 (patch) | |
tree | 02049f0979ec439d6d3cb881bf0693232264a2d0 /libavfilter/af_silencedetect.c | |
parent | 99a520000d376d60cd30fae97bfaaf13d50ee26c (diff) |
lavfi/silencedetect: increase duration precision.
This should also fix CID717889.
Diffstat (limited to 'libavfilter/af_silencedetect.c')
-rw-r--r-- | libavfilter/af_silencedetect.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c index 2ea5d7f5bc..b19ac2e94a 100644 --- a/libavfilter/af_silencedetect.c +++ b/libavfilter/af_silencedetect.c @@ -35,7 +35,7 @@ typedef struct { const AVClass *class; char *noise_str; ///< noise option string double noise; ///< noise amplitude ratio - int duration; ///< minimum duration of silence until notification + double duration; ///< minimum duration of silence until notification int64_t nb_null_samples; ///< current number of continuous zero samples int64_t start; ///< if silence is detected, this value contains the time of the first zero sample int last_sample_rate; ///< last sample rate to check for sample rate changes @@ -46,8 +46,8 @@ typedef struct { static const AVOption silencedetect_options[] = { { "n", "set noise tolerance", OFFSET(noise_str), AV_OPT_TYPE_STRING, {.str="-60dB"}, CHAR_MIN, CHAR_MAX, FLAGS }, { "noise", "set noise tolerance", OFFSET(noise_str), AV_OPT_TYPE_STRING, {.str="-60dB"}, CHAR_MIN, CHAR_MAX, FLAGS }, - { "d", "set minimum duration in seconds", OFFSET(duration), AV_OPT_TYPE_INT, {.i64=2}, 0, INT_MAX, FLAGS }, - { "duration", "set minimum duration in seconds", OFFSET(duration), AV_OPT_TYPE_INT, {.i64=2}, 0, INT_MAX, FLAGS }, + { "d", "set minimum duration in seconds", OFFSET(duration), AV_OPT_TYPE_DOUBLE, {.dbl=2.}, 0, 24*60*60, FLAGS }, + { "duration", "set minimum duration in seconds", OFFSET(duration), AV_OPT_TYPE_DOUBLE, {.dbl=2.}, 0, 24*60*60, FLAGS }, { NULL }, }; @@ -102,7 +102,7 @@ static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) if (!silence->start) { silence->nb_null_samples++; if (silence->nb_null_samples >= nb_samples_notify) { - silence->start = insamples->pts - silence->duration / av_q2d(inlink->time_base); + silence->start = insamples->pts - (int64_t)(silence->duration / av_q2d(inlink->time_base) + .5); av_log(silence, AV_LOG_INFO, "silence_start: %s\n", av_ts2timestr(silence->start, &inlink->time_base)); } |