]> git.sesse.net Git - ffmpeg/blobdiff - libavdevice/v4l2.c
Cosmetic change aimed at making it easier to see how bits are consumed
[ffmpeg] / libavdevice / v4l2.c
index ab5e6857cb89badfefe4a82a509759fb89b09783..818366a71547cb2c5c0fe85cdcf7e8cdbe573222 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#undef __STRICT_ANSI__ //workaround due to broken kernel headers
 #include "config.h"
-#include "avformat.h"
+#include "libavformat/avformat.h"
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
-#ifdef HAVE_SYS_MMAN_H
 #include <sys/mman.h>
-#endif
 #include <sys/time.h>
 #include <asm/types.h>
 #include <linux/videodev2.h>
 #include <time.h>
+#include <strings.h>
 
 static const int desired_video_buffers = 256;
 
@@ -225,7 +225,7 @@ static enum PixelFormat fmt_v4l2ff(uint32_t pix_fmt)
         }
     }
 
-    return -1;
+    return PIX_FMT_NONE;
 }
 
 static int mmap_init(AVFormatContext *ctx)
@@ -497,9 +497,12 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
     int res, frame_rate, frame_rate_base;
     uint32_t desired_format, capabilities;
 
-    if (ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) {
-        av_log(s1, AV_LOG_ERROR, "Missing/Wrong width, height or framerate\n");
-
+    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;
     }
 
@@ -509,7 +512,7 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
     frame_rate_base = ap->time_base.num;
 
     if((unsigned)width > 32767 || (unsigned)height > 32767) {
-        av_log(s1, AV_LOG_ERROR, "Wrong size %dx%d\n", width, height);
+        av_log(s1, AV_LOG_ERROR, "Wrong size (%dx%d)\n", width, height);
 
         return -1;
     }
@@ -528,8 +531,6 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
     capabilities = 0;
     s->fd = device_open(s1, &capabilities);
     if (s->fd < 0) {
-        av_free(st);
-
         return AVERROR(EIO);
     }
     av_log(s1, AV_LOG_INFO, "[%d]Capabilities: %x\n", s->fd, capabilities);
@@ -555,7 +556,6 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
     if (desired_format == 0) {
         av_log(s1, AV_LOG_ERROR, "Cannot find a proper format.\n");
         close(s->fd);
-        av_free(st);
 
         return AVERROR(EIO);
     }
@@ -578,7 +578,6 @@ static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
     }
     if (res < 0) {
         close(s->fd);
-        av_free(st);
 
         return AVERROR(EIO);
     }
@@ -637,7 +636,7 @@ static int v4l2_read_close(AVFormatContext *s1)
 
 AVInputFormat v4l2_demuxer = {
     "video4linux2",
-    "video grab",
+    NULL_IF_CONFIG_SMALL("video grab"),
     sizeof(struct video_data),
     NULL,
     v4l2_read_header,