annotate mp3lib/test.c @ 793:4b157c14aaad

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