I'm working on more efficient badpixel formats. The results will surely be limited by my less than optimal math skills, but at least I now have something that appears to work. I got ideas from previous threads in this forum, thanks for those who mentioned them.
Because my limited skills, I'm only using halfword units, not a bitstream.
The common part of the schemes is that one badpixel coordinate (x) is relative, not absolute. I'm also assuming that the y coordinate fits in 12bits (AFAIK it's true for all current Canon compacts).
Description of the v4 method (v4 is what I call it):
Badpixel descriptors are stored in 16bit halfwords.
bit11...bit0: [y dimension, except when 0x0fff] 0xfff means dummy badpixel, only needed when x distance from previous badpixel exceeds 14.
bit15..bit12: IF not dummy:
0...14: x distance from previous badpixel (or dummy or the "0" coordinate of the x axis)
15: last badpixel in a group of badpixels
This scheme can "compress" like this:
- RLE compressed badpixel groups: 4 bytes before, 4 bytes after, however group length is not limited by 8
- single badpixels: 4 bytes before, 2 bytes after
- overhead: long x "gaps" without badpixels will result in added dummy badpixel descriptors
Example CMOS case (
Ixus310): 153180 bytes -> 103400 bytes
Example CCD case (Ixus870): 80128 bytes -> 40270 bytes
I have some ideas that can improve the compression of badpixel groups, it's in progress.
Attached is a patch for trunk (for testing only, replaces existing routines, NOT compatible with stock badpixel.bins), and a command line utility for transforming between the current and "v4" format. Both can contain errors, and the method is fixed to the above mentioned 12+4 bit split.
If something like this ever gets in, I would change the badpixel.bin file name AND use a proper file header - current method needs CAM_ACTIVE_AREA_X1 to work correctly.
Critique, suggestions, etc. are welcome. Sorry about the messy coding style.