From fe1a7d53ca32be8a2fe7d1af005fbc0f3c540f9c Mon Sep 17 00:00:00 2001 From: ghosthack <837911+ghosthack@users.noreply.github.com> Date: Fri, 13 Nov 2026 20:45:23 -0800 Subject: [PATCH] Move to panama-media 0.1.5 panama-media 0.1.5 reports the displayed size of rotated video from getVideoInfo, so the width/height swap in AppleVideoFrameExtractor.getInfo would now correct it twice. Remove the swap and the preferredTransform lookup it needed. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01VwoQ7k4zMHqQ43juZ2juRw --- .../video/apple/AppleVideoFrameExtractor.java | 48 ++----------------- pom.xml | 2 +- 2 files changed, 4 insertions(+), 46 deletions(-) diff --git a/imageio-native-video-apple/src/main/java/io/github/ghosthack/imageio/video/apple/AppleVideoFrameExtractor.java b/imageio-native-video-apple/src/main/java/io/github/ghosthack/imageio/video/apple/AppleVideoFrameExtractor.java index 6722498..7680d49 100644 --- a/imageio-native-video-apple/src/main/java/io/github/ghosthack/imageio/video/apple/AppleVideoFrameExtractor.java +++ b/imageio-native-video-apple/src/main/java/io/github/ghosthack/imageio/video/apple/AppleVideoFrameExtractor.java @@ -68,17 +68,6 @@ private static UnsupportedOperationException unavailable() { private static final MethodHandle msgSend_ptr_ptr; /** (id, SEL) → BOOL */ private static final MethodHandle msgSend_ret_bool; - /** (id, SEL) → CGAffineTransform */ - private static final MethodHandle msgSend_ret_transform; - - /** CGAffineTransform: six CGFloat members {@code a, b, c, d, tx, ty}. */ - private static final StructLayout CGAFFINETRANSFORM = MemoryLayout.structLayout( - ValueLayout.JAVA_DOUBLE.withName("a"), - ValueLayout.JAVA_DOUBLE.withName("b"), - ValueLayout.JAVA_DOUBLE.withName("c"), - ValueLayout.JAVA_DOUBLE.withName("d"), - ValueLayout.JAVA_DOUBLE.withName("tx"), - ValueLayout.JAVA_DOUBLE.withName("ty")); static { if (AVAILABLE) { @@ -91,14 +80,11 @@ private static UnsupportedOperationException unavailable() { ValueLayout.ADDRESS, ValueLayout.ADDRESS)); msgSend_ret_bool = CoreFoundation.msgSend(FunctionDescriptor.of(ValueLayout.JAVA_BYTE, ValueLayout.ADDRESS, ValueLayout.ADDRESS)); - msgSend_ret_transform = CoreFoundation.msgSend(FunctionDescriptor.of(CGAFFINETRANSFORM, - ValueLayout.ADDRESS, ValueLayout.ADDRESS)); } else { msgSend = null; msgSend_ptr = null; msgSend_ptr_ptr = null; msgSend_ret_bool = null; - msgSend_ret_transform = null; } } @@ -166,33 +152,6 @@ private static MemorySegment playableVideoTrack(Arena arena, Path videoFile) } } - /** - * Returns whether the track's preferred transform turns the picture by an - * odd number of quarter turns, so that the displayed frame has the stored - * width and height swapped. The frame generator applies that transform, - * while the track's natural size does not include it. - */ - private static boolean displayTransposed(Path videoFile) { - MemorySegment pool = CoreFoundation.autoreleasePoolPush(); - try (Arena arena = Arena.ofConfined()) { - MemorySegment track = playableVideoTrack(arena, videoFile); - if (MemorySegment.NULL.equals(track)) return false; - MemorySegment transform = - (MemorySegment) msgSend_ret_transform.invokeExact( - (SegmentAllocator) arena, track, - CoreFoundation.selRegisterName(arena, "preferredTransform")); - double a = transform.get(ValueLayout.JAVA_DOUBLE, 0); - double b = transform.get(ValueLayout.JAVA_DOUBLE, 8); - if (a == 0 && b == 0) return false; - long quarterTurns = Math.round(Math.toDegrees(Math.atan2(b, a)) / 90.0); - return (quarterTurns & 1) != 0; - } catch (Throwable ignored) { - return false; - } finally { - CoreFoundation.autoreleasePoolPop(pool); - } - } - @Override public BufferedImage extractFrame(Path videoFile, Duration time) throws IOException { return extractFrame(videoFile, time, null); @@ -235,11 +194,10 @@ public VideoInfo getInfo(Path videoFile) throws IOException { MemorySegment pool = CoreFoundation.autoreleasePoolPush(); try (Arena arena = Arena.ofConfined()) { var info = AVFoundation.getVideoInfo(arena, videoFile.toAbsolutePath().toString()); - // Report the displayed size, which is what extractFrame returns. - boolean transposed = displayTransposed(videoFile); + // The binding reports the displayed size, which is what + // extractFrame returns. return new VideoInfo( - transposed ? info.height() : info.width(), - transposed ? info.width() : info.height(), + info.width(), info.height(), Duration.ofMillis(info.durationMillis()), null, info.frameRate()); } catch (RuntimeException e) { throw new IOException("Video info extraction failed", e); diff --git a/pom.xml b/pom.xml index c8c41f5..16e8714 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,7 @@ UTF-8 26 6.1.2 - 0.1.4 + 0.1.5 8.1.2-0.3.2