Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/modules/lua/lua_lens.c b/modules/lua/lua_lens.c
- --- a/modules/lua/lua_lens.c
- +++ b/modules/lua/lua_lens.c
- @@ -82,7 +82,7 @@
- if(!strcmp(key, "name"))
- {
- LUA_PARAM_STRING(value, 3);
- - strncpy(lens_info.name, value, 31);
- + strncpy(lens_info.name, value, sizeof(lens_info.name)-1);
- }
- else if(!strcmp(key, "exists"))
- {
- diff --git a/modules/mlv_rec/mlv.c b/modules/mlv_rec/mlv.c
- --- a/modules/mlv_rec/mlv.c
- +++ b/modules/mlv_rec/mlv.c
- @@ -55,10 +55,33 @@
- hdr->autofocusMode = af_mode;
- hdr->flags = 0;
- - strncpy((char *)hdr->lensName, lens_info.name, 32);
- + char name[33];
- + snprintf(name, 32, "%s", lens_info.name);
- +
- + strncpy((char *)hdr->lensName, name, 32);
- strncpy((char *)hdr->lensSerial, "", 32);
- }
- +void mlv_fill_elns(mlv_elns_hdr_t *hdr, uint64_t start_timestamp){
- + /* 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 = lens_info.raw_aperture_min;
- + hdr->apertureMax = lens_info.raw_aperture_max;
- + hdr->version = lens_info.lens_version;
- + hdr->extenderInfo = lens_info.lens_extender;
- + hdr->capabilities = lens_info.lens_capabilities;
- + hdr->chipped = lens_info.lens_exists;
- +}
- +
- void mlv_fill_wbal(mlv_wbal_hdr_t *hdr, uint64_t start_timestamp)
- {
- /* prepare header */
- diff --git a/modules/mlv_rec/mlv.h b/modules/mlv_rec/mlv.h
- --- a/modules/mlv_rec/mlv.h
- +++ b/modules/mlv_rec/mlv.h
- @@ -164,6 +164,21 @@
- } mlv_lens_hdr_t;
- typedef struct {
- + uint8_t blockType[4]; /* ELNS - Extended LENS block with longer lens name and optional fields, depending on camera */
- + uint32_t blockSize;
- + uint64_t timestamp;
- + uint16_t focalLengthMin; /* shortest focal length in mm */
- + uint16_t focalLengthMax; /* longest focal length in mm */
- + uint16_t apertureMin; /* lowest f-number * 100 */
- + uint16_t apertureMax; /* highest f-number * 100 */
- + uint32_t version; /* lens internal version number, if available */
- + 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 */
- +} mlv_elns_hdr_t;
- +
- +typedef struct {
- uint8_t blockType[4];
- uint32_t blockSize; /* total frame size */
- uint64_t timestamp; /* hardware counter timestamp for this frame (relative to recording start) */
- @@ -286,6 +301,7 @@
- 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);
- diff --git a/modules/mlv_rec/mlv_dump.c b/modules/mlv_rec/mlv_dump.c
- --- a/modules/mlv_rec/mlv_dump.c
- +++ b/modules/mlv_rec/mlv_dump.c
- @@ -1590,6 +1590,7 @@
- lv_rec_file_footer_t lv_rec_footer;
- mlv_file_hdr_t main_header;
- mlv_lens_hdr_t lens_info;
- + mlv_elns_hdr_t elns_info;
- mlv_expo_hdr_t expo_info;
- mlv_idnt_hdr_t idnt_info;
- mlv_wbal_hdr_t wbal_info;
- @@ -1600,6 +1601,7 @@
- /* initialize stuff */
- memset(&lv_rec_footer, 0x00, sizeof(lv_rec_file_footer_t));
- memset(&lens_info, 0x00, sizeof(mlv_lens_hdr_t));
- + memset(&elns_info, 0x00, sizeof(mlv_elns_hdr_t));
- memset(&expo_info, 0x00, sizeof(mlv_expo_hdr_t));
- memset(&idnt_info, 0x00, sizeof(mlv_idnt_hdr_t));
- memset(&wbal_info, 0x00, sizeof(mlv_wbal_hdr_t));
- @@ -2847,6 +2849,46 @@
- }
- }
- }
- + else if(!memcmp(buf.blockType, "ELNS", 4))
- + {
- + uint32_t hdr_size = MIN(sizeof(mlv_elns_hdr_t), buf.blockSize);
- +
- + if(fread(&elns_info, hdr_size, 1, in_file) != 1)
- + {
- + print_msg(MSG_ERROR, "File ends in the middle of a block\n");
- + goto abort;
- + }
- +
- + /* skip remaining data, if there is any */
- + file_set_pos(in_file, position + elns_info.blockSize, SEEK_SET);
- +
- + lua_handle_hdr(lua_state, buf.blockType, &elns_info, sizeof(elns_info));
- +
- + if(verbose)
- + {
- + //TODO:
- + print_msg(MSG_INFO, " Name: '%s'\n", elns_info.lensName);
- + print_msg(MSG_INFO, " Focal Length Min: %d mm\n", elns_info.focalLengthMin);
- + print_msg(MSG_INFO, " Focal Length Max: %d mm\n", elns_info.focalLengthMax);
- + print_msg(MSG_INFO, " Aperture Min: f/%.2f\n", elns_info.apertureMin);
- + print_msg(MSG_INFO, " Aperture Max: f/%.2f\n", elns_info.apertureMax);
- + print_msg(MSG_INFO, " Version: %d\n", elns_info.version);
- + print_msg(MSG_INFO, " Extender Info: 0x%02X\n", elns_info.extenderInfo);
- + print_msg(MSG_INFO, " Capabilities: 0x%02X\n", elns_info.capabilities);
- + print_msg(MSG_INFO, " Chipped: 0x%02X\n", elns_info.chipped);
- + }
- +
- + if(mlv_output && !no_metadata_mode && (!extract_block || !strncasecmp(extract_block, (char*)elns_info.blockType, 4)))
- + {
- + /* correct header size if needed */
- + elns_info.blockSize = sizeof(mlv_elns_hdr_t);
- + if(fwrite(&elns_info, elns_info.blockSize, 1, out_file) != 1)
- + {
- + print_msg(MSG_ERROR, "Failed writing into .MLV file\n");
- + goto abort;
- + }
- + }
- + }
- else if(!memcmp(buf.blockType, "INFO", 4))
- {
- mlv_info_hdr_t block_hdr;
- diff --git a/modules/mlv_rec/mlv_rec.c b/modules/mlv_rec/mlv_rec.c
- --- a/modules/mlv_rec/mlv_rec.c
- +++ b/modules/mlv_rec/mlv_rec.c
- @@ -189,6 +189,7 @@
- static mlv_expo_hdr_t last_expo_hdr;
- static mlv_lens_hdr_t last_lens_hdr;
- +static mlv_elns_hdr_t last_elns_hdr;
- static mlv_wbal_hdr_t last_wbal_hdr;
- static mlv_styl_hdr_t last_styl_hdr;
- @@ -1442,14 +1443,17 @@
- trace_write(raw_rec_trace_ctx, "[polling_cbr] queueing INFO blocks");
- mlv_expo_hdr_t *expo_hdr = malloc(sizeof(mlv_expo_hdr_t));
- mlv_lens_hdr_t *lens_hdr = malloc(sizeof(mlv_lens_hdr_t));
- + mlv_elns_hdr_t *elns_hdr = malloc(sizeof(mlv_elns_hdr_t));
- mlv_wbal_hdr_t *wbal_hdr = malloc(sizeof(mlv_wbal_hdr_t));
- mlv_fill_expo(expo_hdr, mlv_start_timestamp);
- mlv_fill_lens(lens_hdr, mlv_start_timestamp);
- + mlv_fill_elns(elns_hdr, mlv_start_timestamp);
- mlv_fill_wbal(wbal_hdr, mlv_start_timestamp);
- msg_queue_post(mlv_block_queue, (uint32_t) expo_hdr);
- msg_queue_post(mlv_block_queue, (uint32_t) lens_hdr);
- + msg_queue_post(mlv_block_queue, (uint32_t) elns_hdr);
- msg_queue_post(mlv_block_queue, (uint32_t) wbal_hdr);
- }
- @@ -2562,6 +2566,7 @@
- mlv_rtci_hdr_t rtci_hdr;
- mlv_expo_hdr_t expo_hdr;
- mlv_lens_hdr_t lens_hdr;
- + mlv_elns_hdr_t elns_hdr;
- mlv_idnt_hdr_t idnt_hdr;
- mlv_wbal_hdr_t wbal_hdr;
- mlv_styl_hdr_t styl_hdr;
- @@ -2569,6 +2574,7 @@
- mlv_fill_rtci(&rtci_hdr, mlv_start_timestamp);
- mlv_fill_expo(&expo_hdr, mlv_start_timestamp);
- mlv_fill_lens(&lens_hdr, mlv_start_timestamp);
- + mlv_fill_elns(&elns_hdr, mlv_start_timestamp);
- mlv_fill_idnt(&idnt_hdr, mlv_start_timestamp);
- mlv_fill_wbal(&wbal_hdr, mlv_start_timestamp);
- mlv_fill_styl(&styl_hdr, mlv_start_timestamp);
- @@ -2580,10 +2586,12 @@
- idnt_hdr.timestamp = 4;
- wbal_hdr.timestamp = 5;
- styl_hdr.timestamp = 6;
- + elns_hdr.timestamp = 7;
- mlv_write_hdr(f, (mlv_hdr_t *)&rtci_hdr);
- mlv_write_hdr(f, (mlv_hdr_t *)&expo_hdr);
- mlv_write_hdr(f, (mlv_hdr_t *)&lens_hdr);
- + mlv_write_hdr(f, (mlv_hdr_t *)&elns_hdr);
- mlv_write_hdr(f, (mlv_hdr_t *)&idnt_hdr);
- mlv_write_hdr(f, (mlv_hdr_t *)&wbal_hdr);
- mlv_write_hdr(f, (mlv_hdr_t *)&styl_hdr);
- @@ -3092,13 +3100,16 @@
- mlv_expo_hdr_t old_expo = last_expo_hdr;
- mlv_lens_hdr_t old_lens = last_lens_hdr;
- + mlv_elns_hdr_t old_elns = last_elns_hdr;
- mlv_fill_expo(&last_expo_hdr, mlv_start_timestamp);
- mlv_fill_lens(&last_lens_hdr, mlv_start_timestamp);
- + mlv_fill_elns(&last_elns_hdr, mlv_start_timestamp);
- /* update timestamp for comparing content changes */
- old_expo.timestamp = last_expo_hdr.timestamp;
- old_lens.timestamp = last_lens_hdr.timestamp;
- + old_elns.timestamp = last_elns_hdr.timestamp;
- /* write new state if something changed */
- if(memcmp(&last_expo_hdr, &old_expo, sizeof(mlv_expo_hdr_t)))
- @@ -3115,6 +3126,13 @@
- memcpy(hdr, &last_lens_hdr, sizeof(mlv_lens_hdr_t));
- msg_queue_post(mlv_block_queue, (uint32_t) hdr);
- }
- + /* write new state if something changed */
- + if(memcmp(&last_elns_hdr, &old_elns, sizeof(mlv_elns_hdr_t)))
- + {
- + mlv_hdr_t *hdr = malloc(sizeof(mlv_elns_hdr_t));
- + memcpy(hdr, &last_elns_hdr, sizeof(mlv_elns_hdr_t));
- + msg_queue_post(mlv_block_queue, (uint32_t) hdr);
- + }
- }
- if(mlv_update_styl && (mlv_metadata & MLV_METADATA_SPORADIC))
- diff --git a/modules/silent/silent.c b/modules/silent/silent.c
- --- a/modules/silent/silent.c
- +++ b/modules/silent/silent.c
- @@ -25,6 +25,7 @@
- extern WEAK_FUNC(ret_0) void mlv_fill_rtci(mlv_rtci_hdr_t *hdr, uint64_t start_timestamp);
- extern WEAK_FUNC(ret_0) void mlv_fill_expo(mlv_expo_hdr_t *hdr, uint64_t start_timestamp);
- extern WEAK_FUNC(ret_0) void mlv_fill_lens(mlv_lens_hdr_t *hdr, uint64_t start_timestamp);
- +extern WEAK_FUNC(ret_0) void mlv_fill_elns(mlv_elns_hdr_t *hdr, uint64_t start_timestamp);
- extern WEAK_FUNC(ret_0) void mlv_fill_idnt(mlv_idnt_hdr_t *hdr, uint64_t start_timestamp);
- extern WEAK_FUNC(ret_0) void mlv_fill_wbal(mlv_wbal_hdr_t *hdr, uint64_t start_timestamp);
- extern WEAK_FUNC(ret_0) void mlv_fill_styl(mlv_styl_hdr_t *hdr, uint64_t start_timestamp);
- @@ -294,6 +295,7 @@
- mlv_rtci_hdr_t rtci_hdr;
- mlv_expo_hdr_t expo_hdr;
- mlv_lens_hdr_t lens_hdr;
- + mlv_elns_hdr_t elns_hdr;
- mlv_idnt_hdr_t idnt_hdr;
- mlv_wbal_hdr_t wbal_hdr;
- mlv_styl_hdr_t styl_hdr;
- @@ -407,7 +409,8 @@
- mlv_fill_rtci(&rtci_hdr, mlv_start_timestamp);
- mlv_fill_expo(&expo_hdr, mlv_start_timestamp);
- mlv_fill_lens(&lens_hdr, mlv_start_timestamp);
- -
- + mlv_fill_elns(&elns_hdr, mlv_start_timestamp);
- +
- if(capture_time_ms > 0)
- {
- expo_hdr.shutterValue = 1000 * capture_time_ms;
- @@ -416,7 +419,8 @@
- if (FIO_WriteFile(save_file, &rtci_hdr, rtci_hdr.blockSize) != (int)rtci_hdr.blockSize) goto write_error;
- if (FIO_WriteFile(save_file, &expo_hdr, expo_hdr.blockSize) != (int)expo_hdr.blockSize) goto write_error;
- if (FIO_WriteFile(save_file, &lens_hdr, lens_hdr.blockSize) != (int)lens_hdr.blockSize) goto write_error;
- -
- + if (FIO_WriteFile(save_file, &elns_hdr, elns_hdr.blockSize) != (int)elns_hdr.blockSize) goto write_error;
- +
- memset(&vidf_hdr, 0, sizeof(mlv_vidf_hdr_t));
- mlv_set_type((mlv_hdr_t *)&vidf_hdr, "VIDF");
- mlv_set_timestamp((mlv_hdr_t *)&vidf_hdr, mlv_start_timestamp);
- diff --git a/scripts/lens.lua b/scripts/lens.lua
- --- a/scripts/lens.lua
- +++ b/scripts/lens.lua
- @@ -19,9 +19,19 @@
- -- serial -> Lens Serial Number (optional)
- -- f_values -> Available f-stop for selected lens (optional)
- - { name = "My Lens", focal_length = 50 },
- - { name = "My Other Lens", focal_length = 25, manual_aperture = 2.8, f_values = {"2.8","4","5.6","8"} },
- - { name = "My Zoom Lens", focal_length = 105, manual_aperture = 4, focal_min = 70, focal_max = 200, serial = 123456789 },
- +{ name = "My Lens", focal_length = 50, serial = 123456789 },
- +{ name = "My Other Lens", focal_length = 25, manual_aperture = 2.8, f_values = {"2.8","4","5.6","8"} },
- +{ name = "My Zoom Lens", focal_length = 25, manual_aperture = 4, focal_length = 105, focal_min = 70, focal_max = 200 },
- +{ name = "Yashica ML 50mm f1.9", focal_length = 50, serial = 123, manual_aperture = 5 },
- +{ name = "Portrait 85mm", focal_length = 85, manual_aperture = 2 },
- +{ name = "Portrait 105mm", focal_length = 105, focal_min = 105, focal_max = 105, manual_aperture = 8 },
- +{ name = "Pentax SMC 80-200mm f4,5", focal_length = 200, manual_aperture = 4.5, serial = 123456789 },
- +{ name = "Pentax SMC 80-200mm f4,5 with focal length min-max", focal_length = 200, focal_min = 80, focal_max = 200, manual_aperture = 4.5, serial = 123456789 },
- +{ name = "Portrait 125mm 2.8", focal_length = 125, manual_aperture = 2.8 },
- +{ name = "Portrait 200mm 5.6", focal_length = 200, focal_min = 200, focal_max = 200, manual_aperture = 5.6 },
- +{ name = "Portrait 125mm 1.4", focal_length = 125, manual_aperture = 1.4 },
- +{ name = "Carl Zeiss Vario-Sonnar T* 100-300 mm f/ 4.5-5.6 C/Y", focal_length = 150, focal_min = 100, focal_max = 300, manual_aperture = 4.5, f_values = {"4.5","8","11","16","22","32"}, serial = 123456789 },
- +{ name = "Carl Zeiss Jena 28-70mm f/3.5-4.5 MC Macro Jenazoom Super", focal_length = 35, focal_min = 24, focal_max = 70, manual_aperture = 3.5, f_values = {"3.5","4.5","8","11","16","22","32"}, serial = 123456789 },
- -- Zeiss ZF.2 manual lenses Nikon mount - these work with the lens profiles that ship with Adobe Camera Raw
- diff --git a/src/focus.c b/src/focus.c
- --- a/src/focus.c
- +++ b/src/focus.c
- @@ -265,14 +265,31 @@
- return;
- }
- - bmp_printf( font, x, y,
- - "Lens: %s, %dmm f/%d.%d",
- - lens_info.name,
- - lens_info.focal_len,
- - lens_info.aperture / 10,
- - lens_info.aperture % 10
- - );
- -
- + // TODO:
- + if(strlen(lens_info.name) > 42)
- + {
- + char lensName[42];
- + snprintf(lensName, 42, "%s", lens_info.name);
- +
- + bmp_printf( font, x, y,
- + "Lens: %s..., %dmm f/%d.%d",
- + lensName,
- + lens_info.focal_len,
- + lens_info.aperture / 10,
- + lens_info.aperture % 10
- + );
- + }
- + else
- + {
- + bmp_printf( font, x, y,
- + "Lens: %s, %dmm f/%d.%d",
- + lens_info.name,
- + lens_info.focal_len,
- + lens_info.aperture / 10,
- + lens_info.aperture % 10
- + );
- + }
- +
- if (!lv)
- {
- y += height;
- diff --git a/src/lens.h b/src/lens.h
- --- a/src/lens.h
- +++ b/src/lens.h
- @@ -37,7 +37,7 @@
- struct lens_info
- {
- void * token;
- - char name[ 32 ];
- + char name[ 64 ];
- unsigned focal_len; // in mm
- unsigned focus_dist; // in cm
- unsigned IS; // PROP_LV_LENS_STABILIZE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement