Go to the documentation of this file.
8 if(
buffer == NULL)
return 0;
9 uint8_t* p = (uint8_t*)
buffer;
11 val = (p[0]) + (p[1] << 8) + (p[2] << 16) + (p[3] << 24);
17 uint8_t* p = (uint8_t*)
buffer;
18 for(
int i = 0; i < 4; i++) {
25 if(section == NULL)
return -1;
28 const uint8_t* p = (
const uint8_t*)
buffer;
31 memcpy(section->
name, p,
sizeof(section->
name));
32 p +=
sizeof(section->
name);
36 p +=
sizeof(section->
size);
40 p +=
sizeof(section->
offset);
48 p +=
sizeof(section->
type);
52 p +=
sizeof(section->
flags);
58 if(
buffer == NULL)
return -1;
59 if(sbr == NULL)
return -1;
63 const uint8_t* p = (uint8_t*)
buffer;
85 if(
buffer == NULL)
return -1;
86 if(sbr == NULL)
return -1;
90 uint8_t* p = (uint8_t*)
buffer;
129 if(sbr_section == NULL)
return false;
135 if(sbr_section == NULL)
return false;
147 if(sbr_section->
name[0] == 0 || ((uint8_t)sbr_section->
name[0]) == 0xFF) {
159 uint8_t* p = (uint8_t*)
buffer;
161 for(
unsigned int i = 0; i <
size; i++) {
173 assert(sbr_section != NULL);
178 assert(sbr_section != NULL);
183 assert(sbr_section != NULL);
184 sbr_section->
offset = offset;
188 assert(sbr_section != NULL);
193 assert(sbr_section != NULL);
198 assert(sbr_section != NULL);
207 assert(sbr_section != NULL);
208 if(ignore_checksum) {
216 assert(sbr_section != NULL);
222 sbr_section->
flags |= compression;
#define SBR_MAX_NUM_SECTIONS
static uint32_t read_uint32_t(const void *buffer)
void sbr_section_set_offset(SBR_SECTION *sbr_section, uint32_t offset)
void sbr_section_set_ignore_checksum(SBR_SECTION *sbr_section, bool ignore_checksum)
bool sbr_section_get_ignore_checksum(const SBR_SECTION *sbr_section)
static const uint8_t SBR_IDENTIFIER[SBR_IDENTIFIER_SIZE]
uint32_t sbr_initial_checksum()
void sbr_section_set_type(SBR_SECTION *sbr_section, uint8_t type)
std::uint32_t checksum(const void *buffer, std::size_t size, uint32_t prevChecksum)
#define SBR_SECTION_FLAG_COMPRESSION_MASK
SBR_COMPRESSION sbr_section_get_compression(const SBR_SECTION *sbr_section)
void sbr_section_set_bootable(SBR_SECTION *sbr_section, bool bootable)
std::vector< std::uint8_t > buffer
SBR_SECTION sections[SBR_MAX_NUM_SECTIONS]
bool sbr_section_is_valid(const SBR_SECTION *sbr_section)
void sbr_section_set_checksum(SBR_SECTION *sbr_section, uint32_t checksum)
constexpr auto size(const C &c) -> decltype(c.size())
#define SBR_SECTION_NAME_MAX_SIZE
uint32_t sbr_compute_checksum_prev(const void *buffer, uint32_t size, uint32_t prev_checksum)
bool sbr_section_get_bootable(const SBR_SECTION *sbr_section)
void sbr_section_set_name(SBR_SECTION *sbr_section, const char *name)
#define SBR_IDENTIFIER_SIZE
char name[SBR_SECTION_NAME_MAX_SIZE]
static void write_uint32_t(void *buffer, uint32_t val)
uint32_t sbr_compute_checksum(const void *buffer, uint32_t size)
#define SBR_SECTION_FLAG_BOOTABLE
#define SBR_SECTION_FLAG_IGNORE_CHECKSUM
void sbr_section_set_size(SBR_SECTION *sbr_section, uint32_t size)
void sbr_section_set_compression(SBR_SECTION *sbr_section, SBR_COMPRESSION compression)
int sbr_parse(const void *buffer, uint32_t size, SBR *sbr)
uint8_t identifier[SBR_IDENTIFIER_SIZE]
int sbr_serialize(const SBR *sbr, void *buffer, uint32_t max_size)
static int read_section(const void *buffer, uint32_t size, SBR_SECTION *section)
depthai
Author(s): Martin Peterlin
autogenerated on Sat Mar 22 2025 02:58:19