diff options
author | Luca Abeni <lucabe72@email.it> | 2006-02-28 11:28:09 +0000 |
---|---|---|
committer | Luca Abeni <lucabe72@email.it> | 2006-02-28 11:28:09 +0000 |
commit | 24300af41691b09df6e798ba4db9e6fafcc432f5 (patch) | |
tree | 840baac8004b366b7750a031b05c15905606ee6a | |
parent | 2b63c2225576b382d0425ae2fb94254255715b33 (diff) | |
download | ffmpeg-24300af41691b09df6e798ba4db9e6fafcc432f5.tar.gz |
Add support for drivers that can change the capture size on VIDIOC_S_FMT
Originally committed as revision 5076 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavformat/v4l2.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/libavformat/v4l2.c b/libavformat/v4l2.c index 8369dae767..a445c6da11 100644 --- a/libavformat/v4l2.c +++ b/libavformat/v4l2.c @@ -148,17 +148,25 @@ static int device_open(const char *devname, uint32_t *capabilities) return fd; } -static int device_init(int fd, int width, int height, int pix_fmt) +static int device_init(int fd, int *width, int *height, int pix_fmt) { struct v4l2_format fmt; + int res; memset(&fmt, 0, sizeof(struct v4l2_format)); fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - fmt.fmt.pix.width = width; - fmt.fmt.pix.height = height; + fmt.fmt.pix.width = *width; + fmt.fmt.pix.height = *height; fmt.fmt.pix.pixelformat = pix_fmt; fmt.fmt.pix.field = V4L2_FIELD_INTERLACED; - return ioctl (fd, VIDIOC_S_FMT, &fmt); + res = ioctl(fd, VIDIOC_S_FMT, &fmt); + if ((*width != fmt.fmt.pix.width) || (*height != fmt.fmt.pix.height)) { + av_log(NULL, AV_LOG_INFO, "The V4L2 driver changed the video from %dx%d to %dx%d\n", *width, *height, fmt.fmt.pix.width, fmt.fmt.pix.height); + *width = fmt.fmt.pix.width; + *height = fmt.fmt.pix.height; + } + + return res; } static int first_field(int fd) @@ -418,13 +426,13 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap) av_log(s1, AV_LOG_ERROR, "[%d]Capabilities: %x\n", s->fd, capabilities); desired_format = fmt_ff2v4l(ap->pix_fmt); - if (desired_format == 0 || (device_init(s->fd, width, height, desired_format) < 0)) { + if (desired_format == 0 || (device_init(s->fd, &width, &height, desired_format) < 0)) { int i, done; done = 0; i = 0; while (!done) { desired_format = fmt_conversion_table[i].v4l2_fmt; - if (device_init(s->fd, width, height, desired_format) < 0) { + if (device_init(s->fd, &width, &height, desired_format) < 0) { desired_format = 0; i++; } else { |