[FFmpeg-cvslog] avfilter/vf_vectorscope: add yet another mode

Paul B Mahol git at videolan.org
Sat Aug 29 16:08:36 CEST 2015


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Aug 29 13:40:25 2015 +0000| [16229fae9c0da763061c679e766e9c66dd478b02] | committer: Paul B Mahol

avfilter/vf_vectorscope: add yet another mode

Signed-off-by: Paul B Mahol <onemda at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=16229fae9c0da763061c679e766e9c66dd478b02
---

 doc/filters.texi                         |    5 +++++
 libavfilter/vf_vectorscope.c             |   25 ++++++++++++++++++++++++-
 tests/fate/filter-video.mak              |    3 +++
 tests/ref/fate/filter-vectorscope_color4 |    4 ++++
 4 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index c9ac107..3b5f817 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -10587,6 +10587,11 @@ Actual color components values present in video frame are displayed on graph.
 Similar as color2 but higher frequency of same values @code{x} and @code{y}
 on graph increases value of another color component, which is luminance by
 default values of @code{x} and @code{y}.
+
+ at item color4
+Actual colors present in video frame are displayed on graph. If two different
+colors map to same position on graph then color with higher value of component
+not present in graph is picked.
 @end table
 
 @item x
diff --git a/libavfilter/vf_vectorscope.c b/libavfilter/vf_vectorscope.c
index dbcf675..88d69b7 100644
--- a/libavfilter/vf_vectorscope.c
+++ b/libavfilter/vf_vectorscope.c
@@ -32,6 +32,7 @@ enum VectorscopeMode {
     COLOR,
     COLOR2,
     COLOR3,
+    COLOR4,
     MODE_NB
 };
 
@@ -56,6 +57,7 @@ static const AVOption vectorscope_options[] = {
     { "color",  0, 0, AV_OPT_TYPE_CONST, {.i64=COLOR},  0, 0, FLAGS, "mode" },
     { "color2", 0, 0, AV_OPT_TYPE_CONST, {.i64=COLOR2}, 0, 0, FLAGS, "mode" },
     { "color3", 0, 0, AV_OPT_TYPE_CONST, {.i64=COLOR3}, 0, 0, FLAGS, "mode" },
+    { "color4", 0, 0, AV_OPT_TYPE_CONST, {.i64=COLOR4}, 0, 0, FLAGS, "mode" },
     { "x", "set color component on X axis", OFFSET(x), AV_OPT_TYPE_INT, {.i64=1}, 0, 2, FLAGS},
     { "y", "set color component on Y axis", OFFSET(y), AV_OPT_TYPE_INT, {.i64=2}, 0, 2, FLAGS},
     { "intensity", "set intensity", OFFSET(intensity), AV_OPT_TYPE_INT, {.i64=1}, 1, 255, FLAGS},
@@ -107,7 +109,8 @@ static int query_formats(AVFilterContext *ctx)
     if (!ctx->inputs[0]->out_formats) {
         const enum AVPixelFormat *in_pix_fmts;
 
-        if ((s->x == 1 && s->y == 2) || (s->x == 2 && s->y == 1))
+        if (((s->x == 1 && s->y == 2) || (s->x == 2 && s->y == 1)) &&
+            (s->mode != COLOR4))
             in_pix_fmts = in2_pix_fmts;
         else
             in_pix_fmts = in1_pix_fmts;
@@ -185,6 +188,7 @@ static void vectorscope(VectorscopeContext *s, AVFrame *in, AVFrame *out, int pd
     const uint8_t * const *src = (const uint8_t * const *)in->data;
     const int slinesizex = in->linesize[s->x];
     const int slinesizey = in->linesize[s->y];
+    const int slinesized = in->linesize[pd];
     const int dlinesize = out->linesize[0];
     const int intensity = s->intensity;
     int i, j, px = s->x, py = s->y;
@@ -192,6 +196,7 @@ static void vectorscope(VectorscopeContext *s, AVFrame *in, AVFrame *out, int pd
     const int w = s->planewidth[px];
     const uint8_t *spx = src[px];
     const uint8_t *spy = src[py];
+    const uint8_t *spd = src[pd];
     uint8_t **dst = out->data;
     uint8_t *dpx = dst[px];
     uint8_t *dpy = dst[py];
@@ -296,6 +301,24 @@ static void vectorscope(VectorscopeContext *s, AVFrame *in, AVFrame *out, int pd
             }
         }
         break;
+    case COLOR4:
+        for (i = 0; i < h; i++) {
+            const int iwx = i * slinesizex;
+            const int iwy = i * slinesizey;
+            const int iwd = i * slinesized;
+            for (j = 0; j < w; j++) {
+                const int x = spx[iwx + j];
+                const int y = spy[iwy + j];
+                const int pos = y * dlinesize + x;
+
+                dpd[pos] = FFMAX(spd[iwd + j], dpd[pos]);
+                dpx[pos] = x;
+                dpy[pos] = y;
+                if (dst[3])
+                    dst[3][pos] = 255;
+            }
+        }
+        break;
     default:
         av_assert0(0);
     }
diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 5bd5c98..c208d04 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -135,6 +135,9 @@ fate-filter-vectorscope_color2: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf vectors
 FATE_FILTER_VSYNTH-$(CONFIG_VECTORSCOPE_FILTER) += fate-filter-vectorscope_color3
 fate-filter-vectorscope_color3: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf vectorscope=color3 -sws_flags +accurate_rnd+bitexact -vframes 3
 
+FATE_FILTER_VSYNTH-$(CONFIG_VECTORSCOPE_FILTER) += fate-filter-vectorscope_color4
+fate-filter-vectorscope_color4: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf vectorscope=color4 -sws_flags +accurate_rnd+bitexact -vframes 3
+
 FATE_FILTER_VSYNTH-$(CONFIG_VECTORSCOPE_FILTER) += fate-filter-vectorscope_xy
 fate-filter-vectorscope_xy: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf vectorscope=x=0:y=1 -sws_flags +accurate_rnd+bitexact -vframes 3
 
diff --git a/tests/ref/fate/filter-vectorscope_color4 b/tests/ref/fate/filter-vectorscope_color4
new file mode 100644
index 0000000..137c189
--- /dev/null
+++ b/tests/ref/fate/filter-vectorscope_color4
@@ -0,0 +1,4 @@
+#tb 0: 1/25
+0,          0,          0,        1,   196608, 0xb6d22af1
+0,          1,          1,        1,   196608, 0xd7c6f971
+0,          2,          2,        1,   196608, 0xfe729faa



More information about the ffmpeg-cvslog mailing list