annotate TOOLS/countquant.pl @ 13394:455a5056801f

New generic 'portable anymap' video output driver. It supports portable pixmaps and graymaps in both raw and ASCII mode. Besides PPM and PGM, it can also output PGMYUV files which are PGM files with the U and V plane appended to the bottom of the Y image (bottom left and bottom right). All files can be written to the current directory, to a specified output directory or to multiple subdirectories if the filesystem can't handle the amount of files in one directory anymore. Note: This driver is not yet activated and will not be compiled and linked to libvo. A separate patch will take care of that. This is just for adding the file to the repository.
author ivo
date Mon, 20 Sep 2004 00:54:57 +0000
parents 85ebbeeb913b
children 32725ca88fed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8464
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
1 #!/usr/bin/perl -w
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
2
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
3 sub display_quants {
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
4 $frames = 0;
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
5 foreach $key (sort(keys(%quants))) {
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
6 $frames += $quants{$key};
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
7 }
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
8 foreach $key (sort({ $a <=> $b } keys(%quants))) {
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
9 printf("q=%d:\t% 6d, % 6.2f%%\n", $key, $quants{$key}, $quants{$key} *
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
10 100 / $frames);
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
11 }
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
12 print("$lines lines processed, $frames frames found\n");
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
13 printf("average quant. is: %f\n", $quant_total/$frames);
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
14 }
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
15
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
16 $lines = 0;
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
17 $thislines = 0;
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
18 $quant_total = 0;
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
19
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
20 while (<STDIN>) {
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
21 $lines++;
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
22 $thislines++;
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
23 if (/ q:([0-9]+) /) {
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
24 $quants{$1}++;
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
25 } elsif (/ q:(([0-9]+)\.[0-9]+) /) {
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
26 $quants{$2}++;
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
27 $quant_total += $1;
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
28 }
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
29 if ((scalar(@ARGV) > 0) && ($thislines > $ARGV[0])) {
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
30 display_quants();
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
31 $thislines = 0;
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
32 }
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
33 }
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
34
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
35 display_quants();
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
36
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
37