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.

Danne


reddeercity

Have problems with ADTG_GUI in the "iso-research" branch , I can't modified/override
c0f06084
c0f06088

but if I use "digital poke" that enabled in "wasa57" "crop_rec_4k_5d2" branch
I can override them to increase the capture area a little bit (100 - 200 lines vertically)
but there's nothing in the ADTG_GUI , the only one's that seem to work are the cmos's
& some of the "adtg"[1] , [2] etc. ...

mainly I need those reg's to work in adtg_gui in combination with the cmos reg's .
I put the sensor I 1:1 mode etc. .... for 4k but I can't override 6084 & 6088 to increase
raw size .
@a1ex , is there hooks of stub that could be missing for those reg's ?
Where should I look ?

a1ex

Hm, right, This is definitely working on DIGIC 5.

Figured it out - DIGIC 4 requires poking 0xC0F06000 after changing any other register from this group. See FPS_REGISTER_CONFIRM_CHANGES in fps-engio.c. This was not necessary on DIGIC 5.

The DIGIC poking code, being written when DIGIC 4 was the main focus, already had this workaround enabled.

Background:

These registers are only changed by Canon firmware when switching video modes (unlike CMOS registers, for example, which are poked once every LiveView frame). So, until recently, the only way to see the change to these registers was to get out of LiveView and back, or to manually trigger some video mode change (e.g. zoom in and back, flip to some other video mode and back).

A workaround for that was introduced in reply #967, commit 5314bde. That one mostly worked, except for two quirks: the one mentioned above, and another one that prevented ML from reading back the value of registers modified on the fly. So, on DIGIC 5, you could modify FPS timers and see the new frame rate on the screen, but the status bar was only updated after getting out of LiveView and back. Fixed that one, too.

reddeercity

Thanks , now I can finally finish 4k/UHD for D4  :)

reddeercity

Ok I can confirm the change that a1ex made are now working on 5d2/D4 for c0f06084 & c0f06088 in the "adtg_gui.c"
I posted a new build if any 5d2 user wishes to try it out/help with 4k  https://bitbucket.org/reddeercity/magic-lantern_10-12bit/downloads/
I also modified mlv_lite.mo & mlv_rec.mo with extended resolutions ,
I add :
3072
3840
4096
5632

the 5632 is the max res for the 5d2

IDA_ML

Reddeercity,

Will your investigations and progress with the 5D2 work on the 7D too?  Could you possibly provide a build for that camera too?  After Sept. 17-th I will have access to my 7D and would love to test.

Thanks.

reddeercity

Quote from: IDA_ML on August 29, 2018, 06:47:16 AM
Reddeercity,
Will your investigations and progress with the 5D2 work on the 7D too? 
Yes ,  should be -- later when I have it close I'll write a tutorial , but in the mean time just follow my posts  :)

Quote from: IDA_ML on August 29, 2018, 06:47:16 AM

........ Could you possibly provide a build for that camera too .......
Sure , but I have to add 7d code for srm "raw_slurp" , you know the one , for 10-12bit raw video
That one of the reasons I'm getting so close to 4k I'm used my Super Bleeding Edge "SRM_Buffer"
It's the one I use for 10-12bit FHD on the 5D2 that works really well in 12bit 1856x1044 .
I did make some extra changes to the buffer I'm using a 32MB buffer
4096*4096
and as per my last quick test here , it seem ML need a 59 MB buffer
so the next test I'll increase the default raw buffer to

2048*16377 ---Not Good ER70---

which is ML is telling me that it needs 59MB , but I not too sure how that ends up to be 59MB -- Hex is not my strong point , but I get by .

If any one can point my to some math examples I would be very grateful  :D

Edit: ok that buffer produce a error 70 when mlv_lite raw video enabled so not a good buffer back to my 32MB 4096*4096

IDA_ML

Thanks a lot, Reddeercity for your amazing progress.  I can't wait to test a new working build for the 7D.  This camera seems to be the only one with that dreamy filmic look and really deserves 4k-crop recording.

Audionut

Quote from: a1ex on August 01, 2017, 01:45:59 AM
Restoring the missing screenshots would be a good starting point.

Done.

Quote from: a1ex on August 01, 2017, 01:45:59 AMScript various test scenarios in Lua (e.g. cycle through all ISOs, take test pictures, change settings, create tables with results).

I've been avoiding LUA.  ::)  But, it looks like a few of your other requests can be knocked out reasonably quickly and easily with this one.


Quote from: a1ex on August 01, 2017, 01:45:59 AM
Find out how low you can push the ISO without getting artifacts in highlights. Different cameras (of the same model) might have different results.

It will probably take a while to re-read the thread and refresh my memory on all this stuff.

Some issues with raw_diag mentioned here, didn't look into them yet: http://www.magiclantern.fm/forum/index.php?topic=16516.msg186527#msg186527

Try to reproduce the above findings on different camera models. Some may need different registers.

Simply play with adtg_gui and document register behavior from your camera.

Figure out the registers required for the ISO tweaks in LiveView (some are the same, others are not).

Evaluate the repeatability of our measurements under various test scenes.

Propose a way to measure the sensor response curve without expensive lab equipment.

Try the pattern noise reduction algorithm from MLVFS or mlv_dump on steroids on the images taken with ISO tweaks (IIRC 5D3 has problems with this, 6D less so). Try to fine-tune the parameters.

Figure out how to reproduce the ETTR + Dual ISO crash on the patchmgr branch (doesn't happen on unified; happens with low probability on patchmgr and any other branches that use this backend).

Figure out why this dark frame introduced additional pattern noise, instead of removing it.

Just some random ideas. Don't limit yourself to these :D

Levas

I want to mess around a little with analog gain registers, goal is not to get a clean image, goal is to get stupidity high iso value  :P
I'm curious if anyone knows more analog gain registers then these commonly known ?

analog gains
ADTG2 [8882]
ADTG2 [8884]
ADTG2 [8886]
ADTG2 [8888]

ADTG2 [FE]

analog preamps
ADTG2 [ 8 ]
ADTG2 [ 9 ]
ADTG2 [ a ]
ADTG2 [ b ]


Danne

Decided to play around with the analog gain registers thinking I could get a cleaner output. Here is one take on this.
First I lower analog gain registers severly causing it to act as 10bit?(maybe lower). What happens is highlights will take a hit and get clipped. However this move will clean shadows by a lot. I matched each file by modifying also cmos 0.
Maybe it could mean that when shooting 12 or 10 bit we would gain much better shadows if this was implemented? I didn´t mess with the preamps at all. How would this test benefit from those?

All files were analysed in Mlv App:
Shortened MLV files and coresponding PNG(brightened) here. Note that the modified mlv files could have been set to 3000 in white level but I skipped that parameter in this test. Only wanted to show shadows:
https://bitbucket.org/Dannephoto/magic-lantern/downloads/ISO_gain_tests.zip

analog gains changed to(note there are eight of those registers on the 5D mark III)
ADTG2 [8882] 0x13b
ADTG2 [8884] 0x13b
ADTG2 [8886] 0x13b
ADTG2 [8888] 0x13b


Recommend to download the png files to really see the difference.

ISO 100


ISO 100 CMOS[0] 0x222 gain to 0x13b


ISO 200


ISO 200 CMOS[0] 0x333 gain to 0x13b


ISO 400


ISO 400 CMOS[0] 0x443 gain to 0x13b


ISO 800


ISO 800 CMOS[0] 0x553 gain to 0x13b


ISO 1600


ISO 1600 CMOS[0] 0xddd gain to 0x13b


ISO 3200


ISO 3200 CMOS[0] 0xfff gain to 0x13b



70MM13

If this can be done to the top ISO in dual ISO, the results would be tremendous.

Danne

Even a slighter change will have a major impact on iso 100. In this case highlights won´t suffer as much:

iso 100


iso 100 CMOS[0] 0x111 gain to 0x21a


Danne

A few last frames:
https://bitbucket.org/Dannephoto/magic-lantern/downloads/iso_100.zip

CMOS[0] is vital. Simply lowering the analog gain registers won´t do:

iso 100 original


iso 100 Lowering analog gain to 0x19a (white level to around 5000)


iso 100 Lowering analog gain to 0x19a and CMOS[0) 0x222 (white level to around 5000)


Danne

Here is a build for the 5D mark III which lets you set iso 100-3200 from within crop_rec menu:
https://bitbucket.org/Dannephoto/magic-lantern/downloads/crop_rec_4k_mlv_snd_isogain_1x3_5D3113_presets.zip

Commit/branch:
https://bitbucket.org/Dannephoto/magic-lantern/branch/crop_rec_4k_mlv_snd_isogain_1x3_presets
https://bitbucket.org/Dannephoto/magic-lantern/commits/9b8625caa3554d09003bd8a89dee7f43d66a634e



Have only tested this briefly but hopefully you get something like below. Compare the color noise and grain in both. Think of the crop_rec mv1080p iso settings as iso for mv1080p. It will override whatever iso you have set in camera. Liveview should be matched to original iso and analog gain registers are lowered to around 12bit. Might wanna change white level to around 5000 in post, who nows, needs more testing.

iso 100


iso 100


iso 100


iso 100


Levas

Interesting, the noise looks quitte different in your examples  :o
Will check if this stuff also has the same effect on 6d

ilia3101

Wow a lot has happened since I last looked at this thread

@Danne looks like massive improvements to dynamic range! How 5D3 specific is the stuff being done here? I'm really struggling with the huge amount of noise my 5D2 has

squig

I'm seeing really severe highlight clipping with mv1080p ISO 100 and ISO 3200.

ISO 100


mv1080p ISO 100 (white level 5000)

a1ex

Quote from: Danne on November 04, 2018, 12:44:27 PM
First I lower analog gain registers severly causing it to act as 10bit?(maybe lower). What happens is highlights will take a hit and get clipped. However this move will clean shadows by a lot. I matched each file by modifying also cmos 0.

Lowering analog gain registers will improve the DR... until the clipping point starts to drop. This is the sweet spot for ADTG gains. Without any other tweaks, when starting from ISO 100 in photo mode on my 5D3, this method improves the DR by about 0.37 EV, reducing the ISO to 77 (i.e. you should scale the original ADTG gains by 77%). On other cameras (possibly other 5D3's too), the numbers will be different.

Further reducing the ADTG gain is not going to improve DR any more; it will start to decrease the clipping point instead (and that happens in way that tricks the white level autodetection routine from raw_diag, so take the measurements with a grain of salt). Once white level starts to drop, DR is going to remain roughly constant, then it will start to get lower and lower (causes: analog noise and quantization error).

Now, if you set the ADTG gains to some very low value, but you keep the old (i.e. close to 15000) white level, this will result in a dark DNG. You might think you've just got a lower ISO, so you may be tempted to increase the exposure time and compare the shadows. Yes, this increase in exposure time will give *much* cleaner shadows. Once you look at the highlights, you will realize it's a false alarm.

When comparing noise at different flavors of ISO 100 (or any other ISO), make sure you capture the same amount of light (i.e. same shutter speed, aperture and test scene). This is important, otherwise the difference in noise will be given by the different amounts of captured light (i.e. the test results will be... well... bogus).

Then, render the two images at the same brightness on the screen, but you already did that.

Danne

Quote from: a1ex on November 05, 2018, 08:20:53 AM
Lowering analog gain registers will improve the DR... until the clipping point starts to drop. This is the sweet spot for ADTG gains. Without any other tweaks, when starting from ISO 100 in photo mode on my 5D3, this method improves the DR by about 0.37 EV, reducing the ISO to 77 (i.e. you should scale the original ADTG gains by 77%). On other cameras (possibly other 5D3's too), the numbers will be different.
Seems not that much but might do a difference in shadows and color noise. My lowering of the analog gains are in other words, over the top. How to correctly calculate scaling to this?" (i.e. you should scale the original ADTG gains by 77%)"?

Question. Recording in situations without cruicial highlights(dark lit scenes for instance), would benefit from the harsh lower gain values in my examples rather than scaling down to 77%?

a1ex

Like this: old_value * 77 / 100.

To check whether it's too much, use something strongly overexposed, and make sure it ends up completely white (i.e. not slightly pinkish, or with noise, or stripes, or whatever). If OK, try a lower value. If you get artifacts, increase the value.

Danne

Quote from: a1ex on November 05, 2018, 10:38:59 AM
Like this: old_value * 77 / 100.
of course, thanks  8)

Quote from: a1ex on November 05, 2018, 10:38:59 AM
To check whether it's too much, use something strongly overexposed, and make sure it ends up completely white (i.e. not slightly pinkish, or with noise, or stripes, or whatever). If OK, try a lower value. If you get artifacts, increase the value.
How about lowering gains to match white level of 12bit and clip accordingly for the benefit of very clean shadows or should these changes stick with 14bit white level only?

a1ex

If you also want 12-bit lossless recording, then you can further reduce the gains by 2 stops. Total gain for 12-bit would be 2^-2 * 77% = 19.25%.

Though, for reducing bit depth, I'd prefer to look once again at the digital gains, and leave the analog side for ISO optimization.


Quote from: Danne on November 05, 2018, 10:35:23 AM
Question. Recording in situations without cruicial highlights(dark lit scenes for instance), would benefit from the harsh lower gain values in my examples rather than scaling down to 77%?

In this case, I'd recommend the following, in this order:
- increase amount of captured light (whether from shutter speed, aperture or scene light)
- increase gains from CMOS amplifiers, where electronic noise is minimal
- increase gains from other analog amplifiers (todo: I need to revisit the noise performance evaluation)
- increase digital gains if that doesn't create gaps in the raw histogram (also need to double-check this)

Reducing any kind of gain will make the shadows *worse* (it will remove information from there). If that reduction comes with additional highlights captured, it may be worth the effort (e.g. for increased DR), otherwise it does not bring any benefits for image quality.

Reducing to 12-bit levels results in better lossless compression, but the image quality suffers a little (possibly just a negligible amount). Overall, it might be a worthy tradeoff.

Levas

Quote from: a1ex on November 05, 2018, 11:01:11 AM
In this case, I'd recommend the following, in this order:
- increase amount of captured light (whether from shutter speed, aperture or scene light)
- increase gains from CMOS amplifiers, where electronic noise is minimal
- increase gains from other analog amplifiers (todo: I need to revisit the noise performance evaluation)
- increase digital gains if that doesn't create gaps in the raw histogram (also need to double-check this)

@Alex, I'm interested in step 2 and 3 and curious if you know some more analog amplifiers I can modify ?

What I have
ISO setting:
                              CMOS[3]  For 6d that is
Analog amplifiers:
                              ADTG2 [8882]
                              ADTG2 [8884]
                              ADTG2 [8886]
                              ADTG2 [8888]
Analog preamps:
                              ADTG2 [ 8 ]
                              ADTG2 [ 9 ]
                              ADTG2 [ a ]
                              ADTG2 [ b ]

And found register 
                              ADTG2 [FE], which also seems to be some sort of gain, not sure if it's analog or digital.

Did I miss any other known amplifiers ?



a1ex

My old notes (to be taken with a grain of salt):


* There are 4 classes of adjustments available. They are optional (one camera can use only one of them,
* or all of them, or anything in-between) and they are applied in this order:
*
* - ADTG preamps: fixed, no adjustable parameters, no menu options
*      - ADTG 0xFE         : only applied at Canon ISO >= 200; lowering it by one notch is too aggressive for ISO 100
*      - ADTG 8/9/A/B      : we lower it a little at Canon ISO 100, and all the way down at ISO >= 200
*
* - Saturate Offset & related:
*      - Saturate Offset   : shifts raw data by constant value, alters black level but keeps white level constant
*                            => can capture more highlights
*      - B/W offset        : optional, shifts raw data by constant value, alters both black level and white levels
*                            => digital offset (can be used to increase the useful range for Saturate Offset)
*      - Digital gain      : we simply fix this one at the value believed to be 1.0
*                            note: at large apertures like f1.4, Canon increases this gain, which clips useful highlights;
*                            we cancel this behavior
*
* - ADTG gain: the first adjustment discovered
*      - analog gain in fine steps (default value is usually around 1000-1500)
*      - this does not alter black and white levels, but lowering it brings more highlight detail
*      - at least one camera (500D) doesn't have it (we couldn't find it)
*      - ADTG gain and Saturate Offset behave somewhat like a waterbed (todo: explain in detail)
*      - if you can adjust ADTG gain, Saturate Offset, Digital Gain, and - highly recommended - B/W offset,
*        you get full control over black and white levels, without impact on the recorded dynamic range
*
* - CMOS trick:
*      - I don't know how this one works, but it seems to reduce the noise at least in the OB area
*      - this does not change the equivalent ISO
*      - to be double-checked with the SNR curve
*
* Movie mode support:
*      - at least 3 different modes need to be analyzed: 1080p, 720p, 5x crop
*      - ADTG gain OK, tiny effect
*      - ADTG preamps OK, noticeable effect
*      - Saturate Offset and B/W Offset not working
*      - Digital gain is not applied in raw video anyway (not needed)
*      - CMOS trick still investigated


Some more useful notes in iso_regs.c:

https://bitbucket.org/hudson/magic-lantern/src/iso-research/modules/iso_regs/iso_regs.c?fileviewer=file-view-default#iso_regs.c-345

Quote from: theBilalFakhouri on July 25, 2018, 10:07:51 AM
Found some ADTG gain registers in 700D:

Negative gain     Original value     Overridden
ADTG2[21] =        0x4626              0x1036
ADTG2[22] =        0x4626              0x1036
ADTG2[23] =        0x4626              0x1036
ADTG2[24] =        0x4626              0x1036

Could not confirm on 700D - these values give a mostly black image, with strong vertical lines.

IIRC these didn't work on 700D either:
https://www.magiclantern.fm/forum/index.php?topic=10111.msg204415#msg204415