]> granicus.if.org Git - libjpeg-turbo/commit
TurboJPEG: Document xform issue w/ big marker data
authorDRC <information@libjpeg-turbo.org>
Wed, 28 Jun 2017 19:47:45 +0000 (14:47 -0500)
committerDRC <information@libjpeg-turbo.org>
Wed, 28 Jun 2017 20:22:33 +0000 (15:22 -0500)
commitb0971e47d76fdb81270e93bbf11ff5558073350d
treed0b851a75aa040e52a75a1f375c4c2521abc4f47
parente248d430e21e39c8d00bdb48dc99a70c1a1ed5e3
TurboJPEG: Document xform issue w/ big marker data

If the source image for a transform operation has a lot of EXIF or ICC
data embedded in it, then it may cause the output image size to exceed
the worst-case size returned by tjBufSize() (because tjTransform()
transfers all markers to the output image.)  This is only a problem if
TJFLAG_NOREALLOC is passed to the function.  Since the TurboJPEG C API
doesn't require the destination image size to be set in this case, it
makes the documented assumption that the calling program has allocated
the destination buffer to exactly the size returned by tjBufSize().
Changing this assumption would change the API behavior and necessitate
a new function name (tjTransform2().)  At the moment, it's easier to
just document this as a known issue, since it's easy to work around in
the C API.

The Java API is unfortunately a different story, since it must always
use TJFLAG_NOREALLOC (because, when using the TurboJPEG Java API, all
buffers are allocated on the Java heap, and thus they can't be
reallocated by the C code.)  There is no easy way to work around this
without changing the C API as discussed above, because if the source
image contains large amounts of marker data, it's virtually impossible
to determine how big the output image will be.
doc/html/group___turbo_j_p_e_g.html
turbojpeg.h