Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: HW机型硬解码探测调整 #439

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/backends/mpv/mpv_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,55 @@
return m_movieInfo;
}

/**
* @return 返回当前设备是否为特殊的HW设备类型,用于进行软/硬解码支持的判断
*/
bool isSpecialHWHardware()
{
enum HWDevice { Unknown, IsHWDev, NotHWDev };
static HWDevice s_DevType = Unknown;

if (Unknown == s_DevType) {
s_DevType = NotHWDev;

QProcess process;
process.start("dmidecode", {"-s", "system-product-name"});
process.waitForFinished(100);
QString info = process.readAllStandardOutput();
if (info.isEmpty()) {
return false;
}

QStringList specilDev{"KLVV", "KLVU", "PGUV", "PGUW", "PGUX", "L540", "W585"};
for (const QString &dev : specilDev) {
if (info.contains(dev)) {
s_DevType = IsHWDev;
break;
}
}

if (NotHWDev == s_DevType) {
// dmidecode | grep -i “String 4”中的值来区分主板类型,PWC30表示PanguW(也就是W525)
process.start("bash", {"-c", "dmidecode | grep -i \"String 4\""});
process.waitForFinished(100);
info = process.readAll();
if (info.contains("PWC30")) {
s_DevType = IsHWDev;
}
}

qInfo() << QString("Detect HW device, current type is: %1").arg((IsHWDev == s_DevType) ? "true" : "false");
}

return bool(s_DevType == IsHWDev);
}

bool MpvProxy::isSurportHardWareDecode(const QString sDecodeName, const int &nVideoWidth, const int &nVideoHeight)

Check warning on line 765 in src/backends/mpv/mpv_proxy.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Parameter 'sDecodeName' is passed by value. It could be passed as a const reference which is usually faster and recommended in C++.
{
if (utils::check_wayland_env() && isSpecialHWHardware()) {
return true;
}

bool isHardWare = true;//未安装探测工具默认支持硬解
decoder_profile decoderValue = decoder_profile::UN_KNOW; //初始化支持解码值
decoderValue = (decoder_profile)getDecodeProbeValue(sDecodeName); //根据视频格式获取解码值
Expand Down
Loading