Tuesday, October 6, 2009

Aspect ratios

Aspect ratios

A DVD video stream is 720x480, right? But 720/480 = 1.5 which is an impossible aspect ratio for a movie. And what about full screen, widescreen, anamorphic, etc?

Many people are unfamiliar with these terms and are unsure about how to resize. This article tries to explain some of these mysteries.

DAR - or how to make the DVD look right

Each MPEG-2 Video stream has a DAR (Display Aspect Ratio) flag. The flag tells the player for what kind of target display the stream has been encoded. There's 4 values: 1:1, 4:3, 16:9 and 2.11:1. The first and last one are not terribly important since there's no TVs having these aspect ratios. A video stream having a DAR of 16:9 is designated for a 16:9 TV, but that doesn't mean it can't be used for 4:3 TVs. The same applies to a DAR of 4:3.

Now let's have a look at a real example: Austin Powers: International Man of Mystery, R1. As this is an NTSC disc the video stream has a resolution of 720x480 (PAL discs have 720x576.. but everything explained in this article also applies for these streams, but the resizing takes the vertical resolution 576 into account). This disc contains 2 versions of the movie: widescreen version and standard version. Standard (also called fullscreen on this disc) is the standard for a 4:3 TV, that is a picture that fills the whole screen, whereas widescreen in this case means 16:9. The expression widescreen should not be used in that way since there is 2 different widescreen variants: letterboxed widescreen and anamorphic widescreen, both of which will be illustrated a little farther down the line. After ripping you can load the VOBs from the widescreen side into DVD2AVI and you'll get an output which looks like the following:

This looks a bit strange doesn't it? Of course, it's 720x480 which gives an aspect ratio of 1:1.5 whereas the movie actually has an aspect ratio of 1:1.85.

When you press F5 for preview the statistic window will tell you that this is a 16:9 stream.

When you watch the movie in your software DVD player what you'll get is this:

This looks better, right? People are not longer squeezed and thin, they look the way they looked on the big screen.

What has happened here? The studio has made an anamorphic widescreen transfer. It took the full frame from the camera (as shown on the left), then horizontally squeezed it to fit the resolution of the DVD (the first picture). Then they set the 16:9 DAR flag which tells the player to unsqueeze the picture again.

Mathematically seen this works as follows: We have a 720x480 MPEG-2 stream. You multiply the vertical resolution with the aspect ratio (480*16/9=853) which gives you the horizontal resolution for a properly stretched movie. So the 720x480 stream will be stretched horizontally to 853x480 during playback. This allows to use the full vertical resolution of the DVD which retains maximum quality.

When you encode for a PC based format (like DivX) you'll have to first unqueeze the picture and then resize that to your desired resolution (this would correspond to a stream having a 1:1 DAR). Formats for standalone players like VCD and SVCD work differently, since they too have a DAR flag (4:3 or 16:9, where the latter won't work properly on all known players). So let's take a look at what has to be done here. The first step is to get the correct aspect ratio at the DVD resolution. In order to do that the picture has to be resized as can be seen below:

Compare this with the first and 2nd picture. You'll see that it has the same resolution as the first one but the same (correct) aspect ratio as the 2nd one. This process of taking a frame and resizing it to the DVD resolution while retaining the correct aspect ratio is called letterboxing. As you can see we use less of the available vertical resolution. This is ideal for 4:3 TVs since there the picture can be displayed as is, whereas when you have a 16:9 DVD the player will first have to perform this letterboxing transfer (which involves a slight, albeit unnoticable, quality loss). If you haven't properly set up your DVD player (4:3 TV = set the TV format to 4:3 or 4:3 letterboxed, 16:9 TV: set the TV format to 16:9) there will be no letterboxing and the picture will look squished as in the first screenshot.

What is important to notice here is that your playback device does letterboxing for a 16:9 disc when watching it on a 4:3 TV. Now when we're encoding such a stream for VCD and SVCD this process has to be done as well. Unfortunately the only encoder which supports to select a DAR of the input stream is TMPG (set source aspect ratio in the advanced settings, plus video arrange mode to full screen while preserving the aspect ratio). When you don't go thru TMPG you'll have to come up with another way of properly letterboxing. One way is VirtualDub where you resize to a smaller resolution than your target resolution and then add black bars (hence the resizing parameters in the CCE guide which look very strange at first sight).

There are also DVDs which have a DAR of 4:3 but contain widescreen picture. In fact, it should say letterboxed widescreen. These DVDs have been mastered as just explained. When you watch these DVDs on a 16:9 TV the picture will both have to be stretched horizontally and vertically whereas when having an anamorphic widescreen picture the picture will only have to be stretched horizontally, giving a larger vertical resolution to work with and therefore a better picture. In the early DVD days letterboxed widescreen transfers were quite popular, especially amongst US studios, whereas in Europe where 16:9 TVs are more popular, 16:9 has been something of a standard from the very beginning. Fortunately nowadays most DVDs are 16:9, and only some stubborn directors and cheap studios refuse to have a new 16:9 transfer created.

Now as you might know the resolution of both VCD and SVCD is not 4:3 even though the video streams have DAR 4:3. But SVCD is 480x480 and if you apply the same calculation rule as above (480*4/3= 640) the output resolution is 640x480 which corresponds to 4:3. Note that the video is stored horizontally squeezed on the disc, and will be unsqueezed during playback. So in fact, if you take the full frame from the (S)VCD it doesn't have the right aspect ratio, which is the exact same situation as with a DVD. Obiously the same rules appy for PAL SVCDs (576*4/3 = 768 so after strecthing you have a 768x576 picture) and VCDs.

An important thing to keep in mind here is that the Windows Media Player does not know about DARs usually (this might be different depending on what MPEG-2 filters you have installed) so it might happen that it plays your SVCD MPG as 480x480 and it looks squished again. But don't worry.. players with SVCD support will stretch it properly and giving you the correct aspect ratio.

Pan & Scan transfers

Now a look at a sad chapter in video history: Since many TVs today are still in 4:3 format many films are still being released as pan&scan copies, or in other words: they fill the screen. 16:9 TV owners hate 4:3 movies with all of their hearts, and after reading this I hope you'll never again buy such a crappy transfer since basically what's going on is crippling the video. Fortunately in the DVD age these kind of transfers are less and less common, despite DVD going mainstream and cutting into the rental biz.

Let's have a look at our source frame again.

What is being done in a pan&scan transfer is that a part from the source frame, having an aspect ratio of 1:1.33 or 4:3 is being cut out. This is symbolized by the red square in the picture. This "window" is not fixed but flexible. So when the actor moves to the right border the window can follow him up to a certain extent. This is the pan part of pan&scan. In certain cases the window might also zoom in on the frame, hence the scan part.

As you can already see in the screenshot pan&scan transfers lose a lot of of the source picture and ruin the

How to make your DVD-ROM region free

How to make your DVD-ROM region free

While not directly DVD ripping related this is certainly an issue that many people are interested in. In order to manufacture a DVD drive one has to obtain a license from the DVD CCA (Copy Control Association). The licensing terms state that every drive must support certain mechanisms, among others CSS (Content Scrambling System) and region code. The latter has only become mandatory for DVD-ROM drives starting from the first of January 2000. Since then every DVD-ROM must contain hardware region code which the user can change 5 times, then send back to the manufacturer which can reset that counter 4 times. Before that date most drives did not have any region protection and it was rather easy to circumvent the software DVD player based region code protection by the use of a well know tool: DVD Genie. That region free state was also called as RPC-1. A none codefree DVD-ROM is called RPC-2.

Pioneer and Matsushita (they make drives for the Creative PC DVD kits) were the first to introduce DVD-ROM hardware region code protection. But after a while nice people found a way to circumvent this region protection. They argued that they'd been cheated when they bought a protected drive since it's nowhere written down that the drive comes crippled and can't play all DVD discs, and they were quite right. In fact it would be really interested to see what would happen if somebody sued the DVD CCA for violating WTO trade agreements - after all region codes are there to restrict global trade.

The solution to get your drive region free is to load another firmware which disables the region code protection. While loading a new firmware isn't the most uncritical of tasks it can be performed without problems if you take all the necessary precautions. However you should be aware that in some cases the warranty might become void if you mess around with your drive on your own. But I've done dozens of mainboard BIOS updates, router firmware updates and now one DVD-ROM firmware update and I've never run into any serious trouble. But don't blame me if something goes wrong, I warned you.

Who should get a new firmware?

Basically whoever needs it. If you live in the USA or Canada (R1) then you most likely won't need the ability to play DVDs from other regions, unless you are interested in some of the rare titles that are out in Europe (R2) but not in the USA: For instance the Buffy discs, or the 6 full seasons of Friends :) If you live in another region than R1 and you don't speak English or prefer to watch the movies in another language (shame on you!!) then most likely you don't have to flash your firmware either since you get all the titles you want in your own region. But if you, like me, prefer to get movies sooner, with more extras, and of course in English all the time then you're in for an upgrade.

The process

First of all go to the mother of all firmware sites and check if there's an updated firmware for your type of DVD drive. If you're unsure about the type of the drive I suggest you run driveinfo. Should you run into an ASPI error you have to install forceaspi first. Unrar the forceaspi archive, then run instaspi.bat. The package comes with detailed instructions which I won't copy here but you should definitely check them out first. After installing forceaspi you have to reboot your machine. Driveinfo will show you the type of your DVD drive as well as the current firmware, and whether or not the drive is regionfree. If driveinfo tells you the drive has no region protection of course you don't have to do anything.

As you can see this nice 8x/24x notebook drive is a Toshiba SD-C2402 and you an find that there's several different firmwares for that drive. The drive currently has firmware version 1015 so you should download the patched firmware 1015, not any other. This step is really crucial.. double or triple check that you have the right firmware, otherwise your drive might not work after flashing anymore (and unfortunately there are flash programs that allow you to load the wrong firmware).

After you've downloaded the right firmware you'll have to create a dos/win9x bootdisk. For this operation I simply took the W98 setupdisk. You can also format a disk and check "copy system files" and you'll get a working bootdisk. Then copy the flasher program and the firmware to the disc as well. In the Toshiba case the flasher is called resetcnt.exe and the firmware file 1015f.hex. Then reboot your pc and change the boot drive order if necessary so that your pc boots from the disk drive. Of course you could also create a boot-CD or as I have a boot-zip disc but a floppy is the most obvious solution (unless you, as I do, don't have a floppy drive anymore).

Since every BIOS looks different I can't tell you where to change the boot order. Please refer to the manual of your mainboard / pc or call customer support. You shouldn't change anything else in the BIOS unless you really know what you're going to do.

After rebooting run the flasher. In our example you'd type "resetcnt 1015f.hex", then the program will search for a DVD-ROM and ask you if you want to flash. Type yes, wait until the program has finished, then reboot your pc.

Once back in Windows run driveinfo again.

If everything has gone as it's supposed to that's what you're supposed to get. Enjoy.. you've just beaten the CCA :)



Parting words

Before you buy a DVD-ROM make sure that there's RPC-1 firmware for it if you intend to watch DVDs that come from outside your region. And make sure you flash the drive with the right firmware.

Popular Posts