view TOOLS/countquant.pl @ 33803:2a4a9659d154

build: fix negative interaction between clean and distclean targets Due to the order in which double-colon rules get evaluated and executed, the ffmpeg/ subdirectory clean dependency of the distclean target was run after the distclean target in the ffmpeg/ subdirectory. Since the distclean target removes config.mak, the clean target failed because config.mak is required.
author diego
date Fri, 22 Jul 2011 10:05:08 +0000
parents 32725ca88fed
children
line wrap: on
line source

#!/usr/bin/perl -w

sub display_quants {
  $frames = 0;
  foreach $key (sort(keys(%quants))) {
    $frames += $quants{$key};
  }
  foreach $key (sort({ $a <=> $b } keys(%quants))) {
    printf("q=%d:\t% 6d, % 6.2f%%\n", $key, $quants{$key}, $quants{$key} *
           100 / $frames);
  }
  print("$lines lines processed, $frames frames found\n");
  printf("average quant. is: %f\n", $quant_total/$frames);
}

$lines = 0;
$thislines = 0;
$quant_total = 0;

while (<STDIN>) {
  $lines++;
  $thislines++;
  if (/ q:([0-9]+) /) {
    $quants{$1}++;
  } elsif (/ q:(([0-9]+)\.[0-9]+) /) {
    $quants{$2}++;
    $quant_total += $1;
  }
  if ((scalar(@ARGV) > 0) && ($thislines > $ARGV[0])) {
    display_quants();
    $thislines = 0;
  }
}

display_quants();