DoF values and other related items - page 5 - General Discussion and Assistance - CHDK Forum  

DoF values and other related items

  • 50 Replies
  • 22519 Views
Re: DoF values and other related items
« Reply #40 on: 28 / November / 2009, 23:22:30 »
Advertisements
I've got some great news on finding a new function!
I got a bit of a hunch on camera focal lengths (after seeing FocalLengthConverter.c in the 720 reference) that the firmware should have the actual focal length in it, so I did a bit of searching and found it (in the SX10 at least).

Currently the focal length is estimated by linear approximation of a few hand input points in SX10/main.c:

Code: [Select]
static const struct {
int zp, fl;
} fl_tbl[] = {
{   0,   5000 },
{  11,   6190 },
{  41,  12610 },
{  64,  25240 },
{  86,  45470 },
{ 105,  65880 },
{ 128, 100000 },
};
#define NUM_FL (sizeof(fl_tbl)/sizeof(fl_tbl[0]))
#define CF_EFL 5600

const int zoom_points = 129;

int get_effective_focal_length(int zp) {
return (CF_EFL*get_focal_length(zp))/1000;
}

int get_focal_length(int zp) {
int i;

if (zp<fl_tbl[0].zp)
return fl_tbl[0].fl;
else if (zp>fl_tbl[NUM_FL-1].zp)
return fl_tbl[NUM_FL-1].fl;
else
for (i=1; i<NUM_FL; ++i) {
if (zp==fl_tbl[i-1].zp)
return fl_tbl[i-1].fl;
else if (zp==fl_tbl[i].zp)
return fl_tbl[i].fl;
else if (zp<fl_tbl[i].zp)
return fl_tbl[i-1].fl+(zp-fl_tbl[i-1].zp)*(fl_tbl[i].fl-fl_tbl[i-1].fl)/(fl_tbl[i].zp-fl_tbl[i-1].zp);
}
return fl_tbl[NUM_FL-1].fl;
}

However, I found a function entry point in the firmware that returns the actual (at least internal set) focal length of the lens at FF941078:

Code: [Select]
FF941078: E51F06CC LDR R0, =0x90E4
FF94107C: E92D4010 STMFD SP!, {R4, LR}
FF941080: E5900004 LDR R0, [R0, #0x4]
FF941084: E3500000 CMP R0, #0x0
FF941088: 059F1620 LDREQ R1, =0x14E
FF94108C: 059F05F0 LDREQ R0, =0xFF9409C8 **"ZoomLensController.c"
FF941090: 0BFB684D BLEQ FF81B1CC
FF941094: EBFFFFE6 BL FF941034
FF941098: E8BD4010 LDMFD SP!, {R4, LR}
FF94109C: EA046780 B FFA5AEA4
V
FFA5AEA4: E3500080 CMP R0, #0x80
FFA5AEA8: E92D4010 STMFD SP!, {R4, LR}
FFA5AEAC: E1A04000 MOV R4, R0
FFA5AEB0: 828F0D06 LDRHI R0, =0xFFA5B038 *"ZoomLensConverter.c"
FFA5AEB4: 83A01068 MOVHI R1, #0x68
FFA5AEB8: 8BF700C3 BLHI FF81B1CC
FFA5AEBC: E59F0170 LDR R0, =0xD2B4
FFA5AEC0: E5900008 LDR R0, [R0, #0x8]
FFA5AEC4: E0800104 ADD R0, R0, R4, LSL #0x2
FFA5AEC8: E59000F0 LDR R0, [R0, #0xF0]
FFA5AECC: E8BD8010 LDMFD SP!, {R4, PC}

Note that in the SX10 firmware, FocalLengthConverter.c is called ZoomLensConverter.c instead.

The next step will be to find the equivalent in the reference dumps for the signature genration (hopefully it is present and similar in the vxworks references).  It will be nicer to work with in-camera calibrated focal lengths rather than having it estimated by zoom position (it isn't linear)

*

Offline reyalp

  • ******
  • 14034
Re: DoF values and other related items
« Reply #41 on: 28 / November / 2009, 23:39:54 »
The existing values on most cameras are not estimated. They are taken from exif data at each zoom step. Only cameras with a lot of zoom steps (like sx10) interpolate between the exif values. I doubt the difference between the interpolation and real value is very significant.

That said, getting it directly from a canon function would be great. Would save effort in future ports, and have less room for error. Good stuff.
Don't forget what the H stands for.

Re: DoF values and other related items
« Reply #42 on: 29 / November / 2009, 15:50:53 »
The exif value is not necessarily always accurate as it seems with the exif av and tv values from what I can tell (at least from comparing the apectual apex96 values used vs the exif data for these), however you are right that they should be very similar.

Here is the full comparison for the SX10 (I had to do every other value for posting size, but you get the picture).  The bold values are the ones that are used for interpolation.  It looks like they have been rounded to the nearest 10 vs the camera reported values.
The differences do vary up to 10%.  Note that there is a large step from the zoom value 127 to 128 for some reason.

Quote
zoom     firmware focal length     old focal length     %difference     
0500050000.0%
252475216-0.6%
454415432-0.2%
6564156490.1%
8585458650.2%
10607760810.1%
1161946190-0.1%
12631564041.4%
14656768324.0%
16683872606.2%
18712676887.9%
20743781169.1%
22777385449.9%
248131897210.3%
268521940010.3%
288938982810.0%
309392102569.2%
329879106848.1%
3410408111126.8%
3610977115405.1%
3811595119683.2%
4012259123961.1%
4112612126100.0%
4212979131591.4%
4413751142573.7%
4614587153555.3%
4815481164536.3%
5016448175526.7%
5217476186506.7%
5418584197486.3%
5619766208465.5%
5821016219454.4%
6022350230433.1%
6223752241411.6%
6425239252400.0%
6626790270791.1%
6828423289181.7%
7030112307572.1%
7231876325962.3%
7433685344352.2%
7635559362742.0%
7837467381131.7%
8039427399521.3%
8241408417910.9%
8443432436300.5%
8645466454700.0%
8847533476180.2%
9049605497660.3%
9251706519150.4%
9453825540630.4%
9655948562120.5%
9858106583600.4%
10060276605080.4%
10262492626570.3%
10464733648050.1%
10565877658800.0%
10667035673630.5%
10869378703301.4%
11071803732972.1%
11274288762642.7%
11476876792313.1%
11679541821983.3%
11882324851653.5%
12085193881323.4%
12288180910993.3%
12491232940663.1%
12694359970332.8%
1281000001000000.0%

Re: DoF values and other related items
« Reply #43 on: 30 / November / 2009, 08:19:13 »
Note that there is a large step from the zoom value 127 to 128 for some reason.
I plotted the FW focal length vs the lens length and it makes sense now.  There is a larger lens movement at the last step corresponding with this.
« Last Edit: 30 / November / 2009, 17:06:14 by barberofcivil »


Re: DoF values and other related items
« Reply #44 on: 30 / November / 2009, 17:11:35 »
I have found the entrys for the 3 DryOS reference dumps, they all have the same structure so possibly only the first would be needed for signature building.

A720: FF603370
SD1100: FF92F558
SD980: FF947534

I'm still working on the vxworks.  I think I may have found it on the A570, but I will have to test yet to verify on my own camera, then find it in the other reference dumps if I can.


One of the odd things about the function in DryOS is that it branches to a function that is generally equivalent to the GetCurrentZoomPoint function, but is not the one used by CHDK.

*

Offline reyalp

  • ******
  • 14034
Re: DoF values and other related items
« Reply #45 on: 30 / November / 2009, 17:17:49 »
A720: FF603370
Typo ?

What units does it return ?
Don't forget what the H stands for.

Re: DoF values and other related items
« Reply #46 on: 30 / November / 2009, 20:50:16 »
A720: FF603370
Typo ?

What units does it return ?
Typo, should be FFD03370
(had a FFFFFFFF wraparound issue with the disassembly so I used FF500000 for the start address...)
Units is um (1000mm), actual focal length (not 35mm equivalent): 5000-100000.

*

Offline reyalp

  • ******
  • 14034
Re: DoF values and other related items
« Reply #47 on: 30 / November / 2009, 20:58:08 »
(had a FFFFFFFF wraparound issue with the disassembly so I used FF500000 for the start address...)
FWIW, you can trim the dump, or only load up to the point it doesn't wrap. There can't be valid ROM after FFFFFFFFF anyway ;)
Don't forget what the H stands for.


Re: DoF values and other related items
« Reply #48 on: 30 / November / 2009, 21:48:53 »
(had a FFFFFFFF wraparound issue with the disassembly so I used FF500000 for the start address...)
FWIW, you can trim the dump, or only load up to the point it doesn't wrap. There can't be valid ROM after FFFFFFFFF anyway ;)
Perhaps, but I'm using the perl script from the wiki, so I just did it the easy way.  I just have to remember to correct the address for it.

Re: DoF values and other related items
« Reply #49 on: 30 / November / 2009, 23:10:05 »
OK, I successfully found and tested for VXWorks cameras I have:
A570 101A: FFE85A24
S2IS 100G: FFA86F24

Based on these, I searched the VXWorks reference dumps and came up with:
1: A610 100E: FFE521C0
2: A710 100A: FFE8E6BC
3: A570 100E: FFE859B0

the A610 & A570 are similar.
The S2 is similar to the A610 & A570 structures.

I assume the A570 100E reference is correct as it is pretty much identical to 101A which tested successfully.
I would assume the A610 is correct based on it's similarity with A570.
The A710 structure has the same general idea as these 2 and I found it using the same methodology, so it should be correct, but would need to be tested.

 

Related Topics