HD_RESULT parse_h26x_desc(UINT32 codec, UINT32 src_addr, UINT32 size, BOOL *is_desc)
{
HD_RESULT r = HD_OK;
UINT32 start_code = 0, count = 0;
UINT8 *ptr8 = NULL;
if (src_addr == 0) {
printf("buf_addr is 0\r\n");
return HD_ERR_NG;
}
if (size == 0) {
printf("size is 0\r\n");
return HD_ERR_NG;
}
if (!is_desc) {
printf("is_desc is null\r\n");
return HD_ERR_NG;
}
ptr8 = (UINT8 *)src_addr;
count = size;
if (codec == HD_CODEC_TYPE_H264) {
while (count--) {
// search start code to skip (sps, pps)
if ((*ptr8 == 0x00) && (*(ptr8 + 1) == 0x00) && (*(ptr8 + 2) == 0x00) && (*(ptr8 + 3) == 0x01)) {
start_code++;
}
if (start_code == 2) {
*is_desc = TRUE;
return HD_OK;
}
ptr8++;
}
} else if (codec == HD_CODEC_TYPE_H265) {
while (count--) {
// search start code to skip (vps, sps, pps)
if ((*ptr8 == 0x00) && (*(ptr8 + 1) == 0x00) && (*(ptr8 + 2) == 0x00) && (*(ptr8 + 3) == 0x01)) {
start_code++;
}
if (start_code == 3) {
*is_desc = TRUE;
return HD_OK;
}
ptr8++;
}
} else {
printf("unknown codec (%d)\r\n", codec);
return HD_ERR_NG;
}
*is_desc = FALSE;
return r;
}