annotate src/libvorbis-1.3.3/vq/make_floor_books.pl @ 56:af97cad61ff0

Add updated build of PortAudio for OSX
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 03 Jan 2017 15:10:52 +0000
parents 05aa0afa9217
children
rev   line source
Chris@1 1 #!/usr/bin/perl
Chris@1 2
Chris@1 3 # quick, very dirty little script so that we can put all the
Chris@1 4 # information for building a floor book set in one spec file.
Chris@1 5
Chris@1 6 #eg:
Chris@1 7
Chris@1 8 # >floor_44
Chris@1 9 # =44c0_s 44c1_s 44c2_s
Chris@1 10 # build line_128x4_class0 0-256
Chris@1 11 # build line_128x4_0sub0 0-4
Chris@1 12
Chris@1 13 die "Could not open $ARGV[0]: $!" unless open (F,$ARGV[0]);
Chris@1 14
Chris@1 15 $goflag=0;
Chris@1 16 while($line=<F>){
Chris@1 17
Chris@1 18 print "#### $line";
Chris@1 19 if($line=~m/^GO/){
Chris@1 20 $goflag=1;
Chris@1 21 next;
Chris@1 22 }
Chris@1 23
Chris@1 24 if($goflag==0){
Chris@1 25 if($line=~m/\S+/ && !($line=~m/^\#/) ){
Chris@1 26 my $command=$line;
Chris@1 27 print ">>> $command";
Chris@1 28 die "Couldn't shell command.\n\tcommand:$command\n"
Chris@1 29 if syst($command);
Chris@1 30 }
Chris@1 31 next;
Chris@1 32 }
Chris@1 33
Chris@1 34 # >floor_44
Chris@1 35 # this sets the output bookset file name
Chris@1 36 if($line=~m/^>(\S+)\s+(\S*)/){
Chris@1 37 # set the output name
Chris@1 38 $globalname=$1;
Chris@1 39
Chris@1 40 $command="rm -f $globalname.vqh";
Chris@1 41 die "Couldn't remove file.\n\tcommand:$command\n"
Chris@1 42 if syst($command);
Chris@1 43
Chris@1 44 next;
Chris@1 45 }
Chris@1 46
Chris@1 47 #=path1 path2 path3
Chris@1 48 #set the search path for input files; each build line will look
Chris@1 49 #for input files in all of the directories in the search path and
Chris@1 50 #append them for huffbuild input
Chris@1 51 if($line=~m/^=(.*)/){
Chris@1 52 # set the output name
Chris@1 53 @paths=split(' ',$1);
Chris@1 54 next;
Chris@1 55 }
Chris@1 56
Chris@1 57 # build book.vqd 0-3 [noguard]
Chris@1 58 if($line=~m/^build (.*)/){
Chris@1 59 # build a huffman book (no mapping)
Chris@1 60 my($datafile,$range,$guard)=split(' ',$1);
Chris@1 61
Chris@1 62 $command="rm -f $datafile.tmp";
Chris@1 63 print "\n\n>>> $command\n";
Chris@1 64 die "Couldn't remove temp file.\n\tcommand:$command\n"
Chris@1 65 if syst($command);
Chris@1 66
Chris@1 67 # first find all the inputs we want; they'll need to be collected into a single input file
Chris@1 68 foreach $dir (@paths){
Chris@1 69 if (-e "$dir/$datafile.vqd"){
Chris@1 70 $command="cat $dir/$datafile.vqd >> $datafile.tmp";
Chris@1 71 print ">>> $command\n";
Chris@1 72 die "Couldn't append training data.\n\tcommand:$command\n"
Chris@1 73 if syst($command);
Chris@1 74 }
Chris@1 75 }
Chris@1 76
Chris@1 77 my $command="huffbuild $datafile.tmp $range $guard";
Chris@1 78 print ">>> $command\n";
Chris@1 79 die "Couldn't build huffbook.\n\tcommand:$command\n"
Chris@1 80 if syst($command);
Chris@1 81
Chris@1 82 $command="cat $datafile.vqh >> $globalname.vqh";
Chris@1 83 print ">>> $command\n";
Chris@1 84 die "Couldn't append to output book.\n\tcommand:$command\n"
Chris@1 85 if syst($command);
Chris@1 86
Chris@1 87 $command="rm $datafile.vqh";
Chris@1 88 print ">>> $command\n";
Chris@1 89 die "Couldn't remove temporary output file.\n\tcommand:$command\n"
Chris@1 90 if syst($command);
Chris@1 91
Chris@1 92 $command="rm -f $datafile.tmp";
Chris@1 93 print ">>> $command\n";
Chris@1 94 die "Couldn't remove temporary output file.\n\tcommand:$command\n"
Chris@1 95 if syst($command);
Chris@1 96 next;
Chris@1 97 }
Chris@1 98
Chris@1 99 }
Chris@1 100
Chris@1 101 $command="rm -f temp$$.vqd";
Chris@1 102 print ">>> $command\n";
Chris@1 103 die "Couldn't remove temp files.\n\tcommand:$command\n"
Chris@1 104 if syst($command);
Chris@1 105
Chris@1 106 sub syst{
Chris@1 107 system(@_)/256;
Chris@1 108 }