Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / libvorbis / vq / make_floor_books.pl
blob5c37366172f6bc513324a15076e4acb2124f26f9
1 #!/usr/bin/perl
3 # quick, very dirty little script so that we can put all the
4 # information for building a floor book set in one spec file.
6 #eg:
8 # >floor_44
9 # =44c0_s 44c1_s 44c2_s
10 # build line_128x4_class0 0-256
11 # build line_128x4_0sub0 0-4
13 die "Could not open $ARGV[0]: $!" unless open (F,$ARGV[0]);
15 $goflag=0;
16 while($line=<F>){
18 print "#### $line";
19 if($line=~m/^GO/){
20 $goflag=1;
21 next;
24 if($goflag==0){
25 if($line=~m/\S+/ && !($line=~m/^\#/) ){
26 my $command=$line;
27 print ">>> $command";
28 die "Couldn't shell command.\n\tcommand:$command\n"
29 if syst($command);
31 next;
34 # >floor_44
35 # this sets the output bookset file name
36 if($line=~m/^>(\S+)\s+(\S*)/){
37 # set the output name
38 $globalname=$1;
40 $command="rm -f $globalname.vqh";
41 die "Couldn't remove file.\n\tcommand:$command\n"
42 if syst($command);
44 next;
47 #=path1 path2 path3
48 #set the search path for input files; each build line will look
49 #for input files in all of the directories in the search path and
50 #append them for huffbuild input
51 if($line=~m/^=(.*)/){
52 # set the output name
53 @paths=split(' ',$1);
54 next;
57 # build book.vqd 0-3 [noguard]
58 if($line=~m/^build (.*)/){
59 # build a huffman book (no mapping)
60 my($datafile,$range,$guard)=split(' ',$1);
62 $command="rm -f $datafile.tmp";
63 print "\n\n>>> $command\n";
64 die "Couldn't remove temp file.\n\tcommand:$command\n"
65 if syst($command);
67 # first find all the inputs we want; they'll need to be collected into a single input file
68 foreach $dir (@paths){
69 if (-e "$dir/$datafile.vqd"){
70 $command="cat $dir/$datafile.vqd >> $datafile.tmp";
71 print ">>> $command\n";
72 die "Couldn't append training data.\n\tcommand:$command\n"
73 if syst($command);
77 my $command="huffbuild $datafile.tmp $range $guard";
78 print ">>> $command\n";
79 die "Couldn't build huffbook.\n\tcommand:$command\n"
80 if syst($command);
82 $command="cat $datafile.vqh >> $globalname.vqh";
83 print ">>> $command\n";
84 die "Couldn't append to output book.\n\tcommand:$command\n"
85 if syst($command);
87 $command="rm $datafile.vqh";
88 print ">>> $command\n";
89 die "Couldn't remove temporary output file.\n\tcommand:$command\n"
90 if syst($command);
92 $command="rm -f $datafile.tmp";
93 print ">>> $command\n";
94 die "Couldn't remove temporary output file.\n\tcommand:$command\n"
95 if syst($command);
96 next;
101 $command="rm -f temp$$.vqd";
102 print ">>> $command\n";
103 die "Couldn't remove temp files.\n\tcommand:$command\n"
104 if syst($command);
106 sub syst{
107 system(@_)/256;