Skip to content

Commit

Permalink
fix: 优化相机显示与录制卡顿回跳问题
Browse files Browse the repository at this point in the history
优化相机显示与录制卡顿回跳问题

Bug: https://pms.uniontech.com/bug-view-293127.html
Log: 优化相机显示与录制卡顿回跳问题
  • Loading branch information
myk1343 authored and deepin-bot[bot] committed Dec 20, 2024
1 parent 49abf55 commit 7855880
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion libcam/libcam_encoder/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ static encoder_video_context_t *encoder_video_init(encoder_context_t *encoder_ct


if (video_defaults->gop_size > 0) {
if (pgux == 1) {
if (pgux == 1 || is_forceGles()) {
video_codec_data->codec_context->gop_size = 3;
} else {
video_codec_data->codec_context->gop_size = video_defaults->gop_size;
Expand Down
1 change: 0 additions & 1 deletion src/src/majorimageprocessingthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,6 @@ void MajorImageProcessingThread::run()
}
} else if (m_frame->yuv_frame){
#ifndef __mips__
emit sigRenderYuv(true);
emit sigYUVFrame(m_yuvPtr, m_nVdWidth, m_nVdHeight);
#endif
}
Expand Down
22 changes: 18 additions & 4 deletions src/src/previewopenglwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,20 @@ void PreviewOpenglWidget::paintGL()
{
if (m_yuvPtr == nullptr)
return;

bool bReBuildImage = false;
if(m_imgSize != QSize(m_videoWidth, m_videoHeight)) {
bReBuildImage = true;
m_imgSize = QSize(m_videoWidth, m_videoHeight);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
glActiveTexture(GL_TEXTURE0); //激活纹理单元GL_TEXTURE0,系统里面的
glBindTexture(GL_TEXTURE_2D, m_idY); //绑定y分量纹理对象id到激活的纹理单元

//使用内存中的数据创建真正的y分量纹理数据,https://blog.csdn.net/xipiaoyouzi/article/details/53584798 纹理参数解析
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, static_cast<int>(m_videoWidth), static_cast<int>(m_videoHeight), 0, GL_RED, GL_UNSIGNED_BYTE, m_yuvPtr);
if( bReBuildImage ) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, static_cast<int>(m_videoWidth), static_cast<int>(m_videoHeight), 0, GL_RED, GL_UNSIGNED_BYTE, 0);
}
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, static_cast<int>(m_videoWidth), static_cast<int>(m_videoHeight), GL_RED, GL_UNSIGNED_BYTE, m_yuvPtr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
Expand All @@ -171,7 +179,10 @@ void PreviewOpenglWidget::paintGL()
glBindTexture(GL_TEXTURE_2D, m_idU);

//使用内存中的数据创建真正的u分量纹理数据
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, m_videoWidth >> 1, m_videoHeight >> 1, 0, GL_RED, GL_UNSIGNED_BYTE, m_yuvPtr + m_videoWidth * m_videoHeight);
if( bReBuildImage ) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, m_videoWidth >> 1, m_videoHeight >> 1, 0, GL_RED, GL_UNSIGNED_BYTE, 0);
}
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_videoWidth >> 1, m_videoHeight >> 1, GL_RED, GL_UNSIGNED_BYTE, m_yuvPtr + m_videoWidth * m_videoHeight);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
Expand All @@ -181,7 +192,10 @@ void PreviewOpenglWidget::paintGL()
glBindTexture(GL_TEXTURE_2D, m_idV);

//使用内存中的数据创建真正的v分量纹理数据
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, m_videoWidth >> 1, m_videoHeight >> 1, 0, GL_RED, GL_UNSIGNED_BYTE, m_yuvPtr + m_videoWidth * m_videoHeight * 5 / 4);
if( bReBuildImage ) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, m_videoWidth >> 1, m_videoHeight >> 1, 0, GL_RED, GL_UNSIGNED_BYTE, 0);
}
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_videoWidth >> 1, m_videoHeight >> 1, GL_RED, GL_UNSIGNED_BYTE, m_yuvPtr + m_videoWidth * m_videoHeight * 5 / 4);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
Expand Down
1 change: 1 addition & 0 deletions src/src/previewopenglwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public slots:
uint m_videoHeight;

uchar *m_yuvPtr;
QSize m_imgSize;
};

#endif // PREVIEWOPENGLWIDGET_H
5 changes: 5 additions & 0 deletions src/src/videowidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ void videowidget::delayInit()
} else {
connect(m_imgPrcThread, SIGNAL(SendMajorImageProcessing(QImage *, int)),
this, SLOT(ReceiveMajorImage(QImage *, int)));
ReceiveOpenGLstatus(true);
connect(m_imgPrcThread, SIGNAL(sigRenderYuv(bool)), this, SLOT(ReceiveOpenGLstatus(bool)));
connect(m_imgPrcThread, SIGNAL(sigYUVFrame(uchar *, uint, uint)),
m_openglwidget, SLOT(slotShowYuv(uchar *, uint, uint)));
Expand Down Expand Up @@ -616,6 +617,10 @@ void videowidget::resizeEvent(QResizeEvent *size)

if (m_gridlinewidget)
m_gridlinewidget->resize(rect().size());

if(m_openglwidget && m_openglwidget->isVisible()) {
ReceiveOpenGLstatus(true);
}
}

void videowidget::showCountdown()
Expand Down

0 comments on commit 7855880

Please sign in to comment.