[FFmpeg-cvslog] avfilter/vf_vectorscope: add color5 mode, mode like color but with higher saturation

Paul B Mahol git at videolan.org
Sun Feb 28 20:05:17 CET 2016


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Feb 28 19:20:50 2016 +0100| [2ad1c87bb260fc921878b04fa7729ab6cc7130e3] | committer: Paul B Mahol

avfilter/vf_vectorscope: add color5 mode, mode like color but with higher saturation

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

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

 doc/filters.texi             |    8 ++++++--
 libavfilter/vf_vectorscope.c |   28 ++++++++++++++++++++++++++--
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 7e7d8ff..67c0da7 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -12513,7 +12513,7 @@ same component color value on location in graph. This is the default mode.
 @item color
 Gray values are displayed on graph. Surrounding pixels values which are not
 present in video frame are drawn in gradient of 2 color components which are
-set by option @code{x} and @code{y}.
+set by option @code{x} and @code{y}. The 3rd color component is static.
 
 @item color2
 Actual color components values present in video frame are displayed on graph.
@@ -12527,6 +12527,10 @@ default values of @code{x} and @code{y}.
 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.
+
+ at item color5
+Gray values are displayed on graph. Similar to @code{color} but with 3rd color
+component picked from radial gradient.
 @end table
 
 @item x
@@ -12536,7 +12540,7 @@ Set which color component will be represented on X-axis. Default is @code{1}.
 Set which color component will be represented on Y-axis. Default is @code{2}.
 
 @item intensity, i
-Set intensity, used by modes: gray, color and color3 for increasing brightness
+Set intensity, used by modes: gray, color, color3 and color5 for increasing brightness
 of color component which represents frequency of (X, Y) location in graph.
 
 @item envelope, e
diff --git a/libavfilter/vf_vectorscope.c b/libavfilter/vf_vectorscope.c
index 2112b80..7389035 100644
--- a/libavfilter/vf_vectorscope.c
+++ b/libavfilter/vf_vectorscope.c
@@ -34,6 +34,7 @@ enum VectorscopeMode {
     COLOR2,
     COLOR3,
     COLOR4,
+    COLOR5,
     MODE_NB
 };
 
@@ -68,6 +69,7 @@ static const AVOption vectorscope_options[] = {
     {   "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" },
+    {   "color5", 0, 0, AV_OPT_TYPE_CONST, {.i64=COLOR5}, 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(fintensity), AV_OPT_TYPE_FLOAT, {.dbl=0.004}, 0, 1, FLAGS},
@@ -354,11 +356,12 @@ static void vectorscope16(VectorscopeContext *s, AVFrame *in, AVFrame *out, int
         for (i = 0; i < out->height ; i++)
             for (j = 0; j < out->width; j++)
                 AV_WN16(out->data[k] + i * out->linesize[k] + j * 2,
-                        s->mode == COLOR && k == s->pd ? 0 : s->bg_color[k] * mult);
+                        (s->mode == COLOR || s->mode == COLOR5) && k == s->pd ? 0 : s->bg_color[k] * mult);
     }
 
     switch (s->mode) {
     case COLOR:
+    case COLOR5:
     case GRAY:
         if (s->is_yuv) {
             for (i = 0; i < h; i++) {
@@ -480,6 +483,16 @@ static void vectorscope16(VectorscopeContext *s, AVFrame *in, AVFrame *out, int
                 }
             }
         }
+    } else if (s->mode == COLOR5) {
+        for (i = 0; i < out->height; i++) {
+            for (j = 0; j < out->width; j++) {
+                if (!dpd[i * dlinesize + j]) {
+                    dpx[i * dlinesize + j] = j;
+                    dpy[i * dlinesize + j] = i;
+                    dpd[i * dlinesize + j] = mid * M_SQRT2 - hypot(i - mid, j - mid);
+                }
+            }
+        }
     }
 }
 
@@ -508,9 +521,10 @@ static void vectorscope8(VectorscopeContext *s, AVFrame *in, AVFrame *out, int p
     for (k = 0; k < 4 && dst[k]; k++)
         for (i = 0; i < out->height ; i++)
             memset(dst[k] + i * out->linesize[k],
-                   s->mode == COLOR && k == s->pd ? 0 : s->bg_color[k], out->width);
+                   (s->mode == COLOR || s->mode == COLOR5) && k == s->pd ? 0 : s->bg_color[k], out->width);
 
     switch (s->mode) {
+    case COLOR5:
     case COLOR:
     case GRAY:
         if (s->is_yuv) {
@@ -633,6 +647,16 @@ static void vectorscope8(VectorscopeContext *s, AVFrame *in, AVFrame *out, int p
                 }
             }
         }
+    } else if (s->mode == COLOR5) {
+        for (i = 0; i < out->height; i++) {
+            for (j = 0; j < out->width; j++) {
+                if (!dpd[i * out->linesize[pd] + j]) {
+                    dpx[i * out->linesize[px] + j] = j;
+                    dpy[i * out->linesize[py] + j] = i;
+                    dpd[i * out->linesize[pd] + j] = 128 * M_SQRT2 - hypot(i - 128, j - 128);
+                }
+            }
+        }
     }
 }
 



More information about the ffmpeg-cvslog mailing list