Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / libvorbis / vq / make_residue_books.pl
blobb811fe2bc491b29710c5a4d58f3d8b24ffd3fc50
1 #!/usr/bin/perl
3 # quick, very dirty little script so that we can put all the
4 # information for building a residue book set (except the original
5 # partitioning) in one spec file.
7 #eg:
9 # >res0_128_128 interleaved
10 # haux 44c0_s/resaux_0.vqd res0_96_128aux 0,4,2 9
11 # :1 res0_128_128_1.vqd, 4, nonseq cull, 0 +- 1
12 # :2 res0_128_128_2.vqd, 4, nonseq, 0 +- 1(.7) 2
13 # :3 res0_128_128_3.vqd, 4, nonseq, 0 +- 1(.7) 3 5
14 # :4 res0_128_128_4.vqd, 2, nonseq, 0 +- 1(.7) 3 5 8 11
15 # :5 res0_128_128_5.vqd, 1, nonseq, 0 +- 1 3 5 8 11 14 17 20 24 28 31 35 39
18 die "Could not open $ARGV[0]: $!" unless open (F,$ARGV[0]);
20 $goflag=0;
21 while($line=<F>){
23 print "#### $line";
24 if($line=~m/^GO/){
25 $goflag=1;
26 next;
29 if($goflag==0){
30 if($line=~m/\S+/ && !($line=~m/^\#/) ){
31 my $command=$line;
32 print ">>> $command";
33 die "Couldn't shell command.\n\tcommand:$command\n"
34 if syst($command);
36 next;
39 # >res0_128_128
40 if($line=~m/^>(\S+)\s+(\S*)/){
41 # set the output name
42 $globalname=$1;
43 $interleave=$2;
44 next;
47 # haux 44c0_s/resaux_0.vqd res0_96_128aux 0,4,2 9
48 if($line=~m/^h(.*)/){
49 # build a huffman book (no mapping)
50 my($name,$datafile,$bookname,$interval,$range)=split(' ',$1);
52 # check the desired subdir to see if the data file exists
53 if(-e $datafile){
54 my $command="cp $datafile $bookname.tmp";
55 print ">>> $command\n";
56 die "Couldn't access partition data file.\n\tcommand:$command\n"
57 if syst($command);
59 my $command="huffbuild $bookname.tmp $interval";
60 print ">>> $command\n";
61 die "Couldn't build huffbook.\n\tcommand:$command\n"
62 if syst($command);
64 my $command="rm $bookname.tmp";
65 print ">>> $command\n";
66 die "Couldn't remove temporary file.\n\tcommand:$command\n"
67 if syst($command);
68 }else{
69 my $command="huffbuild $bookname.tmp 0-$range";
70 print ">>> $command\n";
71 die "Couldn't build huffbook.\n\tcommand:$command\n"
72 if syst($command);
75 next;
78 # :1 res0_128_128_1.vqd, 4, nonseq, 0 +- 1
79 if($line=~m/^:(.*)/){
80 my($namedata,$dim,$seqp,$vals)=split(',',$1);
81 my($name,$datafile)=split(' ',$namedata);
82 # build value list
83 my$plusminus="+";
84 my$list;
85 my$thlist;
86 my$count=0;
87 foreach my$val (split(' ',$vals)){
88 if($val=~/\-?\+?\d+/){
89 my$th;
91 # got an explicit threshhint?
92 if($val=~/([0-9\.]+)\(([^\)]+)/){
93 $val=$1;
94 $th=$2;
97 if($plusminus=~/-/){
98 $list.="-$val ";
99 if(defined($th)){
100 $thlist.="," if(defined($thlist));
101 $thlist.="-$th";
103 $count++;
105 if($plusminus=~/\+/){
106 $list.="$val ";
107 if(defined($th)){
108 $thlist.="," if(defined($thlist));
109 $thlist.="$th";
111 $count++;
113 }else{
114 $plusminus=$val;
117 die "Couldn't open temp file temp$$.vql: $!" unless
118 open(G,">temp$$.vql");
119 print G "$count $dim 0 ";
120 if($seqp=~/non/){
121 print G "0\n$list\n";
122 }else{
123 print G "1\n$list\n";
125 close(G);
127 my $command="latticebuild temp$$.vql > $globalname$name.vqh";
128 print ">>> $command\n";
129 die "Couldn't build latticebook.\n\tcommand:$command\n"
130 if syst($command);
132 my $command="latticehint $globalname$name.vqh $thlist > temp$$.vqh";
133 print ">>> $command\n";
134 die "Couldn't pre-hint latticebook.\n\tcommand:$command\n"
135 if syst($command);
137 if(-e $datafile){
139 if($interleave=~/non/){
140 $restune="res1tune";
141 }else{
142 $restune="res0tune";
145 if($seqp=~/cull/){
146 my $command="$restune temp$$.vqh $datafile 1 > $globalname$name.vqh";
147 print ">>> $command\n";
148 die "Couldn't tune latticebook.\n\tcommand:$command\n"
149 if syst($command);
150 }else{
151 my $command="$restune temp$$.vqh $datafile > $globalname$name.vqh";
152 print ">>> $command\n";
153 die "Couldn't tune latticebook.\n\tcommand:$command\n"
154 if syst($command);
157 my $command="latticehint $globalname$name.vqh $thlist > temp$$.vqh";
158 print ">>> $command\n";
159 die "Couldn't post-hint latticebook.\n\tcommand:$command\n"
160 if syst($command);
162 }else{
163 print "No matching training file; leaving this codebook untrained.\n";
166 my $command="mv temp$$.vqh $globalname$name.vqh";
167 print ">>> $command\n";
168 die "Couldn't rename latticebook.\n\tcommand:$command\n"
169 if syst($command);
171 my $command="rm temp$$.vql";
172 print ">>> $command\n";
173 die "Couldn't remove temp files.\n\tcommand:$command\n"
174 if syst($command);
176 next;
180 $command="rm -f temp$$.vqd";
181 print ">>> $command\n";
182 die "Couldn't remove temp files.\n\tcommand:$command\n"
183 if syst($command);
185 sub syst{
186 system(@_)/256;