1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix(avform): Changed "best modes" search algorithm.

Mentioned in #3535 by @BiTOk
This commit is contained in:
Diadlo 2016-07-24 00:48:00 +03:00
parent 1c8a7e49c1
commit 6e1ef70651
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
2 changed files with 11 additions and 2 deletions

View File

@ -187,7 +187,7 @@ void AVForm::selectBestModes(QVector<VideoMode> &allVideoModes)
// Identify the best resolutions available for the supposed XXXXp resolutions. // Identify the best resolutions available for the supposed XXXXp resolutions.
std::map<int, VideoMode> idealModes; std::map<int, VideoMode> idealModes;
idealModes[120] = VideoMode(160, 120); idealModes[120] = VideoMode(160, 120);
idealModes[240] = VideoMode(460, 240); idealModes[240] = VideoMode(430, 240);
idealModes[360] = VideoMode(640, 360); idealModes[360] = VideoMode(640, 360);
idealModes[480] = VideoMode(854, 480); idealModes[480] = VideoMode(854, 480);
idealModes[720] = VideoMode(1280, 720); idealModes[720] = VideoMode(1280, 720);
@ -247,7 +247,10 @@ void AVForm::selectBestModes(QVector<VideoMode> &allVideoModes)
for (auto it = bestModeInds.rbegin(); it != bestModeInds.rend(); ++it) for (auto it = bestModeInds.rbegin(); it != bestModeInds.rend(); ++it)
{ {
VideoMode mode = allVideoModes[it->second]; VideoMode mode = allVideoModes[it->second];
auto result = std::find(newVideoModes.begin(), newVideoModes.end(), mode); int size = getModeSize(mode);
auto result = std::find_if(newVideoModes.cbegin(), newVideoModes.cend(),
[size](VideoMode mode) { return getModeSize(mode) == size; });
if (result == newVideoModes.end()) if (result == newVideoModes.end())
newVideoModes.push_back(mode); newVideoModes.push_back(mode);
} }
@ -425,6 +428,11 @@ void AVForm::getVideoDevices()
updateVideoModes(videoDevIndex); updateVideoModes(videoDevIndex);
} }
int AVForm::getModeSize(VideoMode mode)
{
return qRound(mode.height / 120.0) ;
}
void AVForm::getAudioInDevices() void AVForm::getAudioInDevices()
{ {
QStringList deviceNames; QStringList deviceNames;

View File

@ -45,6 +45,7 @@ private:
void getAudioOutDevices(); void getAudioOutDevices();
void getVideoDevices(); void getVideoDevices();
static int getModeSize(VideoMode mode);
void selectBestModes(QVector<VideoMode> &allVideoModes); void selectBestModes(QVector<VideoMode> &allVideoModes);
void fillCameraModesComboBox(); void fillCameraModesComboBox();
void fillScreenModesComboBox(); void fillScreenModesComboBox();