Skip to content

Commit

Permalink
Mitigation for newer SDKs on infinity6c
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed Jun 10, 2024
1 parent bc1b15d commit 73fe6c3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 20 deletions.
37 changes: 20 additions & 17 deletions src/hal/sstar/i6c_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ i6c_snr_pad _i6c_snr_pad;
i6c_snr_plane _i6c_snr_plane;
char _i6c_snr_framerate, _i6c_snr_hdr, _i6c_snr_index, _i6c_snr_profile;

char _i6c_upd_venc = 0;

char _i6c_aud_chn = 0;
char _i6c_aud_dev = 0;
char _i6c_isp_chn = 0;
Expand Down Expand Up @@ -500,14 +502,14 @@ int i6c_video_create(char index, hal_vidconfig *config)
channel.attrib.codec = I6C_VENC_CODEC_MJPG;
switch (config->mode) {
case HAL_VIDMODE_CBR:
channel.rate.mode = I6C_VENC_RATEMODE_MJPGCBR;
channel.rate.mode = _i6c_upd_venc ? I6C_VENC_NRATEMODE_MJPGCBR : I6C_VENC_RATEMODE_MJPGCBR;
channel.rate.mjpgCbr.bitrate = config->bitrate << 10;
channel.rate.mjpgCbr.fpsNum =
config->codec == HAL_VIDCODEC_JPG ? 1 : config->framerate;
channel.rate.mjpgCbr.fpsDen = 1;
break;
case HAL_VIDMODE_QP:
channel.rate.mode = I6C_VENC_RATEMODE_MJPGQP;
channel.rate.mode = _i6c_upd_venc ? I6C_VENC_NRATEMODE_MJPGQP : I6C_VENC_RATEMODE_MJPGQP;
channel.rate.mjpgQp.fpsNum = config->framerate;
channel.rate.mjpgQp.fpsDen =
config->codec == HAL_VIDCODEC_JPG ? 1 : config->framerate;
Expand All @@ -532,25 +534,25 @@ int i6c_video_create(char index, hal_vidconfig *config)
attrib = &channel.attrib.h265;
switch (config->mode) {
case HAL_VIDMODE_CBR:
channel.rate.mode = I6C_VENC_RATEMODE_H265CBR;
channel.rate.mode = _i6c_upd_venc ? I6C_VENC_NRATEMODE_H265CBR : I6C_VENC_RATEMODE_H265CBR;
channel.rate.h265Cbr = (i6c_venc_rate_h26xcbr){ .gop = config->gop,
.statTime = 1, .fpsNum = config->framerate, .fpsDen = 1, .bitrate =
(unsigned int)(config->bitrate) << 10, .avgLvl = 1 }; break;
case HAL_VIDMODE_VBR:
channel.rate.mode = I6C_VENC_RATEMODE_H265VBR;
channel.rate.mode = _i6c_upd_venc ? I6C_VENC_NRATEMODE_H265VBR : I6C_VENC_RATEMODE_H265VBR;
channel.rate.h265Vbr = (i6c_venc_rate_h26xvbr){ .gop = config->gop,
.statTime = 1, .fpsNum = config->framerate, .fpsDen = 1, .maxBitrate =
(unsigned int)(MAX(config->bitrate, config->maxBitrate)) << 10,
.maxQual = config->maxQual, .minQual = config->minQual }; break;
case HAL_VIDMODE_QP:
channel.rate.mode = I6C_VENC_RATEMODE_H265QP;
channel.rate.mode = _i6c_upd_venc ? I6C_VENC_NRATEMODE_H265QP : I6C_VENC_RATEMODE_H265QP;
channel.rate.h265Qp = (i6c_venc_rate_h26xqp){ .gop = config->gop,
.fpsNum = config->framerate, .fpsDen = 1, .interQual = config->maxQual,
.predQual = config->minQual }; break;
case HAL_VIDMODE_ABR:
I6C_ERROR("H.265 encoder does not support ABR mode!");
case HAL_VIDMODE_AVBR:
channel.rate.mode = I6C_VENC_RATEMODE_H265AVBR;
channel.rate.mode = _i6c_upd_venc ? I6C_VENC_NRATEMODE_H265AVBR : I6C_VENC_RATEMODE_H265AVBR;
channel.rate.h265Avbr = (i6c_venc_rate_h26xvbr){ .gop = config->gop,
.statTime = 1, .fpsNum = config->framerate, .fpsDen = 1, .maxBitrate =
(unsigned int)(MAX(config->bitrate, config->maxBitrate)) << 10,
Expand All @@ -563,29 +565,29 @@ int i6c_video_create(char index, hal_vidconfig *config)
attrib = &channel.attrib.h264;
switch (config->mode) {
case HAL_VIDMODE_CBR:
channel.rate.mode = I6C_VENC_RATEMODE_H264CBR;
channel.rate.mode = _i6c_upd_venc ? I6C_VENC_NRATEMODE_H264CBR : I6C_VENC_RATEMODE_H264CBR;
channel.rate.h264Cbr = (i6c_venc_rate_h26xcbr){ .gop = config->gop,
.statTime = 1, .fpsNum = config->framerate, .fpsDen = 1, .bitrate =
(unsigned int)(config->bitrate) << 10, .avgLvl = 1 }; break;
case HAL_VIDMODE_VBR:
channel.rate.mode = I6C_VENC_RATEMODE_H264VBR;
channel.rate.mode = _i6c_upd_venc ? I6C_VENC_NRATEMODE_H264VBR : I6C_VENC_RATEMODE_H264VBR;
channel.rate.h264Vbr = (i6c_venc_rate_h26xvbr){ .gop = config->gop,
.statTime = 1, .fpsNum = config->framerate, .fpsDen = 1, .maxBitrate =
(unsigned int)(MAX(config->bitrate, config->maxBitrate)) << 10,
.maxQual = config->maxQual, .minQual = config->minQual }; break;
case HAL_VIDMODE_QP:
channel.rate.mode = I6C_VENC_RATEMODE_H264QP;
channel.rate.mode = _i6c_upd_venc ? I6C_VENC_NRATEMODE_H264QP : I6C_VENC_RATEMODE_H264QP;
channel.rate.h264Qp = (i6c_venc_rate_h26xqp){ .gop = config->gop,
.fpsNum = config->framerate, .fpsDen = 1, .interQual = config->maxQual,
.predQual = config->minQual }; break;
case HAL_VIDMODE_ABR:
channel.rate.mode = I6C_VENC_RATEMODE_H264ABR;
channel.rate.mode = _i6c_upd_venc ? I6C_VENC_NRATEMODE_H264ABR : I6C_VENC_RATEMODE_H264ABR;
channel.rate.h264Abr = (i6c_venc_rate_h26xabr){ .gop = config->gop,
.statTime = 1, .fpsNum = config->framerate, .fpsDen = 1,
.avgBitrate = (unsigned int)(config->bitrate) << 10,
.maxBitrate = (unsigned int)(config->maxBitrate) << 10 }; break;
case HAL_VIDMODE_AVBR:
channel.rate.mode = I6C_VENC_RATEMODE_H264AVBR;
channel.rate.mode = _i6c_upd_venc ? I6C_VENC_NRATEMODE_H264AVBR : I6C_VENC_RATEMODE_H264AVBR;
channel.rate.h264Avbr = (i6c_venc_rate_h26xvbr){ .gop = config->gop,
.statTime = 1, .fpsNum = config->framerate, .fpsDen = 1, .maxBitrate =
(unsigned int)(MAX(config->bitrate, config->maxBitrate)) << 10,
Expand Down Expand Up @@ -931,16 +933,17 @@ int i6c_system_init(void)
{
int ret;

if (ret = i6c_sys.fnInit(0))
return ret;
{
i6c_sys_ver version;
//if (ret = i6c_sys.fnGetVersion(0, &version))
// return ret;
if (ret = i6c_sys.fnGetVersion(0, &version))
return ret;
printf("App built with headers v%s\n", I6C_SYS_API);
//puts(version.version);
puts(version.version);
if (strstr(version.version, "build_time.2023"))
_i6c_upd_venc = 1;
}

if (ret = i6c_sys.fnInit(0))
return ret;

return EXIT_SUCCESS;
}
18 changes: 18 additions & 0 deletions src/hal/sstar/i6c_venc.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,24 @@ typedef enum {
I6C_VENC_SRC_CONF_END
} i6c_venc_src_conf;

enum {
I6C_VENC_NRATEMODE_H264CBR = 1,
I6C_VENC_NRATEMODE_H264VBR,
I6C_VENC_NRATEMODE_H264ABR,
I6C_VENC_NRATEMODE_H264UBR,
I6C_VENC_NRATEMODE_H264QP,
I6C_VENC_NRATEMODE_H264AVBR,
I6C_VENC_NRATEMODE_MJPGCBR,
I6C_VENC_NRATEMODE_MJPGVBR,
I6C_VENC_NRATEMODE_MJPGQP,
I6C_VENC_NRATEMODE_H265CBR,
I6C_VENC_NRATEMODE_H265VBR,
I6C_VENC_NRATEMODE_H265UBR,
I6C_VENC_NRATEMODE_H265QP,
I6C_VENC_NRATEMODE_H265AVBR,
I6C_VENC_NRATEMODE_END
};

typedef enum {
I6C_VENC_RATEMODE_H264CBR = 1,
I6C_VENC_RATEMODE_H264VBR,
Expand Down
5 changes: 2 additions & 3 deletions src/hal/sstar/i6f_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,8 @@ int i6f_system_init(void)
{
int ret;

if (ret = i6f_sys.fnInit(0))
return ret;
{
i6f_sys_ver version;
if (ret = i6f_sys.fnGetVersion(0, &version))
Expand All @@ -898,8 +900,5 @@ int i6f_system_init(void)
puts(version.version);
}

if (ret = i6f_sys.fnInit(0))
return ret;

return EXIT_SUCCESS;
}

0 comments on commit 73fe6c3

Please sign in to comment.