Assign lens focal length and name for non cpu lenses

Started by Lars Steenhoff, October 29, 2016, 12:04:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

a1ex

Quote from: aprofiti on February 09, 2018, 02:19:02 PM
It happens also to me, it's a problem I noticed before and asked for feedback some posts ago.

Sorry, didn't notice it before. Can you try this change? (based on api_test.lua)

diff -r e7ca98e11cd4 scripts/lib/xmp.lua
--- a/scripts/lib/xmp.lua
+++ b/scripts/lib/xmp.lua
@@ -37,3 +37,3 @@
function xmp.get_sidecar_filename()
-    return string.format("DCIM/%03dCANON/%s%04d.XMP", dryos.shooting_card.folder_number, dryos.prefix, dryos.shooting_card.file_number)
+    return dryos.dcim_dir.path ..  dryos.image_prefix .. string.format("%04d", dryos.shooting_card.file_number) .. ".XMP"
end


This should also cover camera models that do not use 100CANON, but 100EOS5D or whatever. There are some unresolved issues with certain settings, such as _MG_1234 or custom image prefix settings on 5D3, maybe also other models (issues revealed by api_test.lua).

Quote
@a1ex maybe it is related to commit 396a8a9 or b0b332a

Yes, clearly. I'm afraid the fix must be done in the memory backend.

ToniX

@Walter Schulz    Thanks. I will add few second more, over the 5s as recommended by the UG. :D
600D - EFs18-55 ISII

Lars Steenhoff

I tested the last manual
lens info build from
experiments, and I had some customs scripts i made that failed to load because the filename was too long, did the max filename got reduced recently?

Walter Schulz


aprofiti

Quote from: a1ex on February 09, 2018, 04:35:19 PM
This should also cover camera models that do not use 100CANON, but 100EOS5D or whatever. There are some unresolved issues with certain settings, such as _MG_1234 or custom image prefix settings on 5D3, maybe also other models (issues revealed by api_test.lua).

Yes, I made a quick test on a custom build and It appears to work. Thank You a1ex!

aprofiti

I made a new PR with experimental 64byte lens name and config.lua rework.

@dfort Can you try it and check if extended name is saved correctly? I tested mostly with silent pictures and some raw video with mlv_rec, but no tests with mlv_lite.

New version of config's lib should be backward compatible with script which use previous version, but it needs to be tested further.
Maybe is better to post a description of what's changed in lua's discussion after a review.

EDIT: There is an issue with the refactor of config.lua code, It work with previous version but not with the one in the PR. I need to figure out where is the problem... I'll try tomorrow if I have some time

dfort

Ok, let me know when it is ready to test. The easiest way to check it with the Zeiss Makro-Planar 100mm ZF.2 lens because the Zeiss ZF.2 lenses work out of the box with Adobe Camera Raw. That's how I first found out about the lens name length issue.

aprofiti

Quote from: dfort on February 16, 2018, 07:22:02 AM
Ok, let me know when it is ready to test. The easiest way to check it with the Zeiss Makro-Planar 100mm ZF.2 lens because the Zeiss ZF.2 lenses work out of the box with Adobe Camera Raw. That's how I first found out about the lens name length issue.

Fixed Typos introduced right before committing, I'll refactor later when I'm not in a hurry.

Particular attention should be paid to "ELNS" Block metadata. Please check validity with FRSP and Raw Rec (mlv_rec, mlv_lite).
Let me know  ;)

dfort

First test, using just the unmodified lua script, simply remove a CPU lens and reattach in photo mode (not in LV):

ML ASSERT:
0
at ../../src/mem.c:781 (__mem_malloc), task PropMgr
lv:0 mode:3

PropMgr stack: 14cc00 [14cf68-14bf68]
0x00AB01DC @ abb4f8:14cce0
0xUNKNOWN  @ ab02c0:14ccc0
0x00081A94 @ ad1170:14cc80
0x0007F5E4 @ 81ad0:14cc30
0x0007EF78 @ 7f640:14cc00

Magic Lantern version : Nightly.2018Feb16.700D115
Mercurial changeset   : c274347c2d19 (manual_lens_info_64byte) tip
Built on 2018-02-16 15:04:22 UTC by rosiefort@RosieFoComputer.
Free Memory  : 128K + 2782K


Next test, activate a few lenses with long names, and again in photo mode shoot a CR2.

Here's the XMP sidecar file:

<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c011 79.156380, 2014/05/21-23:38:37        ">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <rdf:Description rdf:about=""
    xmlns:exif="http://ns.adobe.com/exif/1.0/"
    xmlns:aux="http://ns.adobe.com/exif/1.0/aux/"
    exif:ExifVersion="0230"
    exif:FocalLength="100/1"
    aux:SerialNumber="0"
    exif:FNumber="20/10"
    aux:Lens="Zeiss Makro-Planar T* 2/100 ZF.2">
  </rdf:Description>
</rdf:RDF>
</x:xmpmeta>


But it also saved an ASSERT log.

ML ASSERT:
0
at ../../src/mem.c:844 (__mem_free), task PropMgr
lv:0 mode:3

PropMgr stack: 14cc68 [14cf68-14bf68]
0x00AB047C @ abb798:14cd00
0xUNKNOWN  @ ab0560:14cce0
0xUNKNOWN  @ abfbb0:14ccd0
0x00AD7094 @ abfca4:14ccc8
0x00AAB8DC @ ad7100:14ccb8
0x0007F5E4 @ 81fcc:14cc98
0x0007EF78 @ 7f640:14cc68

Magic Lantern version : Nightly.2018Feb16.700D115
Mercurial changeset   : c274347c2d19 (manual_lens_info_64byte) tip
Built on 2018-02-16 15:04:22 UTC by rosiefort@RosieFoComputer.
Free Memory  : 128K + 2774K


FRSP DNG, the XMP file looks fine but the ASSERT log is slightly different:

ML ASSERT:
0
at ../../src/mem.c:844 (__mem_free), task PropMgr
lv:0 mode:3

PropMgr stack: 14cc68 [14cf68-14bf68]
0x00AB354C @ abe868:14cd00
0xUNKNOWN  @ ab3630:14cce0
0xUNKNOWN  @ ac2c80:14ccd0
0x00ADA164 @ ac2d74:14ccc8
0x00AAE9AC @ ada1d0:14ccb8
0x0007F5E4 @ 81fcc:14cc98
0x0007EF78 @ 7f640:14cc68

Magic Lantern version : Nightly.2018Feb16.700D115
Mercurial changeset   : c274347c2d19 (manual_lens_info_64byte) tip
Built on 2018-02-16 15:04:22 UTC by rosiefort@RosieFoComputer.
Free Memory  : 128K + 2737K


FRSP MLV using mlv_lite and mlv_dump from your manual_lens_info_64byte branch (current mlv_dump skips the ELNS block):

Block: LENS
  Offset: 0x000001f0
    Size: 96
    Time: 1094.548000 ms
     Name:        'Zeiss Makro-Planar T* 2/100 ZF.'
     Serial:      '000000000'
     Focal Len:   100 mm
     Focus Dist:  0 mm
     Aperture:    f/2.00
     IS Mode:     0
     AF Mode:     3
     Lens ID:     0x00000000
     Flags:       0x00000000
Block: ELNS
  Offset: 0x00000250
    Size: 95
    Time: 1094.573000 ms
     Name:                'Zeiss Makro-Planar T* 2/100 ZF.2'
     Focal Length Min:    0 mm
     Focal Length Max:    0 mm
     Aperture Min:        f/0.00
     Aperture Max:        f/0.00
     Version:             0
     Extender Info:       0x00
     Capabilities:        0x00
     Chipped:             0x01


Yay! However, it also saved an XMP sidecar file. The XMP file looks fine but I don't see the point in saving an XMP file when shooting MLV. In my test the MLV file is named 28160000.MLV and the XMP file is named IMG_2816.XMP.

There was also an ASSERT log:

ML ASSERT:
0
at ../../src/mem.c:844 (__mem_free), task PropMgr
lv:0 mode:3

PropMgr stack: 14cc68 [14cf68-14bf68]
0x00AB738C @ ac26a8:14cd00
0xUNKNOWN  @ ab7470:14cce0
0xUNKNOWN  @ ac6ac0:14ccd0
0x00ADDFA4 @ ac6bb4:14ccc8
0x00AB27EC @ ade010:14ccb8
0x0007F5E4 @ 81fcc:14cc98
0x0007EF78 @ 7f640:14cc68

Magic Lantern version : Nightly.2018Feb16.700D115
Mercurial changeset   : c274347c2d19 (manual_lens_info_64byte) tip
Built on 2018-02-16 15:04:22 UTC by rosiefort@RosieFoComputer.
Free Memory  : 128K + 2700K


Next I shot several FRSP in MLV format in succession to see what happens if several shots are saved to a single MLV. It wasn't very practical because the console kept popping up with the ASSERT message and it saved a log for each exposure. It saved a single XMP file and in the MLV file each VIDF block was followed by an RTCI, EXPO, LENS and ELNS block. I believe this is by design because when taking still photos you can change lenses while continuing to save to the same MLV file.

Moving on to video tests -- and some good news.

MLV video shot in mlv_lite worked perfectly! This time as expected there was only a single LENS and ELNS block and none after each VIDF block like in the still photo test. The LENS and ELNS blocks have the same information as the still test so I'll save some space on this post and not duplicate it.

MLV shot with mlv_rec and mlv_snd also worked perfectly.

So it looks like you got the movie modes working and only need to get the ASSERT messages in still photo modes figured out. Saving XMP when shooting silent MLV files should also be addressed.


aprofiti

Thank you dfort for the extensive testing :D
Quote from: dfort on February 16, 2018, 05:16:50 PM
So it looks like you got the movie modes working and only need to get the ASSERT messages in still photo modes figured out. Saving XMP when shooting silent MLV files should also be addressed.

The ASSERT messages where introduced after a1ex's attempt to fix issues related to calling lua's property.
He said that a rework of lua's memory backend is necessary to address this problem, so we need to wait news from him.

Regarding sidecar generation when using MLV format, I don't remember if it was happening from before or can be caused by the fix regarding sidecar's filename.

I'll test and look if is an easy task... disabling xmp engine when mlv format is selected should fix this but I have no idea where this can be checked correctly.

a1ex

This one happens when trying to start a task from the property handler. Still, something I have to fix in the backend somehow.

Another issue: I had to delete the old config file (lens.cfg), otherwise got some errors in config.lua. I can try to reproduce if needed.

aprofiti

Quote from: a1ex on February 18, 2018, 04:49:56 PM
Another issue: I had to delete the old config file (lens.cfg), otherwise got some errors in config.lua. I can try to reproduce if needed.

It's because menu are serialized in a different format now (tables), instead simple "config" are key -> value pairs to be backward compatible (is it ok, or i preferable to follow new format?)

a1ex

It's fine by me, but I'd change the config file extension.

a1ex

Quote from: aprofiti on February 16, 2018, 05:39:40 PM
The ASSERT messages where introduced after a1ex's attempt to fix issues related to calling lua's property.
He said that a rework of lua's memory backend is necessary to address this problem, so we need to wait news from him.

Hopefully solved. Wasn't easy (tried the same approach when merging the first PR, but could not pass the tests from selftest.mo, so I ended up committing a workaround - that turned out not to be very good); however, today I've found the issue: yet another quirk in Canon's large memory allocators (the reason why it was crashing after ~1000 blocks or so). Seems to work in my quick tests, but I'd still like to sleep on it before including in lua_fix and crop_rec_4k.

I've extracted a patch for crop_rec_4k with only the changes related to ELNS and 64-byte lens name (mlv_dump, mlv*, silent and lens.h), but I'm afraid I have no more energy left to run any tests today (so I'm not committing it yet). If you try it, please report back.


# HG changeset patch
# User alex@thinkpad
# Date 1518995384 -3600
#      Mon Feb 19 00:09:44 2018 +0100
# Branch crop_rec_4k
# Node ID 804086b3e47771bd72ed123bdd797c608738bf4f
# Parent  5138c0050854c3c44eb2de21cf63c445baa0b245
* Experimental: 64Byte Extended Lens Name
* mlv_dump.c: Fix duplicate ELNS Block processing
* mlv_rec.c: Fix duplicate ELNS Block processing

diff -r 5138c0050854 -r 804086b3e477 modules/lua/lua_lens.c
--- a/modules/lua/lua_lens.c Sat Feb 17 22:37:51 2018 +0100
+++ b/modules/lua/lua_lens.c Mon Feb 19 00:09:44 2018 +0100
@@ -72,7 +72,55 @@
static int luaCB_lens_newindex(lua_State * L)
{
     LUA_PARAM_STRING_OPTIONAL(key, 2, "");
-    if(!strcmp(key, "name") || !strcmp(key, "focal_length") || !strcmp(key, "focus_distance") || !strcmp(key, "hyperfocal") || !strcmp(key, "dof_near") || !strcmp(key, "dof_far") || !strcmp(key, "af"))
+    if(!strcmp(key, "name"))
+    {
+        LUA_PARAM_STRING(value, 3);
+        strncpy(lens_info.name, value, sizeof(lens_info.name)-1);
+    }
+    else if(!strcmp(key, "exists"))
+    {
+        LUA_PARAM_BOOL(value, 3);
+        lens_info.lens_exists = value;
+    }
+    else if(!strcmp(key, "focal_length"))
+    {
+        LUA_PARAM_INT(value, 3);
+        lens_info.focal_len = value;
+    }
+    else if(!strcmp(key, "focal_min"))
+    {
+        LUA_PARAM_INT(value, 3);
+        lens_info.lens_focal_min = value;
+    }
+    else if(!strcmp(key, "focal_max"))
+    {
+        LUA_PARAM_INT(value, 3);
+        lens_info.lens_focal_max = value;
+    }
+    else if(!strcmp(key, "manual_aperture"))
+    {
+        LUA_PARAM_NUMBER(value, 3);
+        lens_info.aperture = (int)(value * 10);
+        lens_info.raw_aperture = VALUE2RAW(aperture, lens_info.aperture);
+    }
+    else if(!strcmp(key, "aperture_min"))
+    {
+        LUA_PARAM_NUMBER(value, 3);
+        int tmp = (int)(value * 10);
+        lens_info.raw_aperture_min = VALUE2RAW(aperture, tmp);
+    }
+    else if(!strcmp(key, "aperture_max"))
+    {
+        LUA_PARAM_NUMBER(value, 3);
+        int tmp = (int)(value * 10);
+        lens_info.raw_aperture_max = VALUE2RAW(aperture, tmp);
+    }
+    else if(!strcmp(key, "serial"))
+    {
+        LUA_PARAM_INT(value, 3);
+        lens_info.lens_serial = value;
+    }
+    else if(!strcmp(key, "focus_distance") || !strcmp(key, "hyperfocal") || !strcmp(key, "dof_near") || !strcmp(key, "dof_far") || !strcmp(key, "af") || !strcmp(key, "is_chipped"))
     {
         return luaL_error(L, "'%s' is readonly!", key);
     }
diff -r 5138c0050854 -r 804086b3e477 modules/mlv_lite/mlv_lite.c
--- a/modules/mlv_lite/mlv_lite.c Sat Feb 17 22:37:51 2018 +0100
+++ b/modules/mlv_lite/mlv_lite.c Mon Feb 19 00:09:44 2018 +0100
@@ -350,7 +350,8 @@
static GUARDED_BY(RawRecTask)   mlv_rawc_hdr_t rawc_hdr;
static GUARDED_BY(RawRecTask)   mlv_idnt_hdr_t idnt_hdr;
static GUARDED_BY(RawRecTask)   mlv_expo_hdr_t expo_hdr;
-static GUARDED_BY(RawRecTask)   mlv_lens_hdr_t lens_hdr;
+static GUARDED_BY(RawRecTask)   mlv_lens_hdr_t lens_hdr;
+static GUARDED_BY(RawRecTask)   mlv_elns_hdr_t elns_hdr;
static GUARDED_BY(RawRecTask)   mlv_rtci_hdr_t rtci_hdr;
static GUARDED_BY(RawRecTask)   mlv_wbal_hdr_t wbal_hdr;
static GUARDED_BY(LiveViewTask) mlv_vidf_hdr_t vidf_hdr;
@@ -2807,7 +2808,8 @@

     mlv_fill_idnt(&idnt_hdr, mlv_start_timestamp);
     mlv_fill_expo(&expo_hdr, mlv_start_timestamp);
-    mlv_fill_lens(&lens_hdr, mlv_start_timestamp);
+    mlv_fill_lens(&lens_hdr, mlv_start_timestamp);
+    mlv_fill_elns(&elns_hdr, mlv_start_timestamp);
     mlv_fill_rtci(&rtci_hdr, mlv_start_timestamp);
     mlv_fill_wbal(&wbal_hdr, mlv_start_timestamp);

@@ -2827,6 +2829,7 @@
     if (FIO_WriteFile(f, &idnt_hdr, idnt_hdr.blockSize) != (int)idnt_hdr.blockSize) return 0;
     if (FIO_WriteFile(f, &expo_hdr, expo_hdr.blockSize) != (int)expo_hdr.blockSize) return 0;
     if (FIO_WriteFile(f, &lens_hdr, lens_hdr.blockSize) != (int)lens_hdr.blockSize) return 0;
+    if (FIO_WriteFile(f, &elns_hdr, elns_hdr.blockSize) != (int)elns_hdr.blockSize) return 0;
     if (FIO_WriteFile(f, &rtci_hdr, rtci_hdr.blockSize) != (int)rtci_hdr.blockSize) return 0;
     if (FIO_WriteFile(f, &wbal_hdr, wbal_hdr.blockSize) != (int)wbal_hdr.blockSize) return 0;
     if (mlv_write_vers_blocks(f, mlv_start_timestamp)) return 0;
diff -r 5138c0050854 -r 804086b3e477 modules/mlv_rec/mlv.c
--- a/modules/mlv_rec/mlv.c Sat Feb 17 22:37:51 2018 +0100
+++ b/modules/mlv_rec/mlv.c Mon Feb 19 00:09:44 2018 +0100
@@ -55,13 +55,35 @@
     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, lens_info.name, 32);
+
+    strncpy((char *)hdr->lensName, name, 32);
     strncpy((char *)hdr->lensSerial, buf, 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 = 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;
+}
+
void mlv_fill_wbal(mlv_wbal_hdr_t *hdr, uint64_t start_timestamp)
{
     /* prepare header */
@@ -151,7 +173,7 @@
     mlv_set_type((mlv_hdr_t *)hdr, "IDNT");
     mlv_set_timestamp((mlv_hdr_t *)hdr, start_timestamp);
     hdr->blockSize = sizeof(mlv_idnt_hdr_t);
-   
+
     hdr->cameraModel = camera_model_id;
     memcpy(hdr->cameraName, camera_model, 32);
     memcpy(hdr->cameraSerial, camera_serial, 32);
@@ -163,16 +185,16 @@
{
     int block_length = (strlen(version_string) + sizeof(mlv_vers_hdr_t) + 1 + 3) & ~3;
     mlv_vers_hdr_t *header = malloc(block_length);
-   
+
     /* prepare header */
     mlv_set_type((mlv_hdr_t *)header, "VERS");
     mlv_set_timestamp((mlv_hdr_t *)header, start_timestamp);
     header->blockSize = block_length;
     header->length = strlen(version_string);
-   
+
     char *vers_hdr_payload = (char *)&header[1];
     strcpy(vers_hdr_payload, version_string);
-   
+
     *hdr = header;
}

@@ -239,12 +261,12 @@
{
     int mod = -1;
     int error = 0;
-   
+
     do
     {
         /* get next loaded module id */
         mod = module_get_next_loaded(mod);
-       
+
         /* make sure thats a valid one */
         if(mod >= 0)
         {
@@ -252,7 +274,7 @@
             const char *mod_name = module_get_name(mod);
             const char *mod_build_date = module_get_string(mod, "Build date");
             const char *mod_last_update = module_get_string(mod, "Last update");
-           
+
             if(mod_name != NULL)
             {
                 /* just in case that ever happens */
@@ -264,15 +286,15 @@
                 {
                     mod_last_update = "(no version)";
                 }
-               
+
                 /* separating the format string allows us to measure its length for malloc */
                 const char *fmt_string = "%s built %s; commit %s";
                 int buf_length = strlen(fmt_string) + strlen(mod_name) + strlen(mod_build_date) + strlen(mod_last_update) + 1;
                 char *version_string = malloc(buf_length);
-               
+
                 /* now build the string */
                 snprintf(version_string, buf_length, fmt_string, mod_name, mod_build_date, mod_last_update);
-               
+
                 /* and finally remove any newlines, they are annoying */
                 for(unsigned int pos = 0; pos < strlen(version_string); pos++)
                 {
@@ -281,23 +303,23 @@
                         version_string[pos] = ' ';
                     }
                 }
-               
+
                 /* let the mlv helpers build the block for us */
                 mlv_vers_hdr_t *hdr = NULL;
                 mlv_build_vers(&hdr, mlv_start_timestamp, version_string);
-               
+
                 /* try to write to output file */
                 if(FIO_WriteFile(f, hdr, hdr->blockSize) != (int)hdr->blockSize)
                 {
                     error = 1;
                 }
-               
+
                 /* free both temporary string and allocated mlv block */
                 free(version_string);
                 free(hdr);
             }
         }
     } while(mod >= 0 && !error);
-   
+
     return error;
}
diff -r 5138c0050854 -r 804086b3e477 modules/mlv_rec/mlv.h
--- a/modules/mlv_rec/mlv.h Sat Feb 17 22:37:51 2018 +0100
+++ b/modules/mlv_rec/mlv.h Mon Feb 19 00:09:44 2018 +0100
@@ -165,6 +165,22 @@
}  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                 */
+    // TODO: Review Specs
+}  mlv_elns_hdr_t;
+
+typedef struct {
     uint8_t     blockType[4];       /* RTCI: real-time clock metadata */
     uint32_t    blockSize;          /* total frame size */
     uint64_t    timestamp;          /* hardware counter timestamp for this frame (relative to recording start) */
@@ -287,6 +303,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 -r 5138c0050854 -r 804086b3e477 modules/mlv_rec/mlv_dump.c
--- a/modules/mlv_rec/mlv_dump.c Sat Feb 17 22:37:51 2018 +0100
+++ b/modules/mlv_rec/mlv_dump.c Mon Feb 19 00:09:44 2018 +0100
@@ -1894,6 +1894,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;
@@ -1904,6 +1905,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));
@@ -3652,6 +3654,46 @@
                     print_msg(MSG_INFO, "     Flags:       0x%08X\n", lens_info.flags);
                 }
             }
+            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: Check Aperture Min/Max and if other fields are needed
+                    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", (double)elns_info.apertureMin);
+                    print_msg(MSG_INFO, "     Aperture Max:        f/%.2f\n", (double)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(mlv_block->blockType, "INFO", 4))
             {
                 mlv_info_hdr_t block_hdr = *(mlv_info_hdr_t *)mlv_block;
diff -r 5138c0050854 -r 804086b3e477 modules/mlv_rec/mlv_rec.c
--- a/modules/mlv_rec/mlv_rec.c Sat Feb 17 22:37:51 2018 +0100
+++ b/modules/mlv_rec/mlv_rec.c Mon Feb 19 00:09:44 2018 +0100
@@ -195,6 +195,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;

@@ -1449,14 +1450,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);
         }

@@ -2567,6 +2571,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;
@@ -2574,6 +2579,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);
@@ -2585,10 +2591,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);
@@ -3100,13 +3108,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)))
@@ -3123,6 +3134,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 -r 5138c0050854 -r 804086b3e477 modules/silent/silent.c
--- a/modules/silent/silent.c Sat Feb 17 22:37:51 2018 +0100
+++ b/modules/silent/silent.c Mon Feb 19 00:09:44 2018 +0100
@@ -28,6 +28,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);
@@ -365,6 +366,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;
@@ -478,6 +480,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);

     expo_hdr.isoValue = metadata.iso;
     expo_hdr.shutterValue = 1000000000 / metadata.tvr;
@@ -486,7 +489,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 -r 5138c0050854 -r 804086b3e477 src/lens.h
--- a/src/lens.h Sat Feb 17 22:37:51 2018 +0100
+++ b/src/lens.h Mon Feb 19 00:09:44 2018 +0100
@@ -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

aprofiti

Quote from: a1ex on February 19, 2018, 12:04:17 AM
I've extracted a patch for crop_rec_4k with only the changes related to ELNS and 64-byte lens name (mlv_dump, mlv*, silent and lens.h), but I'm afraid I have no more energy left to run any tests today (so I'm not committing it yet). If you try it, please report back.

I can't apply patch to crop_rec_4k branch: (updated my local repository by pulling latest commits from remote)
patch -f -p0 --input=/Users/alex/Desktop/pullML/tmp/a1exPatch64.diff
can't find file to patch at input line 15
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|# HG changeset patch
|# User alex@thinkpad
|# Date 1518995384 -3600
|#      Mon Feb 19 00:09:44 2018 +0100
|# Branch crop_rec_4k
|# Node ID 804086b3e47771bd72ed123bdd797c608738bf4f
|# Parent  5138c0050854c3c44eb2de21cf63c445baa0b245
|* Experimental: 64Byte Extended Lens Name
|* mlv_dump.c: Fix duplicate ELNS Block processing
|* mlv_rec.c: Fix duplicate ELNS Block processing
|
|diff -r 5138c0050854 -r 804086b3e477 modules/lua/lua_lens.c
|--- a/modules/lua/lua_lens.c Sat Feb 17 22:37:51 2018 +0100
|+++ b/modules/lua/lua_lens.c Mon Feb 19 00:09:44 2018 +0100
--------------------------
No file to patch.  Skipping patch.
1 out of 1 hunk ignored
can't find file to patch at input line 75
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -r 5138c0050854 -r 804086b3e477 modules/mlv_lite/mlv_lite.c
|--- a/modules/mlv_lite/mlv_lite.c Sat Feb 17 22:37:51 2018 +0100
|+++ b/modules/mlv_lite/mlv_lite.c Mon Feb 19 00:09:44 2018 +0100
--------------------------
No file to patch.  Skipping patch.
3 out of 3 hunks ignored
can't find file to patch at input line 106
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -r 5138c0050854 -r 804086b3e477 modules/mlv_rec/mlv.c
|--- a/modules/mlv_rec/mlv.c Sat Feb 17 22:37:51 2018 +0100
|+++ b/modules/mlv_rec/mlv.c Mon Feb 19 00:09:44 2018 +0100
--------------------------
No file to patch.  Skipping patch.
7 out of 7 hunks ignored
can't find file to patch at input line 247
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -r 5138c0050854 -r 804086b3e477 modules/mlv_rec/mlv.h
|--- a/modules/mlv_rec/mlv.h Sat Feb 17 22:37:51 2018 +0100
|+++ b/modules/mlv_rec/mlv.h Mon Feb 19 00:09:44 2018 +0100
--------------------------
No file to patch.  Skipping patch.
2 out of 2 hunks ignored
can't find file to patch at input line 281
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -r 5138c0050854 -r 804086b3e477 modules/mlv_rec/mlv_dump.c
|--- a/modules/mlv_rec/mlv_dump.c Sat Feb 17 22:37:51 2018 +0100
|+++ b/modules/mlv_rec/mlv_dump.c Mon Feb 19 00:09:44 2018 +0100
--------------------------
No file to patch.  Skipping patch.
3 out of 3 hunks ignored
can't find file to patch at input line 347
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -r 5138c0050854 -r 804086b3e477 modules/mlv_rec/mlv_rec.c
|--- a/modules/mlv_rec/mlv_rec.c Sat Feb 17 22:37:51 2018 +0100
|+++ b/modules/mlv_rec/mlv_rec.c Mon Feb 19 00:09:44 2018 +0100
--------------------------
No file to patch.  Skipping patch.
7 out of 7 hunks ignored
can't find file to patch at input line 436
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -r 5138c0050854 -r 804086b3e477 modules/silent/silent.c
|--- a/modules/silent/silent.c Sat Feb 17 22:37:51 2018 +0100
|+++ b/modules/silent/silent.c Mon Feb 19 00:09:44 2018 +0100
--------------------------
No file to patch.  Skipping patch.
4 out of 4 hunks ignored
can't find file to patch at input line 473
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff -r 5138c0050854 -r 804086b3e477 src/lens.h
|--- a/src/lens.h Sat Feb 17 22:37:51 2018 +0100
|+++ b/src/lens.h Mon Feb 19 00:09:44 2018 +0100
--------------------------
No file to patch.  Skipping patch.
1 out of 1 hunk ignored
Completed with errors, see above


Note: focus.c is also modified to avoid display problems when using lens with longer name

a1ex

Try "patch -p1" or "hg import".

This was meant only as a temporary patch to test the changes to MLV tools on the more recent codebase (e.g. for mlv_dump), until merging.

aprofiti

Quote from: a1ex on February 19, 2018, 03:16:05 PM
Try "patch -p1" or "hg import".
Nothing to do, recloned remote repo but It's partially applied lo lens.h, lua_len.c and silent.c

I'm trying to apply patch after this commit:

Merged in bouncyball/magic-lantern-merged/crop_rec_4k (pull request #901)
Revision: 17069
Changeset: e1794eb89f68170728b40b0153bb693a2ab9ed4c [e1794eb89f68]

Maybe your local repo is a bit different from remote and so can't find references?

nikfreak

Does this already allow to "overwrite / assign" an attached cpu lens to be one of the list of supported non-cpu lenses??

example: fake an EF-S 24 STM to be a Nikkor/Zeiss lens...

I am thinking about reviving old vintage glas I own.
There are chips for glueing available as well as adpaters (e.g. M42 / Nikon) which already include a chip for focus confirmation beeps in photo mode. I don't own one of these yet but the adapters are stated to work in M/Av modes and report a fixed lens info and apterture e.g, 50mm f1.4. Some adapters seem to be programmable but let's skip that...
[size=8pt]70D.112 & 100D.101[/size]

aprofiti

Quote from: nikfreak on April 01, 2018, 11:19:04 AM
Does this already allow to "overwrite / assign" an attached cpu lens to be one of the list of supported non-cpu lenses??
Yes, It was extended to support adapters with AF confirm Chip.
There is a check which detect when adapter is used, it's based primarily on lens's name/focal length returned by chip (observed "1-65535mm" the one I have).

You have to disable this check if you want to override EF-S lenses, but shouldn't be the case you are talking about.

Quote from: dfort on February 16, 2018, 05:16:50 PM
Saving XMP when shooting silent MLV files should also be addressed.
I was thinking to add a check inside xmp's lib to see which file format is selected.
Initially I was unsure if this could interfere with ML normal functionality like deflickr.mo because it need to save a .xml, but as this issues is present when silent.mo is used and it already have a function to check which file format is selected.

Is it possible to link code between modules? From silent.c to lua_camera.c? (Aldo I don't remember if silent.h exists)

nikfreak

[size=8pt]70D.112 & 100D.101[/size]

aprofiti



This show up when lua.mo is loaded with mlv_rec.mo and a lot of modules loaded.

Enabling only lua.mo and mlv_rec.mo will not shows this error but Raw recording is not working in both cases (Camera freezes after recording is stopped).
It works only without Lua loaded.

Recording works fine with mlv_lite but I get this even without Lua loaded if a lot of modules are enabled:




Tested with manual_lens_info.2018Feb19 build and without enabling any script.
Note: I can see crop_rec.mo into modules list. Is this correct or should appears only in 4k branch?

starbase64

Hi,

i have downloaded magiclantern-manual_lens_info.2018Feb19.1100D105.zip for my 1100d, but camera can't start with this version.

SD LED always blinking...

regards

Maik

aprofiti

Quote from: starbase64 on April 03, 2018, 02:30:50 PM
i have downloaded magiclantern-manual_lens_info.2018Feb19.1100D105.zip for my 1100d, but camera can't start with this version.

Maybe is related to memory constraint resource of 1100D.

I tried to merge latest changes from lua_fix to see if my previous reported issue could be solved with newer memory backend but camera won't show any signs apart the MPU handlings buttons and lens...

EDIT: I was using a workspace with CONFIG_QEMU defined from a previous work and didn't noticed, so this is why it wasn't running on camera.

Ron100

is it possible to make the 6D think that the Canon EF 50 f1, 2 lens is installed when installing the manual lens? if Yes the tell me, please, as this do?

aprofiti

I tested again this time with lua_fix.2018Mar31.50D and camera crashes also with this branch. So I think there is something wrong with memory management.



How to reproduce:
1. enable a lot of modules and mlv_rec.mo with or without lua.mo enabled
2. start a raw recording
3. camera freezes with black screen (sometimes red led on) after stopping recording
if lua.mo is enabled recording it crash immediately. Also noticed some strange behaviour of the text next to the green camera icon, it is suppose to give you current recording time? or an estimated remaining time? Because it seems to print random numbers...

Using mlv_lite.mo instead  (with or without lua.mo loaded) it can record multiple clip in a row but debug menu will show a overflow error

@a1ex Can you take a look please? Any others have this issue with 50D or other camera?

EDIT: Merging lua_fix into manual_lens appears to solve camera crash. I need to retest this branch without the merge a d dig a little more