2 # countquant_x264.pl: displays statistics from x264 multipass logfiles
3 # by Loren Merritt, 2005-4-5
11 /type:(.) q:(\d+\.\d+) tex:(\d+) mv:(\d+) misc:(\d+)/ or next;
17 my $bytes = ($3+$4+$5)/8;
18 $size{$type} += $bytes;
20 $size = $size{I} + $size{P} + $size{B};
21 $n = $n{I} + $n{P} + $n{B};
22 $n or die "unrecognized input\n";
27 open $fh, "<", $_ or die "can't open '$_': $!";
36 printf "q%2d: %6d %4.1f%%\n", $_, $q[$_], 100*$q[$_]/$n;
39 $digits = int(log($n+1)/log(10))+2;
40 printf "All: %${digits}d %s avgQP:%5.2f avgBytes:%5d\n",
41 $n, $n==$n{I}?" ":"", $avgq/$n, $size/$n;
42 foreach(qw(I P B S)) {
44 printf "%s: %${digits}d (%4.1f%%) avgQP:%5.2f avgBytes:%5d\n",
45 $_, $n{$_}, 100*$n{$_}/$n, $avgq{$_}/$n{$_}, $size{$_}/$n{$_};
48 printf "total size: $size B = %.2f KiB = %.2f MiB\n",
49 $size/2**10, $size/2**20;
50 print "bitrate: ", join("\n = ",
51 map sprintf("%.2f kbps @ %s fps", $_*$size*8/1000/$n, $_),
52 23.976, 25, 29.97), "\n";