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 24, 2024
1 parent be33ea8 commit 0fdd30b
Show file tree
Hide file tree
Showing 5 changed files with 46 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

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

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
18 changes: 18 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,24 @@ int main(int argc, char *argv[])
format.setRenderableType(QSurfaceFormat::OpenGLES);
format.setDefaultFormat(format);
set_wayland_status(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)){
set_pugx_status(1);
qDebug() << "this is PGUX";
}
}

QTime time;
Expand Down

0 comments on commit 0fdd30b

Please sign in to comment.