the_mitsuhiko 6 hours ago |

I don't know much about this proposal but I know that the restart marker proposal exists which I believe tries something very similar: https://github.com/w3c/png/issues/60

//EDIT: also Apple is assumed to have an extension that does something similar: https://www.hackerfactor.com/blog/index.php?/archives/895-Co...

pornel 6 hours ago | root | parent |

This proposal is much simpler — it encodes slices of the image with filters and zlib block boundaries that make them naturally independent and obviously correct, and just adds a chunk saying "yeah, it's safe to use that".

The restart marker proposal just adds more configurability on top of that, which IMHO isn't needed. It makes implementation more fiddly. And I'm not sure why they're talking about recovering from broken gzip when spec-conforming encoder shouldn't generate broken gzip.

LegionMammal978 3 hours ago | root | parent |

Restart markers aren't necessarily much more configurable than this proposal. Segmentation type 1 is basically identical to this proposal, except that the fixed number of scanlines in each segment is computed slightly differently. Segmentation type 0 just adds an offset array on top of that, but I can't tell if it's just to enable seeking, or if it's to allow multiple IDAT chunks within a single segment. If the latter is the case, I guess that would make it somewhat more complicated, though the author has suggested limiting the proposal to one type or the other.

Meanwhile, the error-recovery part isn't about a broken DEFLATE stream, it's about avoiding specially-crafted files that would produce one image if decoded using the restart markers, but another image if decoded without them. To prevent the usual issues with different tools yielding different results, this is made an error. But the PNG spec suggests that errors in ancillary chunks shouldn't ever be fatal:

> However, it is recommended that unexpected field values be treated as fatal errors only in critical chunks. An unexpected value in an ancillary chunk can be handled by ignoring the whole chunk as though it were an unknown chunk type. [0]

Therefore, the extension tells decoders to restart with sequential decoding in that case, instead of bailing out entirely.

[0] https://www.w3.org/TR/2003/REC-PNG-20031110/#13Error-checkin..., unchanged in https://www.w3.org/TR/2024/CRD-png-3-20240718/#13Error-check...