From owner-freebsd-multimedia Sat Nov 2 14: 5:54 2002 Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A6AF137B401 for ; Sat, 2 Nov 2002 14:05:49 -0800 (PST) Received: from heaven.gigo.com (heaven.gigo.com [64.57.102.22]) by mx1.FreeBSD.org (Postfix) with ESMTP id DE44243E9E for ; Sat, 2 Nov 2002 14:05:48 -0800 (PST) (envelope-from lioux@brturbo.com) Received: from 200-193-225-247-bsace7003.dsl.telebrasilia.net.br (200-193-225-247-bsace7003.dsl.telebrasilia.net.br [200.193.225.247]) by heaven.gigo.com (Postfix) with ESMTP id 07D7BB851 for ; Sat, 2 Nov 2002 14:05:34 -0800 (PST) Received: (qmail 40686 invoked by uid 1001); 2 Nov 2002 22:02:32 -0000 Message-ID: <20021102220232.40685.qmail@exxodus.fedaykin.here> Date: Sat, 2 Nov 2002 19:02:10 -0300 From: Mario Sergio Fujikawa Ferreira To: Steve O'Hara-Smith Cc: Carl Makin , freebsd-multimedia@FreeBSD.ORG Subject: Re: ffmpeg compile optimisation helps no end! was Re: FreeBSD 4.7R: no sound when recording with ffmpeg? References: <20021028063325.224adec5.steve@sohara.org> <20021102173507.352ddc71.steve@sohara.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="VS++wcV0S1rZb1Fb" Content-Disposition: inline In-Reply-To: <20021102173507.352ddc71.steve@sohara.org> User-Agent: Mutt/1.4i X-Operating-System: FreeBSD 4.7-STABLE X-Disclaimer: I hope you find what you are looking for... in life :) Sender: owner-freebsd-multimedia@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org --VS++wcV0S1rZb1Fb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Nov 02, 2002 at 05:34:45PM +0100, Steve O'Hara-Smith wrote: > On Mon, 28 Oct 2002 23:21:32 +1100 > Carl Makin wrote: > > CM> I have a Celeron 600 and the above ffmpeg parms give me excellent > CM> video with only the occasional jerkyness, however the audio goes out > > I've just noticed something silly, ffmpeg is compiled > completely without optimisation. Try applying the attached patch in > /usr/ports/graphics/ffmpeg (it adds -O3-fomit-frame-pointer to the > compile options). > > I think this is worth committing, with it I can use default > motion estimation and even high quality settings at full resolution > without dropping frames. Humm, I am improved a bit on your idea. :) First, ffmpeg is now CFLAGS safe (I'm a bit confused as to why it was not before); meaning that it will use your CFLAGS now. Second, it will add some optimizations if WITH_OPTIMIZED_CFLAGS is enabled. Third, if not defined WITHOUT_LIBA52, ffmpeg will now use ports' liba52 port instead of internal code. liba52 in ports is faster than ffmpeg's version. Finally, ffmpeg will now use FreeBSD byteswap optimized routines IF you happen to be using a FreeBSD 4.7-RELEASE or later (any 5.x-CURRENT applies) #if defined(__FreeBSD__) && __FreeBSD_version >= 470000 #endif It will use both 16 and 32 bits kernel byteswap routines available in /usr/include/sys/endian.h instead of its own version of them. As far as I can tell, these byteswap routines are only used with mpeg video. However, mpeg video seems to be used a lot by booktree users so it should help a bit. :) I tested these changes with several mpeg output formats: mpeg1video mpeg4 msmpeg4v1 msmpeg4v2 msmpeg4. Everything seems fine but I did not benchmark anything. Steve? Could you try some benchmarks since you've been timing stuff? Unfortunaly, I do not have a booktree board to test capture performance. Regards, -- Mario S F Ferreira - DF - Brazil - "I guess this is a signature." Computer Science Undergraduate | FreeBSD Committer | CS Developer flames to beloved devnull@someotherworldbeloworabove.org feature, n: a documented bug | bug, n: an undocumented feature --VS++wcV0S1rZb1Fb Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch-ffmpeg diff -ruN /usr/ports/graphics/ffmpeg/Makefile ffmpeg/Makefile --- /usr/ports/graphics/ffmpeg/Makefile Wed Oct 16 05:33:47 2002 +++ ffmpeg/Makefile Sat Nov 2 18:41:01 2002 @@ -26,7 +26,6 @@ USE_REINPLACE= yes CONFIGURE_ARGS= --cc="${CC}" --prefix="${PREFIX}" \ --make="${GMAKE}" --enable-shared \ - --extra-cflags="-I${LOCALBASE}/include" \ --extra-libs="-lm -L${LOCALBASE}/lib" PLIST_SUB= SHLIB_VERSION=${SHLIB_VERSION} INSTALLS_SHLIB= yes @@ -58,6 +57,16 @@ ## support activation ## +## disable a52 +.ifndef(WITHOUT_A52) +LIB_DEPENDS+= a52.0:${PORTSDIR}/audio/liba52 + +CONFIGURE_ARGS+= --enable-a52 \ + --enable-a52bin +.else +CONFIGURE_ARGS+= --enable-a52 \ + --disable-a52bin +.endif ## disable mmx .ifdef(WITHOUT_MMX) CONFIGURE_ARGS+= --disable-mmx @@ -68,6 +77,13 @@ CONFIGURE_ARGS+= --enable-mp3lame .endif +## optimization +.ifdef(WITH_OPTIMIZED_CFLAGS) +CONFIGURE_ARGS+= --extra-cflags="${CFLAGS} -I${LOCALBASE}/include \ + -O3 -ffast-math -fomit-frame-pointer" +.else +CONFIGURE_ARGS+= --extra-cflags="${CFLAGS} -I${LOCALBASE}/include" +.endif ## vorbis .ifdef(WITH_VORBIS) LIB_DEPENDS+= vorbisenc.2:${PORTSDIR}/audio/libvorbis @@ -76,12 +92,20 @@ .endif pre-everything:: +.ifndef(WITHOUT_LIBA52) + @${ECHO_MSG} "You can disable liba52 support by defining WITHOUT_LIBA52" +.endif .ifndef(WITHOUT_MMX) @${ECHO_MSG} "Define WITHOUT_MMX if your system does not support MMX" .endif .ifndef(WITH_MP3) @${ECHO_MSG} 'Define WITH_MP3 to enable lame MP3 codec' .endif +.ifndef(WITH_OPTIMIZED_CFLAGS) + @${ECHO_MSG} + @${ECHO_MSG} 'You can enable additional compilation optimizations' + @${ECHO_MSG} 'by defining WITH_OPTIMIZED_CFLAGS' +.endif .ifndef(WITH_VORBIS) @${ECHO_MSG} 'Define WITH_VORBIS to enable libvorbisenc VORBIS codec' .endif @@ -117,6 +141,10 @@ @${REINPLACE_CMD} -e \ "s!VIDEO_INPUT METEOR_INPUT_DEV0!VIDEO_INPUT METEOR_INPUT_DEV${WITH_BKTR_DEV}!" \ ${WRKSRC}/libav/grab_bsdbktr.c +.endif +.ifndef(WITHOUT_LIBA52) + @${REINPLACE_CMD} -e 's|-ldl||' \ + ${WRKSRC}/configure .endif post-install: Binary files /usr/ports/graphics/ffmpeg/ffmpeg-cvs.tar.gz and ffmpeg/ffmpeg-cvs.tar.gz differ diff -ruN /usr/ports/graphics/ffmpeg/files/patch-libavcodec::bswap.h ffmpeg/files/patch-libavcodec::bswap.h --- /usr/ports/graphics/ffmpeg/files/patch-libavcodec::bswap.h Wed Dec 31 21:00:00 1969 +++ ffmpeg/files/patch-libavcodec::bswap.h Sat Nov 2 14:00:01 2002 @@ -0,0 +1,37 @@ +--- libavcodec/bswap.h.orig Sat Nov 2 13:54:00 2002 ++++ libavcodec/bswap.h Sat Nov 2 13:59:41 2002 +@@ -5,6 +5,10 @@ + #include + #else + ++#if defined(__FreeBSD__) && __FreeBSD_version >= 470000 ++#include ++#endif ++ + #ifdef ARCH_X86 + inline static unsigned short ByteSwap16(unsigned short x) + { +@@ -13,7 +17,11 @@ + "0" (x)); + return x; + } ++#if defined(__FreeBSD__) && __FreeBSD_version >= 470000 ++#define bswap_16(x) (be16toh(x)) ++#else + #define bswap_16(x) ByteSwap16(x) ++#endif + + inline static unsigned int ByteSwap32(unsigned int x) + { +@@ -29,7 +37,11 @@ + "0" (x)); + return x; + } ++#if defined(__FreeBSD__) && __FreeBSD_version >= 470000 ++#define bswap_32(x) (be32toh(x)) ++#else + #define bswap_32(x) ByteSwap32(x) ++#endif + + inline static unsigned long long int ByteSwap64(unsigned long long int x) + { --VS++wcV0S1rZb1Fb-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-multimedia" in the body of the message