2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include "mp3lib/mp3.h"
29 #include "cpudetect.h"
31 static inline unsigned int GetTimer(void){
35 gettimeofday(&tv
,&tz
);
36 // s=tv.tv_usec;s*=0.000001;s+=tv.tv_sec;
37 return tv
.tv_sec
* 1000000 + tv
.tv_usec
;
40 static FILE* mp3file
=NULL
;
42 int mplayer_audio_read(char *buf
,int size
){
43 return fread(buf
,1,size
,mp3file
);
47 static unsigned char buffer
[BUFFLEN
];
49 int main(int argc
,char* argv
[]){
56 f
=fopen("test.pcm","wb");
59 mp3file
=fopen((argc
>1)?argv
[1]:"test.mp3","rb");
60 if(!mp3file
){ printf("file not found\n"); exit(1); }
62 GetCpuCaps(&gCpuCaps
);
65 #ifdef CONFIG_FAKE_MONO
70 MP3_samplerate
=MP3_channels
=0;
73 while((len
=MP3_DecodeFrame(buffer
,-1))>0 && total
<2000000){
77 fwrite(buffer
,len
,1,f
);
79 //putchar('.');fflush(stdout);
81 time1
=GetTimer()-time1
;
82 length
=(float)total
/(float)(MP3_samplerate
*MP3_channels
*2);
83 printf("\nDecoding time: %8.6f\n",(float)time1
*0.000001f
);
84 printf("Uncompressed size: %d bytes (%8.3f secs)\n",total
,length
);
85 printf("CPU usage at normal playback: %5.2f %%\n",time1
*0.0001f
/length
);