Mercurial > mplayer.hg
annotate TOOLS/calcbpp.pl @ 11006:fae1fe725886
Resync :)
(just forgot to change synced with... comments, as noted by Diego Biurrun.
changing them now)
author | lumag |
---|---|
date | Sat, 04 Oct 2003 22:54:17 +0000 |
parents | 650dda2e4bbb |
children | 03d14c999d2d |
rev | line source |
---|---|
8464 | 1 #!/usr/bin/perl -w |
2 | |
3 use POSIX; | |
4 | |
5 sub round { | |
6 my $v = shift; | |
7 | |
8 return floor($v + 0.5) != floor($v) ? | |
9 floor($v + 0.5) : | |
10 floor($v); | |
11 } | |
12 | |
8476
650dda2e4bbb
bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents:
8464
diff
changeset
|
13 $raw_aspect = 720/576; |
650dda2e4bbb
bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents:
8464
diff
changeset
|
14 |
8464 | 15 if (scalar(@ARGV) < 4) { |
16 print("Please provide a) the cropped but unscaled resolution (e.g. " . | |
17 "716x524), b) the aspect ratio (either 4/3 or 16/9 for most DVDs), " . | |
18 "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
|
19 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
|
20 "variable at the beginning of this script.\n"); |
8464 | 21 exit(1); |
22 } | |
23 | |
8476
650dda2e4bbb
bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents:
8464
diff
changeset
|
24 ($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
|
25 $encoded_at = $ARGV[1]; |
650dda2e4bbb
bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents:
8464
diff
changeset
|
26 if ($encoded_at =~ /\//) { |
650dda2e4bbb
bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents:
8464
diff
changeset
|
27 my @a = split(/\//, $encoded_at); |
650dda2e4bbb
bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents:
8464
diff
changeset
|
28 $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
|
29 } |
650dda2e4bbb
bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents:
8464
diff
changeset
|
30 $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
|
31 $scaled_height = $unscaled_height; |
650dda2e4bbb
bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents:
8464
diff
changeset
|
32 $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
|
33 ($bps, $fps) = @ARGV[2, 3]; |
8464 | 34 |
8476
650dda2e4bbb
bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents:
8464
diff
changeset
|
35 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
|
36 $picture_ar); |
650dda2e4bbb
bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents:
8464
diff
changeset
|
37 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
|
38 $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
|
39 $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
|
40 $new_ar = $width / $height; |
650dda2e4bbb
bunkus: Restored sane line breaks. Added note about other DVD resolutions than 720x576.
mosu
parents:
8464
diff
changeset
|
41 $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
|
42 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
|
43 "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
|
44 $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
|
45 } |