Display (bitmap overlay)

  • 126 Replies
  • 41878 Views
Re: Display (bitmap overlay)
« Reply #30 on: 25 / February / 2017, 18:58:14 »
Advertisements
Attached is an experimental patch that - for simplicity - treats the DIGIC 6 overlay as if it were quarter resolution (half horizontally and half vertically). Only used my sx280 to test.
I'm far enough in the G16 port that I could probably test this. The text is very small on the G16 screen - it's the first port where I've selected a larger RBF font for the menus.

But any time I feel like complaining, I fire up my really old A560.  Now that was a painful display to read!
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline srsa_4c

  • ******
  • 3728
Re: Display (bitmap overlay)
« Reply #31 on: 01 / March / 2017, 21:05:43 »
Attached is the first (in progress) hi-res version of the DIGIC 6 drawing routines. platform_palette.c has to be modified on every D6 port, and it's recommended to reset the CHDK OSD related config. The bult-in 8x16 font is upscaled to 14x32. It doesn't look too pretty, but I think it's usable. Added bonus is that scalable OSD elements can be set to use the unscaled 8x16 font.
Drawing of the built-in font is accelerated for 8x16 and 14x32 sizes.
Zebra, etc. is not integrated yet.

*

Offline srsa_4c

  • ******
  • 3728
Re: Display (bitmap overlay)
« Reply #32 on: 05 / March / 2017, 20:34:20 »
Attached patch integrates 62ndidiot's zebra, histogram and motion detection developments into the hi-res DIGIC 6 display patch (platform_palette.c and the two stubs have to be added to other ports). I have only made changes to the zebra code, did not change the other two. Also renamed bzero4 to memset32 and changed the exported gui_draw routines.
I suspect that the routines I'm currently using for zebra may not be the final ones - I'm not sure if they are optimal.

Re: Display (bitmap overlay)
« Reply #33 on: 07 / March / 2017, 16:27:51 »
Quote
Attached patch integrates 62ndidiot's zebra, histogram and motion detection developments into the hi-res DIGIC 6 display patch (platform_palette.c and the two stubs have to be added to other ports). I have only made changes to the zebra code, did not change the other two. Also renamed bzero4 to memset32 and changed the exported gui_draw routines.


Downloaded and built for sx60hs. Seems to work fine. The menu fonts and ALT screen stuff is easier to read.
Some compiler warnings in gui_draw.c, that I don't recall seeing before:

Code: [Select]
./../../../core/gui_draw.c: In function 'set_transparent':
../../../../core/gui_draw.c:108:5: warning: passing argument 1 of '_bzero' discards 'volatile' qualifier from pointer target type [enabled by default]
     _bzero(&opacity_buffer[active_buffer_index][offset], n_pixel);
     ^
../../../../core/gui_draw.c:99:17: note: expected 'char *' but argument is of type 'volatile char *'
     extern void _bzero(char *s, int n);
                 ^
../../../../core/gui_draw.c: In function 'draw_2pixels_simple':
../../../../core/gui_draw.c:267:27: warning: initialization from incompatible pointer type [enabled by default]
     unsigned short *obu = current_opacity_buf;
                           ^
../../../../core/gui_draw.c:268:25: warning: initialization from incompatible pointer type [enabled by default]
     unsigned int *bbu = current_bitmap_buf;
                         ^
../../../../core/gui_draw.c: In function 'draw_hline_simple':
../../../../core/gui_draw.c:306:28: warning: initialization from incompatible pointer type [enabled by default]
     unsigned short *obud = current_opacity_buf;
                            ^
../../../../core/gui_draw.c:307:26: warning: initialization from incompatible pointer type [enabled by default]
     unsigned int *bbud = current_bitmap_buf;


*

Offline srsa_4c

  • ******
  • 3728
Re: Display (bitmap overlay)
« Reply #34 on: 07 / March / 2017, 21:12:26 »
Downloaded and built for sx60hs. Seems to work fine. The menu fonts and ALT screen stuff is easier to read.
Some compiler warnings in gui_draw.c, that I don't recall seeing before:
Thanks for trying. The warnings are due to some missing casts.

*

Offline srsa_4c

  • ******
  • 3728
Re: Display (bitmap overlay)
« Reply #35 on: 19 / March / 2017, 19:31:27 »
An explanation of this DIGIC 6 display "rework".

What it provides:

Display a big default font that is approximately same size as on previous DIGIC cams.
This is achieved by upscaling the original 8x16 font to 14x32. The 8 -> 14 conversion allows keeping the aspect ratio and provides 45 characters in a row (which is what cameras with 4:3 LCD used to have).
The font remains stored in its original 8x16 format.

The real display resolution is used.
Historically, supported Powershots started with an overlay of 360x240 pixels. Horizontal resolution was doubled in later camera generations, for which CHDK was adapted by writing double pixels. That has not changed further until the appearance of DIGIC 6.
I felt that halving the CHDK overlay resolution yet again is not the way to go, even if it's simpler to do.

Unfortunately, the CHDK drawing architecture relies heavily on paletted display where one pixel corresponds to one byte.
This patch therefore has to translate one byte colors to yuv chroma and luma values (plus opacity).

Pros:
- Default font is "normal" size again, should be more readable.
- Drawing is accelerated for the default font. Over 19000 (14000) chars/second according to benchmark - lower value is for drawing with unaligned (odd) starting position.
- OSD icons (battery, USB symbol, etc) are doubled (in each direction).
- CHDK menu and other UI elements fit on screen like they used to on previous camera generations.
- Palette is still computed, but almost all required CHDK colors are available.
- OSD elements can be set to use the unscaled "mini" 8x16 font, using the OSD editor.
- ...?

Cons:
- The 8 -> 14 translation introduces a distortion that changes the font's look somewhat.
- Accelerated drawing bypasses the old drawing infrastructure. Pixels of the default font are no longer drawn by a single pixel drawer routine. This is a very unfortunate loss, but I found no better way to improve the sluggish drawing speed.
- Drawing function replacement is ineffective for font drawing. It was only used by the zebra module. The new zebra code (made by 62ndidiot) does not use it.
- Accelerated routines (those with "simple" in their name) rely on global variables for current buffer addresses and foreground and background colors. This makes drawing even less thread safe (but I can't imagine it causing memory corruption).
- The new routines used by the new D6 zebra code "stand out", as they draw yuv colors directly, rather than CHDK ones. This is actually a change introduced by me.
- One of the D6 zebra specific new routine uses two stubs directly in core. This would be unsafe on ARM firmware, but doing so provides lower overhead and is safe on D6.
- The three D6 zebra specific functions are exported and require dummies on pre-D6 ports. This is an unfortunate overhead - the module specific tools would need to be changed to allow skipping nonexistent exports.
- The current D6 zebra can't display the histogram (those menu options are ignored).
- The new histogram (62ndidiot's work) has an inappropriate default position (not completely visible). Should be fixable.
- The CHDK boot logo doesn't display correctly, the bitmap part is unscaled and misplaced. Should be fixable.
- Some games use direct coordinates expecting 8x16 fonts - they look mostly unusable.
- ...?

The patch also contains a fix for a bug introduced with the (relatively recent) rotated OSD functionality. Just check what the file reader does when OSD is rotated.
62ndidiot's zebra, histogram and motion detection fixes are included, as noted above.
The patch does not support D6 ports other than my two, but the changes made to the M10 port should tell what to do (palette and two stubs).

BTW, I did not do this work to let it become buried here and forgotten. I'd like to hear others' opinions: should this go official, and if so, should parts of it change or not.

The alternative patch can be found earlier in this thread (the lo-res one).

edit:
I have doubts about the attachment download counter. It jumped to one right after posting (in a few seconds). A google-bot maybe?
« Last Edit: 19 / March / 2017, 19:33:57 by srsa_4c »

Re: Display (bitmap overlay)
« Reply #36 on: 19 / March / 2017, 20:48:25 »
Quote
The new histogram (62ndidiot's work) has an inappropriate default position (not completely visible). Should be fixable.
Feel free to adjust the default position as you see fit in order to make a complete patch. 
I'll retry this patch in a few days on the sx60hs.
Is there any generic way we can make this patch work for all digic 6 cams without by hand changes for updates in the platform specific directory?
I think it works very well and is a real improvement over the existing graphics.  thanks so much!!

Re: Display (bitmap overlay)
« Reply #37 on: 20 / March / 2017, 00:48:28 »
BTW, I did not do this work to let it become buried here and forgotten. I'd like to hear others' opinions: should this go official, and if so, should parts of it change or not.
I'll take a look at both patches on the G16 and weigh in with my opinion. Won't be until next weekend though.  I have been using an alternative menu font so I'm looking forward to trying a better solution.
Ported :   A1200    SD940   G10    Powershot N    G16


*

Offline reyalp

  • ******
  • 11592
Re: Display (bitmap overlay)
« Reply #38 on: 20 / March / 2017, 02:57:58 »
An explanation of this DIGIC 6 display "rework".
Thanks so much for doing this, as well as the detailed write up :)

I probably won't be able to dig into it much before next weekend, I have few initial comments that don't depend on getting into the code. It does build and run on G7 X (following the M10 example)

If we feel like this is the right direction, I'm fine with it going into the trunk with some unresolved issues.

Quote
I felt that halving the CHDK overlay resolution yet again is not the way to go, even if it's simpler to do.
That's my feeling too.

Quote
- The 8 -> 14 translation introduces a distortion that changes the font's look somewhat.
I think this is OK. I did notice the font looked a bit ugly compared to the large one I was using for the menu before, but it's readable and certainly better than the tiny font in the old version.

Quote
- The new routines used by the new D6 zebra code "stand out", as they draw yuv colors directly, rather than CHDK ones. This is actually a change introduced by me.
I think this is fine (conceptually at least, I haven't looked at the specific code) I would rather have separate code that makes sense for each platform than a tangle of stuff that tries to maximize re-use.
Quote
- One of the D6 zebra specific new routine uses two stubs directly in core. This would be unsafe on ARM firmware, but doing so provides lower overhead and is safe on D6.
_bzero  / _memset32 are quite simple functions, we could have our own versions in CHDK, or even inline them in the drawing function if it helps.

Anyway, no immediate worry. Would be nice to be able to generate build errors if someone did the same thing in a pre-digic 6 build.

Quote
- The three D6 zebra specific functions are exported and require dummies on pre-D6 ports. This is an unfortunate overhead - the module specific tools would need to be changed to allow skipping nonexistent exports.
We may want to deal with this in the future, especially if we end up with more functions like this, but with only 3 I don't think it needs to be addressed right away.

Quote
- The current D6 zebra can't display the histogram (those menu options are ignored).
It's better than having neither ;)

One thing I did notice about the zebra on g7x is that I had to set the thresholds quite high (25+ for both over and under) to see the zebra, even when pointing at a light in a dark room.
Don't forget what the H stands for.

Display (bitmap overlay)
« Reply #39 on: 20 / March / 2017, 03:10:18 »
Quote
- The current D6 zebra can't display the histogram (those menu options are ignored).
It's better than having neither ;)
Does the CHDK histogram do anything that the Canon one does not?  I've been under the impression that histogram was added in the early days of CHDK when it was not common for Canon firmware to provide one.  But I'm guessing every D6 camera will include a Canon histogram so maybe it could be dropped from the D6 CHDK builds?
Ported :   A1200    SD940   G10    Powershot N    G16

 

Related Topics