lavfi/framesync: avoid forcing frame writability unnecessarily

Callers of ff_framesync_get_frame() generally do not expect the result
to be writable, those that do (e.g. ff_framesync_dualinput_get_writable())
ensure writability themselves.

Significantly reduces memory consumption in complex graphs with
framesync-based filters (e.g. scale, ssim).

Reported-By: Mark Shwartzman
Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Anton Khirnov 2024-07-24 17:10:41 +02:00 committed by Paul B Mahol
parent 5f30822782
commit b272c2840b

View File

@ -272,7 +272,6 @@ int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe,
AVFrame *frame;
unsigned need_copy = 0, i;
int64_t pts_next;
int ret;
if (!fs->in[in].frame) {
*rframe = NULL;
@ -290,10 +289,6 @@ int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe,
if (need_copy) {
if (!(frame = av_frame_clone(frame)))
return AVERROR(ENOMEM);
if ((ret = ff_inlink_make_frame_writable(fs->parent->inputs[in], &frame)) < 0) {
av_frame_free(&frame);
return ret;
}
} else {
fs->in[in].frame = NULL;
}