]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_deflicker.c
Merge commit 'b420a27e74750b60d2e064236afb10be06a38ace'
[ffmpeg] / libavfilter / vf_deflicker.c
index e748109c8be184f18667727843b8d0a1658f624a..863a3508c1eca1595ecff811ec0a2280bde23086 100644 (file)
@@ -49,6 +49,7 @@ typedef struct DeflickerContext {
 
     int size;
     int mode;
+    int bypass;
 
     int eof;
     int depth;
@@ -84,6 +85,7 @@ static const AVOption deflicker_options[] = {
         { "cm",      "cubic mean",      0, AV_OPT_TYPE_CONST, {.i64=CUBIC_MEAN},       0, 0, FLAGS, "mode" },
         { "pm",      "power mean",      0, AV_OPT_TYPE_CONST, {.i64=POWER_MEAN},       0, 0, FLAGS, "mode" },
         { "median",  "median",          0, AV_OPT_TYPE_CONST, {.i64=MEDIAN},           0, 0, FLAGS, "mode" },
+    { "bypass", "leave frames unchanged",  OFFSET(bypass), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
     { NULL }
 };
 
@@ -92,7 +94,7 @@ AVFILTER_DEFINE_CLASS(deflicker);
 static int query_formats(AVFilterContext *ctx)
 {
     static const enum AVPixelFormat pixel_fmts[] = {
-        AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY10,
+        AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10,
         AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY16,
         AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
         AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
@@ -377,9 +379,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
     }
 
     s->get_factor(ctx, &f);
-    s->deflicker(ctx, in->data[0], in->linesize[0], out->data[0], out->linesize[0],
-                 outlink->w, outlink->h, f);
-    for (y = 1; y < s->nb_planes; y++) {
+    if (!s->bypass)
+        s->deflicker(ctx, in->data[0], in->linesize[0], out->data[0], out->linesize[0],
+                     outlink->w, outlink->h, f);
+    for (y = 1 - s->bypass; y < s->nb_planes; y++) {
         av_image_copy_plane(out->data[y], out->linesize[y],
                             in->data[y], in->linesize[y],
                             s->planewidth[y] * (1 + (s->depth > 8)), s->planeheight[y]);