Commit a4d18a3f authored by Paul B Mahol's avatar Paul B Mahol

avfilter/vf_lut2: add framesync options

Also stop leaking memory.
Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent 9d99f0af
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment