puNES icon indicating copy to clipboard operation
puNES copied to clipboard

NTSC software filters do not respect Pixel Aspect Ratio

Open ghost opened this issue 2 years ago • 3 comments

The title is fairly self-explanatory. Setting any of the 3 available NTSC software filters changes the aspect to a fixed aspect which doesn't match any of the pixel aspect ratios on the Screen tab. See image for reference: https://i.imgur.com/TkFjeBU.png

ghost avatar Apr 05 '22 23:04 ghost

This is also not a bug. Shay Green (Blargg, creator and developer of the filter) when he created it he made sure that the image had that aspect ratio to correctly simulate the nature of NTSC so, out of respect for his work, I let the the video output always kept the same aspect ratio.

punesemu avatar Apr 10 '22 09:04 punesemu

In a window that filter is 602x480 at 2x rendering. If it is correct aspect then the other aspect settings are wrong because none of their horizontal widths match that at all, and I listed them in the image linked above.

Honestly those ratios don't make any sense to me. My understanding is that the ratios listed are part of the upscale then downscaling of the image.

1:1 is internal 256x240 ratio so just plain square pixels. No analog television ever rendered the image this way. 5:4 is 256*(5/4) = 320, at 2x scale is 640x480. 640/480 = 4/3. 1 unit equals 160 at 2x scale, or 80 at 1x. This is the only correct display aspect. 8:7 is 256*(8/7) = 292.5, at 2x scale is 585x480, and is claimed as NTSC but the FCC is very specific about aspect being 4 units wide for every 3 units tall. The height of the visible image should be 75% of the width, and the width should be 1.333333333333333 the height.

NTSC specification states on page 32 of this official US government PDF: "(7) The aspect ratio of the transmitted television picture shall be 4 units horizontally to 3 units vertically."

Page 2 of the S170m-2004.pdf found here also states: "3.3 The aspect ratio of the active picture area shall be four units horizontally to three units vertically."

640 x 0.75 = 480 480 x 1.333333333333333 = 640

When I use 5:4 PAR in fullscreen on a 1600x900 monitor with all overscan visible (256x240) it fills exactly 1200x900 pixels when stretched. Break that down to 12/9 = 4/3 DAR or Display Aspect Ratio, and this is what they meant for analog television way back then. The monitor's pixels are perfectly square on this machine, so if I measure the final rendered image with a ruler it is consistent with 4:3, quote again "4 units horizontally to 3 units vertically." For example 8 inches wide by 6 inches tall, where the units equal 2 inches. This is why 5:4 PAR is the correct NTSC 4:3 DAR.

I understand pixels are not the same as "dots" on a television screen, pixel are generally squares and dots tend to be rectangular. But when you stretch 256x240 to 640x480 and render that on a computer monitor, it should measure the same as it would on an old TV when using a ruler or tape measure etc.

So I don't understand why there are 4 options when there should only be 3?

1:1 pixel perfect (square) 4:3 NTSC (America and Japan) and PAL (Europe)

Pixel Aspect Ratio (PAR)

Dot Aspect Ratio (DAR)

ghost avatar Apr 11 '22 11:04 ghost

In a window that filter is 602x480 at 2x rendering. If it is correct aspect then the other aspect settings are wrong because none of their horizontal widths match that at all, and I listed them in the image linked above.

https://github.com/Gumball2415/blargg_nes_ntsc :

The output is scaled to the proper horizontal width, leaving it up the
emulator to simply double the height. 
...
Blitting a 256x240 source image to a 602x240 pixel 16-bit RGB memory
buffer...

This is how the filters works and since I liked his filter and use his code, I left everything as he did. As for the rest, to be honest I don't remember all the reasoning and sources that led me to that decision. Several years have passed. I'll take a look at the pixel ratio again but I have to finish a couple of other things first.

punesemu avatar Apr 11 '22 16:04 punesemu