summaryrefslogtreecommitdiffstats
path: root/mp3lib
diff options
context:
space:
mode:
authorarpi_esp <arpi_esp@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-05-13 18:58:23 +0000
committerarpi_esp <arpi_esp@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-05-13 18:58:23 +0000
commit20053431c922198128111106d0e675a889937db5 (patch)
tree71b23c944c8a705ecff71665f566f8c3f496ec9a /mp3lib
parent736949705076c89d0dd9ea14af7361b1d8802f0a (diff)
downloadmpv-20053431c922198128111106d0e675a889937db5.tar.bz2
mpv-20053431c922198128111106d0e675a889937db5.tar.xz
test.c added for benchmarking
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@789 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'mp3lib')
-rw-r--r--mp3lib/Makefile3
-rw-r--r--mp3lib/test.c62
2 files changed, 65 insertions, 0 deletions
diff --git a/mp3lib/Makefile b/mp3lib/Makefile
index c897b63c56..e05bd8cc1f 100644
--- a/mp3lib/Makefile
+++ b/mp3lib/Makefile
@@ -18,6 +18,9 @@ CFLAGS = $(OPTFLAGS)
libMP3.a: .depend $(OBJS)
$(AR) r libMP3.a $(OBJS)
+test: libMP3.a test.c
+ $(CC) $(CFLAGS) test.c -o test -I.. -L. -lMP3
+
all: libMP3.a
clean:
diff --git a/mp3lib/test.c b/mp3lib/test.c
new file mode 100644
index 0000000000..9325bd872f
--- /dev/null
+++ b/mp3lib/test.c
@@ -0,0 +1,62 @@
+
+// gcc test.c -I.. -L. -lMP3 -o test -O4
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <unistd.h>
+#include <sys/time.h>
+
+#include "mp3lib/mp3.h"
+#include "config.h"
+
+static inline unsigned int GetTimer(){
+ struct timeval tv;
+ struct timezone tz;
+// float s;
+ gettimeofday(&tv,&tz);
+// s=tv.tv_usec;s*=0.000001;s+=tv.tv_sec;
+ return (tv.tv_sec*1000000+tv.tv_usec);
+}
+
+static FILE* mp3file=NULL;
+
+int mplayer_audio_read(char *buf,int size){
+ return fread(buf,1,size,mp3file);
+}
+
+#define BUFFLEN 4608
+static unsigned char buffer[BUFFLEN];
+
+int main(int argc,char* argv[]){
+ int len;
+ int total=0;
+ unsigned int time1;
+ float length;
+
+ mp3file=fopen((argc>1)?argv[1]:"test.mp3","rb");
+ if(!mp3file){ printf("file not found\n"); exit(1); }
+
+ // MPEG Audio:
+#ifdef USE_FAKE_MONO
+ MP3_Init(0);
+#else
+ MP3_Init();
+#endif
+ MP3_samplerate=MP3_channels=0;
+
+ time1=GetTimer();
+ while((len=MP3_DecodeFrame(buffer,-1))>0){
+ total+=len;
+ // play it
+ //putchar('.');fflush(stdout);
+ }
+ time1=GetTimer()-time1;
+ length=(float)total/(float)(MP3_samplerate*MP3_channels*2);
+ printf("\nDecoding time: %8.6f\n",(float)time1*0.000001f);
+ printf("Uncompressed size: %d bytes (%8.3f secs)\n",total,length);
+ printf("CPU usage at normal playback: %5.2f %\n",time1*0.0001f/length);
+
+ fclose(mp3file);
+
+}