]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_lut.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavfilter / vf_lut.c
index 9c8b4123cf691e43bd80a10facbc70fe45540a5a..a9b9e8aaecc66e31e5d075e3626be595af739a70 100644 (file)
@@ -91,13 +91,9 @@ static const AVOption lut_options[] = {
     {NULL},
 };
 
-static const AVClass lut_class = {
-    "LutContext",
-    av_default_item_name,
-    lut_options
-};
+AVFILTER_DEFINE_CLASS(lut);
 
-static int init(AVFilterContext *ctx, const char *args, void *opaque)
+static int init(AVFilterContext *ctx, const char *args)
 {
     LutContext *lut = ctx->priv;
     int ret;
@@ -279,7 +275,7 @@ static int config_props(AVFilterLink *inlink)
     return 0;
 }
 
-static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
+static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
 {
     AVFilterContext *ctx = inlink->dst;
     LutContext *lut = ctx->priv;
@@ -325,9 +321,9 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
             inrow  = inpic ->data[plane] + (y>>vsub) * inpic ->linesize[plane];
             outrow = outpic->data[plane] + (y>>vsub) * outpic->linesize[plane];
 
-            for (i = 0; i < h>>vsub; i ++) {
+            for (i = 0; i < (h + (1<<vsub) - 1)>>vsub; i ++) {
                 const uint8_t *tab = lut->lut[plane];
-                int w = inlink->w>>hsub;
+                int w = (inlink->w + (1<<hsub) - 1)>>hsub;
                 for (j = 0; j < w; j++)
                     outrow[j] = tab[inrow[j]];
                 inrow  += inpic ->linesize[plane];
@@ -336,9 +332,22 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
         }
     }
 
-    ff_draw_slice(outlink, y, h, slice_dir);
+    return ff_draw_slice(outlink, y, h, slice_dir);
 }
 
+static const AVFilterPad inputs[] = {
+    { .name            = "default",
+      .type            = AVMEDIA_TYPE_VIDEO,
+      .draw_slice      = draw_slice,
+      .config_props    = config_props,
+      .min_perms       = AV_PERM_READ, },
+    { .name = NULL}
+};
+static const AVFilterPad outputs[] = {
+    { .name            = "default",
+      .type            = AVMEDIA_TYPE_VIDEO, },
+    { .name = NULL}
+};
 #define DEFINE_LUT_FILTER(name_, description_, init_)                   \
     AVFilter avfilter_vf_##name_ = {                                    \
         .name          = #name_,                                        \
@@ -349,15 +358,8 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
         .uninit        = uninit,                                        \
         .query_formats = query_formats,                                 \
                                                                         \
-        .inputs    = (const AVFilterPad[]) {{ .name      = "default",   \
-                                        .type            = AVMEDIA_TYPE_VIDEO, \
-                                        .draw_slice      = draw_slice,  \
-                                        .config_props    = config_props, \
-                                        .min_perms       = AV_PERM_READ, }, \
-                                      { .name = NULL}},                 \
-        .outputs   = (const AVFilterPad[]) {{ .name      = "default",   \
-                                        .type            = AVMEDIA_TYPE_VIDEO, }, \
-                                      { .name = NULL}},                 \
+        .inputs        = inputs,                                        \
+        .outputs       = outputs,                                       \
     }
 
 #if CONFIG_LUT_FILTER
@@ -372,7 +374,7 @@ DEFINE_LUT_FILTER(lutrgb, "Compute and apply a lookup table to the RGB input vid
 
 #if CONFIG_NEGATE_FILTER
 
-static int negate_init(AVFilterContext *ctx, const char *args, void *opaque)
+static int negate_init(AVFilterContext *ctx, const char *args)
 {
     LutContext *lut = ctx->priv;
     char lut_params[64];
@@ -385,7 +387,7 @@ static int negate_init(AVFilterContext *ctx, const char *args, void *opaque)
     snprintf(lut_params, sizeof(lut_params), "c0=negval:c1=negval:c2=negval:a=%s",
              lut->negate_alpha ? "negval" : "val");
 
-    return init(ctx, lut_params, opaque);
+    return init(ctx, lut_params);
 }
 
 DEFINE_LUT_FILTER(negate, "Negate input video.", negate_init);