]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_lut2.c
Merge commit '07a2b155949eb267cdfc7805f42c7b3375f9c7c5'
[ffmpeg] / libavfilter / vf_lut2.c
index 0859285382a7992183c7f927a67666b564002b93..585d121ca35395043a5c005a1cdf92b29331bcf0 100644 (file)
@@ -28,7 +28,7 @@
 #include "formats.h"
 #include "internal.h"
 #include "video.h"
-#include "framesync2.h"
+#include "framesync.h"
 
 static const char *const var_names[] = {
     "w",        ///< width of the input video
@@ -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_framesync_uninit(&s->fs);
     av_frame_free(&s->prev_frame);
 
     for (i = 0; i < 4; i++) {
@@ -110,8 +111,8 @@ static int query_formats(AVFilterContext *ctx)
         AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA444P10,
         AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10,
         AV_PIX_FMT_GBRP12,
-        AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRAP12,
-        AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12,
+        AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12,
+        AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12,
         AV_PIX_FMT_NONE
     };
 
@@ -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)
+    if ((ret = ff_framesync_get_frame(&s->fs, 0, &srcx, 0)) < 0 ||
+        (ret = ff_framesync_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);
@@ -326,13 +327,13 @@ static int lut2_config_output(AVFilterLink *outlink)
     outlink->sample_aspect_ratio = srcx->sample_aspect_ratio;
     outlink->frame_rate = srcx->frame_rate;
 
-    if ((ret = ff_framesync2_init(&s->fs, ctx, 2)) < 0)
+    if ((ret = ff_framesync_init(&s->fs, ctx, 2)) < 0)
         return ret;
 
     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;
@@ -344,13 +345,13 @@ static int lut2_config_output(AVFilterLink *outlink)
     if ((ret = config_output(outlink)) < 0)
         return ret;
 
-    return ff_framesync2_configure(&s->fs);
+    return ff_framesync_configure(&s->fs);
 }
 
 static int activate(AVFilterContext *ctx)
 {
     LUT2Context *s = ctx->priv;
-    return ff_framesync2_activate(&s->fs);
+    return ff_framesync_activate(&s->fs);
 }
 
 static const AVFilterPad inputs[] = {
@@ -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,