Commit 0a7b514f authored by Luca Abeni's avatar Luca Abeni Committed by Diego Biurrun

video4linux2 input support

patch by Luca Abeni, lucabe72 $$at$$ email $$dot$$ it

Originally committed as revision 4916 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent b5bba459
...@@ -66,6 +66,7 @@ echo " --disable-altivec disable AltiVec usage" ...@@ -66,6 +66,7 @@ echo " --disable-altivec disable AltiVec usage"
echo " --disable-audio-oss disable OSS audio support [default=no]" echo " --disable-audio-oss disable OSS audio support [default=no]"
echo " --disable-audio-beos disable BeOS audio support [default=no]" echo " --disable-audio-beos disable BeOS audio support [default=no]"
echo " --disable-v4l disable video4linux grabbing [default=no]" echo " --disable-v4l disable video4linux grabbing [default=no]"
echo " --disable-v4l2 disable video4linux2 grabbing [default=no]"
echo " --disable-bktr disable bktr video grabbing [default=no]" echo " --disable-bktr disable bktr video grabbing [default=no]"
echo " --disable-dv1394 disable DV1394 grabbing [default=no]" echo " --disable-dv1394 disable DV1394 grabbing [default=no]"
echo " --disable-network disable network support [default=no]" echo " --disable-network disable network support [default=no]"
...@@ -183,6 +184,7 @@ case "$cpu" in ...@@ -183,6 +184,7 @@ case "$cpu" in
esac esac
gprof="no" gprof="no"
v4l="yes" v4l="yes"
v4l2="yes"
bktr="no" bktr="no"
audio_oss="yes" audio_oss="yes"
audio_beos="no" audio_beos="no"
...@@ -276,6 +278,7 @@ SHFLAGS=-nostart ...@@ -276,6 +278,7 @@ SHFLAGS=-nostart
# disable Linux things # disable Linux things
audio_oss="no" audio_oss="no"
v4l="no" v4l="no"
v4l2="no"
dv1394="no" dv1394="no"
# enable BeOS things # enable BeOS things
audio_beos="yes" audio_beos="yes"
...@@ -290,6 +293,7 @@ extralibs="-lnet" ...@@ -290,6 +293,7 @@ extralibs="-lnet"
fi ;; fi ;;
SunOS) SunOS)
v4l="no" v4l="no"
v4l2="no"
audio_oss="no" audio_oss="no"
dv1394="no" dv1394="no"
make="gmake" make="gmake"
...@@ -300,6 +304,7 @@ extralibs="$extralibs -lsocket -lnsl" ...@@ -300,6 +304,7 @@ extralibs="$extralibs -lsocket -lnsl"
;; ;;
NetBSD) NetBSD)
v4l="no" v4l="no"
v4l2="no"
bktr="yes" bktr="yes"
audio_oss="yes" audio_oss="yes"
dv1394="no" dv1394="no"
...@@ -312,6 +317,7 @@ esac ...@@ -312,6 +317,7 @@ esac
;; ;;
OpenBSD) OpenBSD)
v4l="no" v4l="no"
v4l2="no"
bktr="yes" bktr="yes"
audio_oss="yes" audio_oss="yes"
dv1394="no" dv1394="no"
...@@ -323,6 +329,7 @@ extralibs="$extralibs -lossaudio" ...@@ -323,6 +329,7 @@ extralibs="$extralibs -lossaudio"
;; ;;
FreeBSD) FreeBSD)
v4l="no" v4l="no"
v4l2="no"
bktr="yes" bktr="yes"
audio_oss="yes" audio_oss="yes"
dv1394="no" dv1394="no"
...@@ -332,6 +339,7 @@ LDFLAGS="$LDFLAGS -export-dynamic -pthread" ...@@ -332,6 +339,7 @@ LDFLAGS="$LDFLAGS -export-dynamic -pthread"
;; ;;
BSD/OS) BSD/OS)
v4l="no" v4l="no"
v4l2="no"
bktr="yes" bktr="yes"
audio_oss="yes" audio_oss="yes"
dv1394="no" dv1394="no"
...@@ -343,6 +351,7 @@ installstrip="" ...@@ -343,6 +351,7 @@ installstrip=""
Darwin) Darwin)
cc="cc" cc="cc"
v4l="no" v4l="no"
v4l2="no"
audio_oss="no" audio_oss="no"
dv1394="no" dv1394="no"
ffserver="no" ffserver="no"
...@@ -364,6 +373,7 @@ mingw32="yes" ...@@ -364,6 +373,7 @@ mingw32="yes"
;; ;;
CYGWIN*) CYGWIN*)
v4l="no" v4l="no"
v4l2="no"
audio_oss="yes" audio_oss="yes"
dv1394="no" dv1394="no"
vhook="no" vhook="no"
...@@ -377,6 +387,7 @@ LDFLAGS="$LDFLAGS -rdynamic" ...@@ -377,6 +387,7 @@ LDFLAGS="$LDFLAGS -rdynamic"
IRIX*) IRIX*)
ranlib="echo ignoring ranlib" ranlib="echo ignoring ranlib"
v4l="no" v4l="no"
v4l2="no"
audio_oss="no" audio_oss="no"
make="gmake" make="gmake"
;; ;;
...@@ -397,6 +408,7 @@ EXESUF=".exe" ...@@ -397,6 +408,7 @@ EXESUF=".exe"
extralibs="" extralibs=""
pkg_requires="" pkg_requires=""
v4l="no" v4l="no"
v4l2="no"
audio_oss="no" audio_oss="no"
dv1394="no" dv1394="no"
network="no" network="no"
...@@ -486,6 +498,8 @@ for opt do ...@@ -486,6 +498,8 @@ for opt do
;; ;;
--disable-v4l) v4l="no" --disable-v4l) v4l="no"
;; ;;
--disable-v4l2) v4l2="no"
;;
--disable-bktr) bktr="no" --disable-bktr) bktr="no"
;; ;;
--disable-audio-oss) audio_oss="no" --disable-audio-oss) audio_oss="no"
...@@ -900,6 +914,7 @@ EOF ...@@ -900,6 +914,7 @@ EOF
exit 1 exit 1
fi fi
v4l="no" v4l="no"
v4l2="no"
bktr="no" bktr="no"
audio_oss="no" audio_oss="no"
dv1394="no" dv1394="no"
...@@ -1613,6 +1628,11 @@ if test "$v4l" = "yes" ; then ...@@ -1613,6 +1628,11 @@ if test "$v4l" = "yes" ; then
echo "CONFIG_VIDEO4LINUX=yes" >> config.mak echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
fi fi
if test "$v4l2" = "yes" ; then
echo "#define CONFIG_VIDEO4LINUX2 1" >> $TMPH
echo "CONFIG_VIDEO4LINUX2=yes" >> config.mak
fi
if test "$bktr" = "yes" ; then if test "$bktr" = "yes" ; then
echo "#define CONFIG_BKTR 1" >> $TMPH echo "#define CONFIG_BKTR 1" >> $TMPH
echo "CONFIG_BKTR=yes" >> config.mak echo "CONFIG_BKTR=yes" >> config.mak
......
...@@ -213,8 +213,12 @@ static int rate_emu = 0; ...@@ -213,8 +213,12 @@ static int rate_emu = 0;
#ifdef CONFIG_BKTR #ifdef CONFIG_BKTR
static char *video_grab_format = "bktr"; static char *video_grab_format = "bktr";
#else #else
#ifdef CONFIG_VIDEO4LINUX2
static char *video_grab_format = "video4linux2";
#else
static char *video_grab_format = "video4linux"; static char *video_grab_format = "video4linux";
#endif #endif
#endif
static char *video_device = NULL; static char *video_device = NULL;
static char *grab_device = NULL; static char *grab_device = NULL;
static int video_channel = 0; static int video_channel = 0;
......
...@@ -50,6 +50,10 @@ ifeq ($(CONFIG_VIDEO4LINUX),yes) ...@@ -50,6 +50,10 @@ ifeq ($(CONFIG_VIDEO4LINUX),yes)
OBJS+= grab.o OBJS+= grab.o
endif endif
ifeq ($(CONFIG_VIDEO4LINUX2),yes)
OBJS+= v4l2.o
endif
ifeq ($(CONFIG_BKTR),yes) ifeq ($(CONFIG_BKTR),yes)
OBJS+= grab_bktr.o OBJS+= grab_bktr.o
endif endif
......
...@@ -89,6 +89,9 @@ void av_register_all(void) ...@@ -89,6 +89,9 @@ void av_register_all(void)
#endif #endif
ffm_init(); ffm_init();
#if defined(CONFIG_VIDEO4LINUX2)
v4l2_init();
#endif
#if defined(CONFIG_VIDEO4LINUX) || defined(CONFIG_BKTR) #if defined(CONFIG_VIDEO4LINUX) || defined(CONFIG_BKTR)
video_grab_init(); video_grab_init();
#endif #endif
......
...@@ -239,7 +239,7 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap) ...@@ -239,7 +239,7 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st->codec->sample_rate = s->sample_rate; st->codec->sample_rate = s->sample_rate;
st->codec->channels = s->channels; st->codec->channels = s->channels;
av_set_pts_info(st, 48, 1, 1000000); /* 48 bits pts in us */ av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
return 0; return 0;
} }
...@@ -271,7 +271,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt) ...@@ -271,7 +271,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
if (ret == -1 && (errno == EAGAIN || errno == EINTR)) { if (ret == -1 && (errno == EAGAIN || errno == EINTR)) {
av_free_packet(pkt); av_free_packet(pkt);
pkt->size = 0; pkt->size = 0;
pkt->pts = av_gettime() & ((1LL << 48) - 1); pkt->pts = av_gettime();
return 0; return 0;
} }
if (!(ret == 0 || (ret == -1 && (errno == EAGAIN || errno == EINTR)))) { if (!(ret == 0 || (ret == -1 && (errno == EAGAIN || errno == EINTR)))) {
...@@ -291,7 +291,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt) ...@@ -291,7 +291,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
cur_time -= (bdelay * 1000000LL) / (s->sample_rate * s->channels); cur_time -= (bdelay * 1000000LL) / (s->sample_rate * s->channels);
/* convert to wanted units */ /* convert to wanted units */
pkt->pts = cur_time & ((1LL << 48) - 1); pkt->pts = cur_time;
if (s->flip_left && s->channels == 2) { if (s->flip_left && s->channels == 2) {
int i; int i;
......
...@@ -82,7 +82,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) ...@@ -82,7 +82,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st = av_new_stream(s1, 0); st = av_new_stream(s1, 0);
if (!st) if (!st)
return -ENOMEM; return -ENOMEM;
av_set_pts_info(st, 48, 1, 1000000); /* 48 bits pts in us */ av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
s->width = width; s->width = width;
s->height = height; s->height = height;
...@@ -331,7 +331,7 @@ static int grab_read_packet(AVFormatContext *s1, AVPacket *pkt) ...@@ -331,7 +331,7 @@ static int grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
if (av_new_packet(pkt, s->frame_size) < 0) if (av_new_packet(pkt, s->frame_size) < 0)
return AVERROR_IO; return AVERROR_IO;
pkt->pts = curtime & ((1LL << 48) - 1); pkt->pts = curtime;
/* read one frame */ /* read one frame */
if (s->aiw_enabled) { if (s->aiw_enabled) {
......
...@@ -229,7 +229,7 @@ static int grab_read_packet(AVFormatContext *s1, AVPacket *pkt) ...@@ -229,7 +229,7 @@ static int grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
bktr_getframe(s->per_frame); bktr_getframe(s->per_frame);
pkt->pts = av_gettime() & ((1LL << 48) - 1); pkt->pts = av_gettime();
memcpy(pkt->data, video_buf, video_buf_size); memcpy(pkt->data, video_buf, video_buf_size);
return video_buf_size; return video_buf_size;
...@@ -260,7 +260,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) ...@@ -260,7 +260,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
st = av_new_stream(s1, 0); st = av_new_stream(s1, 0);
if (!st) if (!st)
return -ENOMEM; return -ENOMEM;
av_set_pts_info(st, 48, 1, 1000000); /* 48 bits pts in use */ av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in use */
s->width = width; s->width = width;
s->height = height; s->height = height;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment