View Full Version : How to calculate resolution applying an AR?
gizmo27
11th December 2009, 11:02
hi
I'm trying to do a resolution calutation : you can choose a custom aspect ratio and the program calculate the height starting from the width
ex : width is fixed to 720 => I enter custom AR=1.25 and it gives : height = 576
but for other values : AR = 1.825 for example : how does it make ?
in mod 1 no real matter but the problem comes in mod 16 : how to choose the nearest height mod 16 ?
Thanks in advance.
roozhou
11th December 2009, 11:45
round(width / (AR*16)) * 16
gizmo27
11th December 2009, 12:42
ok coooooooooooool ! thanks a lot
PS : can you explain the params please ?
gizmo27
11th December 2009, 20:10
I use API WINDOWS
I've just tried it but it doesn't work : are you sure it's the correct syntax ?
Adub
11th December 2009, 21:33
That's pretty much psuedo code.
What parameters do you need explained?
AR = aspect ratio
width = width
16 = 16
And round is a rounding function, such as round().
gizmo27
12th December 2009, 09:52
I've founded the cint() function : but neither the round() function nor the cint() one seem to work :(
Ghitulescu
12th December 2009, 16:39
Ther'ßs no 1.25:1 AR ;)
720:576 is indeed 5:4, but a real video is 4:3.
What you forget, like many others it seems, is an additional parameter called PAR.
For computer displays (and nowadays HDTV displays) PAR is 1:1, that means that your 720x576 is in reality 768x576 pixels.
Mounir
13th December 2009, 05:16
ntsc analog: 704x480
pal analog : 702x576
-------------------
ntsc dvd : 720x480
pal dvd : 720x576
-------------------
gizmo27
14th December 2009, 09:17
round(width / (AR*16)) * 16
it doesn't seem to work : it puts me a negative value : '-2147':eek:
Ghitulescu
14th December 2009, 09:40
it doesn't seem to work : it puts me a negative value : '-2147':eek:
You can't have negative numbers when you feed the formula with positive ones.
You probably did the calculation in insuficient bits, thus an overflow occured (the MSB is usually the sign bit in integer).
BTW: why do you need to use the Windows API for calculations every programming language (inclusive the embedded VB routines in MS Word) knows by definition?
gizmo27
14th December 2009, 09:55
hi
it works now : my problem cames from the fact of the same editbox name in my '#define' at the beginning
it works perfectly now.
Thanks a lot.
an3k
7th January 2010, 01:11
Ther'ßs no 1.25:1 AR ;)Err, 1.25:1 == 1,25 == 5:4 - there it is!
720:576 is indeed 5:4, but a real video is 4:3.Err, real video can be 1,333, 1,778, 2,350 and so on.
What you forget, like many others it seems, is an additional parameter called PAR.
For computer displays (and nowadays HDTV displays) PAR is 1:1, that means that your 720x576 is in reality 768x576 pixels.Err, if PAR is 1:1 a 720x576 video is in reality 720x576!
There are three different Aspect Ratios, SAR, PAR and DAR / StorageAR, PixelAR and DisplayAR.
StorageAR is the AR of the saved video. You always have this information. If you don't have it, you don't have a video :)
PixelAR is just a modifier.
DisplayAR is the AR you want the video to be shown in.
Example 1: You create a video with width 720 and height 576, thus SAR is 5:4 or 1,250. You want the video to be shown in 16:9 or 1,778. In most encoders you only can set PAR (the modifier). To get this information, divide DAR by SAR. (1,778 / 1,250 = 1,4224). In your encoder set PAR to 1,4224 and your 720x576 (5:4) video will be shown in 16:9
Example 2: You create a video with width 720 and height 576, thus SAR is 5:4 or 1,250. You want the video to be shown in 4:3 or 1,333 -> (1,333 / 1,250 = 1,0664). In your encoder set PAR to 1,0664 and your 720x576 (5:4) video video will be shown in 4:3
Example 3: You create a video with width 512 and height 384, thus SAR is 4:3 or 1,333. You want the video to be shown in 16:9 or 1,778 -> (1,778 / 1,333 = 1,3338334583645911477869467366842). In your encoder set PAR to 1,3338334583645911477869467366842 and your 512x384 (4:3) video video will be shown in 16:9
Example 4: You create a video with width 512 and height 288, thus SAR is 16:9 or 1,778. You want the video to be shown in 4:3 or 1,333 -> (1,333 / 1,778 = 0,74971878515185601799775028121485). In your encoder set PAR to 0,74971878515185601799775028121485 and your 512x288 (16:9) video video will be shown in 4:3
Howto get DAR -> SAR * PAR
Howto get PAR -> DAR / SAR
With HDTV its a bit different, there is no anamorph encoding, thus SAR is always 16:9, PAR always 1:1, thus DAR is always 16:9.
Keiyakusha
7th January 2010, 02:22
an3k
You calculations seems to be right but the names...
If by StorageAR you mean abbreviation "SAR", then this is wrong because SAR and PAR is synonyms. The thing you talking here has some other abbreviation. There was huge discussions about that on this forum but as I remember someone linked to some official papers and we all agreed with this.
stax76
7th January 2010, 02:45
@an3k
HD has often 1440x1080 PAR 4:3
an3k
7th January 2010, 03:11
an3k
You calculations seems to be right but the names...
If by StorageAR you mean abbreviation "SAR", then this is wrong because SAR and PAR is synonyms. The thing you talking here has some other abbreviation. There was huge discussions about that on this forum but as I remember someone linked to some official papers and we all agreed with this.
I got my knowledge from GSpot and there its SAR = StorageAR, PAR = PixelAR, DAR = DisplayAR.
SAR and PAR is not the same, i can prove that if you want. You can prove that yourself too :) Create a video with dimensions you like, lets say you used 640x480. Now encode this file with DivX. In the encoder settings you can set PAR. Set it so whatever.
After file is encoded, open it GSpot or other Tools like that and you'll see both, your SAR and PAR.
If my abbreviations are wrong, which are the correct ones? How come that the information GSpot gives are 100 % logical?
@an3k
HD has often 1440x1080 PAR 4:3I never saw that and i hope i never have to. :) I'm not sure but afaik HD doesn't specify 4:3.
Keiyakusha
7th January 2010, 03:20
an3k
I don't feel like I want to prove anything. Since this leads to confusion I thought it worth mentioning. Feel free to ignore that info if you want.
As for GSpot, Its a great tool but everybody can be wrong. No matter how logical numbers are, It doesn't mean that they are named correctly.
stax76
7th January 2010, 03:21
Anamorphic HD is common in DVB for instance.
an3k
7th January 2010, 03:26
an3k
I don't feel like I want to prove anything. Since this leads to confusion I thought it worth mentioning. Feel free to ignore that info if you want.
As for GSpot, Its a great tool but everybody can be wrong. No matter how logical numbers are, It doesn't mean that they are named correctly.
Well, just tell me what you think is correct. As long as you don't do that you're just another "guy who think he knows better" for me. No offense it really looks like that.
Anamorphic HD is common in DVB for instance.
Hmm, not here in Germany, DVB-C. All HD channels (Sky / Premiere/ PayTV) are 1920x1080 but i belief you. I know 1440x1080 but not as 4:3 :)
Keiyakusha
7th January 2010, 03:40
Well, just tell me what you think is correct. As long as you don't do that you're just another "guy who think he knows better" for me. No offense it really looks like that.
But I already said that. At some point abbreviation PAR was changed to SAR, so now we have SAR=PAR and a lot of confusion. And this is not what I think, this is just what I learned at this forum. Before that I was about the same opinion as you.
stax76
7th January 2010, 03:41
I've samples from the UK, you can read about it here: http://de.wikipedia.org/wiki/High_Definition_Television#Aufl.C3.B6sung
an3k
7th January 2010, 04:00
But I already said that. At some point abbreviation PAR was changed to SAR, so now we have SAR=PAR and a lot of confusion. And this is not what I think, this is just what I learned at this forum. Before that I was about the same opinion as you.
You are talking about HDTV. I'm talking about SDTV
EDIT: I think you misunderstood it. Most decoders as well as DVD-Players/LCD-TVs use SAR*PAR to display the video in correct AR. If SAR == PAR the device would calc 1,778 * 1,778 or 1,0 * 1,0 (or whatever PAR is set to) and this would result in a 3,161284:1 DAR - OR - a 1:1 DAR. Both are totally wrong as DAR!
I've samples from the UK, you can read about it here: http://de.wikipedia.org/wiki/High_Definition_Television#Aufl.C3.B6sungAaah, UK...they always had somehow weird resolutions and ARs :) (3:2? 6:7? dunno anymore but MTV Hits still use it often)
Wilbert
7th January 2010, 12:28
But I already said that. At some point abbreviation PAR was changed to SAR, so now we have SAR=PAR and a lot of confusion. And this is not what I think, this is just what I learned at this forum. Before that I was about the same opinion as you.
Yes, you are right. Looking at the specs of MPEG-2 and AVC SAR (= which stands for sample aspect ratio) is mentioned. It's the same as PAR (as used in the MPEG-1 and MPEG-4 part 2 specs).
StorageAR (as used in GSpot and perhaps other utilities) is not an official name. See http://avisynth.org/mediawiki/Aspect_ratios for more info.
stax76
7th January 2010, 14:09
In StaxRip I use PAR, DAR and SAR for Storage Aspect Ratio, not sure if this is the best possible solution, at least there is a tooltip telling Storage Aspect Ratio. Many users are rather clueless anyway and the ones that actually know what they are doing should be able to understand the confusing acronyms.
Click on the image to enlarge.
http://f.imagehost.org/t/0170/Untitled_4.jpg (http://f.imagehost.org/view/0170/Untitled_4)
an3k
7th January 2010, 21:37
Yes, you are right. Looking at the specs of MPEG-2 and AVC SAR (= which stands for sample aspect ratio) is mentioned. It's the same as PAR (as used in the MPEG-1 and MPEG-4 part 2 specs).
StorageAR (as used in GSpot and perhaps other utilities) is not an official name. See http://avisynth.org/mediawiki/Aspect_ratios for more info.
AviSynth wiki doesn't say that SAR == PAR. Additionally AviSynth wiki lists Storage Aspect Ratio as a possible acronym.
I read some posts linked from the wiki but didn't saw that SAR == PAR, only that there is no SAR and we all should call it PAR then.
Sorry but thats stupid since PAR has a totally different meaning than SAR has. You cannot call a Ford a BMW only because Ford had a insolvency. What i want to say is, SAR will always be SAR and PAR will always be PAR.
If a specification does not support anamorph video, you dont need PAR anymore (well, DAR is also useless then) but since 1440x1080 is anamoprh you still need SAR, PAR and DAR to calculate / display it correctly.
Whatever, lets stop that 20th discussion about that topic :) If you use the math GSpot shows (SAR*PAR=DAR) you always get correct results and you really shouldn't care about the idiots @ MPEG consortium. Guess these guys didn't understand the AspectRatio confusion before and just removed one required AR only to be able to understand it.
If MPEG consortium would say "green == red" would you follow?
Wilbert
7th January 2010, 23:49
AviSynth wiki doesn't say that SAR == PAR. Additionally AviSynth wiki lists Storage Aspect Ratio as a possible acronym.
I read some posts linked from the wiki but didn't saw that SAR == PAR, only that there is no SAR and we all should call it PAR then.
That's because i haven't corrected that part of the AviSynth wiki yet.
If MPEG consortium would say "green == red" would you follow?
What kind of stupid argument is that. Yes, i would follow the specifications, and not people own-made definitions (ie official above non-official definitions). I suggest people stick to that.
Guess these guys didn't understand the AspectRatio confusion before and just removed one required AR only to be able to understand it.
Guess you are making a foul out of yourself by making such a statement. Did you even read those specifications?
an3k
8th January 2010, 01:29
What kind of stupid argument is that. Yes, i would follow the specifications, and not people own-made definitions (ie official above non-official definitions). I suggest people stick to that.Its as stupid as the argument SAR == PAR.
So then you should stop saying that SAR == PAR because you were one of the guys asking if we should call SAR PAR from now on - or is there any ISO/ITU specification saying that SAR == PAR? Its a own-made definition...
Guess you are making a foul out of yourself by making such a statement. Did you even read those specifications?I read the threads linked form the AviSynth wiki.
1) There is no specification shown, its only a forum, nothing official.
2) I've bought a copy of each MPEG specification:
MPEG1
ISO/IEC 11172-2:1993
MPEG2
ISO/IEC 13818-2:2000
MPEG4
ISO/IEC 14496-2:2004
ISO/IEC 14496-10:2009
and each correction regarding these specifications. I'll read them.
Sounds like you think you exactly know the specification. If so, please tell me how the decoder knows in which aspect ratio the video has to be shown in if there is no SAR or PAR or if SAR == PAR.
Currently there is no comprehensive explanation of that, its all seperated or outdated.
EDIT: In the other Threads i read that some guys doesn't know from where they can get the MPEG4 specs:
MPEG1 -> http://www.iso.org/iso/search.htm?qt=11172&published=on
MPEG2 -> http://www.iso.org/iso/search.htm?qt=13818&published=on
MPEG4 -> http://www.iso.org/iso/search.htm?qt=14496&published=on
Wilbert
8th January 2010, 12:10
Its as stupid as the argument SAR == PAR.
So then you should stop saying that SAR == PAR because you were one of the guys asking if we should call SAR PAR from now on - or is there any ISO/ITU specification saying that SAR == PAR?
Yes, implicitly. Like i said MPEG-2 and AVC mention SAR. That same quantity is called PAR in the MPEG-1 and MPEG-4 part 2 specs. Sure they should have sticked to the same terminology and it is stupid that they didn't.
All i'm saying is if you use the term StorageAR, go ahead, but don't abbreviate it to SAR. Usually people take the latter to mean sample aspect ratio as that's the only official definition there is.
1) There is no specification shown, its only a forum, nothing official.
There is a section about specifications. It refers to forum-posts, which in turn refer to these specifications. I have them too (and you can get them for free, so i hope you didn't buy anything :)).
Sounds like you think you exactly know the specification. If so, please tell me how the decoder knows in which aspect ratio the video has to be shown in if there is no SAR or PAR or if SAR == PAR.
Currently there is no comprehensive explanation of that, its all seperated or outdated.
The MPEG-2 specs for example, says the following
aspect_ratio_information -- This is a four-bit integer defined in the Table 6-3.
aspect_ratio_information either specifies that the “sample aspect ratio” (SAR) of the reconstructed frame
is 1,0 (square samples) or alternatively it gives the “display aspect ratio” (DAR).
• If sequence_display_extension() is not present then it is intended that the entire reconstructed
frame is intended to be mapped to the entire active region of the display. The sample aspect ratio
may be calculated as follows:
SAR = DAR ´
horizontal_size
vertical_ size
NOTE - In this case horizontal_size and vertical_size are constrained by the SAR of the source and
the DAR selected.
ISO/IEC 13818-2: 1995 (E)
48 Recommendation ITU-T H.262 (1995 E)
• If sequence_display_extension() is present then the sample aspect ratio may be calculated as
follows:
SAR = DAR ´
display_ horizontal_ size
display_vertical _ size
Sharc
8th January 2010, 18:56
Wilbert is perfectly right.
It's just a pity that for describing the same (the width:height ratio of a picture element) 2 different acronyms have historically been used in standards which may inevitably have caused some confusion.
As for so many other 3-letter acronyms there are many meanings. In general it's always recommended to describe what one means => Population At Risk / Search And Rescue :)
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.