Skip to content

Commit

Permalink
(Continued)
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed Jul 14, 2024
1 parent 816bdf3 commit 87b9469
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
40 changes: 25 additions & 15 deletions src/hal/star/i6_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -472,14 +472,14 @@ int i6_video_create(char index, hal_vidconfig *config)
channel.attrib.codec = I6_VENC_CODEC_MJPG;
switch (config->mode) {
case HAL_VIDMODE_CBR:
channel.rate.mode = I6_VENC_RATEMODE_MJPGCBR;
channel.rate.mode = series == 0xEF ? I6OG_VENC_RATEMODE_MJPGCBR : I6_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 = I6_VENC_RATEMODE_MJPGQP;
channel.rate.mode = series == 0xEF ? I6OG_VENC_RATEMODE_MJPGQP : I6_VENC_RATEMODE_MJPGQP;
channel.rate.mjpgQp.fpsNum =
config->codec == HAL_VIDCODEC_JPG ? 1 : config->framerate;
channel.rate.mjpgCbr.fpsDen = 1;
Expand All @@ -489,12 +489,12 @@ int i6_video_create(char index, hal_vidconfig *config)
HAL_ERROR("i6_venc", "MJPEG encoder can only support CBR or fixed QP modes!");
}

channel.attrib.mjpg.maxHeight = ALIGN_UP(config->height, 16);
channel.attrib.mjpg.maxWidth = ALIGN_UP(config->width, 16);
channel.attrib.mjpg.bufSize = ALIGN_UP(config->width, 16) * ALIGN_UP(config->height, 16);
channel.attrib.mjpg.maxHeight = config->height;
channel.attrib.mjpg.maxWidth = config->width;
channel.attrib.mjpg.bufSize = config->width * config->height;
channel.attrib.mjpg.byFrame = 1;
channel.attrib.mjpg.height = ALIGN_UP(config->height, 16);
channel.attrib.mjpg.width = ALIGN_UP(config->width, 16);
channel.attrib.mjpg.height = config->height;
channel.attrib.mjpg.width = config->width;
channel.attrib.mjpg.dcfThumbs = 0;
channel.attrib.mjpg.markPerRow = 0;

Expand All @@ -504,25 +504,29 @@ int i6_video_create(char index, hal_vidconfig *config)
attrib = &channel.attrib.h265;
switch (config->mode) {
case HAL_VIDMODE_CBR:
channel.rate.mode = I6_VENC_RATEMODE_H265CBR;
channel.rate.mode = series == 0xEF ? I6OG_VENC_RATEMODE_H265CBR :
I6_VENC_RATEMODE_H265CBR;
channel.rate.h265Cbr = (i6_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 = I6_VENC_RATEMODE_H265VBR;
channel.rate.mode = series == 0xEF ? I6OG_VENC_RATEMODE_H265VBR :
I6_VENC_RATEMODE_H265VBR;
channel.rate.h265Vbr = (i6_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 = I6_VENC_RATEMODE_H265QP;
channel.rate.mode = series == 0xEF ? I6OG_VENC_RATEMODE_H265QP :
I6_VENC_RATEMODE_H265QP;
channel.rate.h265Qp = (i6_venc_rate_h26xqp){ .gop = config->gop,
.fpsNum = config->framerate, .fpsDen = 1, .interQual = config->maxQual,
.predQual = config->minQual }; break;
case HAL_VIDMODE_ABR:
HAL_ERROR("i6_venc", "H.265 encoder does not support ABR mode!");
case HAL_VIDMODE_AVBR:
channel.rate.mode = I6_VENC_RATEMODE_H265AVBR;
channel.rate.mode = series == 0xEF ? I6OG_VENC_RATEMODE_H265AVBR :
I6_VENC_RATEMODE_H265AVBR;
channel.rate.h265Avbr = (i6_venc_rate_h26xvbr){ .gop = config->gop,
.statTime = 1, .fpsNum = config->framerate, .fpsDen = 1, .maxBitrate =
(unsigned int)(MAX(config->bitrate, config->maxBitrate)) << 10,
Expand All @@ -533,20 +537,25 @@ int i6_video_create(char index, hal_vidconfig *config)
} else if (config->codec == HAL_VIDCODEC_H264) {
channel.attrib.codec = I6_VENC_CODEC_H264;
attrib = &channel.attrib.h264;
if (series == 0xEF && config->mode == HAL_VIDMODE_ABR)
config->mode = -1;
switch (config->mode) {
case HAL_VIDMODE_CBR:
channel.rate.mode = I6_VENC_RATEMODE_H264CBR;
channel.rate.mode = series == 0xEF ? I6OG_VENC_RATEMODE_H264CBR :
I6_VENC_RATEMODE_H264CBR;
channel.rate.h264Cbr = (i6_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 = I6_VENC_RATEMODE_H264VBR;
channel.rate.mode = series == 0xEF ? I6OG_VENC_RATEMODE_H264VBR :
I6_VENC_RATEMODE_H264VBR;
channel.rate.h264Vbr = (i6_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 = I6_VENC_RATEMODE_H264QP;
channel.rate.mode = series == 0xEF ? I6OG_VENC_RATEMODE_H264QP :
I6_VENC_RATEMODE_H264QP;
channel.rate.h264Qp = (i6_venc_rate_h26xqp){ .gop = config->gop,
.fpsNum = config->framerate, .fpsDen = 1, .interQual = config->maxQual,
.predQual = config->minQual }; break;
Expand All @@ -557,7 +566,8 @@ int i6_video_create(char index, hal_vidconfig *config)
.avgBitrate = (unsigned int)(config->bitrate) << 10,
.maxBitrate = (unsigned int)(config->maxBitrate) << 10 }; break;
case HAL_VIDMODE_AVBR:
channel.rate.mode = I6_VENC_RATEMODE_H264AVBR;
channel.rate.mode = series == 0xEF ? I6OG_VENC_RATEMODE_H264AVBR :
I6_VENC_RATEMODE_H264AVBR;
channel.rate.h264Avbr = (i6_venc_rate_h26xvbr){ .gop = config->gop, .statTime = 1,
.fpsNum = config->framerate, .fpsDen = 1, .maxBitrate =
(unsigned int)(MAX(config->bitrate, config->maxBitrate)) << 10,
Expand Down
14 changes: 14 additions & 0 deletions src/hal/star/i6_venc.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ typedef enum {
I6_VENC_RATEMODE_END
} i6_venc_ratemode;

typedef enum {
I6OG_VENC_RATEMODE_H264CBR = 1,
I6OG_VENC_RATEMODE_H264VBR,
I6OG_VENC_RATEMODE_H264QP,
I6OG_VENC_RATEMODE_H264AVBR,
I6OG_VENC_RATEMODE_MJPGCBR,
I6OG_VENC_RATEMODE_MJPGQP,
I6OG_VENC_RATEMODE_H265CBR,
I6OG_VENC_RATEMODE_H265VBR,
I6OG_VENC_RATEMODE_H265QP,
I6OG_VENC_RATEMODE_H265AVBR,
I6OG_VENC_RATEMODE_END
} i6og_venc_ratemode;

typedef struct {
unsigned int maxWidth;
unsigned int maxHeight;
Expand Down

0 comments on commit 87b9469

Please sign in to comment.