aboutsummaryrefslogtreecommitdiffstats
path: root/multimedia
diff options
context:
space:
mode:
authorlioux <lioux@FreeBSD.org>2005-06-08 10:33:41 +0800
committerlioux <lioux@FreeBSD.org>2005-06-08 10:33:41 +0800
commita7339a35738814e01c74519704b2bb7943580900 (patch)
tree4ab3bfc63041e460965ae75960a4e6310715e8d5 /multimedia
parent9c53a4762d826cfb54ef446064082a3863469024 (diff)
downloadfreebsd-ports-gnome-a7339a35738814e01c74519704b2bb7943580900.tar.gz
freebsd-ports-gnome-a7339a35738814e01c74519704b2bb7943580900.tar.zst
freebsd-ports-gnome-a7339a35738814e01c74519704b2bb7943580900.zip
I) Update to snapshot 20050607
II) Improve the bktr(4) device grab code [1] in sync with multimedia/ffmpeg/files/grab_bsdbktr.c revision 1.9 1) Add support for DragonFly 2) Use proper castings 3) Test file descriptors before using them 4) Improve frame capture 5) Fix some errors 6) Clean up the signals on bktr(4) when closing the device III) Re-enable video capture WITH_VIDEO_CAPTURE due to (II) Submitted by: Steve O'Hara-Smith <steve@sohara.org> et al [1]
Diffstat (limited to 'multimedia')
-rw-r--r--multimedia/ffmpeg-devel/Makefile13
-rw-r--r--multimedia/ffmpeg-devel/distinfo4
-rw-r--r--multimedia/ffmpeg-devel/files/extra-bktr-patch-libavformat::Makefile11
-rw-r--r--multimedia/ffmpeg-devel/files/grab_bsdbktr.c94
4 files changed, 67 insertions, 55 deletions
diff --git a/multimedia/ffmpeg-devel/Makefile b/multimedia/ffmpeg-devel/Makefile
index da6c7f99a26c..9d824e89f2b1 100644
--- a/multimedia/ffmpeg-devel/Makefile
+++ b/multimedia/ffmpeg-devel/Makefile
@@ -55,7 +55,7 @@ INSTALLS_SHLIB= yes
NO_LATEST_LINK= yes
CONFLICTS= ffmpeg-[0-9]*-*
-RELEASE_DATE= 20050605
+RELEASE_DATE= 20050607
SHLIB_VERSION= 1
MAN1= ffmpeg.1
@@ -83,9 +83,6 @@ LIB_FILES= libavcodec/libavcodec.a libavformat/libavformat.a
##
GPLLIBS=yes
WITHOUT_LIBA52=yes
-# video captuure is not working as of yet
-WITH_VIDEO_CAPTURE=no
-CONFIGURE_ARGS+=--disable-v4l
##
## support detection
@@ -99,6 +96,8 @@ WITH_IPV6= yes
##
.if ${ARCH} != "i386"
WITHOUT_MMX= yes
+.else
+EXTRA_PATCHES+= ${FILESDIR}/extra-bktr-patch-libavformat::Makefile
.endif
##
@@ -415,6 +414,11 @@ pre-everything::
@${ECHO_MSG}
.endif
.if ${ARCH} == "i386"
+. ifndef(WITH_VIDEO_CAPTURE)
+ @${ECHO_MSG} 'Define WITH_VIDEO_CAPTURE to enable bktr(4) driver'
+ @${ECHO_MSG} 'video capture'
+ @${ECHO_MSG}
+. else
.if !(defined(WITH_BKTR_FORMAT) && defined(WITH_BKTR_DEV))
@${ECHO_MSG}
@${ECHO_MSG} 'If you want to capture from a bktr(4) supported card'
@@ -426,6 +430,7 @@ pre-everything::
@${ECHO_MSG} 'Warning: invalid settings will probably dump cores'
@${ECHO_MSG}
.endif
+. endif # WITH_VIDEO_CAPTURE
.endif # ${ARCH} == i386
post-extract:
diff --git a/multimedia/ffmpeg-devel/distinfo b/multimedia/ffmpeg-devel/distinfo
index dba5940da29b..818035af66f0 100644
--- a/multimedia/ffmpeg-devel/distinfo
+++ b/multimedia/ffmpeg-devel/distinfo
@@ -1,2 +1,2 @@
-MD5 (FFMpeg-20050605.tar.bz2) = ca92f31b3044ffd9d7c4be9358c94356
-SIZE (FFMpeg-20050605.tar.bz2) = 1621717
+MD5 (FFMpeg-20050607.tar.bz2) = fe3a5ba1ddb5feeb9efbdd687a39e0c5
+SIZE (FFMpeg-20050607.tar.bz2) = 1621376
diff --git a/multimedia/ffmpeg-devel/files/extra-bktr-patch-libavformat::Makefile b/multimedia/ffmpeg-devel/files/extra-bktr-patch-libavformat::Makefile
new file mode 100644
index 000000000000..d5e22abe72d1
--- /dev/null
+++ b/multimedia/ffmpeg-devel/files/extra-bktr-patch-libavformat::Makefile
@@ -0,0 +1,11 @@
+--- libavformat/Makefile.orig Mon Jun 6 21:05:05 2005
++++ libavformat/Makefile Mon Jun 6 21:05:10 2005
+@@ -37,7 +37,7 @@
+ OBJS+= framehook.o
+
+ ifeq ($(CONFIG_VIDEO4LINUX),yes)
+-OBJS+= grab.o
++OBJS+= grab_bsdbktr.o
+ endif
+
+ ifeq ($(CONFIG_DV1394),yes)
diff --git a/multimedia/ffmpeg-devel/files/grab_bsdbktr.c b/multimedia/ffmpeg-devel/files/grab_bsdbktr.c
index afb4b79574bb..3112fc9a9c94 100644
--- a/multimedia/ffmpeg-devel/files/grab_bsdbktr.c
+++ b/multimedia/ffmpeg-devel/files/grab_bsdbktr.c
@@ -1,6 +1,6 @@
/*
* FreeBSD video grab interface
- * Copyright (c) 2002 Steve O'Hara-Smith
+ * Copyright (c) 2002,2003,2004,2005 Steve O'Hara-Smith
* based on
* Linux video grab interface
* Copyright (c) 2000,2001 Gerard Lantau.
@@ -24,6 +24,10 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "avformat.h"
+#if defined __DragonFly__
+#include <dev/video/meteor/ioctl_meteor.h>
+#include <dev/video/bktr/ioctl_bt848.h>
+#else
#if __FreeBSD__ >= 502100
#include <dev/bktr/ioctl_meteor.h>
#include <dev/bktr/ioctl_bt848.h>
@@ -31,6 +35,7 @@
#include <machine/ioctl_meteor.h>
#include <machine/ioctl_bt848.h>
#endif
+#endif
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
@@ -80,7 +85,7 @@ static void catchsignal(int signal)
}
static int bktr_init (const char *video_device, int width, int height,
- int format, u_int8_t **video_buf_local, int *video_fd, int *tuner_fd,
+ int format, u_int8_t **video_buf, int *video_fd, int *tuner_fd,
int idev, double frequency)
{
struct meteor_geomet geo;
@@ -127,17 +132,15 @@ static int bktr_init (const char *video_device, int width, int height,
perror("Warning: Tuner not opened continuing");
}
-// *video_fd = open (video_device, O_RDONLY);
- *video_fd = open (video_device, O_RDWR);
+ *video_fd = open (video_device, O_RDONLY);
if (*video_fd < 0) {
perror (video_device);
- return AVERROR_IO;
+ return -1;
}
geo.rows = height;
geo.columns = width;
geo.frames = 1;
-// geo.oformat = METEOR_GEO_YUV_422 | METEOR_GEO_YUV_12;
geo.oformat = METEOR_GEO_YUV_PACKED;
switch (format) {
@@ -168,16 +171,19 @@ static int bktr_init (const char *video_device, int width, int height,
perror ("METEORSINPUT");
return -1;
}
- *video_buf_local = (u_int8_t *) mmap((void *)0, width*height*2,
+ *video_buf = (u_int8_t *) mmap((void *) 0, width*height*2,
PROT_READ, MAP_SHARED, *video_fd, (off_t) 0);
- if (*video_buf_local == MAP_FAILED) {
+ if (*video_buf == MAP_FAILED) {
perror ("mmap");
return -1;
}
if (frequency != 0.0) {
ioctl_frequency = (unsigned long)(frequency*16);
- if (ioctl(*tuner_fd, TVTUNER_SETFREQ, &ioctl_frequency)<0)
- perror("TVTUNER_SETFREQ");
+ if (*tuner_fd > 0)
+ {
+ if (ioctl(*tuner_fd, TVTUNER_SETFREQ, &ioctl_frequency)<0)
+ perror("TVTUNER_SETFREQ");
+ }
}
c = METEOR_CAP_CONTINOUS;
ioctl(*video_fd, METEORCAPTUR, &c);
@@ -186,29 +192,26 @@ static int bktr_init (const char *video_device, int width, int height,
return 0;
}
-static void bktr_getframe(VideoData *s)
+static void bktr_getframe(u_int64_t per_frame)
{
- int64_t curtime, delay;
- struct timespec ts;
-
- /* Calculate the time of the next frame */
- s->per_frame += int64_t_C(1000000);
-
- /* wait based on the frame rate */
- for(;;) {
- curtime = av_gettime();
- delay = s->per_frame * s->frame_rate_base / s->frame_rate - curtime;
- if (delay <= 0) {
- if (delay < int64_t_C(-1000000) * s->frame_rate_base / s->frame_rate) {
- /* printf("grabbing is %d frames late (dropping)\n", (int) -(delay / 16666)); */
- s->per_frame += int64_t_C(1000000);
- }
- break;
+ u_int64_t curtime;
+ static u_int64_t last_frame_time = 0;
+
+ curtime = av_gettime();
+ if (!last_frame_time)
+ last_frame_time = curtime;
+
+ if (!last_frame_time
+ || ((last_frame_time + per_frame) > curtime)) {
+ if (!usleep (last_frame_time + per_frame + per_frame/2 + per_frame/4 - curtime)) {
+ if (!nsignals)
+ printf ("\nSLEPT NO signals - %d microseconds late\n",
+ (int) (av_gettime() - last_frame_time - per_frame));
}
- ts.tv_sec = delay / 1000000;
- ts.tv_nsec = (delay % 1000000) * 1000;
- nanosleep(&ts, NULL);
}
+ nsignals = 0;
+
+ last_frame_time = curtime;
}
void bf_memcpy (char *dest, char *src, int size)
@@ -231,18 +234,13 @@ static int grab_read_packet(AVFormatContext *s1, AVPacket *pkt)
size = s->width * s->height;
halfsize = size << 1;
-// if (av_new_packet(pkt, size + halfsize) < 0)
if (av_new_packet(pkt, size + size) < 0)
- return AVERROR_IO;
-
- bktr_getframe (s);
-// pkt->pts = av_gettime() & ((1LL << 48) - 1);
- pkt->pts = av_gettime() * s->frame_rate / s->frame_rate_base;
+ return -AVERROR_IO;
+ bktr_getframe (s->per_frame);
+ pkt->pts = av_gettime() & ((1LL << 48) - 1);
bf_memcpy (pkt->data, video_buf, size + size);
-// bf_memcpy (pkt->data, video_buf, size + halfsize);
-// return size + halfsize;
return size + size;
}
@@ -260,18 +258,13 @@ static int grab_read_header (AVFormatContext *s1, AVFormatParameters *ap)
width = ap->width;
height = ap->height;
- frame_rate = ap->time_base.den;
+ frame_rate = ap->time_base.den;
frame_rate_base = ap->time_base.num;
- if((unsigned)width > 32767 || (unsigned)height > 32767)
- return -1;
-
st = av_new_stream(s1, 0);
if (!st)
return -ENOMEM;
- av_set_pts_info(st, 48, 1, 1000000); /* 48 bits pts in us */
-
s->width = width;
s->height = height;
s->frame_rate = frame_rate;
@@ -279,15 +272,16 @@ static int grab_read_header (AVFormatContext *s1, AVFormatParameters *ap)
s->per_frame = ((int64_t)1000000 * s->frame_rate_base) / s->frame_rate;
st->codec.codec_type = CODEC_TYPE_VIDEO;
-// st->codec.pix_fmt = PIX_FMT_YUV420P;
st->codec.pix_fmt = PIX_FMT_YUV422;
st->codec.codec_id = CODEC_ID_RAWVIDEO;
st->codec.width = width;
st->codec.height = height;
- st->codec.time_base.den = frame_rate;
- st->codec.time_base.num = frame_rate_base;
+ st->codec.time_base.den = frame_rate;
+ st->codec.time_base.num = frame_rate_base;
+
+ av_set_pts_info(st, 48, 1, 1000000); /* 48 bits pts in use */
- if (ap->standard) {
+ if (ap->standard) {
if (!strcasecmp(ap->standard, "pal"))
format = PAL;
if (!strcasecmp(ap->standard, "secam"))
@@ -298,7 +292,7 @@ static int grab_read_header (AVFormatContext *s1, AVFormatParameters *ap)
if (bktr_init (video_device, width, height, format, &video_buf,
&(s->fd), &(s->tuner_fd), -1, 0.0) < 0)
- return AVERROR_IO;
+ return -AVERROR_IO;
return 0;
}
@@ -308,6 +302,8 @@ static int grab_read_close (AVFormatContext *s1)
int c = METEOR_CAP_STOP_CONT;
ioctl(s->fd, METEORCAPTUR, &c);
+ c = METEOR_SIG_MODE_MASK;
+ ioctl(s->fd, METEORSSIGNAL, &c);
close(s->fd);
close(s->tuner_fd);
munmap((void *)video_buf, sizeof(video_buf));