11 #include "mp3lib/mp3.h"
12 #include "cpudetect.h"
14 static inline unsigned int GetTimer(){
18 gettimeofday(&tv
,&tz
);
19 // s=tv.tv_usec;s*=0.000001;s+=tv.tv_sec;
20 return (tv
.tv_sec
*1000000+tv
.tv_usec
);
23 static FILE* mp3file
=NULL
;
25 int mplayer_audio_read(char *buf
,int size
){
26 return fread(buf
,1,size
,mp3file
);
30 static unsigned char buffer
[BUFFLEN
];
32 int main(int argc
,char* argv
[]){
39 f
=fopen("test.pcm","wb");
42 mp3file
=fopen((argc
>1)?argv
[1]:"test.mp3","rb");
43 if(!mp3file
){ printf("file not found\n"); exit(1); }
45 GetCpuCaps(&gCpuCaps
);
53 MP3_samplerate
=MP3_channels
=0;
56 while((len
=MP3_DecodeFrame(buffer
,-1))>0 && total
<2000000){
60 fwrite(buffer
,len
,1,f
);
62 //putchar('.');fflush(stdout);
64 time1
=GetTimer()-time1
;
65 length
=(float)total
/(float)(MP3_samplerate
*MP3_channels
*2);
66 printf("\nDecoding time: %8.6f\n",(float)time1
*0.000001f
);
67 printf("Uncompressed size: %d bytes (%8.3f secs)\n",total
,length
);
68 printf("CPU usage at normal playback: %5.2f %%\n",time1
*0.0001f
/length
);