CMOS/ADTG/Digic register investigation on ISO

Started by a1ex, January 10, 2014, 12:11:01 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

a1ex

Quote from: Audionut on August 02, 2017, 07:08:04 AM
Are you sure pattern noise has been introduced?  All of the other noise sources help to hide pattern noise.

Pattern noise removal really needs an average of several dark frames to be effective.

Maybe my pixel peeping skills aren't the best, but all files (input and output) and commands used are on the Jenkins page linked in that thread. The dark frame is averaged from 31 frames.

keepersdungeon

Quote from: Levas on August 13, 2014, 05:27:22 PM
Thanks Greg,

I can get 3xzoom/crop mode on 6d by overriding the following registers:
                      1080p     10xzoom     3xzoom(1:1 crop)

ADTG2-805f      2b0        13c             No change needed
ADTG2-8061     2b0        13c             No change needed

CMOS[6]          400         d0             d0       (=Changing the "d" moves horizontal position on the sensor)
CMOS[7]             0         208          206       (Lowering the 8 to 6 moves the white bar outside 16:9 view)
ADTG2-800c         2           0              0         (vertical lines to skip)
ADTG2-8000        6           5             5       (Don't know what it does, if it is 6 you get some vertical interlaced looking footage...)


With these settings I get 3xzoom/crop mode, correct preview in live view on the 6d
Raw recording works, gives correct framing.
I can even record canon "native" h.264 with it, and it works too!

Just saw this! didn't even know it was possible on 6D
Anws was trying it,  and when I hit the crop 1:1 in the raw settings I can see 1826*1092 x3.0 but the recording is identical as the footage without hitting zoom
I missed something again didn't I?

a1ex

Just posted new builds of the iso-research modules (adtg_gui, iso-regs and raw_diag), to be loaded on top of the current crop_rec_4k builds (as the older crop_rec is no longer on the download page).

http://builds.magiclantern.fm/modules.html#iso-research

If you decide to experiment with them, I'm looking forward to seeing your results.

kichetof

@a1ex I would try to play with it, but I've an error with adtg module:

ML ASSERT:
new_entry->name
at ../../src/menu.c:1241 (menu_add_internal), task module_task
lv:0 mode:3

module_task stack: 1db7b8 [1dba50-1d7a50]
0xUNKNOWN  @ b68c8:1db878
0x00072678 @ a0f318:1db860
0x0006EA48 @ 726a4:1db848
0x0006EA48 @ 6ee30:1db818
0x00069FF0 @ 6ec90:1db7e8
0x00069868 @ 6a05c:1db7b8

Magic Lantern version : crop_rec_4k.2017Sep26.5D3113
Mercurial changeset   : 382dafb8a0bd (crop_rec_4k) tip
Built on 2017-09-25 23:32:14 UTC by jenkins@nightly.
Free Memory  : 134K + 3143K


It seems that there are a lot of changes in menu.c between crop_rec_4k and iso-research, I'll try to find how to solve it
https://bitbucket.org/hudson/magic-lantern/branches/compare/crop_rec_4k%0Diso-research#chg-src/menu.c

a1ex

Right - it needs a valid name, such as .name = "(empty)". Did that to avoid a bunch of null pointer issues, but only tried iso_regs and raw_diag from the latest build.

Hopefully fixed, but unable to test right now.

kichetof


a1ex

Here's a quick example on how adtg_gui can be used to find interesting stuff.




In the crop_rec_4k branch I've used raw type 0x12 (DIGIC 5) in order implement 8..12-bit lossless compression. This works by keeping the 14-bit container (as I don't know how to reconfigure the encoder for other bit depths) and darkening the image (applying a digital gain aka SHAD_GAIN) so it ends up with fewer levels (as many as a real 8..12-bit image).

This trick appears to work - it improves the compression ratio.

Problem: LiveView also gets darkened (as a side effect of bit depth reduction).

By default, ML uses raw type CCD (0x10 on D5, 0x5 on D4), as this one gives consistent white levels. This raw type is not affected by ISO changes, therefore it doesn't react to digital gain (so there's no easy way to darken it digitally). I could darken it from analog controls, but didn't want to touch them for bit depth reduction.

Anyway - I'm currently trying to find a way to brighten the image of raw type 0x12 (DEFCORRE, apparently after SHAD in the pipeline, but before other image processing steps, such as the picture style), but *without* brightening the raw buffer contents. That means, I'm looking for some sort of digital gain later in the pipeline (after DEFCORRE).

Incidentally, I've noticed our low-light exposure simulation feature (Expo Override + ExpSim enabled), after a certain threshold (a few seconds of exposure at some high ISO), it brightens the LiveView image, but the raw histogram is no longer pushed to the right. In these (extreme) cases, on DIGIC 5, ML uses something like this:

call("lvae_setdispgain", some_gain); /* 1024 = 1.0 */


Problem: on 5D3, this call only works in photo mode...

On DIGIC 4, we've identified this register by brute force:

#define ISO_PUSH_REGISTER 0xc0f0e0f8


But that doesn't work on 5D3.

Looking in lvae_setdispgain (FF72C0B0 in 5D3 1.2.3), it stores the gain at 0x68C8C, prints a message and sets some flags. The actual configuration is likely done by some other code that reads this value. Unfortunately, that code was not identified by IDA's autoanalysis.

How to find it? This is likely some register used to configure LiveView, like those handled by adtg_gui. So, I've tried to find it using this tool.

How?

1) entered photo mode LiveView (where our function works), enabled ADTG Registers, DIGIC registers and selected "Modified from now on"
2) back to LiveView, then back to ML menu -> a bunch of registers changed. Selected "Modified from now on" again until things settled.
3) called the analyzed function (had it on "don't click me" with random gains) and noticed how the LiveView brightness changed
4) went back to adtg_gui menu and it printed these modified registers (5D3 1.1.3):

C0F42730: 0x1010202 (was 0x1)       - from AeWb:ff33ff94:6b84fc
C0F4273C: 0x46f076c (was 0x5640483) - from AeWb:ff33ff94:6b8514
C0F42740: 0x6900690 (was 0x3fd03fd) - from AeWb:ff33ff94:6b851c
C0F42744: 0x4040404 (was 0x0)       - from AeWb:ff33ff94:6b8524


5) Locked the above registers and confirmed the brightness could no longer be changed with lvae_setdispgain. That's a good sign - it means the register I'm looking for is one of these (or maybe all of them).

6) Changed the above registers to their old value (the "was" one). Result: LiveView back to original brightness (before calling lvae_setdispgain). Another good sign.

7) Now, to find out what they do - the "trial and error" part:

C0F42730 looks like a series of 4 8-bit values. Each of them appears to be a boost of the 4 Bayer channels. Valid values: 0...3 (4 is the same as 0). Making them equal will make the image brighter; otherwise, the colors will be changed.

C0F42744 is similar, but valid values go from 0 to 7. It also gives some Bayer artifacts.

The remaining two are 16-bit values (two values packed in one register). Probably some sort of WB gains.

C0F4273C: the lower half looks like red gain, the higher half looks like blue gain (range 0 - 7FF)
C0F42740: these look like green gains; if the two are different, some interesting artifacts appear - just like with C0F42744.

8.) With the above registers 4 locked, white balance controls (from Canon menu) are no longer working. This makes sense - these are all changed from the AeWb task.

Overriding just C0F4273C/40 does not completely lock WB controls - they still work in some rough increments.

9) Switched to Movie mode and tried to adjust the above registers. It works!

DeafEyeJedi

Once again excellent progress with this troubleshoot of yours, @a1ex!  8)
5D3.113 | 5D3.123 | EOSM.203 | 7D.203 | 70D.112 | 100D.101 | EOSM2.* | 50D.109

deix

Hi there,

will the "raw_diag.mo" be loadable also for the main branch, or is it only available for experimental crop_rec_4k build - I get the following version error while using the main build "magiclantern-Nightly.2017Oct04.60D111.zip"

"Wrong version(v7.0, expected v6.0)
http://ibb.co/fhzJrR

Best regards
Michal Powalko

a1ex

Will be after merging lua_fix; meanwhile, you can use that experimental build to load it.

The other two modules also require the patch manager (not included in lua_fix, so they won't load on that build).

70MM13

ISO 109 tested for shadow noise improvement:

Three images, all settings identical except iso.  Exposed for highlights in a low light scene to really showcase shadow noise.  This time I adjusted register settings to compensate for highlights (as I should have before, but was too eager just to see results!)

No image processing except exposure compensation.  No noise reduction at all.

109 rocks.

5D3 1.13






johannsebastianbach

Quote from: 70MM13 on December 09, 2017, 06:26:42 PM
ISO 109 tested for shadow noise improvement:

Three images, all settings identical except iso.  Exposed for highlights in a low light scene to really showcase shadow noise.  This time I adjusted register settings to compensate for highlights (as I should have before, but was too eager just to see results!)

No image processing except exposure compensation.  No noise reduction at all.

109 rocks.

5D3 1.13






Wow, this is crazy!

70MM13

Yes, it works extremely well!
I shared a music video I shot using this mode on the "share your videos" forum.  Check it out!
This experimental iso mode is long overdue for serious attention...

theBilalFakhouri

Hi @70MM13
Really nice trick at ISO 109!
But how you got it? and how did you know you are at ISO 109?
I played with CMOS 0 register , the ISO was changed but the value stayed 100 on ML.
Can you explain your steps?

Ron100

Hi, help! receive error when enable modules adtg_gui.mo and raw_diag.mo on the camera 6d(1.1.6)

adtg_gui.mo
tcc: error: undefined symbol "unpatch_memory"
tcc: error: undefined symbol "patch_hook_function"
[E] failer to link modules

raw_diag.mo
Wrong version (v7.0, expected v6.0)

IDA_ML

I also have a question about this magic ISO 109.  Isn't is possible hard code it and add it to the ML ISO menu, along with other similar ISO numbers, so that users can easily select them when needed?

a1ex

It is, but first I need to know what to hardcode (adtg_gui). The tweaks (and how far they can be pushed) are model-specific, though they usually follow a similar pattern - certain analog gains can be reduced, revealing additional highlight detail.

There are LOTS of things that can be done by users with minimal coding skills - be sure to read the previous posts for more details. For example, a huge time saver (for me) would be to automate the process of evaluating the equivalent ISO (clipping point) and the resulting dynamic range under various conditions (photo mode, movie mode 1080p/720p/x5/crop/etc, iterating through all ISOs). That should be doable with Lua scripting around raw_diag and adtg_gui. For more ideas, be sure to read the previous posts.

A review of the methods I'm using for evaluating dynamic range and clipping point, maybe by cross-checking the results with other software/methods, would be also very welcome. Details can be found in previous posts as well. In particular, I'm interested in double-checking the clipping point (is that ISO really 109 or is it more like 150 or 75?), the repeatability of the results (are different users following the same test procedure getting similar results, or are the results very different?) and the sensor response curve (is it linear?). All without requiring special equipment for measurements (color chart, second camera or household lights are OK, but that's pretty much it).

@Ron100: try the experimental 6D builds with lossless compression (from the forum), or compile from source (iso-research branch). Modules compiled from that branch are also loadable on crop_rec_4k (all) and lua_fix (only modules without low-level hacks, such as raw_diag).

Ron100

a1ex, please give a link to experimental builds 6D with lossless compression (from the forum). I looked at the whole branch, but I couldn't find it.

70MM13

Regarding the video, I didn't use "iso" 109, but more like 80-320, based on isos 160-640.

I don't have a clue as to what the resulting isos really are, I just go by what magic lantern tells me.

I found that using actual iso 320-400 as the base gives the best results for my video work, particularly for very low light conditions.

I have a very simple method based on my own experiments following a quick reading of a1ex's information contained within this thread:

1: clear the custom iso settings
2: set desired base iso (canon menu)
3: take a silent photo
4: "copy canon settings"
5: set 0xfe to 3, preamp to 2, and reduce adtg until the "iso" is half of the base value

That's it!

I'm sure that better results are obtainable, but I'm very happy with what I'm producing using this simple method!

I've filmed a lot of scenes using this method, and it always works well for me.  I'd be overjoyed to have a simple menu option for this setting!

It's not a huge hassle to do manually, just a bit of a time waster.

Thanks a1ex and everyone for the magic of magic lantern!

I'm looking forward to seeing what's possible when we really nail down the best settings!

Edit: added missing step 4

theBilalFakhouri

@Ron100
Here is a link from @dfort's downloads page you will find experimental build for 6d.

theBilalFakhouri

Thanks! @70MM13
Quote from: 70MM13 on February 12, 2018, 03:22:04 PM
4: set 0xfe to 3, preamp to 2, and reduce adtg until the "iso" is half of the base value
So you are using iso_regs.mo to adjust these settings? which only compatible with 5D3, I am using 700d no luck :-[
But wait :D @a1ex How it's hard to make working it on 700d ? What should I change, the registers only?

Can you help with that and take me to the right place?
If I can use adtg_gui instead, please tell me that. And some useful links to that I will be appreciate it!

a1ex

Yes, you can use adtg_gui to perform all the tweaks discussed in this thread. Refer to previous posts - there were many example screenshots back then (unfortunately, some of them were eaten by Dropbox).

Some of the screenshots may be available on archive.org or similar websites; if you have the time to dig and rescue any of them (or maybe just remind the original authors to reupload them), I can re-host them on ML server and update the links.

IDA_ML

Quote from: a1ex on February 12, 2018, 11:57:44 AM

There are LOTS of things that can be done by users with minimal coding skills - be sure to read the previous posts for more details. For example, a huge time saver (for me) would be to automate the process of evaluating the equivalent ISO (clipping point) and the resulting dynamic range under various conditions (photo mode, movie mode 1080p/720p/x5/crop/etc, iterating through all ISOs). That should be doable with Lua scripting around raw_diag and adtg_gui. For more ideas, be sure to read the previous posts.

A review of the methods I'm using for evaluating dynamic range and clipping point, maybe by cross-checking the results with other software/methods, would be also very welcome. Details can be found in previous posts as well. In particular, I'm interested in double-checking the clipping point (is that ISO really 109 or is it more like 150 or 75?), the repeatability of the results (are different users following the same test procedure getting similar results, or are the results very different?) and the sensor response curve (is it linear?). All without requiring special equipment for measurements (color chart, second camera or household lights are OK, but that's pretty much it).

There is no doubt that this is another very exciting step in ML development that could vastly improve shooting experience and final results.  The problem is that most people, including me, don't understand how to do these tests, despite the detailed explanations in this thread.  In my opinion, it would be very helpful if someone would agree to make a video tutorial, explaining the test and automation (optimization) procedure step by step.  In this way, several people could give it a try and share their results with their camera models. 

A1ex, do I understand properly that the 5D3 with its magic ISO numbers from the first post: 66, 115, 230, 460, 912, etc. is ready for hardcoding these numbers in the ML ISO menu and such magic numbers are needed also for the other camera models?

Ron100

Thanks, I installed the experimental build 6d and enabled the module adtg_gui.mo

I am willing to carefully experiment,but maybe someone detailed the instructions for use of the module adtg_gui.mo?

I fully support IDA_ML, create a video manual would be great!!!

P.s. Can decrease the ISO to give a greater preserving highlight detail than Canon's tone priority (d+)?

70MM13





Here's a photo I snapped using the technique I listed above, base iso 320, resulting "iso" 160.

Extreme dynamic range in the scene, full sun and shade in snow, sunlight reflected in the ice...

No postprocessing except for a nice fujifilm lut for my taste.

This amplifier hacking is incredible.