blob: 474c055cea023f1bccbc43109a6d6946e31535ba [file] [log] [blame]
 #!/usr/bin/python2.4 # # Copyright 2010 Google Inc. # All Rights Reserved. """Converts video encoding result data from text files to visualization data source.""" __author__ = "jzern@google.com (James Zern)," __author__ += "jimbankoski@google.com (Jim Bankoski)" import fnmatch import os import string import sys def FileBetter(fn1, fn2, p): """ Compares two data files and determines which is better and by how much. Also produces a histogram of how much better, by PSNR. p is the metric. """ # Store and parse our two files into lists of unique tuples up = set([]) # Read the two files, parsing out lines starting with bitrate f = open(fn1, "r") for line in f: f = string.split(line) if line[0:1] != "B": x = float(f[0]), float(f[p]) up.add(x) u = sorted(up) vp = set([]) f = open(fn2, "r") for line in f: f = string.split(line) if line[0:1] != "B": x = float(f[0]), float(f[p]) vp.add(x) v = sorted(vp) def GraphBetter(u, v, t): """ Search through the sorted PSNR file for PSNRs on either side of the PSNR from file 1. Since both lists are sorted we really should not have to search through the entire range, but these are small files..""" total = 0.0 c = 0 for br, psnr in u: for i in range(len(v) - 1): b0, p0 = v[i] b1, p1 = v[i+1] # We have a point on either side of our PSNR range if psnr > p0 and psnr <= p1: # Calculate a slope if p1-p0 != 0: s = (b1-b0)/(p1-p0) else: s = 0 ebr = b0 + (psnr-p0) * s # Calculate percentage difference in which direction? if t == 0: d = (br - ebr) / br else: d = (br - ebr) / ebr total += d c += 1 break # Calculate the average improvement between graphs if c != 0: avg = total/c else: avg = 0.0 return avg # Be fair to both graphs a = GraphBetter(u, v, 1) b = GraphBetter(v, u, 0) c = (a-b)/2 return c def HandleFiles(variables): """FIXME! """ base = variables[1] old = variables[2] print """ VP8 Results
Avg PSNR Glb PSNR PP Avg PSNR PP Glb PSNR SSIM
""" return if len(sys.argv) < 3: print """ This script creates html for displaying visually metric data produced in a video stats file, as created by the WEBM project when enable_psnr is turned on: Usage: visual_metrics.py base_directory baseline_dir sub_dir [ sub_dir2 ...] the script parses each metrics file [see below] in the baseline directory => base_directory/baseline_dir and looks for that same file in each of the sub_dirs, and compares the resultant metrics bitrate, avg psnr, glb psnr, pp avg psnr, pp glb psnr, and ssim. " It provides a table in which each row is a file in the baseline directory, and a column for each subdir, with the cells representing how that clip compares to baseline for that subdir. A graph is given for each which compares filesize to that metric. If you click on a point in the graph it zooms in on that point. a SAMPLE metrics file: Bitrate AVGPsnr GLBPsnr AVPsnrP GLPsnrP VPXSSIM Time(us) 25.911 38.242 38.104 38.258 38.121 75.790 14103 Bitrate AVGPsnr GLBPsnr AVPsnrP GLPsnrP VPXSSIM Time(us) 49.982 41.264 41.129 41.255 41.122 83.993 19817 Bitrate AVGPsnr GLBPsnr AVPsnrP GLPsnrP VPXSSIM Time(us) 74.967 42.911 42.767 42.899 42.756 87.928 17332 Bitrate AVGPsnr GLBPsnr AVPsnrP GLPsnrP VPXSSIM Time(us) 100.012 43.983 43.838 43.881 43.738 89.695 25389 Bitrate AVGPsnr GLBPsnr AVPsnrP GLPsnrP VPXSSIM Time(us) 149.980 45.338 45.203 45.184 45.043 91.591 25438 Bitrate AVGPsnr GLBPsnr AVPsnrP GLPsnrP VPXSSIM Time(us) 199.852 46.225 46.123 46.113 45.999 92.679 28302 Bitrate AVGPsnr GLBPsnr AVPsnrP GLPsnrP VPXSSIM Time(us) 249.922 46.864 46.773 46.777 46.673 93.334 27244 Bitrate AVGPsnr GLBPsnr AVPsnrP GLPsnrP VPXSSIM Time(us) 299.998 47.366 47.281 47.317 47.220 93.844 27137 Bitrate AVGPsnr GLBPsnr AVPsnrP GLPsnrP VPXSSIM Time(us) 349.769 47.746 47.677 47.722 47.648 94.178 32226 Bitrate AVGPsnr GLBPsnr AVPsnrP GLPsnrP VPXSSIM Time(us) 399.773 48.032 47.971 48.013 47.946 94.362 36203 sample use: visual_metrics.py . vp8_20101201 vp8_teststatic vp8_teststatic2 > metrics.html """ else: HandleFiles(sys.argv)