Commit 16229fae authored by Paul B Mahol's avatar Paul B Mahol

avfilter/vf_vectorscope: add yet another mode

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent b48d8fa3
...@@ -10587,6 +10587,11 @@ Actual color components values present in video frame are displayed on graph. ...@@ -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} 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 on graph increases value of another color component, which is luminance by
default values of @code{x} and @code{y}. default values of @code{x} and @code{y}.
@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 @end table
@item x @item x
......
...@@ -32,6 +32,7 @@ enum VectorscopeMode { ...@@ -32,6 +32,7 @@ enum VectorscopeMode {
COLOR, COLOR,
COLOR2, COLOR2,
COLOR3, COLOR3,
COLOR4,
MODE_NB MODE_NB
}; };
...@@ -56,6 +57,7 @@ static const AVOption vectorscope_options[] = { ...@@ -56,6 +57,7 @@ static const AVOption vectorscope_options[] = {
{ "color", 0, 0, AV_OPT_TYPE_CONST, {.i64=COLOR}, 0, 0, FLAGS, "mode" }, { "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" }, { "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" }, { "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}, { "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}, { "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}, { "intensity", "set intensity", OFFSET(intensity), AV_OPT_TYPE_INT, {.i64=1}, 1, 255, FLAGS},
...@@ -107,7 +109,8 @@ static int query_formats(AVFilterContext *ctx) ...@@ -107,7 +109,8 @@ static int query_formats(AVFilterContext *ctx)
if (!ctx->inputs[0]->out_formats) { if (!ctx->inputs[0]->out_formats) {
const enum AVPixelFormat *in_pix_fmts; 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; in_pix_fmts = in2_pix_fmts;
else else
in_pix_fmts = in1_pix_fmts; in_pix_fmts = in1_pix_fmts;
...@@ -185,6 +188,7 @@ static void vectorscope(VectorscopeContext *s, AVFrame *in, AVFrame *out, int pd ...@@ -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 uint8_t * const *src = (const uint8_t * const *)in->data;
const int slinesizex = in->linesize[s->x]; const int slinesizex = in->linesize[s->x];
const int slinesizey = in->linesize[s->y]; const int slinesizey = in->linesize[s->y];
const int slinesized = in->linesize[pd];
const int dlinesize = out->linesize[0]; const int dlinesize = out->linesize[0];
const int intensity = s->intensity; const int intensity = s->intensity;
int i, j, px = s->x, py = s->y; int i, j, px = s->x, py = s->y;
...@@ -192,6 +196,7 @@ static void vectorscope(VectorscopeContext *s, AVFrame *in, AVFrame *out, int pd ...@@ -192,6 +196,7 @@ static void vectorscope(VectorscopeContext *s, AVFrame *in, AVFrame *out, int pd
const int w = s->planewidth[px]; const int w = s->planewidth[px];
const uint8_t *spx = src[px]; const uint8_t *spx = src[px];
const uint8_t *spy = src[py]; const uint8_t *spy = src[py];
const uint8_t *spd = src[pd];
uint8_t **dst = out->data; uint8_t **dst = out->data;
uint8_t *dpx = dst[px]; uint8_t *dpx = dst[px];
uint8_t *dpy = dst[py]; uint8_t *dpy = dst[py];
...@@ -296,6 +301,24 @@ static void vectorscope(VectorscopeContext *s, AVFrame *in, AVFrame *out, int pd ...@@ -296,6 +301,24 @@ static void vectorscope(VectorscopeContext *s, AVFrame *in, AVFrame *out, int pd
} }
} }
break; 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: default:
av_assert0(0); av_assert0(0);
} }
......
...@@ -135,6 +135,9 @@ fate-filter-vectorscope_color2: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf vectors ...@@ -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_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-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_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 fate-filter-vectorscope_xy: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf vectorscope=x=0:y=1 -sws_flags +accurate_rnd+bitexact -vframes 3
......
#tb 0: 1/25
0, 0, 0, 1, 196608, 0xb6d22af1
0, 1, 1, 1, 196608, 0xd7c6f971
0, 2, 2, 1, 196608, 0xfe729faa
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment