Commit 246da0b1 authored by Anton Khirnov's avatar Anton Khirnov
Browse files

v4l2: avoid pointless indirection.

v4l2_read_header() does no cleanup, so it can return directly, without
any need for goto.
parent 77525327
...@@ -687,21 +687,16 @@ static int v4l2_read_header(AVFormatContext *s1) ...@@ -687,21 +687,16 @@ static int v4l2_read_header(AVFormatContext *s1)
enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE; enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE;
st = avformat_new_stream(s1, NULL); st = avformat_new_stream(s1, NULL);
if (!st) { if (!st)
res = AVERROR(ENOMEM); return AVERROR(ENOMEM);
goto out;
}
s->fd = device_open(s1); s->fd = device_open(s1);
if (s->fd < 0) { if (s->fd < 0)
res = s->fd; return s->fd;
goto out;
}
if (s->list_format) { if (s->list_format) {
list_formats(s1, s->fd, s->list_format); list_formats(s1, s->fd, s->list_format);
res = AVERROR_EXIT; return AVERROR_EXIT;
goto out;
} }
avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
...@@ -710,7 +705,7 @@ static int v4l2_read_header(AVFormatContext *s1) ...@@ -710,7 +705,7 @@ static int v4l2_read_header(AVFormatContext *s1)
(res = av_parse_video_size(&s->width, &s->height, s->video_size)) < 0) { (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", av_log(s1, AV_LOG_ERROR, "Could not parse video size '%s'.\n",
s->video_size); s->video_size);
goto out; return res;
} }
if (s->pixel_format) { if (s->pixel_format) {
...@@ -725,8 +720,7 @@ static int v4l2_read_header(AVFormatContext *s1) ...@@ -725,8 +720,7 @@ static int v4l2_read_header(AVFormatContext *s1)
av_log(s1, AV_LOG_ERROR, "No such input format: %s.\n", av_log(s1, AV_LOG_ERROR, "No such input format: %s.\n",
s->pixel_format); s->pixel_format);
res = AVERROR(EINVAL); return AVERROR(EINVAL);
goto out;
} }
} }
...@@ -739,8 +733,7 @@ static int v4l2_read_header(AVFormatContext *s1) ...@@ -739,8 +733,7 @@ static int v4l2_read_header(AVFormatContext *s1)
if (ioctl(s->fd, VIDIOC_G_FMT, &fmt) < 0) { if (ioctl(s->fd, VIDIOC_G_FMT, &fmt) < 0) {
av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_FMT): %s\n", av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_FMT): %s\n",
strerror(errno)); strerror(errno));
res = AVERROR(errno); return AVERROR(errno);
goto out;
} }
s->width = fmt.fmt.pix.width; s->width = fmt.fmt.pix.width;
...@@ -756,17 +749,16 @@ static int v4l2_read_header(AVFormatContext *s1) ...@@ -756,17 +749,16 @@ static int v4l2_read_header(AVFormatContext *s1)
"codec_id %d, pix_fmt %d.\n", s1->video_codec_id, pix_fmt); "codec_id %d, pix_fmt %d.\n", s1->video_codec_id, pix_fmt);
close(s->fd); close(s->fd);
res = AVERROR(EIO); return AVERROR(EIO);
goto out;
} }
if ((res = av_image_check_size(s->width, s->height, 0, s1) < 0)) if ((res = av_image_check_size(s->width, s->height, 0, s1) < 0))
goto out; return res;
s->frame_format = desired_format; s->frame_format = desired_format;
if ((res = v4l2_set_parameters(s1) < 0)) if ((res = v4l2_set_parameters(s1) < 0))
goto out; return res;
st->codec->pix_fmt = fmt_v4l2ff(desired_format, codec_id); st->codec->pix_fmt = fmt_v4l2ff(desired_format, codec_id);
s->frame_size = s->frame_size =
...@@ -775,7 +767,7 @@ static int v4l2_read_header(AVFormatContext *s1) ...@@ -775,7 +767,7 @@ static int v4l2_read_header(AVFormatContext *s1)
if ((res = mmap_init(s1)) || if ((res = mmap_init(s1)) ||
(res = mmap_start(s1)) < 0) { (res = mmap_start(s1)) < 0) {
close(s->fd); close(s->fd);
goto out; return res;
} }
s->top_field_first = first_field(s->fd); s->top_field_first = first_field(s->fd);
...@@ -789,8 +781,7 @@ static int v4l2_read_header(AVFormatContext *s1) ...@@ -789,8 +781,7 @@ static int v4l2_read_header(AVFormatContext *s1)
st->codec->height = s->height; st->codec->height = s->height;
st->codec->bit_rate = s->frame_size * 1/av_q2d(st->codec->time_base) * 8; st->codec->bit_rate = s->frame_size * 1/av_q2d(st->codec->time_base) * 8;
out: return 0;
return res;
} }
static int v4l2_read_packet(AVFormatContext *s1, AVPacket *pkt) static int v4l2_read_packet(AVFormatContext *s1, AVPacket *pkt)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment