Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions src/assets/org.deepin.camera.encode.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@
"description": "Is low performance device",
"permissions": "readwrite",
"visibility": "private"
},
"useRgbData": {
"value": -1,
"serial": 0,
"flags": ["global"],
"name": "use RGB data for preview",
"name[zh_CN]": "是否使用RGB数据进行预览显示,-1表示不设置,由系统自动判断;0表示强制关闭;1表示强制开启",
"description": "Force use RGB data for preview rendering. -1: not set (auto), 0: force disable, 1: force enable. When enabled, YUV frames will be converted to RGB format before display.",
"permissions": "readwrite",
"visibility": "private"
}
}
}
10 changes: 10 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,16 @@ int main(int argc, char *argv[])
}
}

if (dconfig && dconfig->isValid() && dconfig->keyList().contains("useRgbData")) {
int useRgbData = dconfig->value("useRgbData").toInt();
if (useRgbData != -1 && useRgbData != 0 && useRgbData != 1) {
qWarning() << "Invalid useRgbData value in config:" << useRgbData << "- mapping to default value -1 (auto)";
useRgbData = -1;
}
qInfo() << "use RGB data for preview:" << useRgbData;
DataManager::instance()->setUseRgbData(useRgbData);
}
Comment thread
sourcery-ai[bot] marked this conversation as resolved.

if (!libVaDriverName.isEmpty()) {
qputenv("LIBVA_DRIVER_NAME", libVaDriverName.toLocal8Bit());
}
Expand Down
13 changes: 13 additions & 0 deletions src/src/basepub/datamanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,18 @@ class DataManager: public QObject
* @return 分辨率
*/
QSize getPreferredResolution();

/**
* @brief 设置RGB数据预览模式
* @param mode -1:不设置(自动), 0:强制关闭, 1:强制开启
*/
void setUseRgbData(int mode) { m_useRgbData = mode; };

/**
* @brief 获取RGB数据预览模式
* @return -1:不设置(自动), 0:强制关闭, 1:强制开启
*/
int getUseRgbData() const { return m_useRgbData; };
private:
DataManager();
static DataManager *m_dataManager;
Expand All @@ -226,5 +238,6 @@ class DataManager: public QObject
bool m_enable8kPreview = false; // 是否启用8K预览
QSet<QString> m_deviceBlacklistSet; // 设备黑名单
QSize m_preferredResolution; // 首选分辨率
int m_useRgbData = -1; // RGB数据预览模式:-1不设置(自动), 0强制关闭, 1强制开启
};
#endif // DATAMANAGER_H
8 changes: 8 additions & 0 deletions src/src/majorimageprocessingthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ void MajorImageProcessingThread::run()
if (GStreamer_Env == m_eEncodeEnv)
bUseRgb = true;

// DConfig配置控制RGB数据使用模式,-1表示不设置(由系统自动判断),0表示强制关闭,1表示强制开启
int useRgbData = DataManager::instance()->getUseRgbData();
if (useRgbData == 1) {
bUseRgb = true;
} else if (useRgbData == 0) {
Comment on lines +286 to +289

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Clarify handling of unexpected useRgbData values to make the auto behavior explicit.

Right now only 0/1 change bUseRgb; any other value (including the documented -1 auto) just falls back to the old behavior. If the intent is “non-0/1 = auto”, consider encoding that explicitly (e.g. switch or explicit -1 case), and/or logging/asserting on unexpected values to surface config mistakes early.

Suggested implementation:

            // DConfig配置控制RGB数据使用模式,-1表示不设置(由系统自动判断),0表示强制关闭,1表示强制开启
            int useRgbData = DataManager::instance()->getUseRgbData();
            switch (useRgbData) {
            case 1:
                // 强制开启 RGB
                bUseRgb = true;
                break;
            case 0:
                // 强制关闭 RGB
                bUseRgb = false;
                break;
            case -1:
                // 自动模式:保持当前 bUseRgb 由系统逻辑决定
                break;
            default:
                // 非法配置值:保持当前 bUseRgb,同时在开发期暴露问题
                assert(false && "Invalid useRgbData configuration value (expected -1/0/1)");
                break;
            }
  1. Ensure <cassert> (or your project’s standard assert/logging header) is included in majorimageprocessingthread.cpp or a common header; e.g. add #include <cassert> if not already present.
  2. If your codebase uses a specific logging/assert macro (e.g. LOG_WARNING, Q_ASSERT, etc.), replace the assert(false && "...") call with that preferred mechanism to align with existing conventions.

bUseRgb = false;
}

if (bUseRgb || (m_bPhoto && m_filtersGroupDislay)) {
if (m_nVdWidth != static_cast<unsigned int>(m_frame->width) || m_nVdHeight != static_cast<unsigned int>(m_frame->height)) {
m_nVdWidth = static_cast<unsigned int>(m_frame->width);
Expand Down
Loading