making sense of tv values - page 2 - Script Writing - CHDK Forum

# making sense of tv values

• 13 Replies
• 10628 Views

#### fbonomi

• 469
• A570IS SD1100/Ixus80
##### Re: making sense of tv values
« Reply #10 on: 21 / February / 2009, 04:04:55 »
>>It's standard APEX system
I've read the wiki page and i'm still not entirely sure what you mean by that - and I have a four year degree in photography!

This: http://doug.kerr.home.att.net/pumpkin/APEX.pdf
Is the best explanation I have found around of the APEX system

#### wiffel

• 1
##### Re: making sense of tv values
« Reply #11 on: 12 / July / 2010, 13:01:10 »
Since this is an old topic, I'm not quite sure somebody is still interested in this. But I noticed that we are lacking a good log2 in Lua that can work with plain integers.

I wrote (a fast) one that also takes an (optional) multiplicator factor as second parameter. Using this mult parameter, there is less loss of parts behind the comma in the result.

Anyway, here it is ...

Code: [Select]
function min(a, b)
return a < b and a or b;
end

function max(a, b)
return a > b and a or b;
end

-- returns : mult * log2(x)
-- mult is optional, it defaults to 1
-- safe for x between 0 and 2097152
function log2(x, mult)
local mult = mult or 1;
local x = min(max(x, 0), 2097152);
local result = 0;
x = bitshl(x, 10);
while x >= 2048 do
result = result + 1048576;
x = bitshru(x, 1);
end
local fraction = 1048576;
while fraction >= 1 do
fraction = bitshru(fraction, 1);
x = bitshru(x * x, 10);
if x >= 2048 then
result = result + fraction;
x = bitshru(x, 1);
end
end
return bitshru(mult * result, 20);
end

Using this log2, the nice functions fbonomi provided us with can now be written fairly trivial as ...

Code: [Select]

function msec_2_tv96(milliseconds)
return log2(milliseconds, -96) + 957;
end

function sec_2_tv96(seconds)
return log2(seconds, -96);
end

function iso_2_sv96(iso)
return log2(iso, 96) - 157;
end

A little warning ...
I'm still anxiously waiting for my new little A480 to arrive, so I had no chance to actually test it in real live yet.
I hope I can do that tomorrow.
« Last Edit: 12 / July / 2010, 16:26:44 by wiffel »
Canon Powershot A480
Canon Powershot S60
Samsung GX-1S

#### fbonomi

• 469
• A570IS SD1100/Ixus80
##### Re: making sense of tv values
« Reply #12 on: 12 / July / 2010, 13:22:06 »
woah! cool!
i don't have my camera either to test it immediately, but that's waaay cool !

#### mattkime

• 299
##### Re: making sense of tv values
« Reply #13 on: 12 / July / 2010, 14:03:56 »
sweet! awesome for a first post. welcome!