Repository navigation
Fix routing, orientation, and video correctness issues from project review - #30
Merged
Merged
Conversation
Service discovery instantiates every installed backend on every platform. Check the operating system before touching a platform's native bindings, and register the Apple video backend through a lightweight wrapper that only loads the AVFoundation bridge on macOS. Run the example consumer as a named module, and drop ROUTING.md now that the README carries the routing contract. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VwoQ7k4zMHqQ43juZ2juRw
The routing SPIs kept the decision made in canDecodeInput in a thread-local and handed it to the next createReaderInstance call. A caller that probed one input and then asked for a reader by format name received the backend chosen for the earlier input. Always return a deferred reader that selects its owner from the input passed to setInput. RoutingImageReader now reports the owning backend and forwards listeners and abort to the backend reader. The video reader re-routes on each input unless it was bound to a backend. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VwoQ7k4zMHqQ43juZ2juRw
Apple and WIC return display-oriented images, but libvips and ImageMagick returned the stored orientation. Because portable backends win intersections by default, installing either one un-rotated phone photos. libvips also disagreed with itself: reduced decodes go through vips_thumbnail, which rotates, while full decodes did not. Rotate full, cropped, and reduced decodes in both backends and report display-oriented dimensions from the size queries. libvips reopens an image with random access when it needs a transform, since rotation cannot be streamed. The per-call downcall handle for the sequential loader is now created once. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VwoQ7k4zMHqQ43juZ2juRw
AVFoundation applies the track's preferred transform when it extracts a frame, but the reported size was the stored one, so a portrait video reported 32x16 and returned a 16x32 frame. FFmpeg ignored the display matrix altogether and returned the frame sideways, and a seek returned the keyframe before the requested time rather than the frame at it. Report the displayed size on both backends, rotate FFmpeg frames by the display matrix, and decode forward from the keyframe to the requested time. Drain an autorelease pool around the AVFoundation calls so long-lived Java threads do not accumulate assets and generators. Add rotated and long-GOP fixtures with their generator scripts. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VwoQ7k4zMHqQ43juZ2juRw
TIFF-based RAW formats were recognised by searching the first 4 KB for "DNG", "Nikon", or "SONY", case-insensitively. A plain TIFF exported from a camera JPEG, or one whose text happened to contain those letters, was classified as RAW and bypassed any routing preference for TIFF. Read the first IFD instead: DNG by its version tag, NEF and ARW only when the make matches and the first IFD is a preview of sub-IFD data. Let a codec brand win over the generic HEIF brands so an AVIF or HEIC file with a mif1 major brand keeps its codec's format, and share one still-image brand list with video detection so Canon CR3 and JPEG XL are no longer offered to video backends. Audio-only MP4 is skipped. Read imageio.native.maxPixels in one place. libvips previously hard-coded the limit, and the video reader kept its own copy of the intermediate-size limit. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VwoQ7k4zMHqQ43juZ2juRw
Drop FormatDetector.matchesFtyp and matchesWebP, which nothing has called since routing moved to the single format detector; the javaNative flag on FormatRegistry.Format, which no code reads; and the deprecated, unregistered PathAware stream aliases in video-common, superseded by the ones in common. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VwoQ7k4zMHqQ43juZ2juRw
Bring back FormatDetector.matchesFtyp and matchesWebP, the javaNative component of FormatRegistry.Format, and the deprecated PathAware stream aliases in video-common. They stay part of the public API. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VwoQ7k4zMHqQ43juZ2juRw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes from a full project review. Each commit is one fix with its own regression tests.
canDecodeInputdecision in a thread-local and handed it to the nextcreateReaderInstance. A caller that probed one input and then requested a reader by format name got the backend chosen for the earlier input. Readers are now always deferred and route from the input passed tosetInput.mif1major brand. Video detection shares the still-image brand list, so Canon CR3 and JPEG XL are not offered to video backends.imageio.native.maxPixelsis read in one place.ROUTING.mdis removed (the README carries the contract).Behaviour and API changes
ImageIO.getImageReaders(input)now returnsRoutingImageReaderrather than the backend's reader class.RoutingImageReader.backendId()reports the owner; listeners andabort()are forwarded. Each read probes the input twice.tiffand still decoded by any backend whose probe accepts it.NativeLimits,FormatDetector.isStillImageBrand, fixturestest-video-rotated.mp4andtest-video-long-gop.mp4with generator scripts.Testing
./mvnw clean install— 270 tests, 0 failures, 32 skipped (Windows-only).example-consumer— 17 tests pass.WicImageReaderTestwas updated for the new reader type without being run; CI needs to confirm it.Follow-up outside this repo
panama-media0.1.4:AVFoundation.getVideoInfoignores the track's preferred transform, andgetVideoInfo/extractFramedo not hold an autorelease pool. Both are worked around here.🤖 Generated with Claude Code
https://claude.ai/code/session_01VwoQ7k4zMHqQ43juZ2juRw