annotate mp3lib/test.c @ 30272:c6c40936049c

We only need to disable seeking back in ad_ffmpeg when we actually _use_ a parser, not when just needs_parsing is set. Fixes playback of e.g. ADPCM in AVI like http://samples.mplayerhq.hu/avi/imaadpcm.avi
author reimar
date Fri, 15 Jan 2010 21:01:31 +0000
parents afc8b80eb027
children fee09b258e8a
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
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
26203
0d255d03016f #include config.h before all other headers.
diego
parents: 16989
diff changeset
10 #include "config.h"
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
11 #include "mp3lib/mp3.h"
16989
e7a129082fda Unify include paths, -I.. is in CFLAGS.
diego
parents: 10372
diff changeset
12 #include "cpudetect.h"
10372
17554a75a654 getcpucaps support
alex
parents: 826
diff changeset
13
28232
8df85ad26746 Add missing 'void' keyword to parameterless function declarations.
diego
parents: 27341
diff changeset
14 static inline unsigned int GetTimer(void){
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
15 struct timeval tv;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
16 struct timezone tz;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
17 // float s;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
18 gettimeofday(&tv,&tz);
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
19 // s=tv.tv_usec;s*=0.000001;s+=tv.tv_sec;
29717
afc8b80eb027 cosmetics: Remove some pointless parentheses from return calls.
diego
parents: 29263
diff changeset
20 return tv.tv_sec * 1000000 + tv.tv_usec;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28232
diff changeset
21 }
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
22
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
23 static FILE* mp3file=NULL;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
24
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
25 int mplayer_audio_read(char *buf,int size){
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
26 return fread(buf,1,size,mp3file);
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
27 }
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
28
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
29 #define BUFFLEN 4608
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
30 static unsigned char buffer[BUFFLEN];
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
31
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
32 int main(int argc,char* argv[]){
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
33 int len;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
34 int total=0;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
35 unsigned int time1;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
36 float length;
814
13805b1ca0f7 dump to file
arpi_esp
parents: 788
diff changeset
37 #ifdef DUMP_PCM
13805b1ca0f7 dump to file
arpi_esp
parents: 788
diff changeset
38 FILE *f=NULL;
13805b1ca0f7 dump to file
arpi_esp
parents: 788
diff changeset
39 f=fopen("test.pcm","wb");
13805b1ca0f7 dump to file
arpi_esp
parents: 788
diff changeset
40 #endif
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28232
diff changeset
41
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
42 mp3file=fopen((argc>1)?argv[1]:"test.mp3","rb");
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
43 if(!mp3file){ printf("file not found\n"); exit(1); }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28232
diff changeset
44
10372
17554a75a654 getcpucaps support
alex
parents: 826
diff changeset
45 GetCpuCaps(&gCpuCaps);
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
46
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
47 // MPEG Audio:
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 26504
diff changeset
48 #ifdef CONFIG_FAKE_MONO
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
49 MP3_Init(0);
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
50 #else
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
51 MP3_Init();
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
52 #endif
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
53 MP3_samplerate=MP3_channels=0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28232
diff changeset
54
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
55 time1=GetTimer();
814
13805b1ca0f7 dump to file
arpi_esp
parents: 788
diff changeset
56 while((len=MP3_DecodeFrame(buffer,-1))>0 && total<2000000){
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
57 total+=len;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
58 // play it
814
13805b1ca0f7 dump to file
arpi_esp
parents: 788
diff changeset
59 #ifdef DUMP_PCM
13805b1ca0f7 dump to file
arpi_esp
parents: 788
diff changeset
60 fwrite(buffer,len,1,f);
13805b1ca0f7 dump to file
arpi_esp
parents: 788
diff changeset
61 #endif
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
62 //putchar('.');fflush(stdout);
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
63 }
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
64 time1=GetTimer()-time1;
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
65 length=(float)total/(float)(MP3_samplerate*MP3_channels*2);
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
66 printf("\nDecoding time: %8.6f\n",(float)time1*0.000001f);
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
67 printf("Uncompressed size: %d bytes (%8.3f secs)\n",total,length);
10372
17554a75a654 getcpucaps support
alex
parents: 826
diff changeset
68 printf("CPU usage at normal playback: %5.2f %%\n",time1*0.0001f/length);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28232
diff changeset
69
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
70 fclose(mp3file);
26502
b3661a203f8b Add return statement, fixes the warning:
diego
parents: 26501
diff changeset
71 return 0;
788
214ea3f02d13 test.c added for benchmarking
arpi_esp
parents:
diff changeset
72 }