Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: axp-list@redhat.com
Subject: Re: Problems with mpg123 (or is the multia too slow to decode MP3?)
Date: Sat, 19 Jun 1999 21:51:00 -0700	[thread overview]
Message-ID: <19990619215100.B8660@twiddle.net> (raw)
In-Reply-To: <199906181106.OAA25638@ee.oulu.fi>; from RaymondInFinland on Fri, Jun 18, 1999 at 02:10:45PM +0300

On Fri, Jun 18, 1999 at 02:10:45PM +0300, RaymondInFinland wrote:
> I recently installed RH6.0 on my alpha and i've noticed that the 
> included mpg123 player isn't performing very good. It's not able to 
> decode the MP3 files realtime, it keeps dropping frames all the time. 

Huh.  I've never seen mpg123 eat more than 7% cpu when playing
to an actual audio device.  This is on an avanti, which is 
marginally faster than a multia, but not 60% worth.

I did spend an evening once upon a time tweeking it to run a 
bit better.  This is worth about a 20% speedup in test mode; I
forget what that comes to when playing -- not much, really.


r~



diff -rup mpg123-0.59q/Makefile mpg123-0.59q-/Makefile
--- mpg123-0.59q/Makefile	Tue Jan 26 06:35:18 1999
+++ mpg123-0.59q-/Makefile	Sat Jun 19 21:36:26 1999
@@ -154,10 +154,8 @@ linux-alsa:
 		mpg123-make
 
 linux-alpha:
-	$(MAKE) CC=gcc LDFLAGS= OBJECTS='decode.o dct64.o audio_oss.o' \
-		CFLAGS='-DLINUX -DOSS -Wall -O2 \
-			-fomit-frame-pointer -funroll-all-loops \
-			-finline-functions -ffast-math \
+	$(MAKE) CC=gcc LDFLAGS='-relax' OBJECTS='decode.o dct64.o audio_oss.o' \
+		CFLAGS='-DLINUX -DOSS -Wall -O3 -funroll-loops -ffast-math -mcpu=ev56 \
 			-Wall -O6 -DUSE_MMAP \
 			$(RPM_OPT_FLAGS)' \
 		mpg123-make
diff -rup mpg123-0.59q/common.c mpg123-0.59q-/common.c
--- mpg123-0.59q/common.c	Mon Jan 11 14:33:00 1999
+++ mpg123-0.59q-/common.c	Sat Jun 19 21:03:04 1999
@@ -32,13 +32,8 @@ int tabsel_123[2][3][16] = {
 
 long freqs[9] = { 44100, 48000, 32000, 22050, 24000, 16000 , 11025 , 12000 , 8000 };
 
-#ifdef I386_ASSEM
 int bitindex;
 unsigned char *wordpointer;
-#else
-static int bitindex;
-static unsigned char *wordpointer;
-#endif
 
 static int fsizeold=0,ssize;
 static unsigned char bsspace[2][MAXFRAMESIZE+512]; /* MAXFRAMESIZE */
Only in mpg123-0.59q-: config.cache
Only in mpg123-0.59q-: config.h
diff -rup mpg123-0.59q/dct64.c mpg123-0.59q-/dct64.c
--- mpg123-0.59q/dct64.c	Sat Sep 20 04:16:04 1997
+++ mpg123-0.59q-/dct64.c	Sat Jun 19 21:08:05 1999
@@ -18,7 +18,7 @@ void dct64(real *out0,real *out1,real *s
   real bufs[64];
 
  {
-  register int i,j;
+  register long i,j;
   register real *b1,*b2,*bs,*costab;
 
   b1 = samples;
@@ -103,7 +103,7 @@ void dct64(real *out0,real *out1,real *s
 
  {
   register real *b1;
-  register int i;
+  register long i;
 
   for(b1=bufs,i=8;i;i--,b1+=4)
     b1[2] += b1[3];
diff -rup mpg123-0.59q/decode.c mpg123-0.59q-/decode.c
--- mpg123-0.59q/decode.c	Tue Jan 26 04:47:05 1999
+++ mpg123-0.59q-/decode.c	Sat Jun 19 21:04:12 1999
@@ -12,10 +12,127 @@
 
 #include "mpg123.h"
 
-#define WRITE_SAMPLE(samples,sum,clip) \
-  if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \
-  else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
-  else { *(samples) = sum; }
+#define WRITE_SAMPLE(samples,sum,clip)		\
+  do {						\
+    long _tmp_ = (sum);				\
+    long _c1_ = (_tmp_ > 32767);		\
+    long _c2_ = (_tmp_ < -32768);		\
+    (clip) += _c1_ + _c2_;			\
+    if (_c1_) _tmp_ = 32767;			\
+    if (_c2_) _tmp_ = -32768;			\
+    *(samples) = _tmp_;				\
+  } while (0)
+
+int synth_1to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
+{
+  static real buffs[2][2][0x110];
+  const int step = 2;
+  static int bo = 1;
+  short *samples = (short *) (out+*pnt);
+
+  real *b0,(*buf)[0x110];
+  long int clip = 0; 
+  long int bo1;
+
+  if(!channel) {
+    bo--;
+    bo &= 0xf;
+    buf = buffs[0];
+  }
+  else {
+    samples++;
+    buf = buffs[1];
+  }
+
+  if(bo & 0x1) {
+    b0 = buf[0];
+    bo1 = bo;
+    dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr);
+  }
+  else {
+    b0 = buf[1];
+    bo1 = bo+1;
+    dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
+  }
+
+
+  {
+    register long j;
+    real *window = decwin + 16 - bo1;
+ 
+    for (j=16;j;j--,window+=0x10,samples+=step)
+    {
+      real sum, t0, t1, t2, t3;
+      t0 = window[0] * b0[0];
+      t1 = window[1] * b0[1];
+      t2 = window[2] * b0[2];
+      t3 = window[3] * b0[3];
+      t0 += window[4] * b0[4];
+      t1 += window[5] * b0[5];
+      t2 += window[6] * b0[6];
+      t3 += window[7] * b0[7];
+      t0 += window[8] * b0[8];
+      t1 += window[9] * b0[9];
+      t2 += window[10] * b0[10];
+      t3 += window[11] * b0[11];
+      t0 += window[12] * b0[12];
+      t1 += window[13] * b0[13];
+      t2 += window[14] * b0[14];
+      t3 += window[15] * b0[15];
+      window += 16, b0 += 16;
+
+      sum = (t0 - t1) + (t2 - t3);
+
+      WRITE_SAMPLE(samples,sum,clip);
+    }
+
+    {
+      real sum, t0, t1, t2, t3;
+      t0 = window[0x0] * b0[0x0];
+      t1 = window[0x2] * b0[0x2];
+      t2 = window[0x4] * b0[0x4];
+      t3 = window[0x6] * b0[0x6];
+      t0 += window[0x8] * b0[0x8];
+      t1 += window[0xA] * b0[0xA];
+      t2 += window[0xC] * b0[0xC];
+      t3 += window[0xE] * b0[0xE];
+      sum = (t0 + t1) + (t2 + t3);
+      WRITE_SAMPLE(samples,sum,clip);
+      b0-=0x10,window-=0x20,samples+=step;
+    }
+    window += bo1<<1;
+
+    for (j=15;j;j--,b0-=0x20,window-=0x10,samples+=step)
+    {
+      real sum, t0, t1, t2, t3;
+      t0 = -window[-1] * b0[0];
+      t1 = -window[-2] * b0[1];
+      t2 = -window[-3] * b0[2];
+      t3 = -window[-4] * b0[3];
+      t0 -= window[-5] * b0[4];
+      t1 -= window[-6] * b0[5];
+      t2 -= window[-7] * b0[6];
+      t3 -= window[-8] * b0[7];
+      t0 -= window[-9] * b0[8];
+      t1 -= window[-10] * b0[9];
+      t2 -= window[-11] * b0[10];
+      t3 -= window[-12] * b0[11];
+      t0 -= window[-13] * b0[12];
+      t1 -= window[-14] * b0[13];
+      t2 -= window[-15] * b0[14];
+      t3 -= window[-16] * b0[15];
+      window -= 16, b0 += 16;
+
+      sum = (t0 + t1) + (t2 + t3);
+
+      WRITE_SAMPLE(samples,sum,clip);
+    }
+  }
+
+  *pnt += 128;
+
+  return clip;
+}
 
 int synth_1to1_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
 {
@@ -111,113 +228,3 @@ int synth_1to1_mono2stereo(real *bandPtr
 
   return ret;
 }
-
-
-int synth_1to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
-{
-  static real buffs[2][2][0x110];
-  static const int step = 2;
-  static int bo = 1;
-  short *samples = (short *) (out+*pnt);
-
-  real *b0,(*buf)[0x110];
-  int clip = 0; 
-  int bo1;
-
-  if(equalfile)
-	do_equalizer(bandPtr,channel);
-
-  if(!channel) {
-    bo--;
-    bo &= 0xf;
-    buf = buffs[0];
-  }
-  else {
-    samples++;
-    buf = buffs[1];
-  }
-
-  if(bo & 0x1) {
-    b0 = buf[0];
-    bo1 = bo;
-    dct64(buf[1]+((bo+1)&0xf),buf[0]+bo,bandPtr);
-  }
-  else {
-    b0 = buf[1];
-    bo1 = bo+1;
-    dct64(buf[0]+bo,buf[1]+bo+1,bandPtr);
-  }
-
-
-  {
-    register int j;
-    real *window = decwin + 16 - bo1;
- 
-    for (j=16;j;j--,window+=0x10,samples+=step)
-    {
-      real sum;
-      sum  = *window++ * *b0++;
-      sum -= *window++ * *b0++;
-      sum += *window++ * *b0++;
-      sum -= *window++ * *b0++;
-      sum += *window++ * *b0++;
-      sum -= *window++ * *b0++;
-      sum += *window++ * *b0++;
-      sum -= *window++ * *b0++;
-      sum += *window++ * *b0++;
-      sum -= *window++ * *b0++;
-      sum += *window++ * *b0++;
-      sum -= *window++ * *b0++;
-      sum += *window++ * *b0++;
-      sum -= *window++ * *b0++;
-      sum += *window++ * *b0++;
-      sum -= *window++ * *b0++;
-
-      WRITE_SAMPLE(samples,sum,clip);
-    }
-
-    {
-      real sum;
-      sum  = window[0x0] * b0[0x0];
-      sum += window[0x2] * b0[0x2];
-      sum += window[0x4] * b0[0x4];
-      sum += window[0x6] * b0[0x6];
-      sum += window[0x8] * b0[0x8];
-      sum += window[0xA] * b0[0xA];
-      sum += window[0xC] * b0[0xC];
-      sum += window[0xE] * b0[0xE];
-      WRITE_SAMPLE(samples,sum,clip);
-      b0-=0x10,window-=0x20,samples+=step;
-    }
-    window += bo1<<1;
-
-    for (j=15;j;j--,b0-=0x20,window-=0x10,samples+=step)
-    {
-      real sum;
-      sum = -*(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-      sum -= *(--window) * *b0++;
-
-      WRITE_SAMPLE(samples,sum,clip);
-    }
-  }
-
-  *pnt += 128;
-
-  return clip;
-}
-
-
diff -rup mpg123-0.59q/mpg123.h mpg123-0.59q-/mpg123.h
--- mpg123-0.59q/mpg123.h	Tue Jan 26 04:47:05 1999
+++ mpg123-0.59q-/mpg123.h	Sat Jun 19 21:03:04 1999
@@ -198,6 +198,29 @@ extern unsigned int   get1bit(void);
 extern unsigned int   getbits(int);
 extern unsigned int   getbits_fast(int);
 
+#ifdef __GNUC__
+extern inline unsigned int get1bit(void)
+{
+  extern int bitindex;
+  extern unsigned char *wordpointer;
+
+  int bi = bitindex;
+  unsigned char * wp = wordpointer;
+
+  unsigned char rval;
+  rval = *wp << bi;
+
+  bi++;
+  wp += bi >> 3;
+  bi &= 7;
+
+  wordpointer = wp;
+  bitindex = bi;
+
+  return rval>>7;
+}
+#endif
+
 extern void set_pointer(long);
 
 extern unsigned char *pcm_sample;


      parent reply	other threads:[~1999-06-20  5:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-18 11:10 Problems with mpg123 (or is the multia too slow to decode MP3?) RaymondInFinland
1999-06-18 13:02 ` Phillip Ezolt
1999-06-18 14:11   ` warp
1999-06-18 14:15     ` warp
1999-06-18 19:49       ` Adam C. Powell, IV
1999-06-18 21:01         ` warp
1999-06-20  4:54           ` Richard Henderson
1999-06-21 15:46             ` Ivan Kokshaysky
1999-06-21 17:23               ` Charles E Rick Taylor IV
1999-06-18 13:42 ` Charles Taylor
1999-06-18 14:43   ` RaymondInFinland
1999-06-18 21:37     ` Peter Petrakis
1999-06-18 23:45       ` Problems with mpg123 (or is the multia too slow to decode MP Charles E Taylor IV
1999-06-20  4:51 ` Richard Henderson [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox