Skip to content

Commit

Permalink
Returned NALU packet infos on infinity6 are broken (but not on i6b0/e)
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed Jul 14, 2024
1 parent 87b9469 commit 72a2654
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
34 changes: 32 additions & 2 deletions src/hal/star/i6_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@ int i6_video_create(char index, hal_vidconfig *config)
attrib->maxHeight = config->height;
attrib->maxWidth = config->width;
attrib->bufSize = config->height * config->width;
attrib->profile = config->profile;
attrib->profile = MIN((series == 0xEF || config->codec == HAL_VIDCODEC_H265) ? 1 : 2,
config->profile);
attrib->byFrame = 1;
attrib->height = config->height;
attrib->width = config->width;
Expand Down Expand Up @@ -836,7 +837,36 @@ void *i6_video_thread(void)
outPack[j].data = pack->data;
outPack[j].length = pack->length;
outPack[j].naluCnt = pack->packNum;
switch (i6_state[i].payload) {
if (series == 0xEF) {
signed char n = 0;
switch (i6_state[i].payload) {
case HAL_VIDCODEC_H264:
for (unsigned int p = 0; p < pack->length - 4; p++) {
if (outPack[j].data[p] || outPack[j].data[p + 1] ||
outPack[j].data[p + 2] || outPack[j].data[p + 3] != 1) continue;
outPack[0].nalu[n].type = outPack[j].data[p + 4] & 0x1F;
outPack[0].nalu[n++].offset = p;
if (n == (outPack[j].naluCnt)) break;
}
break;
case HAL_VIDCODEC_H265:
for (unsigned int p = 0; p < pack->length - 4; p++) {
if (outPack[j].data[p] || outPack[j].data[p + 1] ||
outPack[j].data[p + 2] || outPack[j].data[p + 3] != 1) continue;
outPack[0].nalu[n].type = (outPack[j].data[p + 4] & 0x7E) >> 1;
outPack[0].nalu[n++].offset = p;
if (n == (outPack[j].naluCnt)) break;
}
break;
}

outPack[0].naluCnt = n;
outPack[0].nalu[n].offset = pack->length;
for (n = 0; n < outPack[0].naluCnt; n++)
outPack[0].nalu[n].length =
outPack[0].nalu[n + 1].offset -
outPack[0].nalu[n].offset;
} else switch (i6_state[i].payload) {
case HAL_VIDCODEC_H264:
for (char k = 0; k < outPack[j].naluCnt; k++) {
outPack[j].nalu[k].length =
Expand Down
2 changes: 1 addition & 1 deletion src/hal/support.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void hal_identify(void) {
case 0xF1: // Pudding (6E)
case 0xF2: // Ispahan (6B0)
plat = HAL_PLATFORM_I6;
strcpy(chipId, val == 0xEF ?
strcpy(chipId, series == 0xEF ?
"SSC32x" : "SSC33x");
chnCount = I6_VENC_CHN_NUM;
chnState = (hal_chnstate*)i6_state;
Expand Down

0 comments on commit 72a2654

Please sign in to comment.