diff --git a/swig/README b/swig/README new file mode 100644 index 00000000..8b4298b4 --- /dev/null +++ b/swig/README @@ -0,0 +1,34 @@ +Building: +========= + +JNI SWIG bindings: +------------------ + $ gcc -shared -fPIC -fno-strict-aliasing -O2 \ + -I/path/to/your/jdk/includes \ + libwebp_java_wrap.c \ + -lwebp \ + -o libwebp_jni.so + +-------------------------------------- BEGIN PSEUDO EXAMPLE +import com.google.webp.*; +import java.io.*; + +public class libwebp_jni_example { + static { + System.loadLibrary("webp_jni"); + } + + /** + * usage: java -cp libwebp.jar:. + * libwebp_jni_example <input.webp> <output.ppm> + */ + public static void main(String argv[]) { + final int version = libwebp.WebPGetDecoderVersion(); + + System.out.println("libwebp version: " + Integer.toHexString(version)); + } +} +-------------------------------------- END PSEUDO EXAMPLE + + $ javac -cp libwebp.jar libwebp_jni_example.java + $ java -Djava.library.path=. -cp libwebp.jar:. libwebp_jni_example diff --git a/swig/libwebp.jar b/swig/libwebp.jar new file mode 100644 index 00000000..03b6d353 Binary files /dev/null and b/swig/libwebp.jar differ diff --git a/swig/libwebp_java_wrap.c b/swig/libwebp_java_wrap.c new file mode 100644 index 00000000..58c55762 --- /dev/null +++ b/swig/libwebp_java_wrap.c @@ -0,0 +1,1256 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.40 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGJAVA + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + + + +/* Fix for jlong on some versions of gcc on Windows */ +#if defined(__GNUC__) && !defined(__INTEL_COMPILER) + typedef long long __int64; +#endif + +/* Fix for jlong on 64-bit x86 Solaris */ +#if defined(__x86_64) +# ifdef _LP64 +# undef _LP64 +# endif +#endif + +#include +#include +#include + + +/* Support for throwing Java exceptions */ +typedef enum { + SWIG_JavaOutOfMemoryError = 1, + SWIG_JavaIOException, + SWIG_JavaRuntimeException, + SWIG_JavaIndexOutOfBoundsException, + SWIG_JavaArithmeticException, + SWIG_JavaIllegalArgumentException, + SWIG_JavaNullPointerException, + SWIG_JavaDirectorPureVirtual, + SWIG_JavaUnknownError +} SWIG_JavaExceptionCodes; + +typedef struct { + SWIG_JavaExceptionCodes code; + const char *java_exception; +} SWIG_JavaExceptions_t; + + +static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) { + jclass excep; + static const SWIG_JavaExceptions_t java_exceptions[] = { + { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" }, + { SWIG_JavaIOException, "java/io/IOException" }, + { SWIG_JavaRuntimeException, "java/lang/RuntimeException" }, + { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" }, + { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" }, + { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" }, + { SWIG_JavaNullPointerException, "java/lang/NullPointerException" }, + { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" }, + { SWIG_JavaUnknownError, "java/lang/UnknownError" }, + { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } + }; + const SWIG_JavaExceptions_t *except_ptr = java_exceptions; + + while (except_ptr->code != code && except_ptr->code) + except_ptr++; + + (*jenv)->ExceptionClear(jenv); + excep = (*jenv)->FindClass(jenv, except_ptr->java_exception); + if (excep) + (*jenv)->ThrowNew(jenv, excep, msg); +} + + +/* Contract support */ + +#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + + +SWIGINTERN void SWIG_JavaException(JNIEnv *jenv, int code, const char *msg) { + SWIG_JavaExceptionCodes exception_code = SWIG_JavaUnknownError; + switch(code) { + case SWIG_MemoryError: + exception_code = SWIG_JavaOutOfMemoryError; + break; + case SWIG_IOError: + exception_code = SWIG_JavaIOException; + break; + case SWIG_SystemError: + case SWIG_RuntimeError: + exception_code = SWIG_JavaRuntimeException; + break; + case SWIG_OverflowError: + case SWIG_IndexError: + exception_code = SWIG_JavaIndexOutOfBoundsException; + break; + case SWIG_DivisionByZero: + exception_code = SWIG_JavaArithmeticException; + break; + case SWIG_SyntaxError: + case SWIG_ValueError: + case SWIG_TypeError: + exception_code = SWIG_JavaIllegalArgumentException; + break; + case SWIG_UnknownError: + default: + exception_code = SWIG_JavaUnknownError; + break; + } + SWIG_JavaThrowException(jenv, exception_code, msg); +} + + +#if defined(SWIG_NOINCLUDE) || defined(SWIG_NOARRAYS) + + +int SWIG_JavaArrayInSchar (JNIEnv *jenv, jbyte **jarr, signed char **carr, jbyteArray input); +void SWIG_JavaArrayArgoutSchar (JNIEnv *jenv, jbyte *jarr, signed char *carr, jbyteArray input); +jbyteArray SWIG_JavaArrayOutSchar (JNIEnv *jenv, signed char *result, jsize sz); + + +int SWIG_JavaArrayInUchar (JNIEnv *jenv, jshort **jarr, unsigned char **carr, jshortArray input); +void SWIG_JavaArrayArgoutUchar (JNIEnv *jenv, jshort *jarr, unsigned char *carr, jshortArray input); +jshortArray SWIG_JavaArrayOutUchar (JNIEnv *jenv, unsigned char *result, jsize sz); + + +int SWIG_JavaArrayInShort (JNIEnv *jenv, jshort **jarr, short **carr, jshortArray input); +void SWIG_JavaArrayArgoutShort (JNIEnv *jenv, jshort *jarr, short *carr, jshortArray input); +jshortArray SWIG_JavaArrayOutShort (JNIEnv *jenv, short *result, jsize sz); + + +int SWIG_JavaArrayInUshort (JNIEnv *jenv, jint **jarr, unsigned short **carr, jintArray input); +void SWIG_JavaArrayArgoutUshort (JNIEnv *jenv, jint *jarr, unsigned short *carr, jintArray input); +jintArray SWIG_JavaArrayOutUshort (JNIEnv *jenv, unsigned short *result, jsize sz); + + +int SWIG_JavaArrayInInt (JNIEnv *jenv, jint **jarr, int **carr, jintArray input); +void SWIG_JavaArrayArgoutInt (JNIEnv *jenv, jint *jarr, int *carr, jintArray input); +jintArray SWIG_JavaArrayOutInt (JNIEnv *jenv, int *result, jsize sz); + + +int SWIG_JavaArrayInUint (JNIEnv *jenv, jlong **jarr, unsigned int **carr, jlongArray input); +void SWIG_JavaArrayArgoutUint (JNIEnv *jenv, jlong *jarr, unsigned int *carr, jlongArray input); +jlongArray SWIG_JavaArrayOutUint (JNIEnv *jenv, unsigned int *result, jsize sz); + + +int SWIG_JavaArrayInLong (JNIEnv *jenv, jint **jarr, long **carr, jintArray input); +void SWIG_JavaArrayArgoutLong (JNIEnv *jenv, jint *jarr, long *carr, jintArray input); +jintArray SWIG_JavaArrayOutLong (JNIEnv *jenv, long *result, jsize sz); + + +int SWIG_JavaArrayInUlong (JNIEnv *jenv, jlong **jarr, unsigned long **carr, jlongArray input); +void SWIG_JavaArrayArgoutUlong (JNIEnv *jenv, jlong *jarr, unsigned long *carr, jlongArray input); +jlongArray SWIG_JavaArrayOutUlong (JNIEnv *jenv, unsigned long *result, jsize sz); + + +int SWIG_JavaArrayInLonglong (JNIEnv *jenv, jlong **jarr, jlong **carr, jlongArray input); +void SWIG_JavaArrayArgoutLonglong (JNIEnv *jenv, jlong *jarr, jlong *carr, jlongArray input); +jlongArray SWIG_JavaArrayOutLonglong (JNIEnv *jenv, jlong *result, jsize sz); + + +int SWIG_JavaArrayInFloat (JNIEnv *jenv, jfloat **jarr, float **carr, jfloatArray input); +void SWIG_JavaArrayArgoutFloat (JNIEnv *jenv, jfloat *jarr, float *carr, jfloatArray input); +jfloatArray SWIG_JavaArrayOutFloat (JNIEnv *jenv, float *result, jsize sz); + + +int SWIG_JavaArrayInDouble (JNIEnv *jenv, jdouble **jarr, double **carr, jdoubleArray input); +void SWIG_JavaArrayArgoutDouble (JNIEnv *jenv, jdouble *jarr, double *carr, jdoubleArray input); +jdoubleArray SWIG_JavaArrayOutDouble (JNIEnv *jenv, double *result, jsize sz); + + +#else + + +/* signed char[] support */ +int SWIG_JavaArrayInSchar (JNIEnv *jenv, jbyte **jarr, signed char **carr, jbyteArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetByteArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (signed char*) calloc(sz, sizeof(signed char)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; iGetArrayLength(jenv, input); + for (i=0; iReleaseByteArrayElements(jenv, input, jarr, 0); +} + +jbyteArray SWIG_JavaArrayOutSchar (JNIEnv *jenv, signed char *result, jsize sz) { + jbyte *arr; + int i; + jbyteArray jresult = (*jenv)->NewByteArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetByteArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; iReleaseByteArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* unsigned char[] support */ +int SWIG_JavaArrayInUchar (JNIEnv *jenv, jshort **jarr, unsigned char **carr, jshortArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetShortArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (unsigned char*) calloc(sz, sizeof(unsigned char)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; iGetArrayLength(jenv, input); + for (i=0; iReleaseShortArrayElements(jenv, input, jarr, 0); +} + +jshortArray SWIG_JavaArrayOutUchar (JNIEnv *jenv, unsigned char *result, jsize sz) { + jshort *arr; + int i; + jshortArray jresult = (*jenv)->NewShortArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetShortArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; iReleaseShortArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* short[] support */ +int SWIG_JavaArrayInShort (JNIEnv *jenv, jshort **jarr, short **carr, jshortArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetShortArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (short*) calloc(sz, sizeof(short)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; iGetArrayLength(jenv, input); + for (i=0; iReleaseShortArrayElements(jenv, input, jarr, 0); +} + +jshortArray SWIG_JavaArrayOutShort (JNIEnv *jenv, short *result, jsize sz) { + jshort *arr; + int i; + jshortArray jresult = (*jenv)->NewShortArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetShortArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; iReleaseShortArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* unsigned short[] support */ +int SWIG_JavaArrayInUshort (JNIEnv *jenv, jint **jarr, unsigned short **carr, jintArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetIntArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (unsigned short*) calloc(sz, sizeof(unsigned short)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; iGetArrayLength(jenv, input); + for (i=0; iReleaseIntArrayElements(jenv, input, jarr, 0); +} + +jintArray SWIG_JavaArrayOutUshort (JNIEnv *jenv, unsigned short *result, jsize sz) { + jint *arr; + int i; + jintArray jresult = (*jenv)->NewIntArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetIntArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; iReleaseIntArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* int[] support */ +int SWIG_JavaArrayInInt (JNIEnv *jenv, jint **jarr, int **carr, jintArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetIntArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (int*) calloc(sz, sizeof(int)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; iGetArrayLength(jenv, input); + for (i=0; iReleaseIntArrayElements(jenv, input, jarr, 0); +} + +jintArray SWIG_JavaArrayOutInt (JNIEnv *jenv, int *result, jsize sz) { + jint *arr; + int i; + jintArray jresult = (*jenv)->NewIntArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetIntArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; iReleaseIntArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* unsigned int[] support */ +int SWIG_JavaArrayInUint (JNIEnv *jenv, jlong **jarr, unsigned int **carr, jlongArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetLongArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (unsigned int*) calloc(sz, sizeof(unsigned int)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; iGetArrayLength(jenv, input); + for (i=0; iReleaseLongArrayElements(jenv, input, jarr, 0); +} + +jlongArray SWIG_JavaArrayOutUint (JNIEnv *jenv, unsigned int *result, jsize sz) { + jlong *arr; + int i; + jlongArray jresult = (*jenv)->NewLongArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetLongArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; iReleaseLongArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* long[] support */ +int SWIG_JavaArrayInLong (JNIEnv *jenv, jint **jarr, long **carr, jintArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetIntArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (long*) calloc(sz, sizeof(long)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; iGetArrayLength(jenv, input); + for (i=0; iReleaseIntArrayElements(jenv, input, jarr, 0); +} + +jintArray SWIG_JavaArrayOutLong (JNIEnv *jenv, long *result, jsize sz) { + jint *arr; + int i; + jintArray jresult = (*jenv)->NewIntArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetIntArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; iReleaseIntArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* unsigned long[] support */ +int SWIG_JavaArrayInUlong (JNIEnv *jenv, jlong **jarr, unsigned long **carr, jlongArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetLongArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (unsigned long*) calloc(sz, sizeof(unsigned long)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; iGetArrayLength(jenv, input); + for (i=0; iReleaseLongArrayElements(jenv, input, jarr, 0); +} + +jlongArray SWIG_JavaArrayOutUlong (JNIEnv *jenv, unsigned long *result, jsize sz) { + jlong *arr; + int i; + jlongArray jresult = (*jenv)->NewLongArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetLongArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; iReleaseLongArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* jlong[] support */ +int SWIG_JavaArrayInLonglong (JNIEnv *jenv, jlong **jarr, jlong **carr, jlongArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetLongArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (jlong*) calloc(sz, sizeof(jlong)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; iGetArrayLength(jenv, input); + for (i=0; iReleaseLongArrayElements(jenv, input, jarr, 0); +} + +jlongArray SWIG_JavaArrayOutLonglong (JNIEnv *jenv, jlong *result, jsize sz) { + jlong *arr; + int i; + jlongArray jresult = (*jenv)->NewLongArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetLongArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; iReleaseLongArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* float[] support */ +int SWIG_JavaArrayInFloat (JNIEnv *jenv, jfloat **jarr, float **carr, jfloatArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetFloatArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (float*) calloc(sz, sizeof(float)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; iGetArrayLength(jenv, input); + for (i=0; iReleaseFloatArrayElements(jenv, input, jarr, 0); +} + +jfloatArray SWIG_JavaArrayOutFloat (JNIEnv *jenv, float *result, jsize sz) { + jfloat *arr; + int i; + jfloatArray jresult = (*jenv)->NewFloatArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetFloatArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; iReleaseFloatArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +/* double[] support */ +int SWIG_JavaArrayInDouble (JNIEnv *jenv, jdouble **jarr, double **carr, jdoubleArray input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = (*jenv)->GetArrayLength(jenv, input); + *jarr = (*jenv)->GetDoubleArrayElements(jenv, input, 0); + if (!*jarr) + return 0; + *carr = (double*) calloc(sz, sizeof(double)); + if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; iGetArrayLength(jenv, input); + for (i=0; iReleaseDoubleArrayElements(jenv, input, jarr, 0); +} + +jdoubleArray SWIG_JavaArrayOutDouble (JNIEnv *jenv, double *result, jsize sz) { + jdouble *arr; + int i; + jdoubleArray jresult = (*jenv)->NewDoubleArray(jenv, sz); + if (!jresult) + return NULL; + arr = (*jenv)->GetDoubleArrayElements(jenv, jresult, 0); + if (!arr) + return NULL; + for (i=0; iReleaseDoubleArrayElements(jenv, jresult, arr, 0); + return jresult; +} + + +#endif + + +/* Work around broken gcj jni.h */ +#ifdef __GCJ_JNI_H__ +# undef JNIEXPORT +# define JNIEXPORT +# undef JNICALL +# define JNICALL +#endif + + +#include "webp/decode.h" + +#define FillMeInAsSizeCannotBeDeterminedAutomatically \ + (result ? returned_buffer_size(__FUNCTION__, arg3, arg4) : 0) + +static jint returned_buffer_size( + const char *function, int *width, int *height) { + static const struct sizemap { + const char *function; + int size_multiplier; + } size_map[] = { + { "Java_com_google_webp_libwebpJNI_WebPDecodeRGB", 3 }, + { "Java_com_google_webp_libwebpJNI_WebPDecodeRGBA", 4 }, + { "Java_com_google_webp_libwebpJNI_WebPDecodeBGR", 3 }, + { "Java_com_google_webp_libwebpJNI_WebPDecodeBGRA", 4 }, + { NULL, 0 } + }; + const struct sizemap *p; + jint size = -1; + + for (p = size_map; p->function; p++) { + if (!strcmp(function, p->function)) { + size = *width * *height * p->size_multiplier; + break; + } + } + + return size; +} + + +#ifdef __cplusplus +extern "C" { +#endif + +SWIGEXPORT jint JNICALL Java_com_google_webp_libwebpJNI_WebPGetDecoderVersion(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + int result; + + (void)jenv; + (void)jcls; + result = (int)WebPGetDecoderVersion(); + jresult = (jint)result; + return jresult; +} + + +SWIGEXPORT jint JNICALL Java_com_google_webp_libwebpJNI_WebPGetInfo(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jint jarg2, jintArray jarg3, jintArray jarg4) { + jint jresult = 0 ; + uint8_t *arg1 = (uint8_t *) 0 ; + uint32_t arg2 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + jbyte *jarr1 ; + int temp3 ; + int temp4 ; + int result; + + (void)jenv; + (void)jcls; + if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + arg2 = (uint32_t)jarg2; + { + if (!jarg3) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); + return 0; + } + if ((*jenv)->GetArrayLength(jenv, jarg3) == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return 0; + } + arg3 = &temp3; + } + { + if (!jarg4) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); + return 0; + } + if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return 0; + } + arg4 = &temp4; + } + { + if (arg2 < 0) { + { + SWIG_JavaException(jenv, SWIG_ValueError, "Expected a non-negative value."); return 0; + }; + } + } + result = (int)WebPGetInfo((uint8_t const *)arg1,arg2,arg3,arg4); + jresult = (jint)result; + SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + { + jint jvalue = (jint)temp3; + (*jenv)->SetIntArrayRegion(jenv, jarg3, 0, 1, &jvalue); + } + { + jint jvalue = (jint)temp4; + (*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue); + } + free(arg1); + + + return jresult; +} + + +SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_WebPDecodeRGB(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jint jarg2, jintArray jarg3, jintArray jarg4) { + jbyteArray jresult = 0 ; + uint8_t *arg1 = (uint8_t *) 0 ; + uint32_t arg2 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + jbyte *jarr1 ; + int temp3 ; + int temp4 ; + uint8_t *result = 0 ; + + (void)jenv; + (void)jcls; + if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + arg2 = (uint32_t)jarg2; + { + if (!jarg3) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); + return 0; + } + if ((*jenv)->GetArrayLength(jenv, jarg3) == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return 0; + } + arg3 = &temp3; + } + { + if (!jarg4) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); + return 0; + } + if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return 0; + } + arg4 = &temp4; + } + { + if (arg2 < 0) { + { + SWIG_JavaException(jenv, SWIG_ValueError, "Expected a non-negative value."); return 0; + }; + } + } + result = (uint8_t *)WebPDecodeRGB((uint8_t const *)arg1,arg2,arg3,arg4); + jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); + SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + { + jint jvalue = (jint)temp3; + (*jenv)->SetIntArrayRegion(jenv, jarg3, 0, 1, &jvalue); + } + { + jint jvalue = (jint)temp4; + (*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue); + } + free(arg1); + + + free(result); + return jresult; +} + + +SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_WebPDecodeRGBA(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jint jarg2, jintArray jarg3, jintArray jarg4) { + jbyteArray jresult = 0 ; + uint8_t *arg1 = (uint8_t *) 0 ; + uint32_t arg2 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + jbyte *jarr1 ; + int temp3 ; + int temp4 ; + uint8_t *result = 0 ; + + (void)jenv; + (void)jcls; + if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + arg2 = (uint32_t)jarg2; + { + if (!jarg3) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); + return 0; + } + if ((*jenv)->GetArrayLength(jenv, jarg3) == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return 0; + } + arg3 = &temp3; + } + { + if (!jarg4) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); + return 0; + } + if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return 0; + } + arg4 = &temp4; + } + { + if (arg2 < 0) { + { + SWIG_JavaException(jenv, SWIG_ValueError, "Expected a non-negative value."); return 0; + }; + } + } + result = (uint8_t *)WebPDecodeRGBA((uint8_t const *)arg1,arg2,arg3,arg4); + jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); + SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + { + jint jvalue = (jint)temp3; + (*jenv)->SetIntArrayRegion(jenv, jarg3, 0, 1, &jvalue); + } + { + jint jvalue = (jint)temp4; + (*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue); + } + free(arg1); + + + free(result); + return jresult; +} + + +SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_WebPDecodeBGR(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jint jarg2, jintArray jarg3, jintArray jarg4) { + jbyteArray jresult = 0 ; + uint8_t *arg1 = (uint8_t *) 0 ; + uint32_t arg2 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + jbyte *jarr1 ; + int temp3 ; + int temp4 ; + uint8_t *result = 0 ; + + (void)jenv; + (void)jcls; + if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + arg2 = (uint32_t)jarg2; + { + if (!jarg3) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); + return 0; + } + if ((*jenv)->GetArrayLength(jenv, jarg3) == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return 0; + } + arg3 = &temp3; + } + { + if (!jarg4) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); + return 0; + } + if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return 0; + } + arg4 = &temp4; + } + { + if (arg2 < 0) { + { + SWIG_JavaException(jenv, SWIG_ValueError, "Expected a non-negative value."); return 0; + }; + } + } + result = (uint8_t *)WebPDecodeBGR((uint8_t const *)arg1,arg2,arg3,arg4); + jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); + SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + { + jint jvalue = (jint)temp3; + (*jenv)->SetIntArrayRegion(jenv, jarg3, 0, 1, &jvalue); + } + { + jint jvalue = (jint)temp4; + (*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue); + } + free(arg1); + + + free(result); + return jresult; +} + + +SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_WebPDecodeBGRA(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jint jarg2, jintArray jarg3, jintArray jarg4) { + jbyteArray jresult = 0 ; + uint8_t *arg1 = (uint8_t *) 0 ; + uint32_t arg2 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + jbyte *jarr1 ; + int temp3 ; + int temp4 ; + uint8_t *result = 0 ; + + (void)jenv; + (void)jcls; + if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + arg2 = (uint32_t)jarg2; + { + if (!jarg3) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); + return 0; + } + if ((*jenv)->GetArrayLength(jenv, jarg3) == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return 0; + } + arg3 = &temp3; + } + { + if (!jarg4) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); + return 0; + } + if ((*jenv)->GetArrayLength(jenv, jarg4) == 0) { + SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); + return 0; + } + arg4 = &temp4; + } + { + if (arg2 < 0) { + { + SWIG_JavaException(jenv, SWIG_ValueError, "Expected a non-negative value."); return 0; + }; + } + } + result = (uint8_t *)WebPDecodeBGRA((uint8_t const *)arg1,arg2,arg3,arg4); + jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); + SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + { + jint jvalue = (jint)temp3; + (*jenv)->SetIntArrayRegion(jenv, jarg3, 0, 1, &jvalue); + } + { + jint jvalue = (jint)temp4; + (*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue); + } + free(arg1); + + + free(result); + return jresult; +} + + +SWIGEXPORT jint JNICALL Java_com_google_webp_libwebpJNI_MODE_1RGB_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + WEBP_CSP_MODE result; + + (void)jenv; + (void)jcls; + result = (WEBP_CSP_MODE)MODE_RGB; + jresult = (jint)result; + return jresult; +} + + +SWIGEXPORT jint JNICALL Java_com_google_webp_libwebpJNI_MODE_1RGBA_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + WEBP_CSP_MODE result; + + (void)jenv; + (void)jcls; + result = (WEBP_CSP_MODE)MODE_RGBA; + jresult = (jint)result; + return jresult; +} + + +SWIGEXPORT jint JNICALL Java_com_google_webp_libwebpJNI_MODE_1BGR_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + WEBP_CSP_MODE result; + + (void)jenv; + (void)jcls; + result = (WEBP_CSP_MODE)MODE_BGR; + jresult = (jint)result; + return jresult; +} + + +SWIGEXPORT jint JNICALL Java_com_google_webp_libwebpJNI_MODE_1BGRA_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + WEBP_CSP_MODE result; + + (void)jenv; + (void)jcls; + result = (WEBP_CSP_MODE)MODE_BGRA; + jresult = (jint)result; + return jresult; +} + + +SWIGEXPORT jint JNICALL Java_com_google_webp_libwebpJNI_MODE_1YUV_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + WEBP_CSP_MODE result; + + (void)jenv; + (void)jcls; + result = (WEBP_CSP_MODE)MODE_YUV; + jresult = (jint)result; + return jresult; +} + + +SWIGEXPORT jint JNICALL Java_com_google_webp_libwebpJNI_VP8_1STATUS_1OK_1get(JNIEnv *jenv, jclass jcls) { + jint jresult = 0 ; + VP8StatusCode result; + + (void)jenv; + (void)jcls; + result = (VP8StatusCode)VP8_STATUS_OK; + jresult = (jint)result; + return jresult; +} + + +#ifdef __cplusplus +} +#endif +