You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avfilter/*xfade: reduce memory consumption
There is no always need for new buffers.
This commit is contained in:
@@ -672,14 +672,27 @@ static int acrossfade_config_output(AVFilterLink *outlink)
|
|||||||
return 0;
|
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[] = {
|
static const AVFilterPad avfilter_af_acrossfade_inputs[] = {
|
||||||
{
|
{
|
||||||
.name = "crossfade0",
|
.name = "crossfade0",
|
||||||
.type = AVMEDIA_TYPE_AUDIO,
|
.type = AVMEDIA_TYPE_AUDIO,
|
||||||
|
.get_buffer.audio = get_audio_buffer,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "crossfade1",
|
.name = "crossfade1",
|
||||||
.type = AVMEDIA_TYPE_AUDIO,
|
.type = AVMEDIA_TYPE_AUDIO,
|
||||||
|
.get_buffer.audio = get_audio_buffer,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -2042,14 +2042,25 @@ static int xfade_activate(AVFilterContext *ctx)
|
|||||||
return FFERROR_NOT_READY;
|
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[] = {
|
static const AVFilterPad xfade_inputs[] = {
|
||||||
{
|
{
|
||||||
.name = "main",
|
.name = "main",
|
||||||
.type = AVMEDIA_TYPE_VIDEO,
|
.type = AVMEDIA_TYPE_VIDEO,
|
||||||
|
.get_buffer.video = get_video_buffer,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "xfade",
|
.name = "xfade",
|
||||||
.type = AVMEDIA_TYPE_VIDEO,
|
.type = AVMEDIA_TYPE_VIDEO,
|
||||||
|
.get_buffer.video = get_video_buffer,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user