Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/libvorbis-1.2.0/vq/residue_entropy @ 16

Last change on this file since 16 was 16, checked in by landauf, 16 years ago

added libvorbis

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/usr/bin/perl
2
3@quant=(
4         0,  1,  1,  2,  2,  3,  3,  4,  4,  4,  5,  5,  5,  5,  6,  6,  6,
5         6,  7,  7,  7,  7,  7,  8,  8,  8,  8,  8,  8,  9,  9,  9,  9,  9,  9,
6         9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11,
7        11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
8        12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12
9);
10
11
12use POSIX;
13my($groupn)=@ARGV;
14my%hash;
15my$count=0;
16my$lines=0;
17
18if(!defined($groupn)){
19    print "Usage: residue_entropy <groupsize> \n";
20    exit(1);
21}
22$|=1;
23
24while (<STDIN>) {
25    chop;
26    my@nums = ();
27    @nums = split(/,/);
28    $lines++;
29
30    my$step=$#nums/$groupn;
31    for(my$i=0;$i<$step;$i++){
32        my$key="";
33        for(my$j=$i;$j<$#nums;$j+=$step){
34            if($nums[$j]<0){
35                $num=-$quant[int(-$nums[$j]*2)];
36            }else{
37                $num=$quant[int($nums[$j]*2)];
38            }
39            $key.=":$num";
40        }
41       
42        if(!defined($hash{$key})){
43            $count++;
44            $hash{$key}=1;
45        }
46    }
47         
48    if(($lines % 1000)==0){
49        print "\rworking... $lines lines, found $count values so far";
50    }
51}
52
53foreach $key (keys %hash){
54    print "\t$key\n";
55}
56
57print "\r$count values total                                       \n";
58print "Done.\n\n";
Note: See TracBrowser for help on using the repository browser.