Squashed 'external/libwebp/libwebp/' content from commit dd7364c3c
git-subtree-dir: external/libwebp/libwebp git-subtree-split: dd7364c3cefe0f5c0b3c18c3b1887d353f90fc1f
This commit is contained in:
67
swig/README.md
Normal file
67
swig/README.md
Normal file
@ -0,0 +1,67 @@
|
||||
# SWIG bindings
|
||||
|
||||
## Building
|
||||
|
||||
### JNI SWIG bindings
|
||||
|
||||
```shell
|
||||
$ gcc -shared -fPIC -fno-strict-aliasing -O2 \
|
||||
-I/path/to/your/jdk/includes \
|
||||
libwebp_java_wrap.c \
|
||||
-lwebp \
|
||||
-o libwebp_jni.so
|
||||
```
|
||||
|
||||
Example usage:
|
||||
|
||||
```java
|
||||
import com.google.webp.libwebp;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class libwebp_jni_example {
|
||||
static {
|
||||
System.loadLibrary("webp_jni");
|
||||
}
|
||||
|
||||
/**
|
||||
* usage: java -cp libwebp.jar:. libwebp_jni_example
|
||||
*/
|
||||
public static void main(String argv[]) {
|
||||
final int version = libwebp.WebPGetDecoderVersion();
|
||||
System.out.println("libwebp version: " + Integer.toHexString(version));
|
||||
|
||||
System.out.println("libwebp methods:");
|
||||
final Method[] libwebpMethods = libwebp.class.getDeclaredMethods();
|
||||
for (int i = 0; i < libwebpMethods.length; i++) {
|
||||
System.out.println(libwebpMethods[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```shell
|
||||
$ javac -cp libwebp.jar libwebp_jni_example.java
|
||||
$ java -Djava.library.path=. -cp libwebp.jar:. libwebp_jni_example
|
||||
```
|
||||
|
||||
### Python SWIG bindings:
|
||||
|
||||
```shell
|
||||
$ python setup.py build_ext
|
||||
$ python setup.py install --prefix=pylocal
|
||||
```
|
||||
|
||||
Example usage:
|
||||
|
||||
```python
|
||||
import glob
|
||||
import sys
|
||||
sys.path.append(glob.glob('pylocal/lib/python*/site-packages')[0])
|
||||
|
||||
from com.google.webp import libwebp
|
||||
print "libwebp decoder version: %x" % libwebp.WebPGetDecoderVersion()
|
||||
|
||||
print "libwebp attributes:"
|
||||
for attr in dir(libwebp): print attr
|
||||
```
|
45
swig/libwebp.go
Normal file
45
swig/libwebp.go
Normal file
@ -0,0 +1,45 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.10
|
||||
*
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
package libwebp
|
||||
|
||||
import _ "runtime/cgo"
|
||||
import "unsafe"
|
||||
|
||||
type _ unsafe.Pointer
|
||||
|
||||
type _swig_fnptr *byte
|
||||
type _swig_memberptr *byte
|
||||
|
||||
//extern libwebpSwigCgocall
|
||||
func SwigCgocall()
|
||||
|
||||
//extern libwebpSwigCgocallDone
|
||||
func SwigCgocallDone()
|
||||
|
||||
//extern libwebpSwigCgocallBack
|
||||
func SwigCgocallBack()
|
||||
|
||||
//extern libwebpSwigCgocallBackDone
|
||||
func SwigCgocallBackDone()
|
||||
|
||||
func WebPGetDecoderVersion() int
|
||||
func Wrapped_WebPGetInfo(string, []int, []int) int
|
||||
|
||||
// WebPGetInfo has 2 output parameters, provide a version in the more natural
|
||||
// go idiom:
|
||||
func WebPGetInfo(webp []byte) (ok bool, width int, height int) {
|
||||
w := []int{0}
|
||||
h := []int{0}
|
||||
ok = Wrapped_WebPGetInfo(string(webp), w, h) != 0
|
||||
width = w[0]
|
||||
height = h[0]
|
||||
return
|
||||
}
|
BIN
swig/libwebp.jar
Normal file
BIN
swig/libwebp.jar
Normal file
Binary file not shown.
235
swig/libwebp.py
Normal file
235
swig/libwebp.py
Normal file
@ -0,0 +1,235 @@
|
||||
# This file was automatically generated by SWIG (http://www.swig.org).
|
||||
# Version 3.0.12
|
||||
#
|
||||
# Do not make changes to this file unless you know what you are doing--modify
|
||||
# the SWIG interface file instead.
|
||||
|
||||
from sys import version_info as _swig_python_version_info
|
||||
if _swig_python_version_info >= (2, 7, 0):
|
||||
def swig_import_helper():
|
||||
import importlib
|
||||
pkg = __name__.rpartition('.')[0]
|
||||
mname = '.'.join((pkg, '_libwebp')).lstrip('.')
|
||||
try:
|
||||
return importlib.import_module(mname)
|
||||
except ImportError:
|
||||
return importlib.import_module('_libwebp')
|
||||
_libwebp = swig_import_helper()
|
||||
del swig_import_helper
|
||||
elif _swig_python_version_info >= (2, 6, 0):
|
||||
def swig_import_helper():
|
||||
from os.path import dirname
|
||||
import imp
|
||||
fp = None
|
||||
try:
|
||||
fp, pathname, description = imp.find_module('_libwebp', [dirname(__file__)])
|
||||
except ImportError:
|
||||
import _libwebp
|
||||
return _libwebp
|
||||
try:
|
||||
_mod = imp.load_module('_libwebp', fp, pathname, description)
|
||||
finally:
|
||||
if fp is not None:
|
||||
fp.close()
|
||||
return _mod
|
||||
_libwebp = swig_import_helper()
|
||||
del swig_import_helper
|
||||
else:
|
||||
import _libwebp
|
||||
del _swig_python_version_info
|
||||
|
||||
try:
|
||||
_swig_property = property
|
||||
except NameError:
|
||||
pass # Python < 2.2 doesn't have 'property'.
|
||||
|
||||
try:
|
||||
import builtins as __builtin__
|
||||
except ImportError:
|
||||
import __builtin__
|
||||
|
||||
def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
|
||||
if (name == "thisown"):
|
||||
return self.this.own(value)
|
||||
if (name == "this"):
|
||||
if type(value).__name__ == 'SwigPyObject':
|
||||
self.__dict__[name] = value
|
||||
return
|
||||
method = class_type.__swig_setmethods__.get(name, None)
|
||||
if method:
|
||||
return method(self, value)
|
||||
if (not static):
|
||||
if _newclass:
|
||||
object.__setattr__(self, name, value)
|
||||
else:
|
||||
self.__dict__[name] = value
|
||||
else:
|
||||
raise AttributeError("You cannot add attributes to %s" % self)
|
||||
|
||||
|
||||
def _swig_setattr(self, class_type, name, value):
|
||||
return _swig_setattr_nondynamic(self, class_type, name, value, 0)
|
||||
|
||||
|
||||
def _swig_getattr(self, class_type, name):
|
||||
if (name == "thisown"):
|
||||
return self.this.own()
|
||||
method = class_type.__swig_getmethods__.get(name, None)
|
||||
if method:
|
||||
return method(self)
|
||||
raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
|
||||
|
||||
|
||||
def _swig_repr(self):
|
||||
try:
|
||||
strthis = "proxy of " + self.this.__repr__()
|
||||
except __builtin__.Exception:
|
||||
strthis = ""
|
||||
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
|
||||
|
||||
try:
|
||||
_object = object
|
||||
_newclass = 1
|
||||
except __builtin__.Exception:
|
||||
class _object:
|
||||
pass
|
||||
_newclass = 0
|
||||
|
||||
|
||||
def WebPGetDecoderVersion():
|
||||
"""WebPGetDecoderVersion() -> int"""
|
||||
return _libwebp.WebPGetDecoderVersion()
|
||||
|
||||
def WebPGetInfo(data):
|
||||
"""WebPGetInfo(uint8_t data) -> (width, height)"""
|
||||
return _libwebp.WebPGetInfo(data)
|
||||
|
||||
def WebPDecodeRGB(data):
|
||||
"""WebPDecodeRGB(uint8_t data) -> (rgb, width, height)"""
|
||||
return _libwebp.WebPDecodeRGB(data)
|
||||
|
||||
def WebPDecodeRGBA(data):
|
||||
"""WebPDecodeRGBA(uint8_t data) -> (rgb, width, height)"""
|
||||
return _libwebp.WebPDecodeRGBA(data)
|
||||
|
||||
def WebPDecodeARGB(data):
|
||||
"""WebPDecodeARGB(uint8_t data) -> (rgb, width, height)"""
|
||||
return _libwebp.WebPDecodeARGB(data)
|
||||
|
||||
def WebPDecodeBGR(data):
|
||||
"""WebPDecodeBGR(uint8_t data) -> (rgb, width, height)"""
|
||||
return _libwebp.WebPDecodeBGR(data)
|
||||
|
||||
def WebPDecodeBGRA(data):
|
||||
"""WebPDecodeBGRA(uint8_t data) -> (rgb, width, height)"""
|
||||
return _libwebp.WebPDecodeBGRA(data)
|
||||
|
||||
def WebPGetEncoderVersion():
|
||||
"""WebPGetEncoderVersion() -> int"""
|
||||
return _libwebp.WebPGetEncoderVersion()
|
||||
|
||||
def wrap_WebPEncodeRGB(rgb, unused1, unused2, width, height, stride, quality_factor):
|
||||
"""private, do not call directly."""
|
||||
return _libwebp.wrap_WebPEncodeRGB(rgb, unused1, unused2, width, height, stride, quality_factor)
|
||||
|
||||
def wrap_WebPEncodeBGR(rgb, unused1, unused2, width, height, stride, quality_factor):
|
||||
"""private, do not call directly."""
|
||||
return _libwebp.wrap_WebPEncodeBGR(rgb, unused1, unused2, width, height, stride, quality_factor)
|
||||
|
||||
def wrap_WebPEncodeRGBA(rgb, unused1, unused2, width, height, stride, quality_factor):
|
||||
"""private, do not call directly."""
|
||||
return _libwebp.wrap_WebPEncodeRGBA(rgb, unused1, unused2, width, height, stride, quality_factor)
|
||||
|
||||
def wrap_WebPEncodeBGRA(rgb, unused1, unused2, width, height, stride, quality_factor):
|
||||
"""private, do not call directly."""
|
||||
return _libwebp.wrap_WebPEncodeBGRA(rgb, unused1, unused2, width, height, stride, quality_factor)
|
||||
|
||||
def wrap_WebPEncodeLosslessRGB(rgb, unused1, unused2, width, height, stride):
|
||||
"""private, do not call directly."""
|
||||
return _libwebp.wrap_WebPEncodeLosslessRGB(rgb, unused1, unused2, width, height, stride)
|
||||
|
||||
def wrap_WebPEncodeLosslessBGR(rgb, unused1, unused2, width, height, stride):
|
||||
"""private, do not call directly."""
|
||||
return _libwebp.wrap_WebPEncodeLosslessBGR(rgb, unused1, unused2, width, height, stride)
|
||||
|
||||
def wrap_WebPEncodeLosslessRGBA(rgb, unused1, unused2, width, height, stride):
|
||||
"""private, do not call directly."""
|
||||
return _libwebp.wrap_WebPEncodeLosslessRGBA(rgb, unused1, unused2, width, height, stride)
|
||||
|
||||
def wrap_WebPEncodeLosslessBGRA(rgb, unused1, unused2, width, height, stride):
|
||||
"""private, do not call directly."""
|
||||
return _libwebp.wrap_WebPEncodeLosslessBGRA(rgb, unused1, unused2, width, height, stride)
|
||||
|
||||
_UNUSED = 1
|
||||
|
||||
|
||||
def WebPEncodeRGB(rgb, width, height, stride, quality_factor):
|
||||
"""WebPEncodeRGB(uint8_t rgb, int width, int height, int stride, float quality_factor) -> lossy_webp"""
|
||||
webp = wrap_WebPEncodeRGB(
|
||||
rgb, _UNUSED, _UNUSED, width, height, stride, quality_factor)
|
||||
if len(webp[0]) == 0:
|
||||
return None
|
||||
return webp[0]
|
||||
|
||||
|
||||
def WebPEncodeRGBA(rgb, width, height, stride, quality_factor):
|
||||
"""WebPEncodeRGBA(uint8_t rgb, int width, int height, int stride, float quality_factor) -> lossy_webp"""
|
||||
webp = wrap_WebPEncodeRGBA(
|
||||
rgb, _UNUSED, _UNUSED, width, height, stride, quality_factor)
|
||||
if len(webp[0]) == 0:
|
||||
return None
|
||||
return webp[0]
|
||||
|
||||
|
||||
def WebPEncodeBGR(rgb, width, height, stride, quality_factor):
|
||||
"""WebPEncodeBGR(uint8_t rgb, int width, int height, int stride, float quality_factor) -> lossy_webp"""
|
||||
webp = wrap_WebPEncodeBGR(
|
||||
rgb, _UNUSED, _UNUSED, width, height, stride, quality_factor)
|
||||
if len(webp[0]) == 0:
|
||||
return None
|
||||
return webp[0]
|
||||
|
||||
|
||||
def WebPEncodeBGRA(rgb, width, height, stride, quality_factor):
|
||||
"""WebPEncodeBGRA(uint8_t rgb, int width, int height, int stride, float quality_factor) -> lossy_webp"""
|
||||
webp = wrap_WebPEncodeBGRA(
|
||||
rgb, _UNUSED, _UNUSED, width, height, stride, quality_factor)
|
||||
if len(webp[0]) == 0:
|
||||
return None
|
||||
return webp[0]
|
||||
|
||||
|
||||
def WebPEncodeLosslessRGB(rgb, width, height, stride):
|
||||
"""WebPEncodeLosslessRGB(uint8_t rgb, int width, int height, int stride) -> lossless_webp"""
|
||||
webp = wrap_WebPEncodeLosslessRGB(rgb, _UNUSED, _UNUSED, width, height, stride)
|
||||
if len(webp[0]) == 0:
|
||||
return None
|
||||
return webp[0]
|
||||
|
||||
|
||||
def WebPEncodeLosslessRGBA(rgb, width, height, stride):
|
||||
"""WebPEncodeLosslessRGBA(uint8_t rgb, int width, int height, int stride) -> lossless_webp"""
|
||||
webp = wrap_WebPEncodeLosslessRGBA(rgb, _UNUSED, _UNUSED, width, height, stride)
|
||||
if len(webp[0]) == 0:
|
||||
return None
|
||||
return webp[0]
|
||||
|
||||
|
||||
def WebPEncodeLosslessBGR(rgb, width, height, stride):
|
||||
"""WebPEncodeLosslessBGR(uint8_t rgb, int width, int height, int stride) -> lossless_webp"""
|
||||
webp = wrap_WebPEncodeLosslessBGR(rgb, _UNUSED, _UNUSED, width, height, stride)
|
||||
if len(webp[0]) == 0:
|
||||
return None
|
||||
return webp[0]
|
||||
|
||||
|
||||
def WebPEncodeLosslessBGRA(rgb, width, height, stride):
|
||||
"""WebPEncodeLosslessBGRA(uint8_t rgb, int width, int height, int stride) -> lossless_webp"""
|
||||
webp = wrap_WebPEncodeLosslessBGRA(rgb, _UNUSED, _UNUSED, width, height, stride)
|
||||
if len(webp[0]) == 0:
|
||||
return None
|
||||
return webp[0]
|
||||
|
||||
# This file is compatible with both classic and new-style classes.
|
||||
|
||||
|
438
swig/libwebp.swig
Normal file
438
swig/libwebp.swig
Normal file
@ -0,0 +1,438 @@
|
||||
// Copyright 2011 Google Inc.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style license
|
||||
// that can be found in the COPYING file in the root of the source
|
||||
// tree. An additional intellectual property rights grant can be found
|
||||
// in the file PATENTS. All contributing project authors may
|
||||
// be found in the AUTHORS file in the root of the source tree.
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// libwebp swig interface definition
|
||||
//
|
||||
// Author: James Zern (jzern@google.com)
|
||||
|
||||
/*
|
||||
Go bindings:
|
||||
$ swig -go \
|
||||
-outdir . \
|
||||
-o libwebp_go_wrap.c libwebp.swig
|
||||
|
||||
Java bindings:
|
||||
$ mkdir -p java/com/google/webp
|
||||
$ swig -java \
|
||||
-package com.google.webp \
|
||||
-outdir java/com/google/webp \
|
||||
-o libwebp_java_wrap.c libwebp.swig
|
||||
|
||||
Python bindings:
|
||||
$ swig -python \
|
||||
-outdir . \
|
||||
-o libwebp_python_wrap.c libwebp.swig
|
||||
*/
|
||||
|
||||
#ifdef SWIGPYTHON
|
||||
%module(package="com.google.webp") libwebp
|
||||
%begin %{
|
||||
#define SWIG_PYTHON_STRICT_BYTE_CHAR
|
||||
%}
|
||||
#else
|
||||
%module libwebp
|
||||
#endif /* SWIGPYTHON */
|
||||
|
||||
%include "constraints.i"
|
||||
%include "typemaps.i"
|
||||
|
||||
#ifdef SWIGGO
|
||||
%apply (char* STRING, size_t LENGTH) { (const uint8_t* data, size_t data_size) }
|
||||
|
||||
%rename(wrapped_WebPGetInfo) WebPGetInfo(const uint8_t* data, size_t data_size,
|
||||
int* width, int* height);
|
||||
#endif /* SWIGGO */
|
||||
|
||||
#ifdef SWIGJAVA
|
||||
%include "arrays_java.i";
|
||||
%include "enums.swg" /*NB: requires JDK-1.5+
|
||||
See: http://www.swig.org/Doc1.3/Java.html#enumerations */
|
||||
|
||||
// map uint8_t* such that a byte[] is used
|
||||
%{
|
||||
#include "webp/types.h"
|
||||
%}
|
||||
// from arrays_java.i (signed char)
|
||||
JAVA_ARRAYS_DECL(uint8_t, jbyte, Byte, Uint8)
|
||||
JAVA_ARRAYS_IMPL(uint8_t, jbyte, Byte, Uint8)
|
||||
JAVA_ARRAYS_TYPEMAPS(uint8_t, byte, jbyte, Uint8, "[B")
|
||||
%apply uint8_t[] { uint8_t* }
|
||||
#endif /* SWIGJAVA */
|
||||
|
||||
#ifdef SWIGPYTHON
|
||||
%apply (char* STRING, size_t LENGTH) { (const uint8_t* data, size_t data_size) }
|
||||
%typemap(out) uint8_t* {
|
||||
$result = PyString_FromStringAndSize(
|
||||
(const char*)$1,
|
||||
($1 == NULL) ? 0 : ReturnedBufferSize("$symname", arg3, arg4));
|
||||
}
|
||||
|
||||
%typemap (in) const uint8_t* rgb (Py_buffer rgb_buffer) {
|
||||
// NB: with Python < 2.6 the old style buffer protocol may be used:
|
||||
// Py_ssize_t unused;
|
||||
// PyObject_AsReadBuffer($input, (const void**)(&$1), &unused);
|
||||
if (!PyObject_CheckBuffer($input)) {
|
||||
SWIG_exception_fail(SWIG_TypeError,
|
||||
"in method '$symname', argument $argnum"
|
||||
" does not support the buffer interface");
|
||||
}
|
||||
if (PyObject_GetBuffer($input, &rgb_buffer, PyBUF_SIMPLE)) {
|
||||
SWIG_exception_fail(SWIG_RuntimeError,
|
||||
"in method '$symname', unable to get buffer view");
|
||||
}
|
||||
$1 = ($1_ltype)rgb_buffer.buf;
|
||||
}
|
||||
|
||||
%typemap(freearg) const uint8_t* rgb {
|
||||
PyBuffer_Release(&rgb_buffer$argnum);
|
||||
}
|
||||
|
||||
%define DECODE_AUTODOC(func)
|
||||
%feature("autodoc", #func "(uint8_t data) -> (rgb, width, height)") func;
|
||||
%enddef
|
||||
|
||||
%feature("autodoc", "1");
|
||||
DECODE_AUTODOC(WebPDecodeRGB);
|
||||
DECODE_AUTODOC(WebPDecodeRGBA);
|
||||
DECODE_AUTODOC(WebPDecodeARGB);
|
||||
DECODE_AUTODOC(WebPDecodeBGR);
|
||||
DECODE_AUTODOC(WebPDecodeBGRA);
|
||||
%feature("autodoc", "WebPGetInfo(uint8_t data) -> (width, height)") WebPGetInfo;
|
||||
#endif /* SWIGPYTHON */
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Decoder specific
|
||||
|
||||
%apply int* OUTPUT { int* width, int* height }
|
||||
|
||||
int WebPGetDecoderVersion(void);
|
||||
int WebPGetInfo(const uint8_t* data, size_t data_size,
|
||||
int* width, int* height);
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGPYTHON)
|
||||
|
||||
// free the buffer returned by these functions after copying into
|
||||
// the native type
|
||||
%newobject WebPDecodeRGB;
|
||||
%newobject WebPDecodeRGBA;
|
||||
%newobject WebPDecodeARGB;
|
||||
%newobject WebPDecodeBGR;
|
||||
%newobject WebPDecodeBGRA;
|
||||
%typemap(newfree) uint8_t* "free($1);"
|
||||
|
||||
uint8_t* WebPDecodeRGB(const uint8_t* data, size_t data_size,
|
||||
int* width, int* height);
|
||||
uint8_t* WebPDecodeRGBA(const uint8_t* data, size_t data_size,
|
||||
int* width, int* height);
|
||||
uint8_t* WebPDecodeARGB(const uint8_t* data, size_t data_size,
|
||||
int* width, int* height);
|
||||
uint8_t* WebPDecodeBGR(const uint8_t* data, size_t data_size,
|
||||
int* width, int* height);
|
||||
uint8_t* WebPDecodeBGRA(const uint8_t* data, size_t data_size,
|
||||
int* width, int* height);
|
||||
|
||||
#endif /* SWIGJAVA || SWIGPYTHON */
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Encoder specific
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGPYTHON)
|
||||
|
||||
int WebPGetEncoderVersion(void);
|
||||
|
||||
#endif /* SWIGJAVA || SWIGPYTHON */
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Wrapper code additions
|
||||
|
||||
%{
|
||||
#include "webp/decode.h"
|
||||
#include "webp/encode.h"
|
||||
%}
|
||||
|
||||
#ifdef SWIGJAVA
|
||||
%{
|
||||
#define FillMeInAsSizeCannotBeDeterminedAutomatically \
|
||||
(result ? (jint)ReturnedBufferSize(__FUNCTION__, arg3, arg4) : 0)
|
||||
%}
|
||||
#endif /* SWIGJAVA */
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGPYTHON)
|
||||
%{
|
||||
static size_t ReturnedBufferSize(
|
||||
const char* function, int* width, int* height) {
|
||||
static const struct sizemap {
|
||||
const char* function;
|
||||
int size_multiplier;
|
||||
} size_map[] = {
|
||||
#ifdef SWIGJAVA
|
||||
{ "Java_com_google_webp_libwebpJNI_WebPDecodeRGB", 3 },
|
||||
{ "Java_com_google_webp_libwebpJNI_WebPDecodeRGBA", 4 },
|
||||
{ "Java_com_google_webp_libwebpJNI_WebPDecodeARGB", 4 },
|
||||
{ "Java_com_google_webp_libwebpJNI_WebPDecodeBGR", 3 },
|
||||
{ "Java_com_google_webp_libwebpJNI_WebPDecodeBGRA", 4 },
|
||||
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeRGB", 1 },
|
||||
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeBGR", 1 },
|
||||
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeRGBA", 1 },
|
||||
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeBGRA", 1 },
|
||||
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLosslessRGB", 1 },
|
||||
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLosslessBGR", 1 },
|
||||
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLosslessRGBA", 1 },
|
||||
{ "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLosslessBGRA", 1 },
|
||||
#endif
|
||||
#ifdef SWIGPYTHON
|
||||
{ "WebPDecodeRGB", 3 },
|
||||
{ "WebPDecodeRGBA", 4 },
|
||||
{ "WebPDecodeARGB", 4 },
|
||||
{ "WebPDecodeBGR", 3 },
|
||||
{ "WebPDecodeBGRA", 4 },
|
||||
{ "wrap_WebPEncodeRGB", 1 },
|
||||
{ "wrap_WebPEncodeBGR", 1 },
|
||||
{ "wrap_WebPEncodeRGBA", 1 },
|
||||
{ "wrap_WebPEncodeBGRA", 1 },
|
||||
{ "wrap_WebPEncodeLosslessRGB", 1 },
|
||||
{ "wrap_WebPEncodeLosslessBGR", 1 },
|
||||
{ "wrap_WebPEncodeLosslessRGBA", 1 },
|
||||
{ "wrap_WebPEncodeLosslessBGRA", 1 },
|
||||
#endif
|
||||
{ NULL, 0 }
|
||||
};
|
||||
const struct sizemap* p;
|
||||
size_t size = 0;
|
||||
|
||||
for (p = size_map; p->function; ++p) {
|
||||
if (!strcmp(function, p->function)) {
|
||||
size = *width * *height * p->size_multiplier;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
%}
|
||||
|
||||
%{
|
||||
typedef size_t (*WebPEncodeFunction)(const uint8_t* rgb,
|
||||
int width, int height, int stride,
|
||||
float quality_factor, uint8_t** output);
|
||||
typedef size_t (*WebPEncodeLosslessFunction)(const uint8_t* rgb,
|
||||
int width, int height, int stride,
|
||||
uint8_t** output);
|
||||
|
||||
static uint8_t* EncodeLossy(const uint8_t* rgb,
|
||||
int width, int height, int stride,
|
||||
float quality_factor,
|
||||
WebPEncodeFunction encfn,
|
||||
int* output_size, int* unused) {
|
||||
uint8_t* output = NULL;
|
||||
const size_t image_size =
|
||||
encfn(rgb, width, height, stride, quality_factor, &output);
|
||||
// the values of following two will be interpreted by ReturnedBufferSize()
|
||||
// as 'width' and 'height' in the size calculation.
|
||||
*output_size = image_size;
|
||||
*unused = 1;
|
||||
return image_size ? output : NULL;
|
||||
}
|
||||
|
||||
static uint8_t* EncodeLossless(const uint8_t* rgb,
|
||||
int width, int height, int stride,
|
||||
WebPEncodeLosslessFunction encfn,
|
||||
int* output_size, int* unused) {
|
||||
uint8_t* output = NULL;
|
||||
const size_t image_size = encfn(rgb, width, height, stride, &output);
|
||||
// the values of the following two will be interpreted by
|
||||
// ReturnedBufferSize() as 'width' and 'height' in the size calculation.
|
||||
*output_size = image_size;
|
||||
*unused = 1;
|
||||
return image_size ? output : NULL;
|
||||
}
|
||||
%}
|
||||
|
||||
#endif /* SWIGJAVA || SWIGPYTHON */
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// libwebp/encode wrapper functions
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGPYTHON)
|
||||
|
||||
%apply int* INPUT { int* unused1, int* unused2 }
|
||||
%apply int* OUTPUT { int* output_size }
|
||||
|
||||
// free the buffer returned by these functions after copying into
|
||||
// the native type
|
||||
%newobject wrap_WebPEncodeRGB;
|
||||
%newobject wrap_WebPEncodeBGR;
|
||||
%newobject wrap_WebPEncodeRGBA;
|
||||
%newobject wrap_WebPEncodeBGRA;
|
||||
%newobject wrap_WebPEncodeLosslessRGB;
|
||||
%newobject wrap_WebPEncodeLosslessBGR;
|
||||
%newobject wrap_WebPEncodeLosslessRGBA;
|
||||
%newobject wrap_WebPEncodeLosslessBGRA;
|
||||
|
||||
#ifdef SWIGJAVA
|
||||
// There's no reason to call these directly
|
||||
%javamethodmodifiers wrap_WebPEncodeRGB "private";
|
||||
%javamethodmodifiers wrap_WebPEncodeBGR "private";
|
||||
%javamethodmodifiers wrap_WebPEncodeRGBA "private";
|
||||
%javamethodmodifiers wrap_WebPEncodeBGRA "private";
|
||||
%javamethodmodifiers wrap_WebPEncodeLosslessRGB "private";
|
||||
%javamethodmodifiers wrap_WebPEncodeLosslessBGR "private";
|
||||
%javamethodmodifiers wrap_WebPEncodeLosslessRGBA "private";
|
||||
%javamethodmodifiers wrap_WebPEncodeLosslessBGRA "private";
|
||||
#endif /* SWIGJAVA */
|
||||
|
||||
#ifdef SWIGPYTHON
|
||||
// This autodoc will serve as a catch-all for wrap_*.
|
||||
%feature("autodoc", "private, do not call directly.");
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
// Changes the return type of WebPEncode* to more closely match Decode*.
|
||||
// This also makes it easier to wrap the output buffer in a native type rather
|
||||
// than dealing with the return pointer.
|
||||
// The additional parameters are to allow reuse of ReturnedBufferSize(),
|
||||
// unused2 and output_size will be used in this case.
|
||||
#define LOSSY_WRAPPER(FUNC) \
|
||||
static uint8_t* wrap_##FUNC( \
|
||||
const uint8_t* rgb, int* unused1, int* unused2, int* output_size, \
|
||||
int width, int height, int stride, float quality_factor) { \
|
||||
return EncodeLossy(rgb, width, height, stride, quality_factor, \
|
||||
FUNC, output_size, unused2); \
|
||||
} \
|
||||
|
||||
LOSSY_WRAPPER(WebPEncodeRGB)
|
||||
LOSSY_WRAPPER(WebPEncodeBGR)
|
||||
LOSSY_WRAPPER(WebPEncodeRGBA)
|
||||
LOSSY_WRAPPER(WebPEncodeBGRA)
|
||||
|
||||
#undef LOSSY_WRAPPER
|
||||
|
||||
#define LOSSLESS_WRAPPER(FUNC) \
|
||||
static uint8_t* wrap_##FUNC( \
|
||||
const uint8_t* rgb, int* unused1, int* unused2, int* output_size, \
|
||||
int width, int height, int stride) { \
|
||||
return EncodeLossless(rgb, width, height, stride, \
|
||||
FUNC, output_size, unused2); \
|
||||
} \
|
||||
|
||||
LOSSLESS_WRAPPER(WebPEncodeLosslessRGB)
|
||||
LOSSLESS_WRAPPER(WebPEncodeLosslessBGR)
|
||||
LOSSLESS_WRAPPER(WebPEncodeLosslessRGBA)
|
||||
LOSSLESS_WRAPPER(WebPEncodeLosslessBGRA)
|
||||
|
||||
#undef LOSSLESS_WRAPPER
|
||||
|
||||
%}
|
||||
|
||||
#endif /* SWIGJAVA || SWIGPYTHON */
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Language specific
|
||||
|
||||
#ifdef SWIGGO
|
||||
%insert(go_wrapper) %{
|
||||
|
||||
// WebPGetInfo has 2 output parameters, provide a version in the more natural
|
||||
// go idiom:
|
||||
func WebPGetInfo(webp []byte) (ok bool, width int, height int) {
|
||||
w := []int{0}
|
||||
h := []int{0}
|
||||
ok = Wrapped_WebPGetInfo(string(webp), w, h) != 0
|
||||
width = w[0]
|
||||
height = h[0]
|
||||
return
|
||||
}
|
||||
|
||||
%}
|
||||
#endif /* SWIGGO */
|
||||
|
||||
#ifdef SWIGJAVA
|
||||
%{
|
||||
/* Work around broken gcj jni.h */
|
||||
#ifdef __GCJ_JNI_H__
|
||||
# undef JNIEXPORT
|
||||
# define JNIEXPORT
|
||||
# undef JNICALL
|
||||
# define JNICALL
|
||||
#endif
|
||||
%}
|
||||
|
||||
%pragma(java) modulecode=%{
|
||||
private static final int UNUSED = 1;
|
||||
private static int outputSize[] = { 0 };
|
||||
%}
|
||||
|
||||
|
||||
%define CALL_ENCODE_LOSSY_WRAPPER(func)
|
||||
%pragma(java) modulecode=%{
|
||||
public static byte[] func(
|
||||
byte[] rgb, int width, int height, int stride, float quality_factor) {
|
||||
return wrap_##func(
|
||||
rgb, UNUSED, UNUSED, outputSize, width, height, stride, quality_factor);
|
||||
}
|
||||
%}
|
||||
%enddef
|
||||
|
||||
%define CALL_ENCODE_LOSSLESS_WRAPPER(func)
|
||||
%pragma(java) modulecode=%{
|
||||
public static byte[] func(
|
||||
byte[] rgb, int width, int height, int stride) {
|
||||
return wrap_##func(
|
||||
rgb, UNUSED, UNUSED, outputSize, width, height, stride);
|
||||
}
|
||||
%}
|
||||
%enddef
|
||||
|
||||
CALL_ENCODE_LOSSY_WRAPPER(WebPEncodeRGB)
|
||||
CALL_ENCODE_LOSSY_WRAPPER(WebPEncodeRGBA)
|
||||
CALL_ENCODE_LOSSY_WRAPPER(WebPEncodeBGR)
|
||||
CALL_ENCODE_LOSSY_WRAPPER(WebPEncodeBGRA)
|
||||
CALL_ENCODE_LOSSLESS_WRAPPER(WebPEncodeLosslessRGB)
|
||||
CALL_ENCODE_LOSSLESS_WRAPPER(WebPEncodeLosslessRGBA)
|
||||
CALL_ENCODE_LOSSLESS_WRAPPER(WebPEncodeLosslessBGR)
|
||||
CALL_ENCODE_LOSSLESS_WRAPPER(WebPEncodeLosslessBGRA)
|
||||
#endif /* SWIGJAVA */
|
||||
|
||||
#ifdef SWIGPYTHON
|
||||
%pythoncode %{
|
||||
_UNUSED = 1
|
||||
%}
|
||||
|
||||
%define CALL_ENCODE_LOSSY_WRAPPER(func)
|
||||
%pythoncode %{
|
||||
def func(rgb, width, height, stride, quality_factor):
|
||||
"""func(uint8_t rgb, int width, int height, int stride, float quality_factor) -> lossy_webp"""
|
||||
webp = wrap_##func(
|
||||
rgb, _UNUSED, _UNUSED, width, height, stride, quality_factor)
|
||||
if len(webp[0]) == 0:
|
||||
return None
|
||||
return webp[0]
|
||||
%}
|
||||
%enddef
|
||||
|
||||
%define CALL_ENCODE_LOSSLESS_WRAPPER(func)
|
||||
%pythoncode %{
|
||||
def func(rgb, width, height, stride):
|
||||
"""func(uint8_t rgb, int width, int height, int stride) -> lossless_webp"""
|
||||
webp = wrap_##func(rgb, _UNUSED, _UNUSED, width, height, stride)
|
||||
if len(webp[0]) == 0:
|
||||
return None
|
||||
return webp[0]
|
||||
%}
|
||||
%enddef
|
||||
|
||||
CALL_ENCODE_LOSSY_WRAPPER(WebPEncodeRGB)
|
||||
CALL_ENCODE_LOSSY_WRAPPER(WebPEncodeRGBA)
|
||||
CALL_ENCODE_LOSSY_WRAPPER(WebPEncodeBGR)
|
||||
CALL_ENCODE_LOSSY_WRAPPER(WebPEncodeBGRA)
|
||||
CALL_ENCODE_LOSSLESS_WRAPPER(WebPEncodeLosslessRGB)
|
||||
CALL_ENCODE_LOSSLESS_WRAPPER(WebPEncodeLosslessRGBA)
|
||||
CALL_ENCODE_LOSSLESS_WRAPPER(WebPEncodeLosslessBGR)
|
||||
CALL_ENCODE_LOSSLESS_WRAPPER(WebPEncodeLosslessBGRA)
|
||||
#endif /* SWIGPYTHON */
|
52
swig/libwebp_gc.c
Normal file
52
swig/libwebp_gc.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.10
|
||||
*
|
||||
* 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.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* This file should be compiled with 6c/8c. */
|
||||
#pragma dynimport _ _ "libwebp_go.so"
|
||||
|
||||
#include "runtime.h"
|
||||
#include "cgocall.h"
|
||||
|
||||
#ifdef _64BIT
|
||||
#define SWIG_PARM_SIZE 8
|
||||
#else
|
||||
#define SWIG_PARM_SIZE 4
|
||||
#endif
|
||||
|
||||
#pragma dynimport _wrap_WebPGetDecoderVersion _wrap_WebPGetDecoderVersion ""
|
||||
extern void (*_wrap_WebPGetDecoderVersion)(void*);
|
||||
static void (*x_wrap_WebPGetDecoderVersion)(void*) = _wrap_WebPGetDecoderVersion;
|
||||
|
||||
void
|
||||
·WebPGetDecoderVersion(struct {
|
||||
uint8 x[SWIG_PARM_SIZE];
|
||||
} p)
|
||||
|
||||
{
|
||||
runtime·cgocall(x_wrap_WebPGetDecoderVersion, &p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma dynimport _wrap_wrapped_WebPGetInfo _wrap_wrapped_WebPGetInfo ""
|
||||
extern void (*_wrap_wrapped_WebPGetInfo)(void*);
|
||||
static void (*x_wrap_wrapped_WebPGetInfo)(void*) = _wrap_wrapped_WebPGetInfo;
|
||||
|
||||
void
|
||||
·Wrapped_WebPGetInfo(struct {
|
||||
uint8 x[(2 * SWIG_PARM_SIZE) + (3 * SWIG_PARM_SIZE) + (3 * SWIG_PARM_SIZE) + SWIG_PARM_SIZE];
|
||||
} p)
|
||||
|
||||
{
|
||||
runtime·cgocall(x_wrap_wrapped_WebPGetInfo, &p);
|
||||
}
|
||||
|
||||
|
||||
|
274
swig/libwebp_go_wrap.c
Normal file
274
swig/libwebp_go_wrap.c
Normal file
@ -0,0 +1,274 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 2.0.10
|
||||
*
|
||||
* 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 SWIGMODULE libwebp
|
||||
/* -----------------------------------------------------------------------------
|
||||
* 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
|
||||
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
|
||||
typedef long long intgo;
|
||||
typedef unsigned long long uintgo;
|
||||
|
||||
|
||||
|
||||
typedef struct { char *p; intgo n; } _gostring_;
|
||||
typedef struct { void* array; intgo len; intgo cap; } _goslice_;
|
||||
|
||||
|
||||
|
||||
|
||||
#define swiggo_size_assert_eq(x, y, name) typedef char name[(x-y)*(x-y)*-2+1];
|
||||
#define swiggo_size_assert(t, n) swiggo_size_assert_eq(sizeof(t), n, swiggo_sizeof_##t##_is_not_##n)
|
||||
|
||||
swiggo_size_assert(char, 1)
|
||||
swiggo_size_assert(short, 2)
|
||||
swiggo_size_assert(int, 4)
|
||||
typedef long long swiggo_long_long;
|
||||
swiggo_size_assert(swiggo_long_long, 8)
|
||||
swiggo_size_assert(float, 4)
|
||||
swiggo_size_assert(double, 8)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern void crosscall2(void (*fn)(void *, int), void *, int);
|
||||
extern void _cgo_allocate(void *, int);
|
||||
extern void _cgo_panic(void *, int);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
static void *_swig_goallocate(size_t len) {
|
||||
struct {
|
||||
size_t len;
|
||||
void *ret;
|
||||
} a;
|
||||
a.len = len;
|
||||
crosscall2(_cgo_allocate, &a, (int) sizeof a);
|
||||
return a.ret;
|
||||
}
|
||||
|
||||
static void _swig_gopanic(const char *p) {
|
||||
struct {
|
||||
const char *p;
|
||||
} a;
|
||||
a.p = p;
|
||||
crosscall2(_cgo_panic, &a, (int) sizeof a);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static _gostring_ _swig_makegostring(const char *p, size_t l) {
|
||||
_gostring_ ret;
|
||||
ret.p = (char*)_swig_goallocate(l + 1);
|
||||
memcpy(ret.p, p, l);
|
||||
ret.n = l;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define SWIG_contract_assert(expr, msg) \
|
||||
if (!(expr)) { _swig_gopanic(msg); } else
|
||||
|
||||
|
||||
#define SWIG_exception(code, msg) _swig_gopanic(msg)
|
||||
|
||||
|
||||
#include "webp/decode.h"
|
||||
#include "webp/encode.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void
|
||||
_wrap_WebPGetDecoderVersion(void *swig_v)
|
||||
{
|
||||
int result;
|
||||
|
||||
struct swigargs {
|
||||
long : 0;
|
||||
intgo result;
|
||||
} *swig_a = (struct swigargs *) swig_v;
|
||||
|
||||
|
||||
result = (int)WebPGetDecoderVersion();
|
||||
swig_a->result = result;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_wrap_wrapped_WebPGetInfo(void *swig_v)
|
||||
{
|
||||
uint8_t *arg1 = (uint8_t *) 0 ;
|
||||
size_t arg2 ;
|
||||
int *arg3 = (int *) 0 ;
|
||||
int *arg4 = (int *) 0 ;
|
||||
int temp3 ;
|
||||
int temp4 ;
|
||||
int result;
|
||||
|
||||
struct swigargs {
|
||||
_gostring_ arg1;
|
||||
_goslice_ arg3;
|
||||
_goslice_ arg4;
|
||||
long : 0;
|
||||
intgo result;
|
||||
} *swig_a = (struct swigargs *) swig_v;
|
||||
|
||||
|
||||
arg1 = (uint8_t *)swig_a->arg1.p;
|
||||
arg2 = (size_t)swig_a->arg1.n;
|
||||
|
||||
{
|
||||
if (swig_a->arg3.len == 0) {
|
||||
_swig_gopanic("array must contain at least 1 element");
|
||||
}
|
||||
arg3 = &temp3;
|
||||
}
|
||||
{
|
||||
if (swig_a->arg4.len == 0) {
|
||||
_swig_gopanic("array must contain at least 1 element");
|
||||
}
|
||||
arg4 = &temp4;
|
||||
}
|
||||
|
||||
result = (int)WebPGetInfo((uint8_t const *)arg1,arg2,arg3,arg4);
|
||||
swig_a->result = result;
|
||||
{
|
||||
int* a = (int *) swig_a->arg3.array;
|
||||
a[0] = temp3;
|
||||
}
|
||||
{
|
||||
int* a = (int *) swig_a->arg4.array;
|
||||
a[0] = temp4;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
1765
swig/libwebp_java_wrap.c
Normal file
1765
swig/libwebp_java_wrap.c
Normal file
File diff suppressed because it is too large
Load Diff
5628
swig/libwebp_python_wrap.c
Normal file
5628
swig/libwebp_python_wrap.c
Normal file
File diff suppressed because it is too large
Load Diff
40
swig/setup.py
Normal file
40
swig/setup.py
Normal file
@ -0,0 +1,40 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
"""distutils script for libwebp python module."""
|
||||
|
||||
from distutils.core import setup
|
||||
from distutils.extension import Extension
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
tmpdir = tempfile.mkdtemp()
|
||||
package = "com.google.webp"
|
||||
package_path = os.path.join(tmpdir, *package.split("."))
|
||||
os.makedirs(package_path)
|
||||
|
||||
# Create __init_.py files along the package path.
|
||||
initpy_path = tmpdir
|
||||
for d in package.split("."):
|
||||
initpy_path = os.path.join(initpy_path, d)
|
||||
open(os.path.join(initpy_path, "__init__.py"), "w").close()
|
||||
|
||||
shutil.copy2("libwebp.py", package_path)
|
||||
setup(name="libwebp",
|
||||
version="0.0",
|
||||
description="libwebp python wrapper",
|
||||
long_description="Provides access to 'simple' libwebp decode interface",
|
||||
license="BSD",
|
||||
url="http://developers.google.com/speed/webp",
|
||||
ext_package=package,
|
||||
ext_modules=[Extension("_libwebp",
|
||||
["libwebp_python_wrap.c"],
|
||||
libraries=["webp"],
|
||||
),
|
||||
],
|
||||
package_dir={"": tmpdir},
|
||||
packages=["com", "com.google", "com.google.webp"],
|
||||
py_modules=[package + ".libwebp"],
|
||||
)
|
||||
|
||||
shutil.rmtree(tmpdir)
|
Reference in New Issue
Block a user