Mercurial > mplayer.hg
comparison mp3lib/test.c @ 788:214ea3f02d13
test.c added for benchmarking
author | arpi_esp |
---|---|
date | Sun, 13 May 2001 18:58:23 +0000 |
parents | |
children | 13805b1ca0f7 |
comparison
equal
deleted
inserted
replaced
787:9bc104531aec | 788:214ea3f02d13 |
---|---|
1 | |
2 // gcc test.c -I.. -L. -lMP3 -o test -O4 | |
3 | |
4 #include <stdio.h> | |
5 #include <stdlib.h> | |
6 | |
7 #include <unistd.h> | |
8 #include <sys/time.h> | |
9 | |
10 #include "mp3lib/mp3.h" | |
11 #include "config.h" | |
12 | |
13 static inline unsigned int GetTimer(){ | |
14 struct timeval tv; | |
15 struct timezone tz; | |
16 // float s; | |
17 gettimeofday(&tv,&tz); | |
18 // s=tv.tv_usec;s*=0.000001;s+=tv.tv_sec; | |
19 return (tv.tv_sec*1000000+tv.tv_usec); | |
20 } | |
21 | |
22 static FILE* mp3file=NULL; | |
23 | |
24 int mplayer_audio_read(char *buf,int size){ | |
25 return fread(buf,1,size,mp3file); | |
26 } | |
27 | |
28 #define BUFFLEN 4608 | |
29 static unsigned char buffer[BUFFLEN]; | |
30 | |
31 int main(int argc,char* argv[]){ | |
32 int len; | |
33 int total=0; | |
34 unsigned int time1; | |
35 float length; | |
36 | |
37 mp3file=fopen((argc>1)?argv[1]:"test.mp3","rb"); | |
38 if(!mp3file){ printf("file not found\n"); exit(1); } | |
39 | |
40 // MPEG Audio: | |
41 #ifdef USE_FAKE_MONO | |
42 MP3_Init(0); | |
43 #else | |
44 MP3_Init(); | |
45 #endif | |
46 MP3_samplerate=MP3_channels=0; | |
47 | |
48 time1=GetTimer(); | |
49 while((len=MP3_DecodeFrame(buffer,-1))>0){ | |
50 total+=len; | |
51 // play it | |
52 //putchar('.');fflush(stdout); | |
53 } | |
54 time1=GetTimer()-time1; | |
55 length=(float)total/(float)(MP3_samplerate*MP3_channels*2); | |
56 printf("\nDecoding time: %8.6f\n",(float)time1*0.000001f); | |
57 printf("Uncompressed size: %d bytes (%8.3f secs)\n",total,length); | |
58 printf("CPU usage at normal playback: %5.2f %\n",time1*0.0001f/length); | |
59 | |
60 fclose(mp3file); | |
61 | |
62 } |