Home | History | Annotate | Download | only in livemedia
      1  38  dave #
      2  38  dave # CDDL HEADER START
      3  38  dave #
      4  38  dave # The contents of this file are subject to the terms of the
      5  38  dave # Common Development and Distribution License (the "License").
      6  38  dave # You may not use this file except in compliance with the License.
      7  38  dave #
      8  38  dave # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9  38  dave # or http://www.opensolaris.org/os/licensing.
     10  38  dave # See the License for the specific language governing permissions
     11  38  dave # and limitations under the License.
     12  38  dave #
     13  38  dave # When distributing Covered Code, include this CDDL HEADER in each
     14  38  dave # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15  38  dave # If applicable, add the following below this CDDL HEADER, with the
     16  38  dave # fields enclosed by brackets "[]" replaced with your own identifying
     17  38  dave # information: Portions Copyright [yyyy] [name of copyright owner]
     18  38  dave #
     19  38  dave # CDDL HEADER END
     20  38  dave #
     21  38  dave 
     22  38  dave #
     23  38  dave # Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
     24  38  dave # Use is subject to license terms.
     25  38  dave #
     26  38  dave # ident "%Z%%M% %I%	%E% SMI"
     27  38  dave #
     28  38  dave 
     29  38  dave my $slist = $ARGV[0];
     30  38  dave 
     31  38  dave open(LST, "<$slist") || die "Cannot open slist";
     32  38  dave 
     33  38  dave my %hash = ();
     34  38  dave my %hash1 = ();
     35  38  dave my @lst = ();
     36  38  dave my $count = 2000000;
     37  38  dave #my $count = 1993235;
     38  38  dave #my $count = 2400000;
     39  38  dave my $diff = 5;
     40  38  dave my $ucount = 0;
     41  38  dave 
     42  38  dave while (my $line=<LST>) {
     43  38  dave 
     44  38  dave 	chomp($line);
     45  38  dave 	my @entry = split(/ /, $line);
     46  38  dave 	my $upd = 0;
     47  38  dave 
     48  38  dave 	if (exists($hash{"$entry[1]"})) {
     49  38  dave 		my $pos = $hash{"$entry[1]"};
     50  38  dave 		my @lentry = split(/ /, $lst[$pos]);
     51  38  dave 		if ($ucount - $lentry[1] <= $diff) {
     52  38  dave 			$lentry[0]++;
     53  38  dave 			my $lstent = "$lentry[0] $lentry[1] $lentry[2] $lentry[3]";
     54  38  dave #print "Updating $lstent\n";
     55  38  dave 			$lst[$pos] = $lstent;
     56  38  dave 			$upd = 1;
     57  38  dave 		}
     58  38  dave 	}
     59  38  dave 	if ($upd == 0) {
     60  38  dave 		my $lstent = "1 $ucount $line";
     61  38  dave #print "$lstent\n";
     62  38  dave 		$#lst++;
     63  38  dave 		$lst[$#lst] = $lstent;
     64  38  dave 		$hash{"$entry[1]"} = $#lst;
     65  38  dave 		$ucount++;
     66  38  dave 	}
     67  38  dave }
     68  38  dave close(LST);
     69  38  dave 
     70  38  dave foreach $lstent (@lst) {
     71  38  dave 	my @lentry = split(/ /, $lstent);
     72  38  dave #print "$lstent\n";
     73  38  dave 
     74  38  dave 	if (exists($hash1{"$lentry[3]"})) {
     75  38  dave 		my $hentry = $hash1{"$lentry[3]"};
     76  38  dave #print "Got $lentry[3],$lentry[0]: $hentry->[3],$hentry->[0]\n";
     77  38  dave 		if ($lentry[0] > $hentry->[0]) {
     78  38  dave #print "$hentry->[3] $hentry->[0] swapping to $lentry[3] $lentry[0]\n";
     79  38  dave 			$hentry->[0] = $lentry[0];
     80  38  dave 			$hentry->[1] = $lentry[1];
     81  38  dave 			$hentry->[2] = $lentry[2];
     82  38  dave 			$hentry->[3] = $lentry[3];
     83  38  dave 			$hash1{"$lentry[3]"} = $hentry;
     84  38  dave 
     85  38  dave 		} elsif ($lentry[0] == $hentry->[0]) {
     86  38  dave 			if ($lentry[2] > $hentry->[2]) {
     87  38  dave 				$hentry->[0] = $lentry[0];
     88  38  dave 				$hentry->[1] = $lentry[1];
     89  38  dave 				$hentry->[2] = $lentry[2];
     90  38  dave 				$hentry->[3] = $lentry[3];
     91  38  dave 				$hash1{"$lentry[3]"} = $hentry;
     92  38  dave 			}
     93  38  dave 		}
     94  38  dave 	} else {
     95  38  dave #print "Assigning hash1{$lentry[3]} = \@lentry\n";
     96  38  dave 		$hash1{"$lentry[3]"} = \@lentry;
     97  38  dave 	}
     98  38  dave }
     99  38  dave 
    100  38  dave if (open(PRE, "<$LIVEKIT/iso.sort.pre")) {
    101  38  dave 	while ($line=<PRE>) {
    102  38  dave 		print $line;
    103  38  dave 	}
    104  38  dave 	close(PRE);
    105  38  dave }
    106  38  dave 
    107  38  dave my @vals = (values(%hash1));
    108  38  dave @vals = sort({$a->[1] <=> $b->[1]} @vals);
    109  38  dave foreach my $ventry (@vals) {
    110  38  dave 	print "$ventry->[3]\t$count\n";
    111  38  dave 	$count--;
    112  38  dave }
    113  38  dave 
    114  38  dave print "usr\t$count\n";
    115