2001-05-13 18:58:23 +00:00
|
|
|
|
2001-05-16 22:23:13 +00:00
|
|
|
#define DUMP_PCM
|
|
|
|
|
2001-05-13 18:58:23 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
|
|
#include "config.h"
|
2008-03-14 16:46:13 +00:00
|
|
|
#include "mp3lib/mp3.h"
|
2005-11-15 18:14:07 +00:00
|
|
|
#include "cpudetect.h"
|
2003-07-04 21:38:17 +00:00
|
|
|
|
2009-01-05 14:48:03 +00:00
|
|
|
static inline unsigned int GetTimer(void){
|
2001-05-13 18:58:23 +00:00
|
|
|
struct timeval tv;
|
|
|
|
struct timezone tz;
|
|
|
|
// float s;
|
|
|
|
gettimeofday(&tv,&tz);
|
|
|
|
// s=tv.tv_usec;s*=0.000001;s+=tv.tv_sec;
|
2009-10-08 11:25:01 +00:00
|
|
|
return tv.tv_sec * 1000000 + tv.tv_usec;
|
2009-05-13 02:58:57 +00:00
|
|
|
}
|
2001-05-13 18:58:23 +00:00
|
|
|
|
|
|
|
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;
|
2001-05-16 22:23:13 +00:00
|
|
|
#ifdef DUMP_PCM
|
|
|
|
FILE *f=NULL;
|
|
|
|
f=fopen("test.pcm","wb");
|
|
|
|
#endif
|
2009-05-13 02:58:57 +00:00
|
|
|
|
2001-05-13 18:58:23 +00:00
|
|
|
mp3file=fopen((argc>1)?argv[1]:"test.mp3","rb");
|
|
|
|
if(!mp3file){ printf("file not found\n"); exit(1); }
|
2009-05-13 02:58:57 +00:00
|
|
|
|
2003-07-04 21:38:17 +00:00
|
|
|
GetCpuCaps(&gCpuCaps);
|
2001-05-13 18:58:23 +00:00
|
|
|
|
|
|
|
// MPEG Audio:
|
2008-07-30 12:01:30 +00:00
|
|
|
#ifdef CONFIG_FAKE_MONO
|
2001-05-13 18:58:23 +00:00
|
|
|
MP3_Init(0);
|
|
|
|
#else
|
|
|
|
MP3_Init();
|
|
|
|
#endif
|
|
|
|
MP3_samplerate=MP3_channels=0;
|
2009-05-13 02:58:57 +00:00
|
|
|
|
2001-05-13 18:58:23 +00:00
|
|
|
time1=GetTimer();
|
2001-05-16 22:23:13 +00:00
|
|
|
while((len=MP3_DecodeFrame(buffer,-1))>0 && total<2000000){
|
2001-05-13 18:58:23 +00:00
|
|
|
total+=len;
|
|
|
|
// play it
|
2001-05-16 22:23:13 +00:00
|
|
|
#ifdef DUMP_PCM
|
|
|
|
fwrite(buffer,len,1,f);
|
|
|
|
#endif
|
2001-05-13 18:58:23 +00:00
|
|
|
//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);
|
2003-07-04 21:38:17 +00:00
|
|
|
printf("CPU usage at normal playback: %5.2f %%\n",time1*0.0001f/length);
|
2009-05-13 02:58:57 +00:00
|
|
|
|
2001-05-13 18:58:23 +00:00
|
|
|
fclose(mp3file);
|
2008-04-25 08:34:26 +00:00
|
|
|
return 0;
|
2001-05-13 18:58:23 +00:00
|
|
|
}
|