Skip to content

Commit

Permalink
Change qp for jpeg and drop frames at the begining (#198)
Browse files Browse the repository at this point in the history
Co-authored-by: zhangxiaojingCAN <[email protected]>
  • Loading branch information
longyiluo and zhangxiaojingCAN authored Jul 20, 2022
1 parent e6ecee6 commit 9c394ed
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 53 deletions.
71 changes: 18 additions & 53 deletions package/encode_app/src/main.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ using namespace std;
#include "alsa/asoundlib.h"
#include "G711Codec.h"

#define SET_AE_WORKARROUND 1 //in the future, set AE in seperated thread for r2k/f2k
//#define ISP_OUTPUT_DUMP 1
#define TEST_ISP 1

Expand Down Expand Up @@ -503,12 +502,8 @@ static void *v4l2_output(void *arg)
buf.memory = V4L2_MEMORY_USERPTR;

res = ioctl(pCtx->fd_v4l2[channel], VIDIOC_DQBUF, &buf);
#ifdef SET_AE_WORKARROUND
if(pCtx->set_ae[channel])
#endif
{
set_ae(pCtx->dev_name[channel], pCtx->ae_enable);
}

set_ae(pCtx->dev_name[channel], pCtx->ae_enable);

if (res < 0 || errno == EINTR)
{
Expand All @@ -533,6 +528,13 @@ static void *v4l2_output(void *arg)
printf("v4l2 buffer overflow\n");
enqueue_buf(buf.index, channel);
}
else if(time - start_time < 100000000)
{
if(pCtx->v4l2_pic_cnt[channel] == 0)
{
enqueue_buf(buf.index, channel);
}
}
else
{
int drop=0, repeat=0;
Expand Down Expand Up @@ -624,7 +626,7 @@ static void *encode_ch(void *arg)
input.height = pCtx->height[channel];
input.stride = stride;
input.data = (unsigned char *)pCtx->yuv_phyAddr[channel] + frame_size*(src_index % pCtx->input_frames[channel]);
printf("%s>src_index %d, addr 0x%x\n", __FUNCTION__, src_index, input.data);
//printf("%s>src_index %d, addr 0x%x\n", __FUNCTION__, src_index, input.data);
src_index++;
}

Expand Down Expand Up @@ -1190,50 +1192,6 @@ int init_v4l2()
sem_init(&pCtx->pSemGetData[i],0,0);
}

#ifdef SET_AE_WORKARROUND
for(int i = 0; i < pCtx->ch_cnt; i++)
{
if(pCtx->ae_enable)
{
char* dev_name;

dev_name = pCtx->dev_name[i];

if(i == 0)
{
pCtx->set_ae[i] = 1;

if((dev_name[10] >= '2') && (dev_name[10] <= '5'))
{
f2k = 1;
}
else
{
r2k = 1;
}
}
else
{
if(f2k == 1)
{
if((dev_name[10] >= '6') && (dev_name[10] <= '9'))
{
pCtx->set_ae[i] = 1;
}
}

if(r2k == 1)
{
if((dev_name[10] >= '2') && (dev_name[10] <= '5'))
{
pCtx->set_ae[i] = 1;
}
}
break;
}
}
}
#endif
if(mediactl_init(REAL_CONF_FILENAME, &(pCtx->dev_info[0])) < 0)
{
printf("mediactl_init error!\n");
Expand Down Expand Up @@ -1891,6 +1849,7 @@ int parse_cmd(int argc, char *argv[])
printf("-ar: audio sample rate\n");
printf("-af: auido sample format\n");
printf("-ad: audio device");
printf("-lossless: enable jpeg lossless encode");
// printf("-aof: audio output frames\n");
return 1;
}
Expand Down Expand Up @@ -2073,6 +2032,12 @@ int parse_cmd(int argc, char *argv[])
pCtx->Cfg[cur_ch].SliceQP = nqp;
printf("sliceqp %d\n", nqp);
}
else if (strcmp(argv[i],"-lossless") == 0 )
{
int lossless = atoi(argv[i+1]);
pCtx->Cfg[cur_ch].lossless = lossless;
printf("lossless %d\n", lossless);
}
else if (strcmp(argv[i],"-minqp") == 0 )
{
int nqp = atoi(argv[i+1]);
Expand Down Expand Up @@ -2261,7 +2226,7 @@ int main(int argc, char *argv[])
if(strcmp(ptr, ".jpg") == 0 || strcmp(ptr, ".mjpeg") == 0)
{
pCtx->Cfg[i].profile = JPEG;
pCtx->Cfg[i].rcMode = CONST_QP;
pCtx->Cfg[i].rcMode = CONST_QP;
printf("JPEG encode\n");
}
}
Expand Down
1 change: 1 addition & 0 deletions package/venc_lib/src/enc_interface.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ typedef struct
bool bEnableGDR;//gdr
GDRCtrlMode gdrMode;
bool bEnableLTR;//Long Term reference
bool lossless; //jpeg lossless encode

ROICtrlMode roiCtrlMode;
EncSliceSplitCfg sliceSplitCfg;
Expand Down
Binary file modified package/venc_lib/src/libvenc.so
Binary file not shown.

0 comments on commit 9c394ed

Please sign in to comment.