Commit 833a38db authored by Paul B Mahol's avatar Paul B Mahol

avfilter/vf_datascope: make it possible for output window to automatically change position

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent 4d2b9ece
...@@ -455,8 +455,8 @@ static const AVOption pixscope_options[] = { ...@@ -455,8 +455,8 @@ static const AVOption pixscope_options[] = {
{ "w", "set scope width", POFFSET(w), AV_OPT_TYPE_INT, {.i64=7}, 1, 80, FLAGS }, { "w", "set scope width", POFFSET(w), AV_OPT_TYPE_INT, {.i64=7}, 1, 80, FLAGS },
{ "h", "set scope height", POFFSET(h), AV_OPT_TYPE_INT, {.i64=7}, 1, 80, FLAGS }, { "h", "set scope height", POFFSET(h), AV_OPT_TYPE_INT, {.i64=7}, 1, 80, FLAGS },
{ "o", "set window opacity", POFFSET(o), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGS }, { "o", "set window opacity", POFFSET(o), AV_OPT_TYPE_FLOAT, {.dbl=0.5}, 0, 1, FLAGS },
{ "wx", "set window x offset", POFFSET(wx), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 1, FLAGS }, { "wx", "set window x offset", POFFSET(wx), AV_OPT_TYPE_FLOAT, {.dbl=-1}, -1, 1, FLAGS },
{ "wy", "set window y offset", POFFSET(wy), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, 1, FLAGS }, { "wy", "set window y offset", POFFSET(wy), AV_OPT_TYPE_FLOAT, {.dbl=-1}, -1, 1, FLAGS },
{ NULL } { NULL }
}; };
...@@ -542,8 +542,30 @@ static int pixscope_filter_frame(AVFilterLink *inlink, AVFrame *in) ...@@ -542,8 +542,30 @@ static int pixscope_filter_frame(AVFilterLink *inlink, AVFrame *in)
w = s->ww / s->w; w = s->ww / s->w;
h = s->ww / s->h; h = s->ww / s->h;
X = (in->width - s->ww) * s->wx; if (s->wx >= 0) {
Y = (in->height - s->wh) * s->wy; X = (in->width - s->ww) * s->wx;
} else {
X = (in->width - s->ww) * -s->wx;
}
if (s->wy >= 0) {
Y = (in->height - s->wh) * s->wy;
} else {
Y = (in->height - s->wh) * -s->wy;
}
if (s->wx < 0) {
if (s->x + s->w >= X && (s->x + s->w <= X + s->ww) &&
s->y + s->h >= Y && (s->y + s->h <= Y + s->wh)) {
X = (in->width - s->ww) * (1 + s->wx);
}
}
if (s->wy < 0) {
if (s->x + s->w >= X && (s->x + s->w <= X + s->ww) &&
s->y + s->h >= Y && (s->y + s->h <= Y + s->wh)) {
Y = (in->height - s->wh) * (1 + s->wy);
}
}
ff_blend_rectangle(&s->draw, &s->dark, out->data, out->linesize, ff_blend_rectangle(&s->draw, &s->dark, out->data, out->linesize,
out->width, out->height, out->width, out->height,
......
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