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
26 changes: 7 additions & 19 deletions src/src/majorimageprocessingthread.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd.
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -24,7 +24,6 @@ DCORE_USE_NAMESPACE
MajorImageProcessingThread::MajorImageProcessingThread():m_bHorizontalMirror(false)
{
qDebug() << "Initializing MajorImageProcessingThread";
m_yuvPtr = nullptr;
m_rgbPtr = nullptr;
m_bRecording = false;
m_nVdWidth = 0;
Expand Down Expand Up @@ -251,13 +250,10 @@ void MajorImageProcessingThread::run()
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);
m_nVdHeight = static_cast<unsigned int>(m_frame->height);
if (m_yuvPtr != nullptr) {
delete [] m_yuvPtr;
m_yuvPtr = nullptr;
}
m_yuvPtr.reset();

yuvsize = m_nVdWidth * m_nVdHeight * 3 / 2;
m_yuvPtr = new uchar[yuvsize];
m_yuvPtr = std::shared_ptr<uchar[]>(new uchar[yuvsize]);
if (m_rgbPtr != nullptr) {
free(m_rgbPtr);
m_rgbPtr = nullptr;
Expand All @@ -270,12 +266,12 @@ void MajorImageProcessingThread::run()
}

if (m_bHorizontalMirror) {
ImageHorizontalMirror(m_frame->yuv_frame, m_yuvPtr,m_frame->width,m_frame->height);
ImageHorizontalMirror(m_frame->yuv_frame, m_yuvPtr.get(), m_frame->width, m_frame->height);
} else {
memcpy(m_yuvPtr, m_frame->yuv_frame, yuvsize);
memcpy(m_yuvPtr.get(), m_frame->yuv_frame, yuvsize);
}
pOldYuvFrame = m_frame->yuv_frame;
m_frame->yuv_frame = m_yuvPtr;
m_frame->yuv_frame = m_yuvPtr.get();
} else if (GStreamer_Env == m_eEncodeEnv) {
// qDebug() << "Processing video frame in GStreamer environment";
// GStreamer环境下,获取的帧数据为jpg格式,需要转换为rgb格式,GStreamer底层才能处理
Expand All @@ -292,9 +288,6 @@ void MajorImageProcessingThread::run()
#if defined(_loongarch) || defined(__loongarch__) || defined(__loongarch64) || defined (__mips__)
bUseRgb = true;
#endif
if(DSysInfo::majorVersion().toInt() >= 23) {
bUseRgb = true;
}
if (get_wayland_status())
bUseRgb = true;

Expand Down Expand Up @@ -538,12 +531,7 @@ void MajorImageProcessingThread::run()

MajorImageProcessingThread::~MajorImageProcessingThread()
{
// qDebug() << "Cleaning up MajorImageProcessingThread resources";
if (m_yuvPtr) {
// qDebug() << "Cleaning up MajorImageProcessingThread resources";
delete [] m_yuvPtr;
m_yuvPtr = nullptr;
}
m_yuvPtr.reset();

if (m_rgbPtr) {
// qDebug() << "Cleaning up MajorImageProcessingThread resources";
Expand Down
9 changes: 5 additions & 4 deletions src/src/majorimageprocessingthread.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co.,Ltd.
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand All @@ -9,11 +9,12 @@
#include <QThread>
#include <QPixmap>
#include <QDebug>
#include <QMutex>

Check warning on line 12 in src/src/majorimageprocessingthread.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QMutex> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QWaitCondition>

Check warning on line 13 in src/src/majorimageprocessingthread.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QWaitCondition> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QElapsedTimer>

Check warning on line 14 in src/src/majorimageprocessingthread.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QElapsedTimer> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <memory>

Check warning on line 15 in src/src/majorimageprocessingthread.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <memory> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include "datamanager.h"

Check warning on line 17 in src/src/majorimageprocessingthread.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "datamanager.h" not found.

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -133,11 +134,11 @@
#ifndef __mips__
/**
* @brief sigYUVFrame YUV框架信号
* @param yuv YUV
* @param yuv YUV数据(shared_ptr持有所有权,跨线程安全)
* @param width 宽度
* @param height 高度
*/
void sigYUVFrame(uchar *yuv, uint width, uint height);
void sigYUVFrame(std::shared_ptr<uchar[]> yuv, uint width, uint height);

/**
* @brief sigRenderYuv 发送Yuv信号
Expand Down Expand Up @@ -180,7 +181,7 @@
QAtomicInt m_stopped;
v4l2_dev_t *m_videoDevice;
v4l2_frame_buff_t *m_frame;
uint8_t *m_yuvPtr;// yu12视频帧数据
std::shared_ptr<uchar[]> m_yuvPtr;// yu12视频帧数据(shared_ptr管理生命周期)
uint8_t *m_rgbPtr;// rgb视频帧数据

bool m_bPhoto = true; //相机当前状态,默认为拍照状态
Expand Down
Loading
Loading