aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-30 12:48:05 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-10-30 14:34:07 +0100
commitdb442c873631065e8719df6da91c016d25501084 (patch)
tree197f61ad9f7f39d0e53683bd9e526680d3c400e6
parent0c9f0da0f7656059e9bd41931d250aafddf35ea3 (diff)
downloadffmpeg-db442c873631065e8719df6da91c016d25501084.tar.gz
avdevice/xcbgrab: Fix offset support
Found-by: carl Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavdevice/xcbgrab.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
index b162763bac..2fdb99255a 100644
--- a/libavdevice/xcbgrab.c
+++ b/libavdevice/xcbgrab.c
@@ -491,7 +491,6 @@ static int create_stream(AVFormatContext *s)
{
XCBGrabContext *c = s->priv_data;
AVStream *st = avformat_new_stream(s, NULL);
- const char *opts = strchr(s->filename, '+');
xcb_get_geometry_cookie_t gc;
xcb_get_geometry_reply_t *geo;
int ret;
@@ -507,9 +506,6 @@ static int create_stream(AVFormatContext *s)
if (ret < 0)
return ret;
- if (opts)
- sscanf(opts, "%d,%d", &c->x, &c->y);
-
avpriv_set_pts_info(st, 64, 1, 1000000);
gc = xcb_get_geometry(c->conn, c->screen->root);
@@ -598,8 +594,20 @@ static av_cold int xcbgrab_read_header(AVFormatContext *s)
XCBGrabContext *c = s->priv_data;
int screen_num, ret;
const xcb_setup_t *setup;
+ char *display_name = av_strdup(s->filename);
+
+ if (s->filename) {
+ if (!display_name)
+ return AVERROR(ENOMEM);
+
+ if (!sscanf(s->filename, "%[^+]+%d,%d", display_name, &c->x, &c->y)) {
+ *display_name = 0;
+ sscanf(s->filename, "+%d,%d", &c->x, &c->y);
+ }
+ }
- c->conn = xcb_connect(s->filename, &screen_num);
+ c->conn = xcb_connect(display_name, &screen_num);
+ av_freep(&display_name);
if ((ret = xcb_connection_has_error(c->conn))) {
av_log(s, AV_LOG_ERROR, "Cannot open display %s, error %d.\n",
s->filename ? s->filename : "default", ret);