Dynamic arrays in libpng

Cosmin Truta <[email protected]>
Newsgroups gmane.comp.graphics.png.devel
Message-ID <CAAoVtZztJuyLrxmUxE1O-3VTevg8wf+fcB2NoWSmM4FjhhXozw@mail.gmail.com>
Hi,

Related to the topic of unknown zlib stream length (but not related to
the security implications that I had mentioned), I have realized that
dynamic arrays are useful even outside the immediate zTXt/iCCP
applications.

For example, png_set_unknown_chunks() works well if all of the unknown
chunks are added all at once; but not so well if they are added in
repeated batches. In the worst case, unknown chunks get added one by
one (which, for example, is done in OptiPNG). If there is, say, a
thousand (however small) unknown chunks, there will be a half-million
operations!

On the same topic, png_set_text() does a slightly better job,
reallocating at each of the 8th insertion; but overall, the complexity
of this algorithm is still quadratic.

A dynamic array implementation, on the other hand, will guarantee an
efficient N*log(N) execution, for all the arrays that need to be
constructed dynamically.

Would you (Glenn) accept such a contribution? This data structure may
then serve as the basis for efficient iCCP implementation also.

Sincerely,
Cosmin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
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.