avfilter/*xfade: reduce memory consumption

There is no always need for new buffers.
pull/389/head
Paul B Mahol 2 years ago
parent 6759983bdc
commit 2a74826b02
  1. 13
      libavfilter/af_afade.c
  2. 11
      libavfilter/vf_xfade.c

@ -672,14 +672,27 @@ static int acrossfade_config_output(AVFilterLink *outlink)
return 0;
}
static AVFrame *get_audio_buffer(AVFilterLink *inlink, int nb_samples)
{
AVFilterContext *ctx = inlink->dst;
AudioFadeContext *s = ctx->priv;
return (s->crossfade_is_over ||
(ff_inlink_queued_samples(inlink) > s->nb_samples)) ?
ff_null_get_audio_buffer (inlink, nb_samples) :
ff_default_get_audio_buffer(inlink, nb_samples);
}
static const AVFilterPad avfilter_af_acrossfade_inputs[] = {
{
.name = "crossfade0",
.type = AVMEDIA_TYPE_AUDIO,
.get_buffer.audio = get_audio_buffer,
},
{
.name = "crossfade1",
.type = AVMEDIA_TYPE_AUDIO,
.get_buffer.audio = get_audio_buffer,
},
};

@ -2042,14 +2042,25 @@ static int xfade_activate(AVFilterContext *ctx)
return FFERROR_NOT_READY;
}
static AVFrame *get_video_buffer(AVFilterLink *inlink, int w, int h)
{
XFadeContext *s = inlink->dst->priv;
return s->xfade_is_over || !s->need_second ?
ff_null_get_video_buffer (inlink, w, h) :
ff_default_get_video_buffer(inlink, w, h);
}
static const AVFilterPad xfade_inputs[] = {
{
.name = "main",
.type = AVMEDIA_TYPE_VIDEO,
.get_buffer.video = get_video_buffer,
},
{
.name = "xfade",
.type = AVMEDIA_TYPE_VIDEO,
.get_buffer.video = get_video_buffer,
},
};

Loading…
Cancel
Save