alaw and ulaw table generator

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@880 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
arpi_esp 2001-05-25 18:17:27 +00:00
parent 80ab4a31ae
commit 6c18809ad2
1 changed files with 47 additions and 0 deletions

47
TOOLS/alaw-gen.c Normal file
View File

@ -0,0 +1,47 @@
#include <stdio.h>
#include <stdlib.h>
// sox -t raw -A -r 8000 -b alaw.alaw -t sw alaw.out
int main(){
int i;
FILE *f;
f=fopen("alaw.dat","wb");
for(i=0;i<256;i++) fwrite(&i,1,1,f);
fclose(f);
system("sox -t raw -A -r 8000 -b alaw.dat -t sw alaw.out");
printf("// Generated by TOOLS/alaw-gen.c\n");
printf("\nshort alaw2short[]={\n");
f=fopen("alaw.out","rb");
for(i=0;i<256;i++){
signed short x;
fread(&x,2,1,f);
printf("%6d",x);
if(i!=255) putchar(',');
if((i&7)==7) printf("\n");
}
fclose(f);
printf("}\n");
system("sox -t raw -U -r 8000 -b alaw.dat -t sw alaw.out");
printf("\nshort ulaw2short[]={\n");
f=fopen("alaw.out","rb");
for(i=0;i<256;i++){
signed short x;
fread(&x,2,1,f);
printf("%6d",x);
if(i!=255) putchar(',');
if((i&7)==7) printf("\n");
}
fclose(f);
printf("}\n");
}