mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avfilter/vf_lut2: add framesync options
Also stop leaking memory. Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
parent
9d99f0afbe
commit
a4d18a3f54
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user