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

Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Paul B Mahol 2016-02-28 19:20:50 +01:00
parent c6f4720b86
commit 2ad1c87bb2
2 changed files with 32 additions and 4 deletions

View File

@ -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.
@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

View File

@ -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);
}
}
}
}
}