Closed kleisauke closed 5 days ago
I identified that the reason for this is the security limit on the maximum memory allocation size when allocating the output image memory: https://github.com/strukturag/libheif/blob/e18c15e1365eeee83e7ee1da8376f33a88e176b6/libheif/pixelimage.cc#L260-L262
The individual Y,Cb,Cr planes of the input are below the allocation limit, but the combined, interleaved RGB image exceeds the limit in the color conversion. Because of this, the error only happens when exporting to an RGB format, but exporting to JPEG works.
The error message is misleading and I'll improve that.
Unfortunately, the security check uses the global limits and adding the command line option --disable-limits
does not work in this case. I'll work on that.
Now, it returns this error instead: Could not decode image: Memory allocation error: Security limit exceeded: Allocating 867136015 exceeds the security limit of 536870912 bytes
And now it decodes with --disable-limits
.
Thanks! I confirm that it decodes correctly with --disable-limits
and would otherwise give a proper error message without that flag now.
Note to self: libvips should align the unlimited
load flag to libheif's --disable-limits
flag.
https://github.com/strukturag/libheif/blob/8a139a67ad3ceaaa236ae3c62d32f652e4e5f600/examples/heif_dec.cc#L800-L802
See e.g. commit https://github.com/kleisauke/libvips/commit/5bf7cc60b080d397ef62d37840b664a0bafbc76b. However, this should likely be done after the loader/saver is revised to a tile-based one.
Thanks for the test file and the confirmation.
With this test image: https://github.com/libvips/libvips/blob/master/test/test-suite/images/17000x17000.avif
v1.19.0
andv1.19.3
- decoding fails with the following error:v1.18.2
- decoding succeeds:Interestingly, the AVIF image decodes correctly when outputting to a JPEG image on both versions, suggesting that this issue might be related to the following change in the v1.19.0 release notes:
Let me know if I should perform a
git bisect
.