Revision 304e363b QoE.pl

View differences:

QoE.pl
2 2

  
3 3
use strict;
4 4
use Statistics::Descriptive;
5
use POSIX qw(ceil floor);
5 6

  
6
($#ARGV + 1 == 1) or die;
7
($#ARGV + 1 == 2) or die;
7 8
my $inputfolder=$ARGV[0];
9
my $video=$ARGV[1];
8 10

  
9 11

  
12
#a value of 'src' for the peer creates an empty lost file
10 13
sub peer_chunks_lost ($) {
11 14
  my ($peer)=@_;
12
 
13
  my @losts=`./chunks_lost.sh $peer $inputfolder| tee lost.txt`;
15

  
16
  my @losts;
17
  if ($peer=='src') {
18
    @losts=`echo -n > lost.txt`;
19
  } else {
20
    @losts=`./chunks_lost.sh $peer $inputfolder| tee lost.txt`;
21
  }
14 22
  chomp @losts;
15 23
  return @losts;
16 24
}
17 25

  
18
sub peer_qoe ($) {
19
  my ($peer)=@_;
26
sub peer_qoe ($$) {
27
  my ($peer,$chunksize)=@_;
20 28

  
21 29
  my @losts = peer_chunks_lost($peer);
22 30

  
23 31
  my %qoe;
24 32
  #$qoe{ 'chunkloss' } = peer_chunkloss($peer,@losts);
25 33

  
26
  my $q=`./psnr.sh calc 40000 lost.txt`;
34
  my $q;
35
  if ($chunksize=='gop') {
36
  	$q=`./psnr.sh calc 0 lost.txt`;
37
  } else {
38
  	$q=`./psnr.sh calc $chunksize lost.txt`;
39
  }
27 40

  
28 41
  $q =~ m/psnr: ([\d\.]+)/;
29 42
  $qoe{ 'psnr' } = $1;
......
78 91
  #      "Variance         = $variance\n";
79 92
}
80 93

  
81
#--------------------------------------------------
82 94

  
95
sub qoe($){
96
  my ($chunksize)=@_;
97

  
98
  my @peerclasses=(1,2,3,4);
83 99

  
84
my @peerclasses=(1,2,3,4);
100
  my @psnrs;
101
  my @chunklosses;
102
  
103
  foreach my $peerclass (@peerclasses) {
85 104

  
86
foreach my $peerclass (@peerclasses) {
105
    print "Peer class = $peerclass\n";
87 106

  
88
  print "Peer class = $peerclass\n";
107
    my @peers=peers_of_class($peerclass);
89 108

  
90
  my @peers=peers_of_class($peerclass);
109
    my @psnrs_class;
110
    my @chunklosses_class;
111
    foreach my $peer (@peers) {
112
      my %qoe = peer_qoe($peer,$chunksize);
91 113

  
92
  my @psnrs;
93
  my @chunklosses;
94
  foreach my $peer (@peers) {
95
    #my $qoe=`./chunks_lost.sh $peer | wc -l`;
96
    #chomp $qoe;
97
    #print "peer $peer: QoE: $qoe\n";
98
    my %qoe = peer_qoe($peer);
99

  
100
    push(@psnrs,$qoe{'psnr'});
101
    push(@chunklosses,$qoe{'chunkloss'});
114
      push(@psnrs,$qoe{'psnr'});
115
      push(@psnrs_class,$qoe{'psnr'});
116
      push(@chunklosses,$qoe{'chunkloss'});
117
      push(@chunklosses_class,$qoe{'chunkloss'});
118
    }
119

  
120
    print_stats("psnr(uncompressed->received)",@psnrs_class);
121
    print_stats("chunkloss",@chunklosses_class);
122
    print "\n";
102 123
  }
103 124

  
104
  print_stats("psnr",@psnrs);
125
  print "All peers\n";
126
  print_stats("psnr(uncompressed->received)",@psnrs);
105 127
  print_stats("chunkloss",@chunklosses);
106 128
}
107 129

  
130
#--------------------------------------------------
108 131

  
109
#open(FH, "$ARGV[0]") or die "No file specified\n";
110
#my @temp=<FH>;
111
#close FH;
132
my $tmp=`./psnr.sh init $video`;
133
my %srcqoe = peer_qoe('src','gop');
134
print "psnr(uncompressed->compressed): ".$srcqoe{'psnr'}."\n";
112 135

  
113
#my $stat = Statistics::Descriptive::Full->new();
114
#$stat->add_data(\@temp);
115
#my $mean = $stat->mean();
116
#my $variance  = $stat->variance();
117
#my $num  = $stat->count();
136
my $chunksize = ceil($srcqoe{'bytes'}/$srcqoe{'chunks'}); 
118 137

  
119
#print "Number of Values = $num\n",
120
#      "Mean             = $mean\n",
121
#      "Variance         = $variance\n";
138
print "\nQuality with GOP size chunks (avg chunk size = $srcqoe{'bytes'}/$srcqoe{'chunks'} bytes )\n";
139
qoe('gop');
140
print "\nQuality with $chunksize bytes chunks\n";
141
qoe('$chunksize');

Also available in: Unified diff