summaryrefslogtreecommitdiff
path: root/libavdevice
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2015-06-06 12:59:46 +0200
committerClément Bœsch <u@pkh.me>2015-06-06 13:18:29 +0200
commit272f87fc5ca9fe8a0bee3f0ea2037b4626454195 (patch)
tree2ec83afaadd376f86b59045c81d41783d01c2a03 /libavdevice
parent533c37db8ddba7e698f79b7d2e5918f18a7b39e2 (diff)
avdevice/x11grab: use av_clip() instead of nested min & max
Note: [xy]_off and screen_[wh] variables are int, as well as X11GrabContext.{width,height,x_off,y_off}.
Diffstat (limited to 'libavdevice')
-rw-r--r--libavdevice/x11grab.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c
index d3b0b02e91..bdfaa66d35 100644
--- a/libavdevice/x11grab.c
+++ b/libavdevice/x11grab.c
@@ -315,8 +315,8 @@ static int x11grab_read_header(AVFormatContext *s1)
&ret, &ret, &ret);
x_off -= x11grab->width / 2;
y_off -= x11grab->height / 2;
- x_off = FFMIN(FFMAX(x_off, 0), screen_w - x11grab->width);
- y_off = FFMIN(FFMAX(y_off, 0), screen_h - x11grab->height);
+ x_off = av_clip(x_off, 0, screen_w - x11grab->width);
+ y_off = av_clip(y_off, 0, screen_h - x11grab->height);
av_log(s1, AV_LOG_INFO,
"followmouse is enabled, resetting grabbing region to x: %d y: %d\n",
x_off, y_off);
@@ -587,8 +587,8 @@ static int x11grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
y_off -= (y_off + follow_mouse) - pointer_y;
}
// adjust grabbing region position if it goes out of screen.
- s->x_off = x_off = FFMIN(FFMAX(x_off, 0), screen_w - s->width);
- s->y_off = y_off = FFMIN(FFMAX(y_off, 0), screen_h - s->height);
+ s->x_off = x_off = av_clip(x_off, 0, screen_w - s->width);
+ s->y_off = y_off = av_clip(y_off, 0, screen_h - s->height);
if (s->show_region && s->region_win)
XMoveWindow(dpy, s->region_win,