This instance was upgraded to Heptapod 0.20.1 today

Commit d863be5c authored by Alessandro Profiti's avatar Alessandro Profiti

mlv: ELNS minor code review

--HG--
branch : manual_lens_info
parent 3c11a74e6e9f
......@@ -55,33 +55,40 @@ void mlv_fill_lens(mlv_lens_hdr_t *hdr, uint64_t start_timestamp)
hdr->autofocusMode = af_mode;
hdr->flags = 0;
char name[33];
char buf[33];
snprintf(name, 32, "%s", lens_info.name);
snprintf(buf, sizeof(buf), "%X%08X", (uint32_t) (lens_info.lens_serial >> 32), (uint32_t)(lens_info.lens_serial & 0xFFFFFFFF));
strncpy((char *)hdr->lensName, name, 32);
strncpy((char *)hdr->lensName, lens_info.name, 32);
strncpy((char *)hdr->lensSerial, buf, 32);
}
void mlv_fill_elns(mlv_elns_hdr_t *hdr, uint64_t start_timestamp){
void mlv_fill_elns(mlv_elns_hdr_t **hdr, uint64_t start_timestamp){
/* Calculate total block length: header + fixed data + variable lensName string */
int string_length = strlen(lens_info.name);
int block_length = (string_length + sizeof(mlv_elns_hdr_t) + 3) & ~3;
mlv_elns_hdr_t *hdr_ptr = malloc(block_length);
/* prepare header */
mlv_set_type((mlv_hdr_t *)hdr, "ELNS");
mlv_set_timestamp((mlv_hdr_t *)hdr, start_timestamp);
hdr->blockSize = sizeof(mlv_elns_hdr_t);
char bufName[65];
snprintf(bufName, 64, "%s", lens_info.name);
strncpy((char *)hdr->lensName, bufName, 64);
hdr->focalLengthMin = lens_info.lens_focal_min;
hdr->focalLengthMax = lens_info.lens_focal_max;
hdr->apertureMin = RAW2VALUE(aperture, lens_info.raw_aperture_min) / 10.0;
hdr->apertureMax = RAW2VALUE(aperture, lens_info.raw_aperture_max) / 10.0;
hdr->version = lens_info.lens_version;
hdr->extenderInfo = lens_info.lens_extender;
hdr->capabilities = lens_info.lens_capabilities;
hdr->chipped = lens_info.lens_exists;
mlv_set_type((mlv_hdr_t *)hdr_ptr, "ELNS");
mlv_set_timestamp((mlv_hdr_t *)hdr_ptr, start_timestamp);
hdr_ptr->blockSize = block_length;
/* Fill data */
hdr_ptr->focalLengthMin = lens_info.lens_focal_min;
hdr_ptr->focalLengthMax = lens_info.lens_focal_max;
hdr_ptr->apertureMin = RAW2VALUE(aperture, lens_info.raw_aperture_min) * 10.0;
hdr_ptr->apertureMax = RAW2VALUE(aperture, lens_info.raw_aperture_max) * 10.0;
hdr_ptr->version = lens_info.lens_version;
hdr_ptr->extenderInfo = lens_info.lens_extender;
hdr_ptr->capabilities = lens_info.lens_capabilities;
hdr_ptr->chipped = lens_info.lens_exists;
/* Store lensName string at the end of mlv_elns_hdr_t */
char *lens_hdr_payload = (char *)&hdr_ptr[1];
snprintf(lens_hdr_payload, string_length + 1, "%s", lens_info.name);
/* update block with new values */
*hdr = hdr_ptr;
}
void mlv_fill_wbal(mlv_wbal_hdr_t *hdr, uint64_t start_timestamp)
......
......@@ -175,8 +175,7 @@ typedef struct {
uint8_t extenderInfo; /* extender information, if provided by camera */
uint8_t capabilities; /* capability information, if provided by camera */
uint8_t chipped; /* when not zero, lens is communicating with camera */
uint8_t lensName[64]; /* full lens string, null terminated */
// TODO: Review Specs
/* uint8_t lensName[variable]; full lens string, optional null terminated */
} mlv_elns_hdr_t;
typedef struct {
......@@ -302,10 +301,10 @@ typedef struct {
void mlv_fill_rtci(mlv_rtci_hdr_t *hdr, uint64_t start_timestamp);
void mlv_fill_expo(mlv_expo_hdr_t *hdr, uint64_t start_timestamp);
void mlv_fill_lens(mlv_lens_hdr_t *hdr, uint64_t start_timestamp);
void mlv_fill_elns(mlv_elns_hdr_t *hdr, uint64_t start_timestamp);
void mlv_fill_idnt(mlv_idnt_hdr_t *hdr, uint64_t start_timestamp);
void mlv_fill_wbal(mlv_wbal_hdr_t *hdr, uint64_t start_timestamp);
void mlv_fill_styl(mlv_styl_hdr_t *hdr, uint64_t start_timestamp);
void mlv_fill_styl(mlv_styl_hdr_t *hdr, uint64_t start_timestamp);
void mlv_fill_elns(mlv_elns_hdr_t **hdr, uint64_t start_timestamp);
void mlv_build_vers(mlv_vers_hdr_t **hdr, uint64_t start_timestamp, const char *version_string);
/* randomize the 64 bits passed in parameter using LFSR */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment