Video Bandwidth Calculator

AceInfinity

Emeritus, Contributor
Joined
Feb 21, 2012
Posts
1,728
Location
Canada
I wrote this quick little program in C to use for my own testing really, works pretty well though, might as well share the code here as simple as it is:

MlKOvWV.png


Code:
[NO-PARSE]#include <stdio.h>

#define BITS_PER_CLOCK_COEFFICIENT 10

struct pixels
{
   unsigned int horizontal;
   unsigned int vertical;
};

int main(void)
{
   struct pixels px = { 2200, 1125 };
   double refresh_rate = 60.0;
   unsigned int bits_per_pixel = 8;

   fputs("HPx - Horizontal total pixels\n"
         "VPx - Vertical total pixels\n"
         "R   - Refresh rate (Hz)\n"
         "BP  - Bits/pixel (8/10/12/16)\n\n"
         "Enter: <HPx> <VTPx> <R> <BP>\n\t>> ", stdout);
   if (scanf(" %u %u %lf %u", &px.horizontal, &px.vertical, &refresh_rate, &bits_per_pixel) != 4)
   {
      fputs("ERROR: invalid usage\n", stderr);
      return 1;
   }

   putchar('\n');

   double color_depth_factor;
   unsigned int total_px;
   double bandwidth;

   total_px = px.horizontal * px.vertical;
   printf("Total pixels per frame: %u\n", total_px);

   total_px = (unsigned int)(total_px * refresh_rate);
   printf("Approx total pixels per second: %u\n", total_px);

   color_depth_factor = 1.00 + ((8 - bits_per_pixel) / 2 * 0.20);
   printf("Color depth factor: %f\n", color_depth_factor);

   bandwidth = total_px * BITS_PER_CLOCK_COEFFICIENT;
   printf("Bandwidth per channel: %.2f Gbps ", bandwidth / 10e8);
   printf("(%f)\n", bandwidth / 10e8);bandwidth *= 3.0;
   printf("Total bandwidth: %.2f Gbps ", bandwidth / 10e8);
   printf("(%f)\n", bandwidth / 10e8);

   return 0;
}[/NO-PARSE]

NOTE: Don't expect proper results if you think you're calculating video bandwidth for 1080p @ 60Hz and you put in 1920x1080 as the total horizontal and vertical pixels because this calculation involves the TOTAL pixels, not the active pixels. There are a certain number of pixels out of view that aren't displayed and so the calculation is actually 2200 and 1125 as shown in the test values before the scanf() call. You need to understand these blanking regions in order to be able to use this properly.

Enjoy :thumbsup2:
 

Has Sysnative Forums helped you? Please consider donating to help us support the site!

Back
Top