annotate mp3lib/test.c @ 17616:92431bc3d014

This patch removes mmap support because it doesn't have any benefit. Directly accessing the sample buffer makes sense only when the samples can be constructed in-place. When the samples are just copied from another buffer (as is the case with libao2 drivers), the code to copy those samples is just a reimplementation of snd_pcm_writei(), so we could as well use that function. Besides, the current mmap code does not work except in the most simple cases: it claims to support non-interleaved and complex sample formats, but treats them the same as interleaved formats and writes to the wrong memory location.
author cladisch
date Mon, 13 Feb 2006 11:15:25 +0000
parents e7a129082fda
children 0d255d03016f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
814
13805b1ca0f7 dump to file
arpi_esp
parents: 788
diff changeset
1
13805b1ca0f7 dump to file
arpi_esp
parents: 788
diff changeset
2 #define DUMP_PCM
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
3
826
93304e7353c8 Added missing mathlib for linking.
atmosfear
parents: 814
diff changeset
4 // gcc test.c -I.. -L. -lMP3 -lm -o test1 -O4
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
5
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
6 #include <stdio.h>
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
7 #include <stdlib.h>
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
8
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
9 #include <unistd.h>
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
10 #include <sys/time.h>
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
11
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
12 #include "mp3lib/mp3.h"
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
13 #include "config.h"
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
14
16989
e7a129082fda Unify include paths, -I.. is in CFLAGS.
diego
parents: 10372
diff changeset
15 #include "cpudetect.h"
10372
17554a75a654 getcpucaps support
alex
parents: 826
diff changeset
16 extern CpuCaps gCpuCaps;
17554a75a654 getcpucaps support
alex
parents: 826
diff changeset
17
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
18 static inline unsigned int GetTimer(){
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
19 struct timeval tv;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
20 struct timezone tz;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
21 // float s;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
22 gettimeofday(&tv,&tz);
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
23 // s=tv.tv_usec;s*=0.000001;s+=tv.tv_sec;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
24 return (tv.tv_sec*1000000+tv.tv_usec);
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
25 }
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
26
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
27 static FILE* mp3file=NULL;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
28
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
29 int mplayer_audio_read(char *buf,int size){
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
30 return fread(buf,1,size,mp3file);
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
31 }
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
32
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
33 #define BUFFLEN 4608
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
34 static unsigned char buffer[BUFFLEN];
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
35
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
36 int main(int argc,char* argv[]){
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
37 int len;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
38 int total=0;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
39 unsigned int time1;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
40 float length;
814
13805b1ca0f7 dump to file
arpi_esp
parents: 788
diff changeset
41 #ifdef DUMP_PCM
13805b1ca0f7 dump to file
arpi_esp
parents: 788
diff changeset
42 FILE *f=NULL;
13805b1ca0f7 dump to file
arpi_esp
parents: 788
diff changeset
43 f=fopen("test.pcm","wb");
13805b1ca0f7 dump to file
arpi_esp
parents: 788
diff changeset
44 #endif
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
45
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
46 mp3file=fopen((argc>1)?argv[1]:"test.mp3","rb");
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
47 if(!mp3file){ printf("file not found\n"); exit(1); }
10372
17554a75a654 getcpucaps support
alex
parents: 826
diff changeset
48
17554a75a654 getcpucaps support
alex
parents: 826
diff changeset
49 GetCpuCaps(&gCpuCaps);
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
50
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
51 // MPEG Audio:
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
52 #ifdef USE_FAKE_MONO
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
53 MP3_Init(0);
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
54 #else
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
55 MP3_Init();
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
56 #endif
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
57 MP3_samplerate=MP3_channels=0;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
58
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
59 time1=GetTimer();
814
13805b1ca0f7 dump to file
arpi_esp
parents: 788
diff changeset
60 while((len=MP3_DecodeFrame(buffer,-1))>0 && total<2000000){
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
61 total+=len;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
62 // play it
814
13805b1ca0f7 dump to file
arpi_esp
parents: 788
diff changeset
63 #ifdef DUMP_PCM
13805b1ca0f7 dump to file
arpi_esp
parents: 788
diff changeset
64 fwrite(buffer,len,1,f);
13805b1ca0f7 dump to file
arpi_esp
parents: 788
diff changeset
65 #endif
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
66 //putchar('.');fflush(stdout);
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
67 }
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
68 time1=GetTimer()-time1;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
69 length=(float)total/(float)(MP3_samplerate*MP3_channels*2);
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
70 printf("\nDecoding time: %8.6f\n",(float)time1*0.000001f);
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
71 printf("Uncompressed size: %d bytes (%8.3f secs)\n",total,length);
10372
17554a75a654 getcpucaps support
alex
parents: 826
diff changeset
72 printf("CPU usage at normal playback: %5.2f %%\n",time1*0.0001f/length);
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
73
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
74 fclose(mp3file);
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
75
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
76 }