aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2020-09-13 13:08:35 +0200
committerPaul B Mahol <onemda@gmail.com>2020-09-13 13:18:18 +0200
commit0a17a4891d85e22a077e8d85aa424efebf6c8b76 (patch)
tree4636e7769f935491de22a08dbd96de9d251f8aab
parentaa8935b395162f8438d1f055e671e92685ed1586 (diff)
downloadffmpeg-0a17a4891d85e22a077e8d85aa424efebf6c8b76.tar.gz
avfilter/asrc_anullsrc: make number of output samples match duration
-rw-r--r--libavfilter/asrc_anullsrc.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/libavfilter/asrc_anullsrc.c b/libavfilter/asrc_anullsrc.c
index 0ce2cfd754..f6bd595470 100644
--- a/libavfilter/asrc_anullsrc.c
+++ b/libavfilter/asrc_anullsrc.c
@@ -93,19 +93,28 @@ static int query_formats(AVFilterContext *ctx)
return ff_set_common_channel_layouts(ctx, ff_make_format64_list(chlayouts));
}
+static av_cold int config_props(AVFilterLink *outlink)
+{
+ ANullContext *null = outlink->src->priv;
+
+ if (null->duration >= 0)
+ null->duration = av_rescale(null->duration, null->sample_rate, AV_TIME_BASE);
+
+ return 0;
+}
+
static int activate(AVFilterContext *ctx)
{
ANullContext *null = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0];
- if (null->duration >= 0 &&
- av_rescale_q(null->pts, outlink->time_base, AV_TIME_BASE_Q) >= null->duration) {
+ if (null->duration >= 0 && null->pts >= null->duration) {
ff_outlink_set_status(outlink, AVERROR_EOF, null->pts);
return 0;
}
if (ff_outlink_frame_wanted(outlink)) {
- AVFrame *samplesref = ff_get_audio_buffer(outlink, null->nb_samples);
+ AVFrame *samplesref = ff_get_audio_buffer(outlink, null->duration >= 0 ? FFMIN(null->nb_samples, null->duration - null->pts) : null->nb_samples);
int ret;
if (!samplesref)
@@ -128,6 +137,7 @@ static const AVFilterPad avfilter_asrc_anullsrc_outputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_AUDIO,
+ .config_props = config_props,
},
{ NULL }
};