Round default bitrates to the nearest megabit

This commit is contained in:
Cameron Gutman 2023-09-11 01:18:52 -05:00
parent 2f9c44103b
commit b968886594

View file

@ -309,17 +309,17 @@ int StreamingPreferences::getDefaultBitrate(int width, int height, int fps)
int pixels; int pixels;
int factor; int factor;
} resTable[] { } resTable[] {
{ 640 * 360, 10 }, { 640 * 360, 1 },
{ 854 * 480, 20 }, { 854 * 480, 2 },
{ 1280 * 720, 50 }, { 1280 * 720, 5 },
{ 1920 * 1080, 100 }, { 1920 * 1080, 10 },
{ 2560 * 1440, 200 }, { 2560 * 1440, 20 },
{ 3840 * 2160, 400 }, { 3840 * 2160, 40 },
{ -1, -1 }, { -1, -1 },
}; };
// Calculate the resolution factor by linear interpolation of the resolution table // Calculate the resolution factor by linear interpolation of the resolution table
int resolutionFactor; float resolutionFactor;
int pixels = width * height; int pixels = width * height;
for (int i = 0;; i++) { for (int i = 0;; i++) {
if (pixels == resTable[i].pixels) { if (pixels == resTable[i].pixels) {
@ -345,5 +345,5 @@ int StreamingPreferences::getDefaultBitrate(int width, int height, int fps)
} }
} }
return (int)(resolutionFactor * frameRateFactor) * 100; return qRound(resolutionFactor * frameRateFactor) * 1000;
} }