annotate TOOLS/calcbpp.pl @ 8464:85ebbeeb913b

scripts mentioned by DOCS/tech/encoding-tips.txt written by Moritz Bunkus
author arpi
date Sun, 15 Dec 2002 18:44:24 +0000
parents
children 650dda2e4bbb
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 use POSIX;
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
4
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
5 sub round {
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
6 my $v = shift;
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 return floor($v + 0.5) != floor($v) ?
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
9 floor($v + 0.5) :
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
10 floor($v);
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
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
13 if (scalar(@ARGV) < 4) {
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
14 print("Please provide a) the cropped but unscaled resolution (e.g. " .
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
15 "716x524), b) the aspect ratio (either 4/3 or 16/9 for most DVDs), " .
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
16 "c) the video bitrate in kbps (e.g. 800) and d) the movie's fps.\n");
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
17 exit(1);
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
18 }
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 ($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));.}.
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
21