mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge pull request #3371
Colomban Wendling (1): fix(video): fix video resolution setting
This commit is contained in:
commit
ed886f8716
|
@ -162,8 +162,8 @@ void AVForm::updateVideoModes(int curIndex)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString devName = videoDeviceList[curIndex].first;
|
QString devName = videoDeviceList[curIndex].first;
|
||||||
videoModes = CameraDevice::getVideoModes(devName);
|
QVector<VideoMode> allVideoModes = CameraDevice::getVideoModes(devName);
|
||||||
std::sort(videoModes.begin(), videoModes.end(),
|
std::sort(allVideoModes.begin(), allVideoModes.end(),
|
||||||
[](const VideoMode& a, const VideoMode& b)
|
[](const VideoMode& a, const VideoMode& b)
|
||||||
{return a.width!=b.width ? a.width>b.width :
|
{return a.width!=b.width ? a.width>b.width :
|
||||||
a.height!=b.height ? a.height>b.height :
|
a.height!=b.height ? a.height>b.height :
|
||||||
|
@ -179,9 +179,9 @@ void AVForm::updateVideoModes(int curIndex)
|
||||||
std::map<int, int> bestModeInds;
|
std::map<int, int> bestModeInds;
|
||||||
|
|
||||||
qDebug("available Modes:");
|
qDebug("available Modes:");
|
||||||
for (int i=0; i<videoModes.size(); ++i)
|
for (int i=0; i<allVideoModes.size(); ++i)
|
||||||
{
|
{
|
||||||
VideoMode mode = videoModes[i];
|
VideoMode mode = allVideoModes[i];
|
||||||
qDebug("width: %d, height: %d, FPS: %f, pixel format: %s", mode.width, mode.height, mode.FPS, CameraDevice::getPixelFormatString(mode.pixel_format).toStdString().c_str());
|
qDebug("width: %d, height: %d, FPS: %f, pixel format: %s", mode.width, mode.height, mode.FPS, CameraDevice::getPixelFormatString(mode.pixel_format).toStdString().c_str());
|
||||||
|
|
||||||
// PS3-Cam protection, everything above 60fps makes no sense
|
// PS3-Cam protection, everything above 60fps makes no sense
|
||||||
|
@ -203,19 +203,19 @@ void AVForm::updateVideoModes(int curIndex)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int ind = bestModeInds[res];
|
int ind = bestModeInds[res];
|
||||||
if (mode.norm(idealMode) < videoModes[ind].norm(idealMode))
|
if (mode.norm(idealMode) < allVideoModes[ind].norm(idealMode))
|
||||||
{
|
{
|
||||||
bestModeInds[res] = i;
|
bestModeInds[res] = i;
|
||||||
}
|
}
|
||||||
else if (mode.norm(idealMode) == videoModes[ind].norm(idealMode))
|
else if (mode.norm(idealMode) == allVideoModes[ind].norm(idealMode))
|
||||||
{
|
{
|
||||||
// prefer higher FPS and "better" pixel formats
|
// prefer higher FPS and "better" pixel formats
|
||||||
if (mode.FPS > videoModes[ind].FPS)
|
if (mode.FPS > allVideoModes[ind].FPS)
|
||||||
{
|
{
|
||||||
bestModeInds[res] = i;
|
bestModeInds[res] = i;
|
||||||
}
|
}
|
||||||
else if (mode.FPS == videoModes[ind].FPS &&
|
else if (mode.FPS == allVideoModes[ind].FPS &&
|
||||||
CameraDevice::betterPixelFormat(mode.pixel_format, videoModes[ind].pixel_format))
|
CameraDevice::betterPixelFormat(mode.pixel_format, allVideoModes[ind].pixel_format))
|
||||||
{
|
{
|
||||||
bestModeInds[res] = i;
|
bestModeInds[res] = i;
|
||||||
}
|
}
|
||||||
|
@ -227,12 +227,14 @@ void AVForm::updateVideoModes(int curIndex)
|
||||||
QSize prefRes = Settings::getInstance().getCamVideoRes();
|
QSize prefRes = Settings::getInstance().getCamVideoRes();
|
||||||
unsigned short prefFPS = Settings::getInstance().getCamVideoFPS();
|
unsigned short prefFPS = Settings::getInstance().getCamVideoFPS();
|
||||||
// Iterate backwards to show higest resolution first.
|
// Iterate backwards to show higest resolution first.
|
||||||
|
videoModes.clear();
|
||||||
for(auto iter = bestModeInds.rbegin(); iter != bestModeInds.rend(); ++iter)
|
for(auto iter = bestModeInds.rbegin(); iter != bestModeInds.rend(); ++iter)
|
||||||
{
|
{
|
||||||
int i = iter->second;
|
int i = iter->second;
|
||||||
VideoMode mode = videoModes[i];
|
VideoMode mode = allVideoModes[i];
|
||||||
|
videoModes.append(mode);
|
||||||
if (mode.width==prefRes.width() && mode.height==prefRes.height() && mode.FPS == prefFPS && prefResIndex==-1)
|
if (mode.width==prefRes.width() && mode.height==prefRes.height() && mode.FPS == prefFPS && prefResIndex==-1)
|
||||||
prefResIndex = i;
|
prefResIndex = videoModes.size() - 1;
|
||||||
QString str;
|
QString str;
|
||||||
qDebug("width: %d, height: %d, FPS: %f, pixel format: %s\n", mode.width, mode.height, mode.FPS, CameraDevice::getPixelFormatString(mode.pixel_format).toStdString().c_str());
|
qDebug("width: %d, height: %d, FPS: %f, pixel format: %s\n", mode.width, mode.height, mode.FPS, CameraDevice::getPixelFormatString(mode.pixel_format).toStdString().c_str());
|
||||||
if (mode.height && mode.width)
|
if (mode.height && mode.width)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user