Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(avform): Changed "best modes" search algorithm.
Browse files Browse the repository at this point in the history
Mentioned in #3535 by @BiTOk
  • Loading branch information
Diadlo committed Jul 24, 2016
1 parent 1c8a7e4 commit 6e1ef70
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/widget/form/settings/avform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void AVForm::selectBestModes(QVector<VideoMode> &allVideoModes)
// Identify the best resolutions available for the supposed XXXXp resolutions.
std::map<int, VideoMode> idealModes;
idealModes[120] = VideoMode(160, 120);
idealModes[240] = VideoMode(460, 240);
idealModes[240] = VideoMode(430, 240);
idealModes[360] = VideoMode(640, 360);
idealModes[480] = VideoMode(854, 480);
idealModes[720] = VideoMode(1280, 720);
Expand Down Expand Up @@ -247,7 +247,10 @@ void AVForm::selectBestModes(QVector<VideoMode> &allVideoModes)
for (auto it = bestModeInds.rbegin(); it != bestModeInds.rend(); ++it)
{
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())
newVideoModes.push_back(mode);
}
Expand Down Expand Up @@ -425,6 +428,11 @@ void AVForm::getVideoDevices()
updateVideoModes(videoDevIndex);
}

int AVForm::getModeSize(VideoMode mode)
{
return qRound(mode.height / 120.0) ;
}

void AVForm::getAudioInDevices()
{
QStringList deviceNames;
Expand Down
1 change: 1 addition & 0 deletions src/widget/form/settings/avform.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class AVForm : public GenericForm, private Ui::AVForm
void getAudioOutDevices();
void getVideoDevices();

static int getModeSize(VideoMode mode);
void selectBestModes(QVector<VideoMode> &allVideoModes);
void fillCameraModesComboBox();
void fillScreenModesComboBox();
Expand Down

0 comments on commit 6e1ef70

Please sign in to comment.