Commit 7653ae30 authored by diego's avatar diego

video4linux2 input support

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


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