diff options
author | Paul B Mahol <onemda@gmail.com> | 2017-08-30 12:06:47 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2017-08-30 12:13:02 +0200 |
commit | a4d18a3f54e5b0277234d8fcff65dff8516417a0 (patch) | |
tree | 247b695fe4231d3d2f9ea55d972658f0db706178 /libavfilter/vf_lut2.c | |
parent | 9d99f0afbeedf3e170478c3e8c05789bf2eef48f (diff) |
avfilter/vf_lut2: add framesync options
Also stop leaking memory.
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter/vf_lut2.c')
-rw-r--r-- | libavfilter/vf_lut2.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libavfilter/vf_lut2.c b/libavfilter/vf_lut2.c index 176b98ee80..ba599c3d14 100644 --- a/libavfilter/vf_lut2.c +++ b/libavfilter/vf_lut2.c @@ -52,6 +52,7 @@ enum var_name { typedef struct LUT2Context { const AVClass *class; + FFFrameSync fs; char *comp_expr_str[4]; @@ -66,7 +67,6 @@ typedef struct LUT2Context { void (*lut2)(struct LUT2Context *s, AVFrame *dst, AVFrame *srcx, AVFrame *srcy); - FFFrameSync fs; } LUT2Context; #define OFFSET(x) offsetof(LUT2Context, x) @@ -85,6 +85,7 @@ static av_cold void uninit(AVFilterContext *ctx) LUT2Context *s = ctx->priv; int i; + ff_framesync2_uninit(&s->fs); av_frame_free(&s->prev_frame); for (i = 0; i < 4; i++) { @@ -212,14 +213,14 @@ static int process_frame(FFFrameSync *fs) AVFilterContext *ctx = fs->parent; LUT2Context *s = fs->opaque; AVFilterLink *outlink = ctx->outputs[0]; - AVFrame *out, *srcx, *srcy; + AVFrame *out, *srcx = NULL, *srcy = NULL; int ret; if ((ret = ff_framesync2_get_frame(&s->fs, 0, &srcx, 0)) < 0 || (ret = ff_framesync2_get_frame(&s->fs, 1, &srcy, 0)) < 0) return ret; - if (ctx->is_disabled) { + if (ctx->is_disabled || !srcy) { out = av_frame_clone(srcx); if (!out) return AVERROR(ENOMEM); @@ -332,7 +333,7 @@ static int lut2_config_output(AVFilterLink *outlink) in = s->fs.in; in[0].time_base = srcx->time_base; in[1].time_base = srcy->time_base; - in[0].sync = 1; + in[0].sync = 2; in[0].before = EXT_STOP; in[0].after = EXT_INFINITY; in[1].sync = 1; @@ -378,11 +379,12 @@ static const AVFilterPad outputs[] = { #define lut2_options options -AVFILTER_DEFINE_CLASS(lut2); +FRAMESYNC_DEFINE_CLASS(lut2, LUT2Context, fs); AVFilter ff_vf_lut2 = { .name = "lut2", .description = NULL_IF_CONFIG_SMALL("Compute and apply a lookup table from two video inputs."), + .preinit = lut2_framesync_preinit, .priv_size = sizeof(LUT2Context), .priv_class = &lut2_class, .uninit = uninit, |