# How to calculate Pixel Aspect Ratios??

1. Hello!

I'm trying to understand all this SAR, PAR, DAR stuff and I'm having problem with PAR, what I've got so far?
640 x 480, max common divisor of 640 and 480 is 160, so 640/160 = 4 and 480/160 = 3 or a DAR of 4:3
DAR = 4:3
SAR = 1,33333333333333
PAR = DAR / SAR
PAR = 4:3 / 1,33333333333333
PAR = 0,1265625

This is very different from PAR 10:11 we see over the internet, what I need to do to find a correspondent PAR for a 496 x 384 footage for example?
I know that it has a DAR of 31:24 and PAR 1,01290322580645.
Most of this calculations I'm doing with a calc spreadsheet from libreoffice so I can punch in the numbers and get the values I need.

http://web.archive.org/web/20111228005412/http://lipas.uwasa.fi/~f76998/video/conversion/

Thank you!
2. In your example do not understand your result. 4:3/1,3333333333333 and PAR=0,1265625 shouldn't it be in this case 1? PAR 0,1...... imagine it, it is almost rectangle that has sides in ratio 1 unit to 10 units. In your case it should be (i can be wrong as usual) (4:3)/1.3333333333333333 = 1 Or am wrong?

Bernix
3. That I got from PAR = DAR / SAR
https://en.wikipedia.org/wiki/Pixel_aspect_ratio

That result was done by the spreadsheet, sorry to me this is very confusing, how a 480i has a DAR of 10:11?

I know it has to do with a sample rate of 13.2 Mhz (Rec. 601 / ITU-R BT.601), but still I don't undertand.

Thank you.
4. "Par = 4:3 / 1,33333333333333"

par = 4/3 / 1,33333333333333
par = 1,33333333333333 / 1,33333333333333
par = 1.0
5. Hi, not expert on PAR, but I suggesting to you use brackets. So you get different results. So for example (4/3) instead of 4/3. Some offices software are using different methods in priority, and it can be modified in preference. But in math of course is it fixed rule what operation comes first. Brackets helps a lot in this case.

Bernix
6. Hello jagabo!
Thank you for clarify that.

But how we get to 10:11??
Or better yet, how I calculate that to a DAR 31:24?

Thank you!
7. Originally Posted by amaipaipai
how a 480i has a DAR of 10:11?
In a rec.601 4:3 NTSC video cap the 4:3 image is in an 704x480 frame:

Code:
```PAR = DAR / FAR (Display aspect ratio / frame size aspect ratio)
PAR = 4:3 / 704:480
PAR = (4/3) / (704/480)
PAR = 1.333333... / 1.466666...
PAR  = 0.9090909...
PAR = 10/11
PAR = 10:11```
And yes, the PAR is a result of the sampling frequency when the analog video is digitized. Note that more modern documents use the term SAR (sample aspect ratio) rather than PAR (pixel aspect ratio).
8. Thank you Bernix!
9. [QUOTE=jagabo;2511023]
Originally Posted by amaipaipai
how a 480i has a DAR of 10:11?
In a rec.601 4:3 NTSC video cap the 4:3 image is in an 704x480 frame:
PAR = 0.9090909...

I've got the same result by doing:

[Attachment 44602 - Click to enlarge]

12+(3/11) = 12,2727272727273
13+(1/2) = 13,5
12,2727272727273 / 13,5 = 0,909090909090909

Sorry.
I still don't know how 0,909090909090909 become 10:11.

Thank you.
10. Originally Posted by jagabo
Originally Posted by amaipaipai
how a 480i has a DAR of 10:11?
In a rec.601 4:3 NTSC video cap the 4:3 image is in an 704x480 frame:

Code:
```PAR = DAR / FAR (Display aspect ratio / frame size aspect ratio)
PAR = 4:3 / 704:480
PAR = (4/3) / (704/480)
PAR = 1.333333... / 1.466666...
PAR  = 0.9090909...
PAR = 10/11
PAR = 10:11```
And yes, the PAR is a result of the sampling frequency when the analog video is digitized. Note that more modern documents use the term SAR (sample aspect ratio) rather than PAR (pixel aspect ratio).
Hello @jagabo
Got it!

A fraction of 0,909090909090909 is 10/11 or 10:11

Thank you!
11. 0,90909090909090 is equal to 10/11 and also 12,2727272727/13,5 but 10/11 is better to understand than 12,1212periodically/13,5. So ratio of pixel is 10x11
If you multiply 0,9090909090909009periodicaly with 11 you get 10

Bernix
12. Originally Posted by amaipaipai
I still don't know how 0,909090909090909 become 10:11.
Starting with:

Code:
```PAR = (4/3) / (704/480)
PAR = (4 / 3) * (480 / 704)
PAR = (4 * 480) / ( 3 * 704)

given that:
4 = 2 * 2
480 = 2 * 2 * 2 * 2  * 2 * 3 * 5
3 = 3
704 = 2 * 2 * 2 * 2 * 2 * 2 * 11

PAR = (2 * 2  * 2 * 2 * 2 * 2  * 2 * 3 * 5) / (3 * 2 * 2 * 2 * 2 * 2 * 2 * 11)
PAR = (2 * 5) / (11) # discarding common factors
PAR =  10 / 11
PAR = 10:11```
13. Originally Posted by Bernix
0,90909090909090 is equal to 10/11 and also 12,2727272727/13,5 but 10/11 is better to understand than 12,1212periodically/13,5. So ratio of pixel is 10x11
If you multiply 0,9090909090909009periodicaly with 11 you get 10

Bernix
Thank you!

Originally Posted by jagabo
Originally Posted by amaipaipai
I still don't know how 0,909090909090909 become 10:11.
Starting with:

Code:
```PAR = (4/3) / (704/480)
PAR = (4 / 3) * (480 / 704)
PAR = (4 * 480) / ( 3 * 704)

given that:
4 = 2 * 2
480 = 2 * 2 * 2 * 2  * 2 * 3 * 5
3 = 3
704 = 2 * 2 * 2 * 2 * 2 * 2 * 11

PAR = (2 * 2  * 2 * 2 * 2 * 2  * 2 * 3 * 5) / (3 * 2 * 2 * 2 * 2 * 2 * 2 * 11)
PAR = (2 * 5) / (11) # discarding common factors
PAR =  10 / 11
PAR = 10:11```
Much better now!

Thank you very much!
14. Originally Posted by amaipaipai
Hello!

I'm trying to understand all this SAR, PAR, DAR stuff and I'm having problem with PAR, what I've got so far?
640 x 480, max common divisor of 640 and 480 is 160, so 640/160 = 4 and 480/160 = 3 or a DAR of 4:3
DAR = 4:3
SAR = 1,33333333333333
PAR = DAR / SAR
PAR = 4:3 / 1,33333333333333
PAR = 0,1265625

This is very different from PAR 10:11 we see over the internet, what I need to do to find a correspondent PAR for a 496 x 384 footage for example?
I know that it has a DAR of 31:24 and PAR 1,01290322580645.
Most of this calculations I'm doing with a calc spreadsheet from libreoffice so I can punch in the numbers and get the values I need.

http://web.archive.org/web/20111228005412/http://lipas.uwasa.fi/~f76998/video/conversion/

Thank you!
You can think of the pixel aspect ratio as being the difference between the physical width of the picture, and the width it'd be stretched or squished to in order to display with the correct aspect ratio.

For a 720x576 source (as an example) with a display aspect ratio of 16:9, the correct display width can be calculated based on the height.
576*16/9 = 1024, so it'd display as 1024x576 in "square pixel" dimensions.
The pixel aspect ratio would therefore be 1024/720 = 1.422222

DAR/SAR = PAR would give you the same result as the storage aspect ratio is 720/576, which is 1.25
and
(16/9) / (720/576) = (1.777777 / 1.25) = 1.422222

If the storage dimensions and the display dimensions are the same, the pixel aspect ratio must be 1.0

Your 496x384 example doesn't make sense because to display as 31:24.....
384*31/24 = 496
and
496/496 = 1.0
The display aspect ratio and the pixel aspect ratio you quoted can't both be correct.

There's a list of PARs here: https://forum.doom9.org/showthread.php?p=1058927#post1058927
The "MPEG-4 PARs" are the ones you'd use assuming 704x480 (NTSC) or 704x576 (PAL) should resize to 4:3 or 16:9. If you base the calculation on 720x480 or 720x576, the resulting display aspect ratio will be a little wider than 4:3 or 16:9.
The "Generic PARs" are the ones you'd use assuming the whole 720 width is resized to 4:3 or 16:9.
15. On the subject of converting decimals to fractions, if you're an Avisynth user here's a small function for converting them. The result displays as a subtitle over any opened video. For example, to convert 1.777778 to a fraction, you'd import/load the function below and then add the following to a script:

DecToFrac(1.777778)

# Converts decimal numbers to fractions.
# The result displays as a subtitle in the centre of the video.
# The Limit argument specifies the allowable error as 1/Limit, so Limit=100 would be 1/100 or 0.01 or 1%.
# Limit=50000 by default which should make it accurate to roughly 6 decimal places, and 1.777777 or 1.777778 would therefore both convert to 16:9.
# To disable the Limit argument, set Limit=0
# http://avisynth.nl/index.php/Internal_functions#Continued_Numerator.2C_Denominator
# Examples:
# DecToFrac(1.78) will result in 89/50
# DecToFrac(1.777778) will result in 16/9
# DecToFrac(1.777778, 0) will result in 634601/356963

function DecToFrac(clip c, float "Dec", int "Limit") {
Limit = default(Limit, 50000)
Limited = (Limit == 0) ? undefined : Limit
Numerator = string(ContinuedNumerator(Dec, limit=Limited))
Denominator = string(ContinuedDenominator(Dec, limit=Limited))
return c.subtitle(Numerator + """/""" + Denominator, size=30, align=5, text_color=color_white) }
16. Thank you hello_hello!
A lot of information.

That 496x384 @ 57.524160 is the default video output of the Sega Model 1 arcade machine.
http://www.system16.com/hardware.php?id=712

There is a arcade machine named Virtua Racing, that machine uses a non standard wide screen CRT monitor. The hardware output square pixels in a resolution of 496 x 384.

There is a control that change the screen from 4:3 to 16:9 that doesn't change the PAR, instead it tell the monitor to stretch still keeping the square pixels, this image was done by guessing by the way.

I want to change PAR, we know that:

640 / (10/11) = 704, or a 704x480 frame

That's why I want to know my PAR so I can change PAR, upscale it, etc.
17. Originally Posted by hello_hello
On the subject of converting decimals to fractions, if you're an Avisynth user here's a small function for converting them. The result displays as a subtitle over any opened video. For example, to convert 1.777778 to a fraction, you'd import/load the function below and then add the following to a script:

DecToFrac(1.777778)

# Converts decimal numbers to fractions.
# The result displays as a subtitle in the centre of the video.
# The Limit argument specifies the allowable error as 1/Limit, so Limit=100 would be 1/100 or 0.01 or 1%.
# Limit=50000 by default which should make it accurate to roughly 6 decimal places, and 1.777777 or 1.777778 would therefore both convert to 16:9.
# To disable the Limit argument, set Limit=0
# http://avisynth.nl/index.php/Internal_functions#Continued_Numerator.2C_Denominator
# Examples:
# DecToFrac(1.78) will result in 89/50
# DecToFrac(1.777778) will result in 16/9
# DecToFrac(1.777778, 0) will result in 634601/356963

function DecToFrac(clip c, float "Dec", int "Limit") {
Limit = default(Limit, 50000)
Limited = (Limit == 0) ? undefined : Limit
Numerator = string(ContinuedNumerator(Dec, limit=Limited))
Denominator = string(ContinuedDenominator(Dec, limit=Limited))
return c.subtitle(Numerator + """/""" + Denominator, size=30, align=5, text_color=color_white) }
Very nice!!!!!!!
Thank you!
18. I'm attaching the LibreOffice calc spreadsheet with some calculations about DAR, SAR, PAR and all this thing about ratios, is free and open source office suite, I rather prefer this over Microsoft Office. The file is not protected so anyone can improve it and people like myself can learn from it.

Thank you for helping me!
19. Originally Posted by amaipaipai
That's why I want to know my PAR so I can change PAR, upscale it, etc.
If I understand you correctly you want the 496x384 image to display as 16:9?

384*16/9 = 682.6666667

682.6666667 / 496 = 1.3763

That's irrelevant though if you change the storage aspect ratio when you resize, as due to the PAR=DAR/SAR formula, for DAR to be a constant, when the storage aspect ratio changes the PAR must change accordingly. You really only need to know the correct display aspect ratio in order to calculate the new PAR after resizing (unless you need to know the original PAR in order to determine the correct DAR).

Assuming your image is supposed to display as 16:9, you could resize to 1280x720 and the new pixel aspect ratio would be 1.0 as 1280/720=16/9.
(Edit to fix mistake here): If you resized to 704x480 the new PAR would be 40/33 in order to display as 16:9 (using the mpeg4 PARs from the list I linked to). A PAR of 10/11 for 704x480 would give you a display aspect ratio of 4:3.
If you resized to 960x720 the PAR would need to be 4:3 in order to display as 16:9 (1280x720). 1280/960=1.333334 or 4:3.
You could resize to 600x540 if you wanted to and set a new PAR of 1.11111 for a DAR of 16:9.
540*16/9 = 960
960/600 = 1.11111

Unless you particularly need to author a DVD-Video disc, why not just resize to the 16:9 dimensions of your choice (and therefore "square pixels" or a PAR of 1.0)? That's assuming it's supposed to display as 16:9 and not as 4:3.
20. Originally Posted by hello_hello
If I understand you correctly you want the 496x384 image to display as 16:9?
In reality I'm trying to understand what is the process that the machine is doing to display a wide image, because the output from the board is 496x384, then it send over to the monitor, maybe a standard VGA/RGB 640x480 signal.
I've found the @jagabo script and it does a very decent job!

Code:
```function PadHeight(clip image, int width, int height, int AR_WIDTH, int AR_HEIGHT)
{
# the frame is wider than we want, pad the top and bottom

# calculate what final height we need
nh = width * AR_HEIGHT / AR_WIDTH

# calculate the top and bottom borders
tb = (nh - height) / 2
bb = nh - height - tb
}

function PadWidth(clip image, int width, int height, int AR_WIDTH, int AR_HEIGHT)
{
# the frame is taller than we want, pad the left and right

# calculate the final width we need
nw = height * AR_WIDTH / AR_HEIGHT

# calculate the left and right borders
lb = (nw - width) / 2
rb = nw - width - lb
}

ImageSource("J:\0005.png")
#Import("mame.avs")

# if you want 16:9 change these values to 16 and 9
AR_WIDTH = 16
AR_HEIGHT = 9

width = last.width
height = last.height

((width * AR_HEIGHT) > (height * AR_WIDTH)) \
? PadHeight(last, width, height, AR_WIDTH, AR_HEIGHT)\
: PadWidth(last, width, height, AR_WIDTH, AR_HEIGHT)
# Set new target
tw=1280
th=720
PointResize(tw, th)```

[Attachment 44607 - Click to enlarge]

But looking at the original flyer, I can get a near perfect reproduction.

[Attachment 44608 - Click to enlarge]

[Attachment 44609 - Click to enlarge]

Still, can't get he correct wide aspect, to make jagabo correct proportions in wide without borders.
21. I don't get it. If you want 16:9 just resize to a 16:9 frame size.

Code:
```ImageSource("0005.png")
ConvertToRGB32()
HQ4x()
BilinearResize(1280,720)```
22. That will do @jagabo.
Thanks

Statistics