Skip to content

Commit

Permalink
Merge pull request #8 from umjammer/0.0.6
Browse files Browse the repository at this point in the history
0.0.6
  • Loading branch information
umjammer authored May 2, 2024
2 parents f3f9f2c + d9dd3b7 commit 94753a6
Show file tree
Hide file tree
Showing 19 changed files with 200 additions and 121 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ on:
jobs:
analyze:
name: Analyze
runs-on: macos-latest
runs-on: macos-14
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
Expand All @@ -30,11 +34,11 @@ 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.
Expand All @@ -45,7 +49,7 @@ jobs:
# 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: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
Expand All @@ -62,8 +66,7 @@ jobs:

- name: Build with Maven
run: |
brew install libavif
mvn -B package --file pom.xml -DskipTests
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
8 changes: 4 additions & 4 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ on: [push]
jobs:
build:

runs-on: macos-latest
runs-on: macos-14

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check w/o SNAPSHOT when "bump version"
if: ${{ contains(github.event.head_commit.message, 'bump version') }}
run: grep "<version>" pom.xml | head -1 | grep -v SNAPSHOT

- name: Set up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Build with Maven
run: |
brew install libavif
arch -arm64 brew install libavif
mvn -B package --file pom.xml
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ Java AVIF decoder and encoder<br/>
wrapped [libavif](https://github.com/AOMediaCodec/libavif) by jna<br/>
based on https://github.com/AOMediaCodec/libavif/tree/main/android_jni

<img src="https://upload.wikimedia.org/wikipedia/commons/4/45/Avif-logo-rgb.svg" width="256"/>
<img alt="avif logo" src="https://upload.wikimedia.org/wikipedia/commons/4/45/Avif-logo-rgb.svg" width="256"/>
<sub>© <a href="https://aomedia.org/av1/">AOM</a></sub>

## Install

* install `libavif` 1.0.3 ... e.g. `brew intall libavif`
* install `libavif` 1.0.3~ ... e.g. `brew intall libavif`
* https://jitpack.io/#umjammer/vavi-image-avif
* add `-Djna.library.path=/opt/homebrew/lib` for jvm args

Expand All @@ -28,6 +28,9 @@ based on https://github.com/AOMediaCodec/libavif/tree/main/android_jni
ImageIO.write(image, "AVIF", Paths.get("/foo/baz.avif").toFile());
```

## References


## TODO

* ~~writer~~
30 changes: 25 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>vavi</groupId>
<artifactId>vavi-image-avif</artifactId>
<version>0.0.5</version>
<version>0.0.6</version>

<name>Java AVIF Decoder</name>
<scm>
Expand All @@ -18,9 +18,23 @@

<properties>
<jnaerator.version>0.12</jnaerator.version>
<native.prefix>/usr/local</native.prefix>
</properties>

<profiles>
<profile>
<id>mac arm64</id>
<activation>
<os>
<family>mac</family>
<arch>aarch64</arch>
</os>
</activation>
<properties>
<native.prefix>/opt/homebrew</native.prefix>
</properties>
</profile>

<profile>
<!-- mvn -P jnaerator jnaerator:generate -->
<id>jnaerator</id>
Expand Down Expand Up @@ -60,12 +74,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
<version>3.2.2</version>
<configuration>
<argLine>
--add-opens java.logging/java.util.logging=ALL-UNNAMED
-Djava.util.logging.config.file=${project.build.testOutputDirectory}/logging.properties
-Djna.library.path=/usr/local/lib:/opt/homebrew/lib
-Djna.library.path=@{native.prefix}/lib
</argLine>
<trimStackTrace>false</trimStackTrace>
</configuration>
Expand All @@ -78,7 +92,7 @@
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.10.0</version>
<version>5.10.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -96,7 +110,7 @@
<dependency>
<groupId>com.github.umjammer</groupId>
<artifactId>vavi-commons</artifactId>
<version>1.1.9</version>
<version>1.1.12</version>
</dependency>
<dependency>
<groupId>com.github.umjammer</groupId>
Expand All @@ -109,6 +123,12 @@
<version>5.14.0</version>
</dependency>

<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.9.6</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/vavi/awt/image/avif/jna/Avif.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import org.apache.maven.artifact.versioning.ComparableVersion;
import vavi.awt.image.jna.avif.AvifLibrary;
import vavi.awt.image.jna.avif.avifDecoder;
import vavi.awt.image.jna.avif.avifEncoder;
Expand All @@ -19,7 +20,6 @@
import vavi.awt.image.jna.avif.avifROData;
import vavi.awt.image.jna.avif.avifRWData;
import vavi.util.Debug;
import vavi.util.StringUtil;


/**
Expand All @@ -34,8 +34,12 @@ public class Avif {
// This is a utility class and cannot be instantiated.
private Avif() {
String version = AvifLibrary.INSTANCE.avifVersion();
if (!version.startsWith("1.0.3")) {
Debug.println(Level.SEVERE, "wrong version: " + version);
Debug.println(Level.FINE, version);
ComparableVersion current = new ComparableVersion(version);
ComparableVersion allowed = new ComparableVersion("1.0.3");

if (current.compareTo(allowed) < 0) {
throw new IllegalStateException("not targeted libavif version: " + version);
}
}

Expand Down
Loading

0 comments on commit 94753a6

Please sign in to comment.