Optimize relative seeking with TIFFSetDirectory
Optimize relative seeking with TIFFSetDirectory
Looping through a tiff directory with TIFFSetDirectory was extremely slow for large files continaining thousands of directories: The problem is that TIFFSetDirectory was always starting at the first directory, instead of advancing relatively to the current directory.
The patch here addresses this shortcoming and thereby speeds up code that does something like this:
int imageCount = TIFFNumberOfDirectories(tiff);
for (int i = 0; i < imageCount; ++i)
TIFFSetDirectory(tiff, i);
Previously, this was basically O(N^2), now it's O(N).
Testfiles test_directory.c and test_ifd_loop_detection are updated to test those optimizations.
This MR !474 (merged) replaces the obsolete MR !453 (closed).
Edited by Su Laus