I don't see anyplace in the code where m_cache_scanline is set to true, so I don't believe this fast path will ever come into play. Therefore, for an interlaced file, it will close, open, seek_subimage, and reread the entire file up to that scanline, for EVERY call to read_scanline.

THAT is the source of the performance issue. Everything else we've been talking about is minor in comparison.