这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions third_party/dirent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#ifndef NOMINMAX
#define NOMINMAX
#endif // NOMINMAX

#include <errno.h>
#include <windows.h>

#include <memory>
Expand Down
2 changes: 2 additions & 0 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ if (JNI_FOUND AND Java_FOUND)
jni/org/jpeg/jpegxl/wrapper/Decoder.java
jni/org/jpeg/jpegxl/wrapper/DecoderJni.java
jni/org/jpeg/jpegxl/wrapper/ImageData.java
jni/org/jpeg/jpegxl/wrapper/JniHelper.java
jni/org/jpeg/jpegxl/wrapper/PixelFormat.java
jni/org/jpeg/jpegxl/wrapper/Status.java
jni/org/jpeg/jpegxl/wrapper/StreamInfo.java
Expand Down Expand Up @@ -501,6 +502,7 @@ if (JNI_FOUND AND Java_FOUND)

add_jar(jpegli_jni_wrapper SOURCES
jni/org/jpeg/jpegli/wrapper/Encoder.java
jni/org/jpeg/jpegli/wrapper/JniHelper.java
OUTPUT_NAME org.jpeg.jpegli
)
get_target_property(JPEGLI_JNI_WRAPPER_JAR jpegli_jni_wrapper JAR_FILE)
Expand Down
9 changes: 1 addition & 8 deletions tools/jni/org/jpeg/jpegli/wrapper/Encoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,7 @@
/** Jpegli JNI encoder wrapper. */
public class Encoder {
static {
try {
System.loadLibrary("jpegli_encoder_jni");
} catch (UnsatisfiedLinkError e) {
UnsatisfiedLinkError error =
new UnsatisfiedLinkError("Could not load jni library: jpegli_encoder_jni");
error.initCause(e);
throw error;
}
JniHelper.ensureInitialized();
}

/** Utility library, disable object construction. */
Expand Down
16 changes: 0 additions & 16 deletions tools/jni/org/jpeg/jpegli/wrapper/EncoderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,6 @@
* Tests for jpegli encoder wrapper.
*/
public class EncoderTest {
static {
String jniLibrary = System.getProperty("org.jpeg.jpegli.wrapper.lib");
if (jniLibrary != null) {
try {
System.load(new java.io.File(jniLibrary).getAbsolutePath());
} catch (UnsatisfiedLinkError ex) {
String message =
"If the nested exception message says that some standard library (stdc++, tcmalloc,"
+ " etc.) was not found, it is likely that JDK discovered by the build system"
+ " overrides library search path. Try specifying a different JDK via JAVA_HOME"
+ " environment variable and doing a clean build.";
throw new RuntimeException(message, ex);
}
}
}

static void checkTrue(boolean condition) {
if (!condition) {
throw new IllegalStateException("check failed");
Expand Down
33 changes: 33 additions & 0 deletions tools/jni/org/jpeg/jpegli/wrapper/JniHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) the JPEG XL Project Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package org.jpeg.jpegli.wrapper;

/**
* Helper for native library loading.
*
* Normally the wrapper is responsible for (lazy) library loading; though it is
* sometimes necessary to make the moment of loading more deterministic.
*/
public class JniHelper {
static {
String jniLibrary = System.getProperty("org.jpeg.jpegli.wrapper.lib");
if (jniLibrary != null) {
try {
System.load(new java.io.File(jniLibrary).getAbsolutePath());
} catch (UnsatisfiedLinkError ex) {
String message = "If the nested exception message says that some standard library (stdc++, "
+ "tcmalloc, etc.) was not found, it is likely that JDK discovered by the "
+ "build system overrides library search path. Try specifying a different "
+ "JDK via JAVA_HOME environment variable and doing a clean build.";
throw new RuntimeException(message, ex);
}
}
}

static void ensureInitialized() {
// Do nothing, just trigger static initializer.
}
}
4 changes: 4 additions & 0 deletions tools/jni/org/jpeg/jpegxl/wrapper/Decoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

/** JPEG XL JNI decoder wrapper. */
public class Decoder {
static {
JniHelper.ensureInitialized();
}

/** Utility library, disable object construction. */
private Decoder() {}

Expand Down
15 changes: 0 additions & 15 deletions tools/jni/org/jpeg/jpegxl/wrapper/DecoderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,6 @@
import java.nio.ByteBuffer;

public class DecoderTest {
static {
String jniLibrary = System.getProperty("org.jpeg.jpegxl.wrapper.lib");
if (jniLibrary != null) {
try {
System.load(new java.io.File(jniLibrary).getAbsolutePath());
} catch (UnsatisfiedLinkError ex) {
String message =
"If the nested exception message says that some standard library (stdc++, tcmalloc, etc.) was not found, "
+ "it is likely that JDK discovered by the build system overrides library search path. "
+ "Try specifying a different JDK via JAVA_HOME environment variable and doing a clean build.";
throw new RuntimeException(message, ex);
}
}
}

private static final int SIMPLE_IMAGE_DIM = 1024;
// Base64: "/wr6H0GRCAYBAGAASzgkunkeVbaSBu95EXDn0e7ABz2ShAMA"
private static final byte[] SIMPLE_IMAGE_BYTES = {-1, 10, -6, 31, 65, -111, 8, 6, 1, 0, 96, 0, 75,
Expand Down
33 changes: 33 additions & 0 deletions tools/jni/org/jpeg/jpegxl/wrapper/JniHelper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) the JPEG XL Project Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package org.jpeg.jpegxl.wrapper;

/**
* Helper for native library loading.
*
* Normally the wrapper is responsible for (lazy) library loading; though it is
* sometimes necessary to make the moment of loading more deterministic.
*/
public class JniHelper {
static {
String jniLibrary = System.getProperty("org.jpeg.jpegxl.wrapper.lib");
if (jniLibrary != null) {
try {
System.load(new java.io.File(jniLibrary).getAbsolutePath());
} catch (UnsatisfiedLinkError ex) {
String message = "If the nested exception message says that some standard library (stdc++, "
+ "tcmalloc, etc.) was not found, it is likely that JDK discovered by the "
+ "build system overrides library search path. Try specifying a different "
+ "JDK via JAVA_HOME environment variable and doing a clean build.";
throw new RuntimeException(message, ex);
}
}
}

static void ensureInitialized() {
// Do nothing, just trigger static initializer.
}
}
Loading