mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 21:00:41 +08:00
avfilter/vf_libplacebo: early-free unused resources
Otherwise, this will indefinitely persist the last couple of mapped frames (including any extra decoded frames) in memory, even though they will never be used again, causing a gradual memory leak until filter uninit. Signed-off-by: Niklas Haas <git@haasn.dev> Sponsored-by: nxtedition AB
This commit is contained in:
@@ -1114,6 +1114,8 @@ props_done:
|
|||||||
struct pl_render_params tmp_params = opts->params;
|
struct pl_render_params tmp_params = opts->params;
|
||||||
for (int i = 0; i < s->nb_inputs; i++) {
|
for (int i = 0; i < s->nb_inputs; i++) {
|
||||||
LibplaceboInput *in = &s->inputs[i];
|
LibplaceboInput *in = &s->inputs[i];
|
||||||
|
if (!in->renderer)
|
||||||
|
continue; /* input was already freed */
|
||||||
FilterLink *il = ff_filter_link(ctx->inputs[i]);
|
FilterLink *il = ff_filter_link(ctx->inputs[i]);
|
||||||
FilterLink *ol = ff_filter_link(outlink);
|
FilterLink *ol = ff_filter_link(outlink);
|
||||||
int high_fps = av_cmp_q(il->frame_rate, ol->frame_rate) >= 0;
|
int high_fps = av_cmp_q(il->frame_rate, ol->frame_rate) >= 0;
|
||||||
@@ -1293,6 +1295,9 @@ static int libplacebo_activate(AVFilterContext *ctx)
|
|||||||
LibplaceboInput *in = &s->inputs[i];
|
LibplaceboInput *in = &s->inputs[i];
|
||||||
FilterLink *l = ff_filter_link(outlink);
|
FilterLink *l = ff_filter_link(outlink);
|
||||||
if (in->status && out_pts >= in->status_pts) {
|
if (in->status && out_pts >= in->status_pts) {
|
||||||
|
/* Free up resources which will never be needed again */
|
||||||
|
pl_renderer_destroy(&in->renderer);
|
||||||
|
pl_queue_destroy(&in->queue);
|
||||||
in->qstatus = PL_QUEUE_EOF;
|
in->qstatus = PL_QUEUE_EOF;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user