This is a brain dump of stuff I've spent some time puzzling over. Will try to make it into a wiki article once I actually understand it.
I've added a tool called yuvconvert which can convert live view dumps to either RGB or split it into 8 bit greyscale files containing the Y, U and V channels. It's documented in the source and
http://chdk.wikia.com/wiki/CHDK_ToolsIn all CHDK cameras, the live view is
YUV (or more properly
YCbCr or Y'CbCr ?) UYVYYY with 1 byte per element. So every 6 bytes encodes 4 pixels, and luminance (Y) has 4x the horizontal resolution of color.
In "traditional" CHDK cameras (pre Digic IV, roughly), the live view is 720x240 (if you count Y elements),
BUT the code that accesses the live view only looks at half the Ys, and every pair of Y uses a single set of U and V.
With the above method, the code can pretend there is a 1:1 correspondence between bitmap and live pixels (neglecting minor height differences), and the extra Y's are simply ignored.
In D10 and sd990 (and possibly ixus 100), the bitmap 720x240, and the live view is the same as older cameras (720 Y values, which would be called 360 in CHDK). This means that code (such as zebra) which assumes the old relationship between bitmap and live fails.
Other newer cameras
s90 and g11
lib.c has viewport 720x240 bitmap 320x240
but (in s90 at least) 720 is the *actual* width (number of Y elements in a line) and the actual height is 480. This is verified from a live view dump. I don't understand how this works for zebra, edge overlay etc., if it does.
sx200, sx20,
have viewport 360x240 and bitmap 320x240. I'm still unclear as to the actual layout and how the various special cases handle it. The bitmap buffer is given as 960x270, and some comments seem to indicate this is the real bitmap resolution ?
The following lua code can be used in a native call enabled build to dump the live view. You may get tearing or snow if the frame updates while it is writing.
DUMPFILE="A/LIVE.BIN"
addr=0x40A05158
size=(720*240*12)/8
f=call_event_proc("Fopen_Fut",DUMPFILE,"wb")
if (f==0 or f==-1) then
errf("Fopen_Fut %s failed %d",DUMPFILE,f)
end
r=call_event_proc("Fwrite_Fut",addr,size,1,f)
if (r ~= 1) then
printf("Fwrite_Fut return %d expect 1",size)
end
call_event_proc("Fclose_Fut",f)