Merge commit '36ef5369ee9b336febc2c270f8718cec4476cb85'
[ffmpeg.git] / libavdevice / v4l2.c
index 2808e13..867c363 100644 (file)
@@ -125,31 +125,31 @@ struct buff_data {
 
 struct fmt_map {
     enum PixelFormat ff_fmt;
-    enum CodecID codec_id;
+    enum AVCodecID codec_id;
     uint32_t v4l2_fmt;
 };
 
 static struct fmt_map fmt_conversion_table[] = {
     //ff_fmt           codec_id           v4l2_fmt
-    { PIX_FMT_YUV420P, CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUV420  },
-    { PIX_FMT_YUV420P, CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YVU420  },
-    { PIX_FMT_YUV422P, CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUV422P },
-    { PIX_FMT_YUYV422, CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUYV    },
-    { PIX_FMT_UYVY422, CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_UYVY    },
-    { PIX_FMT_YUV411P, CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUV411P },
-    { PIX_FMT_YUV410P, CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUV410  },
-    { PIX_FMT_RGB555LE,CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB555  },
-    { PIX_FMT_RGB555BE,CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB555X },
-    { PIX_FMT_RGB565LE,CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB565  },
-    { PIX_FMT_RGB565BE,CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB565X },
-    { PIX_FMT_BGR24,   CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_BGR24   },
-    { PIX_FMT_RGB24,   CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB24   },
-    { PIX_FMT_BGR0,    CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_BGR32   },
-    { PIX_FMT_0RGB,    CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB32   },
-    { PIX_FMT_GRAY8,   CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_GREY    },
-    { PIX_FMT_NV12,    CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_NV12    },
-    { PIX_FMT_NONE,    CODEC_ID_MJPEG,    V4L2_PIX_FMT_MJPEG   },
-    { PIX_FMT_NONE,    CODEC_ID_MJPEG,    V4L2_PIX_FMT_JPEG    },
+    { PIX_FMT_YUV420P, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUV420  },
+    { PIX_FMT_YUV420P, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YVU420  },
+    { PIX_FMT_YUV422P, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUV422P },
+    { PIX_FMT_YUYV422, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUYV    },
+    { PIX_FMT_UYVY422, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_UYVY    },
+    { PIX_FMT_YUV411P, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUV411P },
+    { PIX_FMT_YUV410P, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUV410  },
+    { PIX_FMT_RGB555LE,AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB555  },
+    { PIX_FMT_RGB555BE,AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB555X },
+    { PIX_FMT_RGB565LE,AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB565  },
+    { PIX_FMT_RGB565BE,AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB565X },
+    { PIX_FMT_BGR24,   AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_BGR24   },
+    { PIX_FMT_RGB24,   AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB24   },
+    { PIX_FMT_BGR0,    AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_BGR32   },
+    { PIX_FMT_0RGB,    AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB32   },
+    { PIX_FMT_GRAY8,   AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_GREY    },
+    { PIX_FMT_NV12,    AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_NV12    },
+    { PIX_FMT_NONE,    AV_CODEC_ID_MJPEG,    V4L2_PIX_FMT_MJPEG   },
+    { PIX_FMT_NONE,    AV_CODEC_ID_MJPEG,    V4L2_PIX_FMT_JPEG    },
 };
 
 static int device_open(AVFormatContext *ctx)
@@ -264,12 +264,12 @@ static int first_field(int fd)
     return 1;
 }
 
-static uint32_t fmt_ff2v4l(enum PixelFormat pix_fmt, enum CodecID codec_id)
+static uint32_t fmt_ff2v4l(enum PixelFormat pix_fmt, enum AVCodecID codec_id)
 {
     int i;
 
     for (i = 0; i < FF_ARRAY_ELEMS(fmt_conversion_table); i++) {
-        if ((codec_id == CODEC_ID_NONE ||
+        if ((codec_id == AV_CODEC_ID_NONE ||
              fmt_conversion_table[i].codec_id == codec_id) &&
             (pix_fmt == PIX_FMT_NONE ||
              fmt_conversion_table[i].ff_fmt == pix_fmt)) {
@@ -280,7 +280,7 @@ static uint32_t fmt_ff2v4l(enum PixelFormat pix_fmt, enum CodecID codec_id)
     return 0;
 }
 
-static enum PixelFormat fmt_v4l2ff(uint32_t v4l2_fmt, enum CodecID codec_id)
+static enum PixelFormat fmt_v4l2ff(uint32_t v4l2_fmt, enum AVCodecID codec_id)
 {
     int i;
 
@@ -294,7 +294,7 @@ static enum PixelFormat fmt_v4l2ff(uint32_t v4l2_fmt, enum CodecID codec_id)
     return PIX_FMT_NONE;
 }
 
-static enum CodecID fmt_v4l2codec(uint32_t v4l2_fmt)
+static enum AVCodecID fmt_v4l2codec(uint32_t v4l2_fmt)
 {
     int i;
 
@@ -304,7 +304,7 @@ static enum CodecID fmt_v4l2codec(uint32_t v4l2_fmt)
         }
     }
 
-    return CODEC_ID_NONE;
+    return AV_CODEC_ID_NONE;
 }
 
 #if HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE
@@ -338,7 +338,7 @@ static void list_formats(AVFormatContext *ctx, int fd, int type)
     struct v4l2_fmtdesc vfd = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };
 
     while(!ioctl(fd, VIDIOC_ENUM_FMT, &vfd)) {
-        enum CodecID codec_id = fmt_v4l2codec(vfd.pixelformat);
+        enum AVCodecID codec_id = fmt_v4l2codec(vfd.pixelformat);
         enum PixelFormat pix_fmt = fmt_v4l2ff(vfd.pixelformat, codec_id);
 
         vfd.index++;
@@ -732,7 +732,7 @@ static uint32_t device_try_init(AVFormatContext *s1,
                                 enum PixelFormat pix_fmt,
                                 int *width,
                                 int *height,
-                                enum CodecID *codec_id)
+                                enum AVCodecID *codec_id)
 {
     uint32_t desired_format = fmt_ff2v4l(pix_fmt, s1->video_codec_id);
 
@@ -742,7 +742,7 @@ static uint32_t device_try_init(AVFormatContext *s1,
 
         desired_format = 0;
         for (i = 0; i<FF_ARRAY_ELEMS(fmt_conversion_table); i++) {
-            if (s1->video_codec_id == CODEC_ID_NONE ||
+            if (s1->video_codec_id == AV_CODEC_ID_NONE ||
                 fmt_conversion_table[i].codec_id == s1->video_codec_id) {
                 desired_format = fmt_conversion_table[i].v4l2_fmt;
                 if (device_init(s1, width, height, desired_format) >= 0) {
@@ -755,7 +755,7 @@ static uint32_t device_try_init(AVFormatContext *s1,
 
     if (desired_format != 0) {
         *codec_id = fmt_v4l2codec(desired_format);
-        av_assert0(*codec_id != CODEC_ID_NONE);
+        av_assert0(*codec_id != AV_CODEC_ID_NONE);
     }
 
     return desired_format;
@@ -767,7 +767,7 @@ static int v4l2_read_header(AVFormatContext *s1)
     AVStream *st;
     int res = 0;
     uint32_t desired_format;
-    enum CodecID codec_id;
+    enum AVCodecID codec_id;
     enum PixelFormat pix_fmt = PIX_FMT_NONE;
 
     st = avformat_new_stream(s1, NULL);
@@ -858,7 +858,7 @@ static int v4l2_read_header(AVFormatContext *s1)
 
     st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codec->codec_id = codec_id;
-    if (codec_id == CODEC_ID_RAWVIDEO)
+    if (codec_id == AV_CODEC_ID_RAWVIDEO)
         st->codec->codec_tag =
             avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt);
     if (desired_format == V4L2_PIX_FMT_YVU420)