]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Implement size autodetection if one of the width and height
authorstefano <stefano@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Wed, 17 Dec 2008 23:58:28 +0000 (23:58 +0000)
committerstefano <stefano@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Wed, 17 Dec 2008 23:58:28 +0000 (23:58 +0000)
AVFormatParameters for grab_read_header() is non-positive.

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@16199 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavdevice/v4l.c

index 1978ab4bb245db3282c859a65a6f8edfd305d3dc..5b9d5f8a02c198478c29c449f5c64bf4b2113021 100644 (file)
@@ -78,10 +78,6 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
     int j;
     int vformat_num = FF_ARRAY_ELEMS(video_formats);
 
-    if (ap->width <= 0 || ap->height <= 0) {
-        av_log(s1, AV_LOG_ERROR, "Wrong size (%dx%d)\n", ap->width, ap->height);
-        return -1;
-    }
     if (ap->time_base.den <= 0) {
         av_log(s1, AV_LOG_ERROR, "Wrong time base (%d)\n", ap->time_base.den);
         return -1;
@@ -107,6 +103,14 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
         goto fail;
     }
 
+    /* no values set, autodetect them */
+    if (s->video_win.width <= 0 || s->video_win.height <= 0) {
+        if (ioctl(video_fd, VIDIOCGWIN, &s->video_win, sizeof(s->video_win)) < 0) {
+            av_log(s1, AV_LOG_ERROR, "VIDIOCGWIN: %s\n", strerror(errno));
+            goto fail;
+        }
+    }
+
     if (ioctl(video_fd,VIDIOCGCAP, &s->video_cap) < 0) {
         av_log(s1, AV_LOG_ERROR, "VIDIOCGCAP: %s\n", strerror(errno));
         goto fail;