annotate TOOLS/calcbpp.pl @ 26623:61f2d6d20c6e

Fix compilation: disable libdirac and libschroedinger FFmpeg de- and encoders.
author reimar
date Sat, 03 May 2008 14:25:10 +0000
parents 03d14c999d2d
children 0f1b5b68af32
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
13033
03d14c999d2d simplify rounding
wight
parents: 8476
diff changeset
8 return floor($v + 0.5);
8464
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
9 }
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
10
8476
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
11 $raw_aspect = 720/576;
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
12
8464
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");
8476
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
17 print("If your DVD is not encoded at 720x576 then change the \$raw_aspect" .
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
18 "variable at the beginning of this script.\n");
8464
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
19 exit(1);
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
20 }
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
21
8476
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
22 ($unscaled_width, $unscaled_height) = split('x', $ARGV[0]);
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
23 $encoded_at = $ARGV[1];
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
24 if ($encoded_at =~ /\//) {
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
25 my @a = split(/\//, $encoded_at);
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
26 $encoded_at = $a[0] / $a[1];
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
27 }
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
28 $scaled_width = $unscaled_width * ($encoded_at / ($raw_aspect));
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
29 $scaled_height = $unscaled_height;
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
30 $picture_ar = $scaled_width / $scaled_height;
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
31 ($bps, $fps) = @ARGV[2, 3];
8464
85ebbeeb913b scripts mentioned by DOCS/tech/encoding-tips.txt
arpi
parents:
diff changeset
32
8476
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
33 printf("Prescaled picture: %dx%d, AR %.2f\n", $scaled_width, $scaled_height,
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
34 $picture_ar);
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
35 for ($width = 720; $width >= 320; $width -= 16) {
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
36 $height = 16 * round($width / $picture_ar / 16);
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
37 $diff = round($width / $picture_ar - $height);
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
38 $new_ar = $width / $height;
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
39 $picture_ar_error = abs(100 - $picture_ar / $new_ar * 100);
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
40 printf("${width}x${height}, diff % 3d, new AR %.2f, AR error %.2f%% " .
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
41 "scale=%d:%d bpp: %.3f\n", $diff, $new_ar, $picture_ar_error, $width,
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
42 $height, ($bps * 1000) / ($width * $height * $fps));
650dda2e4bbb bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents: 8464
diff changeset
43 }