...
|
...
|
@@ -91,6 +91,7 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
|
91
|
91
|
int y_off = 0;
|
92
|
92
|
int use_shm;
|
93
|
93
|
char *param, *offset;
|
|
94
|
+ int ret = 0;
|
94
|
95
|
|
95
|
96
|
param = av_strdup(s1->filename);
|
96
|
97
|
offset = strchr(param, '+');
|
...
|
...
|
@@ -105,17 +106,20 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
|
105
|
105
|
dpy = XOpenDisplay(param);
|
106
|
106
|
if(!dpy) {
|
107
|
107
|
av_log(s1, AV_LOG_ERROR, "Could not open X display.\n");
|
108
|
|
- return AVERROR(EIO);
|
|
108
|
+ ret = AVERROR(EIO);
|
|
109
|
+ goto out;
|
109
|
110
|
}
|
110
|
111
|
|
111
|
112
|
if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) {
|
112
|
113
|
av_log(s1, AV_LOG_ERROR, "AVParameters don't have video size and/or rate. Use -s and -r.\n");
|
113
|
|
- return AVERROR(EIO);
|
|
114
|
+ ret = AVERROR(EINVAL);
|
|
115
|
+ goto out;
|
114
|
116
|
}
|
115
|
117
|
|
116
|
118
|
st = av_new_stream(s1, 0);
|
117
|
119
|
if (!st) {
|
118
|
|
- return AVERROR(ENOMEM);
|
|
120
|
+ ret = AVERROR(ENOMEM);
|
|
121
|
+ goto out;
|
119
|
122
|
}
|
120
|
123
|
av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
|
121
|
124
|
|
...
|
...
|
@@ -136,7 +140,8 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
|
136
|
136
|
IPC_CREAT|0777);
|
137
|
137
|
if (x11grab->shminfo.shmid == -1) {
|
138
|
138
|
av_log(s1, AV_LOG_ERROR, "Fatal: Can't get shared memory!\n");
|
139
|
|
- return AVERROR(ENOMEM);
|
|
139
|
+ ret = AVERROR(ENOMEM);
|
|
140
|
+ goto out;
|
140
|
141
|
}
|
141
|
142
|
x11grab->shminfo.shmaddr = image->data = shmat(x11grab->shminfo.shmid, 0, 0);
|
142
|
143
|
x11grab->shminfo.readOnly = False;
|
...
|
...
|
@@ -144,7 +149,8 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
|
144
|
144
|
if (!XShmAttach(dpy, &x11grab->shminfo)) {
|
145
|
145
|
av_log(s1, AV_LOG_ERROR, "Fatal: Failed to attach shared memory!\n");
|
146
|
146
|
/* needs some better error subroutine :) */
|
147
|
|
- return AVERROR(EIO);
|
|
147
|
+ ret = AVERROR(EIO);
|
|
148
|
+ goto out;
|
148
|
149
|
}
|
149
|
150
|
} else {
|
150
|
151
|
image = XGetImage(dpy, RootWindow(dpy, DefaultScreen(dpy)),
|
...
|
...
|
@@ -172,7 +178,8 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
|
172
|
172
|
} else {
|
173
|
173
|
av_log(s1, AV_LOG_ERROR, "RGB ordering at image depth %i not supported ... aborting\n", image->bits_per_pixel);
|
174
|
174
|
av_log(s1, AV_LOG_ERROR, "color masks: r 0x%.6lx g 0x%.6lx b 0x%.6lx\n", image->red_mask, image->green_mask, image->blue_mask);
|
175
|
|
- return AVERROR(EIO);
|
|
175
|
+ ret = AVERROR(EIO);
|
|
176
|
+ goto out;
|
176
|
177
|
}
|
177
|
178
|
break;
|
178
|
179
|
case 24:
|
...
|
...
|
@@ -187,7 +194,8 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
|
187
|
187
|
} else {
|
188
|
188
|
av_log(s1, AV_LOG_ERROR,"rgb ordering at image depth %i not supported ... aborting\n", image->bits_per_pixel);
|
189
|
189
|
av_log(s1, AV_LOG_ERROR, "color masks: r 0x%.6lx g 0x%.6lx b 0x%.6lx\n", image->red_mask, image->green_mask, image->blue_mask);
|
190
|
|
- return AVERROR(EIO);
|
|
190
|
+ ret = AVERROR(EIO);
|
|
191
|
+ goto out;
|
191
|
192
|
}
|
192
|
193
|
break;
|
193
|
194
|
case 32:
|
...
|
...
|
@@ -210,7 +218,8 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
|
210
|
210
|
break;
|
211
|
211
|
default:
|
212
|
212
|
av_log(s1, AV_LOG_ERROR, "image depth %i not supported ... aborting\n", image->bits_per_pixel);
|
213
|
|
- return -1;
|
|
213
|
+ ret = AVERROR(EINVAL);
|
|
214
|
+ goto out;
|
214
|
215
|
}
|
215
|
216
|
|
216
|
217
|
x11grab->frame_size = ap->width * ap->height * image->bits_per_pixel/8;
|
...
|
...
|
@@ -232,7 +241,8 @@ x11grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
|
232
|
232
|
st->codec->time_base = ap->time_base;
|
233
|
233
|
st->codec->bit_rate = x11grab->frame_size * 1/av_q2d(ap->time_base) * 8;
|
234
|
234
|
|
235
|
|
- return 0;
|
|
235
|
+out:
|
|
236
|
+ return ret;
|
236
|
237
|
}
|
237
|
238
|
|
238
|
239
|
/**
|