Skip to content

Commit

Permalink
fix: HW机型硬解码探测调整
Browse files Browse the repository at this point in the history
HW机型在自动模式检测为软解码,同预期不符
目前探测HW机型途径有DConfig、gpuinfo。但均
存在设备更新不能及时处理。调整为在影院判断
设备类型,并切换硬解码

Log: 修复部分解码问题
Bug: https://pms.uniontech.com/bug-view-249087.html
  • Loading branch information
rb-union committed Apr 3, 2024
1 parent 20e5f86 commit c40dfbc
Showing 1 changed file with 47 additions and 0 deletions.
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 @@ const PlayingMovieInfo &MpvProxy::playingMovieInfo()
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

0 comments on commit c40dfbc

Please sign in to comment.