Commit eacb3ec9 authored by Nicolas George's avatar Nicolas George

lavfi/vf_lut3d: convert to framesync2.

parent a8ab52fa
...@@ -197,7 +197,7 @@ OBJS-$(CONFIG_FSPP_FILTER) += vf_fspp.o ...@@ -197,7 +197,7 @@ OBJS-$(CONFIG_FSPP_FILTER) += vf_fspp.o
OBJS-$(CONFIG_GBLUR_FILTER) += vf_gblur.o OBJS-$(CONFIG_GBLUR_FILTER) += vf_gblur.o
OBJS-$(CONFIG_GEQ_FILTER) += vf_geq.o OBJS-$(CONFIG_GEQ_FILTER) += vf_geq.o
OBJS-$(CONFIG_GRADFUN_FILTER) += vf_gradfun.o OBJS-$(CONFIG_GRADFUN_FILTER) += vf_gradfun.o
OBJS-$(CONFIG_HALDCLUT_FILTER) += vf_lut3d.o dualinput.o framesync.o OBJS-$(CONFIG_HALDCLUT_FILTER) += vf_lut3d.o framesync2.o
OBJS-$(CONFIG_HFLIP_FILTER) += vf_hflip.o OBJS-$(CONFIG_HFLIP_FILTER) += vf_hflip.o
OBJS-$(CONFIG_HISTEQ_FILTER) += vf_histeq.o OBJS-$(CONFIG_HISTEQ_FILTER) += vf_histeq.o
OBJS-$(CONFIG_HISTOGRAM_FILTER) += vf_histogram.o OBJS-$(CONFIG_HISTOGRAM_FILTER) += vf_histogram.o
......
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
#include "libavutil/avstring.h" #include "libavutil/avstring.h"
#include "avfilter.h" #include "avfilter.h"
#include "drawutils.h" #include "drawutils.h"
#include "dualinput.h"
#include "formats.h" #include "formats.h"
#include "framesync2.h"
#include "internal.h" #include "internal.h"
#include "video.h" #include "video.h"
...@@ -70,7 +70,7 @@ typedef struct LUT3DContext { ...@@ -70,7 +70,7 @@ typedef struct LUT3DContext {
int clut_step; int clut_step;
int clut_is16bit; int clut_is16bit;
int clut_width; int clut_width;
FFDualInputContext dinput; FFFrameSync fs;
#endif #endif
} LUT3DContext; } LUT3DContext;
...@@ -681,24 +681,21 @@ static int config_output(AVFilterLink *outlink) ...@@ -681,24 +681,21 @@ static int config_output(AVFilterLink *outlink)
LUT3DContext *lut3d = ctx->priv; LUT3DContext *lut3d = ctx->priv;
int ret; int ret;
ret = ff_framesync2_init_dualinput(&lut3d->fs, ctx);
if (ret < 0)
return ret;
outlink->w = ctx->inputs[0]->w; outlink->w = ctx->inputs[0]->w;
outlink->h = ctx->inputs[0]->h; outlink->h = ctx->inputs[0]->h;
outlink->time_base = ctx->inputs[0]->time_base; outlink->time_base = ctx->inputs[0]->time_base;
if ((ret = ff_dualinput_init(ctx, &lut3d->dinput)) < 0) if ((ret = ff_framesync2_configure(&lut3d->fs)) < 0)
return ret; return ret;
return 0; return 0;
} }
static int filter_frame_hald(AVFilterLink *inlink, AVFrame *inpicref) static int activate(AVFilterContext *ctx)
{
LUT3DContext *s = inlink->dst->priv;
return ff_dualinput_filter_frame(&s->dinput, inlink, inpicref);
}
static int request_frame(AVFilterLink *outlink)
{ {
LUT3DContext *s = outlink->src->priv; LUT3DContext *s = ctx->priv;
return ff_dualinput_request_frame(&s->dinput, outlink); return ff_framesync2_activate(&s->fs);
} }
static int config_clut(AVFilterLink *inlink) static int config_clut(AVFilterLink *inlink)
...@@ -751,45 +748,50 @@ static int config_clut(AVFilterLink *inlink) ...@@ -751,45 +748,50 @@ static int config_clut(AVFilterLink *inlink)
return 0; return 0;
} }
static AVFrame *update_apply_clut(AVFilterContext *ctx, AVFrame *main, static int update_apply_clut(FFFrameSync *fs)
const AVFrame *second)
{ {
AVFilterContext *ctx = fs->parent;
AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *inlink = ctx->inputs[0];
AVFrame *main, *second, *out;
int ret;
ret = ff_framesync2_dualinput_get(fs, &main, &second);
if (ret < 0)
return ret;
if (!second)
return ff_filter_frame(ctx->outputs[0], main);
update_clut(ctx->priv, second); update_clut(ctx->priv, second);
return apply_lut(inlink, main); out = apply_lut(inlink, main);
return ff_filter_frame(ctx->outputs[0], out);
} }
static av_cold int haldclut_init(AVFilterContext *ctx) static av_cold int haldclut_init(AVFilterContext *ctx)
{ {
LUT3DContext *lut3d = ctx->priv; LUT3DContext *lut3d = ctx->priv;
lut3d->dinput.process = update_apply_clut; lut3d->fs.on_event = update_apply_clut;
return 0; return 0;
} }
static av_cold void haldclut_uninit(AVFilterContext *ctx) static av_cold void haldclut_uninit(AVFilterContext *ctx)
{ {
LUT3DContext *lut3d = ctx->priv; LUT3DContext *lut3d = ctx->priv;
ff_dualinput_uninit(&lut3d->dinput); ff_framesync2_uninit(&lut3d->fs);
} }
static const AVOption haldclut_options[] = { static const AVOption haldclut_options[] = {
{ "shortest", "force termination when the shortest input terminates", OFFSET(dinput.shortest), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
{ "repeatlast", "continue applying the last clut after eos", OFFSET(dinput.repeatlast), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
COMMON_OPTIONS COMMON_OPTIONS
}; };
AVFILTER_DEFINE_CLASS(haldclut); FRAMESYNC_DEFINE_CLASS(haldclut, LUT3DContext, fs);
static const AVFilterPad haldclut_inputs[] = { static const AVFilterPad haldclut_inputs[] = {
{ {
.name = "main", .name = "main",
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
.filter_frame = filter_frame_hald,
.config_props = config_input, .config_props = config_input,
},{ },{
.name = "clut", .name = "clut",
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
.filter_frame = filter_frame_hald,
.config_props = config_clut, .config_props = config_clut,
}, },
{ NULL } { NULL }
...@@ -799,7 +801,6 @@ static const AVFilterPad haldclut_outputs[] = { ...@@ -799,7 +801,6 @@ static const AVFilterPad haldclut_outputs[] = {
{ {
.name = "default", .name = "default",
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
.request_frame = request_frame,
.config_props = config_output, .config_props = config_output,
}, },
{ NULL } { NULL }
...@@ -809,9 +810,11 @@ AVFilter ff_vf_haldclut = { ...@@ -809,9 +810,11 @@ AVFilter ff_vf_haldclut = {
.name = "haldclut", .name = "haldclut",
.description = NULL_IF_CONFIG_SMALL("Adjust colors using a Hald CLUT."), .description = NULL_IF_CONFIG_SMALL("Adjust colors using a Hald CLUT."),
.priv_size = sizeof(LUT3DContext), .priv_size = sizeof(LUT3DContext),
.preinit = haldclut_framesync_preinit,
.init = haldclut_init, .init = haldclut_init,
.uninit = haldclut_uninit, .uninit = haldclut_uninit,
.query_formats = query_formats, .query_formats = query_formats,
.activate = activate,
.inputs = haldclut_inputs, .inputs = haldclut_inputs,
.outputs = haldclut_outputs, .outputs = haldclut_outputs,
.priv_class = &haldclut_class, .priv_class = &haldclut_class,
......
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