Mercurial > mplayer.hg
annotate TOOLS/plotpsnr.pl @ 36679:36cbede21428
Fix bug with unicode font loading for font.desc files.
Unicode glyphs might not get loaded even if they are requested and
available.
Fix it by checking the font encoding rather than the subtitle encoding
when loading the font.
author | ib |
---|---|
date | Sat, 01 Feb 2014 16:57:50 +0000 |
parents | 0f1b5b68af32 |
children |
rev | line source |
---|---|
9366 | 1 #!/usr/bin/perl |
2 # | |
3 # Licence: GPL | |
4 # | |
5 # 2003/02/09 Jonas Jermann <jjermann@gmx.net> | |
6 # | |
7 # Script: Draw PSNR log graphs using gnuplot | |
8 # | |
9 # requires: gnuplot | |
10 | |
11 use Getopt::Long; | |
12 | |
13 # MAIN | |
14 my %options; | |
15 my $dem_file="psnr.dem"; | |
16 | |
17 commandline(); | |
18 demo_file(); | |
19 | |
20 system ("gnuplot $dem_file"); | |
9367 | 21 system("rm $dem_file $options{file}.[IPB] $options{file}.diff* 2>/dev/null"); |
9366 | 22 exit 0; |
23 | |
24 | |
25 # DEMO FILE | |
26 sub demo_file { | |
27 | |
28 if ($options{file2}) { | |
29 my @file1_cont = (); | |
30 my @file2_cont = (); | |
31 my $NewRow,$i,$j; | |
32 | |
33 open(LIST_IN, "$options{file}"); while( <LIST_IN> ) { | |
34 $NewRow=[]; | |
35 @$NewRow = split(/[ ,]+/, $_); | |
36 push( @file1_cont, $NewRow ); | |
37 } | |
38 close(LIST_IN); | |
39 | |
40 open(LIST_IN2, "$options{file2}"); while( <LIST_IN2> ) { | |
41 $NewRow=[]; | |
42 @$NewRow = split(/[ ,]+/, $_); | |
43 push( @file2_cont, $NewRow ); | |
44 } | |
45 close(LIST_IN2); | |
46 | |
47 open(LIST_OUT, ">$options{file}.diff"); | |
48 for($i=0; $i<=$#file2_cont; $i++) { | |
49 print LIST_OUT " $file2_cont[$i]->[1],\ "; | |
50 for($j=2; $j<=7; $j++) { | |
51 $file2_cont[$i]->[$j] -= $file1_cont[$i]->[$j]; | |
52 print LIST_OUT " $file2_cont[$i]->[$j],\ "; | |
53 } | |
54 print LIST_OUT " $file2_cont[$i]->[8]\n"; | |
55 } | |
56 close(LIST_OUT); | |
57 $options{file}="$options{file}.diff"; | |
58 } | |
59 | |
60 if ($options{iframes}) { system("cat $options{file} | grep I > $options{file}.I"); } | |
61 if ($options{pframes}) { system("cat $options{file} | grep P > $options{file}.P"); } | |
62 if ($options{bframes}) { system("cat $options{file} | grep B > $options{file}.B"); } | |
63 | |
64 open(DEM_FILE,">$dem_file"); | |
65 | |
66 print DEM_FILE "#PSNR Statistics | |
67 #--------------- | |
68 | |
69 set title \"PSNR Statistics\" | |
70 set data style fsteps | |
71 set xlabel \"Frames\" | |
72 set grid | |
73 | |
74 | |
75 "; | |
76 | |
77 if ($options{quant}) { | |
78 print DEM_FILE "# Quantizers | |
79 plot [] [0:] \\"; | |
80 if ($options{pframes}) { | |
81 print DEM_FILE " | |
82 \"$options{file}.P\" using 1:2 t \"Quantizer: P frames\" w $options{qs}"; | |
83 if ($options{bframes} || $options{iframes}) { print DEM_FILE ",\\"; } | |
84 } | |
85 if ($options{bframes}) { | |
86 print DEM_FILE " | |
87 \"$options{file}.B\" using 1:2 t \"Quantizer: B frames\" w $options{qs}"; | |
88 if ($options{iframes}) { print DEM_FILE ",\\"; } | |
89 } | |
90 if ($options{iframes}) { | |
91 print DEM_FILE " | |
92 \"$options{file}.I\" using 1:2 t \"Quantizer: I frames\" w $options{qs}"; | |
93 } | |
94 if (!($options{pframes} || $options{bframes} || $options{iframes})) { | |
95 print DEM_FILE " | |
96 \"$options{file}\" using 1:2 t \"Quantizer\" w $options{qs}"; | |
97 } | |
98 | |
99 print DEM_FILE " | |
100 pause -1 | |
101 | |
102 "; | |
103 } | |
104 | |
105 | |
106 if ($options{size}) { | |
107 print DEM_FILE "# Frame size | |
108 plot \\"; | |
109 if ($options{pframes}) { | |
110 print DEM_FILE " | |
111 \"$options{file}.P\" using 1:3 t \"Size: P frames\" w $options{ss}"; | |
112 if ($options{bframes}||$options{iframes}) { print DEM_FILE ",\\"; } | |
113 } | |
114 if ($options{bframes}) { | |
115 print DEM_FILE " | |
116 \"$options{file}.B\" using 1:3 t \"Size: B frames\" w $options{ss}"; | |
117 if ($options{iframes}) { print DEM_FILE ",\\"; } | |
118 } | |
119 if ($options{iframes}) { | |
120 print DEM_FILE " | |
121 \"$options{file}.I\" using 1:3 t \"Size: I frames\" w $options{ss}"; | |
122 } | |
123 if (!($options{pframes}||$options{bframes}||$options{iframes})) { | |
124 print DEM_FILE " | |
125 \"$options{file}\" using 1:3 t \"Size\" w $options{ss}"; | |
126 } | |
127 | |
128 print DEM_FILE " | |
129 pause -1 | |
130 | |
131 "; | |
132 } | |
133 | |
134 if ($options{psnr}) { | |
135 print DEM_FILE "# PSNR | |
136 plot \\"; | |
137 if ($options{pframes}) { | |
138 print DEM_FILE " | |
139 \"$options{file}.P\" using (\$1):(\$7) t \"PSNR (All): P frames\" w $options{ps}"; | |
140 if ($options{bframes}||$options{iframes}) { print DEM_FILE ",\\"; } | |
141 } | |
142 if ($options{bframes}) { | |
143 print DEM_FILE " | |
144 \"$options{file}.B\" using (\$1):(\$7) t \"PSNR (All): B frames\" w $options{ps}"; | |
145 if ($options{iframes}) { print DEM_FILE ",\\"; } | |
146 } | |
147 if ($options{iframes}) { | |
148 print DEM_FILE " | |
149 \"$options{file}.I\" using (\$1):(\$7) t \"PSNR (All): I frames\" w $options{ps}"; | |
150 } | |
151 if (!($options{pframes}||$options{bframes}||$options{iframes})) { | |
152 print DEM_FILE " | |
153 \"$options{file}\" using (\$1):(\$7) t \"PSNR (All)\" w $options{ps}"; | |
154 } | |
155 | |
156 print DEM_FILE " | |
157 #\"$options{file}\" using (\$1):(\$4) t \"PSNR (Y)\" w $options{ps} \\ | |
158 #\"$options{file}\" using (\$1):(\$5) t \"PSNR (Cb)\" w $options{ps} \\ | |
159 #\"$options{file}\" using (\$1):(\$6) t \"PSNR (Cr)\" w $options{ps} | |
160 pause -1 | |
161 | |
162 "; | |
163 } | |
164 | |
165 print DEM_FILE " | |
166 reset"; | |
167 | |
168 close (DEM_FILE); | |
169 } | |
170 | |
171 | |
172 | |
173 # USAGE | |
174 sub usage { | |
175 print STDERR <<EOF; | |
176 | |
177 Usage: plotpsnr.pl [options] 'file' | |
178 | |
179 Options: | |
180 -h, --help Display this help message | |
181 -quant Display quantizers | |
182 -size Display size | |
183 -psnr Display PSNR | |
184 -iframes Display I frames | |
185 -pframes Display P frames | |
186 -bframes Display B frames | |
187 -aframes Display all frames in different colors | |
188 -cmp <file2> Compare two files | |
189 -qs <style> Quantizer style | |
190 -ss <style> Size style | |
191 -ps <style> PSNR style | |
192 | |
193 Default: -quant -size -psnr -qs "p" -ss "i" -ps "p" | |
194 | |
195 Notes: | |
196 Comparison is based on file2. | |
197 Comparison assumes that the frame numbers of both files fit. | |
198 | |
199 EOF | |
200 exit 1; | |
201 } | |
202 | |
203 | |
204 # COMMAND LINE | |
205 sub commandline { | |
206 $options{qs}="p"; | |
207 $options{ss}="i"; | |
208 $options{ps}="p"; | |
209 | |
210 GetOptions( | |
211 "help|h" => \&usage, | |
212 "quant" => \$options{quant}, | |
213 "size" => \$options{size}, | |
214 "psnr" => \$options{psnr}, | |
215 "cmp=s" => \$options{file2}, | |
216 "iframes" => \$options{iframes}, | |
217 "pframes" => \$options{pframes}, | |
218 "bframes" => \$options{bframes}, | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
9367
diff
changeset
|
219 "aframes" => sub { $options{iframes} = 1; |
9366 | 220 $options{pframes} = 1; |
221 $options{bframes} = 1; }, | |
222 "qs=s" => \$options{qs}, | |
223 "ss=s" => \$options{ss}, | |
224 "ps=s" => \$options{ps}, | |
225 ) || usage(); | |
226 | |
227 if (!($options{quant}||$options{size}||$options{psnr})) { | |
228 $options{quant}=1; | |
229 $options{size}=1; | |
230 $options{psnr}=1; | |
231 } | |
232 | |
233 $options{file}="@ARGV"; | |
234 } |