Live viewports - size, aspect, encoding - General Discussion and Assistance - CHDK Forum

Live viewports - size, aspect, encoding

  • 4 Replies
  • 6815 Views
*

Offline reyalp

  • ******
  • 14118
Live viewports - size, aspect, encoding
« on: 05 / July / 2010, 00:23:31 »
Advertisements
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_Tools

In 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.
Code: [Select]
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)
Don't forget what the H stands for.

*

Offline c10ud

  • ***
  • 245
Re: Live viewports - size, aspect, encoding
« Reply #1 on: 14 / July / 2010, 05:37:58 »
i tried with a "skipy" cam, and you must double "npixels" in order to get a complete image (see code)

edit: and no need to do oheight = height/2, at least this is what i did in order to make a480 work :p
« Last Edit: 14 / July / 2010, 09:09:34 by c10ud »

*

Offline srsa_4c

  • ******
  • 4451
Re: Live viewports - size, aspect, encoding
« Reply #2 on: 30 / October / 2011, 00:34:58 »
Some observations on an IXUS 30 (DIGIC II), play mode.
The size of the viewports (in play mode) depends on several factors:
- without using tv-out, they are 720x240
- with tv-out their size depends on the "video system" setting
 PAL -> 720x576, used area 704x576
 NTSC -> 720x480, used area 704x480

Had to investigate this because of histogram and zebra weirdness. The reason was the tv-out, which was used all the time. This also means these functions will never work correctly with tv-out in this cam (in play mode).

IXUS 65 (also DIGIC II), play mode:
The viewport for tv-out is a separate buffer, behaves like the one described above.
The usual viewport for vid_get_viewport_fb_d() is fixed size, 720x240.
« Last Edit: 30 / October / 2011, 17:34:11 by srsa_4c »

*

Offline srsa_4c

  • ******
  • 4451
Re: Live viewports - size, aspect, encoding
« Reply #3 on: 30 / October / 2012, 20:25:10 »
I noticed on a DIGIC4 camera (and found out it applies to even DIGIC II models), that there's a (single) dynamically allocated buffer for the bitmap overlay (in addition to the double, static one which is used by CHDK). It's allocated from the "malloc" heap, so it's one of the reasons that new cameras with their huge overlay dimensions have so small amount of free memory available.


*

Offline srsa_4c

  • ******
  • 4451
Re: Live viewports - size, aspect, encoding
« Reply #4 on: 14 / March / 2013, 13:13:25 »
Ixus 65 (DIGIC II)
active viewport during shooting
nr 0: 0x105F17A0
nr 1: 0x1067CB20
nr 2: 0x10707EA0
nr 3: 0x105599A0


vid_get_viewport_live_fb() only expects 0..2 as the index value, so it's not optimal when half-shooting

all viewports get overwritten during the shooting process, event the first in memory (nr 3), so none of them is suitable for edge overlay...

viewport index is sampled in spytask

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal