* RE: FYI: bladeenc - fairly easy port.
2003-09-23 22:53 ` Hannu E K Nevalainen (garbage mail)
@ 2003-11-14 15:52 ` Hannu E K Nevalainen
0 siblings, 0 replies; 4+ messages in thread
From: Hannu E K Nevalainen @ 2003-11-14 15:52 UTC (permalink / raw)
To: cygwin
[-- Attachment #1: Type: text/plain, Size: 947 bytes --]
> From: Hannu E K Nevalainen
> Sent: Wednesday, September 24, 2003 12:26 AM
MOTIVATION:
Gerrit, about a Windows-native version:
> > How fast is it compared with the Cygwin version?
>
Hannu:
> Answer: Approximately 20-40% faster in "cmd native mode"
>
> IMO the better "compatibility" with the other cygwin tools is worth more
> than the extra speed.
Well, here it finally is; the patch(es?) for the executable version - for
those that have interest in it. (using: bladeenc 0.94.2 & gcc 3.3.1)
Mostly due to the usual excuse (i.e. "lack of time") I have chosen to not
create a cygwin package. A secondary reason; This might also be problematic
due to mp3-licensing.
Feel free to use the patch as you wish. I *might* 'enhance' it further, but
don't count on it. ;-) e.g. I've not tried -mno-cygwin yet ;-) FWIW.
/Hannu E K Nevalainen, B.Sc. EE - 59+16.37'N, 17+12.60'E
-- printf("LocalTime: UTC+%02d\n",(DST)? 2:1); --
--END OF MESSAGE--
[-- Attachment #2: bladeenc-0.94.2-stable-cygwin.sh --]
[-- Type: application/octet-stream, Size: 1584 bytes --]
#!/bin/bash
# GPL stuff, (C) Copyright by Hannu E K Nevalainen, Mariefred, Sweden
# garbage_collector@telia.com
#
# Launch this script with full path, or with cwd == containing dir.
# Assumes that the source AND patch exists in this dir.
# One arg possible, where to put "be-build/" dir. Not given -> "./"
be="bladeenc-0.94.2"
if [ -z "$1" ] ;then
prefix=.
else
prefix="$1"
fi
source="${0%/*}"
if [ "$source" == "." ] ;then
source="$(pwd)"
fi
cd "$prefix"
if [ ! -d be-build ]; then
mkdir be-build
fi
cd be-build;
if [ ! -f "$source/${be}-src-stable.tar.gz" ] ;then
echo "can't find $source/${be}-src-stable.tar.gz"
else
tar -zxf $source/${be}-src-stable.tar.gz
if [ ! -d "${be}" ]; then
echo "No $be directory? Can't continue."
exit 1
fi
cd "$be/"
case "$(uname -s)" in
CYGWIN_*)
if [ ! -f "$source/${be}-stable-cygwin.patch" ] ;then
echo "can't find $source/${be}-stable-cygwin.patch, can't patch..."
echo "\a\e[7m prepare to fail... \e[m"
else
if [ ! -f "bladeenc/cygwin.h" ]; then
patch -Np1 <$source/${be}-stable-cygwin.patch
else
echo "Patch already applied!? bladeenc/cygwin.h exists, contents:"
cat bladeenc/cygwin.h
echo "--- eof ---"
fi
fi
;;
esac
configure; make CFLAGS="-O3"; echo -e "\aDone.\n"
ls -l $(pwd)/bladeenc/bladeenc.exe
if [ ! -z "$(which upx)" ]; then
upx --best bladeenc/bladeenc.exe;
ls -l $(pwd)/bladeenc/bladeenc.exe
fi
fi
[-- Attachment #3: bladeenc-0.94.2-stable-cygwin.README --]
[-- Type: application/octet-stream, Size: 4227 bytes --]
Patches to make bladeenc-0.94.2-stable compile on cygwin 1.5
============================================================
Created Nov 13 2003 by Hannu E K Nevalainen, Mariefred, Sweden
garbage_collector@telia.com
Patch created with
------------------
$ rm cygwin/stamp-h cygwin/bladeenc/Makefile cygwin/bladeenc/system.h.orig \
cygwin/config.cache cygwin/config.h cygwin/config.log cygwin/config.status
$ LC_ALL=C TZ=UTC0 diff -Naur original/ cygwin/ >bladeenc-0.94.2-stable-cygwin.patch
$ diff --version
diff (GNU diffutils) 2.8.4
<SNIP>
Original source code
--------------------
Webpage at http://bladeenc.mp3.no, click on 'sourcecode' - or do:
$ wget http://bladeenc.mp3.no/source/bladeenc-0.94.2-src-stable.tar.gz \
http://bladeenc.mp3.no/source/extras.tar.gz
COMMENTS
========
As cygwin is an *emulated* Unix-like environment many things are slower
than on a 'native' Unix/Linux. This makes trying different compiler
optimization worthwhile - e.g. having a version of bladeenc compiled with
-O3 instead of -O2 (default) increases execution speed by 10-30%, when
running on an old P2 at 450 Mhz (achieves approx 1.8x on most input).
i.e. build it with:
$ make CFLAGS="-O3"
Removing the -g option (defaults to on) also reduces excutable size.
It can then be further decreased with:
$ upx --best bladeenc/bladeenc.exe
CHANGES APPLIED - as included in the patch
==========================================
cygwin.h
--------
Created. For tracking version of this patch/avoiding patch problems.
#define BE_CYGPATCH 1 // for now, will increase if patch changes.
bladesys.c
----------
Adjusted to make it possible to conditionally compile relevant parts.
loop.c
------
Replacing "infinty" with "local_inf" all over, due to a clash
with "inifnity" in the standard include files.
system.h
--------
All the changes to enable "autodetection" of current CYGWIN
configure
---------
Bug in detection of BYTE_ORDER; "faster" non-working code
replaced with something that DOES work. (autoconfig "bug"?)
HOWTO
=====
Prerequisites:
- Relevant cygwin packages (gcc...) has been installed
e.g. cygwin 1.5.5 and gcc 3.3.1 at the time of writing.
- /mp3/ contains the patch and the source tarball.
$ bash
$ cd; md tests; cd tests; tar -zxf /mp3/bladeenc-0.94.2-src-stable.tar.gz
$ ls -l
total 0
drwxr-xr-x 4 Hannu 0 May 8 2001 bladeenc-0.94.2/
$ cd bladeenc-0.94.2/ ; ls -l
total 171
-rw-r--r-- 1 Hannu 2954 Jan 10 2001 AUTHORS
-rw-r--r-- 1 Hannu 26416 Jun 10 2000 COPYING
-rw-r--r-- 1 Hannu 23720 Mar 7 2001 ChangeLog
-rw-r--r-- 1 Hannu 3606 Nov 28 2000 INSTALL
-rw-r--r-- 1 Hannu 165 Feb 21 2001 Makefile.am
-rw-r--r-- 1 Hannu 10811 May 8 2001 Makefile.in
-rw-r--r-- 1 Hannu 72 Jun 10 2000 README
-rw-r--r-- 1 Hannu 464 Jan 24 2001 TODO
-rw-r--r-- 1 Hannu 4396 May 8 2001 aclocal.m4
drwxr-xr-x 2 Hannu 0 May 8 2001 bladeenc/
-rw-r--r-- 1 Hannu 27932 May 8 2001 bladeenc.html
-rw-r--r-- 1 Hannu 513 May 3 2001 bladeenc.lsm
-rw-r--r-- 1 Hannu 945 May 8 2001 bladeenc.spec
-rw-r--r-- 1 Hannu 323 Nov 27 2000 config.h.in
-rwxr-xr-x 1 Hannu 48667 May 8 2001 configure*
-rw-r--r-- 1 Hannu 454 May 3 2001 configure.in
-rwxr-xr-x 1 Hannu 5584 Nov 24 2000 install-sh*
-rwxr-xr-x 1 Hannu 6274 Nov 24 2000 missing*
-rwxr-xr-x 1 Hannu 732 Nov 24 2000 mkinstalldirs*
drwxr-xr-x 2 Hannu 0 Mar 7 2001 other_makefiles/
-rw-r--r-- 1 Hannu 10 May 8 2001 stamp-h.in
$ patch -Np1 </mp3/bladeenc-0.94.2-stable-cygwin.patch
patching file bladeenc/cygwin.h
patching file bladeenc/bladesys.c
patching file bladeenc/loop.c
patching file bladeenc/system.h
patching file configure
$ configure; make all; echo -e "\aDone.\n";ls -lan bladeenc/*.exe
<-- 93 lines of output snipped -->
Done.
-rwxr-xr-x 1 500 251737 Nov 14 2003 bladeenc/bladeenc.exe*
$
/Hannu E K Nevalainen, Mariefred, Sweden - November 14, 2003
[-- Attachment #4: bladeenc-0.94.2-stable-cygwin.patch --]
[-- Type: application/octet-stream, Size: 4652 bytes --]
diff -Naur original/bladeenc/cygwin.h cygwin/bladeenc/cygwin.h
--- original/bladeenc/cygwin.h 1970-01-01 00:00:00.000000000 +0000
+++ cygwin/bladeenc/cygwin.h 2003-11-14 10:59:06.000000000 +0000
@@ -0,0 +1,6 @@
+#ifndef __CYGWIN_H
+#define __CYGWIN_H
+
+#define BE_CYGPAT 1 /* bladeenc -> cygwin - PATCH version, increases with new ones */
+
+#endif /* __CYGWIN_H */
diff -Naur original/bladeenc/bladesys.c cygwin/bladeenc/bladesys.c
--- original/bladeenc/bladesys.c 2001-05-08 12:11:54.000000000 +0000
+++ cygwin/bladeenc/bladesys.c 2003-09-23 15:53:52.000000000 +0000
@@ -189,7 +189,9 @@
#endif
+
#ifdef UNIX_SYSTEM
+#ifdef PRIO
pid_t my_pid;
int prio;
@@ -209,6 +211,8 @@
my_pid = getpid();
setpriority (PRIO_PROCESS, my_pid, prio);
#endif
+#endif
+
#if SYSTEM == AMIGA_WOS /* WarpOS. */
diff -Naur original/bladeenc/loop.c cygwin/bladeenc/loop.c
--- original/bladeenc/loop.c 2001-05-08 12:11:54.000000000 +0000
+++ cygwin/bladeenc/loop.c 2003-09-22 19:22:40.000000000 +0000
@@ -95,7 +95,7 @@
-#define infinity 99999999
+#define local_inf 999999
@@ -709,8 +709,8 @@
double xmax, the_xmax;
- the_lo_quant = -infinity; /* "-infinity" */
- the_hi_quant = -infinity; /* the real maximum for high_quant is about +4 ! */
+ the_lo_quant = -local_inf; /* "-infinity" */
+ the_hi_quant = -local_inf; /* the real maximum for high_quant is about +4 ! */
the_xmax = -1.0;
@@ -719,8 +719,8 @@
xmax = xmax_l[sfb];
if (xmax == 0.0)
{
- lo_quant_l[sfb] = -infinity;
- hi_quant_l[sfb] = -infinity;
+ lo_quant_l[sfb] = -local_inf;
+ hi_quant_l[sfb] = -local_inf;
}
else
{
@@ -743,8 +743,8 @@
xmax = xmax_s[sfb][b];
if (xmax == 0.0)
{
- lo_quant_s[sfb][b] = -infinity;
- hi_quant_s[sfb][b] = -infinity;
+ lo_quant_s[sfb][b] = -local_inf;
+ hi_quant_s[sfb][b] = -local_inf;
}
else
{
@@ -885,7 +885,7 @@
partial_quantize ();
#if ORG_BINARY_SEARCH || ORG_QUANTANF_INIT || CHECK_TJ_OVERFLOW
if (tjBitOverflow2)
- bits = infinity;
+ bits = local_inf;
else
bits = count_bits ();
#else
@@ -899,7 +899,7 @@
tjBitOverflow2 = FALSE;
quantize ();
if (tjBitOverflow2)
- bits = infinity;
+ bits = local_inf;
else
bits = count_bits ();
#else
@@ -950,7 +950,7 @@
counts the bits needed to code the scale factors (cod_info->part2_length)
and the compression index (cod_info->scalefac_compress).
- If there is no suitable index, it returns "infinity".
+ If there is no suitable index, it returns "local_inf".
*/
static int needed_bits_for_storing_scalefactors
@@ -1044,7 +1044,7 @@
}
- cod_info->part2_length = infinity;
+ cod_info->part2_length = local_inf;
for (k = 0; k < 16; k++)
{
@@ -1732,7 +1732,7 @@
tjBitOverflow2 = FALSE;
quantize ();
if (tjBitOverflow2)
- bits = infinity;
+ bits = local_inf;
else
bits = count_bits ();
@@ -1754,7 +1754,7 @@
tjBitOverflow2 = FALSE;
quantize ();
if (tjBitOverflow2)
- bits = infinity;
+ bits = local_inf;
else
bits = count_bits ();
#else
diff -Naur original/bladeenc/system.h cygwin/bladeenc/system.h
--- original/bladeenc/system.h 2001-05-08 12:11:54.000000000 +0000
+++ cygwin/bladeenc/system.h 2003-09-23 15:47:54.000000000 +0000
@@ -28,6 +28,10 @@
- Added Andrea Vallinotto's Amiga WarpOS changes.
- Added some more defines and cleaned up.
+ 2003-09-23 Hannu E K Nevalainen
+
+ - Added simple "autodetection" for Cygwin (www.cygwin.com)
+
*/
#ifndef __SYSTEM__
@@ -82,6 +86,10 @@
# define SYSTEM MSDOS_DJGPP
# endif
+# ifdef __CYGWIN__ /* www.cygwin.com, unix emulation layer for WinXX */
+# define SYSTEM UNIX_AUTOCONF
+# endif
+
# if defined(__dest_os) && (__dest_os == __mac_os) /* defined in "ansi_prefix.mac.h" */
# define SYSTEM MAC_OS
# endif
@@ -267,6 +275,9 @@
# define DIRECTORY_SEPARATOR '/'
#endif
+#ifdef __CYGWIN__ /* www.cygwin.com, unix emulation layer for WinXX */
+# undef PRIO /* not correclty emulated? */
+#endif
/*==== COMPILER SPECIFIC DEFINES ============================================ */
/*
diff -Naur original/configure cygwin/configure
--- original/configure 2001-05-08 12:11:56.000000000 +0000
+++ cygwin/configure 2003-09-22 19:41:58.000000000 +0000
@@ -1064,7 +1064,7 @@
int main() {
#if BYTE_ORDER != BIG_ENDIAN
- not big endian
+ return 1; // not big endian
#endif
; return 0; }
EOF
[-- Attachment #5: Type: text/plain, Size: 218 bytes --]
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
^ permalink raw reply [flat|nested] 4+ messages in thread