Skip to content

Commit

Permalink
fix: the omx encode cache small in PGUX
Browse files Browse the repository at this point in the history
fix the omx encode cache small in PGUX

Log: fix the omx encode cache small in PGUX
Bug: https://pms.uniontech.com/bug-view-254991.html
  • Loading branch information
add-uos committed Jun 25, 2024
1 parent be33ea8 commit 152db71
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 6 deletions.
15 changes: 14 additions & 1 deletion libcam/libcam/camview.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ static int my_encoder_status = 0;

static int is_wayland = 0; //是否是wayland的窗口管理器

static int is_pgux = 0; //是否是pugx

static uint8_t soundTakePhoto = 1;//拍照声音提示

static char status_message[80];
Expand Down Expand Up @@ -794,7 +796,8 @@ static void *encoder_loop(__attribute__((unused))void *data)
v4l2core_get_fps_num(my_vd),
v4l2core_get_fps_denom(my_vd),
channels,
samprate);
samprate,
get_pugx_status());

/*store external SPS and PPS data if needed*/
if(encoder_ctx->video_codec_ind == 0 && /*raw - direct input*/
Expand Down Expand Up @@ -1355,3 +1358,13 @@ int get_sound_of_takeing_photo()
{
return soundTakePhoto;
}

void set_pugx_status(int status)
{
is_pgux = status;
}

int get_pugx_status()
{
return is_pgux;
}
3 changes: 3 additions & 0 deletions libcam/libcam/camview.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ void set_takeing_photo_sound(uint8_t status);

int get_sound_of_takeing_photo(void);

void set_pugx_status(int status);

int get_pugx_status();

#ifdef __cplusplus
}
Expand Down
13 changes: 9 additions & 4 deletions libcam/libcam_encoder/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ static void encoder_set_raw_video_input(
*
* returns: pointer to encoder video context (NULL on none)
*/
static encoder_video_context_t *encoder_video_init(encoder_context_t *encoder_ctx)
static encoder_video_context_t *encoder_video_init(encoder_context_t *encoder_ctx, int pgux)

Check warning on line 431 in libcam/libcam_encoder/encoder.c

View workflow job for this annotation

GitHub Actions / cppcheck

Parameter 'encoder_ctx' can be declared with const
{
//assertions
assert(encoder_ctx != NULL);
Expand Down Expand Up @@ -581,7 +581,11 @@ static encoder_video_context_t *encoder_video_init(encoder_context_t *encoder_ct


if (video_defaults->gop_size > 0) {
video_codec_data->codec_context->gop_size = video_defaults->gop_size;
if(pgux == 1){
video_codec_data->codec_context->gop_size = 3;
}else{
video_codec_data->codec_context->gop_size = video_defaults->gop_size;
}
} else {
video_codec_data->codec_context->gop_size = video_codec_data->codec_context->time_base.den;
}
Expand Down Expand Up @@ -1134,7 +1138,8 @@ encoder_context_t *encoder_init(
int fps_num,
int fps_den,
int audio_channels,
int audio_samprate)
int audio_samprate,
int use_pugx_code)
{
encoder_context_t *encoder_ctx = calloc(1, sizeof(encoder_context_t));

Expand Down Expand Up @@ -1162,7 +1167,7 @@ encoder_context_t *encoder_init(
/******************* video **********************/
encoder_video_init_vaapi(encoder_ctx);
if (HW_VAAPI_OK != is_vaapi) {
encoder_video_init(encoder_ctx);
encoder_video_init(encoder_ctx, use_pugx_code);
//hw_vaapi ng
}

Expand Down
3 changes: 2 additions & 1 deletion libcam/libcam_encoder/gviewencoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ encoder_context_t *encoder_init(
int fps_num,
int fps_den,
int audio_channels,
int audio_samprate);
int audio_samprate,
int use_pugx_code);

/*
* initialization of the file muxer
Expand Down
10 changes: 10 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,13 @@ set(APPSHAREDIR ${CMAKE_INSTALL_DATADIR}/${TARGET_NAME})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/translations
DESTINATION ${APPSHAREDIR}
FILES_MATCHING PATTERN "*.qm")

#hw机型增加DConfig配置
set(APPID org.deepin.camera)
set(configFile ${PROJECT_SOURCE_DIR}/assets/org.deepin.camera.encode.json)
if (DEFINED DSG_DATA_DIR)
message("-- DConfig is supported by DTK")
dconfig_meta_files(APPID ${APPID} FILES ${configFile})
else()
install(FILES ${configFile} DESTINATION ${CMAKE_INSTALL_DATADIR}/dsg/configs/org.deepin.camera/)
endif()
16 changes: 16 additions & 0 deletions src/assets/org.deepin.camera.encode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"magic": "dsg.config.meta",
"version": "1.0",
"contents": {
"mp4EncodeMode": {
"value": 0,
"serial": 0,
"flags": ["global"],
"name": "pugx mp4 code mode",
"name[zh_CN]": "特殊编码模式",
"description": "pugx mp4 code mode",
"permissions": "readwrite",
"visibility": "private"
}
}
}
40 changes: 40 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ extern "C"
#include "acobjectlist.h"
#include "dbus_adpator.h"

#ifdef DTKCORE_CLASS_DConfigFile
#include <DConfig>
#endif

extern "C"
{
#include <libimagevisualresult/visualresult.h>
Expand Down Expand Up @@ -120,6 +124,42 @@ int main(int argc, char *argv[])
format.setRenderableType(QSurfaceFormat::OpenGLES);
format.setDefaultFormat(format);
set_wayland_status(1);

int mp4Encode = -1;

Check warning on line 128 in src/main.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct.
#ifdef DTKCORE_CLASS_DConfigFile
//需要查询是否支持特殊特殊机型打开迷你模式,例如hw机型
DConfig *dconfig = DConfig::create("org.deepin.camera","org.deepin.camera.encode");
if(dconfig && dconfig->isValid() && dconfig->keyList().contains("mp4EncodeMode")){
mp4Encode = dconfig->value("mp4EncodeMode").toInt();
set_pugx_status(mp4Encode);
}
#endif
qInfo() << "mp4EncodeMode value is:" << get_pugx_status();
if(mp4Encode == -1){
//判断是否是pgux
QStringList options;
options << QString(QStringLiteral("-c"));
options << QString(QStringLiteral("dmidecode -s system-product-name|awk '{print $NF}'"));
QProcess process;
process.start(QString(QStringLiteral("bash")), options);
process.waitForFinished();
process.waitForReadyRead();
QByteArray tempArray = process.readAllStandardOutput();
char *charTemp = tempArray.data();
QString str_output = QString(QLatin1String(charTemp));
process.close();

if (str_output.contains("PGUX", Qt::CaseInsensitive)){
mp4Encode = 1;
qDebug() << "this is PGUX";
}else{
mp4Encode = 0;
}
qInfo() << "process find mp4EncodeMode value is:" << get_pugx_status();
}

set_pugx_status(mp4Encode);
qInfo() << "last mp4EncodeMode value is:" << get_pugx_status();
}

QTime time;
Expand Down

0 comments on commit 152db71

Please sign in to comment.