summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2023-05-14 14:41:38 +0200
committerPaul B Mahol <onemda@gmail.com>2023-05-14 20:58:08 +0200
commit932ccf9e7d159887766fa9a1f3ef171b8a89a3dd (patch)
tree8818ce15b18f5bebe65162c0157e5cf5387b154e /libavfilter
parentc27895bb9865fa274e66aa67ec7df574a104da69 (diff)
downloadffmpeg-932ccf9e7d159887766fa9a1f3ef171b8a89a3dd.tar.gz
avfilter/f_loop: free video frames once not needed
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/f_loop.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/libavfilter/f_loop.c b/libavfilter/f_loop.c
index 7974d266f0..33b66fa534 100644
--- a/libavfilter/f_loop.c
+++ b/libavfilter/f_loop.c
@@ -336,14 +336,19 @@ static av_cold int init(AVFilterContext *ctx)
return 0;
}
-static av_cold void uninit(AVFilterContext *ctx)
+static void free_frames(AVFilterContext *ctx)
{
LoopContext *s = ctx->priv;
- int i;
- for (i = 0; i < s->nb_frames; i++)
+ for (int i = 0; i < s->nb_frames; i++)
av_frame_free(&s->frames[i]);
+}
+static av_cold void uninit(AVFilterContext *ctx)
+{
+ LoopContext *s = ctx->priv;
+
+ free_frames(ctx);
av_freep(&s->frames);
s->nb_frames = 0;
}
@@ -368,6 +373,8 @@ static int push_frame(AVFilterContext *ctx)
s->pts_offset += s->duration;
if (s->loop > 0)
s->loop--;
+ if (s->loop == 0)
+ free_frames(ctx);
}
return ret;
@@ -419,7 +426,12 @@ static int activate(AVFilterContext *ctx)
AVFrame *frame = NULL;
int ret, status;
- FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
+ ret = ff_outlink_get_status(outlink);
+ if (ret) {
+ ff_inlink_set_status(inlink, ret);
+ free_frames(ctx);
+ return 0;
+ }
update_time(ctx, inlink->time_base);
@@ -440,6 +452,7 @@ static int activate(AVFilterContext *ctx)
if (s->eof && (!s->loop || !s->size)) {
ff_outlink_set_status(outlink, AVERROR_EOF, s->eof_pts + s->pts_offset);
+ free_frames(ctx);
return 0;
}