diff options
author | Mario Sergio Fujikawa Ferreira <lioux@FreeBSD.org> | 2005-06-06 02:05:01 +0000 |
---|---|---|
committer | Mario Sergio Fujikawa Ferreira <lioux@FreeBSD.org> | 2005-06-06 02:05:01 +0000 |
commit | 74ca587a9e593f461527465a489bd63c186f1847 (patch) | |
tree | c5c099911c3e57ee78e318ad37b3b3ec9c013c8d /multimedia | |
parent | c7a6f12d72438292339d1995109b26461c806e84 (diff) |
o Improve the bktr(4) device grab code [1]
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
o Inherit CFLAGS (uphold CFLAGS) if WITH_OPTIMIZED_CFLAGS
o Build and install post processing library
o Bump PORTREVISION
Submitted by: Steve O'Hara-Smith <steve@sohara.org> et al [1]
Notes
Notes:
svn path=/head/; revision=136883
Diffstat (limited to 'multimedia')
-rw-r--r-- | multimedia/ffmpeg/Makefile | 48 | ||||
-rw-r--r-- | multimedia/ffmpeg/files/grab_bsdbktr.c | 38 |
2 files changed, 59 insertions, 27 deletions
diff --git a/multimedia/ffmpeg/Makefile b/multimedia/ffmpeg/Makefile index 936b901d48fd..fd008329a32a 100644 --- a/multimedia/ffmpeg/Makefile +++ b/multimedia/ffmpeg/Makefile @@ -7,7 +7,7 @@ PORTNAME= ffmpeg DISTVERSION= 0.4.9-pre1 -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= multimedia audio net MASTER_SITES= ${MASTER_SITE_SOURCEFORGE_EXTENDED} MASTER_SITE_SUBDIR= ffmpeg @@ -22,8 +22,9 @@ USE_REINPLACE= yes WANT_SDL= yes CONFIGURE_ARGS= --cc="${CC}" --prefix="${PREFIX}" \ --make="${GMAKE}" --enable-shared \ - --extra-ldflags="-L${LOCALBASE}/lib -L${X11BASE}/lib" \ - --extra-libs"-lm" \ + --extra-ldflags="-L${WRKSRC}/libavcodec -L${WRKSRC}/libavcodec/libpostproc \ + -L${LOCALBASE}/lib -L${X11BASE}/lib " \ + --extra-libs="-lm" \ --disable-debug PLIST_SUB= SHLIB_VERSION=${SHLIB_VERSION} @@ -154,28 +155,29 @@ LIB_DEPENDS+= mp3lame.0:${PORTSDIR}/audio/lame CONFIGURE_ARGS+= --enable-mp3lame .endif ## optimization +# breaks ffmpeg build if defined +CFLAGS+= -fno-force-addr .if ${OSVERSION} > 502124 . ifdef(WITH_OPTIMIZED_CFLAGS) CONFIGURE_ARGS+= --extra-cflags="-fPIC -DPIC -I${LOCALBASE}/include \ + ${CFLAGS} \ -I${X11BASE}/include \ - -ffast-math -fomit-frame-pointer -fno-unit-at-a-time" \ - --extra-ldflags="-L${LOCALBASE}/lib -L${X11BASE}/lib -lm" + -ffast-math -fomit-frame-pointer -fno-unit-at-a-time" . else CONFIGURE_ARGS+= --extra-cflags="-fPIC -DPIC -I${LOCALBASE}/include \ -I${X11BASE}/include \ - -fomit-frame-pointer -fno-unit-at-a-time" \ - --extra-ldflags="-L${LOCALBASE}/lib -L${X11BASE}/lib -lm " -# --disable-opts + -fomit-frame-pointer -fno-unit-at-a-time" . endif .else +. ifdef(WITH_OPTIMIZED_CFLAGS) CONFIGURE_ARGS+= --extra-cflags="-fPIC -DPIC -I${LOCALBASE}/include \ + ${CFLAGS} \ -I${X11BASE}/include \ - -ffast-math -fomit-frame-pointer" \ - --extra-ldflags="-L${LOCALBASE}/lib -L${X11BASE}/lib -lm" + -ffast-math -fomit-frame-pointer" . else CONFIGURE_ARGS+= --extra-cflags="-fPIC -DPIC -I${LOCALBASE}/include \ - -I${X11BASE}/include" \ - --extra-ldflags="-L${WRKSRC}/libavcodec -L${LOCALBASE}/lib -L${X11BASE}/lib -lm " + -I${X11BASE}/include" +. endif .endif ## vhook @@ -214,6 +216,15 @@ CONFIGURE_ARGS+= --enable-gpl CONFIGURE_ARGS+= --enable-shared-pp PLIST_FILES+= include/ffmpeg/postproc/postprocess.h PLIST_DIRS+= include/ffmpeg/postproc +. ifdef(GPLLIBS) +CONFIGURE_ARGS+= --enable-pp + +LIB_POSTPROC= lib/libpostproc.a \ + lib/libpostproc.so \ + lib/libpostproc.so.0 \ + lib/libpostproc.so.${SHLIB_VERSION} +PLIST_FILES+= ${LIB_POSTPROC} +. endif .endif ## ffserver .ifdef(WITHOUT_FFMPEG_FFSERVER) @@ -349,6 +360,11 @@ post-patch: -e 's|#include <SDL|#include <SDL11/SDL|' .endif +pre-build: +.ifndef(WITHOUT_POSTPROCESS) + @cd ${WRKSRC}/libavcodec/libpostproc && ${GMAKE} +.endif + post-install: .ifndef(NOPORTDOCS) @${MKDIR} ${DOCSDIR} @@ -383,6 +399,14 @@ post-install: @${MKDIR} ${PREFIX}/include/ffmpeg/postproc @${INSTALL_DATA} ${WRKSRC}/libavcodec/libpostproc/postprocess.h \ ${PREFIX}/include/ffmpeg/postproc/postprocess.h +. ifdef(GPLLIBS) +. for lib in libpostproc.a libpostproc.so + @${INSTALL_DATA} ${WRKSRC}/libavcodec/libpostproc/${lib} \ + ${PREFIX}/lib +. endfor + @${LN} -sf libpostproc.so ${PREFIX}/lib/libpostproc.so.0 + @${LN} -sf libpostproc.so ${PREFIX}/lib/libpostproc.so.${SHLIB_VERSION} +. endif .endif .include <bsd.port.post.mk> diff --git a/multimedia/ffmpeg/files/grab_bsdbktr.c b/multimedia/ffmpeg/files/grab_bsdbktr.c index 853cf55221f4..21111c827e44 100644 --- a/multimedia/ffmpeg/files/grab_bsdbktr.c +++ b/multimedia/ffmpeg/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> @@ -136,7 +141,6 @@ static int bktr_init (const char *video_device, int width, int height, 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) { @@ -167,7 +171,7 @@ static int bktr_init (const char *video_device, int width, int height, perror ("METEORSINPUT"); return -1; } - *video_buf = (u_int8_t *) mmap((caddr_t)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 == MAP_FAILED) { perror ("mmap"); @@ -175,8 +179,11 @@ static int bktr_init (const char *video_device, int width, int height, } 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); @@ -191,9 +198,12 @@ static void bktr_getframe(u_int64_t per_frame) 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/8 - 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)); @@ -224,16 +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 -EIO; + 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; } @@ -265,7 +272,6 @@ 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; @@ -273,9 +279,9 @@ static int grab_read_header (AVFormatContext *s1, AVFormatParameters *ap) st->codec.frame_rate = frame_rate; st->codec.frame_rate_base = frame_rate_base; - av_set_pts_info(s1, 48, 1, 1000000); /* 48 bits pts in use */ + 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")) @@ -286,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 -EIO; + return -AVERROR_IO; return 0; } @@ -296,9 +302,11 @@ 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); - av_free(s); + munmap((void *)video_buf, sizeof(video_buf)); return 0; } |