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
40 changes: 40 additions & 0 deletions libcam/libcam_v4l2core/v4l2_formats.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
0
};

// 是否开启8K预览
static int enable_8k_preview = 0;

/* FIXME: doesn't support bigendian formats=> fourcc | (1 << 31)
* get pixelformat from fourcc
* args:
Expand Down Expand Up @@ -748,8 +751,45 @@

int is_valid_resolution(int width, int height)
{
// 希沃的8K分辨率是8192x2772,过多限制会导致此分辨率不可用
if (enable_8k_preview) {
return (width > 0 && height > 0)
&& (width % 16 == 0 && height % 4 == 0);
}

// 由于上游guvcview项目在解码3840x2160分辨率以上时会出现异常(出现条纹、崩溃等),所以我们需要限制可用分辨率到3840x2160
return (width > 0 && height > 0)
&& (width <= MAX_WIDTH_LIMIT && height <= MAX_HEIGHT_LIMIT)
&& (width % 16 == 0 && height % 8 == 0);
}

/*
* set enable 8k preview
* args:
* enable - enable 8k preview
*
* asserts:
* none
*
* returns: void
*/
void set_enable_8k_preview(int enable)
{
enable_8k_preview = enable;
}

/*
* check if 8k preview is enabled
* args:
* none
*
* asserts:
* none
*
* returns: TRUE(1) if enabled
* FALSE(0) if not
*/
int is_enable_8k_preview()

Check warning on line 792 in libcam/libcam_v4l2core/v4l2_formats.c

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'is_enable_8k_preview' is never used.

Check warning on line 792 in libcam/libcam_v4l2core/v4l2_formats.c

View workflow job for this annotation

GitHub Actions / static-check / static-check

The function 'is_enable_8k_preview' is never used.
{
return enable_8k_preview;
}
25 changes: 25 additions & 0 deletions libcam/libcam_v4l2core/v4l2_formats.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,29 @@ void free_frame_formats(v4l2_dev_t *vd);
*/
int is_valid_resolution(int width, int height);

/*
* set enable 8k preview
* args:
* enable - enable 8k preview
*
* asserts:
* none
*
* returns: void
*/
void set_enable_8k_preview(int enable);

/*
* check if 8k preview is enabled
* args:
* none
*
* asserts:
* none
*
* returns: TRUE(1) if enabled
* FALSE(0) if not
*/
int is_enable_8k_preview();

#endif
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 @@ -81,6 +81,16 @@
"description": "Enable USB group",
"permissions": "readwrite",
"visibility": "private"
},
"enable8kPreview": {
"value": false,
"serial": 0,
"flags": ["global"],
"name": "enable 8k preview",
"name[zh_CN]": "是否启用8K预览",
"description": "Enable 8k preview",
"permissions": "readwrite",
"visibility": "private"
}
}
}
11 changes: 11 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
// SPDX-License-Identifier: GPL-3.0-or-later

extern "C" {
#include "camview.h"

Check warning on line 7 in src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "camview.h" not found.

Check warning on line 7 in src/main.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "camview.h" not found.
#include "v4l2_formats.h"

Check warning on line 8 in src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "v4l2_formats.h" not found.

Check warning on line 8 in src/main.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "v4l2_formats.h" not found.
}
#include "mainwindow.h"

Check warning on line 10 in src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "mainwindow.h" not found.

Check warning on line 10 in src/main.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "mainwindow.h" not found.
#include "capplication.h"

Check warning on line 11 in src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "capplication.h" not found.

Check warning on line 11 in src/main.cpp

View workflow job for this annotation

GitHub Actions / static-check / static-check

Include file: "capplication.h" not found.
#include "cameraconfig.h"
#include "acobjectlist.h"
#include "dbus_adpator.h"
Expand Down Expand Up @@ -188,6 +189,16 @@
DataManager::instance()->setEnableUsbGroup(enable);
}

// 是否开启8K预览通过DConfig控制,目前要求开启8K预览的厂家是希沃
// 希沃的8K分辨率是8192x2772,希沃在8K预览的时候表现正常,在录像的时候表现异常,所以在开启8K预览的时候我们会禁用录像功能
// 8K预览功能默认关闭,因为多个厂家的摄像头在8K预览的时候表现异常
if (dconfig && dconfig->isValid() && dconfig->keyList().contains("enable8kPreview")) {
bool enable = dconfig->value("enable8kPreview").toBool();
qInfo() << "enable 8K preview:" << enable;
DataManager::instance()->setEnable8kPreview(enable);
set_enable_8k_preview(enable ? 1 : 0);
}

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 @@ -175,6 +175,18 @@ class DataManager: public QObject
* @return
*/
bool isEnableUsbGroup() const { return m_enableUsbGroup; };

/**
* @brief 设置是否启用8K预览
* @param enable
*/
void setEnable8kPreview(bool enable) { m_enable8kPreview = enable; };

/**
* @brief 获取是否启用8K预览
* @return
*/
bool isEnable8kPreview() const { return m_enable8kPreview; };
private:
DataManager();
static DataManager *m_dataManager;
Expand All @@ -187,5 +199,6 @@ class DataManager: public QObject
bool m_isSupportCameraSwitch = false; // 是否带有摄像头开关
bool m_isPreviewNoDelay = false; // 是否预览无延迟
bool m_enableUsbGroup = false; // 是否启用USB摄像头分组
bool m_enable8kPreview = false; // 是否启用8K预览
};
#endif // DATAMANAGER_H
28 changes: 27 additions & 1 deletion src/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,7 @@ void CMainWindow::onSwitchCameraSuccess(const QString &cameraName)
m_labelCameraName->show();
m_filterName->hide();
m_showCameraNameTimer->start();
showChildWidget();
}

void CMainWindow::onTimeoutLock(const QString &serviceName, QVariantMap key2value, QStringList)
Expand Down Expand Up @@ -2216,6 +2217,13 @@ void CMainWindow::onSettingsDlgClose()
if (bPathChanged) {
reflushSnapshotLabel();
}

// 8k分辨率时不显示录像功能
bool isResolutionTooHigh = checkResolutionTooHigh();
if (isResolutionTooHigh) {
m_modeSwitchBox->reset();
}
showChildWidget();
}

void CMainWindow::onEnableSettings(bool bTrue)
Expand Down Expand Up @@ -2327,9 +2335,12 @@ void CMainWindow::showChildWidget()
showWidget(m_photoRecordBtn, true);
return;
}

// 8k分辨率时不显示录像功能
bool isResolutionTooHigh = checkResolutionTooHigh();
showWidget(m_snapshotLabel, true);
showWidget(m_cameraSwitchBtn, m_bSwitchCameraShowEnable);
showWidget(m_modeSwitchBox, true);
showWidget(m_modeSwitchBox, !isResolutionTooHigh);
showWidget(m_photoRecordBtn, true);
showWidget(m_takePhotoSettingArea, true);
showWidget(m_filterName, m_bShowFilterName);
Expand All @@ -2348,6 +2359,21 @@ void CMainWindow::showWidget(DWidget *widget, bool bShow)
}
}

bool CMainWindow::checkResolutionTooHigh() const
{
int currentWidth = 0;
int currentHeight = 0;
v4l2_dev_t *fd = get_v4l2_device_handler();
if (fd) {
currentWidth = v4l2core_get_frame_width(fd);
currentHeight = v4l2core_get_frame_height(fd);
}
bool isTrue = currentWidth > MAX_WIDTH_LIMIT || currentHeight > MAX_HEIGHT_LIMIT;
qInfo() << __func__ << isTrue << currentWidth << "x" << currentHeight;

return isTrue;
}

CMainWindow::~CMainWindow()
{
if (m_devnumMonitor) {
Expand Down
5 changes: 5 additions & 0 deletions src/src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ class CMainWindow : public DMainWindow
*/
void getMediaFileInfoList(const QString &path, QFileInfoList &fileList);

/**
* @brief 检测分辨率是否太高,8K分辨率不显示录像功能
*/
bool checkResolutionTooHigh() const;

private slots:
/**
* @brief setSelBtnHide 设置切换相机按钮隐藏
Expand Down
7 changes: 7 additions & 0 deletions src/src/rollingbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,10 @@ void RollingBox::setDeviation(int n)
update();
}

void RollingBox::reset()
{
m_currentIndex = m_rangeMin;
m_deviation = 0;
emit currentValueChanged(m_currentIndex);
update();
}
5 changes: 5 additions & 0 deletions src/src/rollingbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class RollingBox : public QWidget
*/
int getCurrentValue();

/**
* @brief 重置至初始位置
*/
void reset();

protected:
/**
* @brief 鼠标按下事件
Expand Down
Loading