summaryrefslogtreecommitdiff
path: root/libavfilter/af_apad.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2021-07-28 23:53:42 +0200
committerMarton Balint <cus@passwd.hu>2021-11-14 18:13:58 +0100
commit0a9edac48eacc0f914f489dc7953a51bf24bb99c (patch)
treec18e100fc7505a5aa3bda1c3add80c8474d80a00 /libavfilter/af_apad.c
parent97c3053d59f30f84b30efcc73ccf1b2e84b89006 (diff)
downloadffmpeg-0a9edac48eacc0f914f489dc7953a51bf24bb99c.tar.gz
avfilter/af_apad: do not add infinite silence for zero pad_dur or whole_dur
Unfortunately pad_len and pad_dur behaviour was different if 0 was specified, pad_dur handled 0 duration as infinity, for pad_len, infinity was -1. Let's make the behaviour consistent by handling 0 duration for pad_dur and whole_dur as indeed 0 duration. This somewhat changes the behaviour of the filter if 0 was explicitly specified, but deprecating the old option and adding a new for the corrected behaviour seemed a bit overkill. So let's document the change instead. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavfilter/af_apad.c')
-rw-r--r--libavfilter/af_apad.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libavfilter/af_apad.c b/libavfilter/af_apad.c
index 27259a87a3..ae73f0b6b1 100644
--- a/libavfilter/af_apad.c
+++ b/libavfilter/af_apad.c
@@ -52,8 +52,8 @@ static const AVOption apad_options[] = {
{ "packet_size", "set silence packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, { .i64 = 4096 }, 0, INT_MAX, A },
{ "pad_len", "set number of samples of silence to add", OFFSET(pad_len), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, A },
{ "whole_len", "set minimum target number of samples in the audio stream", OFFSET(whole_len), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, A },
- { "pad_dur", "set duration of silence to add", OFFSET(pad_dur), AV_OPT_TYPE_DURATION, { .i64 = 0 }, 0, INT64_MAX, A },
- { "whole_dur", "set minimum target duration in the audio stream", OFFSET(whole_dur), AV_OPT_TYPE_DURATION, { .i64 = 0 }, 0, INT64_MAX, A },
+ { "pad_dur", "set duration of silence to add", OFFSET(pad_dur), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT64_MAX, A },
+ { "whole_dur", "set minimum target duration in the audio stream", OFFSET(whole_dur), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT64_MAX, A },
{ NULL }
};
@@ -138,9 +138,9 @@ static int config_output(AVFilterLink *outlink)
AVFilterContext *ctx = outlink->src;
APadContext *s = ctx->priv;
- if (s->pad_dur)
+ if (s->pad_dur >= 0)
s->pad_len = av_rescale(s->pad_dur, outlink->sample_rate, AV_TIME_BASE);
- if (s->whole_dur)
+ if (s->whole_dur >= 0)
s->whole_len = av_rescale(s->whole_dur, outlink->sample_rate, AV_TIME_BASE);
s->pad_len_left = s->pad_len;