From owner-freebsd-ports-bugs@FreeBSD.ORG Mon Oct 13 04:30:02 2008 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38E4010656A3 for ; Mon, 13 Oct 2008 04:30:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id E420A8FC15 for ; Mon, 13 Oct 2008 04:30:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id m9D4U1lQ052273 for ; Mon, 13 Oct 2008 04:30:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id m9D4U1oE052270; Mon, 13 Oct 2008 04:30:01 GMT (envelope-from gnats) Resent-Date: Mon, 13 Oct 2008 04:30:01 GMT Resent-Message-Id: <200810130430.m9D4U1oE052270@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Carlos Santos Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DA4C9106568B for ; Mon, 13 Oct 2008 04:24:50 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id C8DDB8FC16 for ; Mon, 13 Oct 2008 04:24:50 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id m9D4OouY006670 for ; Mon, 13 Oct 2008 04:24:50 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id m9D4OoXg006669; Mon, 13 Oct 2008 04:24:50 GMT (envelope-from nobody) Message-Id: <200810130424.m9D4OoXg006669@www.freebsd.org> Date: Mon, 13 Oct 2008 04:24:50 GMT From: Carlos Santos To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/128042: [PATCH] multimedia/xvid: use assembly for better performance X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Oct 2008 04:30:02 -0000 >Number: 128042 >Category: ports >Synopsis: [PATCH] multimedia/xvid: use assembly for better performance >Confidential: no >Severity: critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Oct 13 04:30:01 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Carlos Santos >Release: 8.0-CURRENT >Organization: N.A. >Environment: FreeBSD poacasantos1 8.0-CURRENT FreeBSD 8.0-CURRENT #0: Sat Oct 11 19:09:09 BRT 2008 root@poacasantos1:/local/FreeBSD/obj-current/local/FreeBSD/src-current/sys/GENERIC amd64 >Description: >From a message set by Michel Talon to freebsd-ports on Oct 9 2008: "Trying to encode with mencoder and the xvid codec, I discovered that it is awfully slow (around 3 frames/s on my P4 machine). So I played a little bit with the options in the Makefile without any success. Finally I understood that the cause was that the build system requires nasm, but doesn't use it! There are several assembly files in the xvid codec which are not used due to that. The solution i have found by looking at the configure script is to install the yasm port. Then the build system picks the yasm dependency and compiles the assembly files, which enables SSE instructions. The net result is that, without any other tweak, i now encode the same stuff at 11 frames/s. So to be short, multimedia/xvid should require a dependency on yasm." Sean Winn noted that the problem comes because the configure script tries to use the -r option which yasm has but not nasm. So the xvid people had really yasm in view when doing their work. Fixing the configure script should be done upstream, but it seems that the xvid project is somewhat asleep, so better use yasm in the Makefile on which there is control. I (Casantos) gave it a try and found that configure needs some help on AMD64 because it expects the architecture name to be "x86_64", not "amd64". >How-To-Repeat: Build multimedia/xvid version 1.1.3_1. >Fix: The attached patch fixes the build in order to use yasm. According to Michel Talon, "the performance improvement obtained by using SSE instructions in the assembly files is astounding. I could not beleive what i was seeing, basically an x 4 improvement, that is the code perfectly parallelizes the computations on the 128 bits registers." The patch also eliminates the pkg-plist file, using PLIST_FILES instead, since the port installs only three files and one symbolic link. Patch attached with submission follows: diff -durN xvid.orig/Makefile xvid/Makefile --- xvid.orig/Makefile 2008-09-08 00:02:28.000000000 -0300 +++ xvid/Makefile 2008-10-13 00:43:21.000000000 -0300 @@ -7,7 +7,7 @@ PORTNAME= xvid PORTVERSION= 1.1.3 -PORTEPOCH= 1 +PORTEPOCH= 2 CATEGORIES= multimedia MASTER_SITES= http://downloads.xvid.org/downloads/ DISTNAME= ${PORTNAME}core-${PORTVERSION} @@ -15,17 +15,27 @@ MAINTAINER= ports@FreeBSD.org COMMENT= An opensource MPEG-4 codec, based on OpenDivx -BUILD_DEPENDS= ${LOCALBASE}/bin/nasm:${PORTSDIR}/devel/nasm - GNU_CONFIGURE= yes USE_LDCONFIG= yes -WRKSRC= ${WRKDIR}/${DISTNAME}/build/generic +PLIST_FILES= include/xvid.h \ + lib/libxvidcore.a \ + lib/libxvidcore.so \ + lib/libxvidcore.so.4 + +WRKSRC= ${WRKDIR}/${DISTNAME}/build/generic OPTIONS= OPTIMIZED_CFLAGS "Use XviD's default optimizations" off .include +.if ${ARCH} == "amd64" +CONFIGURE_TARGET= x86_64-portbld-freebsd${OSREL} +.endif +.if ${ARCH} == "amd64" || ${ARCH} == "i386" +BUILD_DEPENDS+= yasm:${PORTSDIR}/devel/yasm +.endif + .if defined(WITH_OPTIMIZED_CFLAGS) CFLAGS= # let xvid's build system decide about those .endif diff -durN xvid.orig/pkg-plist xvid/pkg-plist --- xvid.orig/pkg-plist 2004-06-11 18:48:50.000000000 -0300 +++ xvid/pkg-plist 1969-12-31 21:00:00.000000000 -0300 @@ -1,4 +0,0 @@ -include/xvid.h -lib/libxvidcore.a -lib/libxvidcore.so -lib/libxvidcore.so.4 >Release-Note: >Audit-Trail: >Unformatted: