Phoronix Forums  

Go Back   Phoronix Forums > Linux Graphics / X.Org Drivers > Intel Linux

Intel Linux Technical support and discussion of the open-source xf86-video-intel driver and other Intel Linux software projects.

Reply
 
Thread Tools Display Modes
  #1  
Old 02-22-2008, 01:08 PM
duby229 duby229 is offline
Senior Member
 
Join Date: Nov 2007
Posts: 341
Default Solving a simple equation for resolution?

Hey guys. I need a little bit of your brain power becouse in this case my own is inadequate. I've never really been any good at math, and I really could use some help... Here is the problem, I'm trying to figure out how to solve a problem where everything is constant except the resolution... Maybe this will help better...

BPP=0.25
Bitrate=1000000
Refresh=24*1000/1001
Source Width=704
Source Height=256

Now in order to solve for BPP we have to figure out what the aspect ratio is, and that is simply dividing the width by height. Then we divide the bitrate by the refresh rate by the aspect ratio. The solution is the bits per pixel.

Aspect=Source Width/Source Height

BPP=Bitrate/Refresh/Aspect

Or if we want to solve for the bitrate we can multiply the BPP by the width by the height by the refresh rate. Seems simple enough.

Bitrate=BPP*Source Width*Source Height*Refresh.

...............................

Now where I'm stuck is, assuming that Bitrate, BPP, Refresh, and Aspect are fixed values, how would I solve for the width and height? This has to be done while maintaining the aspect ratio of the original source. I havent been able to figure out how to do it. Anybody have any suggestions?

Last edited by duby229; 02-22-2008 at 01:41 PM.
Reply With Quote
  #2  
Old 02-22-2008, 02:07 PM
StringCheesian StringCheesian is offline
Senior Member
 
Join Date: Aug 2006
Posts: 128
Default

Assuming BPP stands for bits per pixel: No, Bitrate/Refresh/Aspect does not equal BPP. Bitrate divided by Refresh is bits per frame. Divide that by pixels per frame (width * height) and then you've got BPP.

Bitrate / Refresh rate is bits per frame, divide that by BPP and you've got pixels per frame. width * height also gives you pixels per frame. So:
Width * Height = Bitrate / Refresh / BPP
Multiply both sides by Aspect
Aspect * Width * Height = Aspect * (Bitrate / Refresh / BPP)
Aspect = Width / Height, so substitute:
Width / Height * Width * Height = Aspect * (Bitrate / Refresh / BPP)

Width * Width = Aspect * (Bitrate / Refresh / BPP)

Width = SquareRoot(Aspect * (Bitrate / Refresh / BPP))
Height = Width / Aspect

Last edited by StringCheesian; 02-22-2008 at 02:23 PM.
Reply With Quote
  #3  
Old 02-22-2008, 02:50 PM
duby229 duby229 is offline
Senior Member
 
Join Date: Nov 2007
Posts: 341
Default

Quote:
Originally Posted by StringCheesian View Post
Assuming BPP stands for bits per pixel: No, Bitrate/Refresh/Aspect does not equal BPP. Bitrate divided by Refresh is bits per frame. Divide that by pixels per frame (width * height) and then you've got BPP.

Bitrate / Refresh rate is bits per frame, divide that by BPP and you've got pixels per frame. width * height also gives you pixels per frame. So:
Width * Height = Bitrate / Refresh / BPP
Multiply both sides by Aspect
Aspect * Width * Height = Aspect * (Bitrate / Refresh / BPP)
Aspect = Width / Height, so substitute:
Width / Height * Width * Height = Aspect * (Bitrate / Refresh / BPP)

Width * Width = Aspect * (Bitrate / Refresh / BPP)

Width = SquareRoot(Aspect * (Bitrate / Refresh / BPP))
Height = Width / Aspect

Exactly what I was looking for. Thank you so much. Like I said, I'm not much for math, and I would have never figured that out on my own.

Let me see if I can understand what you've said....

Bits Per Pixel is Bitrate/Refresh/Width*Height, however substituting names with the values I supplioed above I get this result.

1000000/24*1000/1001/704*256=15136.378

That doesnt seem correct for bits per pixel. If I substitute width*height with aspect=width/height, I get this..

1000000/24*1000/1001/704/256=0.230

That seems about right to me.I'm not sure whats going on. I think I have it right, but based on what you've said I'm not sure anymore.

Although in the end your width calculation works perfectly. Thank you so much. I would have been scratching my head all day, and would not have figured it out.
Reply With Quote
  #4  
Old 02-22-2008, 07:41 PM
StringCheesian StringCheesian is offline
Senior Member
 
Join Date: Aug 2006
Posts: 128
Default

Bits Per Pixel = 0.25 makes absolutely no sense.

For example: the number 42 has 2 digits. The number 5 has 1 digit. What number has 0.25 digits?

A normal Bits Per Pixel is 8, 16, or 32. Sometimes it can be 1, 2, 4, or 24. It is never a fraction.

Maybe 0.25 is actually the dot pitch of a CRT monitor or something like that?

EDIT: Oh I see, it's a compressed video stream. Ok, in that case maybe you could have a compression ratio of 4 pixels to 1 bit or 0.25 bits per pixel.

Last edited by StringCheesian; 02-22-2008 at 07:46 PM.
Reply With Quote
  #5  
Old 02-22-2008, 07:50 PM
StringCheesian StringCheesian is offline
Senior Member
 
Join Date: Aug 2006
Posts: 128
Default

Quote:
Originally Posted by duby229 View Post
1000000/24*1000/1001/704*256=15136.378

That doesnt seem correct for bits per pixel. If I substitute width*height with aspect=width/height, I get this..

1000000/24*1000/1001/704/256=0.230

That seems about right to me.I'm not sure whats going on. I think I have it right, but based on what you've said I'm not sure anymore.
Order of operations. This:
1000000/24*1000/1001/704*256
is different from this:
1000000/(24*1000/1001)/(704*256)

Note the parentheses- they can help you keep the order of operations straight when you substitute.
Reply With Quote
  #6  
Old 02-22-2008, 08:29 PM
duby229 duby229 is offline
Senior Member
 
Join Date: Nov 2007
Posts: 341
Default

Quote:
Originally Posted by StringCheesian View Post
Order of operations. This:
1000000/24*1000/1001/704*256
is different from this:
1000000/(24*1000/1001)/(704*256)

Note the parentheses- they can help you keep the order of operations straight when you substitute.
Ok, I understand. So using the brackets more or less means "do this first" then do the operations outside the brackets last. Ok, I see. Thank you for your patience.
Reply With Quote
  #7  
Old 02-22-2008, 08:35 PM
duby229 duby229 is offline
Senior Member
 
Join Date: Nov 2007
Posts: 341
Default

Quote:
Originally Posted by StringCheesian View Post
Bits Per Pixel = 0.25 makes absolutely no sense.

For example: the number 42 has 2 digits. The number 5 has 1 digit. What number has 0.25 digits?

A normal Bits Per Pixel is 8, 16, or 32. Sometimes it can be 1, 2, 4, or 24. It is never a fraction.

Maybe 0.25 is actually the dot pitch of a CRT monitor or something like that?

EDIT: Oh I see, it's a compressed video stream. Ok, in that case maybe you could have a compression ratio of 4 pixels to 1 bit or 0.25 bits per pixel.
Actually the codec I'm using is x264, so yes it's compressed. I'm not sure how the compression algorithms work though, just that they do it in a way that compares blocks of colors rather then each pixel individually. They call it a quantizer matrix. Chances are likely that multiple pixels side by side will have very similar colors, and what x264 does it it allocates blocks and assigns these blocks the same color in order to save bits. That is why low quality encodes you can actually see blocks in the video. Also instead of using a 24bit RGB value for the color they use a 12bit YUY value that comes pretty dang close to 24bit RGB quality.

How exactly it is done, and the details involved I really dont know.

Last edited by duby229; 02-22-2008 at 08:56 PM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 10:40 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2009 by Phoronix Media.