Re: cOMp chunk [was: EXIF support in PNG]
Glenn Randers-Pehrson <[email protected]>
| Newsgroups | gmane.comp.graphics.png.general |
|---|---|
| Message-ID | <CA+PdXcvGcf8nN66B_F20HBO+H3YDTO+ZR2w=Arf+GaC+RG_OiQ@mail.gmail.com> |
On Sun, Jan 29, 2017 at 12:23 PM, John Bowler < [email protected]> wrote: > Glenn has made a number of off-thread proposals about "comp" plus the > on-thread one of moving the compression byte. I don't see any merit > in these. In particular the suggestion to add a keyword reveals a > complete misunderstanding of the merits of the chunk. > Just to clarify: I am not suggesting that the comp chunk have a keyword. My suggestion is to have a one-byte "prefix_length" that informs the compressor/decompressor that the first N bytes of chunk data should be passed through in-the-clear, and the remainder of the chunk data be compressed. Imagine doing a "cOMp" chunk containing a tEXt chunk. original chunk: [original length]tEXtAuthor\0Glenn Randers-Pehrson[original CRC] becomes [comp-chunk length]cOMp\0\7[original length]tEXtAuthor\0[gibberish][comp-chunk-CRC] but without the prefix-length, [comp-chunk length]cOMp\0[original length]tEXt[gibberish][comp-chunk-CRC] The chunks look like this (using "od" to display them): glenn.rp> od -c glenn.tEXt: 0000000 \0 \0 \0 1 t E X t A u t h o r \0 G 0000020 l e n n R a n d e r s - P e h 0000040 r s o n < g l e n n r p @ g m 0000060 a i l . c o m > \n 261 341 | { 0000075 glenn.rp> od -c glenn.cOMp (no prefix_length): 0000000 \0 \0 \0 D c O M p \0 t E X t x 001 c 0000020 \0 002 303 022 327 210 022 307 322 222 214 374 " 006 367 234 0000040 324 274 < 205 240 304 274 224 324 242 b 335 200 324 214 242 0000060 342 374 < 005 233 t 220 p Q 201 C z n b f 216 0000100 ^ r ~ 256 035 027 \0 027 310 023 j \n 264 373 357 177 0000120 glenn.rp> od -c glenn.cOMp (prefix_length=12): 0000000 \0 \0 \0 C c O M p \0 \n \0 \0 \0 1 t E 0000020 X t A u t h o r \0 G l e n n x 001 0000040 343 J 314 K I - * 326 \r H 315 ( * 316 317 S 0000060 260 I 317 I 315 313 + * p H 317 M 314 314 321 K 0000100 316 317 265 343 002 \0 374 221 \r 7 \n X 315 300 032 0000117 Note that the prefix_length doesn't have to actually match the inner chunk's keyword length (here the keyword is length 7, but I asked cOMp to keep the first 12 bytes in-the-clear). Glenn ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ png-mng-misc mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/png-mng-misc