[FFmpeg-devel] [PATCH 1/6] Move lavd/v4l2-common.* to lavc.
Alexis Ballier
aballier at gentoo.org
Thu Nov 20 17:51:52 CET 2014
This code needs lavc for AV_CODEC_ID_* and can be used by lavc & lavfi with v4l m2m support.
---
configure | 6 ++-
libavcodec/Makefile | 1 +
libavcodec/v4l2-common.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++
libavcodec/v4l2-common.h | 47 +++++++++++++++++++++
libavdevice/Makefile | 6 +--
libavdevice/v4l2-common.c | 105 ----------------------------------------------
libavdevice/v4l2-common.h | 62 ---------------------------
libavdevice/v4l2.c | 38 ++++++++++++-----
libavdevice/v4l2enc.c | 12 +++++-
9 files changed, 196 insertions(+), 186 deletions(-)
create mode 100644 libavcodec/v4l2-common.c
create mode 100644 libavcodec/v4l2-common.h
delete mode 100644 libavdevice/v4l2-common.c
delete mode 100644 libavdevice/v4l2-common.h
diff --git a/configure b/configure
index c0aa718..81a6acf 100755
--- a/configure
+++ b/configure
@@ -1467,6 +1467,7 @@ SUBSYSTEM_LIST="
pixelutils
network
rdft
+ v4l2
"
CONFIG_LIST="
@@ -2051,6 +2052,7 @@ mpegaudio_select="mpegaudiodsp"
mpegaudiodsp_select="dct"
mpegvideo_select="blockdsp h264chroma hpeldsp idctdsp me_cmp videodsp"
mpegvideoenc_select="me_cmp mpegvideo pixblockdsp qpeldsp"
+v4l2_deps_any="linux_videodev2_h sys_videoio_h"
# decoders / encoders
aac_decoder_select="mdct sinewin"
@@ -2496,8 +2498,8 @@ sdl_outdev_deps="sdl"
sndio_indev_deps="sndio_h"
sndio_outdev_deps="sndio_h"
v4l_indev_deps="linux_videodev_h"
-v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
-v4l2_outdev_deps_any="linux_videodev2_h sys_videoio_h"
+v4l2_indev_select="v4l2"
+v4l2_outdev_select="v4l2"
vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
vfwcap_indev_extralibs="-lavicap32"
xv_outdev_deps="X11_extensions_Xvlib_h XvGetPortAttribute"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 6c625ce..a134fa6 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -95,6 +95,7 @@ OBJS-$(CONFIG_SHARED) += log2_tab.o
OBJS-$(CONFIG_SINEWIN) += sinewin.o
OBJS-$(CONFIG_STARTCODE) += startcode.o
OBJS-$(CONFIG_TPELDSP) += tpeldsp.o
+OBJS-$(CONFIG_V4L2) += v4l2-common.o
OBJS-$(CONFIG_VIDEODSP) += videodsp.o
OBJS-$(CONFIG_VP3DSP) += vp3dsp.o
OBJS-$(CONFIG_WMA_FREQS) += wma_freqs.o
diff --git a/libavcodec/v4l2-common.c b/libavcodec/v4l2-common.c
new file mode 100644
index 0000000..884101d
--- /dev/null
+++ b/libavcodec/v4l2-common.c
@@ -0,0 +1,105 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "v4l2-common.h"
+
+const struct v4l_fmt_map avpriv_v4l_fmt_conversion_table[] = {
+ //ff_fmt codec_id v4l2_fmt
+ { AV_PIX_FMT_YUV420P, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUV420 },
+ { AV_PIX_FMT_YUV420P, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YVU420 },
+ { AV_PIX_FMT_YUV422P, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUV422P },
+ { AV_PIX_FMT_YUYV422, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUYV },
+ { AV_PIX_FMT_UYVY422, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_UYVY },
+ { AV_PIX_FMT_YUV411P, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUV411P },
+ { AV_PIX_FMT_YUV410P, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUV410 },
+ { AV_PIX_FMT_YUV410P, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YVU410 },
+ { AV_PIX_FMT_RGB555LE,AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB555 },
+ { AV_PIX_FMT_RGB555BE,AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB555X },
+ { AV_PIX_FMT_RGB565LE,AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB565 },
+ { AV_PIX_FMT_RGB565BE,AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB565X },
+ { AV_PIX_FMT_BGR24, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_BGR24 },
+ { AV_PIX_FMT_RGB24, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB24 },
+ { AV_PIX_FMT_BGR0, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_BGR32 },
+ { AV_PIX_FMT_0RGB, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB32 },
+ { AV_PIX_FMT_GRAY8, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_GREY },
+#ifdef V4L2_PIX_FMT_Y16
+ { AV_PIX_FMT_GRAY16LE,AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_Y16 },
+#endif
+ { AV_PIX_FMT_NV12, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_NV12 },
+ { AV_PIX_FMT_NONE, AV_CODEC_ID_MJPEG, V4L2_PIX_FMT_MJPEG },
+ { AV_PIX_FMT_NONE, AV_CODEC_ID_MJPEG, V4L2_PIX_FMT_JPEG },
+#ifdef V4L2_PIX_FMT_H264
+ { AV_PIX_FMT_NONE, AV_CODEC_ID_H264, V4L2_PIX_FMT_H264 },
+#endif
+#ifdef V4L2_PIX_FMT_MPEG4
+ { AV_PIX_FMT_NONE, AV_CODEC_ID_MPEG4, V4L2_PIX_FMT_MPEG4 },
+#endif
+#ifdef V4L2_PIX_FMT_CPIA1
+ { AV_PIX_FMT_NONE, AV_CODEC_ID_CPIA, V4L2_PIX_FMT_CPIA1 },
+#endif
+#ifdef V4L2_PIX_FMT_SRGGB8
+ { AV_PIX_FMT_BAYER_BGGR8, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_SBGGR8 },
+ { AV_PIX_FMT_BAYER_GBRG8, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_SGBRG8 },
+ { AV_PIX_FMT_BAYER_GRBG8, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_SGRBG8 },
+ { AV_PIX_FMT_BAYER_RGGB8, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_SRGGB8 },
+#endif
+ { AV_PIX_FMT_NONE, AV_CODEC_ID_NONE, 0 },
+};
+
+uint32_t avpriv_v4l_fmt_ff2v4l(enum AVPixelFormat pix_fmt, enum AVCodecID codec_id)
+{
+ int i;
+
+ for (i = 0; avpriv_v4l_fmt_conversion_table[i].codec_id != AV_CODEC_ID_NONE; i++) {
+ if ((codec_id == AV_CODEC_ID_NONE ||
+ avpriv_v4l_fmt_conversion_table[i].codec_id == codec_id) &&
+ (pix_fmt == AV_PIX_FMT_NONE ||
+ avpriv_v4l_fmt_conversion_table[i].ff_fmt == pix_fmt)) {
+ return avpriv_v4l_fmt_conversion_table[i].v4l2_fmt;
+ }
+ }
+
+ return 0;
+}
+
+enum AVPixelFormat avpriv_v4l_fmt_v4l2ff(uint32_t v4l2_fmt, enum AVCodecID codec_id)
+{
+ int i;
+
+ for (i = 0; avpriv_v4l_fmt_conversion_table[i].codec_id != AV_CODEC_ID_NONE; i++) {
+ if (avpriv_v4l_fmt_conversion_table[i].v4l2_fmt == v4l2_fmt &&
+ avpriv_v4l_fmt_conversion_table[i].codec_id == codec_id) {
+ return avpriv_v4l_fmt_conversion_table[i].ff_fmt;
+ }
+ }
+
+ return AV_PIX_FMT_NONE;
+}
+
+enum AVCodecID avpriv_v4l_fmt_v4l2codec(uint32_t v4l2_fmt)
+{
+ int i;
+
+ for (i = 0; avpriv_v4l_fmt_conversion_table[i].codec_id != AV_CODEC_ID_NONE; i++) {
+ if (avpriv_v4l_fmt_conversion_table[i].v4l2_fmt == v4l2_fmt) {
+ return avpriv_v4l_fmt_conversion_table[i].codec_id;
+ }
+ }
+
+ return AV_CODEC_ID_NONE;
+}
diff --git a/libavcodec/v4l2-common.h b/libavcodec/v4l2-common.h
new file mode 100644
index 0000000..2528cd0
--- /dev/null
+++ b/libavcodec/v4l2-common.h
@@ -0,0 +1,47 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_V4L2_COMMON_H
+#define AVCODEC_V4L2_COMMON_H
+
+#undef __STRICT_ANSI__ //workaround due to broken kernel headers
+#include "config.h"
+#if HAVE_SYS_VIDEOIO_H
+#include <sys/videoio.h>
+#else
+#if HAVE_ASM_TYPES_H
+#include <asm/types.h>
+#endif
+#include <linux/videodev2.h>
+#endif
+#include "libavutil/pixfmt.h"
+#include "libavcodec/avcodec.h"
+
+struct v4l_fmt_map {
+ enum AVPixelFormat ff_fmt;
+ enum AVCodecID codec_id;
+ uint32_t v4l2_fmt;
+};
+
+extern const struct v4l_fmt_map avpriv_v4l_fmt_conversion_table[];
+
+uint32_t avpriv_v4l_fmt_ff2v4l(enum AVPixelFormat pix_fmt, enum AVCodecID codec_id);
+enum AVPixelFormat avpriv_v4l_fmt_v4l2ff(uint32_t v4l2_fmt, enum AVCodecID codec_id);
+enum AVCodecID avpriv_v4l_fmt_v4l2codec(uint32_t v4l2_fmt);
+
+#endif /* AVCODEC_V4L2_COMMON_H */
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index e44c88a..42b0a40 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -42,8 +42,8 @@ OBJS-$(CONFIG_QTKIT_INDEV) += qtkit.o
OBJS-$(CONFIG_SDL_OUTDEV) += sdl.o
OBJS-$(CONFIG_SNDIO_INDEV) += sndio_common.o sndio_dec.o
OBJS-$(CONFIG_SNDIO_OUTDEV) += sndio_common.o sndio_enc.o
-OBJS-$(CONFIG_V4L2_INDEV) += v4l2.o v4l2-common.o timefilter.o
-OBJS-$(CONFIG_V4L2_OUTDEV) += v4l2enc.o v4l2-common.o
+OBJS-$(CONFIG_V4L2_INDEV) += v4l2.o timefilter.o
+OBJS-$(CONFIG_V4L2_OUTDEV) += v4l2enc.o
OBJS-$(CONFIG_V4L_INDEV) += v4l.o
OBJS-$(CONFIG_VFWCAP_INDEV) += vfwcap.o
OBJS-$(CONFIG_X11GRAB_INDEV) += x11grab.o
@@ -65,8 +65,6 @@ SKIPHEADERS-$(CONFIG_DSHOW_INDEV) += dshow_capture.h
SKIPHEADERS-$(CONFIG_FBDEV_INDEV) += fbdev_common.h
SKIPHEADERS-$(CONFIG_FBDEV_OUTDEV) += fbdev_common.h
SKIPHEADERS-$(CONFIG_LIBPULSE) += pulse_audio_common.h
-SKIPHEADERS-$(CONFIG_V4L2_INDEV) += v4l2-common.h
-SKIPHEADERS-$(CONFIG_V4L2_OUTDEV) += v4l2-common.h
SKIPHEADERS-$(HAVE_ALSA_ASOUNDLIB_H) += alsa-audio.h
SKIPHEADERS-$(HAVE_SNDIO_H) += sndio_common.h
diff --git a/libavdevice/v4l2-common.c b/libavdevice/v4l2-common.c
deleted file mode 100644
index 196c09b..0000000
--- a/libavdevice/v4l2-common.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "v4l2-common.h"
-
-const struct fmt_map ff_fmt_conversion_table[] = {
- //ff_fmt codec_id v4l2_fmt
- { AV_PIX_FMT_YUV420P, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUV420 },
- { AV_PIX_FMT_YUV420P, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YVU420 },
- { AV_PIX_FMT_YUV422P, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUV422P },
- { AV_PIX_FMT_YUYV422, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUYV },
- { AV_PIX_FMT_UYVY422, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_UYVY },
- { AV_PIX_FMT_YUV411P, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUV411P },
- { AV_PIX_FMT_YUV410P, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YUV410 },
- { AV_PIX_FMT_YUV410P, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_YVU410 },
- { AV_PIX_FMT_RGB555LE,AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB555 },
- { AV_PIX_FMT_RGB555BE,AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB555X },
- { AV_PIX_FMT_RGB565LE,AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB565 },
- { AV_PIX_FMT_RGB565BE,AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB565X },
- { AV_PIX_FMT_BGR24, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_BGR24 },
- { AV_PIX_FMT_RGB24, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB24 },
- { AV_PIX_FMT_BGR0, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_BGR32 },
- { AV_PIX_FMT_0RGB, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_RGB32 },
- { AV_PIX_FMT_GRAY8, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_GREY },
-#ifdef V4L2_PIX_FMT_Y16
- { AV_PIX_FMT_GRAY16LE,AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_Y16 },
-#endif
- { AV_PIX_FMT_NV12, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_NV12 },
- { AV_PIX_FMT_NONE, AV_CODEC_ID_MJPEG, V4L2_PIX_FMT_MJPEG },
- { AV_PIX_FMT_NONE, AV_CODEC_ID_MJPEG, V4L2_PIX_FMT_JPEG },
-#ifdef V4L2_PIX_FMT_H264
- { AV_PIX_FMT_NONE, AV_CODEC_ID_H264, V4L2_PIX_FMT_H264 },
-#endif
-#ifdef V4L2_PIX_FMT_MPEG4
- { AV_PIX_FMT_NONE, AV_CODEC_ID_MPEG4, V4L2_PIX_FMT_MPEG4 },
-#endif
-#ifdef V4L2_PIX_FMT_CPIA1
- { AV_PIX_FMT_NONE, AV_CODEC_ID_CPIA, V4L2_PIX_FMT_CPIA1 },
-#endif
-#ifdef V4L2_PIX_FMT_SRGGB8
- { AV_PIX_FMT_BAYER_BGGR8, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_SBGGR8 },
- { AV_PIX_FMT_BAYER_GBRG8, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_SGBRG8 },
- { AV_PIX_FMT_BAYER_GRBG8, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_SGRBG8 },
- { AV_PIX_FMT_BAYER_RGGB8, AV_CODEC_ID_RAWVIDEO, V4L2_PIX_FMT_SRGGB8 },
-#endif
- { AV_PIX_FMT_NONE, AV_CODEC_ID_NONE, 0 },
-};
-
-uint32_t ff_fmt_ff2v4l(enum AVPixelFormat pix_fmt, enum AVCodecID codec_id)
-{
- int i;
-
- for (i = 0; ff_fmt_conversion_table[i].codec_id != AV_CODEC_ID_NONE; i++) {
- if ((codec_id == AV_CODEC_ID_NONE ||
- ff_fmt_conversion_table[i].codec_id == codec_id) &&
- (pix_fmt == AV_PIX_FMT_NONE ||
- ff_fmt_conversion_table[i].ff_fmt == pix_fmt)) {
- return ff_fmt_conversion_table[i].v4l2_fmt;
- }
- }
-
- return 0;
-}
-
-enum AVPixelFormat ff_fmt_v4l2ff(uint32_t v4l2_fmt, enum AVCodecID codec_id)
-{
- int i;
-
- for (i = 0; ff_fmt_conversion_table[i].codec_id != AV_CODEC_ID_NONE; i++) {
- if (ff_fmt_conversion_table[i].v4l2_fmt == v4l2_fmt &&
- ff_fmt_conversion_table[i].codec_id == codec_id) {
- return ff_fmt_conversion_table[i].ff_fmt;
- }
- }
-
- return AV_PIX_FMT_NONE;
-}
-
-enum AVCodecID ff_fmt_v4l2codec(uint32_t v4l2_fmt)
-{
- int i;
-
- for (i = 0; ff_fmt_conversion_table[i].codec_id != AV_CODEC_ID_NONE; i++) {
- if (ff_fmt_conversion_table[i].v4l2_fmt == v4l2_fmt) {
- return ff_fmt_conversion_table[i].codec_id;
- }
- }
-
- return AV_CODEC_ID_NONE;
-}
diff --git a/libavdevice/v4l2-common.h b/libavdevice/v4l2-common.h
deleted file mode 100644
index 40c7164..0000000
--- a/libavdevice/v4l2-common.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVDEVICE_V4L2_COMMON_H
-#define AVDEVICE_V4L2_COMMON_H
-
-#undef __STRICT_ANSI__ //workaround due to broken kernel headers
-#include "config.h"
-#include "libavformat/internal.h"
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <sys/time.h>
-#if HAVE_SYS_VIDEOIO_H
-#include <sys/videoio.h>
-#else
-#if HAVE_ASM_TYPES_H
-#include <asm/types.h>
-#endif
-#include <linux/videodev2.h>
-#endif
-#include "libavutil/atomic.h"
-#include "libavutil/avassert.h"
-#include "libavutil/imgutils.h"
-#include "libavutil/log.h"
-#include "libavutil/opt.h"
-#include "avdevice.h"
-#include "timefilter.h"
-#include "libavutil/parseutils.h"
-#include "libavutil/pixdesc.h"
-#include "libavutil/time.h"
-#include "libavutil/avstring.h"
-
-struct fmt_map {
- enum AVPixelFormat ff_fmt;
- enum AVCodecID codec_id;
- uint32_t v4l2_fmt;
-};
-
-extern const struct fmt_map ff_fmt_conversion_table[];
-
-uint32_t ff_fmt_ff2v4l(enum AVPixelFormat pix_fmt, enum AVCodecID codec_id);
-enum AVPixelFormat ff_fmt_v4l2ff(uint32_t v4l2_fmt, enum AVCodecID codec_id);
-enum AVCodecID ff_fmt_v4l2codec(uint32_t v4l2_fmt);
-
-#endif /* AVDEVICE_V4L2_COMMON_H */
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index 8695645..95fcf5e 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -30,7 +30,23 @@
* V4L2_PIX_FMT_* and AV_PIX_FMT_*
*/
-#include "v4l2-common.h"
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "libavutil/atomic.h"
+#include "libavutil/avassert.h"
+#include "libavutil/avstring.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/parseutils.h"
+#include "libavutil/time.h"
+#include "libavcodec/v4l2-common.h"
+#include "libavformat/internal.h"
+#include "avdevice.h"
+#include "timefilter.h"
#if CONFIG_LIBV4L2
#include <libv4l2.h>
@@ -271,8 +287,8 @@ static void list_formats(AVFormatContext *ctx, int type)
struct v4l2_fmtdesc vfd = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };
while(!v4l2_ioctl(s->fd, VIDIOC_ENUM_FMT, &vfd)) {
- enum AVCodecID codec_id = ff_fmt_v4l2codec(vfd.pixelformat);
- enum AVPixelFormat pix_fmt = ff_fmt_v4l2ff(vfd.pixelformat, codec_id);
+ enum AVCodecID codec_id = avpriv_v4l_fmt_v4l2codec(vfd.pixelformat);
+ enum AVPixelFormat pix_fmt = avpriv_v4l_fmt_v4l2ff(vfd.pixelformat, codec_id);
vfd.index++;
@@ -768,7 +784,7 @@ static int device_try_init(AVFormatContext *ctx,
{
int ret, i;
- *desired_format = ff_fmt_ff2v4l(pix_fmt, ctx->video_codec_id);
+ *desired_format = avpriv_v4l_fmt_ff2v4l(pix_fmt, ctx->video_codec_id);
if (*desired_format) {
ret = device_init(ctx, width, height, *desired_format);
@@ -780,14 +796,14 @@ static int device_try_init(AVFormatContext *ctx,
}
if (!*desired_format) {
- for (i = 0; ff_fmt_conversion_table[i].codec_id != AV_CODEC_ID_NONE; i++) {
+ for (i = 0; avpriv_v4l_fmt_conversion_table[i].codec_id != AV_CODEC_ID_NONE; i++) {
if (ctx->video_codec_id == AV_CODEC_ID_NONE ||
- ff_fmt_conversion_table[i].codec_id == ctx->video_codec_id) {
+ avpriv_v4l_fmt_conversion_table[i].codec_id == ctx->video_codec_id) {
av_log(ctx, AV_LOG_DEBUG, "Trying to set codec:%s pix_fmt:%s\n",
- avcodec_get_name(ff_fmt_conversion_table[i].codec_id),
- (char *)av_x_if_null(av_get_pix_fmt_name(ff_fmt_conversion_table[i].ff_fmt), "none"));
+ avcodec_get_name(avpriv_v4l_fmt_conversion_table[i].codec_id),
+ (char *)av_x_if_null(av_get_pix_fmt_name(avpriv_v4l_fmt_conversion_table[i].ff_fmt), "none"));
- *desired_format = ff_fmt_conversion_table[i].v4l2_fmt;
+ *desired_format = avpriv_v4l_fmt_conversion_table[i].v4l2_fmt;
ret = device_init(ctx, width, height, *desired_format);
if (ret >= 0)
break;
@@ -806,7 +822,7 @@ static int device_try_init(AVFormatContext *ctx,
}
}
- *codec_id = ff_fmt_v4l2codec(*desired_format);
+ *codec_id = avpriv_v4l_fmt_v4l2codec(*desired_format);
av_assert0(*codec_id != AV_CODEC_ID_NONE);
return ret;
}
@@ -939,7 +955,7 @@ static int v4l2_read_header(AVFormatContext *ctx)
if ((res = v4l2_set_parameters(ctx)) < 0)
goto fail;
- st->codec->pix_fmt = ff_fmt_v4l2ff(desired_format, codec_id);
+ st->codec->pix_fmt = avpriv_v4l_fmt_v4l2ff(desired_format, codec_id);
s->frame_size =
avpicture_get_size(st->codec->pix_fmt, s->width, s->height);
diff --git a/libavdevice/v4l2enc.c b/libavdevice/v4l2enc.c
index ac4068c..5d9b7f5 100644
--- a/libavdevice/v4l2enc.c
+++ b/libavdevice/v4l2enc.c
@@ -18,7 +18,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "v4l2-common.h"
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "libavutil/imgutils.h"
+#include "libavutil/pixdesc.h"
+#include "libavcodec/v4l2-common.h"
#include "avdevice.h"
typedef struct {
@@ -56,7 +64,7 @@ static av_cold int write_header(AVFormatContext *s1)
enc_ctx = s1->streams[0]->codec;
- v4l2_pixfmt = ff_fmt_ff2v4l(enc_ctx->pix_fmt, AV_CODEC_ID_RAWVIDEO);
+ v4l2_pixfmt = avpriv_v4l_fmt_ff2v4l(enc_ctx->pix_fmt, AV_CODEC_ID_RAWVIDEO);
if (!v4l2_pixfmt) { // XXX: try to force them one by one?
av_log(s1, AV_LOG_ERROR, "Unknown V4L2 pixel format equivalent for %s\n",
av_get_pix_fmt_name(enc_ctx->pix_fmt));
--
2.1.3
More information about the ffmpeg-devel
mailing list