summaryrefslogtreecommitdiffstats
path: root/libavdevice
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-01-07 18:35:48 +0100
committerAnton Khirnov <anton@khirnov.net>2013-01-13 16:30:38 +0100
commit246da0b13551b1f80f067e4f258e5bd691f5ab33 (patch)
tree0b510073e70b54b77d9c60964f1ada6b6609b1c5 /libavdevice
parent775253278914d82ca3598b2d48e4ce0c6e05452a (diff)
downloadffmpeg-streaming-246da0b13551b1f80f067e4f258e5bd691f5ab33.zip
ffmpeg-streaming-246da0b13551b1f80f067e4f258e5bd691f5ab33.tar.gz
v4l2: avoid pointless indirection.
v4l2_read_header() does no cleanup, so it can return directly, without any need for goto.
Diffstat (limited to 'libavdevice')
-rw-r--r--libavdevice/v4l2.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 9e71f1d..fd2ab38 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -687,21 +687,16 @@ static int v4l2_read_header(AVFormatContext *s1)
enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE;
st = avformat_new_stream(s1, NULL);
- if (!st) {
- res = AVERROR(ENOMEM);
- goto out;
- }
+ if (!st)
+ return AVERROR(ENOMEM);
s->fd = device_open(s1);
- if (s->fd < 0) {
- res = s->fd;
- goto out;
- }
+ if (s->fd < 0)
+ return s->fd;
if (s->list_format) {
list_formats(s1, s->fd, s->list_format);
- res = AVERROR_EXIT;
- goto out;
+ return AVERROR_EXIT;
}
avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
@@ -710,7 +705,7 @@ static int v4l2_read_header(AVFormatContext *s1)
(res = av_parse_video_size(&s->width, &s->height, s->video_size)) < 0) {
av_log(s1, AV_LOG_ERROR, "Could not parse video size '%s'.\n",
s->video_size);
- goto out;
+ return res;
}
if (s->pixel_format) {
@@ -725,8 +720,7 @@ static int v4l2_read_header(AVFormatContext *s1)
av_log(s1, AV_LOG_ERROR, "No such input format: %s.\n",
s->pixel_format);
- res = AVERROR(EINVAL);
- goto out;
+ return AVERROR(EINVAL);
}
}
@@ -739,8 +733,7 @@ static int v4l2_read_header(AVFormatContext *s1)
if (ioctl(s->fd, VIDIOC_G_FMT, &fmt) < 0) {
av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_FMT): %s\n",
strerror(errno));
- res = AVERROR(errno);
- goto out;
+ return AVERROR(errno);
}
s->width = fmt.fmt.pix.width;
@@ -756,17 +749,16 @@ static int v4l2_read_header(AVFormatContext *s1)
"codec_id %d, pix_fmt %d.\n", s1->video_codec_id, pix_fmt);
close(s->fd);
- res = AVERROR(EIO);
- goto out;
+ return AVERROR(EIO);
}
if ((res = av_image_check_size(s->width, s->height, 0, s1) < 0))
- goto out;
+ return res;
s->frame_format = desired_format;
if ((res = v4l2_set_parameters(s1) < 0))
- goto out;
+ return res;
st->codec->pix_fmt = fmt_v4l2ff(desired_format, codec_id);
s->frame_size =
@@ -775,7 +767,7 @@ static int v4l2_read_header(AVFormatContext *s1)
if ((res = mmap_init(s1)) ||
(res = mmap_start(s1)) < 0) {
close(s->fd);
- goto out;
+ return res;
}
s->top_field_first = first_field(s->fd);
@@ -789,8 +781,7 @@ static int v4l2_read_header(AVFormatContext *s1)
st->codec->height = s->height;
st->codec->bit_rate = s->frame_size * 1/av_q2d(st->codec->time_base) * 8;
-out:
- return res;
+ return 0;
}
static int v4l2_read_packet(AVFormatContext *s1, AVPacket *pkt)
OpenPOWER on IntegriCloud