annotate mp3lib/test2.c @ 11696:85f1f61200ab

lets see if lmin/lmax for constant IP quantizer and different constant quant for B works ...
author michael
date Sun, 28 Dec 2003 01:14:10 +0000
parents b277842a74a2
children 0d255d03016f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
789
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
1
1245
03b7e2955a20 Added newest MMX-optimized decore which speedups decoding at least on 13% for any cpu.
nick
parents: 826
diff changeset
2 //gcc test2.c -O2 -I.. -L. ../libvo/aclib.c -lMP3 -lm -o test2
789
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
3
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
4 #include <stdio.h>
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
5 #include <stdlib.h>
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
6
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
7 #include <fcntl.h>
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
8 #include <sys/ioctl.h>
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
9 #include <unistd.h>
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
10 #include <sys/soundcard.h>
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
11
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
12 #include "mp3lib/mp3.h"
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
13 #include "config.h"
10343
b277842a74a2 merged with mpg123 0.59s-pre
arpi
parents: 1245
diff changeset
14 #include "cpudetect.h"
789
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
15
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
16 static FILE* mp3file=NULL;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
17
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
18 int mplayer_audio_read(char *buf,int size){
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
19 return fread(buf,1,size,mp3file);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
20 }
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
21
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
22 #define BUFFLEN 4608
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
23 static unsigned char buffer[BUFFLEN];
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
24
10343
b277842a74a2 merged with mpg123 0.59s-pre
arpi
parents: 1245
diff changeset
25
789
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
26 int main(int argc,char* argv[]){
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
27 int len;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
28 int total=0;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
29 float length;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
30 int r;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
31 int audio_fd;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
32
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
33 mp3file=fopen((argc>1)?argv[1]:"test.mp3","rb");
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
34 if(!mp3file){ printf("file not found\n"); exit(1); }
10343
b277842a74a2 merged with mpg123 0.59s-pre
arpi
parents: 1245
diff changeset
35
b277842a74a2 merged with mpg123 0.59s-pre
arpi
parents: 1245
diff changeset
36 GetCpuCaps(&gCpuCaps);
789
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
37
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
38 // MPEG Audio:
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
39 #ifdef USE_FAKE_MONO
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
40 MP3_Init(0);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
41 #else
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
42 MP3_Init();
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
43 #endif
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
44 MP3_samplerate=MP3_channels=0;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
45 len=MP3_DecodeFrame(buffer,-1);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
46
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
47 audio_fd=open("/dev/dsp", O_WRONLY);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
48 if(audio_fd<0){ printf("Can't open audio device\n");exit(1); }
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
49 r=AFMT_S16_LE;ioctl (audio_fd, SNDCTL_DSP_SETFMT, &r);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
50 r=MP3_channels-1;ioctl (audio_fd, SNDCTL_DSP_STEREO, &r);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
51 r=MP3_samplerate;ioctl (audio_fd, SNDCTL_DSP_SPEED, &r);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
52 printf("audio_setup: using %d Hz samplerate (requested: %d)\n",r,MP3_samplerate);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
53
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
54 while(1){
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
55 int len2;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
56 if(len==0) len=MP3_DecodeFrame(buffer,-1);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
57 if(len<=0) break; // EOF
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
58
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
59 // play it
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
60 len2=write(audio_fd,buffer,len);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
61 if(len2<0) break; // ERROR?
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
62 len-=len2; total+=len2;
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
63 if(len>0){
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
64 // this shouldn't happen...
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
65 memcpy(buffer,buffer+len2,len);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
66 putchar('!');fflush(stdout);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
67 }
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
68 }
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
69
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
70 fclose(mp3file);
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
71
989b921361d0 test2 added for playback test, testreanmed to test1 to make Atmosfear happy...
arpi_esp
parents:
diff changeset
72 }