From 419299180f4971e9d8fe5a44f6c58f0bb354d8c6 Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Tue, 20 Feb 2024 20:47:32 +0900 Subject: [PATCH 1/7] [artmaster88] satisfy the specs. more --- .../vavi/awt/image/am88/ArtMasterImage.java | 50 +++++++++++++++---- .../awt/image/am88/ArtMasterImageSource.java | 4 +- .../imageio/am88/ArtMasterImageReader.java | 38 ++++++++------ 3 files changed, 65 insertions(+), 27 deletions(-) diff --git a/src/main/java/vavi/awt/image/am88/ArtMasterImage.java b/src/main/java/vavi/awt/image/am88/ArtMasterImage.java index 729b09d..0f2efe7 100644 --- a/src/main/java/vavi/awt/image/am88/ArtMasterImage.java +++ b/src/main/java/vavi/awt/image/am88/ArtMasterImage.java @@ -22,6 +22,8 @@ *

* magic SS_SIF * separated RGB RLE + *

+ * TODO 400 line * * @author Naohide Sano (umjammer) * @version 0.00 2019/04/10 umjammer initial version
@@ -41,24 +43,39 @@ public class ArtMasterImage { public ColorModel cm = defaultCm; /** width */ - public static final int W = 640; + private static final int W = 640; /** height */ - public static final int H = 200; + private int H = 200; /** Red buffer */ - private byte[] R = new byte[(W / 8) * H + 256]; + private byte[] R; /** Blue buffer */ - private byte[] G = new byte[(W / 8) * H + 256]; + private byte[] G; /** Green buffer */ - private byte[] B = new byte[(W / 8) * H + 256]; + private byte[] B; private static final byte[] header = { - 'S', 'S', '_', 'S', 'I', 'F', ' ', ' ', ' ', ' ', '0', '.', '0', '0', 0x1a, 0 + 'S', 'S', '_', 'S', 'I', 'F', ' ', ' ', ' ', ' ', '#', '.', '#', '#', 0x1a, 0 }; + /** */ + public int getWidth() { + return W; + } + + /** */ + public int getHeight() { + return H; + } + + /** */ + public ColorModel getColorModel() { + return defaultCm; + } + /** * Creates ArtMaster88 image. * @throws IllegalArgumentException when header is wrong @@ -70,15 +87,18 @@ public ArtMasterImage(InputStream in) throws IOException { int l = 0; while (l < 40) { l += in.read(buf, l, 40 - l); -//Debug.println(l); } -//Debug.dump(buf); for (int i = 0; i < 16; i++) { - if (buf[i] != header[i]) { + if (header[i] == '#') { + if (!Character.isDigit(buf[i])) { + throw new IllegalArgumentException("wrong version: " + StringUtil.getDump(buf, 16)); + } + } else if (buf[i] != header[i]) { throw new IllegalArgumentException("wrong header: " + StringUtil.getDump(buf, 16)); } } +Debug.println(Level.FINE, "version: " + (char) buf[10] + "." + (char) buf[12] + (char) buf[13]); l = 0; if (buf[16] == 'I') { @@ -95,6 +115,18 @@ public ArtMasterImage(InputStream in) throws IOException { Debug.println(Level.FINE, "skip B: " + l); } + H = buf[26] & 0xff | (buf[27] & 0xff) << 8; + if (H == 0) H = 200; + if (H == 400) { + // TODO use recoil currently + throw new IllegalArgumentException("wrong height: 400 lines mode is not supported"); + } +Debug.println(Level.FINE, "height: " + H); + + R = new byte[(W / 8) * H + 256]; + G = new byte[(W / 8) * H + 256]; + B = new byte[(W / 8) * H + 256]; + PushbackInputStream pin = new PushbackInputStream(in, 2); for (int i = 0; i < 3; i++) { diff --git a/src/main/java/vavi/awt/image/am88/ArtMasterImageSource.java b/src/main/java/vavi/awt/image/am88/ArtMasterImageSource.java index 828674a..883c8d5 100644 --- a/src/main/java/vavi/awt/image/am88/ArtMasterImageSource.java +++ b/src/main/java/vavi/awt/image/am88/ArtMasterImageSource.java @@ -73,13 +73,13 @@ public ArtMasterImageSource(InputStream in) throws IOException { * Loads pixels. */ private void loadPixel() { - ic.setDimensions(ArtMasterImage.W, ArtMasterImage.H); + ic.setDimensions(image.getWidth(), image.getHeight()); ic.setProperties(new Hashtable<>()); ic.setColorModel(image.cm); ic.setHints(ImageConsumer.TOPDOWNLEFTRIGHT | ImageConsumer.COMPLETESCANLINES | ImageConsumer.SINGLEPASS | ImageConsumer.SINGLEFRAME); - ic.setPixels(0, 0, ArtMasterImage.W, ArtMasterImage.H, image.cm, image.getPixels(), 0, ArtMasterImage.W); + ic.setPixels(0, 0, image.getWidth(), image.getHeight(), image.cm, image.getPixels(), 0, image.getWidth()); ic.imageComplete(ImageConsumer.STATICIMAGEDONE); } diff --git a/src/main/java/vavi/imageio/am88/ArtMasterImageReader.java b/src/main/java/vavi/imageio/am88/ArtMasterImageReader.java index 17d2cbf..88643d5 100644 --- a/src/main/java/vavi/imageio/am88/ArtMasterImageReader.java +++ b/src/main/java/vavi/imageio/am88/ArtMasterImageReader.java @@ -6,15 +6,12 @@ package vavi.imageio.am88; -import java.awt.Image; -import java.awt.Toolkit; import java.awt.image.BufferedImage; +import java.awt.image.IndexColorModel; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Iterator; -import java.util.logging.Level; - import javax.imageio.IIOException; import javax.imageio.ImageReadParam; import javax.imageio.ImageReader; @@ -24,8 +21,6 @@ import javax.imageio.stream.ImageInputStream; import vavi.awt.image.am88.ArtMasterImage; -import vavi.awt.image.am88.ArtMasterImageSource; -import vavi.imageio.ImageConverter; import vavi.imageio.WrappedImageInputStream; import vavi.util.Debug; @@ -41,8 +36,8 @@ public class ArtMasterImageReader extends ImageReader { /** */ private IIOMetadata metadata; - /** TODO eliminate */ - private ArtMasterImageSource imageSource; + /** */ + private BufferedImage image; /** */ public ArtMasterImageReader(ImageReaderSpi originatingProvider) { @@ -56,12 +51,18 @@ public int getNumImages(boolean allowSearch) throws IIOException { @Override public int getWidth(int imageIndex) throws IIOException { - return ArtMasterImage.W; + if (imageIndex != 0) { + throw new IndexOutOfBoundsException(imageIndex + "/" + 1); + } + return image.getWidth(); } @Override public int getHeight(int imageIndex) throws IIOException { - return ArtMasterImage.H; + if (imageIndex != 0) { + throw new IndexOutOfBoundsException(imageIndex + "/" + 1); + } + return image.getHeight(); } @Override @@ -78,12 +79,11 @@ public BufferedImage read(int imageIndex, ImageReadParam param) Debug.println(input); } - Toolkit t = Toolkit.getDefaultToolkit(); try { - imageSource = new ArtMasterImageSource(is); - Image image = t.createImage(imageSource); -//Debug.println(w + ", " + h + ": " + image.getClass().getName() + "[" + imageIndex + "]"); - return ImageConverter.getInstance().toBufferedImage(image); + ArtMasterImage ami = new ArtMasterImage(is); + image = new BufferedImage(ami.getWidth(), ami.getHeight(), BufferedImage.TYPE_BYTE_INDEXED, (IndexColorModel) ami.getColorModel()); + image.getRaster().setDataElements(0, 0, ami.getWidth(), ami.getHeight(), ami.getPixels()); + return image; } catch (IOException e) { throw new IIOException(e.getMessage(), e); } @@ -96,12 +96,18 @@ public IIOMetadata getStreamMetadata() throws IIOException { @Override public IIOMetadata getImageMetadata(int imageIndex) throws IIOException { + if (imageIndex != 0) { + throw new IndexOutOfBoundsException(imageIndex + "/" + 1); + } return metadata; } @Override public Iterator getImageTypes(int imageIndex) throws IIOException { -Debug.println(Level.FINE, "here"); + if (imageIndex != 0) { + throw new IndexOutOfBoundsException(imageIndex + "/" + 1); + } + ImageTypeSpecifier specifier = null; java.util.List l = new ArrayList<>(); l.add(specifier); From 353b5d2302f45c018aaf91165b1d0373d3bd1f9f Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Tue, 20 Feb 2024 20:48:52 +0900 Subject: [PATCH 2/7] clean up --- .../image/resample/Lanczos3ResampleOp.java | 7 +++-- src/test/java/GifUnderDirectory.java | 29 ++++++++++++------- src/test/java/vavi/awt/image/mag/MagTest.java | 2 -- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/main/java/vavi/awt/image/resample/Lanczos3ResampleOp.java b/src/main/java/vavi/awt/image/resample/Lanczos3ResampleOp.java index 945adb5..a3ed181 100644 --- a/src/main/java/vavi/awt/image/resample/Lanczos3ResampleOp.java +++ b/src/main/java/vavi/awt/image/resample/Lanczos3ResampleOp.java @@ -25,6 +25,8 @@ /** * Lanczos3ResampleOp. * + * WARNING this filter doesn't deal alpha channel. + * * @author Naohide Sano (nsano) * @version 0.00 060616 nsano initial version
*/ @@ -41,7 +43,7 @@ public Lanczos3ResampleOp(double sx, double sy) { this.sy = sy; } - /* */ + @Override protected int[] filterPixels(int width, int height, int[] inPixels) { RGB24Image inImage = new MemoryRGB24Image(width, height); @@ -88,12 +90,13 @@ protected int[] filterPixels(int width, int height, int[] inPixels) { return outPixels; } - /* */ + @Override public Rectangle2D getBounds2D(BufferedImage src) { return new Rectangle(0, 0, (int) (src.getWidth() * sx), (int) (src.getHeight() * sy)); } /** @return scaled point */ + @Override public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) { if (dstPt == null) { dstPt = new Point2D.Double(); diff --git a/src/test/java/GifUnderDirectory.java b/src/test/java/GifUnderDirectory.java index c04b143..bf9c54e 100644 --- a/src/test/java/GifUnderDirectory.java +++ b/src/test/java/GifUnderDirectory.java @@ -9,6 +9,11 @@ import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; import java.util.regex.Pattern; import javax.imageio.ImageIO; @@ -18,9 +23,6 @@ import vavi.imageio.IIOUtil; -import vavix.util.grep.FileDigger; -import vavix.util.grep.RegexFileDigger; - /** * GifUnderDirectory. gif in directory @@ -53,15 +55,22 @@ public void paint(Graphics g) { frame.pack(); frame.setVisible(true); - new RegexFileDigger(file -> { - try { + Files.walkFileTree(Path.of(args[0]), new SimpleFileVisitor() { + Pattern p = Pattern.compile(".+\\.(gif|GIF)"); + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + try { + if (p.matcher(file.getFileName().toString()).find()) { System.err.println("--- " + file + " ---"); - image = ImageIO.read(file); - panel.repaint(); - } catch (IOException e) { - e.printStackTrace(); + image = ImageIO.read(file.toFile()); + panel.repaint(); + } + } catch (IOException e) { + e.printStackTrace(); + } + return FileVisitResult.CONTINUE; } - }, Pattern.compile(".+\\.(gif|GIF)")).dig(new File(args[0])); + }); } } diff --git a/src/test/java/vavi/awt/image/mag/MagTest.java b/src/test/java/vavi/awt/image/mag/MagTest.java index f0ea609..4e09bfc 100644 --- a/src/test/java/vavi/awt/image/mag/MagTest.java +++ b/src/test/java/vavi/awt/image/mag/MagTest.java @@ -15,7 +15,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.concurrent.CountDownLatch; -import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JPanel; @@ -24,7 +23,6 @@ import org.junit.jupiter.api.condition.EnabledIf; import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import vavi.io.LittleEndianSeekableDataInputStream; -import vavi.swing.JImageComponent; import vavi.util.properties.annotation.Property; import vavi.util.properties.annotation.PropsEntity; From bb739ece3bfb992c6d491d8c252365a851e19b36 Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Tue, 20 Feb 2024 20:49:08 +0900 Subject: [PATCH 3/7] make test more effective --- .../am88/ArtMasterImageReaderTest.java | 21 ++++++++++++++++++- .../vavi/imageio/mag/MagImageReaderTest.java | 2 +- .../imageio/mag/RetroMagImageReaderTest.java | 2 +- .../imageio/maki/MakiImageReaderTest.java | 2 +- .../vavi/imageio/pi/PiImageReaderTest.java | 2 +- .../vavi/imageio/pic/PicImageReaderTest.java | 2 +- 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/test/java/vavi/imageio/am88/ArtMasterImageReaderTest.java b/src/test/java/vavi/imageio/am88/ArtMasterImageReaderTest.java index e519134..7bfa678 100644 --- a/src/test/java/vavi/imageio/am88/ArtMasterImageReaderTest.java +++ b/src/test/java/vavi/imageio/am88/ArtMasterImageReaderTest.java @@ -21,10 +21,14 @@ import javax.swing.JFrame; import javax.swing.JPanel; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIf; import org.junit.jupiter.api.condition.EnabledIfSystemProperty; import vavi.util.Debug; +import vavi.util.properties.annotation.Property; +import vavi.util.properties.annotation.PropsEntity; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -35,6 +39,7 @@ * @author Naohide Sano (umjammer) * @version 0.00 2019/04/11 umjammer initial version
*/ +@PropsEntity(url = "file:local.properties") class ArtMasterImageReaderTest { static { @@ -42,6 +47,20 @@ class ArtMasterImageReaderTest { "sun\\.util\\.logging\\.[\\w\\$]+#\\w+"); } + static boolean localPropertiesExists() { + return Files.exists(Paths.get("local.properties")); + } + + @Property + String art88Image = "src/test/resources/test.am88"; + + @BeforeEach + void setup() throws IOException { + if (localPropertiesExists()) { + PropsEntity.Util.bind(this); + } + } + @Test void test() throws Exception { ImageReader ir = null; @@ -70,7 +89,7 @@ void test1() throws Exception { void test0() throws Exception { // using cdl cause junit stops awt thread suddenly CountDownLatch cdl = new CountDownLatch(1); - main(new String[] { "src/test/resources/test.am88" }); + main(new String[] { art88Image }); cdl.await(); // depends on main frame's exit on close } diff --git a/src/test/java/vavi/imageio/mag/MagImageReaderTest.java b/src/test/java/vavi/imageio/mag/MagImageReaderTest.java index f74eb3a..02a4e11 100644 --- a/src/test/java/vavi/imageio/mag/MagImageReaderTest.java +++ b/src/test/java/vavi/imageio/mag/MagImageReaderTest.java @@ -76,7 +76,7 @@ void show(BufferedImage image) throws Exception { }); JImageComponent panel = new JImageComponent(); panel.setImage(image); - panel.setPreferredSize(new Dimension(800, 600)); + panel.setPreferredSize(new Dimension(640, 400)); frame.getContentPane().add(panel); frame.pack(); frame.setVisible(true); diff --git a/src/test/java/vavi/imageio/mag/RetroMagImageReaderTest.java b/src/test/java/vavi/imageio/mag/RetroMagImageReaderTest.java index 21e06f4..21c8efd 100644 --- a/src/test/java/vavi/imageio/mag/RetroMagImageReaderTest.java +++ b/src/test/java/vavi/imageio/mag/RetroMagImageReaderTest.java @@ -90,7 +90,7 @@ void show(BufferedImage image) throws Exception { }); JImageComponent panel = new JImageComponent(); panel.setImage(image); - panel.setPreferredSize(new Dimension(800, 600)); + panel.setPreferredSize(new Dimension(640, 400)); frame.getContentPane().add(panel); frame.pack(); frame.setVisible(true); diff --git a/src/test/java/vavi/imageio/maki/MakiImageReaderTest.java b/src/test/java/vavi/imageio/maki/MakiImageReaderTest.java index f4f772a..5a7291d 100644 --- a/src/test/java/vavi/imageio/maki/MakiImageReaderTest.java +++ b/src/test/java/vavi/imageio/maki/MakiImageReaderTest.java @@ -77,7 +77,7 @@ void show(BufferedImage image) throws Exception { }); JImageComponent panel = new JImageComponent(); panel.setImage(image); - panel.setPreferredSize(new Dimension(800, 600)); + panel.setPreferredSize(new Dimension(640, 400)); frame.getContentPane().add(panel); frame.pack(); frame.setVisible(true); diff --git a/src/test/java/vavi/imageio/pi/PiImageReaderTest.java b/src/test/java/vavi/imageio/pi/PiImageReaderTest.java index 3a3563c..0c59afa 100644 --- a/src/test/java/vavi/imageio/pi/PiImageReaderTest.java +++ b/src/test/java/vavi/imageio/pi/PiImageReaderTest.java @@ -77,7 +77,7 @@ void show(BufferedImage image) throws Exception { }); JImageComponent panel = new JImageComponent(); panel.setImage(image); - panel.setPreferredSize(new Dimension(800, 600)); + panel.setPreferredSize(new Dimension(640, 400)); frame.getContentPane().add(panel); frame.pack(); frame.setVisible(true); diff --git a/src/test/java/vavi/imageio/pic/PicImageReaderTest.java b/src/test/java/vavi/imageio/pic/PicImageReaderTest.java index d83cd70..8f34b89 100644 --- a/src/test/java/vavi/imageio/pic/PicImageReaderTest.java +++ b/src/test/java/vavi/imageio/pic/PicImageReaderTest.java @@ -77,7 +77,7 @@ void show(BufferedImage image) throws Exception { }); JImageComponent panel = new JImageComponent(); panel.setImage(image); - panel.setPreferredSize(new Dimension(800, 600)); + panel.setPreferredSize(new Dimension(640, 400)); frame.getContentPane().add(panel); frame.pack(); frame.setVisible(true); From 99573a1da309f5573223cf49a72693fd11c221f4 Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Tue, 20 Feb 2024 20:50:41 +0900 Subject: [PATCH 4/7] [ffmpeg-resizser] use native in jar loader library --- pom.xml | 242 +++++++++++------- .../awt/image/resample/FfmpegResampleOp.java | 8 +- src/main/native/FfmpegResampleOpWrapper.c | 8 +- 3 files changed, 159 insertions(+), 99 deletions(-) diff --git a/pom.xml b/pom.xml index f42698c..4685d0d 100644 --- a/pom.xml +++ b/pom.xml @@ -28,13 +28,17 @@ + + /opt/homebrew + + local (not on jitpack) mac - x86_64 + aarch64 env.JITPACK @@ -44,27 +48,67 @@ + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + + + javah + + compile + + compile + + + -h + ${project.build.directory}/native + -d + ${project.build.directory}/native/classes + + + vavi/awt/image/resample/FfmpegResampleOp.java + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 3.1.0 + + + javah + + run + + compile + + + + + + + + + + + org.codehaus.mojo native-maven-plugin 1.0-alpha-11 true - - vavi.awt.image.resample.FfmpegResampleOp - - false - darwin generic-classic -g -Wall -O2 -fomit-frame-pointer -fPIC - -arch x86_64 - -I${java.home}/../include - -I${java.home}/../include/darwin - -I/usr/local/include/libavformat - -I/usr/local/include/libavcodec - -I/usr/local/include/libavutil - -I/usr/local/include/libswscale + -arch arm64 + -I${java.home}/include + -I${java.home}/include/darwin + -I${brew.prefix}/include + -I${project.build.directory}/native @@ -76,37 +120,22 @@ - -dynamiclib -arch x86_64 -v - -L/usr/local/lib -lobjc -lavformat -lavcodec -lswscale -lavutil + -dynamiclib -arch arm64 -v + -L${brew.prefix}/lib -lobjc -lavformat -lavcodec -lswscale -lavutil - - test-dylib - test-compile - - javah - compile - link - - - - -o ${project.build.testOutputDirectory}/libFfmpegResampleOpWrapper.dylib - - - dylib compile - javah compile link - -o ${project.build.directory}/libFFmpegWrapper-${project.version}.dylib + -o ${project.build.outputDirectory}/natives/osx_arm64/libFfmpegResampleOpWrapper.dylib @@ -115,107 +144,130 @@ org.apache.maven.plugins - maven-install-plugin - 3.0.1 + maven-jar-plugin + 2.5 + + + + + + + on jitpack + + + env.JITPACK + true + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 3.1.0 - install-library - install + assets-download - install-file + run + compile - ${project.groupId} - vavi-image-ffmpeg - ${project.version} - dylib - ${project.build.directory}/libFFmpegWrapper-${project.version}.dylib + + + + + + + + + + test + + + ${basedir}/local.properties + + + + org.apache.maven.plugins - maven-deploy-plugin - 3.0.0-M2 + maven-antrun-plugin + 3.1.0 + + + assets-download + + run + + compile - true + + + + + + + + + + + + - org.codehaus.mojo - exec-maven-plugin - 3.1.0 + properties-maven-plugin + 1.1.0 - deploy-library - deploy + read-properties + initialize - exec + read-project-properties - - - mvn - - deploy:deploy-file - -DgroupId=${project.groupId} - -DartifactId=vavi-image-ffmpeg - -Dversion=${project.version} - -Dpackaging=dylib - -Dfile=${project.build.directory}/libFFmpegWrapper-${project.version}.dylib - -DrepositoryId=github - -Durl=https://maven.pkg.github.com/umjammer/vavi-image - -s - ${env.GITHUB_WORKSPACE}/settings.xml - + + ${basedir}/local.properties + + + - - maven-jar-plugin - 2.5 + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + + 17 + org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M7 + 3.2.2 - once - -Djava.library.path=${project.build.testOutputDirectory} -Djava.util.logging.config.file=${project.build.testOutputDirectory}/logging.properties + -Djava.library.path=${brew.prefix}/lib - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.10.1 - - 8 - 8 - UTF-8 - - - - @@ -248,6 +300,12 @@ 0.14.3 + + org.scijava + native-lib-loader + 2.5.0 + + com.github.umjammer vavi-awt diff --git a/src/main/java/vavi/awt/image/resample/FfmpegResampleOp.java b/src/main/java/vavi/awt/image/resample/FfmpegResampleOp.java index 2904298..65257ab 100644 --- a/src/main/java/vavi/awt/image/resample/FfmpegResampleOp.java +++ b/src/main/java/vavi/awt/image/resample/FfmpegResampleOp.java @@ -17,8 +17,10 @@ import java.awt.image.DataBufferByte; import java.awt.image.DataBufferInt; import java.awt.image.IndexColorModel; +import java.io.IOException; import java.util.logging.Level; +import org.scijava.nativelib.NativeLoader; import vavi.util.Debug; @@ -177,9 +179,9 @@ public RenderingHints getRenderingHints() { /* */ static { try { - System.loadLibrary("FfmpegResampleOpWrapper"); - } catch (UnsatisfiedLinkError e) { - e.printStackTrace(System.err); + NativeLoader.loadLibrary("FfmpegResampleOpWrapper"); + } catch (IOException e) { +Debug.printStackTrace(e); throw new IllegalStateException(e); } } diff --git a/src/main/native/FfmpegResampleOpWrapper.c b/src/main/native/FfmpegResampleOpWrapper.c index 5e8411c..b360a18 100644 --- a/src/main/native/FfmpegResampleOpWrapper.c +++ b/src/main/native/FfmpegResampleOpWrapper.c @@ -6,8 +6,8 @@ #include #include -#include "avutil.h" -#include "avformat.h" +#include "libavutil/avutil.h" +#include "libavformat/avformat.h" #include "vavi_awt_image_resample_FfmpegResampleOp.h" /* @@ -105,8 +105,8 @@ JNIEXPORT void JNICALL Java_vavi_awt_image_resample_FfmpegResampleOp_filterInter #else -#include "swscale.h" -#include "imgutils.h" +#include "libswscale/swscale.h" +#include "libavutil/imgutils.h" #ifdef __cplusplus extern "C" { From f4f3797fc390b8553e04fa11d94f9f5d3f593877 Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Tue, 20 Feb 2024 20:55:52 +0900 Subject: [PATCH 5/7] update settings --- .github/workflows/codeql-analysis.yml | 20 ++++++++--- .github/workflows/maven-publish.yml | 20 ++++++----- .github/workflows/maven.yml | 6 ++-- README.md | 24 ++++++------- jitpack.yml | 2 ++ local.properties.sample | 1 + pom.xml | 50 +++++++++++++-------------- 7 files changed, 68 insertions(+), 55 deletions(-) create mode 100644 jitpack.yml create mode 100644 local.properties.sample diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 7ef0c9e..da0a763 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -18,6 +18,10 @@ jobs: analyze: name: Analyze runs-on: macos-latest + permissions: + actions: read + contents: read + security-events: write strategy: fail-fast: false @@ -30,24 +34,30 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. + # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. # queries: ./path/to/local/query, your-org/your-repo/queries@main + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + cache: maven # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Build run: | brew install ffmpeg - mvn -B install --file pom.xml + mvn -B install --file pom.xml -Dmaven.test.skip=true - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 26c7664..2c548cc 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -1,4 +1,4 @@ -name: GitHub Packages (only ffmpeg) +name: GitHub Release Assets on: release: @@ -7,16 +7,16 @@ on: jobs: build: - runs-on: macos-latest + runs-on: macos-14 steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - name: Set up JDK 8 - uses: actions/setup-java@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v4 with: - java-version: '8' + java-version: '17' distribution: 'temurin' cache: maven server-id: github # Value of the distributionManagement/repository/id field of the pom.xml @@ -25,9 +25,11 @@ jobs: - name: Build with Maven run: | brew install ffmpeg - mvn -B package --file pom.xml + mvn -B package --file pom.xml -Dmaven.test.skip=true - - name: Publish to GitHub Packages Apache Maven - run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml -Dmaven.test.skip=true + - name: Upload Release Asset + uses: softprops/action-gh-release@v1 env: GITHUB_TOKEN: ${{ github.token }} + with: + files: target/classes/natives/osx_arm64/libFfmpegResampleOpWrapper.dylib diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index e610099..c6e7e59 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -5,7 +5,7 @@ on: [push] jobs: build: - runs-on: macos-latest + runs-on: macos-14 steps: - name: Checkout repository @@ -15,10 +15,10 @@ jobs: if: ${{ contains(github.event.head_commit.message, 'bump version') }} run: grep "" pom.xml | head -1 | grep -v SNAPSHOT - - name: Set up JDK 8 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: '8' + java-version: '17' distribution: 'temurin' cache: maven diff --git a/README.md b/README.md index 500a02e..e75b004 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ [![Release](https://jitpack.io/v/umjammer/vavi-image.svg)](https://jitpack.io/#umjammer/vavi-image) [![Java CI](https://github.com/umjammer/vavi-image/actions/workflows/maven.yml/badge.svg)](https://github.com/umjammer/vavi-image/actions/workflows/maven.yml) [![CodeQL](https://github.com/umjammer/vavi-image/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/umjammer/vavi-image/actions/workflows/codeql-analysis.yml) -[![GitHub Packages (only ffmpeg)](https://github.com/umjammer/vavi-image/actions/workflows/maven-publish.yml/badge.svg)](https://github.com/umjammer/vavi-image/actions/workflows/maven-publish.yml) -![Java](https://img.shields.io/badge/Java-8-b07219) +![Java](https://img.shields.io/badge/Java-17-b07219) # vavi-image @@ -33,18 +32,17 @@ ## Quantization -| type |quality|comment| -|----------------------------------------------------------------------------------|---|---| -| [`ImageMagick`](src/main/java/vavi/awt/image/quantization/ImageMagikQuantizeOp.java) ||| -| `NeuralNet` |👑|https://github.com/umjammer/vavi-image-sandbox/wiki/OctTree_vs_NeuralNet| -| `OctTree` ||| +| type |quality| comment | +|----------------------------------------------------------------------------------|---|----------------------------------------------------------------------------------------| +| [`ImageMagick`](src/main/java/vavi/awt/image/quantization/ImageMagikQuantizeOp.java) || | +| `NeuralNet` |👑| [comparison](https://github.com/umjammer/vavi-image-sandbox/wiki/OctTree-vs-NeuralNet) | +| `OctTree` || | ## Installation * maven: https://jitpack.io/#umjammer/vavi-image * if you want to use ffmpeg resizing - * [pom.xml](https://github.com/umjammer/vavi-image/wiki/Install-ffmpeg-native-library) - * exec jvm w/ `java.library.path` system property e.g `-Djava.library.path=/target/test-classes` + * exec jvm w/ `java.library.path` system property e.g `-Djava.library.path=/opt/homebrew/lib` ## TODO @@ -54,13 +52,13 @@ * `BufferedImageOp` ??? * https://github.com/iariro/N88BasicImage * ~~ffmpeg resize 4byte 32bit operation is wrong~~ - * DaVinchi (wip) - * n88basic image format (wip) + * DaVinchi (wip, branch:davinch) + * n88basic image format (wip, branch:n88basic) * yet another pic image format (wip) ## Tech Know - * Mac Open JDK's JNI library extension is `.dylib` + * ~~Mac Open JDK's JNI library extension is `.dylib`~~ already common * ~~`libsescale` has MMX bug, this causes segmentation fault when resizing image.~~ ## References @@ -71,7 +69,7 @@ ### Image I/O PPM Reader -Public Domain +🅮 Public Domain ### ImageMagik diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 0000000..efde7bf --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,2 @@ +jdk: + - openjdk17 diff --git a/local.properties.sample b/local.properties.sample new file mode 100644 index 0000000..62494a2 --- /dev/null +++ b/local.properties.sample @@ -0,0 +1 @@ +brew.prefix=/user/local \ No newline at end of file diff --git a/pom.xml b/pom.xml index 4685d0d..935d6b0 100644 --- a/pom.xml +++ b/pom.xml @@ -208,14 +208,14 @@ run compile - + - + @@ -226,17 +226,17 @@ - - org.codehaus.mojo + + org.codehaus.mojo properties-maven-plugin 1.1.0 - - + + read-properties initialize - + read-project-properties - + ${basedir}/local.properties @@ -244,30 +244,30 @@ - + - + org.apache.maven.plugins maven-compiler-plugin 3.11.0 17 - + - - org.apache.maven.plugins - maven-surefire-plugin + + org.apache.maven.plugins + maven-surefire-plugin 3.2.2 - - - -Djava.util.logging.config.file=${project.build.testOutputDirectory}/logging.properties + + + -Djava.util.logging.config.file=${project.build.testOutputDirectory}/logging.properties -Djava.library.path=${brew.prefix}/lib - - - - - + + + + + @@ -281,7 +281,7 @@ org.junit junit-bom - 5.9.2 + 5.10.1 pom import @@ -292,7 +292,7 @@ com.github.umjammer vavi-commons - 1.1.9 + 1.1.10 com.github.umjammer @@ -309,7 +309,7 @@ com.github.umjammer vavi-awt - 1.0.6 + 1.0.7 test From ec7c00371de4a4353236e77af2cbd4d23aa53d91 Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Tue, 20 Feb 2024 20:56:29 +0900 Subject: [PATCH 6/7] bump version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 935d6b0..7f50e8c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ vavi vavi-image - 1.0.11 + 1.0.12 Vavi Imaging API From 398138b289ee8e8e0b326830581c4306bb615789 Mon Sep 17 00:00:00 2001 From: Naohide Sano Date: Tue, 20 Feb 2024 21:07:25 +0900 Subject: [PATCH 7/7] =?UTF-8?q?=F0=9F=A5=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- pom.xml | 44 ++++++++++++++++++++++---------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index e75b004..a7c7b2f 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ * ~~ffmpeg resize 4byte 32bit operation is wrong~~ * DaVinchi (wip, branch:davinch) * n88basic image format (wip, branch:n88basic) - * yet another pic image format (wip) + * yet another pic image format (wip, branch:pic) ## Tech Know diff --git a/pom.xml b/pom.xml index 7f50e8c..9ec1dc8 100644 --- a/pom.xml +++ b/pom.xml @@ -188,8 +188,7 @@ - - test + local ${basedir}/local.properties @@ -198,6 +197,27 @@ + org.codehaus.mojo + properties-maven-plugin + 1.1.0 + + + read-properties + initialize + + read-project-properties + + + + ${basedir}/local.properties + + + + + + + + org.apache.maven.plugins maven-antrun-plugin 3.1.0 @@ -226,26 +246,6 @@ - - org.codehaus.mojo - properties-maven-plugin - 1.1.0 - - - read-properties - initialize - - read-project-properties - - - - ${basedir}/local.properties - - - - - - org.apache.maven.plugins maven-compiler-plugin