subreader: fix unsafe sscanf calls with "%["
[mplayer.git] / TOOLS / alaw-gen.c
blob92769015d1b81e774c96da18e3359ce64f3261d3
1 /*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License along
13 * with this program; if not, write to the Free Software Foundation, Inc.,
14 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 #include <stdio.h>
18 #include <stdlib.h>
20 // sox -t raw -A -r 8000 -b alaw.alaw -t sw alaw.out
22 int main(void){
23 int i;
24 FILE *f;
26 f=fopen("alaw.dat","wb");
27 for(i=0;i<256;i++) fwrite(&i,1,1,f);
28 fclose(f);
30 system("sox -t raw -A -r 8000 -b alaw.dat -t sw alaw.out");
32 printf("// Generated by TOOLS/alaw-gen.c\n\n");
34 printf("#ifndef MPLAYER_ALAW_H\n");
35 printf("#define MPLAYER_ALAW_H\n");
37 printf("\nconst short alaw2short[]={\n");
39 f=fopen("alaw.out","rb");
40 for(i=0;i<256;i++){
41 signed short x;
42 fread(&x,2,1,f);
43 printf("%7d",x);
44 if(i!=255) putchar(',');
45 if((i&7)==7) printf("\n");
47 fclose(f);
48 printf("};\n");
50 system("sox -t raw -U -r 8000 -b alaw.dat -t sw alaw.out");
52 printf("\nconst short ulaw2short[]={\n");
54 f=fopen("alaw.out","rb");
55 for(i=0;i<256;i++){
56 signed short x;
57 fread(&x,2,1,f);
58 printf("%7d",x);
59 if(i!=255) putchar(',');
60 if((i&7)==7) printf("\n");
62 fclose(f);
63 printf("};\n\n");
65 printf("#endif /* MPLAYER_ALAW_H */\n");
67 return 0;