&calc1($ARGV[0]);

sub calc1
{
  my($src)=@_;
  open(IN, $src);
  $actPel =0;
  $fnum = 0;
  $flag = 0;
  while($str_tmp = <IN>) 
  {
    $str_tmp =~ s/\*.//g;
    if ($str_tmp =~ /ACT_CODED_INTRA/)
    { 
      $str_tmp =~ s/://g; 
      #printf("%s\n", $str_tmp);
      ($tmp1, $pel) = split(/\s+/,$str_tmp);
      chomp $pel;
      $actPel += $pel;
    }
    elsif ($str_tmp =~ /ACT_CODED_INTER/)
    { 
      $str_tmp =~ s/://g; 
      #printf("%s\n", $str_tmp);
      ($tmp1, $pel) = split(/\s+/,$str_tmp);
      chomp $pel;
      $actPel += $pel;
    }
    elsif ($str_tmp =~ /^POC/)
    { 
      $flag = 1;
      $str_tmp =~ s/://g; 
      #printf("%s\n", $str_tmp);
      ($tmp1, $poc, $tmp2) = split(/\s+/,$str_tmp);
      $fnum = $poc + 1;
    }
  }
  if ($flag!=1)
  {
    printf ("%s does NOT have complete decoding information.\n", $src);
  }
  else
  {
    printf ("%.2lf\n", $actPel / $fnum);
  }
  close(IN);
}
