diff options
author | Paul B Mahol <onemda@gmail.com> | 2017-09-04 14:20:29 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2017-09-04 14:20:29 +0200 |
commit | 833a38dbe5b3faa07cfdded65f1c2ddecafad11c (patch) | |
tree | 8caeeee85ccefabdfe04a021c4aa0bc35d53a210 | |
parent | 4d2b9ece45e576474a2f03eb47f5cc088eec3f0c (diff) | |
download | ffmpeg-833a38dbe5b3faa07cfdded65f1c2ddecafad11c.tar.gz |
avfilter/vf_datascope: make it possible for output window to automatically change position
Signed-off-by: Paul B Mahol <onemda@gmail.com>
-rw-r--r-- | libavfilter/vf_datascope.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/libavfilter/vf_datascope.c b/libavfilter/vf_datascope.c index a0482cdb75..467663556e 100644 --- a/libavfilter/vf_datascope.c +++ b/libavfilter/vf_datascope.c @@ -455,8 +455,8 @@ static const AVOption pixscope_options[] = { { "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 }, { "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 }, - { "wy", "set window y offset", POFFSET(wy), AV_OPT_TYPE_FLOAT, {.dbl=0}, 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=-1}, -1, 1, FLAGS }, { NULL } }; @@ -542,8 +542,30 @@ static int pixscope_filter_frame(AVFilterLink *inlink, AVFrame *in) w = s->ww / s->w; h = s->ww / s->h; - X = (in->width - s->ww) * s->wx; - Y = (in->height - s->wh) * s->wy; + if (s->wx >= 0) { + 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, out->width, out->height, |