summaryrefslogtreecommitdiffstats
path: root/TOOLS
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-12-15 18:44:24 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-12-15 18:44:24 +0000
commitc758807e5b22050a1395f0d16b202e647e14a669 (patch)
tree41aadc8816d914440b85a35bdf4d7e7d40b35f43 /TOOLS
parent7b448af68c567937aca6c843f08577174b98c135 (diff)
downloadmpv-c758807e5b22050a1395f0d16b202e647e14a669.tar.bz2
mpv-c758807e5b22050a1395f0d16b202e647e14a669.tar.xz
scripts mentioned by DOCS/tech/encoding-tips.txt
written by Moritz Bunkus git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8465 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'TOOLS')
-rwxr-xr-xTOOLS/calcbpp.pl21
-rwxr-xr-xTOOLS/countquant.pl37
2 files changed, 58 insertions, 0 deletions
diff --git a/TOOLS/calcbpp.pl b/TOOLS/calcbpp.pl
new file mode 100755
index 0000000000..067434c1e1
--- /dev/null
+++ b/TOOLS/calcbpp.pl
@@ -0,0 +1,21 @@
+#!/usr/bin/perl -w
+
+use POSIX;
+
+sub round {
+ my $v = shift;
+
+ return floor($v + 0.5) != floor($v) ?
+ floor($v + 0.5) :
+ floor($v);
+}
+
+if (scalar(@ARGV) < 4) {
+ print("Please provide a) the cropped but unscaled resolution (e.g. " .
+ "716x524), b) the aspect ratio (either 4/3 or 16/9 for most DVDs), " .
+ "c) the video bitrate in kbps (e.g. 800) and d) the movie's fps.\n");
+ exit(1);
+}
+
+($unscaled_width, $unscaled_height) = split('x', $ARGV[0]);.$encoded_at = $ARGV[1];.if ($encoded_at =~ /\//) {. my @a = split(/\//, $encoded_at);. $encoded_at = $a[0] / $a[1];.}.$scaled_width = $unscaled_width * ($encoded_at / (5/4));.$scaled_height = $unscaled_height;.$picture_ar = $scaled_width / $scaled_height;.($bps, $fps) = @ARGV[2, 3];..printf("Prescaled picture: %dx%d, AR %.2f\n", $scaled_width, $scaled_height,. $picture_ar);.for ($width = 720; $width >= 320; $width -= 16) {. $height = 16 * round($width / $picture_ar / 16);. $diff = round($width / $picture_ar - $height);. $new_ar = $width / $height;. $picture_ar_error = abs(100 - $picture_ar / $new_ar * 100);. printf("${width}x${height}, diff % 3d, new AR %.2f, AR error %.2f%% " .. "scale=%d:%d bpp: %.3f\n", $diff, $new_ar, $picture_ar_error, $width,. $height, ($bps * 1000) / ($width * $height * $fps));.}.
+
diff --git a/TOOLS/countquant.pl b/TOOLS/countquant.pl
new file mode 100755
index 0000000000..2b19c5b79d
--- /dev/null
+++ b/TOOLS/countquant.pl
@@ -0,0 +1,37 @@
+#!/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();
+
+