[FFmpeg-devel] [PATCH 3/6] Remove unnecessary width and height variables from v4l2_read_header().
Stefano Sabatini
stefano.sabatini-lala
Sat Apr 24 20:53:22 CEST 2010
---
libavdevice/v4l2.c | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index c5b1768..de34f49 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -583,7 +583,6 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
{
struct video_data *s = s1->priv_data;
AVStream *st;
- int width, height;
int res;
uint32_t desired_format, capabilities;
enum CodecID codec_id;
@@ -593,9 +592,6 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
return AVERROR(EINVAL);
}
- width = ap->width;
- height = ap->height;
-
if(avcodec_check_dimensions(s1, ap->width, ap->height) < 0)
return AVERROR(EINVAL);
@@ -605,8 +601,8 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
}
av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
- s->width = width;
- s->height = height;
+ s->width = ap->width;
+ s->height = ap->height;
capabilities = 0;
s->fd = device_open(s1, &capabilities);
@@ -615,7 +611,7 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
}
av_log(s1, AV_LOG_INFO, "[%d]Capabilities: %x\n", s->fd, capabilities);
- desired_format = device_try_init(s1, ap, &width, &height, &codec_id);
+ desired_format = device_try_init(s1, ap, &s->width, &s->height, &codec_id);
if (desired_format == 0) {
av_log(s1, AV_LOG_ERROR, "Cannot find a proper format for "
"codec_id %d, pix_fmt %d.\n", s1->video_codec_id, ap->pix_fmt);
@@ -629,7 +625,7 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
return AVERROR(EIO);
st->codec->pix_fmt = fmt_v4l2ff(desired_format, codec_id);
- s->frame_size = avpicture_get_size(st->codec->pix_fmt, width, height);
+ s->frame_size = avpicture_get_size(st->codec->pix_fmt, s->width, s->height);
if (capabilities & V4L2_CAP_STREAMING) {
s->io_method = io_mmap;
res = mmap_init(s1);
@@ -649,8 +645,8 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = codec_id;
- st->codec->width = width;
- st->codec->height = height;
+ st->codec->width = s->width;
+ st->codec->height = s->height;
st->codec->time_base.den = ap->time_base.den;
st->codec->time_base.num = ap->time_base.num;
st->codec->bit_rate = s->frame_size * 1/av_q2d(st->codec->time_base) * 8;
--
1.7.0
More information about the ffmpeg-devel
mailing list