Re: Support of RGBA 10x10x10x2 ?

John Bowler <[email protected]>
Newsgroups gmane.comp.graphics.png.general
Message-ID <CAP7U39-iaqxCNHLCOfxAq6fOZGF42jEnrSHdCLYYc9JsqodZZw@mail.gmail.com>
On Sat, Jan 14, 2017 at 8:07 AM, Glenn Randers-Pehrson
<[email protected]> wrote:
> On Sat, Jan 14, 2017 at 10:13 AM, John Bowler
> <[email protected]> wrote:
>> It's not going to be very good, but it is probably comparable to the
>> result of bit-packing the values into 32 bits then LZ77 compressing
>> 4-byte pixels.  In neither case are the bit patterns aligned to byte
>> boundaries so they don't compress well with LZ77.
>
>
> It also defeats the filtering that is based upon correlation of bytes
> between adjacent pixels.

The filtering still works in the 64-bit expansion, indeed, it works
quite well because the low order 8 bits of each component can be made
to have only four possible values.

The problem posed by the filtering for 16-bit components is that, as
you say, the filtering only applies at the byte level, so for the
sequence of two pixels:

    | R1Hi | R1Lo | G1Hi | G1Lo | B1Hi | B1Lo | A1Hi | A1Lo |
    | R2Hi | R2Lo | G2Hi | G2Lo | B2Hi | B2Lo | A2Hi | A2Lo |

The filter algorithms compare [x1Hi]x[x2Hi] and [x1Lo]x[x2Lo}.  That
means that the way you extend the 10-bit values to 16-bits when
maximizing compression is by storing the 2 "Lo" bits in the "Lo" byte
by replication:

    ABCDEFGHJK -> | ABCDEFGH | | JKJKJKJK |

And for the 2-bit alpha do the same but throughout both Hi and Lo bytes:

    LM - > | LMLMLMLM | LMLMLMLM |

This results in only four possible values (0x00, 0x55, 0xCC, 0xFF) for
5 of the 8 bytes in each pixel together with all 256 possible values
for the "Hi" RGB bytes.  This gives the LZ77 algorithm the best
possible chance of finding strings and, anyway, it can find an
incredibly efficient Huffman encoding even without filtering.  In the
worst case Huffman encoding the four "common" bytes reduce to 3 bits
each and the "Hi" RGB bytes require 9 bits each.  That's a total of 42
bits without any LZ77 stuff.

The Huffman for the corresponding 4-byte packed representation is,
IRC, still 36 bits and neither the LZ77 stuff nor the filtering work.

It's making me want to try compressing some 10-bit images ;-)   Really
cheap digital detectors these days produce 10 bits because you need 10
bits to get even vaguely acceptable digital camera images.

-- 
John Bowler <[email protected]>
+1 (541) 450-9885
PO BOX 3151
KERBY OR 97531-3151
USA

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.