]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_waveform.c
avfilter: Constify all AVFilters
[ffmpeg] / libavfilter / vf_waveform.c
index 9e708b277825a9a729b19514e87c1c0d110fb310..2fa1815d6ca128fafba79db16064f2822f34f5e2 100644 (file)
@@ -45,6 +45,7 @@ enum FilterType {
     COLOR,
     ACOLOR,
     XFLAT,
+    YFLAT,
     NB_FILTERS
 };
 
@@ -111,6 +112,8 @@ typedef struct WaveformContext {
     GraticuleLines *glines;
     int            nb_glines;
     int            rgb;
+    float          ftint[2];
+    int            tint[2];
 
     int (*waveform_slice)(AVFilterContext *ctx, void *arg,
                           int jobnr, int nb_jobs);
@@ -158,6 +161,7 @@ static const AVOption waveform_options[] = {
         { "color",   NULL, 0, AV_OPT_TYPE_CONST, {.i64=COLOR},   0, 0, FLAGS, "filter" },
         { "acolor",  NULL, 0, AV_OPT_TYPE_CONST, {.i64=ACOLOR},  0, 0, FLAGS, "filter" },
         { "xflat",   NULL, 0, AV_OPT_TYPE_CONST, {.i64=XFLAT},   0, 0, FLAGS, "filter" },
+        { "yflat",   NULL, 0, AV_OPT_TYPE_CONST, {.i64=YFLAT},   0, 0, FLAGS, "filter" },
     { "graticule", "set graticule", OFFSET(graticule), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_GRATICULES-1, FLAGS, "graticule" },
     { "g",         "set graticule", OFFSET(graticule), AV_OPT_TYPE_INT, {.i64=0}, 0, NB_GRATICULES-1, FLAGS, "graticule" },
         { "none",   NULL, 0, AV_OPT_TYPE_CONST, {.i64=GRAT_NONE},   0, 0, FLAGS, "graticule" },
@@ -177,6 +181,10 @@ static const AVOption waveform_options[] = {
         { "ire",        NULL, 0, AV_OPT_TYPE_CONST, {.i64=IRE},        0, 0, FLAGS, "scale" },
     { "bgopacity", "set background opacity", OFFSET(bgopacity), AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 1, FLAGS },
     { "b",         "set background opacity", OFFSET(bgopacity), AV_OPT_TYPE_FLOAT, {.dbl=0.75}, 0, 1, FLAGS },
+    { "tint0", "set 1st tint", OFFSET(ftint[0]), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, FLAGS},
+    { "t0",    "set 1st tint", OFFSET(ftint[0]), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, FLAGS},
+    { "tint1", "set 2nd tint", OFFSET(ftint[1]), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, FLAGS},
+    { "t1",    "set 2nd tint", OFFSET(ftint[1]), AV_OPT_TYPE_FLOAT, {.dbl=0}, -1, 1, FLAGS},
     { NULL }
 };
 
@@ -197,6 +205,7 @@ static const enum AVPixelFormat in_lowpass_pix_fmts[] = {
     AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV420P10,
     AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA420P10,
     AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV440P12,
+    AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA422P12,
     AV_PIX_FMT_NONE
 };
 
@@ -214,6 +223,7 @@ static const enum AVPixelFormat in_color_pix_fmts[] = {
     AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV420P10,
     AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA420P10,
     AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV440P12,
+    AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA422P12,
     AV_PIX_FMT_NONE
 };
 
@@ -229,6 +239,7 @@ static const enum AVPixelFormat in_flat_pix_fmts[] = {
     AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV420P10,
     AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA420P10,
     AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV440P12,
+    AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_YUVA422P12,
     AV_PIX_FMT_NONE
 };
 
@@ -268,7 +279,7 @@ static const enum AVPixelFormat out_yuv10_lowpass_pix_fmts[] = {
 };
 
 static const enum AVPixelFormat out_yuv12_lowpass_pix_fmts[] = {
-    AV_PIX_FMT_YUV444P12,
+    AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUVA444P12,
     AV_PIX_FMT_NONE
 };
 
@@ -292,13 +303,6 @@ static const enum AVPixelFormat out_gray12_lowpass_pix_fmts[] = {
     AV_PIX_FMT_NONE
 };
 
-static const enum AVPixelFormat flat_pix_fmts[] = {
-    AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P,
-    AV_PIX_FMT_YUV444P9, AV_PIX_FMT_YUV444P10,
-    AV_PIX_FMT_YUV444P12,
-    AV_PIX_FMT_NONE
-};
-
 static int query_formats(AVFilterContext *ctx)
 {
     WaveformContext *s = ctx->priv;
@@ -308,8 +312,8 @@ static int query_formats(AVFilterContext *ctx)
     AVFilterFormats *avff, *avff2;
     int depth, depth2, rgb, i, ret, ncomp, ncomp2;
 
-    if (!ctx->inputs[0]->in_formats ||
-        !ctx->inputs[0]->in_formats->nb_formats) {
+    if (!ctx->inputs[0]->incfg.formats ||
+        !ctx->inputs[0]->incfg.formats->nb_formats) {
         return AVERROR(EAGAIN);
     }
 
@@ -317,6 +321,7 @@ static int query_formats(AVFilterContext *ctx)
     case LOWPASS: in_pix_fmts = in_lowpass_pix_fmts; break;
     case CHROMA:
     case XFLAT:
+    case YFLAT:
     case AFLAT:
     case FLAT:    in_pix_fmts = in_flat_pix_fmts;    break;
     case ACOLOR:
@@ -324,13 +329,13 @@ static int query_formats(AVFilterContext *ctx)
     default: return AVERROR_BUG;
     }
 
-    if (!ctx->inputs[0]->out_formats) {
-        if ((ret = ff_formats_ref(ff_make_format_list(in_pix_fmts), &ctx->inputs[0]->out_formats)) < 0)
+    if (!ctx->inputs[0]->outcfg.formats) {
+        if ((ret = ff_formats_ref(ff_make_format_list(in_pix_fmts), &ctx->inputs[0]->outcfg.formats)) < 0)
             return ret;
     }
 
-    avff = ctx->inputs[0]->in_formats;
-    avff2 = ctx->inputs[0]->out_formats;
+    avff = ctx->inputs[0]->incfg.formats;
+    avff2 = ctx->inputs[0]->outcfg.formats;
     desc = av_pix_fmt_desc_get(avff->formats[0]);
     desc2 = av_pix_fmt_desc_get(avff2->formats[0]);
     ncomp = desc->nb_components;
@@ -373,7 +378,7 @@ static int query_formats(AVFilterContext *ctx)
         out_pix_fmts = out_yuv12_lowpass_pix_fmts;
     else
         return AVERROR(EAGAIN);
-    if ((ret = ff_formats_ref(ff_make_format_list(out_pix_fmts), &ctx->outputs[0]->in_formats)) < 0)
+    if ((ret = ff_formats_ref(ff_make_format_list(out_pix_fmts), &ctx->outputs[0]->incfg.formats)) < 0)
         return ret;
 
     return 0;
@@ -675,10 +680,11 @@ static av_always_inline void lowpass16(WaveformContext *s,
                                        int jobnr, int nb_jobs)
 {
     const int plane = s->desc->comp[component].plane;
+    const int dplane = (s->rgb || s->display == OVERLAY) ? plane : 0;
     const int shift_w = s->shift_w[component];
     const int shift_h = s->shift_h[component];
     const int src_linesize = in->linesize[plane] / 2;
-    const int dst_linesize = out->linesize[plane] / 2;
+    const int dst_linesize = out->linesize[dplane] / 2;
     const int dst_signed_linesize = dst_linesize * (mirror == 1 ? -1 : 1);
     const int limit = s->max - 1;
     const int max = limit - intensity;
@@ -690,7 +696,7 @@ static av_always_inline void lowpass16(WaveformContext *s,
     const int slicew_end = column ? (src_w * (jobnr+1)) / nb_jobs : src_w;
     const int step = column ? 1 << shift_w : 1 << shift_h;
     const uint16_t *src_data = (const uint16_t *)in->data[plane] + sliceh_start * src_linesize;
-    uint16_t *dst_data = (uint16_t *)out->data[plane] + (offset_y + sliceh_start * step) * dst_linesize + offset_x;
+    uint16_t *dst_data = (uint16_t *)out->data[dplane] + (offset_y + sliceh_start * step) * dst_linesize + offset_x;
     uint16_t * const dst_bottom_line = dst_data + dst_linesize * (s->size - 1);
     uint16_t * const dst_line = (mirror ? dst_bottom_line : dst_data);
     const uint16_t *p;
@@ -727,6 +733,56 @@ static av_always_inline void lowpass16(WaveformContext *s,
         src_data += src_linesize;
         dst_data += dst_linesize * step;
     }
+
+    if (s->display != OVERLAY && column && !s->rgb) {
+        const int mult = s->max / 256;
+        const int bg = s->bg_color[0] * mult;
+        const int t0 = s->tint[0];
+        const int t1 = s->tint[1];
+        uint16_t *dst0, *dst1;
+        const uint16_t *src;
+        int x;
+
+        src  = (const uint16_t *)(out->data[0]) + offset_y * dst_linesize + offset_x;
+        dst0 = (uint16_t *)(out->data[1]) + offset_y * dst_linesize + offset_x;
+        dst1 = (uint16_t *)(out->data[2]) + offset_y * dst_linesize + offset_x;
+        for (y = 0; y < s->max; y++) {
+            for (x = slicew_start * step; x < slicew_end * step; x++) {
+                if (src[x] != bg) {
+                    dst0[x] = t0;
+                    dst1[x] = t1;
+                }
+            }
+
+            src  += dst_linesize;
+            dst0 += dst_linesize;
+            dst1 += dst_linesize;
+        }
+    } else if (s->display != OVERLAY && !s->rgb) {
+        const int mult = s->max / 256;
+        const int bg = s->bg_color[0] * mult;
+        const int t0 = s->tint[0];
+        const int t1 = s->tint[1];
+        uint16_t *dst0, *dst1;
+        const uint16_t *src;
+        int x;
+
+        src  = (const uint16_t *)out->data[0] + (offset_y + sliceh_start * step) * dst_linesize + offset_x;
+        dst0 = (uint16_t *)(out->data[1]) + (offset_y + sliceh_start * step) * dst_linesize + offset_x;
+        dst1 = (uint16_t *)(out->data[2]) + (offset_y + sliceh_start * step) * dst_linesize + offset_x;
+        for (y = sliceh_start * step; y < sliceh_end * step; y++) {
+            for (x = 0; x < s->max; x++) {
+                if (src[x] != bg) {
+                    dst0[x] = t0;
+                    dst1[x] = t1;
+                }
+            }
+
+            src  += dst_linesize;
+            dst0 += dst_linesize;
+            dst1 += dst_linesize;
+        }
+    }
 }
 
 #define LOWPASS16_FUNC(name, column, mirror)        \
@@ -762,10 +818,11 @@ static av_always_inline void lowpass(WaveformContext *s,
                                      int jobnr, int nb_jobs)
 {
     const int plane = s->desc->comp[component].plane;
+    const int dplane = (s->rgb || s->display == OVERLAY) ? plane : 0;
     const int shift_w = s->shift_w[component];
     const int shift_h = s->shift_h[component];
     const int src_linesize = in->linesize[plane];
-    const int dst_linesize = out->linesize[plane];
+    const int dst_linesize = out->linesize[dplane];
     const int dst_signed_linesize = dst_linesize * (mirror == 1 ? -1 : 1);
     const int max = 255 - intensity;
     const int src_h = AV_CEIL_RSHIFT(in->height, shift_h);
@@ -776,7 +833,7 @@ static av_always_inline void lowpass(WaveformContext *s,
     const int slicew_end = column ? (src_w * (jobnr+1)) / nb_jobs : src_w;
     const int step = column ? 1 << shift_w : 1 << shift_h;
     const uint8_t *src_data = in->data[plane] + sliceh_start * src_linesize;
-    uint8_t *dst_data = out->data[plane] + (offset_y + sliceh_start * step) * dst_linesize + offset_x;
+    uint8_t *dst_data = out->data[dplane] + (offset_y + sliceh_start * step) * dst_linesize + offset_x;
     uint8_t * const dst_bottom_line = dst_data + dst_linesize * (s->size - 1);
     uint8_t * const dst_line = (mirror ? dst_bottom_line : dst_data);
     const uint8_t *p;
@@ -791,48 +848,76 @@ static av_always_inline void lowpass(WaveformContext *s,
 
         for (p = src_data + slicew_start; p < src_data_end; p++) {
             uint8_t *target;
+            int i = 0;
+
             if (column) {
-                target = dst + dst_signed_linesize * *p;
-                dst += step;
-                update(target, max, intensity);
+                do {
+                    target = dst++ + dst_signed_linesize * *p;
+                    update(target, max, intensity);
+                } while (++i < step);
             } else {
                 uint8_t *row = dst_data;
-                if (mirror)
-                    target = row - *p - 1;
-                else
-                    target = row + *p;
-                update(target, max, intensity);
-                row += dst_linesize;
+                do {
+                    if (mirror)
+                        target = row - *p - 1;
+                    else
+                        target = row + *p;
+                    update(target, max, intensity);
+                    row += dst_linesize;
+                } while (++i < step);
             }
         }
         src_data += src_linesize;
         dst_data += dst_linesize * step;
     }
 
-    if (column && step > 1) {
+    if (s->display != OVERLAY && column && !s->rgb) {
+        const int bg = s->bg_color[0];
         const int dst_h = 256;
-        uint8_t *dst;
-        int x, z;
-
-        dst = out->data[plane] + offset_y * dst_linesize + offset_x;
+        const int t0 = s->tint[0];
+        const int t1 = s->tint[1];
+        uint8_t *dst0, *dst1;
+        const uint8_t *src;
+        int x;
+
+        src  = out->data[0] + offset_y * dst_linesize + offset_x;
+        dst0 = out->data[1] + offset_y * dst_linesize + offset_x;
+        dst1 = out->data[2] + offset_y * dst_linesize + offset_x;
         for (y = 0; y < dst_h; y++) {
-            for (x = slicew_start * step; x < slicew_end * step; x+=step) {
-                for (z = 1; z < step; z++) {
-                    dst[x + z] = dst[x];
+            for (x = slicew_start * step; x < slicew_end * step; x++) {
+                if (src[x] != bg) {
+                    dst0[x] = t0;
+                    dst1[x] = t1;
                 }
             }
-            dst += dst_linesize;
+
+            src  += dst_linesize;
+            dst0 += dst_linesize;
+            dst1 += dst_linesize;
         }
-    } else if (step > 1) {
+    } else if (s->display != OVERLAY && !s->rgb) {
+        const int bg = s->bg_color[0];
         const int dst_w = 256;
-        uint8_t *dst;
-        int z;
+        const int t0 = s->tint[0];
+        const int t1 = s->tint[1];
+        uint8_t *dst0, *dst1;
+        const uint8_t *src;
+        int x;
+
+        src  = out->data[0] + (offset_y + sliceh_start * step) * dst_linesize + offset_x;
+        dst0 = out->data[1] + (offset_y + sliceh_start * step) * dst_linesize + offset_x;
+        dst1 = out->data[2] + (offset_y + sliceh_start * step) * dst_linesize + offset_x;
+        for (y = sliceh_start * step; y < sliceh_end * step; y++) {
+            for (x = 0; x < dst_w; x++) {
+                if (src[x] != bg) {
+                    dst0[x] = t0;
+                    dst1[x] = t1;
+                }
+            }
 
-        dst = out->data[plane] + (offset_y + sliceh_start * step) * dst_linesize + offset_x;
-        for (y = sliceh_start * step; y < sliceh_end * step; y+=step) {
-            for (z = 1; z < step; z++)
-                memcpy(dst + dst_linesize * z, dst, dst_w);
-            dst += dst_linesize * step;
+            src  += dst_linesize;
+            dst0 += dst_linesize;
+            dst1 += dst_linesize;
         }
     }
 }
@@ -1138,7 +1223,7 @@ FLAT_FUNC(column,        1, 0)
 FLAT_FUNC(row_mirror,    0, 1)
 FLAT_FUNC(row,           0, 0)
 
-#define AFLAT16(name, update_cr, column, mirror)                                                                   \
+#define AFLAT16(name, update_cb, update_cr, column, mirror)                                                        \
 static int name(AVFilterContext *ctx,                                                                              \
                 void *arg, int jobnr,                                                                              \
                 int nb_jobs)                                                                                       \
@@ -1204,7 +1289,7 @@ static int name(AVFilterContext *ctx,
                 update16(target, max, intensity, limit);                                                           \
                                                                                                                    \
                 target = d1 + x + d1_signed_linesize * (c0 + c1);                                                  \
-                update16(target, max, intensity, limit);                                                           \
+                update_cb(target, max, intensity, limit);                                                          \
                                                                                                                    \
                 target = d2 + x + d2_signed_linesize * (c0 + c2);                                                  \
                 update_cr(target, max, intensity, limit);                                                          \
@@ -1245,14 +1330,14 @@ static int name(AVFilterContext *ctx,
                     target = d0_data - c0;                                                                         \
                     update16(target, max, intensity, limit);                                                       \
                     target = d1_data - (c0 + c1);                                                                  \
-                    update16(target, max, intensity, limit);                                                       \
+                    update_cb(target, max, intensity, limit);                                                      \
                     target = d2_data - (c0 + c2);                                                                  \
                     update_cr(target, max, intensity, limit);                                                      \
                 } else {                                                                                           \
                     target = d0_data + c0;                                                                         \
                     update16(target, max, intensity, limit);                                                       \
                     target = d1_data + (c0 + c1);                                                                  \
-                    update16(target, max, intensity, limit);                                                       \
+                    update_cb(target, max, intensity, limit);                                                      \
                     target = d2_data + (c0 + c2);                                                                  \
                     update_cr(target, max, intensity, limit);                                                      \
                 }                                                                                                  \
@@ -1272,7 +1357,7 @@ static int name(AVFilterContext *ctx,
     return 0;                                                                                                      \
 }
 
-#define AFLAT(name, update_cr, column, mirror)                                                        \
+#define AFLAT(name, update_cb, update_cr, column, mirror)                                             \
 static int name(AVFilterContext *ctx,                                                                 \
                 void *arg, int jobnr,                                                                 \
                 int nb_jobs)                                                                          \
@@ -1336,7 +1421,7 @@ static int name(AVFilterContext *ctx,
                 update(target, max, intensity);                                                       \
                                                                                                       \
                 target = d1 + x + d1_signed_linesize * (c0 + c1);                                     \
-                update(target, max, intensity);                                                       \
+                update_cb(target, max, intensity);                                                    \
                                                                                                       \
                 target = d2 + x + d2_signed_linesize * (c0 + c2);                                     \
                 update_cr(target, max, intensity);                                                    \
@@ -1345,8 +1430,8 @@ static int name(AVFilterContext *ctx,
                     c0_data += c0_linesize;                                                           \
                 if (!c1_shift_h || (y & c1_shift_h))                                                  \
                     c1_data += c1_linesize;                                                           \
-                if (!c1_shift_h || (y & c1_shift_h))                                                  \
-                    c2_data += c1_linesize;                                                           \
+                if (!c2_shift_h || (y & c2_shift_h))                                                  \
+                    c2_data += c2_linesize;                                                           \
                 d0_data += d0_linesize;                                                               \
                 d1_data += d1_linesize;                                                               \
                 d2_data += d2_linesize;                                                               \
@@ -1377,14 +1462,14 @@ static int name(AVFilterContext *ctx,
                     target = d0_data - c0;                                                            \
                     update(target, max, intensity);                                                   \
                     target = d1_data - (c0 + c1);                                                     \
-                    update(target, max, intensity);                                                   \
+                    update_cb(target, max, intensity);                                                \
                     target = d2_data - (c0 + c2);                                                     \
                     update_cr(target, max, intensity);                                                \
                 } else {                                                                              \
                     target = d0_data + c0;                                                            \
                     update(target, max, intensity);                                                   \
                     target = d1_data + (c0 + c1);                                                     \
-                    update(target, max, intensity);                                                   \
+                    update_cb(target, max, intensity);                                                \
                     target = d2_data + (c0 + c2);                                                     \
                     update_cr(target, max, intensity);                                                \
                 }                                                                                     \
@@ -1404,23 +1489,31 @@ static int name(AVFilterContext *ctx,
     return 0;                                                                                         \
 }
 
-AFLAT16(aflat16_row,           update16,    0, 0)
-AFLAT16(aflat16_row_mirror,    update16,    0, 1)
-AFLAT16(aflat16_column,        update16,    1, 0)
-AFLAT16(aflat16_column_mirror, update16,    1, 1)
-AFLAT16(xflat16_row,           update16_cr, 0, 0)
-AFLAT16(xflat16_row_mirror,    update16_cr, 0, 1)
-AFLAT16(xflat16_column,        update16_cr, 1, 0)
-AFLAT16(xflat16_column_mirror, update16_cr, 1, 1)
-
-AFLAT(aflat_row,           update,    0, 0)
-AFLAT(aflat_row_mirror,    update,    0, 1)
-AFLAT(aflat_column,        update,    1, 0)
-AFLAT(aflat_column_mirror, update,    1, 1)
-AFLAT(xflat_row,           update_cr, 0, 0)
-AFLAT(xflat_row_mirror,    update_cr, 0, 1)
-AFLAT(xflat_column,        update_cr, 1, 0)
-AFLAT(xflat_column_mirror, update_cr, 1, 1)
+AFLAT16(aflat16_row,           update16, update16,    0, 0)
+AFLAT16(aflat16_row_mirror,    update16, update16,    0, 1)
+AFLAT16(aflat16_column,        update16, update16,    1, 0)
+AFLAT16(aflat16_column_mirror, update16, update16,    1, 1)
+AFLAT16(xflat16_row,           update16, update16_cr, 0, 0)
+AFLAT16(xflat16_row_mirror,    update16, update16_cr, 0, 1)
+AFLAT16(xflat16_column,        update16, update16_cr, 1, 0)
+AFLAT16(xflat16_column_mirror, update16, update16_cr, 1, 1)
+AFLAT16(yflat16_row,           update16_cr, update16_cr, 0, 0)
+AFLAT16(yflat16_row_mirror,    update16_cr, update16_cr, 0, 1)
+AFLAT16(yflat16_column,        update16_cr, update16_cr, 1, 0)
+AFLAT16(yflat16_column_mirror, update16_cr, update16_cr, 1, 1)
+
+AFLAT(aflat_row,           update, update,    0, 0)
+AFLAT(aflat_row_mirror,    update, update,    0, 1)
+AFLAT(aflat_column,        update, update,    1, 0)
+AFLAT(aflat_column_mirror, update, update,    1, 1)
+AFLAT(xflat_row,           update, update_cr, 0, 0)
+AFLAT(xflat_row_mirror,    update, update_cr, 0, 1)
+AFLAT(xflat_column,        update, update_cr, 1, 0)
+AFLAT(xflat_column_mirror, update, update_cr, 1, 1)
+AFLAT(yflat_row,           update_cr, update_cr, 0, 0)
+AFLAT(yflat_row_mirror,    update_cr, update_cr, 0, 1)
+AFLAT(yflat_column,        update_cr, update_cr, 1, 0)
+AFLAT(yflat_column_mirror, update_cr, update_cr, 1, 1)
 
 static av_always_inline void chroma16(WaveformContext *s,
                                       AVFrame *in, AVFrame *out,
@@ -2957,6 +3050,7 @@ static int config_input(AVFilterLink *inlink)
 
     switch (s->filter) {
     case XFLAT:
+    case YFLAT:
     case AFLAT: s->size = 256 * 2; break;
     case FLAT:  s->size = 256 * 3; break;
     default:    s->size = 256;     break;
@@ -3020,6 +3114,14 @@ static int config_input(AVFilterLink *inlink)
     case 0x1016: s->waveform_slice = xflat16_row_mirror;    break;
     case 0x0116: s->waveform_slice = xflat16_column;        break;
     case 0x0016: s->waveform_slice = xflat16_row;           break;
+    case 0x1107: s->waveform_slice = yflat_column_mirror; break;
+    case 0x1007: s->waveform_slice = yflat_row_mirror;    break;
+    case 0x0107: s->waveform_slice = yflat_column;        break;
+    case 0x0007: s->waveform_slice = yflat_row;           break;
+    case 0x1117: s->waveform_slice = yflat16_column_mirror; break;
+    case 0x1017: s->waveform_slice = yflat16_row_mirror;    break;
+    case 0x0117: s->waveform_slice = yflat16_column;        break;
+    case 0x0017: s->waveform_slice = yflat16_row;           break;
     }
 
     s->grat_yuva_color[0] = 255;
@@ -3048,6 +3150,7 @@ static int config_input(AVFilterLink *inlink)
     case CHROMA:
     case AFLAT:
     case XFLAT:
+    case YFLAT:
     case FLAT:
         if (s->graticule > GRAT_NONE && s->mode == 1)
             s->graticulef = s->bits > 8 ? graticule16_column : graticule_column;
@@ -3116,6 +3219,7 @@ static int config_input(AVFilterLink *inlink)
         }
         break;
     case XFLAT:
+    case YFLAT:
     case AFLAT:
         switch (s->scale) {
         case DIGITAL:
@@ -3176,6 +3280,9 @@ static int config_input(AVFilterLink *inlink)
 
     s->size = s->size << (s->bits - 8);
 
+    s->tint[0] = .5f * (s->ftint[0] + 1.f) * (s->size - 1);
+    s->tint[1] = .5f * (s->ftint[1] + 1.f) * (s->size - 1);
+
     switch (inlink->format) {
     case AV_PIX_FMT_GBRAP:
     case AV_PIX_FMT_GBRP:
@@ -3312,10 +3419,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             td.offset_x = offset_x;
             ctx->internal->execute(ctx, s->waveform_slice, &td, NULL, ff_filter_get_nb_threads(ctx));
             switch (s->filter) {
+            case LOWPASS:
+                if (s->bits <= 8)
+                    envelope(s, out, plane, s->rgb || s->display == OVERLAY ? plane : 0, s->mode ? offset_x : offset_y);
+                else
+                    envelope16(s, out, plane, s->rgb || s->display == OVERLAY ? plane : 0, s->mode ? offset_x : offset_y);
+                break;
             case ACOLOR:
             case CHROMA:
             case COLOR:
-            case LOWPASS:
                 if (s->bits <= 8)
                     envelope(s, out, plane, plane, s->mode ? offset_x : offset_y);
                 else
@@ -3332,6 +3444,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
                 break;
             case AFLAT:
             case XFLAT:
+            case YFLAT:
                 if (s->bits <= 8) {
                     envelope(s, out, plane, (plane + 0) % s->ncomp, s->mode ? offset_x : offset_y);
                     envelope(s, out, plane, (plane + 1) % s->ncomp, s->mode ? offset_x : offset_y);
@@ -3377,7 +3490,7 @@ static const AVFilterPad outputs[] = {
     { NULL }
 };
 
-AVFilter ff_vf_waveform = {
+const AVFilter ff_vf_waveform = {
     .name          = "waveform",
     .description   = NULL_IF_CONFIG_SMALL("Video waveform monitor."),
     .priv_size     = sizeof(WaveformContext),