From bc9f5fbe0fae8121d398b087f233e02b7674fb93 Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 2 Apr 2013 18:45:02 -0700 Subject: [PATCH 01/57] configure.ac: add AM_PROG_AR for automake >= 1.12 fixes: automake-1.12/am/ltlibrary.am: warning: 'libwebp.la': linking libtool libraries using a non-POSIX automake-1.12/am/ltlibrary.am: archiver requires 'AM_PROG_AR' in 'configure.ac' Change-Id: I223f93e5f075aaf23cfefceef55e2ab8eeb34ccd (cherry picked from commit ed4dc717696ddc791363f2301fb4a142d4ef4633) --- configure.ac | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index 3b344f0e..df0560a0 100644 --- a/configure.ac +++ b/configure.ac @@ -3,6 +3,11 @@ AC_INIT([libwebp], [0.3.0], [http://developers.google.com/speed/webp]) AC_CANONICAL_TARGET AM_INIT_AUTOMAKE([-Wall foreign subdir-objects]) + +dnl === automake >= 1.12 requires this for 'unusual archivers' support. +dnl === it must occur before LT_INIT (AC_PROG_LIBTOOL). +m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) + AC_PROG_LIBTOOL AM_PROG_CC_C_O From dcbb1ca54aae57fadd220b269cd4907f89085ca4 Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Tue, 2 Apr 2013 19:14:14 -0700 Subject: [PATCH 02/57] add WebPBlendAlpha() function to blend colors against background new option: -blend_alpha 0xrrggbb also: don't force picture.use_argb value for lossless. Instead, delay the YUVA<->ARGB conversion till WebPEncode() is called. This make the blending more accurate when source is ARGB and lossy compression is used (YUVA). This has an effect on cropping/rescaling. E.g. for PNG, these are now done in ARGB colorspace instead of YUV when lossy compression is used. Change-Id: I18571f1b1179881737a8dbd23ad0aa8cddae3c6b (cherry picked from commit e7d9548c9bc94a7c8f2ce70ec81464abb4abf9d6) --- README | 4 ++ examples/cwebp.c | 16 +++++++- examples/pngdec.c | 1 + examples/tiffdec.c | 1 + examples/wicdec.c | 1 + man/cwebp.1 | 7 +++- src/enc/picture.c | 92 ++++++++++++++++++++++++++++++++++++++++++++-- src/webp/encode.h | 5 +++ 8 files changed, 121 insertions(+), 6 deletions(-) diff --git a/README b/README index a2eed05b..aa6bca45 100644 --- a/README +++ b/README @@ -170,6 +170,10 @@ options: -alpha_filter . predictive filtering for alpha plane. One of: none, fast (default) or best. -alpha_cleanup ......... Clean RGB values in transparent area. + -blend_alpha ..... Blend colors against background color + expressed as RGB values written in + hexadecimal, e.g. 0xc0e0d0 for red=0xc0 + green=0xe0 and blue=0xd0. -noalpha ............... discard any transparency information. -lossless .............. Encode image losslessly. -hint ......... Specify image characteristics hint. diff --git a/examples/cwebp.c b/examples/cwebp.c index 827b5c25..300d2c4f 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -594,6 +594,10 @@ static void HelpLong(void) { printf(" -alpha_filter . predictive filtering for alpha plane.\n"); printf(" One of: none, fast (default) or best.\n"); printf(" -alpha_cleanup ......... Clean RGB values in transparent area.\n"); + printf(" -blend_alpha ..... Blend colors against background color\n" + " expressed as RGB values written in\n" + " hexadecimal, e.g. 0xc0e0d0 for red=0xc0\n" + " green=0xe0 and blue=0xd0.\n"); printf(" -noalpha ............... discard any transparency information.\n"); printf(" -lossless .............. Encode image losslessly.\n"); printf(" -hint ......... Specify image characteristics hint.\n"); @@ -656,6 +660,8 @@ int main(int argc, const char *argv[]) { int short_output = 0; int quiet = 0; int keep_alpha = 1; + int blend_alpha = 0; + uint32_t background_color = 0xffffffu; int crop = 0, crop_x = 0, crop_y = 0, crop_w = 0, crop_h = 0; int resize_w = 0, resize_h = 0; int show_progress = 0; @@ -720,6 +726,10 @@ int main(int argc, const char *argv[]) { config.alpha_compression = strtol(argv[++c], NULL, 0); } else if (!strcmp(argv[c], "-alpha_cleanup")) { keep_alpha = keep_alpha ? 2 : 0; + } else if (!strcmp(argv[c], "-blend_alpha") && c < argc - 1) { + blend_alpha = 1; + background_color = strtol(argv[++c], NULL, 16); // <- parses '0x' prefix + background_color = background_color & 0x00ffffffu; } else if (!strcmp(argv[c], "-alpha_filter") && c < argc - 1) { ++c; if (!strcmp(argv[c], "none")) { @@ -736,7 +746,6 @@ int main(int argc, const char *argv[]) { keep_alpha = 0; } else if (!strcmp(argv[c], "-lossless")) { config.lossless = 1; - picture.use_argb = 1; } else if (!strcmp(argv[c], "-hint") && c < argc - 1) { ++c; if (!strcmp(argv[c], "photo")) { @@ -924,6 +933,11 @@ int main(int argc, const char *argv[]) { goto Error; } picture.progress_hook = (show_progress && !quiet) ? ProgressReport : NULL; + + if (blend_alpha) { + WebPBlendAlpha(&picture, background_color); + } + if (keep_alpha == 2) { WebPCleanupTransparentArea(&picture); } diff --git a/examples/pngdec.c b/examples/pngdec.c index e30df0a3..7a7649c7 100644 --- a/examples/pngdec.c +++ b/examples/pngdec.c @@ -267,6 +267,7 @@ int ReadPNG(FILE* in_file, WebPPicture* const pic, int keep_alpha, pic->width = width; pic->height = height; + pic->use_argb = 1; ok = has_alpha ? WebPPictureImportRGBA(pic, rgb, stride) : WebPPictureImportRGB(pic, rgb, stride); free(rgb); diff --git a/examples/tiffdec.c b/examples/tiffdec.c index 81cb7e46..8845afbd 100644 --- a/examples/tiffdec.c +++ b/examples/tiffdec.c @@ -98,6 +98,7 @@ int ReadTIFF(const char* const filename, #ifdef __BIG_ENDIAN__ TIFFSwabArrayOfLong(raster, width * height); #endif + pic->use_argb = 1; ok = keep_alpha ? WebPPictureImportRGBA(pic, (const uint8_t*)raster, stride) : WebPPictureImportRGBX(pic, (const uint8_t*)raster, stride); diff --git a/examples/wicdec.c b/examples/wicdec.c index aab6f985..009401d8 100644 --- a/examples/wicdec.c +++ b/examples/wicdec.c @@ -306,6 +306,7 @@ int ReadPictureWithWIC(const char* const filename, int ok; pic->width = width; pic->height = height; + pic->use_argb = 1; ok = importer->import(pic, rgb, stride); if (!ok) hr = E_FAIL; } diff --git a/man/cwebp.1 b/man/cwebp.1 index 2e5dbb08..9c3c7338 100644 --- a/man/cwebp.1 +++ b/man/cwebp.1 @@ -1,5 +1,5 @@ .\" Hey, EMACS: -*- nroff -*- -.TH CWEBP 1 "March 13, 2013" +.TH CWEBP 1 "March 28, 2013" .SH NAME cwebp \- compress an image file to a WebP file .SH SYNOPSIS @@ -187,6 +187,11 @@ no compression, 1 uses WebP lossless format for compression. The default is 1. Modify unseen RGB values under fully transparent area, to help compressibility. The default is off. .TP +.BI \-blend_alpha " int +This option blends the alpha channel (if present) with the source using the +background color specified in hexadecimal as 0xrrggbb. The alpha channel is +afterward reset to the opaque value 255. +.TP .B \-noalpha Using this option will discard the alpha channel. .TP diff --git a/src/enc/picture.c b/src/enc/picture.c index 1e51a8dc..ce8f59ad 100644 --- a/src/enc/picture.c +++ b/src/enc/picture.c @@ -32,6 +32,10 @@ static const union { } test_endian = { 0xff000000u }; #define ALPHA_IS_LAST (test_endian.bytes[3] == 0xff) +static WEBP_INLINE uint32_t MakeARGB32(int r, int g, int b) { + return (0xff000000u | (r << 16) | (g << 8) | b); +} + //------------------------------------------------------------------------------ // WebPPicture //------------------------------------------------------------------------------ @@ -696,10 +700,7 @@ static int Import(WebPPicture* const picture, for (x = 0; x < width; ++x) { const int offset = step * x + y * rgb_stride; const uint32_t argb = - 0xff000000u | - (r_ptr[offset] << 16) | - (g_ptr[offset] << 8) | - (b_ptr[offset]); + MakeARGB32(r_ptr[offset], g_ptr[offset], b_ptr[offset]); picture->argb[x + y * picture->argb_stride] = argb; } } @@ -910,6 +911,89 @@ void WebPCleanupTransparentArea(WebPPicture* pic) { #undef SIZE #undef SIZE2 +//------------------------------------------------------------------------------ +// Blend color and remove transparency info + +#define BLEND(V0, V1, ALPHA) \ + ((((V0) * (255 - (ALPHA)) + (V1) * (ALPHA)) * 0x101) >> 16) +#define BLEND_10BIT(V0, V1, ALPHA) \ + ((((V0) * (1020 - (ALPHA)) + (V1) * (ALPHA)) * 0x101) >> 18) + +void WebPBlendAlpha(WebPPicture* pic, uint32_t background_rgb) { + const int red = (background_rgb >> 16) & 0xff; + const int green = (background_rgb >> 8) & 0xff; + const int blue = (background_rgb >> 0) & 0xff; + int x, y; + if (pic == NULL) return; + if (!pic->use_argb) { + const int uv_width = (pic->width >> 1); // omit last pixel during u/v loop + const int Y0 = VP8RGBToY(red, green, blue); + // VP8RGBToU/V expects the u/v values summed over four pixels + const int U0 = VP8RGBToU(4 * red, 4 * green, 4 * blue); + const int V0 = VP8RGBToV(4 * red, 4 * green, 4 * blue); + const int has_alpha = pic->colorspace & WEBP_CSP_ALPHA_BIT; + if (!has_alpha || pic->a == NULL) return; // nothing to do + for (y = 0; y < pic->height; ++y) { + // Luma blending + uint8_t* const y_ptr = pic->y + y * pic->y_stride; + uint8_t* const a_ptr = pic->a + y * pic->a_stride; + for (x = 0; x < pic->width; ++x) { + const int alpha = a_ptr[x]; + if (alpha < 0xff) { + y_ptr[x] = BLEND(Y0, y_ptr[x], a_ptr[x]); + } + } + // Chroma blending every even line + if ((y & 1) == 0) { + uint8_t* const u = pic->u + (y >> 1) * pic->uv_stride; + uint8_t* const v = pic->v + (y >> 1) * pic->uv_stride; + uint8_t* const a_ptr2 = + (y + 1 == pic->height) ? a_ptr : a_ptr + pic->a_stride; + for (x = 0; x < uv_width; ++x) { + // Average four alpha values into a single blending weight. + // TODO(skal): might lead to visible contouring. Can we do better? + const int alpha = + a_ptr[2 * x + 0] + a_ptr[2 * x + 1] + + a_ptr2[2 * x + 0] + a_ptr2[2 * x + 1]; + u[x] = BLEND_10BIT(U0, u[x], alpha); + v[x] = BLEND_10BIT(V0, v[x], alpha); + } + if (pic->width & 1) { // rightmost pixel + const int alpha = 2 * (a_ptr[2 * x + 0] + a_ptr2[2 * x + 0]); + u[x] = BLEND_10BIT(U0, u[x], alpha); + v[x] = BLEND_10BIT(V0, v[x], alpha); + } + } + memset(a_ptr, 0xff, pic->width); + } + } else { + uint32_t* argb = pic->argb; + const uint32_t background = MakeARGB32(red, green, blue); + for (y = 0; y < pic->height; ++y) { + for (x = 0; x < pic->width; ++x) { + const int alpha = (argb[x] >> 24) & 0xff; + if (alpha != 0xff) { + if (alpha > 0) { + int r = (argb[x] >> 16) & 0xff; + int g = (argb[x] >> 8) & 0xff; + int b = (argb[x] >> 0) & 0xff; + r = BLEND(red, r, alpha); + g = BLEND(green, g, alpha); + b = BLEND(blue, b, alpha); + argb[x] = MakeARGB32(r, g, b); + } else { + argb[x] = background; + } + } + } + argb += pic->argb_stride; + } + } +} + +#undef BLEND +#undef BLEND_10BIT + //------------------------------------------------------------------------------ // local-min distortion // diff --git a/src/webp/encode.h b/src/webp/encode.h index fea8ee42..ad20fa1d 100644 --- a/src/webp/encode.h +++ b/src/webp/encode.h @@ -456,6 +456,11 @@ WEBP_EXTERN(void) WebPCleanupTransparentArea(WebPPicture* picture); // alpha plane can be ignored altogether e.g.). WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* picture); +// Remove the transparency information (if present) by blending the color with +// the background color 'background_rgb' (specified as 24bit RGB triplet). +// After this call, all alpha values are reset to 0xff. +WEBP_EXTERN(void) WebPBlendAlpha(WebPPicture* pic, uint32_t background_rgb); + //------------------------------------------------------------------------------ // Main call From 1fb04bec99c6930aac702e74bf85c7de2519fed1 Mon Sep 17 00:00:00 2001 From: Urvang Joshi Date: Fri, 5 Apr 2013 11:24:59 -0700 Subject: [PATCH 03/57] pngdec: Avoid a double-free. Earlier, at line#275, if ok == 0, it would have triggered a double free of 'rgb'. Change-Id: Iaee1f35824a66f6e4b488e523416f73b87c5ec30 (cherry picked from commit b68912af2c8cefa52bb16634b077938ff074f03a) --- examples/pngdec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/pngdec.c b/examples/pngdec.c index 7a7649c7..78353560 100644 --- a/examples/pngdec.c +++ b/examples/pngdec.c @@ -207,7 +207,6 @@ int ReadPNG(FILE* in_file, WebPPicture* const pic, int keep_alpha, Error: MetadataFree(metadata); png_destroy_read_struct(&png, &info, &end_info); - free(rgb); goto End; } @@ -270,13 +269,13 @@ int ReadPNG(FILE* in_file, WebPPicture* const pic, int keep_alpha, pic->use_argb = 1; ok = has_alpha ? WebPPictureImportRGBA(pic, rgb, stride) : WebPPictureImportRGB(pic, rgb, stride); - free(rgb); if (!ok) { goto Error; } End: + free(rgb); return ok; } #else // !WEBP_HAVE_PNG From f4c7b6547b3ef9c51bedfef316a4447f79103629 Mon Sep 17 00:00:00 2001 From: Urvang Joshi Date: Fri, 5 Apr 2013 11:33:44 -0700 Subject: [PATCH 04/57] WebPEncode: An additional check. Start VP8EncLoop/VP8EncTokenLoop only if VP8EncStartAlpha succeeded. Change-Id: Id1faca3e6def88102329ae2b4974bd4d6d4c4a7a (cherry picked from commit 67708d67013776fb0aa6593a49249a1b350fe602) --- src/enc/webpenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/enc/webpenc.c b/src/enc/webpenc.c index 20fbac4d..93d34dae 100644 --- a/src/enc/webpenc.c +++ b/src/enc/webpenc.c @@ -386,9 +386,9 @@ int WebPEncode(const WebPConfig* config, WebPPicture* pic) { // Analysis is done, proceed to actual coding. ok = ok && VP8EncStartAlpha(enc); // possibly done in parallel if (!enc->use_tokens_) { - ok = VP8EncLoop(enc); + ok = ok && VP8EncLoop(enc); } else { - ok = VP8EncTokenLoop(enc); + ok = ok && VP8EncTokenLoop(enc); } ok = ok && VP8EncFinishAlpha(enc); #ifdef WEBP_EXPERIMENTAL_FEATURES From 5568dbcfe63cd03133ce3b9c449b5acd0f1f3847 Mon Sep 17 00:00:00 2001 From: James Zern Date: Fri, 5 Apr 2013 14:51:02 -0700 Subject: [PATCH 05/57] update gitignore *.a, new examples and new automake-1.12 file (ar-lib) Change-Id: I28d7bc59a2977a7c5959940936e3d13a71dd149c (cherry picked from commit 3a15125d2f1916cd42c2f438e6f60d876b63235b) --- .gitignore | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 17225768..c7b01341 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,9 @@ *.l[ao] -*.o +*.[ao] .deps .libs /aclocal.m4 +/ar-lib /autom4te.cache /compile /config.* @@ -16,7 +17,9 @@ /stamp-h1 Makefile Makefile.in -examples/[cd]webp +examples/[cdv]webp +examples/gif2webp +examples/webpmux /output /doc/output *.idb From b9d747351a3691fcfa3d37947cb1523f147f1fb9 Mon Sep 17 00:00:00 2001 From: James Zern Date: Fri, 5 Apr 2013 14:54:05 -0700 Subject: [PATCH 06/57] Makefile.vc: drop /FD flag breaks under wine; from MSDN: /FD is only used by the development environment, and it should not be used from the command line or a build script. Change-Id: I180c9813e721b163cc645b9b7f14fe36556019d3 (cherry picked from commit c61baf0c10d566ebe92b9a9402f978f950ab9b89) --- Makefile.vc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.vc b/Makefile.vc index f490acc6..d4be6c79 100644 --- a/Makefile.vc +++ b/Makefile.vc @@ -27,7 +27,7 @@ PLATFORM_LDFLAGS = /SAFESEH MT = mt.exe CCNODBG = cl.exe /nologo /O2 /DNDEBUG CCDEBUG = cl.exe /nologo /Od /Gm /Zi /D_DEBUG /RTC1 -CFLAGS = /Isrc /nologo /W3 /EHsc /FD /c /GS +CFLAGS = /Isrc /nologo /W3 /EHsc /c /GS CFLAGS = $(CFLAGS) /DWIN32 /D_CRT_SECURE_NO_WARNINGS /DWIN32_LEAN_AND_MEAN CFLAGS = $(CFLAGS) /DHAVE_WINCODEC_H /DWEBP_USE_THREAD LDFLAGS = /LARGEADDRESSAWARE /MANIFEST /NXCOMPAT /DYNAMICBASE From 8191decae99673a9669454fdf6574a6164f25c55 Mon Sep 17 00:00:00 2001 From: James Zern Date: Fri, 5 Apr 2013 18:45:53 -0700 Subject: [PATCH 07/57] Makefile.vc: flags cleanup - drop some unnecessary link flags - use lib.exe directly for creating libraries - factorize /nologo and use it consistently Change-Id: Ie76119bc051e9bc53e4d6bba1a0a3f124f9062fc (cherry picked from commit 52967498b3ef7fb8c0bdc5cb5934e46edaa069f2) --- Makefile.vc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Makefile.vc b/Makefile.vc index d4be6c79..f1fd9f7e 100644 --- a/Makefile.vc +++ b/Makefile.vc @@ -24,18 +24,18 @@ PLATFORM_LDFLAGS = /SAFESEH ############################################################# ## Nothing more to do below this line! -MT = mt.exe -CCNODBG = cl.exe /nologo /O2 /DNDEBUG -CCDEBUG = cl.exe /nologo /Od /Gm /Zi /D_DEBUG /RTC1 -CFLAGS = /Isrc /nologo /W3 /EHsc /c /GS +NOLOGO = /nologo +CCNODBG = cl.exe $(NOLOGO) /O2 /DNDEBUG +CCDEBUG = cl.exe $(NOLOGO) /Od /Gm /Zi /D_DEBUG /RTC1 +CFLAGS = /Isrc $(NOLOGO) /W3 /EHsc /c /GS CFLAGS = $(CFLAGS) /DWIN32 /D_CRT_SECURE_NO_WARNINGS /DWIN32_LEAN_AND_MEAN CFLAGS = $(CFLAGS) /DHAVE_WINCODEC_H /DWEBP_USE_THREAD LDFLAGS = /LARGEADDRESSAWARE /MANIFEST /NXCOMPAT /DYNAMICBASE LDFLAGS = $(LDFLAGS) $(PLATFORM_LDFLAGS) -LNKDLL = link.exe /DLL -LNKLIB = link.exe /lib -LNKEXE = link.exe -LFLAGS = /nologo /machine:$(ARCH) +LNKDLL = link.exe /DLL $(NOLOGO) +LNKEXE = link.exe $(NOLOGO) +LNKLIB = lib.exe $(NOLOGO) +MT = mt.exe $(NOLOGO) CFGSET = FALSE !IF "$(OBJDIR)" == "" @@ -278,7 +278,7 @@ clean:: @-erase /s $(DIROBJ)\$(DLLC) $(DIROBJ)\$(DLLINC) 2> NUL !ELSE $(LIBWEBPDECODER) $(LIBWEBP) $(LIBWEBPMUX) $(LIBWEBPDEMUX): - $(LNKLIB) /out:$@ $(LFLAGS) $** + $(LNKLIB) /out:$@ $** -xcopy $(DIROBJ)\*.pdb $(DIRLIB) /y !ENDIF From 5051245f3a9c0ddf613167017bfebbf655d6c7ca Mon Sep 17 00:00:00 2001 From: James Zern Date: Fri, 5 Apr 2013 19:21:01 -0700 Subject: [PATCH 08/57] Makefile.vc: have 'all' target build everything default is still the core examples as makefile.unix Change-Id: Ica3fe6123f4359aefa130b39d2b0739b65e34c0b (cherry picked from commit 69d0f92658ae20017bf23240eaa06523a5f189bb) --- Makefile.vc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile.vc b/Makefile.vc index f1fd9f7e..114d073b 100644 --- a/Makefile.vc +++ b/Makefile.vc @@ -130,7 +130,8 @@ CFGSET = TRUE !MESSAGE - clean - perform a clean for CFG !MESSAGE - experimental - build CFG with experimental !MESSAGE . features enabled. -!MESSAGE - (empty) or all - build all targets for CFG +!MESSAGE - (empty) - build libwebp-based targets for CFG +!MESSAGE - all - build (de)mux-based targets for CFG !MESSAGE !MESSAGE RTLIBCFG controls the runtime library linkage - 'static' or 'dynamic'. !MESSAGE OBJDIR is the path where you like to build (obj, bins, etc.), @@ -238,8 +239,10 @@ LIBWEBPDEMUX_OBJS = $(DEMUX_OBJS) $(LIBWEBPDEMUX_OBJS) OUT_LIBS = $(LIBWEBPDECODER) $(LIBWEBP) OUT_EXAMPLES = $(DIRBIN)\cwebp.exe $(DIRBIN)\dwebp.exe +EXTRA_EXAMPLES = $(DIRBIN)\vwebp.exe $(DIRBIN)\webpmux.exe -all: $(OUT_LIBS) $(OUT_EXAMPLES) +ex: $(OUT_LIBS) $(OUT_EXAMPLES) +all: ex $(EXTRA_EXAMPLES) $(DIRBIN)\cwebp.exe: $(DIROBJ)\examples\cwebp.obj $(EX_FORMAT_DEC_OBJS) $(DIRBIN)\dwebp.exe: $(DIROBJ)\examples\dwebp.obj $(DIRBIN)\vwebp.exe: $(DIROBJ)\examples\vwebp.obj @@ -247,6 +250,7 @@ $(DIRBIN)\vwebp.exe: $(EX_UTIL_OBJS) $(LIBWEBPDEMUX) $(LIBWEBP) $(DIRBIN)\webpmux.exe: $(DIROBJ)\examples\webpmux.obj $(LIBWEBPMUX) $(DIRBIN)\webpmux.exe: $(EX_UTIL_OBJS) $(LIBWEBP) $(OUT_EXAMPLES): $(EX_UTIL_OBJS) $(LIBWEBP) +$(EX_UTIL_OBJS) $(EX_FORMAT_DEC_OBJS): $(OUTPUT_DIRS) experimental: $(MAKE) /f Makefile.vc \ From c22877f70f822148d4fea9f11079d50f19c71144 Mon Sep 17 00:00:00 2001 From: Urvang Joshi Date: Fri, 5 Apr 2013 14:01:07 -0700 Subject: [PATCH 09/57] Add incremental support for extended format files This applies to images with optional chunks (e.g. images with ALPH chunk, ICCP chunk etc). Before this, the incremental decoding used to work like non-incremental decoding for such files, that is, no rows were decoded until all data was available. The change is in 2 parts: - During optional chunk parsing, don't wait for the full VP8/VP8L chunk. - Remap 'alpha_data' pointer whenever a new buffer is allocated/used in WebPIAppend() and WebPIUpdate(). Change-Id: I6cfd6ca1f334b9c6610fcbf662cd85fa494f2a91 (cherry picked from commit ead4d478595d0c7b112e42f6766d00b16a39e294) --- NEWS | 3 +++ src/dec/alpha.c | 2 ++ src/dec/idec.c | 36 ++++++++++++++++++++++++++++++------ src/dec/vp8i.h | 1 + src/dec/webp.c | 12 +++++++++--- 5 files changed, 45 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index f61fad26..3f956e00 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +- Next version: + * Add incremental decoding support for images containing ALPH and ICCP chunks. + - 3/20/13: version 0.3.0 This is a binary compatible release. * WebPINewRGB/WebPINewYUVA accept being passed a NULL output buffer diff --git a/src/dec/alpha.c b/src/dec/alpha.c index 5c9cdd6a..630e367f 100644 --- a/src/dec/alpha.c +++ b/src/dec/alpha.c @@ -113,11 +113,13 @@ const uint8_t* VP8DecompressAlphaRows(VP8Decoder* const dec, if (row == 0) { // Decode everything during the first call. + assert(!dec->is_alpha_decoded_); if (!DecodeAlpha(dec->alpha_data_, (size_t)dec->alpha_data_size_, dec->pic_hdr_.width_, dec->pic_hdr_.height_, stride, dec->alpha_plane_)) { return NULL; // Error. } + dec->is_alpha_decoded_ = 1; } // Return a pointer to the current decoded row. diff --git a/src/dec/idec.c b/src/dec/idec.c index 17810c83..cbf9638e 100644 --- a/src/dec/idec.c +++ b/src/dec/idec.c @@ -97,6 +97,23 @@ static WEBP_INLINE size_t MemDataSize(const MemBuffer* mem) { return (mem->end_ - mem->start_); } +// Check if we need to preserve the compressed alpha data, as it may not have +// been decoded yet. +static int NeedCompressedAlpha(const WebPIDecoder* const idec) { + if (idec->state_ == STATE_PRE_VP8) { + // We haven't parsed the headers yet, so we don't know whether the image is + // lossy or lossless. This also means that we haven't parsed the ALPH chunk. + return 0; + } + if (idec->is_lossless_) { + return 0; // ALPH chunk is not present for lossless images. + } else { + const VP8Decoder* const dec = (VP8Decoder*)idec->dec_; + assert(dec != NULL); // Must be true as idec->state_ != STATE_PRE_VP8. + return (dec->alpha_data_ != NULL) && !dec->is_alpha_decoded_; + } +} + static void DoRemap(WebPIDecoder* const idec, ptrdiff_t offset) { MemBuffer* const mem = &idec->mem_; const uint8_t* const new_base = mem->buf_ + mem->start_; @@ -122,6 +139,7 @@ static void DoRemap(WebPIDecoder* const idec, ptrdiff_t offset) { } assert(last_part >= 0); dec->parts_[last_part].buf_end_ = mem->buf_ + mem->end_; + if (NeedCompressedAlpha(idec)) dec->alpha_data_ += offset; } else { // Resize lossless bitreader VP8LDecoder* const dec = (VP8LDecoder*)idec->dec_; VP8LBitReaderSetBuffer(&dec->br_, new_base, MemDataSize(mem)); @@ -133,8 +151,12 @@ static void DoRemap(WebPIDecoder* const idec, ptrdiff_t offset) { // size if required and also updates VP8BitReader's if new memory is allocated. static int AppendToMemBuffer(WebPIDecoder* const idec, const uint8_t* const data, size_t data_size) { + VP8Decoder* const dec = (VP8Decoder*)idec->dec_; MemBuffer* const mem = &idec->mem_; - const uint8_t* const old_base = mem->buf_ + mem->start_; + const int need_compressed_alpha = NeedCompressedAlpha(idec); + const uint8_t* const old_start = mem->buf_ + mem->start_; + const uint8_t* const old_base = + need_compressed_alpha ? dec->alpha_data_ : old_start; assert(mem->mode_ == MEM_MODE_APPEND); if (data_size > MAX_CHUNK_PAYLOAD) { // security safeguard: trying to allocate more than what the format @@ -143,7 +165,8 @@ static int AppendToMemBuffer(WebPIDecoder* const idec, } if (mem->end_ + data_size > mem->buf_size_) { // Need some free memory - const size_t current_size = MemDataSize(mem); + const size_t new_mem_start = old_start - old_base; + const size_t current_size = MemDataSize(mem) + new_mem_start; const uint64_t new_size = (uint64_t)current_size + data_size; const uint64_t extra_size = (new_size + CHUNK_SIZE - 1) & ~(CHUNK_SIZE - 1); uint8_t* const new_buf = @@ -153,7 +176,7 @@ static int AppendToMemBuffer(WebPIDecoder* const idec, free(mem->buf_); mem->buf_ = new_buf; mem->buf_size_ = (size_t)extra_size; - mem->start_ = 0; + mem->start_ = new_mem_start; mem->end_ = current_size; } @@ -161,14 +184,15 @@ static int AppendToMemBuffer(WebPIDecoder* const idec, mem->end_ += data_size; assert(mem->end_ <= mem->buf_size_); - DoRemap(idec, mem->buf_ + mem->start_ - old_base); + DoRemap(idec, mem->buf_ + mem->start_ - old_start); return 1; } static int RemapMemBuffer(WebPIDecoder* const idec, const uint8_t* const data, size_t data_size) { MemBuffer* const mem = &idec->mem_; - const uint8_t* const old_base = mem->buf_ + mem->start_; + const uint8_t* const old_buf = mem->buf_; + const uint8_t* const old_start = old_buf + mem->start_; assert(mem->mode_ == MEM_MODE_MAP); if (data_size < mem->buf_size_) return 0; // can't remap to a shorter buffer! @@ -176,7 +200,7 @@ static int RemapMemBuffer(WebPIDecoder* const idec, mem->buf_ = (uint8_t*)data; mem->end_ = mem->buf_size_ = data_size; - DoRemap(idec, mem->buf_ + mem->start_ - old_base); + DoRemap(idec, mem->buf_ + mem->start_ - old_start); return 1; } diff --git a/src/dec/vp8i.h b/src/dec/vp8i.h index 1aa92385..4f1a91c8 100644 --- a/src/dec/vp8i.h +++ b/src/dec/vp8i.h @@ -276,6 +276,7 @@ struct VP8Decoder { // extensions const uint8_t* alpha_data_; // compressed alpha data (if present) size_t alpha_data_size_; + int is_alpha_decoded_; // true if alpha_data_ is decoded in alpha_plane_ uint8_t* alpha_plane_; // output. Persistent, contains the whole data. int layer_colorspace_; diff --git a/src/dec/webp.c b/src/dec/webp.c index 39d90188..aa3a703f 100644 --- a/src/dec/webp.c +++ b/src/dec/webp.c @@ -192,6 +192,15 @@ static VP8StatusCode ParseOptionalChunks(const uint8_t** const data, return VP8_STATUS_BITSTREAM_ERROR; // Not a valid chunk size. } + // Start of a (possibly incomplete) VP8/VP8L chunk implies that we have + // parsed all the optional chunks. + // Note: This check must occur before the check 'buf_size < disk_chunk_size' + // below to allow incomplete VP8/VP8L chunks. + if (!memcmp(buf, "VP8 ", TAG_SIZE) || + !memcmp(buf, "VP8L", TAG_SIZE)) { + return VP8_STATUS_OK; + } + if (buf_size < disk_chunk_size) { // Insufficient data. return VP8_STATUS_NOT_ENOUGH_DATA; } @@ -199,9 +208,6 @@ static VP8StatusCode ParseOptionalChunks(const uint8_t** const data, if (!memcmp(buf, "ALPH", TAG_SIZE)) { // A valid ALPH header. *alpha_data = buf + CHUNK_HEADER_SIZE; *alpha_size = chunk_size; - } else if (!memcmp(buf, "VP8 ", TAG_SIZE) || - !memcmp(buf, "VP8L", TAG_SIZE)) { // A valid VP8/VP8L header. - return VP8_STATUS_OK; // Found. } // We have a full and valid chunk; skip it. From 31bea324080b6547ccb83a484b8fd627dcf98e3a Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Tue, 9 Apr 2013 17:52:37 -0700 Subject: [PATCH 10/57] add precision about dynamic output reallocation with IDecoder The output surface CAN be changed inbetween calls to WebPIUpdate() or WebPIAppend(), but with precautions. Change-Id: I899afbd95738a6a8e0e7000f8daef3e74c99ddd8 (cherry picked from commit ff885bfe1f6e419bec762b28879f7039318eaf4e) --- src/webp/decode.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/webp/decode.h b/src/webp/decode.h index 181eb186..f8a852ca 100644 --- a/src/webp/decode.h +++ b/src/webp/decode.h @@ -262,6 +262,12 @@ enum VP8StatusCode { // is used (with MODE_RGB). Otherwise, an internal reference to 'output_buffer' // is kept, which means that the lifespan of 'output_buffer' must be larger than // that of the returned WebPIDecoder object. +// The supplied 'output_buffer' content MUST NOT be changed between calls to +// WebPIAppend() or WebPIUpdate() unless 'output_buffer.is_external_memory' is +// set to 1. In such a case, it is allowed to modify the pointers, size and +// stride of output_buffer.u.RGBA or output_buffer.u.YUVA, provided they remain +// within valid bounds. +// All other fields of WebPDecBuffer MUST remain constant between calls. // Returns NULL if the allocation failed. WEBP_EXTERN(WebPIDecoder*) WebPINewDecoder(WebPDecBuffer* output_buffer); From 7a650c6ad65cc77421aaf3d9aadfdfd583e54b8d Mon Sep 17 00:00:00 2001 From: James Zern Date: Sat, 13 Apr 2013 10:33:41 -0700 Subject: [PATCH 11/57] prevent signed int overflow in left shift ops force unsigned when shifting by 24. Change-Id: Ie229d252e2e4078107cd705b09397e686a321ffd (cherry picked from commit f4f90880a8de432cdead8baed1e2b04e1afb6128) --- examples/cwebp.c | 6 +++--- src/enc/picture.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/cwebp.c b/examples/cwebp.c index 300d2c4f..0aee03ea 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -109,15 +109,15 @@ typedef enum { static InputFileFormat GetImageType(FILE* in_file) { InputFileFormat format = UNSUPPORTED; - unsigned int magic; - unsigned char buf[4]; + uint32_t magic; + uint8_t buf[4]; if ((fread(&buf[0], 4, 1, in_file) != 1) || (fseek(in_file, 0, SEEK_SET) != 0)) { return format; } - magic = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; + magic = ((uint32_t)buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; if (magic == 0x89504E47U) { format = PNG_; } else if (magic >= 0xFFD8FF00U && magic <= 0xFFD8FFFFU) { diff --git a/src/enc/picture.c b/src/enc/picture.c index ce8f59ad..e9f78e1e 100644 --- a/src/enc/picture.c +++ b/src/enc/picture.c @@ -710,7 +710,7 @@ static int Import(WebPPicture* const picture, for (y = 0; y < height; ++y) { for (x = 0; x < width; ++x) { const int offset = step * x + y * rgb_stride; - const uint32_t argb = (a_ptr[offset] << 24) | + const uint32_t argb = ((uint32_t)a_ptr[offset] << 24) | (r_ptr[offset] << 16) | (g_ptr[offset] << 8) | (b_ptr[offset]); @@ -810,7 +810,7 @@ int WebPPictureYUVAToARGB(WebPPicture* picture) { const uint8_t* const src = picture->a + y * picture->a_stride; int x; for (x = 0; x < width; ++x) { - argb_dst[x] = (argb_dst[x] & 0x00ffffffu) | (src[x] << 24); + argb_dst[x] = (argb_dst[x] & 0x00ffffffu) | ((uint32_t)src[x] << 24); } } } From c7b92184dfbd391b9e302a3722a32b41823317d9 Mon Sep 17 00:00:00 2001 From: James Zern Date: Sat, 13 Apr 2013 10:38:09 -0700 Subject: [PATCH 12/57] don't forward declare enums doing so is not part of ISO C; removes some pedantic warnings Change-Id: I739ad8c5cacc133e2546e9f45c0db9d92fb93d7e (cherry picked from commit 96e948d7b034d916e959b68e7151405f8a309eaa) --- src/webp/decode.h | 16 ++++++++-------- src/webp/demux.h | 16 ++++++++-------- src/webp/encode.h | 28 ++++++++++++++-------------- src/webp/mux.h | 16 ++++++++-------- src/webp/mux_types.h | 18 +++++++++--------- 5 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/webp/decode.h b/src/webp/decode.h index f8a852ca..fc2a83ab 100644 --- a/src/webp/decode.h +++ b/src/webp/decode.h @@ -20,13 +20,13 @@ extern "C" { #define WEBP_DECODER_ABI_VERSION 0x0201 // MAJOR(8b) + MINOR(8b) +// Note: forward declaring enumerations is not allowed in (strict) C and C++, +// the types are left here for reference. +// typedef enum VP8StatusCode VP8StatusCode; +// typedef enum WEBP_CSP_MODE WEBP_CSP_MODE; typedef struct WebPRGBABuffer WebPRGBABuffer; typedef struct WebPYUVABuffer WebPYUVABuffer; typedef struct WebPDecBuffer WebPDecBuffer; -#if !(defined(__cplusplus) || defined(c_plusplus)) -typedef enum VP8StatusCode VP8StatusCode; -typedef enum WEBP_CSP_MODE WEBP_CSP_MODE; -#endif typedef struct WebPIDecoder WebPIDecoder; typedef struct WebPBitstreamFeatures WebPBitstreamFeatures; typedef struct WebPDecoderOptions WebPDecoderOptions; @@ -138,7 +138,7 @@ WEBP_EXTERN(uint8_t*) WebPDecodeYUVInto( // RGBA-4444: [b3 b2 b1 b0 a3 a2 a1 a0], [r3 r2 r1 r0 g3 g2 g1 g0], ... // RGB-565: [g2 g1 g0 b4 b3 b2 b1 b0], [r4 r3 r2 r1 r0 g5 g4 g3], ... -enum WEBP_CSP_MODE { +typedef enum WEBP_CSP_MODE { MODE_RGB = 0, MODE_RGBA = 1, MODE_BGR = 2, MODE_BGRA = 3, MODE_ARGB = 4, MODE_RGBA_4444 = 5, @@ -151,7 +151,7 @@ enum WEBP_CSP_MODE { // YUV modes must come after RGB ones. MODE_YUV = 11, MODE_YUVA = 12, // yuv 4:2:0 MODE_LAST = 13 -}; +} WEBP_CSP_MODE; // Some useful macros: static WEBP_INLINE int WebPIsPremultipliedMode(WEBP_CSP_MODE mode) { @@ -220,7 +220,7 @@ WEBP_EXTERN(void) WebPFreeDecBuffer(WebPDecBuffer* buffer); //------------------------------------------------------------------------------ // Enumeration of the status codes -enum VP8StatusCode { +typedef enum VP8StatusCode { VP8_STATUS_OK = 0, VP8_STATUS_OUT_OF_MEMORY, VP8_STATUS_INVALID_PARAM, @@ -229,7 +229,7 @@ enum VP8StatusCode { VP8_STATUS_SUSPENDED, VP8_STATUS_USER_ABORT, VP8_STATUS_NOT_ENOUGH_DATA -}; +} VP8StatusCode; //------------------------------------------------------------------------------ // Incremental decoding diff --git a/src/webp/demux.h b/src/webp/demux.h index cfb4fdfe..2006b94f 100644 --- a/src/webp/demux.h +++ b/src/webp/demux.h @@ -53,11 +53,11 @@ extern "C" { #define WEBP_DEMUX_ABI_VERSION 0x0100 // MAJOR(8b) + MINOR(8b) +// Note: forward declaring enumerations is not allowed in (strict) C and C++, +// the types are left here for reference. +// typedef enum WebPDemuxState WebPDemuxState; +// typedef enum WebPFormatFeature WebPFormatFeature; typedef struct WebPDemuxer WebPDemuxer; -#if !(defined(__cplusplus) || defined(c_plusplus)) -typedef enum WebPDemuxState WebPDemuxState; -typedef enum WebPFormatFeature WebPFormatFeature; -#endif typedef struct WebPIterator WebPIterator; typedef struct WebPChunkIterator WebPChunkIterator; @@ -70,11 +70,11 @@ WEBP_EXTERN(int) WebPGetDemuxVersion(void); //------------------------------------------------------------------------------ // Life of a Demux object -enum WebPDemuxState { +typedef enum WebPDemuxState { WEBP_DEMUX_PARSING_HEADER, // Not enough data to parse full header. WEBP_DEMUX_PARSED_HEADER, // Header parsing complete, data may be available. WEBP_DEMUX_DONE // Entire file has been parsed. -}; +} WebPDemuxState; // Internal, version-checked, entry point WEBP_EXTERN(WebPDemuxer*) WebPDemuxInternal( @@ -100,7 +100,7 @@ WEBP_EXTERN(void) WebPDemuxDelete(WebPDemuxer* dmux); //------------------------------------------------------------------------------ // Data/information extraction. -enum WebPFormatFeature { +typedef enum WebPFormatFeature { WEBP_FF_FORMAT_FLAGS, // Extended format flags present in the 'VP8X' chunk. WEBP_FF_CANVAS_WIDTH, WEBP_FF_CANVAS_HEIGHT, @@ -110,7 +110,7 @@ enum WebPFormatFeature { // In case of a partial demux, this is the number of // frames seen so far, with the last frame possibly // being partial. -}; +} WebPFormatFeature; // Get the 'feature' value from the 'dmux'. // NOTE: values are only valid if WebPDemux() was used or WebPDemuxPartial() diff --git a/src/webp/encode.h b/src/webp/encode.h index ad20fa1d..d635fcf0 100644 --- a/src/webp/encode.h +++ b/src/webp/encode.h @@ -20,12 +20,12 @@ extern "C" { #define WEBP_ENCODER_ABI_VERSION 0x0201 // MAJOR(8b) + MINOR(8b) -#if !(defined(__cplusplus) || defined(c_plusplus)) -typedef enum WebPImageHint WebPImageHint; -typedef enum WebPEncCSP WebPEncCSP; -typedef enum WebPPreset WebPPreset; -typedef enum WebPEncodingError WebPEncodingError; -#endif +// Note: forward declaring enumerations is not allowed in (strict) C and C++, +// the types are left here for reference. +// typedef enum WebPImageHint WebPImageHint; +// typedef enum WebPEncCSP WebPEncCSP; +// typedef enum WebPPreset WebPPreset; +// typedef enum WebPEncodingError WebPEncodingError; typedef struct WebPConfig WebPConfig; typedef struct WebPPicture WebPPicture; // main structure for I/O typedef struct WebPAuxStats WebPAuxStats; @@ -77,13 +77,13 @@ WEBP_EXTERN(size_t) WebPEncodeLosslessBGRA(const uint8_t* bgra, // Coding parameters // Image characteristics hint for the underlying encoder. -enum WebPImageHint { +typedef enum WebPImageHint { WEBP_HINT_DEFAULT = 0, // default preset. WEBP_HINT_PICTURE, // digital picture, like portrait, inner shot WEBP_HINT_PHOTO, // outdoor photograph, with natural lighting WEBP_HINT_GRAPH, // Discrete tone image (graph, map-tile etc). WEBP_HINT_LAST -}; +} WebPImageHint; // Compression parameters. struct WebPConfig { @@ -133,14 +133,14 @@ struct WebPConfig { // Enumerate some predefined settings for WebPConfig, depending on the type // of source picture. These presets are used when calling WebPConfigPreset(). -enum WebPPreset { +typedef enum WebPPreset { WEBP_PRESET_DEFAULT = 0, // default preset. WEBP_PRESET_PICTURE, // digital picture, like portrait, inner shot WEBP_PRESET_PHOTO, // outdoor photograph, with natural lighting WEBP_PRESET_DRAWING, // hand or line drawing, with high-contrast details WEBP_PRESET_ICON, // small-sized colorful images WEBP_PRESET_TEXT // text-like -}; +} WebPPreset; // Internal, version-checked, entry point WEBP_EXTERN(int) WebPConfigInitInternal(WebPConfig*, WebPPreset, float, int); @@ -230,7 +230,7 @@ WEBP_EXTERN(int) WebPMemoryWrite(const uint8_t* data, size_t data_size, typedef int (*WebPProgressHook)(int percent, const WebPPicture* picture); // Color spaces. -enum WebPEncCSP { +typedef enum WebPEncCSP { // chroma sampling WEBP_YUV420 = 0, // 4:2:0 WEBP_YUV422 = 1, // 4:2:2 @@ -243,10 +243,10 @@ enum WebPEncCSP { WEBP_YUV444A = 6, WEBP_YUV400A = 7, // grayscale + alpha WEBP_CSP_ALPHA_BIT = 4 // bit that is set if alpha is present -}; +} WebPEncCSP; // Encoding error conditions. -enum WebPEncodingError { +typedef enum WebPEncodingError { VP8_ENC_OK = 0, VP8_ENC_ERROR_OUT_OF_MEMORY, // memory error allocating objects VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY, // memory error while flushing bits @@ -259,7 +259,7 @@ enum WebPEncodingError { VP8_ENC_ERROR_FILE_TOO_BIG, // file is bigger than 4G VP8_ENC_ERROR_USER_ABORT, // abort request by user VP8_ENC_ERROR_LAST // list terminator. always last. -}; +} WebPEncodingError; // maximum width/height allowed (inclusive), in pixels #define WEBP_MAX_DIMENSION 16383 diff --git a/src/webp/mux.h b/src/webp/mux.h index 85a89227..f869a2dc 100644 --- a/src/webp/mux.h +++ b/src/webp/mux.h @@ -53,26 +53,26 @@ extern "C" { #define WEBP_MUX_ABI_VERSION 0x0100 // MAJOR(8b) + MINOR(8b) +// Note: forward declaring enumerations is not allowed in (strict) C and C++, +// the types are left here for reference. +// typedef enum WebPMuxError WebPMuxError; +// typedef enum WebPChunkId WebPChunkId; typedef struct WebPMux WebPMux; // main opaque object. -#if !(defined(__cplusplus) || defined(c_plusplus)) -typedef enum WebPMuxError WebPMuxError; -typedef enum WebPChunkId WebPChunkId; -#endif typedef struct WebPMuxFrameInfo WebPMuxFrameInfo; typedef struct WebPMuxAnimParams WebPMuxAnimParams; // Error codes -enum WebPMuxError { +typedef enum WebPMuxError { WEBP_MUX_OK = 1, WEBP_MUX_NOT_FOUND = 0, WEBP_MUX_INVALID_ARGUMENT = -1, WEBP_MUX_BAD_DATA = -2, WEBP_MUX_MEMORY_ERROR = -3, WEBP_MUX_NOT_ENOUGH_DATA = -4 -}; +} WebPMuxError; // IDs for different types of chunks. -enum WebPChunkId { +typedef enum WebPChunkId { WEBP_CHUNK_VP8X, // VP8X WEBP_CHUNK_ICCP, // ICCP WEBP_CHUNK_ANIM, // ANIM @@ -84,7 +84,7 @@ enum WebPChunkId { WEBP_CHUNK_XMP, // XMP WEBP_CHUNK_UNKNOWN, // Other chunks. WEBP_CHUNK_NIL -}; +} WebPChunkId; //------------------------------------------------------------------------------ diff --git a/src/webp/mux_types.h b/src/webp/mux_types.h index 4006a540..7bad0004 100644 --- a/src/webp/mux_types.h +++ b/src/webp/mux_types.h @@ -20,31 +20,31 @@ extern "C" { #endif -#if !(defined(__cplusplus) || defined(c_plusplus)) -typedef enum WebPFeatureFlags WebPFeatureFlags; -typedef enum WebPMuxAnimDispose WebPMuxAnimDispose; -#endif +// Note: forward declaring enumerations is not allowed in (strict) C and C++, +// the types are left here for reference. +// typedef enum WebPFeatureFlags WebPFeatureFlags; +// typedef enum WebPMuxAnimDispose WebPMuxAnimDispose; +typedef struct WebPData WebPData; // VP8X Feature Flags. -enum WebPFeatureFlags { +typedef enum WebPFeatureFlags { FRAGMENTS_FLAG = 0x00000001, ANIMATION_FLAG = 0x00000002, XMP_FLAG = 0x00000004, EXIF_FLAG = 0x00000008, ALPHA_FLAG = 0x00000010, ICCP_FLAG = 0x00000020 -}; +} WebPFeatureFlags; // Dispose method (animation only). Indicates how the area used by the current // frame is to be treated before rendering the next frame on the canvas. -enum WebPMuxAnimDispose { +typedef enum WebPMuxAnimDispose { WEBP_MUX_DISPOSE_NONE, // Do not dispose. WEBP_MUX_DISPOSE_BACKGROUND // Dispose to background color. -}; +} WebPMuxAnimDispose; // Data type used to describe 'raw' data, e.g., chunk data // (ICC profile, metadata) and WebP compressed image data. -typedef struct WebPData WebPData; struct WebPData { const uint8_t* bytes; size_t size; From 11edf5e24bf6151c28ab7b0fe73b4c68bdc916ef Mon Sep 17 00:00:00 2001 From: Urvang Joshi Date: Tue, 16 Apr 2013 14:13:45 -0700 Subject: [PATCH 13/57] Demux: Fix a potential memleak Change-Id: Ic0dcac010da088b791c130be4abacdd8c31e92cf (cherry picked from commit 94328d6457e427da1e0dcf11210f9936fe5c4aeb) --- src/demux/demux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/demux/demux.c b/src/demux/demux.c index 5d4dcf54..dd75904f 100644 --- a/src/demux/demux.c +++ b/src/demux/demux.c @@ -317,6 +317,7 @@ static ParseStatus ParseAnimationFrame( frame->duration_ = ReadLE24s(mem); frame->dispose_method_ = (WebPMuxAnimDispose)(ReadByte(mem) & 1); if (frame->width_ * (uint64_t)frame->height_ >= MAX_IMAGE_AREA) { + free(frame); return PARSE_ERROR; } From d8e53211447d5ffeefea00ee1aaf2ebb57dffac5 Mon Sep 17 00:00:00 2001 From: Christian Duvivier Date: Thu, 18 Apr 2013 11:28:03 +0200 Subject: [PATCH 14/57] Add missing name to AUTHORS Change-Id: I00092e5bb676b48abc05b94080b589b48c911c82 (cherry picked from commit 46089b207daf3d0bf30ffa7f04dc7b67edade87f) --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index df11a6ed..9ef75042 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,4 +1,5 @@ Contributors: +- Christian Duvivier (cduvivier at google dot com) - James Zern (jzern at google dot com) - Jan Engelhardt (jengelh at medozas dot de) - Johann (johann dot koenig at duck dot com) From 7f25ff99fd89ac6d2d1404145bdc8c4b7e7decb6 Mon Sep 17 00:00:00 2001 From: Urvang Joshi Date: Thu, 18 Apr 2013 14:19:25 -0700 Subject: [PATCH 15/57] gif2webp: Fix ICC and XMP support Change-Id: Ib5aafef388bd191610e4cc2f8180f35cd454f1d3 (cherry picked from commit b26e5ad540bea568d9c5d7126918465bea200c70) --- examples/gif2webp.c | 88 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 68 insertions(+), 20 deletions(-) diff --git a/examples/gif2webp.c b/examples/gif2webp.c index db1332dd..c5112b3b 100644 --- a/examples/gif2webp.c +++ b/examples/gif2webp.c @@ -209,6 +209,8 @@ int main(int argc, const char *argv[]) { WebPConfig config; WebPMux* mux = NULL; WebPData webp_data = { NULL, 0 }; + int stored_icc = 0; // Whether we have already stored an ICC profile. + int stored_xmp = 0; memset(&frame, 0, sizeof(frame)); frame.id = WEBP_CHUNK_ANMF; @@ -398,24 +400,70 @@ int main(int argc, const char *argv[]) { if (data[0] != 3 && data[1] != 1) break; // wrong size/marker anim.loop_count = data[2] | (data[3] << 8); if (verbose) printf("Loop count: %d\n", anim.loop_count); - } else if (!memcmp(data + 1, "XMP dataXMP", 11)) { - // Read XMP metadata. - WebPData xmp; - if (DGifGetExtensionNext(gif, &data) == GIF_ERROR) goto End; - if (data == NULL) goto End; - xmp.bytes = (uint8_t*)data; - xmp.size = data[0] + 1; - WebPMuxSetChunk(mux, "XMP ", &xmp, 1); - if (verbose) printf("XMP size: %d\n", (int)xmp.size); - } else if (!memcmp(data + 1, "ICCRGBG1012", 11)) { - // Read ICC profile. - WebPData icc; - if (DGifGetExtensionNext(gif, &data) == GIF_ERROR) goto End; - if (data == NULL) goto End; - icc.bytes = (uint8_t*)data; - icc.size = data[0] + 1; - WebPMuxSetChunk(mux, "ICCP", &icc, 1); - if (verbose) printf("ICC size: %d\n", (int)icc.size); + } else { // An extension containing metadata. + // We only store the first encountered chunk of each type. + const int is_xmp = + !stored_xmp && !memcmp(data + 1, "XMP DataXMP", 11); + const int is_icc = + !stored_icc && !memcmp(data + 1, "ICCRGBG1012", 11); + if (is_xmp || is_icc) { + const char fourccs[2][4] = { "XMP " , "ICCP" }; + const char* const features[2] = { "XMP" , "ICC" }; + WebPData metadata = { NULL, 0 }; + // Construct metadata from sub-blocks. + // Usual case (including ICC profile): In each sub-block, the + // first byte specifies its size in bytes (0 to 255) and the + // rest of the bytes contain the data. + // Special case for XMP data: In each sub-block, the first byte + // is also part of the XMP payload. XMP in GIF also has a 257 + // byte padding data. See the XMP specification for details. + while (1) { + WebPData prev_metadata = metadata; + WebPData subblock; + if (DGifGetExtensionNext(gif, &data) == GIF_ERROR) { + WebPDataClear(&metadata); + goto End; + } + if (data == NULL) break; // Finished. + subblock.size = is_xmp ? data[0] + 1 : data[0]; + assert(subblock.size > 0); + subblock.bytes = is_xmp ? data : data + 1; + metadata.bytes = + (uint8_t*)realloc((void*)metadata.bytes, + prev_metadata.size + subblock.size); + if (metadata.bytes == NULL) { + WebPDataClear(&prev_metadata); + goto End; + } + metadata.size += subblock.size; + memcpy((void*)metadata.bytes + prev_metadata.size, + subblock.bytes, subblock.size); + } + if (is_xmp) { + // XMP padding data is 0x01, 0xff, 0xfe ... 0x01, 0x00. + const int xmp_pading_size = 257; + if (metadata.size > xmp_pading_size) { + metadata.size -= xmp_pading_size; + } + } + + // Add metadata chunk. + err = WebPMuxSetChunk(mux, fourccs[is_icc], &metadata, 1); + if (verbose) { + printf("%s size: %d\n", features[is_icc], (int)metadata.size); + } + WebPDataClear(&metadata); + if (err != WEBP_MUX_OK) { + fprintf(stderr, "ERROR (%s): Could not set %s chunk.\n", + ErrorString(err), features[is_icc]); + goto End; + } + if (is_icc) { + stored_icc = 1; + } else if (is_xmp) { + stored_xmp = 1; + } + } } break; } @@ -423,9 +471,9 @@ int main(int argc, const char *argv[]) { break; // skip } } - do { + while (data != NULL) { if (DGifGetExtensionNext(gif, &data) == GIF_ERROR) goto End; - } while (data != NULL); + } break; } case TERMINATE_RECORD_TYPE: { From 980e7ae951156835be25d668eb1879434789d15f Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Mon, 1 Apr 2013 23:10:35 +0000 Subject: [PATCH 16/57] Remove the gcc compilation comments They went out of sync some time ago, and are no longer really required since we have them buildable from makefile.unix Change-Id: Ica2dcf5c55f44365598f832f55204d123d7aa601 (cherry picked from commit a4e1cdbbe80af7e4a95ccb5131df6e71d138753b) --- examples/dwebp.c | 4 +--- examples/gif2webp.c | 9 --------- examples/vwebp.c | 8 +------- examples/webpmux.c | 3 --- 4 files changed, 2 insertions(+), 22 deletions(-) diff --git a/examples/dwebp.c b/examples/dwebp.c index a3dc615e..59896651 100644 --- a/examples/dwebp.c +++ b/examples/dwebp.c @@ -5,9 +5,7 @@ // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // ----------------------------------------------------------------------------- // -// Command-line tool for decoding a WebP image -// -// Compile with: gcc -o dwebp dwebp.c -lwebpdecode +// Command-line tool for decoding a WebP image. // // Author: Skal (pascal.massimino@gmail.com) diff --git a/examples/gif2webp.c b/examples/gif2webp.c index c5112b3b..4ae7fdde 100644 --- a/examples/gif2webp.c +++ b/examples/gif2webp.c @@ -7,15 +7,6 @@ // // simple tool to convert animated GIFs to WebP // -// Getting the prerequisites: -// Debian-like linux: -// sudo apt-get install libgif-dev -// MacPorts -// sudo port install giflib -// -// Compiling: -// gcc -o gif2webp gif2webp.c -O3 -lwebpmux -lwebp -lgif -lpthread -lm -// // Authors: Skal (pascal.massimino@gmail.com) // Urvang (urvang@google.com) diff --git a/examples/vwebp.c b/examples/vwebp.c index 8fe49acd..22f14b23 100644 --- a/examples/vwebp.c +++ b/examples/vwebp.c @@ -5,13 +5,7 @@ // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ // ----------------------------------------------------------------------------- // -// Simple WebP file viewer. -// -// Compiling on linux: -// sudo apt-get install freeglut3-dev mesa-common-dev -// gcc -o vwebp vwebp.c -O3 -lwebp -lwebpmux -lglut -lGL -lpthread -lm -// Compiling on Mac + XCode: -// gcc -o vwebp vwebp.c -lwebp -lwebpmux -framework GLUT -framework OpenGL +// Simple OpenGL-based WebP file viewer. // // Author: Skal (pascal.massimino@gmail.com) diff --git a/examples/webpmux.c b/examples/webpmux.c index bed8aab4..40592f27 100644 --- a/examples/webpmux.c +++ b/examples/webpmux.c @@ -8,9 +8,6 @@ // Simple command-line to create a WebP container file and to extract or strip // relevant data from the container file. // -// Compile with: gcc -o webpmux webpmux.c -lwebpmux -lwebp -// -// // Authors: Vikas (vikaas.arora@gmail.com), // Urvang (urvang@google.com) From b8307cc08ba7f5cba24a268c9b155b717bfcb82d Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 24 Apr 2013 14:40:58 -0700 Subject: [PATCH 17/57] configure.ac: add some helper macros library check related variable maintenance -> *_INCLUDES / *_LIBS CLEAR_LIBVARS / LIBCHECK_PROLOGUE / LIBCHECK_EPILOGUE Change-Id: I72e292dc1f69b02f69a26639308f247db0471e2b (cherry picked from commit 4ef144779260bdd4f4b06d2ccf67f6756e1f0f57) --- configure.ac | 82 ++++++++++++++++++++++------------------------------ 1 file changed, 34 insertions(+), 48 deletions(-) diff --git a/configure.ac b/configure.ac index df0560a0..739be272 100644 --- a/configure.ac +++ b/configure.ac @@ -19,6 +19,10 @@ AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=DIR], [pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig']) AC_SUBST([pkgconfigdir]) +dnl === CLEAR_LIBVARS([var_pfx]) +dnl === Clears _{INCLUDES,LIBS}. +AC_DEFUN([CLEAR_LIBVARS], [$1_INCLUDES=""; $1_LIBS=""]) + dnl === WITHLIB_OPTION([opt_pfx], [outvar_pfx]) dnl === Defines --with-{include,lib}dir options which set dnl === the variables _{INCLUDES,LIBS}. @@ -32,6 +36,24 @@ AC_DEFUN([WITHLIB_OPTION], [use $2 libraries from DIR]), [$2_LIBS="-L$withval"])]) +dnl === LIBCHECK_PROLOGUE([var_pfx]) +dnl === Caches the current values of CPPFLAGS/LIBS in SAVED_* then +dnl === prepends the current values with _{INCLUDES,LIBS}. +AC_DEFUN([LIBCHECK_PROLOGUE], + [SAVED_CPPFLAGS=$CPPFLAGS + SAVED_LIBS=$LIBS + CPPFLAGS="$$1_INCLUDES $CPPFLAGS" + LIBS="$$1_LIBS $LIBS"]) + +dnl === LIBCHECK_EPILOGUE([var_pfx]) +dnl === Restores the values of CPPFLAGS/LIBS from SAVED_* and exports +dnl === _{INCLUDES,LIBS} with AC_SUBST. +AC_DEFUN([LIBCHECK_EPILOGUE], + [AC_SUBST($1_LIBS) + AC_SUBST($1_INCLUDES) + CPPFLAGS=$SAVED_CPPFLAGS + LIBS=$SAVED_LIBS]) + dnl === Check for pthread support AC_ARG_ENABLE([threading], AS_HELP_STRING([--disable-threading], @@ -51,8 +73,7 @@ AC_MSG_NOTICE([checking if threading is enabled... ${enable_threading-no}]) dnl === check for PNG support === -PNG_INCLUDES="" -PNG_LIBS="" +CLEAR_LIBVARS([PNG]) AC_PATH_PROGS(LIBPNG_CONFIG, [libpng-config libpng15-config libpng14-config libpng12-config]) if test -n "$LIBPNG_CONFIG"; then @@ -66,11 +87,7 @@ fi WITHLIB_OPTION([png], [PNG]) -SAVED_CPPFLAGS=$CPPFLAGS -SAVED_LIBS=$LIBS -CPPFLAGS="$PNG_INCLUDES $CPPFLAGS" -LIBS="$PNG_LIBS $LIBS" - +LIBCHECK_PROLOGUE([PNG]) AC_CHECK_HEADER(png.h, AC_SEARCH_LIBS(png_get_libpng_ver, [png], [test "$ac_cv_search_png_get_libpng_ver" = "none required" \ @@ -90,23 +107,14 @@ AC_CHECK_HEADER(png.h, PNG_INCLUDES="" ], ) -AC_SUBST(PNG_LIBS) -AC_SUBST(PNG_INCLUDES) - -CPPFLAGS=$SAVED_CPPFLAGS -LIBS=$SAVED_LIBS +LIBCHECK_EPILOGUE([PNG]) dnl === check for JPEG support === -JPEG_INCLUDES="" -JPEG_LIBS="" +CLEAR_LIBVARS([JPEG]) WITHLIB_OPTION([jpeg], [JPEG]) -SAVED_CPPFLAGS=$CPPFLAGS -SAVED_LIBS=$LIBS -CPPFLAGS="$JPEG_INCLUDES $CPPFLAGS" -LIBS="$JPEG_LIBS $LIBS" - +LIBCHECK_PROLOGUE([JPEG]) AC_CHECK_HEADER(jpeglib.h, AC_CHECK_LIB(jpeg, jpeg_set_defaults, [JPEG_LIBS="$JPEG_LIBS -ljpeg" @@ -119,23 +127,14 @@ AC_CHECK_HEADER(jpeglib.h, [$MATH_LIBS]), AC_MSG_WARN(jpeg library not available - no jpeglib.h) ) -AC_SUBST(JPEG_LIBS) -AC_SUBST(JPEG_INCLUDES) - -CPPFLAGS=$SAVED_CPPFLAGS -LIBS=$SAVED_LIBS +LIBCHECK_EPILOGUE([JPEG]) dnl === check for TIFF support === -TIFF_INCLUDES="" -TIFF_LIBS="" +CLEAR_LIBVARS([TIFF]) WITHLIB_OPTION([tiff], [TIFF]) -SAVED_CPPFLAGS=$CPPFLAGS -SAVED_LIBS=$LIBS -CPPFLAGS="$TIFF_INCLUDES $CPPFLAGS" -LIBS="$TIFF_LIBS $LIBS" - +LIBCHECK_PROLOGUE([TIFF]) AC_CHECK_HEADER(tiffio.h, AC_CHECK_LIB(tiff, TIFFGetVersion, [TIFF_LIBS="$TIFF_LIBS -ltiff" @@ -148,23 +147,14 @@ AC_CHECK_HEADER(tiffio.h, [$MATH_LIBS]), AC_MSG_WARN(tiff library not available - no tiffio.h) ) -AC_SUBST(TIFF_LIBS) -AC_SUBST(TIFF_INCLUDES) - -CPPFLAGS=$SAVED_CPPFLAGS -LIBS=$SAVED_LIBS +LIBCHECK_EPILOGUE([TIFF]) dnl === check for GIF support === -GIF_INCLUDES="" -GIF_LIBS="" +CLEAR_LIBVARS([GIF]) WITHLIB_OPTION([gif], [GIF]) -SAVED_CPPFLAGS=$CPPFLAGS -SAVED_LIBS=$LIBS -CPPFLAGS="$GIF_INCLUDES $CPPFLAGS" -LIBS="$GIF_LIBS $LIBS" - +LIBCHECK_PROLOGUE([GIF]) AC_CHECK_HEADER(gif_lib.h, AC_CHECK_LIB([gif], [DGifOpenFileHandle], [GIF_LIBS="$GIF_LIBS -lgif" @@ -174,11 +164,7 @@ AC_CHECK_HEADER(gif_lib.h, [$MATH_LIBS]), AC_MSG_WARN(gif library not available - no gif_lib.h) ) -AC_SUBST(GIF_LIBS) -AC_SUBST(GIF_INCLUDES) - -CPPFLAGS=$SAVED_CPPFLAGS -LIBS=$SAVED_LIBS +LIBCHECK_EPILOGUE([GIF]) if test "$gif_support" = "yes" -a \ "$enable_libwebpmux" = "yes"; then From 20aa7a8dd571519e01ea79fec81df2cf8cffbd0c Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 1 May 2013 18:13:55 -0700 Subject: [PATCH 18/57] configure: add --enable-everything Change-Id: Ie1b3abd42459de7f789fe985759c465c2a196727 (cherry picked from commit 3cafcc9a8de7419d98a3deb456b3c807748eeda7) --- configure.ac | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/configure.ac b/configure.ac index 739be272..b60a683c 100644 --- a/configure.ac +++ b/configure.ac @@ -14,6 +14,18 @@ AM_PROG_CC_C_O dnl === Enable less verbose output when building. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) +dnl === SET_IF_UNSET(shell_var, value) +dnl === Set the shell variable 'shell_var' to 'value' if it is unset. +AC_DEFUN([SET_IF_UNSET], [test "${$1+set}" = "set" || $1=$2]) + +AC_ARG_ENABLE([everything], + AS_HELP_STRING([--enable-everything], + [Enable all optional targets. These can still be + disabled with --disable-target]), + [SET_IF_UNSET([enable_libwebpdecoder], [$enableval]) + SET_IF_UNSET([enable_libwebpdemux], [$enableval]) + SET_IF_UNSET([enable_libwebpmux], [$enableval])]) + AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=DIR], [Path to the pkgconfig directory @<:@LIBDIR/pkgconfig@:>@]), [pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig']) From b0ffc43700565119b89ba7211320b42572c0a190 Mon Sep 17 00:00:00 2001 From: Urvang Joshi Date: Thu, 2 May 2013 18:24:46 -0700 Subject: [PATCH 19/57] Alpha decoding: significantly reduce memory usage Simply get rid of an intermediate buffer of size width x height, by using the fact that stride == width in this case. Change-Id: I92376a2561a3beb6e723e8bcf7340c7f348e02c2 (cherry picked from commit edccd194362f86ed3b8106dd2474688e4a2a305e) --- src/dec/alpha.c | 52 ++++++++++++++++--------------------------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/src/dec/alpha.c b/src/dec/alpha.c index 630e367f..5c173718 100644 --- a/src/dec/alpha.c +++ b/src/dec/alpha.c @@ -20,20 +20,10 @@ extern "C" { #endif -// TODO(skal): move to dsp/ ? -static void CopyPlane(const uint8_t* src, int src_stride, - uint8_t* dst, int dst_stride, int width, int height) { - while (height-- > 0) { - memcpy(dst, src, width); - src += src_stride; - dst += dst_stride; - } -} - //------------------------------------------------------------------------------ // Decodes the compressed data 'data' of size 'data_size' into the 'output'. // The 'output' buffer should be pre-allocated and must be of the same -// dimension 'height'x'stride', as that of the image. +// dimension 'height'x'width', as that of the image. // // Returns 1 on successfully decoding the compressed alpha and // 0 if either: @@ -41,16 +31,16 @@ static void CopyPlane(const uint8_t* src, int src_stride, // error returned by appropriate compression method. static int DecodeAlpha(const uint8_t* data, size_t data_size, - int width, int height, int stride, uint8_t* output) { - uint8_t* decoded_data = NULL; - const size_t decoded_size = height * width; + int width, int height, uint8_t* output) { WEBP_FILTER_TYPE filter; int pre_processing; int rsrv; int ok = 0; int method; + const uint8_t* const alpha_data = data + ALPHA_HEADER_LEN; + const size_t alpha_data_size = data_size - ALPHA_HEADER_LEN; - assert(width > 0 && height > 0 && stride >= width); + assert(width > 0 && height > 0); assert(data != NULL && output != NULL); if (data_size <= ALPHA_HEADER_LEN) { @@ -70,15 +60,12 @@ static int DecodeAlpha(const uint8_t* data, size_t data_size, } if (method == ALPHA_NO_COMPRESSION) { - ok = (data_size >= decoded_size); - decoded_data = (uint8_t*)data + ALPHA_HEADER_LEN; + const size_t alpha_decoded_size = height * width; + ok = (alpha_data_size >= alpha_decoded_size); + if (ok) memcpy(output, alpha_data, alpha_decoded_size); } else { - decoded_data = (uint8_t*)malloc(decoded_size); - if (decoded_data == NULL) return 0; - ok = VP8LDecodeAlphaImageStream(width, height, - data + ALPHA_HEADER_LEN, - data_size - ALPHA_HEADER_LEN, - decoded_data); + ok = VP8LDecodeAlphaImageStream(width, height, alpha_data, alpha_data_size, + output); } if (ok) { @@ -86,18 +73,13 @@ static int DecodeAlpha(const uint8_t* data, size_t data_size, if (unfilter_func != NULL) { // TODO(vikas): Implement on-the-fly decoding & filter mechanism to decode // and apply filter per image-row. - unfilter_func(width, height, width, decoded_data); + unfilter_func(width, height, width, output); } - // Construct raw_data (height x stride) from alpha data (height x width). - CopyPlane(decoded_data, width, output, stride, width, height); if (pre_processing == ALPHA_PREPROCESSED_LEVELS) { - ok = DequantizeLevels(decoded_data, width, height); + ok = DequantizeLevels(output, width, height); } } - if (method != ALPHA_NO_COMPRESSION) { - free(decoded_data); - } return ok; } @@ -105,9 +87,10 @@ static int DecodeAlpha(const uint8_t* data, size_t data_size, const uint8_t* VP8DecompressAlphaRows(VP8Decoder* const dec, int row, int num_rows) { - const int stride = dec->pic_hdr_.width_; + const int width = dec->pic_hdr_.width_; + const int height = dec->pic_hdr_.height_; - if (row < 0 || num_rows < 0 || row + num_rows > dec->pic_hdr_.height_) { + if (row < 0 || num_rows < 0 || row + num_rows > height) { return NULL; // sanity check. } @@ -115,15 +98,14 @@ const uint8_t* VP8DecompressAlphaRows(VP8Decoder* const dec, // Decode everything during the first call. assert(!dec->is_alpha_decoded_); if (!DecodeAlpha(dec->alpha_data_, (size_t)dec->alpha_data_size_, - dec->pic_hdr_.width_, dec->pic_hdr_.height_, stride, - dec->alpha_plane_)) { + width, height, dec->alpha_plane_)) { return NULL; // Error. } dec->is_alpha_decoded_ = 1; } // Return a pointer to the current decoded row. - return dec->alpha_plane_ + row * stride; + return dec->alpha_plane_ + row * width; } #if defined(__cplusplus) || defined(c_plusplus) From e676b04309fd8bac89eb4b658d14ae8b5840fd82 Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 1 May 2013 14:47:56 -0700 Subject: [PATCH 20/57] configure: add GLUT detection; build vwebp Change-Id: I7f0964db2d04c22ff9ec274e8cd1cbed7379a165 (cherry picked from commit 0e513f7ae3e41c69baba66d1b68749860879a3f6) --- configure.ac | 95 ++++++++++++++++++++++++++++++++++++++++++-- examples/Makefile.am | 21 +++++++--- examples/vwebp.c | 5 ++- makefile.unix | 1 + 4 files changed, 111 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index b60a683c..e24f41f1 100644 --- a/configure.ac +++ b/configure.ac @@ -83,6 +83,92 @@ if test "$enable_threading" = "yes"; then fi AC_MSG_NOTICE([checking if threading is enabled... ${enable_threading-no}]) +dnl === check for OpenGL/GLUT support === +CLEAR_LIBVARS([GL]) +WITHLIB_OPTION([gl], [GL]) + +LIBCHECK_PROLOGUE([GL]) + +glut_cflags="none" +glut_ldflags="none" +case $host_os in + darwin*) + # Special case for OSX builds. Append these to give the user a chance to + # override with --with-gl* + glut_cflags="$glut_cflags|-framework GLUT -framework OpenGL" + glut_ldflags="$glut_ldflags|-framework GLUT -framework OpenGL" + ;; +esac + +GLUT_SAVED_CPPFLAGS="$CPPFLAGS" +SAVED_IFS="$IFS" +IFS="|" +for flag in $glut_cflags; do + # restore IFS immediately as the autoconf macros may need the default. + IFS="$SAVED_IFS" + unset ac_cv_header_GL_glut_h + unset ac_cv_header_OpenGL_glut_h + + case $flag in + none) ;; + *) CPPFLAGS="$flag $CPPFLAGS";; + esac + AC_CHECK_HEADERS([GL/glut.h GLUT/glut.h OpenGL/glut.h], + [glut_headers=yes; + test "$flag" = "none" || GL_INCLUDES="$CPPFLAGS"; + break]) + CPPFLAGS="$GLUT_SAVED_CPPFLAGS" + test "$glut_headers" = "yes" && break +done +IFS="$SAVED_IFS" + +if test "$glut_headers" = "yes"; then + AC_LANG_PUSH([C]) + GLUT_SAVED_LDFLAGS="$LDFLAGS" + SAVED_IFS="$IFS" + IFS="|" + for flag in $glut_ldflags; do + # restore IFS immediately as the autoconf macros may need the default. + IFS="$SAVED_IFS" + unset ac_cv_search_glBegin + + case $flag in + none) ;; + *) LDFLAGS="$flag $LDFLAGS";; + esac + + # find libGL + GL_SAVED_LIBS="$LIBS" + AC_SEARCH_LIBS([glBegin], [GL OpenGL]) + LIBS="$GL_SAVED_LIBS" + + # A direct link to libGL may not be necessary on e.g., linux. + for lib in "" $ac_cv_search_glBegin; do + unset ac_cv_search_glutMainLoop + AC_SEARCH_LIBS([glutMainLoop], [glut], [glut_support=yes], [], [$lib]) + if test "$glut_support" = "yes"; then + GL_LIBS="$LDFLAGS" + if test "$ac_cv_search_glutMainLoop" != "none required"; then + GL_LIBS="$GL_LIBS $ac_cv_search_glutMainLoop" + fi + GL_LIBS="$GL_LIBS $lib" + break + fi + done + LDFLAGS="$GLUT_SAVED_LDFLAGS" + test "$glut_support" = "yes" && break + done + IFS="$SAVED_IFS" + AC_LANG_POP +fi + +LIBCHECK_EPILOGUE([GL]) + +if test "$glut_support" = "yes" -a "$enable_libwebpdemux" = "yes"; then + build_vwebp=yes +fi +AM_CONDITIONAL([BUILD_VWEBP], [test "$build_vwebp" = "yes"]) + dnl === check for PNG support === CLEAR_LIBVARS([PNG]) @@ -305,18 +391,19 @@ libwebpdemux: ${enable_libwebpdemux-no} libwebpmux: ${enable_libwebpmux-no} Tools: -cwebp: yes +cwebp : yes Input format support ==================== JPEG : ${jpeg_support-no} PNG : ${png_support-no} TIFF : ${tiff_support-no} WIC : ${wic_support-no} -dwebp: yes +dwebp : yes Output format support ===================== PNG : ${png_support-no} WIC : ${wic_support-no} -gif2webp: ${build_gif2webp-no} -webpmux: ${enable_libwebpmux-no} +gif2webp : ${build_gif2webp-no} +webpmux : ${enable_libwebpmux-no} +vwebp : ${build_vwebp-no} ]) diff --git a/examples/Makefile.am b/examples/Makefile.am index b09a9798..20e925a1 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,6 +1,9 @@ AM_CPPFLAGS = -I$(top_srcdir)/src bin_PROGRAMS = dwebp cwebp +if BUILD_VWEBP + bin_PROGRAMS += vwebp +endif if WANT_MUX bin_PROGRAMS += webpmux endif @@ -18,12 +21,6 @@ dwebp_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE) dwebp_CPPFLAGS += $(JPEG_INCLUDES) $(PNG_INCLUDES) dwebp_LDADD = libexampleutil.la $(PNG_LIBS) $(JPEG_LIBS) -if BUILD_LIBWEBPDECODER - dwebp_LDADD += ../src/libwebpdecoder.la -else - dwebp_LDADD += ../src/libwebp.la -endif - cwebp_SOURCES = cwebp.c metadata.c metadata.h stopwatch.h cwebp_SOURCES += jpegdec.c jpegdec.h cwebp_SOURCES += pngdec.c pngdec.h @@ -41,3 +38,15 @@ gif2webp_LDADD += $(GIF_LIBS) webpmux_SOURCES = webpmux.c webpmux_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE) webpmux_LDADD = libexampleutil.la ../src/mux/libwebpmux.la ../src/libwebp.la + +vwebp_SOURCES = vwebp.c +vwebp_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE) $(GL_INCLUDES) +vwebp_LDADD = libexampleutil.la ../src/demux/libwebpdemux.la $(GL_LIBS) + +if BUILD_LIBWEBPDECODER + dwebp_LDADD += ../src/libwebpdecoder.la + vwebp_LDADD += ../src/libwebpdecoder.la +else + dwebp_LDADD += ../src/libwebp.la + vwebp_LDADD += ../src/libwebp.la +endif diff --git a/examples/vwebp.c b/examples/vwebp.c index 22f14b23..93897449 100644 --- a/examples/vwebp.c +++ b/examples/vwebp.c @@ -8,12 +8,15 @@ // Simple OpenGL-based WebP file viewer. // // Author: Skal (pascal.massimino@gmail.com) +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include #include -#ifdef __APPLE__ +#if defined(HAVE_GLUT_GLUT_H) #include #else #include diff --git a/makefile.unix b/makefile.unix index 0f8cf311..6c787f54 100644 --- a/makefile.unix +++ b/makefile.unix @@ -24,6 +24,7 @@ ifeq ($(strip $(shell uname)), Darwin) # cf., src/enc/yuv.[hc] # Failure observed with: gcc 4.2.1 and 4.0.1. EXTRA_FLAGS += -fno-common + EXTRA_FLAGS += -DHAVE_GLUT_GLUT_H EXTRA_FLAGS += -I/opt/local/include EXTRA_LIBS += -L/opt/local/lib GL_LIBS = -framework GLUT -framework OpenGL From 8ecec6865218cb1fd371fee028e9c962310c3d8e Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 6 May 2013 17:18:27 -0700 Subject: [PATCH 21/57] configure: add warning related flags adds TEST_AND_ADD_CFLAGS function uses AM_CFLAGS to allow CFLAGS override Change-Id: I9352aec6e5d905a41d832bf5ad0c8dcd154f7e97 (cherry picked from commit bba4c2b2a6e47fdce45761fc81f0175cc04c3a67) --- configure.ac | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/configure.ac b/configure.ac index e24f41f1..f4937170 100644 --- a/configure.ac +++ b/configure.ac @@ -31,6 +31,30 @@ AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=DIR], [pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig']) AC_SUBST([pkgconfigdir]) +dnl === TEST_AND_ADD_CFLAGS(flag) +dnl === Checks whether $CC supports 'flag' and adds it to AM_CFLAGS on success. +AC_DEFUN([TEST_AND_ADD_CFLAGS], + [SAVED_CFLAGS="$CFLAGS" + CFLAGS="-Werror $1" + AC_MSG_CHECKING([whether $CC supports $1]) + dnl Note AC_LANG_PROGRAM([]) uses an old-style main definition. + AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])], + [AC_MSG_RESULT([yes])] + [AS_VAR_APPEND([AM_CFLAGS], [" $1"])], + [AC_MSG_RESULT([no])]) + CFLAGS="$SAVED_CFLAGS"]) +TEST_AND_ADD_CFLAGS([-Wall]) +TEST_AND_ADD_CFLAGS([-Wdeclaration-after-statement]) +TEST_AND_ADD_CFLAGS([-Wextra]) +TEST_AND_ADD_CFLAGS([-Wmissing-declarations]) +TEST_AND_ADD_CFLAGS([-Wmissing-prototypes]) +TEST_AND_ADD_CFLAGS([-Wold-style-definition]) +TEST_AND_ADD_CFLAGS([-Wshadow]) +TEST_AND_ADD_CFLAGS([-Wunused-but-set-variable]) +TEST_AND_ADD_CFLAGS([-Wunused]) +TEST_AND_ADD_CFLAGS([-Wvla]) +AC_SUBST([AM_CFLAGS]) + dnl === CLEAR_LIBVARS([var_pfx]) dnl === Clears _{INCLUDES,LIBS}. AC_DEFUN([CLEAR_LIBVARS], [$1_INCLUDES=""; $1_LIBS=""]) From 26e724422148cd042c59407ece8f02c326ed2c5a Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 8 May 2013 17:13:40 -0700 Subject: [PATCH 22/57] swig: ifdef some Java specific code no implementation change Change-Id: I077c707e1f6293188e6fa11ba24757009a709f77 (cherry picked from commit c7247c4c6847d49ff696dc02c6da4828ce23ffc7) --- swig/libwebp.i | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/swig/libwebp.i b/swig/libwebp.i index b2014e16..de80b6e4 100644 --- a/swig/libwebp.i +++ b/swig/libwebp.i @@ -71,7 +71,10 @@ int WebPGetEncoderVersion(void); %{ #include "webp/decode.h" #include "webp/encode.h" +%} +#ifdef SWIGJAVA +%{ #define FillMeInAsSizeCannotBeDeterminedAutomatically \ (result ? returned_buffer_size(__FUNCTION__, arg3, arg4) : 0) @@ -108,6 +111,10 @@ static jint returned_buffer_size( return size; } +%} +#endif /* SWIGJAVA */ + +%{ typedef size_t (*WebPEncodeFunction)(const uint8_t* rgb, int width, int height, int stride, From 498d4dd634f052f9e7cde7f328ee96278a577c66 Mon Sep 17 00:00:00 2001 From: Vikas Arora Date: Wed, 8 May 2013 17:19:04 -0700 Subject: [PATCH 23/57] WebP-Lossless encoding improvements. Lossy (with Alpha) image compression gets 2.3X speedup. Compressing lossless images is 20%-40% faster now. Change-Id: I41f0225838b48ae5c60b1effd1b0de72fecb3ae6 (cherry picked from commit 8eae188a62bdd2dfef2266cfd34617a421c3266f) --- src/dsp/lossless.c | 21 +++++++++ src/dsp/lossless.h | 3 ++ src/enc/alpha.c | 65 +++++++++++++++++++++------ src/enc/backward_references.c | 76 +++++++++++++++---------------- src/enc/vp8l.c | 84 ++++++++++++++++++----------------- src/utils/filters.c | 4 +- 6 files changed, 159 insertions(+), 94 deletions(-) diff --git a/src/dsp/lossless.c b/src/dsp/lossless.c index 080b3e63..c015b7ad 100644 --- a/src/dsp/lossless.c +++ b/src/dsp/lossless.c @@ -1325,6 +1325,27 @@ void VP8LConvertFromBGRA(const uint32_t* const in_data, int num_pixels, } } +// Bundles multiple (1, 2, 4 or 8) pixels into a single pixel. +void VP8LBundleColorMap(const uint8_t* const row, int width, + int xbits, uint32_t* const dst) { + int x; + if (xbits > 0) { + const int bit_depth = 1 << (3 - xbits); + const int mask = (1 << xbits) - 1; + uint32_t code = 0xff000000; + for (x = 0; x < width; ++x) { + const int xsub = x & mask; + if (xsub == 0) { + code = 0xff000000; + } + code |= row[x] << (8 + bit_depth * xsub); + dst[x >> xbits] = code; + } + } else { + for (x = 0; x < width; ++x) dst[x] = 0xff000000 | (row[x] << 8); + } +} + //------------------------------------------------------------------------------ #if defined(__cplusplus) || defined(c_plusplus) diff --git a/src/dsp/lossless.h b/src/dsp/lossless.h index 0ac4ecb8..6742bcc8 100644 --- a/src/dsp/lossless.h +++ b/src/dsp/lossless.h @@ -83,6 +83,9 @@ static WEBP_INLINE uint32_t VP8LSubPixels(uint32_t a, uint32_t b) { return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu); } +void VP8LBundleColorMap(const uint8_t* const row, int width, + int xbits, uint32_t* const dst); + //------------------------------------------------------------------------------ #if defined(__cplusplus) || defined(c_plusplus) diff --git a/src/enc/alpha.c b/src/enc/alpha.c index aadf88fe..60391c11 100644 --- a/src/enc/alpha.c +++ b/src/enc/alpha.c @@ -80,7 +80,7 @@ static int EncodeLossless(const uint8_t* const data, int width, int height, config.lossless = 1; config.method = effort_level; // impact is very small // Set a moderate default quality setting for alpha. - config.quality = 5.f * effort_level; + config.quality = 10.f * effort_level; assert(config.quality >= 0 && config.quality <= 100.f); ok = VP8LBitWriterInit(&tmp_bw, (width * height) >> 3); @@ -156,6 +156,25 @@ static void CopyPlane(const uint8_t* src, int src_stride, } } +static int GetNumColors(const uint8_t* data, int width, int height, + int stride) { + int j; + int colors = 0; + uint8_t color[256] = { 0 }; + + for (j = 0; j < height; ++j) { + int i; + const uint8_t* const p = data + j * stride; + for (i = 0; i < width; ++i) { + color[p[i]] = 1; + } + } + for (j = 0; j < 256; ++j) { + if (color[j] > 0) ++colors; + } + return colors; +} + static int EncodeAlpha(VP8Encoder* const enc, int quality, int method, int filter, int effort_level, @@ -207,18 +226,32 @@ static int EncodeAlpha(VP8Encoder* const enc, VP8BitWriter bw; int test_filter; uint8_t* filtered_alpha = NULL; + int try_filter_none = (effort_level > 3); - // We always test WEBP_FILTER_NONE first. - ok = EncodeAlphaInternal(quant_alpha, width, height, - method, WEBP_FILTER_NONE, reduce_levels, - effort_level, NULL, &bw, pic->stats); - if (!ok) { - VP8BitWriterWipeOut(&bw); - goto End; + if (filter == WEBP_FILTER_FAST) { // Quick estimate of the best candidate. + const int kMinColorsForFilterNone = 16; + const int kMaxColorsForFilterNone = 192; + const int num_colors = GetNumColors(quant_alpha, width, height, width); + // For low number of colors, NONE yeilds better compression. + filter = (num_colors <= kMinColorsForFilterNone) ? WEBP_FILTER_NONE : + EstimateBestFilter(quant_alpha, width, height, width); + // For large number of colors, try FILTER_NONE in addition to the best + // filter as well. + if (num_colors > kMaxColorsForFilterNone) { + try_filter_none = 1; + } } - if (filter == WEBP_FILTER_FAST) { // Quick estimate of a second candidate? - filter = EstimateBestFilter(quant_alpha, width, height, width); + // Test for WEBP_FILTER_NONE for higher effort levels. + if (try_filter_none || filter == WEBP_FILTER_NONE) { + ok = EncodeAlphaInternal(quant_alpha, width, height, + method, WEBP_FILTER_NONE, reduce_levels, + effort_level, NULL, &bw, pic->stats); + + if (!ok) { + VP8BitWriterWipeOut(&bw); + goto End; + } } // Stop? if (filter == WEBP_FILTER_NONE) { @@ -234,11 +267,14 @@ static int EncodeAlpha(VP8Encoder* const enc, // Try the other mode(s). { WebPAuxStats best_stats; - size_t best_score = VP8BitWriterSize(&bw); + size_t best_score = try_filter_none ? + VP8BitWriterSize(&bw) : (size_t)~0U; + int wipe_tmp_bw = try_filter_none; memset(&best_stats, 0, sizeof(best_stats)); // prevent spurious warning if (pic->stats != NULL) best_stats = *pic->stats; - for (test_filter = WEBP_FILTER_HORIZONTAL; + for (test_filter = + try_filter_none ? WEBP_FILTER_HORIZONTAL : WEBP_FILTER_NONE; ok && (test_filter <= WEBP_FILTER_GRADIENT); ++test_filter) { VP8BitWriter tmp_bw; @@ -262,7 +298,10 @@ static int EncodeAlpha(VP8Encoder* const enc, } else { VP8BitWriterWipeOut(&bw); } - VP8BitWriterWipeOut(&tmp_bw); + if (wipe_tmp_bw) { + VP8BitWriterWipeOut(&tmp_bw); + } + wipe_tmp_bw = 1; // For next filter trial for WEBP_FILTER_BEST. } if (pic->stats != NULL) *pic->stats = best_stats; } diff --git a/src/enc/backward_references.c b/src/enc/backward_references.c index cf027875..67dd7e94 100644 --- a/src/enc/backward_references.c +++ b/src/enc/backward_references.c @@ -142,9 +142,10 @@ static void HashChainInsert(HashChain* const p, } static void GetParamsForHashChainFindCopy(int quality, int xsize, - int* window_size, int* iter_pos, - int* iter_limit) { + int cache_bits, int* window_size, + int* iter_pos, int* iter_limit) { const int iter_mult = (quality < 27) ? 1 : 1 + ((quality - 27) >> 4); + const int iter_neg = -iter_mult * (quality >> 1); // Limit the backward-ref window size for lower qualities. const int max_window_size = (quality > 50) ? WINDOW_SIZE : (quality > 25) ? (xsize << 8) @@ -152,77 +153,74 @@ static void GetParamsForHashChainFindCopy(int quality, int xsize, assert(xsize > 0); *window_size = (max_window_size > WINDOW_SIZE) ? WINDOW_SIZE : max_window_size; - *iter_pos = 5 + (quality >> 3); - *iter_limit = -quality * iter_mult; + *iter_pos = 8 + (quality >> 3); + // For lower entropy images, the rigourous search loop in HashChainFindCopy + // can be relaxed. + *iter_limit = (cache_bits > 0) ? iter_neg : iter_neg / 2; } static int HashChainFindCopy(const HashChain* const p, - int base_position, int xsize, + int base_position, int xsize_signed, const uint32_t* const argb, int maxlen, int window_size, int iter_pos, int iter_limit, int* const distance_ptr, int* const length_ptr) { - const uint64_t hash_code = GetPixPairHash64(&argb[base_position]); - int prev_length = 0; - int64_t best_val = 0; - int best_length = 0; - int best_distance = 0; const uint32_t* const argb_start = argb + base_position; + uint64_t best_val = 0; + uint32_t best_length = 1; + uint32_t best_distance = 0; + const uint32_t xsize = (uint32_t)xsize_signed; const int min_pos = (base_position > window_size) ? base_position - window_size : 0; int pos; - assert(xsize > 0); - for (pos = p->hash_to_first_index_[hash_code]; + for (pos = p->hash_to_first_index_[GetPixPairHash64(argb_start)]; pos >= min_pos; pos = p->chain_[pos]) { - int64_t val; - int curr_length; + uint64_t val; + uint32_t curr_length; + uint32_t distance; if (iter_pos < 0) { if (iter_pos < iter_limit || best_val >= 0xff0000) { break; } } --iter_pos; - if (best_length != 0 && - argb[pos + best_length - 1] != argb_start[best_length - 1]) { + if (argb[pos + best_length - 1] != argb_start[best_length - 1]) { continue; } curr_length = FindMatchLength(argb + pos, argb_start, maxlen); - if (curr_length < prev_length) { + if (curr_length < best_length) { continue; } - val = 65536 * curr_length; + distance = (uint32_t)(base_position - pos); + val = curr_length << 16; // Favoring 2d locality here gives savings for certain images. - if (base_position - pos < 9 * xsize) { - const int y = (base_position - pos) / xsize; - int x = (base_position - pos) % xsize; - if (x > xsize / 2) { + if (distance < 9 * xsize) { + const uint32_t y = distance / xsize; + uint32_t x = distance % xsize; + if (x > (xsize >> 1)) { x = xsize - x; } - if (x <= 7 && x >= -8) { + if (x <= 7) { + val += 9 * 9 + 9 * 9; val -= y * y + x * x; - } else { - val -= 9 * 9 + 9 * 9; } - } else { - val -= 9 * 9 + 9 * 9; } if (best_val < val) { - prev_length = curr_length; best_val = val; best_length = curr_length; - best_distance = base_position - pos; + best_distance = distance; if (curr_length >= MAX_LENGTH) { break; } - if ((best_distance == 1 || best_distance == xsize) && + if ((best_distance == 1 || distance == xsize) && best_length >= 128) { break; } } } - *distance_ptr = best_distance; + *distance_ptr = (int)best_distance; *length_ptr = best_length; return (best_length >= MIN_LENGTH); } @@ -284,8 +282,8 @@ static int BackwardReferencesHashChain(int xsize, int ysize, if (!HashChainInit(hash_chain, pix_count)) goto Error; refs->size = 0; - GetParamsForHashChainFindCopy(quality, xsize, &window_size, &iter_pos, - &iter_limit); + GetParamsForHashChainFindCopy(quality, xsize, cache_bits, + &window_size, &iter_pos, &iter_limit); for (i = 0; i < pix_count; ) { // Alternative#1: Code the pixels starting at 'i' using backward reference. int offset = 0; @@ -510,8 +508,8 @@ static int BackwardReferencesHashChainDistanceOnly( // We loop one pixel at a time, but store all currently best points to // non-processed locations from this point. dist_array[0] = 0; - GetParamsForHashChainFindCopy(quality, xsize, &window_size, &iter_pos, - &iter_limit); + GetParamsForHashChainFindCopy(quality, xsize, cache_bits, + &window_size, &iter_pos, &iter_limit); for (i = 0; i < pix_count; ++i) { double prev_cost = 0.0; int shortmax; @@ -645,8 +643,8 @@ static int BackwardReferencesHashChainFollowChosenPath( } refs->size = 0; - GetParamsForHashChainFindCopy(quality, xsize, &window_size, &iter_pos, - &iter_limit); + GetParamsForHashChainFindCopy(quality, xsize, cache_bits, + &window_size, &iter_pos, &iter_limit); for (ix = 0; ix < chosen_path_size; ++ix, ++size) { int offset = 0; int len = 0; @@ -785,7 +783,9 @@ int VP8LGetBackwardReferences(int width, int height, *best = refs_lz77; // default guess: lz77 is better VP8LClearBackwardRefs(&refs_rle); if (try_lz77_trace_backwards) { - const int recursion_level = (num_pix < 320 * 200) ? 1 : 0; + // Set recursion level for large images using a color cache. + const int recursion_level = + (num_pix < 320 * 200) && (cache_bits > 0) ? 1 : 0; VP8LBackwardRefs refs_trace; if (!VP8LBackwardRefsAlloc(&refs_trace, num_pix)) { goto End; diff --git a/src/enc/vp8l.c b/src/enc/vp8l.c index 5077167b..8af544ff 100644 --- a/src/enc/vp8l.c +++ b/src/enc/vp8l.c @@ -811,27 +811,6 @@ static WebPEncodingError AllocateTransformBuffer(VP8LEncoder* const enc, return err; } -// Bundles multiple (1, 2, 4 or 8) pixels into a single pixel. -static void BundleColorMap(const uint8_t* const row, int width, - int xbits, uint32_t* const dst) { - int x; - if (xbits > 0) { - const int bit_depth = 1 << (3 - xbits); - const int mask = (1 << xbits) - 1; - uint32_t code = 0xff000000; - for (x = 0; x < width; ++x) { - const int xsub = x & mask; - if (xsub == 0) { - code = 0xff000000; - } - code |= row[x] << (8 + bit_depth * xsub); - dst[x >> xbits] = code; - } - } else { - for (x = 0; x < width; ++x) dst[x] = 0xff000000 | (row[x] << 8); - } -} - // Note: Expects "enc->palette_" to be set properly. // Also, "enc->palette_" will be modified after this call and should not be used // later. @@ -848,6 +827,7 @@ static WebPEncodingError ApplyPalette(VP8LBitWriter* const bw, const int palette_size = enc->palette_size_; uint8_t* row = NULL; int xbits; + int is_alpha = 1; // Replace each input pixel by corresponding palette index. // This is done line by line. @@ -864,19 +844,43 @@ static WebPEncodingError ApplyPalette(VP8LBitWriter* const bw, row = WebPSafeMalloc((uint64_t)width, sizeof(*row)); if (row == NULL) return VP8_ENC_ERROR_OUT_OF_MEMORY; - for (y = 0; y < height; ++y) { - for (x = 0; x < width; ++x) { - const uint32_t pix = src[x]; - for (i = 0; i < palette_size; ++i) { - if (pix == palette[i]) { - row[x] = i; - break; + for (i = 0; i < palette_size; ++i) { + if ((palette[i] & 0x00ff00ffu) != 0) { + is_alpha = 0; + break; + } + } + + if (is_alpha) { + int inv_palette[MAX_PALETTE_SIZE] = { 0 }; + for (i = 0; i < palette_size; ++i) { + const int color = (palette[i] >> 8) & 0xff; + inv_palette[color] = i; + } + for (y = 0; y < height; ++y) { + for (x = 0; x < width; ++x) { + const int color = (src[x] >> 8) & 0xff; + row[x] = inv_palette[color]; + } + VP8LBundleColorMap(row, width, xbits, dst); + src += pic->argb_stride; + dst += enc->current_width_; + } + } else { + for (y = 0; y < height; ++y) { + for (x = 0; x < width; ++x) { + const uint32_t pix = src[x]; + for (i = 0; i < palette_size; ++i) { + if (pix == palette[i]) { + row[x] = i; + break; + } } } + VP8LBundleColorMap(row, width, xbits, dst); + src += pic->argb_stride; + dst += enc->current_width_; } - BundleColorMap(row, width, xbits, dst); - src += pic->argb_stride; - dst += enc->current_width_; } // Save palette to bitstream. @@ -899,13 +903,10 @@ static WebPEncodingError ApplyPalette(VP8LBitWriter* const bw, // ----------------------------------------------------------------------------- -static int GetHistoBits(const WebPConfig* const config, - const WebPPicture* const pic) { - const int width = pic->width; - const int height = pic->height; +static int GetHistoBits(int method, int use_palette, int width, int height) { const uint64_t hist_size = sizeof(VP8LHistogram); // Make tile size a function of encoding method (Range: 0 to 6). - int histo_bits = 7 - config->method; + int histo_bits = (use_palette ? 9 : 7) - method; while (1) { const uint64_t huff_image_size = VP8LSubSampleSize(width, histo_bits) * VP8LSubSampleSize(height, histo_bits) * @@ -917,13 +918,14 @@ static int GetHistoBits(const WebPConfig* const config, (histo_bits > MAX_HUFFMAN_BITS) ? MAX_HUFFMAN_BITS : histo_bits; } -static void InitEncParams(VP8LEncoder* const enc) { +static void FinishEncParams(VP8LEncoder* const enc) { const WebPConfig* const config = enc->config_; - const WebPPicture* const picture = enc->pic_; + const WebPPicture* const pic = enc->pic_; const int method = config->method; const float quality = config->quality; + const int use_palette = enc->use_palette_; enc->transform_bits_ = (method < 4) ? 5 : (method > 4) ? 3 : 4; - enc->histo_bits_ = GetHistoBits(config, picture); + enc->histo_bits_ = GetHistoBits(method, use_palette, pic->width, pic->height); enc->cache_bits_ = (quality <= 25.f) ? 0 : 7; } @@ -965,8 +967,6 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config, goto Error; } - InitEncParams(enc); - // --------------------------------------------------------------------------- // Analyze image (entropy, num_palettes etc) @@ -975,6 +975,8 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config, goto Error; } + FinishEncParams(enc); + if (enc->use_palette_) { err = ApplyPalette(bw, enc, quality); if (err != VP8_ENC_OK) goto Error; diff --git a/src/utils/filters.c b/src/utils/filters.c index 9486355a..ad847746 100644 --- a/src/utils/filters.c +++ b/src/utils/filters.c @@ -154,8 +154,7 @@ static void GradientUnfilter(int width, int height, int stride, uint8_t* data) { #undef SANITY_CHECK // ----------------------------------------------------------------------------- -// Quick estimate of a potentially interesting filter mode to try, in addition -// to the default NONE. +// Quick estimate of a potentially interesting filter mode to try. #define SMAX 16 #define SDIFF(a, b) (abs((a) - (b)) >> 4) // Scoring diff, in [0..SMAX) @@ -165,6 +164,7 @@ WEBP_FILTER_TYPE EstimateBestFilter(const uint8_t* data, int i, j; int bins[WEBP_FILTER_LAST][SMAX]; memset(bins, 0, sizeof(bins)); + // We only sample every other pixels. That's enough. for (j = 2; j < height - 1; j += 2) { const uint8_t* const p = data + j * stride; From b4f5bb6ca3ff0638d3de1440d95b3ccad33fb32e Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 8 May 2013 18:00:30 -0700 Subject: [PATCH 24/57] swig: cosmetics normalize formatting - update decode prototypes - match project function name style Change-Id: Ib481b5602171b72dbb1a5d462e6d5166e9b8566e (cherry picked from commit 7f5f42bb36e07c4f61fe19617e29fb2b5fed5b5d) --- swig/libwebp.i | 66 ++++++++++++++++++++-------------------- swig/libwebp_java_wrap.c | 55 +++++++++++++++++---------------- 2 files changed, 62 insertions(+), 59 deletions(-) diff --git a/swig/libwebp.i b/swig/libwebp.i index de80b6e4..06b9bee5 100644 --- a/swig/libwebp.i +++ b/swig/libwebp.i @@ -28,13 +28,13 @@ // map uint8_t* such that a byte[] is used // this will generate a few spurious warnings in the wrapper code -%apply signed char[] { uint8_t * } +%apply signed char[] { uint8_t* } #endif /* SWIGJAVA */ //------------------------------------------------------------------------------ // Decoder specific -%apply int *OUTPUT { int *width, int *height } +%apply int* OUTPUT { int* width, int* height } // free the buffer returned by these functions after copying into // the native type @@ -47,18 +47,18 @@ int WebPGetDecoderVersion(void); int WebPGetInfo(const uint8_t* data, size_t data_size, - int *width, int *height); + int* width, int* height); uint8_t* WebPDecodeRGB(const uint8_t* data, size_t data_size, - int *width, int *height); + int* width, int* height); uint8_t* WebPDecodeRGBA(const uint8_t* data, size_t data_size, - int *width, int *height); + 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); + int* width, int* height); uint8_t* WebPDecodeBGRA(const uint8_t* data, size_t data_size, - int *width, int *height); + int* width, int* height); //------------------------------------------------------------------------------ // Encoder specific @@ -76,12 +76,12 @@ int WebPGetEncoderVersion(void); #ifdef SWIGJAVA %{ #define FillMeInAsSizeCannotBeDeterminedAutomatically \ - (result ? returned_buffer_size(__FUNCTION__, arg3, arg4) : 0) + (result ? ReturnedBufferSize(__FUNCTION__, arg3, arg4) : 0) -static jint returned_buffer_size( - const char *function, int *width, int *height) { +static jint ReturnedBufferSize( + const char* function, int* width, int* height) { static const struct sizemap { - const char *function; + const char* function; int size_multiplier; } size_map[] = { { "Java_com_google_webp_libwebpJNI_WebPDecodeRGB", 3 }, @@ -99,7 +99,7 @@ static jint returned_buffer_size( { "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLosslessBGRA", 1 }, { NULL, 0 } }; - const struct sizemap *p; + const struct sizemap* p; jint size = -1; for (p = size_map; p->function; p++) { @@ -123,29 +123,29 @@ typedef size_t (*WebPEncodeLosslessFunction)(const uint8_t* rgb, int width, int height, int stride, uint8_t** output); -static uint8_t* encode(const uint8_t* rgb, - int width, int height, int stride, - float quality_factor, - WebPEncodeFunction encfn, - int* output_size, int* unused) { - uint8_t *output = NULL; +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 returned_buffer_size() + // 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* encode_lossless(const uint8_t* rgb, - int width, int height, int stride, - WebPEncodeLosslessFunction encfn, - int* output_size, int* unused) { - uint8_t *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 following two will be interpreted by returned_buffer_size() - // as 'width' and 'height' in the size calculation. + // 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; @@ -155,8 +155,8 @@ static uint8_t* encode_lossless(const uint8_t* rgb, //------------------------------------------------------------------------------ // libwebp/encode wrapper functions -%apply int *INPUT { int *unused1, int *unused2 } -%apply int *OUTPUT { int *output_size } +%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 @@ -185,14 +185,14 @@ static uint8_t* encode_lossless(const uint8_t* rgb, // 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 returned_buffer_size(), +// 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 encode(rgb, width, height, stride, quality_factor, \ - FUNC, output_size, unused2); \ + return EncodeLossy(rgb, width, height, stride, quality_factor, \ + FUNC, output_size, unused2); \ } \ LOSSY_WRAPPER(WebPEncodeRGB) @@ -206,8 +206,8 @@ LOSSY_WRAPPER(WebPEncodeBGRA) static uint8_t* wrap_##FUNC( \ const uint8_t* rgb, int* unused1, int* unused2, int* output_size, \ int width, int height, int stride) { \ - return encode_lossless(rgb, width, height, stride, \ - FUNC, output_size, unused2); \ + return EncodeLossless(rgb, width, height, stride, \ + FUNC, output_size, unused2); \ } \ LOSSLESS_WRAPPER(WebPEncodeLosslessRGB) diff --git a/swig/libwebp_java_wrap.c b/swig/libwebp_java_wrap.c index f2ea1b50..fd5821a9 100644 --- a/swig/libwebp_java_wrap.c +++ b/swig/libwebp_java_wrap.c @@ -1,6 +1,6 @@ /* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.40 + * Version 2.0.4 * * 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 @@ -811,13 +811,14 @@ jdoubleArray SWIG_JavaArrayOutDouble (JNIEnv *jenv, double *result, jsize sz) { #include "webp/decode.h" #include "webp/encode.h" -#define FillMeInAsSizeCannotBeDeterminedAutomatically \ - (result ? returned_buffer_size(__FUNCTION__, arg3, arg4) : 0) -static jint returned_buffer_size( - const char *function, int *width, int *height) { +#define FillMeInAsSizeCannotBeDeterminedAutomatically \ + (result ? ReturnedBufferSize(__FUNCTION__, arg3, arg4) : 0) + +static jint ReturnedBufferSize( + const char* function, int* width, int* height) { static const struct sizemap { - const char *function; + const char* function; int size_multiplier; } size_map[] = { { "Java_com_google_webp_libwebpJNI_WebPDecodeRGB", 3 }, @@ -835,7 +836,7 @@ static jint returned_buffer_size( { "Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLosslessBGRA", 1 }, { NULL, 0 } }; - const struct sizemap *p; + const struct sizemap* p; jint size = -1; for (p = size_map; p->function; p++) { @@ -848,6 +849,8 @@ static jint returned_buffer_size( return size; } + + typedef size_t (*WebPEncodeFunction)(const uint8_t* rgb, int width, int height, int stride, float quality_factor, uint8_t** output); @@ -855,29 +858,29 @@ typedef size_t (*WebPEncodeLosslessFunction)(const uint8_t* rgb, int width, int height, int stride, uint8_t** output); -static uint8_t* encode(const uint8_t* rgb, - int width, int height, int stride, - float quality_factor, - WebPEncodeFunction encfn, - int* output_size, int* unused) { - uint8_t *output = NULL; +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 returned_buffer_size() + // 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* encode_lossless(const uint8_t* rgb, - int width, int height, int stride, - WebPEncodeLosslessFunction encfn, - int* output_size, int* unused) { - uint8_t *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 following two will be interpreted by returned_buffer_size() - // as 'width' and 'height' in the size calculation. + // 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; @@ -887,14 +890,14 @@ static uint8_t* encode_lossless(const uint8_t* rgb, // 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 returned_buffer_size(), +// 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 encode(rgb, width, height, stride, quality_factor, \ - FUNC, output_size, unused2); \ + return EncodeLossy(rgb, width, height, stride, quality_factor, \ + FUNC, output_size, unused2); \ } \ LOSSY_WRAPPER(WebPEncodeRGB) @@ -908,8 +911,8 @@ LOSSY_WRAPPER(WebPEncodeBGRA) static uint8_t* wrap_##FUNC( \ const uint8_t* rgb, int* unused1, int* unused2, int* output_size, \ int width, int height, int stride) { \ - return encode_lossless(rgb, width, height, stride, \ - FUNC, output_size, unused2); \ + return EncodeLossless(rgb, width, height, stride, \ + FUNC, output_size, unused2); \ } \ LOSSLESS_WRAPPER(WebPEncodeLosslessRGB) From 6c76d28e4ba355fc198a4b3a7f926909c7ac70d0 Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 9 May 2013 23:27:54 -0700 Subject: [PATCH 25/57] swig: add python (decode) support similar to Java, simple interface only Change-Id: I8a3d344e5d89f73627e4e0cb2067512260d46fdd (cherry picked from commit f980faf4177761a491c94d4279343753c72c3cd9) --- swig/README | 17 + swig/libwebp.i | 59 +- swig/libwebp.py | 136 + swig/libwebp_java_wrap.c | 19 +- swig/libwebp_python_wrap.c | 5257 ++++++++++++++++++++++++++++++++++++ swig/setup.py | 40 + 6 files changed, 5509 insertions(+), 19 deletions(-) create mode 100644 swig/libwebp.py create mode 100644 swig/libwebp_python_wrap.c create mode 100644 swig/setup.py diff --git a/swig/README b/swig/README index 959f3ec9..725c0716 100644 --- a/swig/README +++ b/swig/README @@ -37,3 +37,20 @@ public class libwebp_jni_example { $ javac -cp libwebp.jar libwebp_jni_example.java $ java -Djava.library.path=. -cp libwebp.jar:. libwebp_jni_example + +Python SWIG bindings: +--------------------- + $ python setup.py build_ext + $ python setup.py install --prefix=pylocal + +-------------------------------------- BEGIN PSEUDO EXAMPLE +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 +-------------------------------------- END PSEUDO EXAMPLE diff --git a/swig/libwebp.i b/swig/libwebp.i index 06b9bee5..7156dbec 100644 --- a/swig/libwebp.i +++ b/swig/libwebp.i @@ -8,15 +8,26 @@ // libwebp swig interface definition // // Author: James Zern (jzern@google.com) -// -// For java bindings compile with: -// $ mkdir -p java/com/google/webp -// $ swig -ignoremissing -I../src \ -// -java \ -// -package com.google.webp \ -// -outdir java/com/google/webp \ -// -o libwebp_java_wrap.c libwebp.i + +/* + 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.i + + Python bindings: + $ swig -python \ + -outdir . \ + -o libwebp_python_wrap.c libwebp.i +*/ + +#ifdef SWIGPYTHON +%module(package="com.google.webp") libwebp +#else %module libwebp +#endif /* SWIGPYTHON */ %include "constraints.i" %include "typemaps.i" @@ -31,6 +42,14 @@ %apply signed char[] { 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, ReturnedBufferSize("$symname", arg3, arg4)); +} +#endif /* SWIGPYTHON */ + //------------------------------------------------------------------------------ // Decoder specific @@ -76,14 +95,19 @@ int WebPGetEncoderVersion(void); #ifdef SWIGJAVA %{ #define FillMeInAsSizeCannotBeDeterminedAutomatically \ - (result ? ReturnedBufferSize(__FUNCTION__, arg3, arg4) : 0) + (result ? (jint)ReturnedBufferSize(__FUNCTION__, arg3, arg4) : 0) +%} +#endif /* SWIGJAVA */ -static jint ReturnedBufferSize( +#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 }, @@ -97,12 +121,20 @@ static jint ReturnedBufferSize( { "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 }, +#endif { NULL, 0 } }; const struct sizemap* p; - jint size = -1; + size_t size = 0; - for (p = size_map; p->function; p++) { + for (p = size_map; p->function; ++p) { if (!strcmp(function, p->function)) { size = *width * *height * p->size_multiplier; break; @@ -112,10 +144,9 @@ static jint ReturnedBufferSize( return size; } %} -#endif /* SWIGJAVA */ +#endif /* SWIGJAVA || SWIGPYTHON */ %{ - typedef size_t (*WebPEncodeFunction)(const uint8_t* rgb, int width, int height, int stride, float quality_factor, uint8_t** output); diff --git a/swig/libwebp.py b/swig/libwebp.py new file mode 100644 index 00000000..fde96bb7 --- /dev/null +++ b/swig/libwebp.py @@ -0,0 +1,136 @@ +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 2.0.4 +# +# 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 +if 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 + if fp is not None: + try: + _mod = imp.load_module('_libwebp', fp, pathname, description) + finally: + fp.close() + return _mod + _libwebp = swig_import_helper() + del swig_import_helper +else: + import _libwebp +del version_info +try: + _swig_property = property +except NameError: + pass # Python < 2.2 doesn't have 'property'. +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): + 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(name) + +def _swig_repr(self): + try: strthis = "proxy of " + self.this.__repr__() + except: strthis = "" + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + +try: + _object = object + _newclass = 1 +except AttributeError: + class _object : pass + _newclass = 0 + + + +def WebPGetDecoderVersion(): + return _libwebp.WebPGetDecoderVersion() +WebPGetDecoderVersion = _libwebp.WebPGetDecoderVersion + +def WebPGetInfo(*args): + return _libwebp.WebPGetInfo(*args) +WebPGetInfo = _libwebp.WebPGetInfo + +def WebPDecodeRGB(*args): + return _libwebp.WebPDecodeRGB(*args) +WebPDecodeRGB = _libwebp.WebPDecodeRGB + +def WebPDecodeRGBA(*args): + return _libwebp.WebPDecodeRGBA(*args) +WebPDecodeRGBA = _libwebp.WebPDecodeRGBA + +def WebPDecodeARGB(*args): + return _libwebp.WebPDecodeARGB(*args) +WebPDecodeARGB = _libwebp.WebPDecodeARGB + +def WebPDecodeBGR(*args): + return _libwebp.WebPDecodeBGR(*args) +WebPDecodeBGR = _libwebp.WebPDecodeBGR + +def WebPDecodeBGRA(*args): + return _libwebp.WebPDecodeBGRA(*args) +WebPDecodeBGRA = _libwebp.WebPDecodeBGRA + +def WebPGetEncoderVersion(): + return _libwebp.WebPGetEncoderVersion() +WebPGetEncoderVersion = _libwebp.WebPGetEncoderVersion + +def wrap_WebPEncodeRGB(*args): + return _libwebp.wrap_WebPEncodeRGB(*args) +wrap_WebPEncodeRGB = _libwebp.wrap_WebPEncodeRGB + +def wrap_WebPEncodeBGR(*args): + return _libwebp.wrap_WebPEncodeBGR(*args) +wrap_WebPEncodeBGR = _libwebp.wrap_WebPEncodeBGR + +def wrap_WebPEncodeRGBA(*args): + return _libwebp.wrap_WebPEncodeRGBA(*args) +wrap_WebPEncodeRGBA = _libwebp.wrap_WebPEncodeRGBA + +def wrap_WebPEncodeBGRA(*args): + return _libwebp.wrap_WebPEncodeBGRA(*args) +wrap_WebPEncodeBGRA = _libwebp.wrap_WebPEncodeBGRA + +def wrap_WebPEncodeLosslessRGB(*args): + return _libwebp.wrap_WebPEncodeLosslessRGB(*args) +wrap_WebPEncodeLosslessRGB = _libwebp.wrap_WebPEncodeLosslessRGB + +def wrap_WebPEncodeLosslessBGR(*args): + return _libwebp.wrap_WebPEncodeLosslessBGR(*args) +wrap_WebPEncodeLosslessBGR = _libwebp.wrap_WebPEncodeLosslessBGR + +def wrap_WebPEncodeLosslessRGBA(*args): + return _libwebp.wrap_WebPEncodeLosslessRGBA(*args) +wrap_WebPEncodeLosslessRGBA = _libwebp.wrap_WebPEncodeLosslessRGBA + +def wrap_WebPEncodeLosslessBGRA(*args): + return _libwebp.wrap_WebPEncodeLosslessBGRA(*args) +wrap_WebPEncodeLosslessBGRA = _libwebp.wrap_WebPEncodeLosslessBGRA +# This file is compatible with both classic and new-style classes. + + diff --git a/swig/libwebp_java_wrap.c b/swig/libwebp_java_wrap.c index fd5821a9..1ba22925 100644 --- a/swig/libwebp_java_wrap.c +++ b/swig/libwebp_java_wrap.c @@ -813,14 +813,16 @@ jdoubleArray SWIG_JavaArrayOutDouble (JNIEnv *jenv, double *result, jsize sz) { #define FillMeInAsSizeCannotBeDeterminedAutomatically \ - (result ? ReturnedBufferSize(__FUNCTION__, arg3, arg4) : 0) + (result ? (jint)ReturnedBufferSize(__FUNCTION__, arg3, arg4) : 0) -static jint ReturnedBufferSize( + +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 }, @@ -834,12 +836,20 @@ static jint ReturnedBufferSize( { "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 }, +#endif { NULL, 0 } }; const struct sizemap* p; - jint size = -1; + size_t size = 0; - for (p = size_map; p->function; p++) { + for (p = size_map; p->function; ++p) { if (!strcmp(function, p->function)) { size = *width * *height * p->size_multiplier; break; @@ -850,7 +860,6 @@ static jint ReturnedBufferSize( } - typedef size_t (*WebPEncodeFunction)(const uint8_t* rgb, int width, int height, int stride, float quality_factor, uint8_t** output); diff --git a/swig/libwebp_python_wrap.c b/swig/libwebp_python_wrap.c new file mode 100644 index 00000000..4c32bed0 --- /dev/null +++ b/swig/libwebp_python_wrap.c @@ -0,0 +1,5257 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 2.0.4 + * + * 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 SWIGPYTHON +#define SWIG_PYTHON_DIRECTOR_NO_VTABLE + +/* ----------------------------------------------------------------------------- + * 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 + + + +/* Python.h has to appear first */ +#include + +/* ----------------------------------------------------------------------------- + * swigrun.swg + * + * This file contains generic C API SWIG runtime support for pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "4" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the SWIG runtime code. + In 99.9% of the cases, SWIG just needs to declare them as 'static'. + + But only do this if strictly necessary, ie, if you have problems + with your compiler or suchlike. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 +#define SWIG_CAST_NEW_MEMORY 0x2 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The SWIG conversion methods, as ConvertPtr, return an integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old versions of SWIG, code such as the following was usually written: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + which is the same really, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + also requires SWIG_ConvertPtr to return new result values, such as + + int SWIG_ConvertPtr(obj, ptr,...) { + if () { + if () { + *ptr = ; + return SWIG_NEWOBJ; + } else { + *ptr = ; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + SWIG errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() +*/ + +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *, int *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store information on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class" == "Class", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + } + return (int)((l1 - f1) - (l2 - f2)); +} + +/* + Check type equivalence in a name list like ||... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like ||... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (strcmp(iter->type->name, c) == 0) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; +} + +/* + Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { + if (ty) { + swig_cast_info *iter = ty->cast; + while (iter) { + if (iter->type == from) { + if (iter == ty->cast) + return iter; + /* Move iter to the top of the linked list */ + iter->prev->next = iter->next; + if (iter->next) + iter->next->prev = iter->prev; + iter->next = ty->cast; + iter->prev = 0; + if (ty->cast) ty->cast->prev = iter; + ty->cast = iter; + return iter; + } + iter = iter->next; + } + } + return 0; +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* 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 + + + +/* Compatibility macros for Python 3 */ +#if PY_VERSION_HEX >= 0x03000000 + +#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) +#define PyInt_Check(x) PyLong_Check(x) +#define PyInt_AsLong(x) PyLong_AsLong(x) +#define PyInt_FromLong(x) PyLong_FromLong(x) +#define PyString_Check(name) PyBytes_Check(name) +#define PyString_FromString(x) PyUnicode_FromString(x) +#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) +#define PyString_AsString(str) PyBytes_AsString(str) +#define PyString_Size(str) PyBytes_Size(str) +#define PyString_InternFromString(key) PyUnicode_InternFromString(key) +#define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE +#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x) +#define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x) + +#endif + +#ifndef Py_TYPE +# define Py_TYPE(op) ((op)->ob_type) +#endif + +/* SWIG APIs for compatibility of both Python 2 & 3 */ + +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_Python_str_FromFormat PyUnicode_FromFormat +#else +# define SWIG_Python_str_FromFormat PyString_FromFormat +#endif + + +/* Warning: This function will allocate a new string in Python 3, + * so please call SWIG_Python_str_DelForPy3(x) to free the space. + */ +SWIGINTERN char* +SWIG_Python_str_AsChar(PyObject *str) +{ +#if PY_VERSION_HEX >= 0x03000000 + char *cstr; + char *newstr; + Py_ssize_t len; + str = PyUnicode_AsUTF8String(str); + PyBytes_AsStringAndSize(str, &cstr, &len); + newstr = (char *) malloc(len+1); + memcpy(newstr, cstr, len+1); + Py_XDECREF(str); + return newstr; +#else + return PyString_AsString(str); +#endif +} + +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) +#else +# define SWIG_Python_str_DelForPy3(x) +#endif + + +SWIGINTERN PyObject* +SWIG_Python_str_FromChar(const char *c) +{ +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_FromString(c); +#else + return PyString_FromString(c); +#endif +} + +/* Add PyOS_snprintf for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# define PyOS_snprintf _snprintf +# else +# define PyOS_snprintf snprintf +# endif +#endif + +/* A crude PyString_FromFormat implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 + +#ifndef SWIG_PYBUFFER_SIZE +# define SWIG_PYBUFFER_SIZE 1024 +#endif + +static PyObject * +PyString_FromFormat(const char *fmt, ...) { + va_list ap; + char buf[SWIG_PYBUFFER_SIZE * 2]; + int res; + va_start(ap, fmt); + res = vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); +} +#endif + +/* Add PyObject_Del for old Pythons */ +#if PY_VERSION_HEX < 0x01060000 +# define PyObject_Del(op) PyMem_DEL((op)) +#endif +#ifndef PyObject_DEL +# define PyObject_DEL PyObject_Del +#endif + +/* A crude PyExc_StopIteration exception for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +# ifndef PyExc_StopIteration +# define PyExc_StopIteration PyExc_RuntimeError +# endif +# ifndef PyObject_GenericGetAttr +# define PyObject_GenericGetAttr 0 +# endif +#endif + +/* Py_NotImplemented is defined in 2.1 and up. */ +#if PY_VERSION_HEX < 0x02010000 +# ifndef Py_NotImplemented +# define Py_NotImplemented PyExc_RuntimeError +# endif +#endif + +/* A crude PyString_AsStringAndSize implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02010000 +# ifndef PyString_AsStringAndSize +# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} +# endif +#endif + +/* PySequence_Size for old Pythons */ +#if PY_VERSION_HEX < 0x02000000 +# ifndef PySequence_Size +# define PySequence_Size PySequence_Length +# endif +#endif + +/* PyBool_FromLong for old Pythons */ +#if PY_VERSION_HEX < 0x02030000 +static +PyObject *PyBool_FromLong(long ok) +{ + PyObject *result = ok ? Py_True : Py_False; + Py_INCREF(result); + return result; +} +#endif + +/* Py_ssize_t for old Pythons */ +/* This code is as recommended by: */ +/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ +#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) +typedef int Py_ssize_t; +# define PY_SSIZE_T_MAX INT_MAX +# define PY_SSIZE_T_MIN INT_MIN +typedef inquiry lenfunc; +typedef intargfunc ssizeargfunc; +typedef intintargfunc ssizessizeargfunc; +typedef intobjargproc ssizeobjargproc; +typedef intintobjargproc ssizessizeobjargproc; +typedef getreadbufferproc readbufferproc; +typedef getwritebufferproc writebufferproc; +typedef getsegcountproc segcountproc; +typedef getcharbufferproc charbufferproc; +static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc)) +{ + long result = 0; + PyObject *i = PyNumber_Int(x); + if (i) { + result = PyInt_AsLong(i); + Py_DECREF(i); + } + return result; +} +#endif + +#if PY_VERSION_HEX < 0x02040000 +#define Py_VISIT(op) \ + do { \ + if (op) { \ + int vret = visit((op), arg); \ + if (vret) \ + return vret; \ + } \ + } while (0) +#endif + +#if PY_VERSION_HEX < 0x02030000 +typedef struct { + PyTypeObject type; + PyNumberMethods as_number; + PyMappingMethods as_mapping; + PySequenceMethods as_sequence; + PyBufferProcs as_buffer; + PyObject *name, *slots; +} PyHeapTypeObject; +#endif + +#if PY_VERSION_HEX < 0x02030000 +typedef destructor freefunc; +#endif + +#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \ + (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \ + (PY_MAJOR_VERSION > 3)) +# define SWIGPY_USE_CAPSULE +# define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME) +#endif + +#if PY_VERSION_HEX < 0x03020000 +#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) +#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) +#endif + +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIME PyObject* +SWIG_Python_ErrorType(int code) { + PyObject* type = 0; + switch(code) { + case SWIG_MemoryError: + type = PyExc_MemoryError; + break; + case SWIG_IOError: + type = PyExc_IOError; + break; + case SWIG_RuntimeError: + type = PyExc_RuntimeError; + break; + case SWIG_IndexError: + type = PyExc_IndexError; + break; + case SWIG_TypeError: + type = PyExc_TypeError; + break; + case SWIG_DivisionByZero: + type = PyExc_ZeroDivisionError; + break; + case SWIG_OverflowError: + type = PyExc_OverflowError; + break; + case SWIG_SyntaxError: + type = PyExc_SyntaxError; + break; + case SWIG_ValueError: + type = PyExc_ValueError; + break; + case SWIG_SystemError: + type = PyExc_SystemError; + break; + case SWIG_AttributeError: + type = PyExc_AttributeError; + break; + default: + type = PyExc_RuntimeError; + } + return type; +} + + +SWIGRUNTIME void +SWIG_Python_AddErrorMsg(const char* mesg) +{ + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + + if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); + if (value) { + char *tmp; + PyObject *old_str = PyObject_Str(value); + PyErr_Clear(); + Py_XINCREF(type); + + PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(old_str); + Py_DECREF(value); + } else { + PyErr_SetString(PyExc_RuntimeError, mesg); + } +} + +#if defined(SWIG_PYTHON_NO_THREADS) +# if defined(SWIG_PYTHON_THREADS) +# undef SWIG_PYTHON_THREADS +# endif +#endif +#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ +# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) +# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ +# define SWIG_PYTHON_USE_GIL +# endif +# endif +# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ +# ifndef SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() +# endif +# ifdef __cplusplus /* C++ code */ + class SWIG_Python_Thread_Block { + bool status; + PyGILState_STATE state; + public: + void end() { if (status) { PyGILState_Release(state); status = false;} } + SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} + ~SWIG_Python_Thread_Block() { end(); } + }; + class SWIG_Python_Thread_Allow { + bool status; + PyThreadState *save; + public: + void end() { if (status) { PyEval_RestoreThread(save); status = false; }} + SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} + ~SWIG_Python_Thread_Allow() { end(); } + }; +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block +# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow +# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() +# else /* C code */ +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() +# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() +# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) +# endif +# else /* Old thread way, not implemented, user must provide it */ +# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) +# define SWIG_PYTHON_INITIALIZE_THREADS +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) +# define SWIG_PYTHON_THREAD_END_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# endif +# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) +# define SWIG_PYTHON_THREAD_END_ALLOW +# endif +# endif +#else /* No thread support */ +# define SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# define SWIG_PYTHON_THREAD_END_BLOCK +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# define SWIG_PYTHON_THREAD_END_ALLOW +#endif + +/* ----------------------------------------------------------------------------- + * Python API portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* ----------------------------------------------------------------------------- + * Constant declarations + * ----------------------------------------------------------------------------- */ + +/* Constant Types */ +#define SWIG_PY_POINTER 4 +#define SWIG_PY_BINARY 5 + +/* Constant information structure */ +typedef struct swig_const_info { + int type; + char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_const_info; + + +/* ----------------------------------------------------------------------------- + * Wrapper of PyInstanceMethod_New() used in Python 3 + * It is exported to the generated module, used for -fastproxy + * ----------------------------------------------------------------------------- */ +#if PY_VERSION_HEX >= 0x03000000 +SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func) +{ + return PyInstanceMethod_New(func); +} +#else +SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func)) +{ + return NULL; +} +#endif + +#ifdef __cplusplus +} +#endif + + +/* ----------------------------------------------------------------------------- + * pyrun.swg + * + * This file contains the runtime support for Python modules + * and includes code for managing global variables and pointer + * type checking. + * + * ----------------------------------------------------------------------------- */ + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) +#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) +#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) + +#ifdef SWIGPYTHON_BUILTIN +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags) +#else +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) +#endif + +#define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) + +#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) +#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) +#define swig_owntype int + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) +#define SWIG_NewClientData(obj) SwigPyClientData_New(obj) + +#define SWIG_SetErrorObj SWIG_Python_SetErrorObj +#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg +#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) +#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail + + +/* Runtime API implementation */ + +/* Error manipulation */ + +SWIGINTERN void +SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetObject(errtype, obj); + Py_DECREF(obj); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +SWIGINTERN void +SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(errtype, (char *) msg); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) + +/* Set a constant value */ + +#if defined(SWIGPYTHON_BUILTIN) + +SWIGINTERN void +SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { + PyObject *s = PyString_InternFromString(key); + PyList_Append(seq, s); + Py_DECREF(s); +} + +SWIGINTERN void +SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { + PyDict_SetItemString(d, (char *)name, obj); + Py_DECREF(obj); + if (public_interface) + SwigPyBuiltin_AddPublicSymbol(public_interface, name); +} + +#else + +SWIGINTERN void +SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { + PyDict_SetItemString(d, (char *)name, obj); + Py_DECREF(obj); +} + +#endif + +/* Append a value to the result obj */ + +SWIGINTERN PyObject* +SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { +#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyList_Check(result)) { + PyObject *o2 = result; + result = PyList_New(1); + PyList_SetItem(result, 0, o2); + } + PyList_Append(result,obj); + Py_DECREF(obj); + } + return result; +#else + PyObject* o2; + PyObject* o3; + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyTuple_Check(result)) { + o2 = result; + result = PyTuple_New(1); + PyTuple_SET_ITEM(result, 0, o2); + } + o3 = PyTuple_New(1); + PyTuple_SET_ITEM(o3, 0, obj); + o2 = result; + result = PySequence_Concat(o2, o3); + Py_DECREF(o2); + Py_DECREF(o3); + } + return result; +#endif +} + +/* Unpack the argument tuple */ + +SWIGINTERN int +SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) +{ + if (!args) { + if (!min && !max) { + return 1; + } else { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", + name, (min == max ? "" : "at least "), (int)min); + return 0; + } + } + if (!PyTuple_Check(args)) { + if (min <= 1 && max >= 1) { + register int i; + objs[0] = args; + for (i = 1; i < max; ++i) { + objs[i] = 0; + } + return 2; + } + PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); + return 0; + } else { + register Py_ssize_t l = PyTuple_GET_SIZE(args); + if (l < min) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at least "), (int)min, (int)l); + return 0; + } else if (l > max) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at most "), (int)max, (int)l); + return 0; + } else { + register int i; + for (i = 0; i < l; ++i) { + objs[i] = PyTuple_GET_ITEM(args, i); + } + for (; l < max; ++l) { + objs[l] = 0; + } + return i + 1; + } + } +} + +/* A functor is a function object with one single object argument */ +#if PY_VERSION_HEX >= 0x02020000 +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); +#else +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); +#endif + +/* + Helper for static pointer initialization for both C and C++ code, for example + static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); +*/ +#ifdef __cplusplus +#define SWIG_STATIC_POINTER(var) var +#else +#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var +#endif + +/* ----------------------------------------------------------------------------- + * Pointer declarations + * ----------------------------------------------------------------------------- */ + +/* Flags for new pointer objects */ +#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) +#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) + +#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) + +#define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) +#define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) + +#ifdef __cplusplus +extern "C" { +#endif + +/* How to access Py_None */ +#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# ifndef SWIG_PYTHON_NO_BUILD_NONE +# ifndef SWIG_PYTHON_BUILD_NONE +# define SWIG_PYTHON_BUILD_NONE +# endif +# endif +#endif + +#ifdef SWIG_PYTHON_BUILD_NONE +# ifdef Py_None +# undef Py_None +# define Py_None SWIG_Py_None() +# endif +SWIGRUNTIMEINLINE PyObject * +_SWIG_Py_None(void) +{ + PyObject *none = Py_BuildValue((char*)""); + Py_DECREF(none); + return none; +} +SWIGRUNTIME PyObject * +SWIG_Py_None(void) +{ + static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); + return none; +} +#endif + +/* The python void return value */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Py_Void(void) +{ + PyObject *none = Py_None; + Py_INCREF(none); + return none; +} + +/* SwigPyClientData */ + +typedef struct { + PyObject *klass; + PyObject *newraw; + PyObject *newargs; + PyObject *destroy; + int delargs; + int implicitconv; + PyTypeObject *pytype; +} SwigPyClientData; + +SWIGRUNTIMEINLINE int +SWIG_Python_CheckImplicit(swig_type_info *ty) +{ + SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; + return data ? data->implicitconv : 0; +} + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_ExceptionType(swig_type_info *desc) { + SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; + PyObject *klass = data ? data->klass : 0; + return (klass ? klass : PyExc_RuntimeError); +} + + +SWIGRUNTIME SwigPyClientData * +SwigPyClientData_New(PyObject* obj) +{ + if (!obj) { + return 0; + } else { + SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); + /* the klass element */ + data->klass = obj; + Py_INCREF(data->klass); + /* the newraw method and newargs arguments used to create a new raw instance */ + if (PyClass_Check(obj)) { + data->newraw = 0; + data->newargs = obj; + Py_INCREF(obj); + } else { +#if (PY_VERSION_HEX < 0x02020000) + data->newraw = 0; +#else + data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); +#endif + if (data->newraw) { + Py_INCREF(data->newraw); + data->newargs = PyTuple_New(1); + PyTuple_SetItem(data->newargs, 0, obj); + } else { + data->newargs = obj; + } + Py_INCREF(data->newargs); + } + /* the destroy method, aka as the C++ delete method */ + data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); + if (PyErr_Occurred()) { + PyErr_Clear(); + data->destroy = 0; + } + if (data->destroy) { + int flags; + Py_INCREF(data->destroy); + flags = PyCFunction_GET_FLAGS(data->destroy); +#ifdef METH_O + data->delargs = !(flags & (METH_O)); +#else + data->delargs = 0; +#endif + } else { + data->delargs = 0; + } + data->implicitconv = 0; + data->pytype = 0; + return data; + } +} + +SWIGRUNTIME void +SwigPyClientData_Del(SwigPyClientData *data) { + Py_XDECREF(data->newraw); + Py_XDECREF(data->newargs); + Py_XDECREF(data->destroy); +} + +/* =============== SwigPyObject =====================*/ + +typedef struct { + PyObject_HEAD + void *ptr; + swig_type_info *ty; + int own; + PyObject *next; +#ifdef SWIGPYTHON_BUILTIN + PyObject *dict; +#endif +} SwigPyObject; + +SWIGRUNTIME PyObject * +SwigPyObject_long(SwigPyObject *v) +{ + return PyLong_FromVoidPtr(v->ptr); +} + +SWIGRUNTIME PyObject * +SwigPyObject_format(const char* fmt, SwigPyObject *v) +{ + PyObject *res = NULL; + PyObject *args = PyTuple_New(1); + if (args) { + if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { + PyObject *ofmt = SWIG_Python_str_FromChar(fmt); + if (ofmt) { +#if PY_VERSION_HEX >= 0x03000000 + res = PyUnicode_Format(ofmt,args); +#else + res = PyString_Format(ofmt,args); +#endif + Py_DECREF(ofmt); + } + Py_DECREF(args); + } + } + return res; +} + +SWIGRUNTIME PyObject * +SwigPyObject_oct(SwigPyObject *v) +{ + return SwigPyObject_format("%o",v); +} + +SWIGRUNTIME PyObject * +SwigPyObject_hex(SwigPyObject *v) +{ + return SwigPyObject_format("%x",v); +} + +SWIGRUNTIME PyObject * +#ifdef METH_NOARGS +SwigPyObject_repr(SwigPyObject *v) +#else +SwigPyObject_repr(SwigPyObject *v, PyObject *args) +#endif +{ + const char *name = SWIG_TypePrettyName(v->ty); + PyObject *repr = SWIG_Python_str_FromFormat("", name, (void *)v); + if (v->next) { +# ifdef METH_NOARGS + PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); +# else + PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); +# endif +# if PY_VERSION_HEX >= 0x03000000 + PyObject *joined = PyUnicode_Concat(repr, nrep); + Py_DecRef(repr); + Py_DecRef(nrep); + repr = joined; +# else + PyString_ConcatAndDel(&repr,nrep); +# endif + } + return repr; +} + +SWIGRUNTIME int +SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) +{ + char *str; +#ifdef METH_NOARGS + PyObject *repr = SwigPyObject_repr(v); +#else + PyObject *repr = SwigPyObject_repr(v, NULL); +#endif + if (repr) { + str = SWIG_Python_str_AsChar(repr); + fputs(str, fp); + SWIG_Python_str_DelForPy3(str); + Py_DECREF(repr); + return 0; + } else { + return 1; + } +} + +SWIGRUNTIME PyObject * +SwigPyObject_str(SwigPyObject *v) +{ + char result[SWIG_BUFFER_SIZE]; + return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? + SWIG_Python_str_FromChar(result) : 0; +} + +SWIGRUNTIME int +SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) +{ + void *i = v->ptr; + void *j = w->ptr; + return (i < j) ? -1 : ((i > j) ? 1 : 0); +} + +/* Added for Python 3.x, would it also be useful for Python 2.x? */ +SWIGRUNTIME PyObject* +SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) +{ + PyObject* res; + if( op != Py_EQ && op != Py_NE ) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0); + return res; +} + + +SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); + +#ifdef SWIGPYTHON_BUILTIN +static swig_type_info *SwigPyObject_stype = 0; +SWIGRUNTIME PyTypeObject* +SwigPyObject_type(void) { + SwigPyClientData *cd; + assert(SwigPyObject_stype); + cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; + assert(cd); + assert(cd->pytype); + return cd->pytype; +} +#else +SWIGRUNTIME PyTypeObject* +SwigPyObject_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); + return type; +} +#endif + +SWIGRUNTIMEINLINE int +SwigPyObject_Check(PyObject *op) { +#ifdef SWIGPYTHON_BUILTIN + PyTypeObject *target_tp = SwigPyObject_type(); + if (PyType_IsSubtype(op->ob_type, target_tp)) + return 1; + return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0); +#else + return (Py_TYPE(op) == SwigPyObject_type()) + || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); +#endif +} + +SWIGRUNTIME PyObject * +SwigPyObject_New(void *ptr, swig_type_info *ty, int own); + +SWIGRUNTIME void +SwigPyObject_dealloc(PyObject *v) +{ + SwigPyObject *sobj = (SwigPyObject *) v; + PyObject *next = sobj->next; + if (sobj->own == SWIG_POINTER_OWN) { + swig_type_info *ty = sobj->ty; + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + PyObject *destroy = data ? data->destroy : 0; + if (destroy) { + /* destroy is always a VARARGS method */ + PyObject *res; + if (data->delargs) { + /* we need to create a temporary object to carry the destroy operation */ + PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); + res = SWIG_Python_CallFunctor(destroy, tmp); + Py_DECREF(tmp); + } else { + PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); + PyObject *mself = PyCFunction_GET_SELF(destroy); + res = ((*meth)(mself, v)); + } + Py_XDECREF(res); + } +#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) + else { + const char *name = SWIG_TypePrettyName(ty); + printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); + } +#endif + } + Py_XDECREF(next); + PyObject_DEL(v); +} + +SWIGRUNTIME PyObject* +SwigPyObject_append(PyObject* v, PyObject* next) +{ + SwigPyObject *sobj = (SwigPyObject *) v; +#ifndef METH_O + PyObject *tmp = 0; + if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; + next = tmp; +#endif + if (!SwigPyObject_Check(next)) { + return NULL; + } + sobj->next = next; + Py_INCREF(next); + return SWIG_Py_Void(); +} + +SWIGRUNTIME PyObject* +#ifdef METH_NOARGS +SwigPyObject_next(PyObject* v) +#else +SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + SwigPyObject *sobj = (SwigPyObject *) v; + if (sobj->next) { + Py_INCREF(sobj->next); + return sobj->next; + } else { + return SWIG_Py_Void(); + } +} + +SWIGINTERN PyObject* +#ifdef METH_NOARGS +SwigPyObject_disown(PyObject *v) +#else +SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + SwigPyObject *sobj = (SwigPyObject *)v; + sobj->own = 0; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +#ifdef METH_NOARGS +SwigPyObject_acquire(PyObject *v) +#else +SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + SwigPyObject *sobj = (SwigPyObject *)v; + sobj->own = SWIG_POINTER_OWN; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +SwigPyObject_own(PyObject *v, PyObject *args) +{ + PyObject *val = 0; +#if (PY_VERSION_HEX < 0x02020000) + if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) +#else + if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) +#endif + { + return NULL; + } + else + { + SwigPyObject *sobj = (SwigPyObject *)v; + PyObject *obj = PyBool_FromLong(sobj->own); + if (val) { +#ifdef METH_NOARGS + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v); + } else { + SwigPyObject_disown(v); + } +#else + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v,args); + } else { + SwigPyObject_disown(v,args); + } +#endif + } + return obj; + } +} + +#ifdef METH_O +static PyMethodDef +swigobject_methods[] = { + {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, + {0, 0, 0, 0} +}; +#else +static PyMethodDef +swigobject_methods[] = { + {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, + {0, 0, 0, 0} +}; +#endif + +#if PY_VERSION_HEX < 0x02020000 +SWIGINTERN PyObject * +SwigPyObject_getattr(SwigPyObject *sobj,char *name) +{ + return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); +} +#endif + +SWIGRUNTIME PyTypeObject* +SwigPyObject_TypeOnce(void) { + static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; + + static PyNumberMethods SwigPyObject_as_number = { + (binaryfunc)0, /*nb_add*/ + (binaryfunc)0, /*nb_subtract*/ + (binaryfunc)0, /*nb_multiply*/ + /* nb_divide removed in Python 3 */ +#if PY_VERSION_HEX < 0x03000000 + (binaryfunc)0, /*nb_divide*/ +#endif + (binaryfunc)0, /*nb_remainder*/ + (binaryfunc)0, /*nb_divmod*/ + (ternaryfunc)0,/*nb_power*/ + (unaryfunc)0, /*nb_negative*/ + (unaryfunc)0, /*nb_positive*/ + (unaryfunc)0, /*nb_absolute*/ + (inquiry)0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ +#if PY_VERSION_HEX < 0x03000000 + 0, /*nb_coerce*/ +#endif + (unaryfunc)SwigPyObject_long, /*nb_int*/ +#if PY_VERSION_HEX < 0x03000000 + (unaryfunc)SwigPyObject_long, /*nb_long*/ +#else + 0, /*nb_reserved*/ +#endif + (unaryfunc)0, /*nb_float*/ +#if PY_VERSION_HEX < 0x03000000 + (unaryfunc)SwigPyObject_oct, /*nb_oct*/ + (unaryfunc)SwigPyObject_hex, /*nb_hex*/ +#endif +#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ +#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ +#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ +#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ + 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ +#endif + }; + + static PyTypeObject swigpyobject_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { + /* PyObject header changed in Python 3 */ +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + (char *)"SwigPyObject", /* tp_name */ + sizeof(SwigPyObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyObject_dealloc, /* tp_dealloc */ + (printfunc)SwigPyObject_print, /* tp_print */ +#if PY_VERSION_HEX < 0x02020000 + (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ +#else + (getattrfunc)0, /* tp_getattr */ +#endif + (setattrfunc)0, /* tp_setattr */ +#if PY_VERSION_HEX >= 0x03000000 + 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ +#else + (cmpfunc)SwigPyObject_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyObject_repr, /* tp_repr */ + &SwigPyObject_as_number, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)SwigPyObject_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigobject_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0, /* tp_iter */ + 0, /* tp_iternext */ + swigobject_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#if PY_VERSION_HEX >= 0x02060000 + 0, /* tp_version */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + swigpyobject_type = tmp; + type_init = 1; +#if PY_VERSION_HEX < 0x02020000 + swigpyobject_type.ob_type = &PyType_Type; +#else + if (PyType_Ready(&swigpyobject_type) < 0) + return NULL; +#endif + } + return &swigpyobject_type; +} + +SWIGRUNTIME PyObject * +SwigPyObject_New(void *ptr, swig_type_info *ty, int own) +{ + SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); + if (sobj) { + sobj->ptr = ptr; + sobj->ty = ty; + sobj->own = own; + sobj->next = 0; + } + return (PyObject *)sobj; +} + +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Packed type, and use it instead of string + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *pack; + swig_type_info *ty; + size_t size; +} SwigPyPacked; + +SWIGRUNTIME int +SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) +{ + char result[SWIG_BUFFER_SIZE]; + fputs("pack, v->size, 0, sizeof(result))) { + fputs("at ", fp); + fputs(result, fp); + } + fputs(v->ty->name,fp); + fputs(">", fp); + return 0; +} + +SWIGRUNTIME PyObject * +SwigPyPacked_repr(SwigPyPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + return SWIG_Python_str_FromFormat("", result, v->ty->name); + } else { + return SWIG_Python_str_FromFormat("", v->ty->name); + } +} + +SWIGRUNTIME PyObject * +SwigPyPacked_str(SwigPyPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ + return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); + } else { + return SWIG_Python_str_FromChar(v->ty->name); + } +} + +SWIGRUNTIME int +SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) +{ + size_t i = v->size; + size_t j = w->size; + int s = (i < j) ? -1 : ((i > j) ? 1 : 0); + return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); +} + +SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); + +SWIGRUNTIME PyTypeObject* +SwigPyPacked_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); + return type; +} + +SWIGRUNTIMEINLINE int +SwigPyPacked_Check(PyObject *op) { + return ((op)->ob_type == SwigPyPacked_TypeOnce()) + || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); +} + +SWIGRUNTIME void +SwigPyPacked_dealloc(PyObject *v) +{ + if (SwigPyPacked_Check(v)) { + SwigPyPacked *sobj = (SwigPyPacked *) v; + free(sobj->pack); + } + PyObject_DEL(v); +} + +SWIGRUNTIME PyTypeObject* +SwigPyPacked_TypeOnce(void) { + static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; + static PyTypeObject swigpypacked_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { + /* PyObject header changed in Python 3 */ +#if PY_VERSION_HEX>=0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + (char *)"SwigPyPacked", /* tp_name */ + sizeof(SwigPyPacked), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ + (printfunc)SwigPyPacked_print, /* tp_print */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ +#if PY_VERSION_HEX>=0x03000000 + 0, /* tp_reserved in 3.0.1 */ +#else + (cmpfunc)SwigPyPacked_compare, /* tp_compare */ +#endif + (reprfunc)SwigPyPacked_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)SwigPyPacked_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigpacked_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#if PY_VERSION_HEX >= 0x02060000 + 0, /* tp_version */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + swigpypacked_type = tmp; + type_init = 1; +#if PY_VERSION_HEX < 0x02020000 + swigpypacked_type.ob_type = &PyType_Type; +#else + if (PyType_Ready(&swigpypacked_type) < 0) + return NULL; +#endif + } + return &swigpypacked_type; +} + +SWIGRUNTIME PyObject * +SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) +{ + SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); + if (sobj) { + void *pack = malloc(size); + if (pack) { + memcpy(pack, ptr, size); + sobj->pack = pack; + sobj->ty = ty; + sobj->size = size; + } else { + PyObject_DEL((PyObject *) sobj); + sobj = 0; + } + } + return (PyObject *) sobj; +} + +SWIGRUNTIME swig_type_info * +SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) +{ + if (SwigPyPacked_Check(obj)) { + SwigPyPacked *sobj = (SwigPyPacked *)obj; + if (sobj->size != size) return 0; + memcpy(ptr, sobj->pack, size); + return sobj->ty; + } else { + return 0; + } +} + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIMEINLINE PyObject * +_SWIG_This(void) +{ + return SWIG_Python_str_FromChar("this"); +} + +static PyObject *swig_this = NULL; + +SWIGRUNTIME PyObject * +SWIG_This(void) +{ + if (swig_this == NULL) + swig_this = _SWIG_This(); + return swig_this; +} + +/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ + +/* TODO: I don't know how to implement the fast getset in Python 3 right now */ +#if PY_VERSION_HEX>=0x03000000 +#define SWIG_PYTHON_SLOW_GETSET_THIS +#endif + +SWIGRUNTIME SwigPyObject * +SWIG_Python_GetSwigThis(PyObject *pyobj) +{ + PyObject *obj; + + if (SwigPyObject_Check(pyobj)) + return (SwigPyObject *) pyobj; + +#ifdef SWIGPYTHON_BUILTIN + (void)obj; +# ifdef PyWeakref_CheckProxy + if (PyWeakref_CheckProxy(pyobj)) { + pyobj = PyWeakref_GET_OBJECT(pyobj); + if (pyobj && SwigPyObject_Check(pyobj)) + return (SwigPyObject*) pyobj; + } +# endif + return NULL; +#else + + obj = 0; + +#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) + if (PyInstance_Check(pyobj)) { + obj = _PyInstance_Lookup(pyobj, SWIG_This()); + } else { + PyObject **dictptr = _PyObject_GetDictPtr(pyobj); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; + } else { +#ifdef PyWeakref_CheckProxy + if (PyWeakref_CheckProxy(pyobj)) { + PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); + return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; + } +#endif + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } + } + } +#else + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } +#endif + if (obj && !SwigPyObject_Check(obj)) { + /* a PyObject is called 'this', try to get the 'real this' + SwigPyObject from it */ + return SWIG_Python_GetSwigThis(obj); + } + return (SwigPyObject *)obj; +#endif +} + +/* Acquire a pointer value */ + +SWIGRUNTIME int +SWIG_Python_AcquirePtr(PyObject *obj, int own) { + if (own == SWIG_POINTER_OWN) { + SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); + if (sobj) { + int oldown = sobj->own; + sobj->own = own; + return oldown; + } + } + return 0; +} + +/* Convert a pointer value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { + int res; + SwigPyObject *sobj; + + if (!obj) + return SWIG_ERROR; + if (obj == Py_None) { + if (ptr) + *ptr = 0; + return SWIG_OK; + } + + res = SWIG_ERROR; + + sobj = SWIG_Python_GetSwigThis(obj); + if (own) + *own = 0; + while (sobj) { + void *vptr = sobj->ptr; + if (ty) { + swig_type_info *to = sobj->ty; + if (to == ty) { + /* no type cast needed */ + if (ptr) *ptr = vptr; + break; + } else { + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) { + sobj = (SwigPyObject *)sobj->next; + } else { + if (ptr) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ + if (own) + *own = *own | SWIG_CAST_NEW_MEMORY; + } + } + break; + } + } + } else { + if (ptr) *ptr = vptr; + break; + } + } + if (sobj) { + if (own) + *own = *own | sobj->own; + if (flags & SWIG_POINTER_DISOWN) { + sobj->own = 0; + } + res = SWIG_OK; + } else { + if (flags & SWIG_POINTER_IMPLICIT_CONV) { + SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + if (data && !data->implicitconv) { + PyObject *klass = data->klass; + if (klass) { + PyObject *impconv; + data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ + impconv = SWIG_Python_CallFunctor(klass, obj); + data->implicitconv = 0; + if (PyErr_Occurred()) { + PyErr_Clear(); + impconv = 0; + } + if (impconv) { + SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); + if (iobj) { + void *vptr; + res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); + if (SWIG_IsOK(res)) { + if (ptr) { + *ptr = vptr; + /* transfer the ownership to 'ptr' */ + iobj->own = 0; + res = SWIG_AddCast(res); + res = SWIG_AddNewMask(res); + } else { + res = SWIG_AddCast(res); + } + } + } + Py_DECREF(impconv); + } + } + } + } + } + return res; +} + +/* Convert a function ptr value */ + +SWIGRUNTIME int +SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { + if (!PyCFunction_Check(obj)) { + return SWIG_ConvertPtr(obj, ptr, ty, 0); + } else { + void *vptr = 0; + + /* here we get the method pointer for callbacks */ + const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; + if (desc) + desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; + if (!desc) + return SWIG_ERROR; + if (ty) { + swig_cast_info *tc = SWIG_TypeCheck(desc,ty); + if (tc) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } else { + return SWIG_ERROR; + } + } else { + *ptr = vptr; + } + return SWIG_OK; + } +} + +/* Convert a packed value value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { + swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); + if (!to) return SWIG_ERROR; + if (ty) { + if (to != ty) { + /* check type cast? */ + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) return SWIG_ERROR; + } + } + return SWIG_OK; +} + +/* ----------------------------------------------------------------------------- + * Create a new pointer object + * ----------------------------------------------------------------------------- */ + +/* + Create a new instance object, without calling __init__, and set the + 'this' attribute. +*/ + +SWIGRUNTIME PyObject* +SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) +{ +#if (PY_VERSION_HEX >= 0x02020000) + PyObject *inst = 0; + PyObject *newraw = data->newraw; + if (newraw) { + inst = PyObject_Call(newraw, data->newargs, NULL); + if (inst) { +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + PyDict_SetItem(dict, SWIG_This(), swig_this); + } + } +#else + PyObject *key = SWIG_This(); + PyObject_SetAttr(inst, key, swig_this); +#endif + } + } else { +#if PY_VERSION_HEX >= 0x03000000 + inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); + PyObject_SetAttr(inst, SWIG_This(), swig_this); + Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; +#else + PyObject *dict = PyDict_New(); + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); +#endif + } + return inst; +#else +#if (PY_VERSION_HEX >= 0x02010000) + PyObject *inst; + PyObject *dict = PyDict_New(); + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + return (PyObject *) inst; +#else + PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); + if (inst == NULL) { + return NULL; + } + inst->in_class = (PyClassObject *)data->newargs; + Py_INCREF(inst->in_class); + inst->in_dict = PyDict_New(); + if (inst->in_dict == NULL) { + Py_DECREF(inst); + return NULL; + } +#ifdef Py_TPFLAGS_HAVE_WEAKREFS + inst->in_weakreflist = NULL; +#endif +#ifdef Py_TPFLAGS_GC + PyObject_GC_Init(inst); +#endif + PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); + return (PyObject *) inst; +#endif +#endif +} + +SWIGRUNTIME void +SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) +{ + PyObject *dict; +#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + } + PyDict_SetItem(dict, SWIG_This(), swig_this); + return; + } +#endif + dict = PyObject_GetAttrString(inst, (char*)"__dict__"); + PyDict_SetItem(dict, SWIG_This(), swig_this); + Py_DECREF(dict); +} + + +SWIGINTERN PyObject * +SWIG_Python_InitShadowInstance(PyObject *args) { + PyObject *obj[2]; + if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { + return NULL; + } else { + SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); + if (sthis) { + SwigPyObject_append((PyObject*) sthis, obj[1]); + } else { + SWIG_Python_SetSwigThis(obj[0], obj[1]); + } + return SWIG_Py_Void(); + } +} + +/* Create a new pointer object */ + +SWIGRUNTIME PyObject * +SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) { + SwigPyClientData *clientdata; + PyObject * robj; + int own; + + if (!ptr) + return SWIG_Py_Void(); + + clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; + own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; + if (clientdata && clientdata->pytype) { + SwigPyObject *newobj; + if (flags & SWIG_BUILTIN_TP_INIT) { + newobj = (SwigPyObject*) self; + if (newobj->ptr) { + PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0); + while (newobj->next) + newobj = (SwigPyObject *) newobj->next; + newobj->next = next_self; + newobj = (SwigPyObject *)next_self; + } + } else { + newobj = PyObject_New(SwigPyObject, clientdata->pytype); + } + if (newobj) { + newobj->ptr = ptr; + newobj->ty = type; + newobj->own = own; + newobj->next = 0; +#ifdef SWIGPYTHON_BUILTIN + newobj->dict = 0; +#endif + return (PyObject*) newobj; + } + return SWIG_Py_Void(); + } + + assert(!(flags & SWIG_BUILTIN_TP_INIT)); + + robj = SwigPyObject_New(ptr, type, own); + if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { + PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); + if (inst) { + Py_DECREF(robj); + robj = inst; + } + } + return robj; +} + +/* Create a new packed object */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { + return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); +} + +/* -----------------------------------------------------------------------------* + * Get type list + * -----------------------------------------------------------------------------*/ + +#ifdef SWIG_LINK_RUNTIME +void *SWIG_ReturnGlobalTypeList(void *); +#endif + +SWIGRUNTIME swig_module_info * +SWIG_Python_GetModule(void) { + static void *type_pointer = (void *)0; + /* first check if module already created */ + if (!type_pointer) { +#ifdef SWIG_LINK_RUNTIME + type_pointer = SWIG_ReturnGlobalTypeList((void *)0); +#else +# ifdef SWIGPY_USE_CAPSULE + type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); +# else + type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); +# endif + if (PyErr_Occurred()) { + PyErr_Clear(); + type_pointer = (void *)0; + } +#endif + } + return (swig_module_info *) type_pointer; +} + +#if PY_MAJOR_VERSION < 2 +/* PyModule_AddObject function was introduced in Python 2.0. The following function + is copied out of Python/modsupport.c in python version 2.3.4 */ +SWIGINTERN int +PyModule_AddObject(PyObject *m, char *name, PyObject *o) +{ + PyObject *dict; + if (!PyModule_Check(m)) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs module as first arg"); + return SWIG_ERROR; + } + if (!o) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs non-NULL value"); + return SWIG_ERROR; + } + + dict = PyModule_GetDict(m); + if (dict == NULL) { + /* Internal error -- modules must have a dict! */ + PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", + PyModule_GetName(m)); + return SWIG_ERROR; + } + if (PyDict_SetItemString(dict, name, o)) + return SWIG_ERROR; + Py_DECREF(o); + return SWIG_OK; +} +#endif + +SWIGRUNTIME void +#ifdef SWIGPY_USE_CAPSULE +SWIG_Python_DestroyModule(PyObject *obj) +#else +SWIG_Python_DestroyModule(void *vptr) +#endif +{ +#ifdef SWIGPY_USE_CAPSULE + swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); +#else + swig_module_info *swig_module = (swig_module_info *) vptr; +#endif + swig_type_info **types = swig_module->types; + size_t i; + for (i =0; i < swig_module->size; ++i) { + swig_type_info *ty = types[i]; + if (ty->owndata) { + SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; + if (data) SwigPyClientData_Del(data); + } + } + Py_DECREF(SWIG_This()); + swig_this = NULL; +} + +SWIGRUNTIME void +SWIG_Python_SetModule(swig_module_info *swig_module) { +#if PY_VERSION_HEX >= 0x03000000 + /* Add a dummy module object into sys.modules */ + PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); +#else + static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ + PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); +#endif +#ifdef SWIGPY_USE_CAPSULE + PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); + if (pointer && module) { + PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); + } else { + Py_XDECREF(pointer); + } +#else + PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); + if (pointer && module) { + PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); + } else { + Py_XDECREF(pointer); + } +#endif +} + +/* The python cached type query */ +SWIGRUNTIME PyObject * +SWIG_Python_TypeCache(void) { + static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); + return cache; +} + +SWIGRUNTIME swig_type_info * +SWIG_Python_TypeQuery(const char *type) +{ + PyObject *cache = SWIG_Python_TypeCache(); + PyObject *key = SWIG_Python_str_FromChar(type); + PyObject *obj = PyDict_GetItem(cache, key); + swig_type_info *descriptor; + if (obj) { +#ifdef SWIGPY_USE_CAPSULE + descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); +#else + descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); +#endif + } else { + swig_module_info *swig_module = SWIG_Python_GetModule(); + descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); + if (descriptor) { +#ifdef SWIGPY_USE_CAPSULE + obj = PyCapsule_New((void*) descriptor, NULL, NULL); +#else + obj = PyCObject_FromVoidPtr(descriptor, NULL); +#endif + PyDict_SetItem(cache, key, obj); + Py_DECREF(obj); + } + } + Py_DECREF(key); + return descriptor; +} + +/* + For backward compatibility only +*/ +#define SWIG_POINTER_EXCEPTION 0 +#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) +#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) + +SWIGRUNTIME int +SWIG_Python_AddErrMesg(const char* mesg, int infront) +{ + if (PyErr_Occurred()) { + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + PyErr_Fetch(&type, &value, &traceback); + if (value) { + char *tmp; + PyObject *old_str = PyObject_Str(value); + Py_XINCREF(type); + PyErr_Clear(); + if (infront) { + PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); + } else { + PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); + } + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(old_str); + } + return 1; + } else { + return 0; + } +} + +SWIGRUNTIME int +SWIG_Python_ArgFail(int argnum) +{ + if (PyErr_Occurred()) { + /* add information about failing argument */ + char mesg[256]; + PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); + return SWIG_Python_AddErrMesg(mesg, 1); + } else { + return 0; + } +} + +SWIGRUNTIMEINLINE const char * +SwigPyObject_GetDesc(PyObject *self) +{ + SwigPyObject *v = (SwigPyObject *)self; + swig_type_info *ty = v ? v->ty : 0; + return ty ? ty->str : (char*)""; +} + +SWIGRUNTIME void +SWIG_Python_TypeError(const char *type, PyObject *obj) +{ + if (type) { +#if defined(SWIG_COBJECT_TYPES) + if (obj && SwigPyObject_Check(obj)) { + const char *otype = (const char *) SwigPyObject_GetDesc(obj); + if (otype) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", + type, otype); + return; + } + } else +#endif + { + const char *otype = (obj ? obj->ob_type->tp_name : 0); + if (otype) { + PyObject *str = PyObject_Str(obj); + const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; + if (cstr) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", + type, otype, cstr); + SWIG_Python_str_DelForPy3(cstr); + } else { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", + type, otype); + } + Py_XDECREF(str); + return; + } + } + PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); + } else { + PyErr_Format(PyExc_TypeError, "unexpected type is received"); + } +} + + +/* Convert a pointer value, signal an exception on a type mismatch */ +SWIGRUNTIME void * +SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { + void *result; + if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { + PyErr_Clear(); +#if SWIG_POINTER_EXCEPTION + if (flags) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + SWIG_Python_ArgFail(argnum); + } +#endif + } + return result; +} + +SWIGRUNTIME int +SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { + PyTypeObject *tp = obj->ob_type; + PyObject *descr; + PyObject *encoded_name; + descrsetfunc f; + int res; + +#ifdef Py_USING_UNICODE + if (PyString_Check(name)) { + name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); + if (!name) + return -1; + } else if (!PyUnicode_Check(name)) +#else + if (!PyString_Check(name)) +#endif + { + PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); + return -1; + } else { + Py_INCREF(name); + } + + if (!tp->tp_dict) { + if (PyType_Ready(tp) < 0) + goto done; + } + + res = -1; + descr = _PyType_Lookup(tp, name); + f = NULL; + if (descr != NULL) + f = descr->ob_type->tp_descr_set; + if (!f) { + if (PyString_Check(name)) { + encoded_name = name; + Py_INCREF(name); + } else { + encoded_name = PyUnicode_AsUTF8String(name); + } + PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); + Py_DECREF(encoded_name); + } else { + res = f(descr, obj, value); + } + + done: + Py_DECREF(name); + return res; +} + + +#ifdef __cplusplus +} +#endif + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + + #define SWIG_exception(code, msg) do { SWIG_Error(code, msg); SWIG_fail;; } while(0) + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_char swig_types[0] +#define SWIGTYPE_p_int swig_types[1] +#define SWIGTYPE_p_uint8_t swig_types[2] +static swig_type_info *swig_types[4]; +static swig_module_info swig_module = {swig_types, 3, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#if (PY_VERSION_HEX <= 0x02000000) +# if !defined(SWIG_PYTHON_CLASSIC) +# error "This python version requires swig to be run with the '-classic' option" +# endif +#endif + +/*----------------------------------------------- + @(target):= _libwebp.so + ------------------------------------------------*/ +#if PY_VERSION_HEX >= 0x03000000 +# define SWIG_init PyInit__libwebp + +#else +# define SWIG_init init_libwebp + +#endif +#define SWIG_name "_libwebp" + +#define SWIGVERSION 0x020004 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + + #define SWIG_From_long PyInt_FromLong + + +SWIGINTERNINLINE PyObject * +SWIG_From_int (int value) +{ + return SWIG_From_long (value); +} + + +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor(void) +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERN int +SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) +{ +#if PY_VERSION_HEX>=0x03000000 + if (PyUnicode_Check(obj)) +#else + if (PyString_Check(obj)) +#endif + { + char *cstr; Py_ssize_t len; +#if PY_VERSION_HEX>=0x03000000 + if (!alloc && cptr) { + /* We can't allow converting without allocation, since the internal + representation of string in Python 3 is UCS-2/UCS-4 but we require + a UTF-8 representation. + TODO(bhy) More detailed explanation */ + return SWIG_RuntimeError; + } + obj = PyUnicode_AsUTF8String(obj); + PyBytes_AsStringAndSize(obj, &cstr, &len); + if(alloc) *alloc = SWIG_NEWOBJ; +#else + PyString_AsStringAndSize(obj, &cstr, &len); +#endif + if (cptr) { + if (alloc) { + /* + In python the user should not be able to modify the inner + string representation. To warranty that, if you define + SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string + buffer is always returned. + + The default behavior is just to return the pointer value, + so, be careful. + */ +#if defined(SWIG_PYTHON_SAFE_CSTRINGS) + if (*alloc != SWIG_OLDOBJ) +#else + if (*alloc == SWIG_NEWOBJ) +#endif + { + *cptr = (char *)memcpy((char *)malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); + *alloc = SWIG_NEWOBJ; + } + else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } else { + #if PY_VERSION_HEX>=0x03000000 + assert(0); /* Should never reach here in Python 3 */ + #endif + *cptr = SWIG_Python_str_AsChar(obj); + } + } + if (psize) *psize = len + 1; +#if PY_VERSION_HEX>=0x03000000 + Py_XDECREF(obj); +#endif + return SWIG_OK; + } else { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + void* vptr = 0; + if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = (char *) vptr; + if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_double (PyObject *obj, double *val) +{ + int res = SWIG_TypeError; + if (PyFloat_Check(obj)) { + if (val) *val = PyFloat_AsDouble(obj); + return SWIG_OK; + } else if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; + } else if (PyLong_Check(obj)) { + double v = PyLong_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + double d = PyFloat_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = d; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); + } else { + PyErr_Clear(); + } + } + } +#endif + return res; +} + + +#include + + +#include + + +SWIGINTERNINLINE int +SWIG_CanCastAsInteger(double *d, double min, double max) { + double x = *d; + if ((min <= x && x <= max)) { + double fx = floor(x); + double cx = ceil(x); + double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ + if ((errno == EDOM) || (errno == ERANGE)) { + errno = 0; + } else { + double summ, reps, diff; + if (rd < x) { + diff = x - rd; + } else if (rd > x) { + diff = rd - x; + } else { + return 1; + } + summ = rd + x; + reps = diff/summ; + if (reps < 8*DBL_EPSILON) { + *d = rd; + return 1; + } + } + } + return 0; +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) +{ + if (PyInt_Check(obj)) { + long v = PyInt_AsLong(obj); + if (v >= 0) { + if (val) *val = v; + return SWIG_OK; + } else { + return SWIG_OverflowError; + } + } else if (PyLong_Check(obj)) { + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { + if (val) *val = (unsigned long)(d); + return res; + } + } + } +#endif + return SWIG_TypeError; +} + + +SWIGINTERNINLINE int +SWIG_AsVal_size_t (PyObject * obj, size_t *val) +{ + unsigned long v; + int res = SWIG_AsVal_unsigned_SS_long (obj, val ? &v : 0); + if (SWIG_IsOK(res) && val) *val = (size_t)(v); + return res; +} + + +#include "webp/decode.h" +#include "webp/encode.h" + + +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 }, +#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; +} + + +// 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 + + + +#include +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif +#endif + + +SWIGINTERN int +SWIG_AsVal_long (PyObject *obj, long* val) +{ + if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; + } else if (PyLong_Check(obj)) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + long v = PyInt_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); + return res; + } + } + } +#endif + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_int (PyObject * obj, int *val) +{ + long v; + int res = SWIG_AsVal_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (int)(v); + } + } + return res; +} + + +SWIGINTERN int +SWIG_AsVal_float (PyObject * obj, float *val) +{ + double v; + int res = SWIG_AsVal_double (obj, &v); + if (SWIG_IsOK(res)) { + if ((v < -FLT_MAX || v > FLT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (float)(v); + } + } + return res; +} + +#ifdef __cplusplus +extern "C" { +#endif +SWIGINTERN PyObject *_wrap_WebPGetDecoderVersion(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int result; + + if (!PyArg_ParseTuple(args,(char *)":WebPGetDecoderVersion")) SWIG_fail; + result = (int)WebPGetDecoderVersion(); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_WebPGetInfo(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint8_t *arg1 = (uint8_t *) 0 ; + size_t arg2 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int res1 ; + char *buf1 = 0 ; + size_t size1 = 0 ; + int alloc1 = 0 ; + int temp3 ; + int res3 = SWIG_TMPOBJ ; + int temp4 ; + int res4 = SWIG_TMPOBJ ; + PyObject * obj0 = 0 ; + int result; + + arg3 = &temp3; + arg4 = &temp4; + if (!PyArg_ParseTuple(args,(char *)"O:WebPGetInfo",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, &size1, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "WebPGetInfo" "', argument " "1"" of type '" "uint8_t const *""'"); + } + arg1 = (uint8_t *)(buf1); + arg2 = (size_t)(size1 - 1); + result = (int)WebPGetInfo((uint8_t const *)arg1,arg2,arg3,arg4); + resultobj = SWIG_From_int((int)(result)); + if (SWIG_IsTmpObj(res3)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg3))); + } else { + int new_flags = SWIG_IsNewObj(res3) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg3), SWIGTYPE_p_int, new_flags)); + } + if (SWIG_IsTmpObj(res4)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); + } else { + int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_WebPDecodeRGB(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint8_t *arg1 = (uint8_t *) 0 ; + size_t arg2 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int res1 ; + char *buf1 = 0 ; + size_t size1 = 0 ; + int alloc1 = 0 ; + int temp3 ; + int res3 = SWIG_TMPOBJ ; + int temp4 ; + int res4 = SWIG_TMPOBJ ; + PyObject * obj0 = 0 ; + uint8_t *result = 0 ; + + arg3 = &temp3; + arg4 = &temp4; + if (!PyArg_ParseTuple(args,(char *)"O:WebPDecodeRGB",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, &size1, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "WebPDecodeRGB" "', argument " "1"" of type '" "uint8_t const *""'"); + } + arg1 = (uint8_t *)(buf1); + arg2 = (size_t)(size1 - 1); + result = (uint8_t *)WebPDecodeRGB((uint8_t const *)arg1,arg2,arg3,arg4); + { + resultobj = PyString_FromStringAndSize( + (const char*)result, ReturnedBufferSize("WebPDecodeRGB", arg3, arg4)); + } + if (SWIG_IsTmpObj(res3)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg3))); + } else { + int new_flags = SWIG_IsNewObj(res3) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg3), SWIGTYPE_p_int, new_flags)); + } + if (SWIG_IsTmpObj(res4)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); + } else { + int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + free(result); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_WebPDecodeRGBA(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint8_t *arg1 = (uint8_t *) 0 ; + size_t arg2 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int res1 ; + char *buf1 = 0 ; + size_t size1 = 0 ; + int alloc1 = 0 ; + int temp3 ; + int res3 = SWIG_TMPOBJ ; + int temp4 ; + int res4 = SWIG_TMPOBJ ; + PyObject * obj0 = 0 ; + uint8_t *result = 0 ; + + arg3 = &temp3; + arg4 = &temp4; + if (!PyArg_ParseTuple(args,(char *)"O:WebPDecodeRGBA",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, &size1, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "WebPDecodeRGBA" "', argument " "1"" of type '" "uint8_t const *""'"); + } + arg1 = (uint8_t *)(buf1); + arg2 = (size_t)(size1 - 1); + result = (uint8_t *)WebPDecodeRGBA((uint8_t const *)arg1,arg2,arg3,arg4); + { + resultobj = PyString_FromStringAndSize( + (const char*)result, ReturnedBufferSize("WebPDecodeRGBA", arg3, arg4)); + } + if (SWIG_IsTmpObj(res3)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg3))); + } else { + int new_flags = SWIG_IsNewObj(res3) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg3), SWIGTYPE_p_int, new_flags)); + } + if (SWIG_IsTmpObj(res4)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); + } else { + int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + free(result); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_WebPDecodeARGB(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint8_t *arg1 = (uint8_t *) 0 ; + size_t arg2 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int res1 ; + char *buf1 = 0 ; + size_t size1 = 0 ; + int alloc1 = 0 ; + int temp3 ; + int res3 = SWIG_TMPOBJ ; + int temp4 ; + int res4 = SWIG_TMPOBJ ; + PyObject * obj0 = 0 ; + uint8_t *result = 0 ; + + arg3 = &temp3; + arg4 = &temp4; + if (!PyArg_ParseTuple(args,(char *)"O:WebPDecodeARGB",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, &size1, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "WebPDecodeARGB" "', argument " "1"" of type '" "uint8_t const *""'"); + } + arg1 = (uint8_t *)(buf1); + arg2 = (size_t)(size1 - 1); + result = (uint8_t *)WebPDecodeARGB((uint8_t const *)arg1,arg2,arg3,arg4); + { + resultobj = PyString_FromStringAndSize( + (const char*)result, ReturnedBufferSize("WebPDecodeARGB", arg3, arg4)); + } + if (SWIG_IsTmpObj(res3)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg3))); + } else { + int new_flags = SWIG_IsNewObj(res3) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg3), SWIGTYPE_p_int, new_flags)); + } + if (SWIG_IsTmpObj(res4)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); + } else { + int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + free(result); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_WebPDecodeBGR(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint8_t *arg1 = (uint8_t *) 0 ; + size_t arg2 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int res1 ; + char *buf1 = 0 ; + size_t size1 = 0 ; + int alloc1 = 0 ; + int temp3 ; + int res3 = SWIG_TMPOBJ ; + int temp4 ; + int res4 = SWIG_TMPOBJ ; + PyObject * obj0 = 0 ; + uint8_t *result = 0 ; + + arg3 = &temp3; + arg4 = &temp4; + if (!PyArg_ParseTuple(args,(char *)"O:WebPDecodeBGR",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, &size1, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "WebPDecodeBGR" "', argument " "1"" of type '" "uint8_t const *""'"); + } + arg1 = (uint8_t *)(buf1); + arg2 = (size_t)(size1 - 1); + result = (uint8_t *)WebPDecodeBGR((uint8_t const *)arg1,arg2,arg3,arg4); + { + resultobj = PyString_FromStringAndSize( + (const char*)result, ReturnedBufferSize("WebPDecodeBGR", arg3, arg4)); + } + if (SWIG_IsTmpObj(res3)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg3))); + } else { + int new_flags = SWIG_IsNewObj(res3) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg3), SWIGTYPE_p_int, new_flags)); + } + if (SWIG_IsTmpObj(res4)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); + } else { + int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + free(result); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_WebPDecodeBGRA(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint8_t *arg1 = (uint8_t *) 0 ; + size_t arg2 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int res1 ; + char *buf1 = 0 ; + size_t size1 = 0 ; + int alloc1 = 0 ; + int temp3 ; + int res3 = SWIG_TMPOBJ ; + int temp4 ; + int res4 = SWIG_TMPOBJ ; + PyObject * obj0 = 0 ; + uint8_t *result = 0 ; + + arg3 = &temp3; + arg4 = &temp4; + if (!PyArg_ParseTuple(args,(char *)"O:WebPDecodeBGRA",&obj0)) SWIG_fail; + res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, &size1, &alloc1); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "WebPDecodeBGRA" "', argument " "1"" of type '" "uint8_t const *""'"); + } + arg1 = (uint8_t *)(buf1); + arg2 = (size_t)(size1 - 1); + result = (uint8_t *)WebPDecodeBGRA((uint8_t const *)arg1,arg2,arg3,arg4); + { + resultobj = PyString_FromStringAndSize( + (const char*)result, ReturnedBufferSize("WebPDecodeBGRA", arg3, arg4)); + } + if (SWIG_IsTmpObj(res3)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg3))); + } else { + int new_flags = SWIG_IsNewObj(res3) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg3), SWIGTYPE_p_int, new_flags)); + } + if (SWIG_IsTmpObj(res4)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); + } else { + int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); + } + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + free(result); + return resultobj; +fail: + if (alloc1 == SWIG_NEWOBJ) free((char*)buf1); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_WebPGetEncoderVersion(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + int result; + + if (!PyArg_ParseTuple(args,(char *)":WebPGetEncoderVersion")) SWIG_fail; + result = (int)WebPGetEncoderVersion(); + resultobj = SWIG_From_int((int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wrap_WebPEncodeRGB(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint8_t *arg1 = (uint8_t *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int arg5 ; + int arg6 ; + int arg7 ; + float arg8 ; + void *argp1 = 0 ; + int res1 = 0 ; + int temp2 ; + int res2 = 0 ; + int temp3 ; + int res3 = 0 ; + int temp4 ; + int res4 = SWIG_TMPOBJ ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + float val8 ; + int ecode8 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + uint8_t *result = 0 ; + + arg4 = &temp4; + if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:wrap_WebPEncodeRGB",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_uint8_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wrap_WebPEncodeRGB" "', argument " "1"" of type '" "uint8_t const *""'"); + } + arg1 = (uint8_t *)(argp1); + if (!(SWIG_IsOK((res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2),SWIGTYPE_p_int,0))))) { + int val; + int ecode = SWIG_AsVal_int(obj1, &val); + if (!SWIG_IsOK(ecode)) { + SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "wrap_WebPEncodeRGB" "', argument " "2"" of type '" "int""'"); + } + temp2 = (int)(val); + arg2 = &temp2; + res2 = SWIG_AddTmpMask(ecode); + } + if (!(SWIG_IsOK((res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3),SWIGTYPE_p_int,0))))) { + int val; + int ecode = SWIG_AsVal_int(obj2, &val); + if (!SWIG_IsOK(ecode)) { + SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "wrap_WebPEncodeRGB" "', argument " "3"" of type '" "int""'"); + } + temp3 = (int)(val); + arg3 = &temp3; + res3 = SWIG_AddTmpMask(ecode); + } + ecode5 = SWIG_AsVal_int(obj3, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "wrap_WebPEncodeRGB" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(obj4, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "wrap_WebPEncodeRGB" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(obj5, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "wrap_WebPEncodeRGB" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_float(obj6, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "wrap_WebPEncodeRGB" "', argument " "8"" of type '" "float""'"); + } + arg8 = (float)(val8); + result = (uint8_t *)wrap_WebPEncodeRGB((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + { + resultobj = PyString_FromStringAndSize( + (const char*)result, ReturnedBufferSize("wrap_WebPEncodeRGB", arg3, arg4)); + } + if (SWIG_IsTmpObj(res4)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); + } else { + int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); + } + if (SWIG_IsNewObj(res2)) free((char*)arg2); + if (SWIG_IsNewObj(res3)) free((char*)arg3); + free(result); + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) free((char*)arg2); + if (SWIG_IsNewObj(res3)) free((char*)arg3); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wrap_WebPEncodeBGR(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint8_t *arg1 = (uint8_t *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int arg5 ; + int arg6 ; + int arg7 ; + float arg8 ; + void *argp1 = 0 ; + int res1 = 0 ; + int temp2 ; + int res2 = 0 ; + int temp3 ; + int res3 = 0 ; + int temp4 ; + int res4 = SWIG_TMPOBJ ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + float val8 ; + int ecode8 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + uint8_t *result = 0 ; + + arg4 = &temp4; + if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:wrap_WebPEncodeBGR",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_uint8_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wrap_WebPEncodeBGR" "', argument " "1"" of type '" "uint8_t const *""'"); + } + arg1 = (uint8_t *)(argp1); + if (!(SWIG_IsOK((res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2),SWIGTYPE_p_int,0))))) { + int val; + int ecode = SWIG_AsVal_int(obj1, &val); + if (!SWIG_IsOK(ecode)) { + SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "wrap_WebPEncodeBGR" "', argument " "2"" of type '" "int""'"); + } + temp2 = (int)(val); + arg2 = &temp2; + res2 = SWIG_AddTmpMask(ecode); + } + if (!(SWIG_IsOK((res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3),SWIGTYPE_p_int,0))))) { + int val; + int ecode = SWIG_AsVal_int(obj2, &val); + if (!SWIG_IsOK(ecode)) { + SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "wrap_WebPEncodeBGR" "', argument " "3"" of type '" "int""'"); + } + temp3 = (int)(val); + arg3 = &temp3; + res3 = SWIG_AddTmpMask(ecode); + } + ecode5 = SWIG_AsVal_int(obj3, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "wrap_WebPEncodeBGR" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(obj4, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "wrap_WebPEncodeBGR" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(obj5, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "wrap_WebPEncodeBGR" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_float(obj6, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "wrap_WebPEncodeBGR" "', argument " "8"" of type '" "float""'"); + } + arg8 = (float)(val8); + result = (uint8_t *)wrap_WebPEncodeBGR((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + { + resultobj = PyString_FromStringAndSize( + (const char*)result, ReturnedBufferSize("wrap_WebPEncodeBGR", arg3, arg4)); + } + if (SWIG_IsTmpObj(res4)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); + } else { + int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); + } + if (SWIG_IsNewObj(res2)) free((char*)arg2); + if (SWIG_IsNewObj(res3)) free((char*)arg3); + free(result); + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) free((char*)arg2); + if (SWIG_IsNewObj(res3)) free((char*)arg3); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wrap_WebPEncodeRGBA(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint8_t *arg1 = (uint8_t *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int arg5 ; + int arg6 ; + int arg7 ; + float arg8 ; + void *argp1 = 0 ; + int res1 = 0 ; + int temp2 ; + int res2 = 0 ; + int temp3 ; + int res3 = 0 ; + int temp4 ; + int res4 = SWIG_TMPOBJ ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + float val8 ; + int ecode8 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + uint8_t *result = 0 ; + + arg4 = &temp4; + if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:wrap_WebPEncodeRGBA",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_uint8_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wrap_WebPEncodeRGBA" "', argument " "1"" of type '" "uint8_t const *""'"); + } + arg1 = (uint8_t *)(argp1); + if (!(SWIG_IsOK((res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2),SWIGTYPE_p_int,0))))) { + int val; + int ecode = SWIG_AsVal_int(obj1, &val); + if (!SWIG_IsOK(ecode)) { + SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "wrap_WebPEncodeRGBA" "', argument " "2"" of type '" "int""'"); + } + temp2 = (int)(val); + arg2 = &temp2; + res2 = SWIG_AddTmpMask(ecode); + } + if (!(SWIG_IsOK((res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3),SWIGTYPE_p_int,0))))) { + int val; + int ecode = SWIG_AsVal_int(obj2, &val); + if (!SWIG_IsOK(ecode)) { + SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "wrap_WebPEncodeRGBA" "', argument " "3"" of type '" "int""'"); + } + temp3 = (int)(val); + arg3 = &temp3; + res3 = SWIG_AddTmpMask(ecode); + } + ecode5 = SWIG_AsVal_int(obj3, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "wrap_WebPEncodeRGBA" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(obj4, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "wrap_WebPEncodeRGBA" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(obj5, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "wrap_WebPEncodeRGBA" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_float(obj6, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "wrap_WebPEncodeRGBA" "', argument " "8"" of type '" "float""'"); + } + arg8 = (float)(val8); + result = (uint8_t *)wrap_WebPEncodeRGBA((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + { + resultobj = PyString_FromStringAndSize( + (const char*)result, ReturnedBufferSize("wrap_WebPEncodeRGBA", arg3, arg4)); + } + if (SWIG_IsTmpObj(res4)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); + } else { + int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); + } + if (SWIG_IsNewObj(res2)) free((char*)arg2); + if (SWIG_IsNewObj(res3)) free((char*)arg3); + free(result); + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) free((char*)arg2); + if (SWIG_IsNewObj(res3)) free((char*)arg3); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wrap_WebPEncodeBGRA(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint8_t *arg1 = (uint8_t *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int arg5 ; + int arg6 ; + int arg7 ; + float arg8 ; + void *argp1 = 0 ; + int res1 = 0 ; + int temp2 ; + int res2 = 0 ; + int temp3 ; + int res3 = 0 ; + int temp4 ; + int res4 = SWIG_TMPOBJ ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + float val8 ; + int ecode8 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + uint8_t *result = 0 ; + + arg4 = &temp4; + if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:wrap_WebPEncodeBGRA",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_uint8_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wrap_WebPEncodeBGRA" "', argument " "1"" of type '" "uint8_t const *""'"); + } + arg1 = (uint8_t *)(argp1); + if (!(SWIG_IsOK((res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2),SWIGTYPE_p_int,0))))) { + int val; + int ecode = SWIG_AsVal_int(obj1, &val); + if (!SWIG_IsOK(ecode)) { + SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "wrap_WebPEncodeBGRA" "', argument " "2"" of type '" "int""'"); + } + temp2 = (int)(val); + arg2 = &temp2; + res2 = SWIG_AddTmpMask(ecode); + } + if (!(SWIG_IsOK((res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3),SWIGTYPE_p_int,0))))) { + int val; + int ecode = SWIG_AsVal_int(obj2, &val); + if (!SWIG_IsOK(ecode)) { + SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "wrap_WebPEncodeBGRA" "', argument " "3"" of type '" "int""'"); + } + temp3 = (int)(val); + arg3 = &temp3; + res3 = SWIG_AddTmpMask(ecode); + } + ecode5 = SWIG_AsVal_int(obj3, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "wrap_WebPEncodeBGRA" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(obj4, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "wrap_WebPEncodeBGRA" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(obj5, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "wrap_WebPEncodeBGRA" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + ecode8 = SWIG_AsVal_float(obj6, &val8); + if (!SWIG_IsOK(ecode8)) { + SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "wrap_WebPEncodeBGRA" "', argument " "8"" of type '" "float""'"); + } + arg8 = (float)(val8); + result = (uint8_t *)wrap_WebPEncodeBGRA((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); + { + resultobj = PyString_FromStringAndSize( + (const char*)result, ReturnedBufferSize("wrap_WebPEncodeBGRA", arg3, arg4)); + } + if (SWIG_IsTmpObj(res4)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); + } else { + int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); + } + if (SWIG_IsNewObj(res2)) free((char*)arg2); + if (SWIG_IsNewObj(res3)) free((char*)arg3); + free(result); + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) free((char*)arg2); + if (SWIG_IsNewObj(res3)) free((char*)arg3); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessRGB(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint8_t *arg1 = (uint8_t *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int arg5 ; + int arg6 ; + int arg7 ; + void *argp1 = 0 ; + int res1 = 0 ; + int temp2 ; + int res2 = 0 ; + int temp3 ; + int res3 = 0 ; + int temp4 ; + int res4 = SWIG_TMPOBJ ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + uint8_t *result = 0 ; + + arg4 = &temp4; + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:wrap_WebPEncodeLosslessRGB",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_uint8_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wrap_WebPEncodeLosslessRGB" "', argument " "1"" of type '" "uint8_t const *""'"); + } + arg1 = (uint8_t *)(argp1); + if (!(SWIG_IsOK((res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2),SWIGTYPE_p_int,0))))) { + int val; + int ecode = SWIG_AsVal_int(obj1, &val); + if (!SWIG_IsOK(ecode)) { + SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "wrap_WebPEncodeLosslessRGB" "', argument " "2"" of type '" "int""'"); + } + temp2 = (int)(val); + arg2 = &temp2; + res2 = SWIG_AddTmpMask(ecode); + } + if (!(SWIG_IsOK((res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3),SWIGTYPE_p_int,0))))) { + int val; + int ecode = SWIG_AsVal_int(obj2, &val); + if (!SWIG_IsOK(ecode)) { + SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "wrap_WebPEncodeLosslessRGB" "', argument " "3"" of type '" "int""'"); + } + temp3 = (int)(val); + arg3 = &temp3; + res3 = SWIG_AddTmpMask(ecode); + } + ecode5 = SWIG_AsVal_int(obj3, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "wrap_WebPEncodeLosslessRGB" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(obj4, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "wrap_WebPEncodeLosslessRGB" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(obj5, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "wrap_WebPEncodeLosslessRGB" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + result = (uint8_t *)wrap_WebPEncodeLosslessRGB((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7); + { + resultobj = PyString_FromStringAndSize( + (const char*)result, ReturnedBufferSize("wrap_WebPEncodeLosslessRGB", arg3, arg4)); + } + if (SWIG_IsTmpObj(res4)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); + } else { + int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); + } + if (SWIG_IsNewObj(res2)) free((char*)arg2); + if (SWIG_IsNewObj(res3)) free((char*)arg3); + free(result); + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) free((char*)arg2); + if (SWIG_IsNewObj(res3)) free((char*)arg3); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessBGR(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint8_t *arg1 = (uint8_t *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int arg5 ; + int arg6 ; + int arg7 ; + void *argp1 = 0 ; + int res1 = 0 ; + int temp2 ; + int res2 = 0 ; + int temp3 ; + int res3 = 0 ; + int temp4 ; + int res4 = SWIG_TMPOBJ ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + uint8_t *result = 0 ; + + arg4 = &temp4; + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:wrap_WebPEncodeLosslessBGR",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_uint8_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wrap_WebPEncodeLosslessBGR" "', argument " "1"" of type '" "uint8_t const *""'"); + } + arg1 = (uint8_t *)(argp1); + if (!(SWIG_IsOK((res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2),SWIGTYPE_p_int,0))))) { + int val; + int ecode = SWIG_AsVal_int(obj1, &val); + if (!SWIG_IsOK(ecode)) { + SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "wrap_WebPEncodeLosslessBGR" "', argument " "2"" of type '" "int""'"); + } + temp2 = (int)(val); + arg2 = &temp2; + res2 = SWIG_AddTmpMask(ecode); + } + if (!(SWIG_IsOK((res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3),SWIGTYPE_p_int,0))))) { + int val; + int ecode = SWIG_AsVal_int(obj2, &val); + if (!SWIG_IsOK(ecode)) { + SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "wrap_WebPEncodeLosslessBGR" "', argument " "3"" of type '" "int""'"); + } + temp3 = (int)(val); + arg3 = &temp3; + res3 = SWIG_AddTmpMask(ecode); + } + ecode5 = SWIG_AsVal_int(obj3, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "wrap_WebPEncodeLosslessBGR" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(obj4, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "wrap_WebPEncodeLosslessBGR" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(obj5, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "wrap_WebPEncodeLosslessBGR" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + result = (uint8_t *)wrap_WebPEncodeLosslessBGR((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7); + { + resultobj = PyString_FromStringAndSize( + (const char*)result, ReturnedBufferSize("wrap_WebPEncodeLosslessBGR", arg3, arg4)); + } + if (SWIG_IsTmpObj(res4)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); + } else { + int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); + } + if (SWIG_IsNewObj(res2)) free((char*)arg2); + if (SWIG_IsNewObj(res3)) free((char*)arg3); + free(result); + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) free((char*)arg2); + if (SWIG_IsNewObj(res3)) free((char*)arg3); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessRGBA(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint8_t *arg1 = (uint8_t *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int arg5 ; + int arg6 ; + int arg7 ; + void *argp1 = 0 ; + int res1 = 0 ; + int temp2 ; + int res2 = 0 ; + int temp3 ; + int res3 = 0 ; + int temp4 ; + int res4 = SWIG_TMPOBJ ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + uint8_t *result = 0 ; + + arg4 = &temp4; + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:wrap_WebPEncodeLosslessRGBA",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_uint8_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wrap_WebPEncodeLosslessRGBA" "', argument " "1"" of type '" "uint8_t const *""'"); + } + arg1 = (uint8_t *)(argp1); + if (!(SWIG_IsOK((res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2),SWIGTYPE_p_int,0))))) { + int val; + int ecode = SWIG_AsVal_int(obj1, &val); + if (!SWIG_IsOK(ecode)) { + SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "wrap_WebPEncodeLosslessRGBA" "', argument " "2"" of type '" "int""'"); + } + temp2 = (int)(val); + arg2 = &temp2; + res2 = SWIG_AddTmpMask(ecode); + } + if (!(SWIG_IsOK((res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3),SWIGTYPE_p_int,0))))) { + int val; + int ecode = SWIG_AsVal_int(obj2, &val); + if (!SWIG_IsOK(ecode)) { + SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "wrap_WebPEncodeLosslessRGBA" "', argument " "3"" of type '" "int""'"); + } + temp3 = (int)(val); + arg3 = &temp3; + res3 = SWIG_AddTmpMask(ecode); + } + ecode5 = SWIG_AsVal_int(obj3, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "wrap_WebPEncodeLosslessRGBA" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(obj4, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "wrap_WebPEncodeLosslessRGBA" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(obj5, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "wrap_WebPEncodeLosslessRGBA" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + result = (uint8_t *)wrap_WebPEncodeLosslessRGBA((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7); + { + resultobj = PyString_FromStringAndSize( + (const char*)result, ReturnedBufferSize("wrap_WebPEncodeLosslessRGBA", arg3, arg4)); + } + if (SWIG_IsTmpObj(res4)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); + } else { + int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); + } + if (SWIG_IsNewObj(res2)) free((char*)arg2); + if (SWIG_IsNewObj(res3)) free((char*)arg3); + free(result); + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) free((char*)arg2); + if (SWIG_IsNewObj(res3)) free((char*)arg3); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessBGRA(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + uint8_t *arg1 = (uint8_t *) 0 ; + int *arg2 = (int *) 0 ; + int *arg3 = (int *) 0 ; + int *arg4 = (int *) 0 ; + int arg5 ; + int arg6 ; + int arg7 ; + void *argp1 = 0 ; + int res1 = 0 ; + int temp2 ; + int res2 = 0 ; + int temp3 ; + int res3 = 0 ; + int temp4 ; + int res4 = SWIG_TMPOBJ ; + int val5 ; + int ecode5 = 0 ; + int val6 ; + int ecode6 = 0 ; + int val7 ; + int ecode7 = 0 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + uint8_t *result = 0 ; + + arg4 = &temp4; + if (!PyArg_ParseTuple(args,(char *)"OOOOOO:wrap_WebPEncodeLosslessBGRA",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_uint8_t, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wrap_WebPEncodeLosslessBGRA" "', argument " "1"" of type '" "uint8_t const *""'"); + } + arg1 = (uint8_t *)(argp1); + if (!(SWIG_IsOK((res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2),SWIGTYPE_p_int,0))))) { + int val; + int ecode = SWIG_AsVal_int(obj1, &val); + if (!SWIG_IsOK(ecode)) { + SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "wrap_WebPEncodeLosslessBGRA" "', argument " "2"" of type '" "int""'"); + } + temp2 = (int)(val); + arg2 = &temp2; + res2 = SWIG_AddTmpMask(ecode); + } + if (!(SWIG_IsOK((res3 = SWIG_ConvertPtr(obj2,SWIG_as_voidptrptr(&arg3),SWIGTYPE_p_int,0))))) { + int val; + int ecode = SWIG_AsVal_int(obj2, &val); + if (!SWIG_IsOK(ecode)) { + SWIG_exception_fail(SWIG_ArgError(ecode), "in method '" "wrap_WebPEncodeLosslessBGRA" "', argument " "3"" of type '" "int""'"); + } + temp3 = (int)(val); + arg3 = &temp3; + res3 = SWIG_AddTmpMask(ecode); + } + ecode5 = SWIG_AsVal_int(obj3, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "wrap_WebPEncodeLosslessBGRA" "', argument " "5"" of type '" "int""'"); + } + arg5 = (int)(val5); + ecode6 = SWIG_AsVal_int(obj4, &val6); + if (!SWIG_IsOK(ecode6)) { + SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "wrap_WebPEncodeLosslessBGRA" "', argument " "6"" of type '" "int""'"); + } + arg6 = (int)(val6); + ecode7 = SWIG_AsVal_int(obj5, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "wrap_WebPEncodeLosslessBGRA" "', argument " "7"" of type '" "int""'"); + } + arg7 = (int)(val7); + result = (uint8_t *)wrap_WebPEncodeLosslessBGRA((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7); + { + resultobj = PyString_FromStringAndSize( + (const char*)result, ReturnedBufferSize("wrap_WebPEncodeLosslessBGRA", arg3, arg4)); + } + if (SWIG_IsTmpObj(res4)) { + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); + } else { + int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; + resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); + } + if (SWIG_IsNewObj(res2)) free((char*)arg2); + if (SWIG_IsNewObj(res3)) free((char*)arg3); + free(result); + return resultobj; +fail: + if (SWIG_IsNewObj(res2)) free((char*)arg2); + if (SWIG_IsNewObj(res3)) free((char*)arg3); + return NULL; +} + + +static PyMethodDef SwigMethods[] = { + { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL}, + { (char *)"WebPGetDecoderVersion", _wrap_WebPGetDecoderVersion, METH_VARARGS, NULL}, + { (char *)"WebPGetInfo", _wrap_WebPGetInfo, METH_VARARGS, NULL}, + { (char *)"WebPDecodeRGB", _wrap_WebPDecodeRGB, METH_VARARGS, NULL}, + { (char *)"WebPDecodeRGBA", _wrap_WebPDecodeRGBA, METH_VARARGS, NULL}, + { (char *)"WebPDecodeARGB", _wrap_WebPDecodeARGB, METH_VARARGS, NULL}, + { (char *)"WebPDecodeBGR", _wrap_WebPDecodeBGR, METH_VARARGS, NULL}, + { (char *)"WebPDecodeBGRA", _wrap_WebPDecodeBGRA, METH_VARARGS, NULL}, + { (char *)"WebPGetEncoderVersion", _wrap_WebPGetEncoderVersion, METH_VARARGS, NULL}, + { (char *)"wrap_WebPEncodeRGB", _wrap_wrap_WebPEncodeRGB, METH_VARARGS, NULL}, + { (char *)"wrap_WebPEncodeBGR", _wrap_wrap_WebPEncodeBGR, METH_VARARGS, NULL}, + { (char *)"wrap_WebPEncodeRGBA", _wrap_wrap_WebPEncodeRGBA, METH_VARARGS, NULL}, + { (char *)"wrap_WebPEncodeBGRA", _wrap_wrap_WebPEncodeBGRA, METH_VARARGS, NULL}, + { (char *)"wrap_WebPEncodeLosslessRGB", _wrap_wrap_WebPEncodeLosslessRGB, METH_VARARGS, NULL}, + { (char *)"wrap_WebPEncodeLosslessBGR", _wrap_wrap_WebPEncodeLosslessBGR, METH_VARARGS, NULL}, + { (char *)"wrap_WebPEncodeLosslessRGBA", _wrap_wrap_WebPEncodeLosslessRGBA, METH_VARARGS, NULL}, + { (char *)"wrap_WebPEncodeLosslessBGRA", _wrap_wrap_WebPEncodeLosslessBGRA, METH_VARARGS, NULL}, + { NULL, NULL, 0, NULL } +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "int *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_uint8_t = {"_p_uint8_t", "uint8_t *", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_char, + &_swigt__p_int, + &_swigt__p_uint8_t, +}; + +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_uint8_t[] = { {&_swigt__p_uint8_t, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_char, + _swigc__p_int, + _swigc__p_uint8_t, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_const_info swig_const_table[] = { +{0, 0, 0, 0.0, 0, 0}}; + +#ifdef __cplusplus +} +#endif +/* ----------------------------------------------------------------------------- + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + * + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop through that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + * + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* c-mode */ +#endif +#endif + +#if 0 +#define SWIGRUNTIME_DEBUG +#endif + + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + size_t i; + swig_module_info *module_head, *iter; + int found, init; + + clientdata = clientdata; + + /* check to see if the circular list has been setup, if not, set it up */ + if (swig_module.next==0) { + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + swig_module.next = &swig_module; + init = 1; + } else { + init = 0; + } + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (!module_head) { + /* This is the first module loaded for this interpreter */ + /* so set the swig module into the interpreter */ + SWIG_SetModule(clientdata, &swig_module); + module_head = &swig_module; + } else { + /* the interpreter has loaded a SWIG module, but has it loaded this one? */ + found=0; + iter=module_head; + do { + if (iter==&swig_module) { + found=1; + break; + } + iter=iter->next; + } while (iter!= module_head); + + /* if the is found in the list, then all is done and we may leave */ + if (found) return; + /* otherwise we must add out module into the list */ + swig_module.next = module_head->next; + module_head->next = &swig_module; + } + + /* When multiple interpeters are used, a module could have already been initialized in + a different interpreter, but not yet have a pointer in this interpreter. + In this case, we do not want to continue adding types... everything should be + set up already */ + if (init == 0) return; + + /* Now work on filling in swig_module.types */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: size %d\n", swig_module.size); +#endif + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; + +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); +#endif + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found type %s\n", type->name); +#endif + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); +#endif + } + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); +#endif + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); +#ifdef SWIGRUNTIME_DEBUG + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); +#endif + } + if (ret) { + if (type == swig_module.type_initial[i]) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); +#endif + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); +#ifdef SWIGRUNTIME_DEBUG + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); +#endif + if (!ocast) ret = 0; + } + } + + if (!ret) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); +#endif + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + cast++; + } + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + +#ifdef SWIGRUNTIME_DEBUG + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; + } + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); +#endif +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +#if 0 +{ + /* c-mode */ +#endif +} +#endif + + + +#ifdef __cplusplus +extern "C" { +#endif + + /* Python-specific SWIG API */ +#define SWIG_newvarlink() SWIG_Python_newvarlink() +#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) +#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) + + /* ----------------------------------------------------------------------------- + * global variable support code. + * ----------------------------------------------------------------------------- */ + + typedef struct swig_globalvar { + char *name; /* Name of global variable */ + PyObject *(*get_attr)(void); /* Return the current value */ + int (*set_attr)(PyObject *); /* Set the value */ + struct swig_globalvar *next; + } swig_globalvar; + + typedef struct swig_varlinkobject { + PyObject_HEAD + swig_globalvar *vars; + } swig_varlinkobject; + + SWIGINTERN PyObject * + swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_InternFromString(""); +#else + return PyString_FromString(""); +#endif + } + + SWIGINTERN PyObject * + swig_varlink_str(swig_varlinkobject *v) { +#if PY_VERSION_HEX >= 0x03000000 + PyObject *str = PyUnicode_InternFromString("("); + PyObject *tail; + PyObject *joined; + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + tail = PyUnicode_FromString(var->name); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + if (var->next) { + tail = PyUnicode_InternFromString(", "); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; + } + } + tail = PyUnicode_InternFromString(")"); + joined = PyUnicode_Concat(str, tail); + Py_DecRef(str); + Py_DecRef(tail); + str = joined; +#else + PyObject *str = PyString_FromString("("); + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + PyString_ConcatAndDel(&str,PyString_FromString(var->name)); + if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); + } + PyString_ConcatAndDel(&str,PyString_FromString(")")); +#endif + return str; + } + + SWIGINTERN int + swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { + char *tmp; + PyObject *str = swig_varlink_str(v); + fprintf(fp,"Swig global variables "); + fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str)); + SWIG_Python_str_DelForPy3(tmp); + Py_DECREF(str); + return 0; + } + + SWIGINTERN void + swig_varlink_dealloc(swig_varlinkobject *v) { + swig_globalvar *var = v->vars; + while (var) { + swig_globalvar *n = var->next; + free(var->name); + free(var); + var = n; + } + } + + SWIGINTERN PyObject * + swig_varlink_getattr(swig_varlinkobject *v, char *n) { + PyObject *res = NULL; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->get_attr)(); + break; + } + var = var->next; + } + if (res == NULL && !PyErr_Occurred()) { + PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + } + return res; + } + + SWIGINTERN int + swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { + int res = 1; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->set_attr)(p); + break; + } + var = var->next; + } + if (res == 1 && !PyErr_Occurred()) { + PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + } + return res; + } + + SWIGINTERN PyTypeObject* + swig_varlink_type(void) { + static char varlink__doc__[] = "Swig var link object"; + static PyTypeObject varlink_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp = { + /* PyObject header changed in Python 3 */ +#if PY_VERSION_HEX >= 0x03000000 + PyVarObject_HEAD_INIT(NULL, 0) +#else + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ +#endif + (char *)"swigvarlink", /* tp_name */ + sizeof(swig_varlinkobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor) swig_varlink_dealloc, /* tp_dealloc */ + (printfunc) swig_varlink_print, /* tp_print */ + (getattrfunc) swig_varlink_getattr, /* tp_getattr */ + (setattrfunc) swig_varlink_setattr, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc) swig_varlink_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc) swig_varlink_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + 0, /* tp_flags */ + varlink__doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#if PY_VERSION_HEX >= 0x02060000 + 0, /* tp_version */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + varlink_type = tmp; + type_init = 1; +#if PY_VERSION_HEX < 0x02020000 + varlink_type.ob_type = &PyType_Type; +#else + if (PyType_Ready(&varlink_type) < 0) + return NULL; +#endif + } + return &varlink_type; + } + + /* Create a variable linking object for use later */ + SWIGINTERN PyObject * + SWIG_Python_newvarlink(void) { + swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); + if (result) { + result->vars = 0; + } + return ((PyObject*) result); + } + + SWIGINTERN void + SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + swig_varlinkobject *v = (swig_varlinkobject *) p; + swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); + if (gv) { + size_t size = strlen(name)+1; + gv->name = (char *)malloc(size); + if (gv->name) { + strncpy(gv->name,name,size); + gv->get_attr = get_attr; + gv->set_attr = set_attr; + gv->next = v->vars; + } + } + v->vars = gv; + } + + SWIGINTERN PyObject * + SWIG_globals(void) { + static PyObject *_SWIG_globals = 0; + if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); + return _SWIG_globals; + } + + /* ----------------------------------------------------------------------------- + * constants/methods manipulation + * ----------------------------------------------------------------------------- */ + + /* Install Constants */ + SWIGINTERN void + SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { + PyObject *obj = 0; + size_t i; + for (i = 0; constants[i].type; ++i) { + switch(constants[i].type) { + case SWIG_PY_POINTER: + obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); + break; + case SWIG_PY_BINARY: + obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); + break; + default: + obj = 0; + break; + } + if (obj) { + PyDict_SetItemString(d, constants[i].name, obj); + Py_DECREF(obj); + } + } + } + + /* -----------------------------------------------------------------------------*/ + /* Fix SwigMethods to carry the callback ptrs when needed */ + /* -----------------------------------------------------------------------------*/ + + SWIGINTERN void + SWIG_Python_FixMethods(PyMethodDef *methods, + swig_const_info *const_table, + swig_type_info **types, + swig_type_info **types_initial) { + size_t i; + for (i = 0; methods[i].ml_name; ++i) { + const char *c = methods[i].ml_doc; + if (c && (c = strstr(c, "swig_ptr: "))) { + int j; + swig_const_info *ci = 0; + const char *name = c + 10; + for (j = 0; const_table[j].type; ++j) { + if (strncmp(const_table[j].name, name, + strlen(const_table[j].name)) == 0) { + ci = &(const_table[j]); + break; + } + } + if (ci) { + void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; + if (ptr) { + size_t shift = (ci->ptype) - types; + swig_type_info *ty = types_initial[shift]; + size_t ldoc = (c - methods[i].ml_doc); + size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; + char *ndoc = (char*)malloc(ldoc + lptr + 10); + if (ndoc) { + char *buff = ndoc; + strncpy(buff, methods[i].ml_doc, ldoc); + buff += ldoc; + strncpy(buff, "swig_ptr: ", 10); + buff += 10; + SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); + methods[i].ml_doc = ndoc; + } + } + } + } + } + } + +#ifdef __cplusplus +} +#endif + +/* -----------------------------------------------------------------------------* + * Partial Init method + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +#endif + +SWIGEXPORT +#if PY_VERSION_HEX >= 0x03000000 +PyObject* +#else +void +#endif +SWIG_init(void) { + PyObject *m, *d, *md; +#if PY_VERSION_HEX >= 0x03000000 + static struct PyModuleDef SWIG_module = { +# if PY_VERSION_HEX >= 0x03020000 + PyModuleDef_HEAD_INIT, +# else + { + PyObject_HEAD_INIT(NULL) + NULL, /* m_init */ + 0, /* m_index */ + NULL, /* m_copy */ + }, +# endif + (char *) SWIG_name, + NULL, + -1, + SwigMethods, + NULL, + NULL, + NULL, + NULL + }; +#endif + +#if defined(SWIGPYTHON_BUILTIN) + static SwigPyClientData SwigPyObject_clientdata = { + 0, 0, 0, 0, 0, 0, 0 + }; + static PyGetSetDef this_getset_def = { + (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL + }; + static SwigPyGetSet thisown_getset_closure = { + (PyCFunction) SwigPyObject_own, + (PyCFunction) SwigPyObject_own + }; + static PyGetSetDef thisown_getset_def = { + (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure + }; + PyObject *metatype_args; + PyTypeObject *builtin_pytype; + int builtin_base_count; + swig_type_info *builtin_basetype; + PyObject *tuple; + PyGetSetDescrObject *static_getset; + PyTypeObject *metatype; + SwigPyClientData *cd; + PyObject *public_interface, *public_symbol; + PyObject *this_descr; + PyObject *thisown_descr; + int i; + + (void)builtin_pytype; + (void)builtin_base_count; + (void)builtin_basetype; + (void)tuple; + (void)static_getset; + + /* metatype is used to implement static member variables. */ + metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type); + assert(metatype_args); + metatype = (PyTypeObject *) PyType_Type.tp_call((PyObject *) &PyType_Type, metatype_args, NULL); + assert(metatype); + Py_DECREF(metatype_args); + metatype->tp_setattro = (setattrofunc) &SwigPyObjectType_setattro; + assert(PyType_Ready(metatype) >= 0); +#endif + + /* Fix SwigMethods to carry the callback ptrs when needed */ + SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); + +#if PY_VERSION_HEX >= 0x03000000 + m = PyModule_Create(&SWIG_module); +#else + m = Py_InitModule((char *) SWIG_name, SwigMethods); +#endif + md = d = PyModule_GetDict(m); + + SWIG_InitializeModule(0); + +#ifdef SWIGPYTHON_BUILTIN + SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject"); + assert(SwigPyObject_stype); + cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; + if (!cd) { + SwigPyObject_stype->clientdata = &SwigPyObject_clientdata; + SwigPyObject_clientdata.pytype = SwigPyObject_TypeOnce(); + } else if (SwigPyObject_TypeOnce()->tp_basicsize != cd->pytype->tp_basicsize) { + PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules."); +# if PY_VERSION_HEX >= 0x03000000 + return NULL; +# else + return; +# endif + } + + /* All objects have a 'this' attribute */ + this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def); + (void)this_descr; + + /* All objects have a 'thisown' attribute */ + thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def); + (void)thisown_descr; + + public_interface = PyList_New(0); + public_symbol = 0; + (void)public_symbol; + + PyDict_SetItemString(md, "__all__", public_interface); + Py_DECREF(public_interface); + for (i = 0; SwigMethods[i].ml_name != NULL; ++i) + SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name); + for (i = 0; swig_const_table[i].name != 0; ++i) + SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name); +#endif + + SWIG_InstallConstants(d,swig_const_table); + +#if PY_VERSION_HEX >= 0x03000000 + return m; +#else + return; +#endif +} + diff --git a/swig/setup.py b/swig/setup.py new file mode 100644 index 00000000..3a3bfe19 --- /dev/null +++ b/swig/setup.py @@ -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) From 31f346fe0c1e10661254c0de8f5e87d04eafa1aa Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 9 May 2013 23:47:30 -0700 Subject: [PATCH 26/57] Makefile.vc: fix libwebpdemux dll variable typo Fixes issue #149 Patch by: Jason Stevens (cypher497 at gmail dot com) Change-Id: I65cceaad37d22b96e5e92cb78f859fc0b7c38b67 (cherry picked from commit 3eeedae1bc3be6509b6b9145f77ff4688e3820f5) --- Makefile.vc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.vc b/Makefile.vc index 114d073b..468f8b3e 100644 --- a/Makefile.vc +++ b/Makefile.vc @@ -108,7 +108,7 @@ CC = $(CC) /I$(DIROBJ) /FI$(DLLINC) $(RTLIB) /DWEBP_DLL LIBWEBPDECODER = $(DIRLIB)\$(LIBWEBPDECODER_BASENAME)_dll.lib LIBWEBP = $(DIRLIB)\$(LIBWEBP_BASENAME)_dll.lib LIBWEBPMUX = $(DIRLIB)\$(LIBWEBPMUX_BASENAME)_dll.lib -LIBWEBPDEMUX = $(DIRLIB)\$(LIBWEBPMDEMUX_BASENAME)_dll.lib +LIBWEBPDEMUX = $(DIRLIB)\$(LIBWEBPDEMUX_BASENAME)_dll.lib LIBWEBP_PDBNAME = $(DIROBJ)\$(LIBWEBP_BASENAME)_dll.pdb CFGSET = TRUE !ENDIF From eda8a7dec52f6a858029b50d89cf1bccc3e9f9c9 Mon Sep 17 00:00:00 2001 From: Urvang Joshi Date: Fri, 10 May 2013 13:37:20 -0700 Subject: [PATCH 27/57] gif2webp: Fix signed/unsigned comparison mismatch Change-Id: I355f0614424276550db71b24e5bb1948e5c6894c (cherry picked from commit 043e1ae4bdf6430736a7e74c589c5566cc6b07e5) --- examples/gif2webp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gif2webp.c b/examples/gif2webp.c index 4ae7fdde..14a29718 100644 --- a/examples/gif2webp.c +++ b/examples/gif2webp.c @@ -432,7 +432,7 @@ int main(int argc, const char *argv[]) { } if (is_xmp) { // XMP padding data is 0x01, 0xff, 0xfe ... 0x01, 0x00. - const int xmp_pading_size = 257; + const size_t xmp_pading_size = 257; if (metadata.size > xmp_pading_size) { metadata.size -= xmp_pading_size; } From 07db70d20fc93594d624f88cec57c8b41e781033 Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Sat, 11 May 2013 03:53:01 -0700 Subject: [PATCH 28/57] fix for big-endian (Issue #150: https://code.google.com/p/webp/issues/detail?id=150) Change-Id: Iad46d375a8c5eabae37cde8f55b3e7448601f264 (cherry picked from commit 443706173516408b5a6a95fcb912326ab783d340) --- src/utils/bit_reader.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/bit_reader.h b/src/utils/bit_reader.h index ccf450c5..7c5b3b1f 100644 --- a/src/utils/bit_reader.h +++ b/src/utils/bit_reader.h @@ -194,6 +194,7 @@ static WEBP_INLINE void VP8LoadNewBytes(VP8BitReader* const br) { #endif #else // BIG_ENDIAN bits = (bit_t)in_bits; + if (BITS != 8 * sizeof(bit_t)) bits >>= (8 * sizeof(bit_t) - BITS); #endif #ifndef USE_RIGHT_JUSTIFY br->value_ |= bits << (-br->bits_); From cc128e0bfcaac90f8c32ccc60320c26fed0b3b0a Mon Sep 17 00:00:00 2001 From: Urvang Joshi Date: Mon, 13 May 2013 16:24:49 -0700 Subject: [PATCH 29/57] Further reduce memory to decode lossy+alpha images Earlier such images were using roughly 9 * width * height bytes for decoding. Now, they take 6 * width * height memory. Change-Id: Ie4a681ca5074d96d64f30b2597fafdca648dd8f7 (cherry picked from commit 64c844863ab0d13e8dd51a59001ab55fbe64065e) --- src/dec/vp8l.c | 322 ++++++++++++++++++++++++++------------------- src/dec/vp8li.h | 3 +- src/dsp/lossless.c | 87 +++++++----- src/dsp/lossless.h | 7 + 4 files changed, 253 insertions(+), 166 deletions(-) diff --git a/src/dec/vp8l.c b/src/dec/vp8l.c index 1665fe17..19858822 100644 --- a/src/dec/vp8l.c +++ b/src/dec/vp8l.c @@ -625,10 +625,24 @@ static void ApplyInverseTransforms(VP8LDecoder* const dec, int num_rows, } } +// Special method for paletted alpha data. +static void ApplyInverseTransformsAlpha(VP8LDecoder* const dec, int num_rows, + const uint8_t* const rows) { + const int start_row = dec->last_row_; + const int end_row = start_row + num_rows; + const uint8_t* rows_in = rows; + uint8_t* rows_out = (uint8_t*)dec->io_->opaque + dec->io_->width * start_row; + VP8LTransform* const transform = &dec->transforms_[0]; + assert(dec->next_transform_ == 1); + assert(transform->type_ == COLOR_INDEXING_TRANSFORM); + VP8LColorIndexInverseTransformAlpha(transform, start_row, end_row, rows_in, + rows_out); +} + // Processes (transforms, scales & color-converts) the rows decoded after the // last call. static void ProcessRows(VP8LDecoder* const dec, int row) { - const uint32_t* const rows = dec->argb_ + dec->width_ * dec->last_row_; + const uint32_t* const rows = dec->pixels_ + dec->width_ * dec->last_row_; const int num_rows = row - dec->last_row_; if (num_rows <= 0) return; // Nothing to be done. @@ -667,121 +681,135 @@ static void ProcessRows(VP8LDecoder* const dec, int row) { assert(dec->last_row_ <= dec->height_); } -static int DecodeImageData(VP8LDecoder* const dec, - uint32_t* const data, int width, int height, - ProcessRowsFunc process_func) { - int ok = 1; - int col = 0, row = 0; - VP8LBitReader* const br = &dec->br_; - VP8LMetadata* const hdr = &dec->hdr_; - HTreeGroup* htree_group = hdr->htree_groups_; - uint32_t* src = data; - uint32_t* last_cached = data; - uint32_t* const src_end = data + width * height; - const int len_code_limit = NUM_LITERAL_CODES + NUM_LENGTH_CODES; - const int color_cache_limit = len_code_limit + hdr->color_cache_size_; - VP8LColorCache* const color_cache = - (hdr->color_cache_size_ > 0) ? &hdr->color_cache_ : NULL; - const int mask = hdr->huffman_mask_; - - assert(htree_group != NULL); - - while (!br->eos_ && src < src_end) { - int code; - // Only update when changing tile. Note we could use the following test: - // if "((((prev_col ^ col) | prev_row ^ row)) > mask)" -> tile changed - // but that's actually slower and requires storing the previous col/row - if ((col & mask) == 0) { - htree_group = GetHtreeGroupForPos(hdr, col, row); - } - VP8LFillBitWindow(br); - code = ReadSymbol(&htree_group->htrees_[GREEN], br); - if (code < NUM_LITERAL_CODES) { // Literal. - int red, green, blue, alpha; - red = ReadSymbol(&htree_group->htrees_[RED], br); - green = code; - VP8LFillBitWindow(br); - blue = ReadSymbol(&htree_group->htrees_[BLUE], br); - alpha = ReadSymbol(&htree_group->htrees_[ALPHA], br); - *src = (alpha << 24) + (red << 16) + (green << 8) + blue; - AdvanceByOne: - ++src; - ++col; - if (col >= width) { - col = 0; - ++row; - if ((process_func != NULL) && (row % NUM_ARGB_CACHE_ROWS == 0)) { - process_func(dec, row); - } - if (color_cache != NULL) { - while (last_cached < src) { - VP8LColorCacheInsert(color_cache, *last_cached++); - } - } - } - } else if (code < len_code_limit) { // Backward reference - int dist_code, dist; - const int length_sym = code - NUM_LITERAL_CODES; - const int length = GetCopyLength(length_sym, br); - const int dist_symbol = ReadSymbol(&htree_group->htrees_[DIST], br); - VP8LFillBitWindow(br); - dist_code = GetCopyDistance(dist_symbol, br); - dist = PlaneCodeToDistance(width, dist_code); - if (src - data < dist || src_end - src < length) { - ok = 0; - goto End; - } - { - int i; - for (i = 0; i < length; ++i) src[i] = src[i - dist]; - src += length; - } - col += length; - while (col >= width) { - col -= width; - ++row; - if ((process_func != NULL) && (row % NUM_ARGB_CACHE_ROWS == 0)) { - process_func(dec, row); - } - } - if (src < src_end) { - htree_group = GetHtreeGroupForPos(hdr, col, row); - if (color_cache != NULL) { - while (last_cached < src) { - VP8LColorCacheInsert(color_cache, *last_cached++); - } - } - } - } else if (code < color_cache_limit) { // Color cache. - const int key = code - len_code_limit; - assert(color_cache != NULL); - while (last_cached < src) { - VP8LColorCacheInsert(color_cache, *last_cached++); - } - *src = VP8LColorCacheLookup(color_cache, key); - goto AdvanceByOne; - } else { // Not reached. - ok = 0; - goto End; - } - ok = !br->error_; - if (!ok) goto End; - } - // Process the remaining rows corresponding to last row-block. - if (process_func != NULL) process_func(dec, row); - - End: - if (br->error_ || !ok || (br->eos_ && src < src_end)) { - ok = 0; - dec->status_ = (!br->eos_) ? - VP8_STATUS_BITSTREAM_ERROR : VP8_STATUS_SUSPENDED; - } else if (src == src_end) { - dec->state_ = READ_DATA; - } - - return ok; +#define DECODE_DATA_FUNC(FUNC_NAME, TYPE, STORE_PIXEL) \ +static int FUNC_NAME(VP8LDecoder* const dec, TYPE* const data, int width, \ + int height, ProcessRowsFunc process_func) { \ + int ok = 1; \ + int col = 0, row = 0; \ + VP8LBitReader* const br = &dec->br_; \ + VP8LMetadata* const hdr = &dec->hdr_; \ + HTreeGroup* htree_group = hdr->htree_groups_; \ + TYPE* src = data; \ + TYPE* last_cached = data; \ + TYPE* const src_end = data + width * height; \ + const int len_code_limit = NUM_LITERAL_CODES + NUM_LENGTH_CODES; \ + const int color_cache_limit = len_code_limit + hdr->color_cache_size_; \ + VP8LColorCache* const color_cache = \ + (hdr->color_cache_size_ > 0) ? &hdr->color_cache_ : NULL; \ + const int mask = hdr->huffman_mask_; \ + assert(htree_group != NULL); \ + while (!br->eos_ && src < src_end) { \ + int code; \ + /* Only update when changing tile. Note we could use this test: */ \ + /* if "((((prev_col ^ col) | prev_row ^ row)) > mask)" -> tile changed */ \ + /* but that's actually slower and needs storing the previous col/row. */ \ + if ((col & mask) == 0) { \ + htree_group = GetHtreeGroupForPos(hdr, col, row); \ + } \ + VP8LFillBitWindow(br); \ + code = ReadSymbol(&htree_group->htrees_[GREEN], br); \ + if (code < NUM_LITERAL_CODES) { /* Literal*/ \ + int red, green, blue, alpha; \ + red = ReadSymbol(&htree_group->htrees_[RED], br); \ + green = code; \ + VP8LFillBitWindow(br); \ + blue = ReadSymbol(&htree_group->htrees_[BLUE], br); \ + alpha = ReadSymbol(&htree_group->htrees_[ALPHA], br); \ + *src = STORE_PIXEL(alpha, red, green, blue); \ + AdvanceByOne: \ + ++src; \ + ++col; \ + if (col >= width) { \ + col = 0; \ + ++row; \ + if ((process_func != NULL) && (row % NUM_ARGB_CACHE_ROWS == 0)) { \ + process_func(dec, row); \ + } \ + if (color_cache != NULL) { \ + while (last_cached < src) { \ + VP8LColorCacheInsert(color_cache, *last_cached++); \ + } \ + } \ + } \ + } else if (code < len_code_limit) { /* Backward reference */ \ + int dist_code, dist; \ + const int length_sym = code - NUM_LITERAL_CODES; \ + const int length = GetCopyLength(length_sym, br); \ + const int dist_symbol = ReadSymbol(&htree_group->htrees_[DIST], br); \ + VP8LFillBitWindow(br); \ + dist_code = GetCopyDistance(dist_symbol, br); \ + dist = PlaneCodeToDistance(width, dist_code); \ + if (src - data < dist || src_end - src < length) { \ + ok = 0; \ + goto End; \ + } \ + { \ + int i; \ + for (i = 0; i < length; ++i) src[i] = src[i - dist]; \ + src += length; \ + } \ + col += length; \ + while (col >= width) { \ + col -= width; \ + ++row; \ + if ((process_func != NULL) && (row % NUM_ARGB_CACHE_ROWS == 0)) { \ + process_func(dec, row); \ + } \ + } \ + if (src < src_end) { \ + htree_group = GetHtreeGroupForPos(hdr, col, row); \ + if (color_cache != NULL) { \ + while (last_cached < src) { \ + VP8LColorCacheInsert(color_cache, *last_cached++); \ + } \ + } \ + } \ + } else if (code < color_cache_limit) { /* Color cache */ \ + const int key = code - len_code_limit; \ + assert(color_cache != NULL); \ + while (last_cached < src) { \ + VP8LColorCacheInsert(color_cache, *last_cached++); \ + } \ + *src = VP8LColorCacheLookup(color_cache, key); \ + goto AdvanceByOne; \ + } else { /* Not reached */ \ + ok = 0; \ + goto End; \ + } \ + ok = !br->error_; \ + if (!ok) goto End; \ + } \ + /* Process the remaining rows corresponding to last row-block. */ \ + if (process_func != NULL) process_func(dec, row); \ +End: \ + if (br->error_ || !ok || (br->eos_ && src < src_end)) { \ + ok = 0; \ + dec->status_ = \ + (!br->eos_) ? VP8_STATUS_BITSTREAM_ERROR : VP8_STATUS_SUSPENDED; \ + } else if (src == src_end) { \ + dec->state_ = READ_DATA; \ + } \ + return ok; \ } +static WEBP_INLINE uint32_t GetARGBPixel(int alpha, int red, int green, + int blue) { + return (alpha << 24) | (red << 16) | (green << 8) | blue; +} + +static WEBP_INLINE uint8_t GetAlphaPixel(int alpha, int red, int green, + int blue) { + (void)alpha; + (void)red; + (void)blue; + return green; // Alpha value is stored in green channel. +} + +DECODE_DATA_FUNC(DecodeImageData, uint32_t, GetARGBPixel) +DECODE_DATA_FUNC(DecodeAlphaData, uint8_t, GetAlphaPixel) + +#undef DECODE_DATA_FUNC + // ----------------------------------------------------------------------------- // VP8LTransform @@ -903,8 +931,8 @@ void VP8LClear(VP8LDecoder* const dec) { if (dec == NULL) return; ClearMetadata(&dec->hdr_); - free(dec->argb_); - dec->argb_ = NULL; + free(dec->pixels_); + dec->pixels_ = NULL; for (i = 0; i < dec->next_transform_; ++i) { ClearTransform(&dec->transforms_[i]); } @@ -1028,35 +1056,38 @@ static int DecodeImageStream(int xsize, int ysize, } //------------------------------------------------------------------------------ -// Allocate dec->argb_ and dec->argb_cache_ using dec->width_ and dec->height_ - -static int AllocateARGBBuffers(VP8LDecoder* const dec, int final_width) { +// Allocate internal buffers dec->pixels_ and dec->argb_cache_. +static int AllocateInternalBuffers(VP8LDecoder* const dec, int final_width, + size_t bytes_per_pixel) { + const int argb_cache_needed = (bytes_per_pixel == sizeof(uint32_t)); const uint64_t num_pixels = (uint64_t)dec->width_ * dec->height_; // Scratch buffer corresponding to top-prediction row for transforming the - // first row in the row-blocks. - const uint64_t cache_top_pixels = final_width; - // Scratch buffer for temporary BGRA storage. - const uint64_t cache_pixels = (uint64_t)final_width * NUM_ARGB_CACHE_ROWS; + // first row in the row-blocks. Not needed for paletted alpha. + const uint64_t cache_top_pixels = argb_cache_needed ? final_width : 0ULL; + // Scratch buffer for temporary BGRA storage. Not needed for paletted alpha. + const uint64_t cache_pixels = + argb_cache_needed ? (uint64_t)final_width * NUM_ARGB_CACHE_ROWS : 0ULL; const uint64_t total_num_pixels = num_pixels + cache_top_pixels + cache_pixels; assert(dec->width_ <= final_width); - dec->argb_ = (uint32_t*)WebPSafeMalloc(total_num_pixels, sizeof(*dec->argb_)); - if (dec->argb_ == NULL) { + dec->pixels_ = (uint32_t*)WebPSafeMalloc(total_num_pixels, bytes_per_pixel); + if (dec->pixels_ == NULL) { dec->argb_cache_ = NULL; // for sanity check dec->status_ = VP8_STATUS_OUT_OF_MEMORY; return 0; } - dec->argb_cache_ = dec->argb_ + num_pixels + cache_top_pixels; + dec->argb_cache_ = + argb_cache_needed ? dec->pixels_ + num_pixels + cache_top_pixels : NULL; return 1; } //------------------------------------------------------------------------------ -// Special row-processing that only stores the alpha data. +// Special row-processing that only stores the alpha data. static void ExtractAlphaRows(VP8LDecoder* const dec, int row) { const int num_rows = row - dec->last_row_; - const uint32_t* const in = dec->argb_ + dec->width_ * dec->last_row_; + const uint32_t* const in = dec->pixels_ + dec->width_ * dec->last_row_; if (num_rows <= 0) return; // Nothing to be done. ApplyInverseTransforms(dec, num_rows, in); @@ -1070,7 +1101,17 @@ static void ExtractAlphaRows(VP8LDecoder* const dec, int row) { int i; for (i = 0; i < cache_pixs; ++i) dst[i] = (src[i] >> 8) & 0xff; } + dec->last_row_ = dec->last_out_row_ = row; +} +// Row-processing for the special case when alpha data contains only one +// transform: color indexing. +static void ExtractPalettedAlphaRows(VP8LDecoder* const dec, int row) { + const int num_rows = row - dec->last_row_; + const uint8_t* const in = + (uint8_t*)dec->pixels_ + dec->width_ * dec->last_row_; + if (num_rows <= 0) return; // Nothing to be done. + ApplyInverseTransformsAlpha(dec, num_rows, in); dec->last_row_ = dec->last_out_row_ = row; } @@ -1079,6 +1120,7 @@ int VP8LDecodeAlphaImageStream(int width, int height, const uint8_t* const data, VP8Io io; int ok = 0; VP8LDecoder* const dec = VP8LNew(); + size_t bytes_per_pixel = sizeof(uint32_t); // Default: BGRA mode. if (dec == NULL) return 0; dec->width_ = width; @@ -1097,13 +1139,24 @@ int VP8LDecodeAlphaImageStream(int width, int height, const uint8_t* const data, dec->action_ = READ_HDR; if (!DecodeImageStream(width, height, 1, dec, NULL)) goto Err; - // Allocate output (note that dec->width_ may have changed here). - if (!AllocateARGBBuffers(dec, width)) goto Err; + // Special case: if alpha data contains only the color indexing transform + // (a frequent case), we will use DecodeAlphaData() method that only needs + // allocation of 1 byte per pixel (alpha channel). + if (dec->next_transform_ == 1 && + dec->transforms_[0].type_ == COLOR_INDEXING_TRANSFORM) { + bytes_per_pixel = sizeof(uint8_t); + } + + // Allocate internal buffers (note that dec->width_ may have changed here). + if (!AllocateInternalBuffers(dec, width, bytes_per_pixel)) goto Err; // Decode (with special row processing). dec->action_ = READ_DATA; - ok = DecodeImageData(dec, dec->argb_, dec->width_, dec->height_, - ExtractAlphaRows); + ok = (bytes_per_pixel == sizeof(uint8_t)) ? + DecodeAlphaData(dec, (uint8_t*)dec->pixels_, dec->width_, dec->height_, + ExtractPalettedAlphaRows) : + DecodeImageData(dec, dec->pixels_, dec->width_, dec->height_, + ExtractAlphaRows); Err: VP8LDelete(dec); @@ -1143,6 +1196,7 @@ int VP8LDecodeHeader(VP8LDecoder* const dec, VP8Io* const io) { } int VP8LDecodeImage(VP8LDecoder* const dec) { + const size_t bytes_per_pixel = sizeof(uint32_t); VP8Io* io = NULL; WebPDecParams* params = NULL; @@ -1162,13 +1216,13 @@ int VP8LDecodeImage(VP8LDecoder* const dec) { goto Err; } - if (!AllocateARGBBuffers(dec, io->width)) goto Err; + if (!AllocateInternalBuffers(dec, io->width, bytes_per_pixel)) goto Err; if (io->use_scaling && !AllocateAndInitRescaler(dec, io)) goto Err; // Decode. dec->action_ = READ_DATA; - if (!DecodeImageData(dec, dec->argb_, dec->width_, dec->height_, + if (!DecodeImageData(dec, dec->pixels_, dec->width_, dec->height_, ProcessRows)) { goto Err; } diff --git a/src/dec/vp8li.h b/src/dec/vp8li.h index ee29eb5f..8b240585 100644 --- a/src/dec/vp8li.h +++ b/src/dec/vp8li.h @@ -63,7 +63,8 @@ typedef struct { const WebPDecBuffer *output_; // shortcut to io->opaque->output - uint32_t *argb_; // Internal data: always in BGRA color mode. + uint32_t *pixels_; // Internal data: either uint8_t* for alpha + // or uint32_t* for BGRA. uint32_t *argb_cache_; // Scratch buffer for temporary BGRA storage. VP8LBitReader br_; diff --git a/src/dsp/lossless.c b/src/dsp/lossless.c index c015b7ad..1060cbd3 100644 --- a/src/dsp/lossless.c +++ b/src/dsp/lossless.c @@ -1093,39 +1093,64 @@ static void ColorSpaceInverseTransform(const VP8LTransform* const transform, } // Separate out pixels packed together using pixel-bundling. -static void ColorIndexInverseTransform( - const VP8LTransform* const transform, - int y_start, int y_end, const uint32_t* src, uint32_t* dst) { - int y; - const int bits_per_pixel = 8 >> transform->bits_; - const int width = transform->xsize_; - const uint32_t* const color_map = transform->data_; - if (bits_per_pixel < 8) { - const int pixels_per_byte = 1 << transform->bits_; - const int count_mask = pixels_per_byte - 1; - const uint32_t bit_mask = (1 << bits_per_pixel) - 1; - for (y = y_start; y < y_end; ++y) { - uint32_t packed_pixels = 0; - int x; - for (x = 0; x < width; ++x) { - // We need to load fresh 'packed_pixels' once every 'pixels_per_byte' - // increments of x. Fortunately, pixels_per_byte is a power of 2, so - // can just use a mask for that, instead of decrementing a counter. - if ((x & count_mask) == 0) packed_pixels = ((*src++) >> 8) & 0xff; - *dst++ = color_map[packed_pixels & bit_mask]; - packed_pixels >>= bits_per_pixel; - } - } - } else { - for (y = y_start; y < y_end; ++y) { - int x; - for (x = 0; x < width; ++x) { - *dst++ = color_map[((*src++) >> 8) & 0xff]; - } - } - } +// We define two methods for ARGB data (uint32_t) and alpha-only data (uint8_t). +#define COLOR_INDEX_INVERSE(FUNC_NAME, TYPE, GET_INDEX, GET_VALUE) \ +void FUNC_NAME(const VP8LTransform* const transform, \ + int y_start, int y_end, const TYPE* src, TYPE* dst) { \ + int y; \ + const int bits_per_pixel = 8 >> transform->bits_; \ + const int width = transform->xsize_; \ + const uint32_t* const color_map = transform->data_; \ + if (bits_per_pixel < 8) { \ + const int pixels_per_byte = 1 << transform->bits_; \ + const int count_mask = pixels_per_byte - 1; \ + const uint32_t bit_mask = (1 << bits_per_pixel) - 1; \ + for (y = y_start; y < y_end; ++y) { \ + uint32_t packed_pixels = 0; \ + int x; \ + for (x = 0; x < width; ++x) { \ + /* We need to load fresh 'packed_pixels' once every */ \ + /* 'pixels_per_byte' increments of x. Fortunately, pixels_per_byte */ \ + /* is a power of 2, so can just use a mask for that, instead of */ \ + /* decrementing a counter. */ \ + if ((x & count_mask) == 0) packed_pixels = GET_INDEX(*src++); \ + *dst++ = GET_VALUE(color_map[packed_pixels & bit_mask]); \ + packed_pixels >>= bits_per_pixel; \ + } \ + } \ + } else { \ + for (y = y_start; y < y_end; ++y) { \ + int x; \ + for (x = 0; x < width; ++x) { \ + *dst++ = GET_VALUE(color_map[GET_INDEX(*src++)]); \ + } \ + } \ + } \ } +static WEBP_INLINE uint32_t GetARGBIndex(uint32_t index) { + return (index >> 8) & 0xff; +} + +static WEBP_INLINE uint8_t GetAlphaIndex(uint8_t index) { + return index; +} + +static WEBP_INLINE uint32_t GetARGBValue(uint32_t val) { + return val; +} + +static WEBP_INLINE uint8_t GetAlphaValue(uint32_t val) { + return (val >> 8) & 0xff; +} + +static COLOR_INDEX_INVERSE(ColorIndexInverseTransform, uint32_t, GetARGBIndex, + GetARGBValue) +COLOR_INDEX_INVERSE(VP8LColorIndexInverseTransformAlpha, uint8_t, GetAlphaIndex, + GetAlphaValue) + +#undef COLOR_INDEX_INVERSE + void VP8LInverseTransform(const VP8LTransform* const transform, int row_start, int row_end, const uint32_t* const in, uint32_t* const out) { diff --git a/src/dsp/lossless.h b/src/dsp/lossless.h index 6742bcc8..3fd224e6 100644 --- a/src/dsp/lossless.h +++ b/src/dsp/lossless.h @@ -33,6 +33,13 @@ void VP8LInverseTransform(const struct VP8LTransform* const transform, int row_start, int row_end, const uint32_t* const in, uint32_t* const out); +// Similar to the static method ColorIndexInverseTransform() that is part of +// lossless.c, but used only for alpha decoding. It takes uint8_t (rather than +// uint32_t) arguments for 'src' and 'dst'. +void VP8LColorIndexInverseTransformAlpha( + const struct VP8LTransform* const transform, int y_start, int y_end, + const uint8_t* src, uint8_t* dst); + // Subtracts green from blue and red channels. void VP8LSubtractGreenFromBlueAndRed(uint32_t* argb_data, int num_pixs); From 8112c8cf544a261cc89d54e91cad95d44c2486bb Mon Sep 17 00:00:00 2001 From: skal Date: Tue, 14 May 2013 22:28:32 +0200 Subject: [PATCH 30/57] remove some warnings: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * "declaration of ‘index’ shadows a global declaration [-Wshadow]" * "signed and unsigned type in conditional expression [-Wsign-compare]" Change-Id: I891182d919b18b6c84048486e0385027bd93b57d (cherry picked from commit 87a4fca25f6ead8a244003d63ccb0d0b4529dc55) --- src/dec/vp8l.c | 3 ++- src/dsp/lossless.c | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/dec/vp8l.c b/src/dec/vp8l.c index 19858822..395b36d7 100644 --- a/src/dec/vp8l.c +++ b/src/dec/vp8l.c @@ -1063,7 +1063,8 @@ static int AllocateInternalBuffers(VP8LDecoder* const dec, int final_width, const uint64_t num_pixels = (uint64_t)dec->width_ * dec->height_; // Scratch buffer corresponding to top-prediction row for transforming the // first row in the row-blocks. Not needed for paletted alpha. - const uint64_t cache_top_pixels = argb_cache_needed ? final_width : 0ULL; + const uint64_t cache_top_pixels = + argb_cache_needed ? (uint16_t)final_width : 0ULL; // Scratch buffer for temporary BGRA storage. Not needed for paletted alpha. const uint64_t cache_pixels = argb_cache_needed ? (uint64_t)final_width * NUM_ARGB_CACHE_ROWS : 0ULL; diff --git a/src/dsp/lossless.c b/src/dsp/lossless.c index 1060cbd3..8c0960ad 100644 --- a/src/dsp/lossless.c +++ b/src/dsp/lossless.c @@ -1128,12 +1128,12 @@ void FUNC_NAME(const VP8LTransform* const transform, \ } \ } -static WEBP_INLINE uint32_t GetARGBIndex(uint32_t index) { - return (index >> 8) & 0xff; +static WEBP_INLINE uint32_t GetARGBIndex(uint32_t idx) { + return (idx >> 8) & 0xff; } -static WEBP_INLINE uint8_t GetAlphaIndex(uint8_t index) { - return index; +static WEBP_INLINE uint8_t GetAlphaIndex(uint8_t idx) { + return idx; } static WEBP_INLINE uint32_t GetARGBValue(uint32_t val) { From f036d4bfa6ddbd4f914ba10ff33ae03e6f5066c4 Mon Sep 17 00:00:00 2001 From: Vikas Arora Date: Thu, 16 May 2013 15:43:12 -0700 Subject: [PATCH 31/57] Speed up ApplyPalette for ARGB pixels. Added 1 pixel cache for palette colors for faster lookup. This will speedup images that require ApplyPalette by 6.5% for lossless compression. Change-Id: Id0c5174d797ffabdb09905c2ba76e60601b686f8 (cherry picked from commit 742110ccce25cc573532231cbea5e4a3323bbd2e) --- src/enc/vp8l.c | 98 +++++++++++++++++++++++++++++--------------------- 1 file changed, 57 insertions(+), 41 deletions(-) diff --git a/src/enc/vp8l.c b/src/enc/vp8l.c index 8af544ff..1797b7cc 100644 --- a/src/enc/vp8l.c +++ b/src/enc/vp8l.c @@ -86,7 +86,7 @@ static int AnalyzeAndCreatePalette(const WebPPicture* const pic, argb += pic->argb_stride; } - // TODO(skal): could we reuse in_use[] to speed up ApplyPalette()? + // TODO(skal): could we reuse in_use[] to speed up EncodePalette()? num_colors = 0; for (i = 0; i < (int)(sizeof(in_use) / sizeof(in_use[0])); ++i) { if (in_use[i]) { @@ -811,39 +811,12 @@ static WebPEncodingError AllocateTransformBuffer(VP8LEncoder* const enc, return err; } -// Note: Expects "enc->palette_" to be set properly. -// Also, "enc->palette_" will be modified after this call and should not be used -// later. -static WebPEncodingError ApplyPalette(VP8LBitWriter* const bw, - VP8LEncoder* const enc, int quality) { - WebPEncodingError err = VP8_ENC_OK; +static void ApplyPalette(uint32_t* src, uint32_t* dst, + uint32_t src_stride, uint32_t dst_stride, + const uint32_t* palette, int palette_size, + int width, int height, int xbits, uint8_t* row) { int i, x, y; - const WebPPicture* const pic = enc->pic_; - uint32_t* src = pic->argb; - uint32_t* dst; - const int width = pic->width; - const int height = pic->height; - uint32_t* const palette = enc->palette_; - const int palette_size = enc->palette_size_; - uint8_t* row = NULL; - int xbits; int is_alpha = 1; - - // Replace each input pixel by corresponding palette index. - // This is done line by line. - if (palette_size <= 4) { - xbits = (palette_size <= 2) ? 3 : 2; - } else { - xbits = (palette_size <= 16) ? 1 : 0; - } - - err = AllocateTransformBuffer(enc, VP8LSubSampleSize(width, xbits), height); - if (err != VP8_ENC_OK) goto Error; - dst = enc->argb_; - - row = WebPSafeMalloc((uint64_t)width, sizeof(*row)); - if (row == NULL) return VP8_ENC_ERROR_OUT_OF_MEMORY; - for (i = 0; i < palette_size; ++i) { if ((palette[i] & 0x00ff00ffu) != 0) { is_alpha = 0; @@ -863,25 +836,68 @@ static WebPEncodingError ApplyPalette(VP8LBitWriter* const bw, row[x] = inv_palette[color]; } VP8LBundleColorMap(row, width, xbits, dst); - src += pic->argb_stride; - dst += enc->current_width_; + src += src_stride; + dst += dst_stride; } } else { + // Use 1 pixel cache for ARGB pixels. + uint32_t last_pix = palette[0]; + int last_idx = 0; for (y = 0; y < height; ++y) { for (x = 0; x < width; ++x) { const uint32_t pix = src[x]; - for (i = 0; i < palette_size; ++i) { - if (pix == palette[i]) { - row[x] = i; - break; + if (pix != last_pix) { + for (i = 0; i < palette_size; ++i) { + if (pix == palette[i]) { + last_idx = i; + last_pix = pix; + break; + } } } + row[x] = last_idx; } VP8LBundleColorMap(row, width, xbits, dst); - src += pic->argb_stride; - dst += enc->current_width_; + src += src_stride; + dst += dst_stride; } } +} + +// Note: Expects "enc->palette_" to be set properly. +// Also, "enc->palette_" will be modified after this call and should not be used +// later. +static WebPEncodingError EncodePalette(VP8LBitWriter* const bw, + VP8LEncoder* const enc, int quality) { + WebPEncodingError err = VP8_ENC_OK; + int i; + const WebPPicture* const pic = enc->pic_; + uint32_t* src = pic->argb; + uint32_t* dst; + const int width = pic->width; + const int height = pic->height; + uint32_t* const palette = enc->palette_; + const int palette_size = enc->palette_size_; + uint8_t* row = NULL; + int xbits; + + // Replace each input pixel by corresponding palette index. + // This is done line by line. + if (palette_size <= 4) { + xbits = (palette_size <= 2) ? 3 : 2; + } else { + xbits = (palette_size <= 16) ? 1 : 0; + } + + err = AllocateTransformBuffer(enc, VP8LSubSampleSize(width, xbits), height); + if (err != VP8_ENC_OK) goto Error; + dst = enc->argb_; + + row = WebPSafeMalloc((uint64_t)width, sizeof(*row)); + if (row == NULL) return VP8_ENC_ERROR_OUT_OF_MEMORY; + + ApplyPalette(src, dst, pic->argb_stride, enc->current_width_, + palette, palette_size, width, height, xbits, row); // Save palette to bitstream. VP8LWriteBits(bw, 1, TRANSFORM_PRESENT); @@ -978,7 +994,7 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config, FinishEncParams(enc); if (enc->use_palette_) { - err = ApplyPalette(bw, enc, quality); + err = EncodePalette(bw, enc, quality); if (err != VP8_ENC_OK) goto Error; // Color cache is disabled for palette. enc->cache_bits_ = 0; From 7bb28d2a55dfb253b29a3cb4d795d94253245bd0 Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 16 May 2013 13:47:15 -0700 Subject: [PATCH 32/57] webp/lossless: fix big endian BGRA output Change-Id: I3d4b3d21f561cb526dbe7697a31ea847d3e8b2c1 (cherry picked from commit 2ca83968ae53bfdad3100882be9d3628b0e7aa9e) --- src/dsp/lossless.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/dsp/lossless.c b/src/dsp/lossless.c index 8c0960ad..f9078071 100644 --- a/src/dsp/lossless.c +++ b/src/dsp/lossless.c @@ -1279,11 +1279,12 @@ static void CopyOrSwap(const uint32_t* src, int num_pixels, uint8_t* dst, while (src < src_end) { uint32_t argb = *src++; +#if !defined(__BIG_ENDIAN__) #if !defined(WEBP_REFERENCE_IMPLEMENTATION) -#if !defined(__BIG_ENDIAN__) && (defined(__i386__) || defined(__x86_64__)) +#if defined(__i386__) || defined(__x86_64__) __asm__ volatile("bswap %0" : "=r"(argb) : "0"(argb)); *(uint32_t*)dst = argb; -#elif !defined(__BIG_ENDIAN__) && defined(_MSC_VER) +#elif defined(_MSC_VER) argb = _byteswap_ulong(argb); *(uint32_t*)dst = argb; #else @@ -1292,11 +1293,17 @@ static void CopyOrSwap(const uint32_t* src, int num_pixels, uint8_t* dst, dst[2] = (argb >> 8) & 0xff; dst[3] = (argb >> 0) & 0xff; #endif -#else // WEBP_REFERENCE_IMPLEMENTATION +#else // WEBP_REFERENCE_IMPLEMENTATION dst[0] = (argb >> 24) & 0xff; dst[1] = (argb >> 16) & 0xff; dst[2] = (argb >> 8) & 0xff; dst[3] = (argb >> 0) & 0xff; +#endif +#else // __BIG_ENDIAN__ + dst[0] = (argb >> 0) & 0xff; + dst[1] = (argb >> 8) & 0xff; + dst[2] = (argb >> 16) & 0xff; + dst[3] = (argb >> 24) & 0xff; #endif dst += sizeof(argb); } From a2ea46439ec5c7a72ede729399223913b70f5f1a Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 18 May 2013 17:03:18 +0200 Subject: [PATCH 33/57] Fix the bug in ApplyPalette. The auto-infer logic of detecting the 'Alpha' use case (via check '(palette[i] & 0x00ff00ffu) != 0' is failing for this corner case image with all black pixels (rgb = 0) and different Alpha values. -> switch generic use-LUT detection Change-Id: I982a8b28c8bcc43e3dc68ac358f978a4bcc14c36 (cherry picked from commit afa3450c11d968f73f0230b8756df6ee660d9a84) --- src/enc/vp8l.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/enc/vp8l.c b/src/enc/vp8l.c index 1797b7cc..6422c544 100644 --- a/src/enc/vp8l.c +++ b/src/enc/vp8l.c @@ -816,15 +816,15 @@ static void ApplyPalette(uint32_t* src, uint32_t* dst, const uint32_t* palette, int palette_size, int width, int height, int xbits, uint8_t* row) { int i, x, y; - int is_alpha = 1; + int use_LUT = 1; for (i = 0; i < palette_size; ++i) { - if ((palette[i] & 0x00ff00ffu) != 0) { - is_alpha = 0; + if ((palette[i] & 0xffff00ffu) != 0) { + use_LUT = 0; break; } } - if (is_alpha) { + if (use_LUT) { int inv_palette[MAX_PALETTE_SIZE] = { 0 }; for (i = 0; i < palette_size; ++i) { const int color = (palette[i] >> 8) & 0xff; From 6fe536f4bac786b0688144e8426a44a0ecfab3b1 Mon Sep 17 00:00:00 2001 From: James Zern Date: Fri, 17 May 2013 14:10:37 -0700 Subject: [PATCH 34/57] swig/java: rework uint8_t typemap reuse the declarations from arrays_java.i for signed char to make an explicit uint8_t mapping. this avoids sign conversion build warnings. Change-Id: Icfb5b865cf1fd404e89f2cd889111f0a94e3c604 (cherry picked from commit ad4a367dba292f2bdaab19f87114eaabc035ca8d) --- swig/libwebp.i | 10 ++- swig/libwebp_java_wrap.c | 160 ++++++++++++++++++++++++++------------- 2 files changed, 115 insertions(+), 55 deletions(-) diff --git a/swig/libwebp.i b/swig/libwebp.i index 7156dbec..0cb7ccce 100644 --- a/swig/libwebp.i +++ b/swig/libwebp.i @@ -38,8 +38,14 @@ See: http://www.swig.org/Doc1.3/Java.html#enumerations */ // map uint8_t* such that a byte[] is used -// this will generate a few spurious warnings in the wrapper code -%apply signed char[] { uint8_t* } +%{ +#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 diff --git a/swig/libwebp_java_wrap.c b/swig/libwebp_java_wrap.c index 1ba22925..10960ebd 100644 --- a/swig/libwebp_java_wrap.c +++ b/swig/libwebp_java_wrap.c @@ -187,18 +187,18 @@ static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionC #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_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 @@ -808,6 +808,60 @@ jdoubleArray SWIG_JavaArrayOutDouble (JNIEnv *jenv, double *result, jsize sz) { #endif +#include "webp/types.h" + + +int SWIG_JavaArrayInUint8 (JNIEnv *jenv, jbyte **jarr, uint8_t **carr, jbyteArray input); +void SWIG_JavaArrayArgoutUint8 (JNIEnv *jenv, jbyte *jarr, uint8_t *carr, jbyteArray input); +jbyteArray SWIG_JavaArrayOutUint8 (JNIEnv *jenv, uint8_t *result, jsize sz); + + +/* uint8_t[] support */ +int SWIG_JavaArrayInUint8 (JNIEnv *jenv, jbyte **jarr, uint8_t **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 = (uint8_t*) calloc(sz, sizeof(uint8_t)); + 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_JavaArrayOutUint8 (JNIEnv *jenv, uint8_t *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; +} + + #include "webp/decode.h" #include "webp/encode.h" @@ -971,7 +1025,7 @@ SWIGEXPORT jint JNICALL Java_com_google_webp_libwebpJNI_WebPGetInfo(JNIEnv *jenv (void)jenv; (void)jcls; - if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + if (!SWIG_JavaArrayInUint8(jenv, &jarr1, &arg1, jarg1)) return 0; arg2 = (size_t)jarg2; { if (!jarg3) { @@ -997,7 +1051,7 @@ SWIGEXPORT jint JNICALL Java_com_google_webp_libwebpJNI_WebPGetInfo(JNIEnv *jenv } result = (int)WebPGetInfo((uint8_t const *)arg1,arg2,arg3,arg4); jresult = (jint)result; - SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + SWIG_JavaArrayArgoutUint8(jenv, jarr1, arg1, jarg1); { jint jvalue = (jint)temp3; (*jenv)->SetIntArrayRegion(jenv, jarg3, 0, 1, &jvalue); @@ -1026,7 +1080,7 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_WebPDecodeRGB(JNIE (void)jenv; (void)jcls; - if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + if (!SWIG_JavaArrayInUint8(jenv, &jarr1, &arg1, jarg1)) return 0; arg2 = (size_t)jarg2; { if (!jarg3) { @@ -1051,8 +1105,8 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_WebPDecodeRGB(JNIE arg4 = &temp4; } result = (uint8_t *)WebPDecodeRGB((uint8_t const *)arg1,arg2,arg3,arg4); - jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); - SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + jresult = SWIG_JavaArrayOutUint8(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); + SWIG_JavaArrayArgoutUint8(jenv, jarr1, arg1, jarg1); { jint jvalue = (jint)temp3; (*jenv)->SetIntArrayRegion(jenv, jarg3, 0, 1, &jvalue); @@ -1082,7 +1136,7 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_WebPDecodeRGBA(JNI (void)jenv; (void)jcls; - if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + if (!SWIG_JavaArrayInUint8(jenv, &jarr1, &arg1, jarg1)) return 0; arg2 = (size_t)jarg2; { if (!jarg3) { @@ -1107,8 +1161,8 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_WebPDecodeRGBA(JNI arg4 = &temp4; } result = (uint8_t *)WebPDecodeRGBA((uint8_t const *)arg1,arg2,arg3,arg4); - jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); - SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + jresult = SWIG_JavaArrayOutUint8(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); + SWIG_JavaArrayArgoutUint8(jenv, jarr1, arg1, jarg1); { jint jvalue = (jint)temp3; (*jenv)->SetIntArrayRegion(jenv, jarg3, 0, 1, &jvalue); @@ -1138,7 +1192,7 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_WebPDecodeARGB(JNI (void)jenv; (void)jcls; - if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + if (!SWIG_JavaArrayInUint8(jenv, &jarr1, &arg1, jarg1)) return 0; arg2 = (size_t)jarg2; { if (!jarg3) { @@ -1163,8 +1217,8 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_WebPDecodeARGB(JNI arg4 = &temp4; } result = (uint8_t *)WebPDecodeARGB((uint8_t const *)arg1,arg2,arg3,arg4); - jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); - SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + jresult = SWIG_JavaArrayOutUint8(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); + SWIG_JavaArrayArgoutUint8(jenv, jarr1, arg1, jarg1); { jint jvalue = (jint)temp3; (*jenv)->SetIntArrayRegion(jenv, jarg3, 0, 1, &jvalue); @@ -1194,7 +1248,7 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_WebPDecodeBGR(JNIE (void)jenv; (void)jcls; - if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + if (!SWIG_JavaArrayInUint8(jenv, &jarr1, &arg1, jarg1)) return 0; arg2 = (size_t)jarg2; { if (!jarg3) { @@ -1219,8 +1273,8 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_WebPDecodeBGR(JNIE arg4 = &temp4; } result = (uint8_t *)WebPDecodeBGR((uint8_t const *)arg1,arg2,arg3,arg4); - jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); - SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + jresult = SWIG_JavaArrayOutUint8(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); + SWIG_JavaArrayArgoutUint8(jenv, jarr1, arg1, jarg1); { jint jvalue = (jint)temp3; (*jenv)->SetIntArrayRegion(jenv, jarg3, 0, 1, &jvalue); @@ -1250,7 +1304,7 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_WebPDecodeBGRA(JNI (void)jenv; (void)jcls; - if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + if (!SWIG_JavaArrayInUint8(jenv, &jarr1, &arg1, jarg1)) return 0; arg2 = (size_t)jarg2; { if (!jarg3) { @@ -1275,8 +1329,8 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_WebPDecodeBGRA(JNI arg4 = &temp4; } result = (uint8_t *)WebPDecodeBGRA((uint8_t const *)arg1,arg2,arg3,arg4); - jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); - SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + jresult = SWIG_JavaArrayOutUint8(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); + SWIG_JavaArrayArgoutUint8(jenv, jarr1, arg1, jarg1); { jint jvalue = (jint)temp3; (*jenv)->SetIntArrayRegion(jenv, jarg3, 0, 1, &jvalue); @@ -1321,7 +1375,7 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeRG (void)jenv; (void)jcls; - if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + if (!SWIG_JavaArrayInUint8(jenv, &jarr1, &arg1, jarg1)) return 0; arg2 = (int *)&jarg2; arg3 = (int *)&jarg3; { @@ -1340,8 +1394,8 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeRG arg7 = (int)jarg7; arg8 = (float)jarg8; result = (uint8_t *)wrap_WebPEncodeRGB((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); - jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); - SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + jresult = SWIG_JavaArrayOutUint8(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); + SWIG_JavaArrayArgoutUint8(jenv, jarr1, arg1, jarg1); { jint jvalue = (jint)temp4; (*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue); @@ -1371,7 +1425,7 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeBG (void)jenv; (void)jcls; - if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + if (!SWIG_JavaArrayInUint8(jenv, &jarr1, &arg1, jarg1)) return 0; arg2 = (int *)&jarg2; arg3 = (int *)&jarg3; { @@ -1390,8 +1444,8 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeBG arg7 = (int)jarg7; arg8 = (float)jarg8; result = (uint8_t *)wrap_WebPEncodeBGR((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); - jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); - SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + jresult = SWIG_JavaArrayOutUint8(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); + SWIG_JavaArrayArgoutUint8(jenv, jarr1, arg1, jarg1); { jint jvalue = (jint)temp4; (*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue); @@ -1421,7 +1475,7 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeRG (void)jenv; (void)jcls; - if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + if (!SWIG_JavaArrayInUint8(jenv, &jarr1, &arg1, jarg1)) return 0; arg2 = (int *)&jarg2; arg3 = (int *)&jarg3; { @@ -1440,8 +1494,8 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeRG arg7 = (int)jarg7; arg8 = (float)jarg8; result = (uint8_t *)wrap_WebPEncodeRGBA((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); - jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); - SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + jresult = SWIG_JavaArrayOutUint8(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); + SWIG_JavaArrayArgoutUint8(jenv, jarr1, arg1, jarg1); { jint jvalue = (jint)temp4; (*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue); @@ -1471,7 +1525,7 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeBG (void)jenv; (void)jcls; - if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + if (!SWIG_JavaArrayInUint8(jenv, &jarr1, &arg1, jarg1)) return 0; arg2 = (int *)&jarg2; arg3 = (int *)&jarg3; { @@ -1490,8 +1544,8 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeBG arg7 = (int)jarg7; arg8 = (float)jarg8; result = (uint8_t *)wrap_WebPEncodeBGRA((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); - jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); - SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + jresult = SWIG_JavaArrayOutUint8(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); + SWIG_JavaArrayArgoutUint8(jenv, jarr1, arg1, jarg1); { jint jvalue = (jint)temp4; (*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue); @@ -1520,7 +1574,7 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLo (void)jenv; (void)jcls; - if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + if (!SWIG_JavaArrayInUint8(jenv, &jarr1, &arg1, jarg1)) return 0; arg2 = (int *)&jarg2; arg3 = (int *)&jarg3; { @@ -1538,8 +1592,8 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLo arg6 = (int)jarg6; arg7 = (int)jarg7; result = (uint8_t *)wrap_WebPEncodeLosslessRGB((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7); - jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); - SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + jresult = SWIG_JavaArrayOutUint8(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); + SWIG_JavaArrayArgoutUint8(jenv, jarr1, arg1, jarg1); { jint jvalue = (jint)temp4; (*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue); @@ -1568,7 +1622,7 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLo (void)jenv; (void)jcls; - if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + if (!SWIG_JavaArrayInUint8(jenv, &jarr1, &arg1, jarg1)) return 0; arg2 = (int *)&jarg2; arg3 = (int *)&jarg3; { @@ -1586,8 +1640,8 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLo arg6 = (int)jarg6; arg7 = (int)jarg7; result = (uint8_t *)wrap_WebPEncodeLosslessBGR((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7); - jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); - SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + jresult = SWIG_JavaArrayOutUint8(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); + SWIG_JavaArrayArgoutUint8(jenv, jarr1, arg1, jarg1); { jint jvalue = (jint)temp4; (*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue); @@ -1616,7 +1670,7 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLo (void)jenv; (void)jcls; - if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + if (!SWIG_JavaArrayInUint8(jenv, &jarr1, &arg1, jarg1)) return 0; arg2 = (int *)&jarg2; arg3 = (int *)&jarg3; { @@ -1634,8 +1688,8 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLo arg6 = (int)jarg6; arg7 = (int)jarg7; result = (uint8_t *)wrap_WebPEncodeLosslessRGBA((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7); - jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); - SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + jresult = SWIG_JavaArrayOutUint8(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); + SWIG_JavaArrayArgoutUint8(jenv, jarr1, arg1, jarg1); { jint jvalue = (jint)temp4; (*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue); @@ -1664,7 +1718,7 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLo (void)jenv; (void)jcls; - if (!SWIG_JavaArrayInSchar(jenv, &jarr1, &arg1, jarg1)) return 0; + if (!SWIG_JavaArrayInUint8(jenv, &jarr1, &arg1, jarg1)) return 0; arg2 = (int *)&jarg2; arg3 = (int *)&jarg3; { @@ -1682,8 +1736,8 @@ SWIGEXPORT jbyteArray JNICALL Java_com_google_webp_libwebpJNI_wrap_1WebPEncodeLo arg6 = (int)jarg6; arg7 = (int)jarg7; result = (uint8_t *)wrap_WebPEncodeLosslessBGRA((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7); - jresult = SWIG_JavaArrayOutSchar(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); - SWIG_JavaArrayArgoutSchar(jenv, jarr1, arg1, jarg1); + jresult = SWIG_JavaArrayOutUint8(jenv, result, FillMeInAsSizeCannotBeDeterminedAutomatically); + SWIG_JavaArrayArgoutUint8(jenv, jarr1, arg1, jarg1); { jint jvalue = (jint)temp4; (*jenv)->SetIntArrayRegion(jenv, jarg4, 0, 1, &jvalue); From 6b931875acfd54ef35de6926c5cf4552e06e8443 Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 20 May 2013 17:03:35 -0700 Subject: [PATCH 35/57] swig/java: reduce wrapper function code duplication define a macro to emit the wrapper code Change-Id: I672416016162d6d9ce6f455d224044e0837e3ace (cherry picked from commit a5c297c842c96e899725328378ff14400176458b) --- swig/libwebp.i | 68 ++++++++++++++++------------------------------- swig/libwebp.jar | Bin 2143 -> 3099 bytes 2 files changed, 23 insertions(+), 45 deletions(-) diff --git a/swig/libwebp.i b/swig/libwebp.i index 0cb7ccce..b541c3f9 100644 --- a/swig/libwebp.i +++ b/swig/libwebp.i @@ -273,57 +273,35 @@ LOSSLESS_WRAPPER(WebPEncodeLosslessBGRA) %pragma(java) modulecode=%{ private static final int UNUSED = 1; private static int outputSize[] = { 0 }; +%} - public static byte[] WebPEncodeRGB(byte[] rgb, - int width, int height, int stride, - float quality_factor) { - return wrap_WebPEncodeRGB( + +%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 - public static byte[] WebPEncodeBGR(byte[] bgr, - int width, int height, int stride, - float quality_factor) { - return wrap_WebPEncodeBGR( - bgr, UNUSED, UNUSED, outputSize, width, height, stride, quality_factor); - } - - public static byte[] WebPEncodeRGBA(byte[] rgba, - int width, int height, int stride, - float quality_factor) { - return wrap_WebPEncodeRGBA( - rgba, UNUSED, UNUSED, outputSize, width, height, stride, quality_factor); - } - - public static byte[] WebPEncodeBGRA(byte[] bgra, - int width, int height, int stride, - float quality_factor) { - return wrap_WebPEncodeBGRA( - bgra, UNUSED, UNUSED, outputSize, width, height, stride, quality_factor); - } - - public static byte[] WebPEncodeLosslessRGB( +%define CALL_ENCODE_LOSSLESS_WRAPPER(func) +%pragma(java) modulecode=%{ + public static byte[] func( byte[] rgb, int width, int height, int stride) { - return wrap_WebPEncodeLosslessRGB( + return wrap_##func( rgb, UNUSED, UNUSED, outputSize, width, height, stride); } - - public static byte[] WebPEncodeLosslessBGR( - byte[] bgr, int width, int height, int stride) { - return wrap_WebPEncodeLosslessBGR( - bgr, UNUSED, UNUSED, outputSize, width, height, stride); - } - - public static byte[] WebPEncodeLosslessRGBA( - byte[] rgba, int width, int height, int stride) { - return wrap_WebPEncodeLosslessRGBA( - rgba, UNUSED, UNUSED, outputSize, width, height, stride); - } - - public static byte[] WebPEncodeLosslessBGRA( - byte[] bgra, int width, int height, int stride) { - return wrap_WebPEncodeLosslessBGRA( - bgra, 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 */ diff --git a/swig/libwebp.jar b/swig/libwebp.jar index 602f037ce69ec88363f3f4f95526f880da7c8b3d..6cc574b2d8d163b9aade3b5857e0bc646398ea94 100644 GIT binary patch literal 3099 zcmaJ@2{@E{7k|mVT+)QG-z-@N$r{VjYiqBSEizdG?!48n37^L zS;jJ!u1jS%Ql@OBRKA(&3w?ZNp7(kF&%Eb%-t(T{d(QbGV7pjA00##L5O%KC1lVMp z01IGcZfC3lg&$G<+5rH&00fMkgWQmx8=6ffi(-6Fbif4V z1$=yQ(Ko^qwTQ;g#&H^5%axh^X%N+LY$;#wIse!~Z;Pc_=0i(K2GsRKJ-SG~HR{`* zQ9$mFYB9SySSh;O(Yx{F6L3H}iUcFENjDFj3RKTY4tvw178pv> zqW?i0s+r6euaX_QH{p`fmcybT*G$0gwVaN;arGEgsSGot2+gXq{McXvpE`^e5U~N( zbWynoi)fb4cSmi|DC;$Fjt5AKl+MN=Q)#Z3VofiJn8bcHG!%Q$0J^@`+e+St z>C^}?R4L8;K&Tlm&YZ!`sVl;ZyyKZYEvqPD$9dg?DlWbibatq-QK-6TIoR%=*I!gJ_M8&g%MO~t| z5OCjoPkXoSg#z0}0{L&Ou7ts{qLRJKla=BjARZ6LW{%HXwDBf1;FY)gRJuAzcM;gb zB?q=m_am9=+o%yQdy~~ag<7EZmy5IV9h{e{Vk7wU;#F?sm$NUuYB3H~iNO1GE(=?= zC@lzQ%-j@W?oA9{4doVyU3oB)MG*KxE7fx54ojr{xvWAtUA)d-QuSH8RftuB_e-+RU$K=lKsY1+AWbdDmsg6Fi)?yz8cjd6Z~c0lNTVq%Oug(XrWdM zt4S?&T5)vm!C;}uc#xz&+Drrc1^A^PIDeOKb*n1jn7P=c0* zdZf}O+1s$Uk(z1GbewEgl+9~P+pv{LUGsosWxds8O^!ouiLYDql3(YX3mcrh}$)JvS_zsUmSMwN)-YAyP5 z^>SSD`eY0$q*1ATaXBU&qJ6+TI)8nT+6UIh;j*h8Z3zmB`%9Du?e3dRODkk!E$i`r z;$&5e9*uoMoq6f~%zd%4wfepI{6qi*o{k>P>G{gU7)LQ7avjiJ0N}{^eHd)tlTthP zq$M2sy)98WUGNqo5a#W>@@YvkRy zwR(c?J`euevA=umH^pVAD>ZLP0BK*ygmvqw#mf$jD|6GhXq+@tOpT)B z9{rO~6y_Q%#@-1r*vnYrkPl@7fCc(S*?F1BY{Qh2dD`JKV|Ok)_) zh#xar>Q@i76&*>{HgBxe6>ct`ki|Qe2|9xw=E*>Q55k_s4i`@}_43Nw`8R7%JCzc}Z_gs`-oBBjXOUFgj%X@4cc#Cyl;<`PG0Z)wHiDGDr{^#q z!8Qo3WHqf2B~3(XEj)=Fi`}h&xmX(`RjnFZGq{qQA}#~v=Zu3i4$$1iBzYlm?8Hc6 z(!ar17R$eoSDx+2IO2O9%HU%3bIlcY^A+hLpZB8Jjx(rXbT@aBkDYiCKYuKRI zrR{r{Vz<%c~jYEUe#{7$v`HN@#3k9wMc3ig&Udz=zuD`ty9e5(Bz-KfL4d zFc0CO{DrB*ruQgK{)HN|6;sY?d3x5$aHN;}v9&_OeX{)sEk4X=oVLg{DexhWoU_v7 zWQ<{0tk6@7FP*eAhr*E7%BNikBPHP0!e#V$indeafw=ZSk@Li(vMZy#GmjsvD2IZS zPi1>Kt|#!DI$3wOrI}L6lIM*)GhSBo8>;!1@x8F?&fed8oqS@o^b3zq)nVhfqvckq zu&KZC#b$NWc}kzhhP08Nn~&q0EbBBKBU8D9)7~RoDSz$Krahjw@ckg;tAK@d>D2)h z<I82W6h{S;gbwT6Igg>F_&40X0) z2K3`k=q9bkh`CXtAxY zx_Kus)YyjUY=hpS&3>)g<^d(O5r=*v)2sh$B0oa?Tq(as+uUi4p|)YEZ2uc=yAk(m r#LXWIqeC~0kD-Y-D*UZbn<8%MR|Jfe{(J!7r2mlg@2il$Oab6OmW7Ip delta 1564 zcmYjR2T+qq82yEiKmsD2Py>-JMVbNj9pJItoMuLEtE!94P4RH@n~4Z)d;VnK$nh%Kp7)w;PThA_)j?hVI#U zYuav8*bc-wna?1nE2pNarkK23hGr1^5(8cm_dLF!#lOWLaKpg_`%so^)&Kz5Z_ceo z@XZVWAI|h+Xx;L#9XO}D1L?B6GRvXxXH0}EHD1CoD<~}a$bJ@OL2L7TkKC5O;?|;4h$G#vp_mXPE~ut z>SjG=aamLCp)#+WBE!}0W~Cy;nQTaJOMT7@WL?nCHec44o485K3Zu-CtiL>dZRpfi5-fXEy z%BBwx9N&&76tjeH2I|bjn)j%XMX%l(dU__Uc8X(srzNkvAE)U4ctcs)?-iR+8nbwk zm^%KBai>_)=-IkLtz%k$OSYx!^O<`Dyfq1FHr`O)|3~ZaVq)33BlAxke?e5XHKlcJz>zd~&y(rET1?+lCE3*}dgT=g#^B4uu|iI<4p}MfR7dCWaPq zrMf&dHI|(BSLwZ5?b5n(e%ZcTDMNvXAxbX3u17>j37>T07}&yRU$;>VxPrLLU^bYh z`!=@pI0eiCQ{Jg4Y2_0cCm7(&6Gfq7vwtOpWQRkbL6XohWcNbL?$035HvsewbyprdxL@Q8F+1-W}dE_8E*;?8&DaCl!fgdFn zIH)^!;lnB&2-3-ny6)x_d{GSPI?)G&28*l!##cWsM+6}t4=jSCCmb}feRT6a5wUUf zbg*KlhAom(LLRX$~F}tw(-qfX)x+ zgk;2(xLE4TCL*5=nlj=-!oFZ%5KZ!Jmu{2|%|_VVm)A^M5JdcmDzM C+n&(? From d573a8d53fe451c58cc4ac7afd403e09049ae341 Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 20 May 2013 13:29:41 -0700 Subject: [PATCH 36/57] swig: add python encode support wraps the simple interface similar to java. Change-Id: Ib922bbcae322b2345b6dce5dee08faad705a77fd (cherry picked from commit 14677e11d44d18eaaed0df8931df12ef788978df) --- swig/libwebp.i | 67 +++- swig/libwebp.py | 54 ++++ swig/libwebp_java_wrap.c | 8 + swig/libwebp_python_wrap.c | 635 ++++++++++++++++++++++--------------- 4 files changed, 516 insertions(+), 248 deletions(-) diff --git a/swig/libwebp.i b/swig/libwebp.i index b541c3f9..20977c77 100644 --- a/swig/libwebp.i +++ b/swig/libwebp.i @@ -52,7 +52,28 @@ JAVA_ARRAYS_TYPEMAPS(uint8_t, byte, jbyte, Uint8, "[B") %apply (char* STRING, size_t LENGTH) { (const uint8_t* data, size_t data_size) } %typemap(out) uint8_t* { $result = PyString_FromStringAndSize( - (const char*)$1, ReturnedBufferSize("$symname", arg3, arg4)); + (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); } #endif /* SWIGPYTHON */ @@ -134,6 +155,14 @@ static size_t ReturnedBufferSize( { "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 } }; @@ -305,3 +334,39 @@ 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): + 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): + 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 */ diff --git a/swig/libwebp.py b/swig/libwebp.py index fde96bb7..31ad4d5b 100644 --- a/swig/libwebp.py +++ b/swig/libwebp.py @@ -131,6 +131,60 @@ wrap_WebPEncodeLosslessRGBA = _libwebp.wrap_WebPEncodeLosslessRGBA def wrap_WebPEncodeLosslessBGRA(*args): return _libwebp.wrap_WebPEncodeLosslessBGRA(*args) wrap_WebPEncodeLosslessBGRA = _libwebp.wrap_WebPEncodeLosslessBGRA +_UNUSED = 1 + +def WebPEncodeRGB(rgb, width, height, stride, quality_factor): + 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): + 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): + 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): + 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): + 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): + 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): + 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): + 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. diff --git a/swig/libwebp_java_wrap.c b/swig/libwebp_java_wrap.c index 10960ebd..c8d4b133 100644 --- a/swig/libwebp_java_wrap.c +++ b/swig/libwebp_java_wrap.c @@ -897,6 +897,14 @@ static size_t ReturnedBufferSize( { "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 } }; diff --git a/swig/libwebp_python_wrap.c b/swig/libwebp_python_wrap.c index 4c32bed0..5e8e89ca 100644 --- a/swig/libwebp_python_wrap.c +++ b/swig/libwebp_python_wrap.c @@ -209,7 +209,7 @@ // success code if (SWIG_IsNewObj(res) { ... - delete *ptr; + delete *ptr; } else { ... } @@ -310,32 +310,32 @@ typedef struct swig_type_info *(*swig_dycast_func)(void **); /* Structure to store information on one type */ typedef struct swig_type_info { - const char *name; /* mangled name of this type */ - const char *str; /* human readable name of this type */ - swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ - struct swig_cast_info *cast; /* linked list of types that can cast into this type */ - void *clientdata; /* language specific type data */ - int owndata; /* flag if the structure owns the clientdata */ + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ } swig_type_info; /* Structure to store a type and conversion function used for casting */ typedef struct swig_cast_info { - swig_type_info *type; /* pointer to type that is equivalent to this type */ - swig_converter_func converter; /* function to cast the void pointers */ - struct swig_cast_info *next; /* pointer to next cast in linked list */ - struct swig_cast_info *prev; /* pointer to the previous cast */ + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ } swig_cast_info; /* Structure used to store module information * Each module generates one structure like this, and the runtime collects * all of these structures and stores them in a circularly linked list.*/ typedef struct swig_module_info { - swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ - size_t size; /* Number of types in this module */ - struct swig_module_info *next; /* Pointer to next element in circularly linked list */ - swig_type_info **type_initial; /* Array of initially generated type structures */ - swig_cast_info **cast_initial; /* Array of initially generated casting structures */ - void *clientdata; /* Language specific module data */ + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ } swig_module_info; /* @@ -347,7 +347,7 @@ typedef struct swig_module_info { */ SWIGRUNTIME int SWIG_TypeNameComp(const char *f1, const char *l1, - const char *f2, const char *l2) { + const char *f2, const char *l2) { for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { while ((*f1 == ' ') && (f1 != l1)) ++f1; while ((*f2 == ' ') && (f2 != l2)) ++f2; @@ -514,7 +514,7 @@ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { if (!cast->converter) { swig_type_info *tc = cast->type; if (!tc->clientdata) { - SWIG_TypeClientData(tc, clientdata); + SWIG_TypeClientData(tc, clientdata); } } cast = cast->next; @@ -537,32 +537,32 @@ SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { SWIGRUNTIME swig_type_info * SWIG_MangledTypeQueryModule(swig_module_info *start, swig_module_info *end, - const char *name) { + const char *name) { swig_module_info *iter = start; do { if (iter->size) { register size_t l = 0; register size_t r = iter->size - 1; do { - /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - register size_t i = (l + r) >> 1; - const char *iname = iter->types[i]->name; - if (iname) { - register int compare = strcmp(name, iname); - if (compare == 0) { - return iter->types[i]; - } else if (compare < 0) { - if (i) { - r = i - 1; - } else { - break; - } - } else if (compare > 0) { - l = i + 1; - } - } else { - break; /* should never happen */ - } + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } } while (l <= r); } iter = iter->next; @@ -582,7 +582,7 @@ SWIG_MangledTypeQueryModule(swig_module_info *start, SWIGRUNTIME swig_type_info * SWIG_TypeQueryModule(swig_module_info *start, swig_module_info *end, - const char *name) { + const char *name) { /* STEP 1: Search the name field using binary search */ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); if (ret) { @@ -594,8 +594,8 @@ SWIG_TypeQueryModule(swig_module_info *start, do { register size_t i = 0; for (; i < iter->size; ++i) { - if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) - return iter->types[i]; + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; } iter = iter->next; } while (iter != end); @@ -709,18 +709,18 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { #endif /* 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_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 @@ -902,13 +902,13 @@ static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc)) #endif #if PY_VERSION_HEX < 0x02040000 -#define Py_VISIT(op) \ - do { \ - if (op) { \ - int vret = visit((op), arg); \ - if (vret) \ - return vret; \ - } \ +#define Py_VISIT(op) \ + do { \ + if (op) { \ + int vret = visit((op), arg); \ + if (vret) \ + return vret; \ + } \ } while (0) #endif @@ -1147,7 +1147,7 @@ SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) #endif -#define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) +#define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) #define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) #define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) @@ -1177,10 +1177,10 @@ SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), #define SWIG_NewClientData(obj) SwigPyClientData_New(obj) #define SWIG_SetErrorObj SWIG_Python_SetErrorObj -#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg -#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) -#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) -#define SWIG_fail goto fail +#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg +#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) +#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail /* Runtime API implementation */ @@ -1288,7 +1288,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi return 1; } else { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", - name, (min == max ? "" : "at least "), (int)min); + name, (min == max ? "" : "at least "), (int)min); return 0; } } @@ -1297,7 +1297,7 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi register int i; objs[0] = args; for (i = 1; i < max; ++i) { - objs[i] = 0; + objs[i] = 0; } return 2; } @@ -1307,19 +1307,19 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi register Py_ssize_t l = PyTuple_GET_SIZE(args); if (l < min) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at least "), (int)min, (int)l); + name, (min == max ? "" : "at least "), (int)min, (int)l); return 0; } else if (l > max) { PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at most "), (int)max, (int)l); + name, (min == max ? "" : "at most "), (int)max, (int)l); return 0; } else { register int i; for (i = 0; i < l; ++i) { - objs[i] = PyTuple_GET_ITEM(args, i); + objs[i] = PyTuple_GET_ITEM(args, i); } for (; l < max; ++l) { - objs[l] = 0; + objs[l] = 0; } return i + 1; } @@ -1328,9 +1328,9 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi /* A functor is a function object with one single object argument */ #if PY_VERSION_HEX >= 0x02020000 -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); #else -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); #endif /* @@ -1353,8 +1353,8 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi #define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) -#define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) -#define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) +#define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) +#define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) #ifdef __cplusplus extern "C" { @@ -1448,11 +1448,11 @@ SwigPyClientData_New(PyObject* obj) data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); #endif if (data->newraw) { - Py_INCREF(data->newraw); - data->newargs = PyTuple_New(1); - PyTuple_SetItem(data->newargs, 0, obj); + Py_INCREF(data->newraw); + data->newargs = PyTuple_New(1); + PyTuple_SetItem(data->newargs, 0, obj); } else { - data->newargs = obj; + data->newargs = obj; } Py_INCREF(data->newargs); } @@ -1516,11 +1516,11 @@ SwigPyObject_format(const char* fmt, SwigPyObject *v) PyObject *ofmt = SWIG_Python_str_FromChar(fmt); if (ofmt) { #if PY_VERSION_HEX >= 0x03000000 - res = PyUnicode_Format(ofmt,args); + res = PyUnicode_Format(ofmt,args); #else - res = PyString_Format(ofmt,args); + res = PyString_Format(ofmt,args); #endif - Py_DECREF(ofmt); + Py_DECREF(ofmt); } Py_DECREF(args); } @@ -1667,14 +1667,14 @@ SwigPyObject_dealloc(PyObject *v) /* destroy is always a VARARGS method */ PyObject *res; if (data->delargs) { - /* we need to create a temporary object to carry the destroy operation */ - PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); - res = SWIG_Python_CallFunctor(destroy, tmp); - Py_DECREF(tmp); + /* we need to create a temporary object to carry the destroy operation */ + PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); + res = SWIG_Python_CallFunctor(destroy, tmp); + Py_DECREF(tmp); } else { - PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); - PyObject *mself = PyCFunction_GET_SELF(destroy); - res = ((*meth)(mself, v)); + PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); + PyObject *mself = PyCFunction_GET_SELF(destroy); + res = ((*meth)(mself, v)); } Py_XDECREF(res); } @@ -1764,17 +1764,17 @@ SwigPyObject_own(PyObject *v, PyObject *args) PyObject *obj = PyBool_FromLong(sobj->own); if (val) { #ifdef METH_NOARGS - if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v); - } else { - SwigPyObject_disown(v); - } + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v); + } else { + SwigPyObject_disown(v); + } #else - if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v,args); - } else { - SwigPyObject_disown(v,args); - } + if (PyObject_IsTrue(val)) { + SwigPyObject_acquire(v,args); + } else { + SwigPyObject_disown(v,args); + } #endif } return obj; @@ -1832,12 +1832,12 @@ SwigPyObject_TypeOnce(void) { (unaryfunc)0, /*nb_positive*/ (unaryfunc)0, /*nb_absolute*/ (inquiry)0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ #if PY_VERSION_HEX < 0x03000000 0, /*nb_coerce*/ #endif @@ -2221,16 +2221,16 @@ SWIG_Python_GetSwigThis(PyObject *pyobj) } else { #ifdef PyWeakref_CheckProxy if (PyWeakref_CheckProxy(pyobj)) { - PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); - return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; + PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); + return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; } #endif obj = PyObject_GetAttr(pyobj,SWIG_This()); if (obj) { - Py_DECREF(obj); + Py_DECREF(obj); } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; + if (PyErr_Occurred()) PyErr_Clear(); + return 0; } } } @@ -2433,12 +2433,12 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) PyObject **dictptr = _PyObject_GetDictPtr(inst); if (dictptr != NULL) { - PyObject *dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - PyDict_SetItem(dict, SWIG_This(), swig_this); - } + PyObject *dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + PyDict_SetItem(dict, SWIG_This(), swig_this); + } } #else PyObject *key = SWIG_This(); @@ -2548,7 +2548,7 @@ SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int f if (newobj->ptr) { PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0); while (newobj->next) - newobj = (SwigPyObject *) newobj->next; + newobj = (SwigPyObject *) newobj->next; newobj->next = next_self; newobj = (SwigPyObject *)next_self; } @@ -2608,7 +2608,7 @@ SWIG_Python_GetModule(void) { type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); # else type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); + (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); # endif if (PyErr_Occurred()) { PyErr_Clear(); @@ -2628,12 +2628,12 @@ PyModule_AddObject(PyObject *m, char *name, PyObject *o) PyObject *dict; if (!PyModule_Check(m)) { PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs module as first arg"); + "PyModule_AddObject() needs module as first arg"); return SWIG_ERROR; } if (!o) { PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs non-NULL value"); + "PyModule_AddObject() needs non-NULL value"); return SWIG_ERROR; } @@ -2641,7 +2641,7 @@ PyModule_AddObject(PyObject *m, char *name, PyObject *o) if (dict == NULL) { /* Internal error -- modules must have a dict! */ PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", - PyModule_GetName(m)); + PyModule_GetName(m)); return SWIG_ERROR; } if (PyDict_SetItemString(dict, name, o)) @@ -2760,9 +2760,9 @@ SWIG_Python_AddErrMesg(const char* mesg, int infront) Py_XINCREF(type); PyErr_Clear(); if (infront) { - PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); + PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); } else { - PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); + PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); } SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); @@ -2802,27 +2802,27 @@ SWIG_Python_TypeError(const char *type, PyObject *obj) if (obj && SwigPyObject_Check(obj)) { const char *otype = (const char *) SwigPyObject_GetDesc(obj); if (otype) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", - type, otype); - return; + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", + type, otype); + return; } } else #endif { const char *otype = (obj ? obj->ob_type->tp_name : 0); if (otype) { - PyObject *str = PyObject_Str(obj); - const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; - if (cstr) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", - type, otype, cstr); + PyObject *str = PyObject_Str(obj); + const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; + if (cstr) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", + type, otype, cstr); SWIG_Python_str_DelForPy3(cstr); - } else { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", - type, otype); - } - Py_XDECREF(str); - return; + } else { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", + type, otype); + } + Py_XDECREF(str); + return; } } PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); @@ -3003,33 +3003,33 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) #endif if (cptr) { if (alloc) { - /* - In python the user should not be able to modify the inner - string representation. To warranty that, if you define - SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string - buffer is always returned. + /* + In python the user should not be able to modify the inner + string representation. To warranty that, if you define + SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string + buffer is always returned. - The default behavior is just to return the pointer value, - so, be careful. - */ + The default behavior is just to return the pointer value, + so, be careful. + */ #if defined(SWIG_PYTHON_SAFE_CSTRINGS) - if (*alloc != SWIG_OLDOBJ) + if (*alloc != SWIG_OLDOBJ) #else - if (*alloc == SWIG_NEWOBJ) + if (*alloc == SWIG_NEWOBJ) #endif - { - *cptr = (char *)memcpy((char *)malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); - *alloc = SWIG_NEWOBJ; - } - else { - *cptr = cstr; - *alloc = SWIG_OLDOBJ; - } + { + *cptr = (char *)memcpy((char *)malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); + *alloc = SWIG_NEWOBJ; + } + else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } } else { #if PY_VERSION_HEX>=0x03000000 assert(0); /* Should never reach here in Python 3 */ #endif - *cptr = SWIG_Python_str_AsChar(obj); + *cptr = SWIG_Python_str_AsChar(obj); } } if (psize) *psize = len + 1; @@ -3042,10 +3042,10 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) if (pchar_descriptor) { void* vptr = 0; if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { - if (cptr) *cptr = (char *) vptr; - if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; - if (alloc) *alloc = SWIG_OLDOBJ; - return SWIG_OK; + if (cptr) *cptr = (char *) vptr; + if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; } } } @@ -3085,10 +3085,10 @@ SWIG_AsVal_double (PyObject *obj, double *val) if (!dispatch) { long v = PyLong_AsLong(obj); if (!PyErr_Occurred()) { - if (val) *val = v; - return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); + if (val) *val = v; + return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); } else { - PyErr_Clear(); + PyErr_Clear(); } } } @@ -3167,8 +3167,8 @@ SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) double d; int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { - if (val) *val = (unsigned long)(d); - return res; + if (val) *val = (unsigned long)(d); + return res; } } } @@ -3218,6 +3218,14 @@ static size_t ReturnedBufferSize( { "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 } }; @@ -3347,8 +3355,8 @@ SWIG_AsVal_long (PyObject *obj, long* val) double d; int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { - if (val) *val = (long)(d); - return res; + if (val) *val = (long)(d); + return res; } } } @@ -3481,7 +3489,8 @@ SWIGINTERN PyObject *_wrap_WebPDecodeRGB(PyObject *SWIGUNUSEDPARM(self), PyObjec result = (uint8_t *)WebPDecodeRGB((uint8_t const *)arg1,arg2,arg3,arg4); { resultobj = PyString_FromStringAndSize( - (const char*)result, ReturnedBufferSize("WebPDecodeRGB", arg3, arg4)); + (const char*)result, + (result == NULL) ? 0 : ReturnedBufferSize("WebPDecodeRGB", arg3, arg4)); } if (SWIG_IsTmpObj(res3)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg3))); @@ -3533,7 +3542,8 @@ SWIGINTERN PyObject *_wrap_WebPDecodeRGBA(PyObject *SWIGUNUSEDPARM(self), PyObje result = (uint8_t *)WebPDecodeRGBA((uint8_t const *)arg1,arg2,arg3,arg4); { resultobj = PyString_FromStringAndSize( - (const char*)result, ReturnedBufferSize("WebPDecodeRGBA", arg3, arg4)); + (const char*)result, + (result == NULL) ? 0 : ReturnedBufferSize("WebPDecodeRGBA", arg3, arg4)); } if (SWIG_IsTmpObj(res3)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg3))); @@ -3585,7 +3595,8 @@ SWIGINTERN PyObject *_wrap_WebPDecodeARGB(PyObject *SWIGUNUSEDPARM(self), PyObje result = (uint8_t *)WebPDecodeARGB((uint8_t const *)arg1,arg2,arg3,arg4); { resultobj = PyString_FromStringAndSize( - (const char*)result, ReturnedBufferSize("WebPDecodeARGB", arg3, arg4)); + (const char*)result, + (result == NULL) ? 0 : ReturnedBufferSize("WebPDecodeARGB", arg3, arg4)); } if (SWIG_IsTmpObj(res3)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg3))); @@ -3637,7 +3648,8 @@ SWIGINTERN PyObject *_wrap_WebPDecodeBGR(PyObject *SWIGUNUSEDPARM(self), PyObjec result = (uint8_t *)WebPDecodeBGR((uint8_t const *)arg1,arg2,arg3,arg4); { resultobj = PyString_FromStringAndSize( - (const char*)result, ReturnedBufferSize("WebPDecodeBGR", arg3, arg4)); + (const char*)result, + (result == NULL) ? 0 : ReturnedBufferSize("WebPDecodeBGR", arg3, arg4)); } if (SWIG_IsTmpObj(res3)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg3))); @@ -3689,7 +3701,8 @@ SWIGINTERN PyObject *_wrap_WebPDecodeBGRA(PyObject *SWIGUNUSEDPARM(self), PyObje result = (uint8_t *)WebPDecodeBGRA((uint8_t const *)arg1,arg2,arg3,arg4); { resultobj = PyString_FromStringAndSize( - (const char*)result, ReturnedBufferSize("WebPDecodeBGRA", arg3, arg4)); + (const char*)result, + (result == NULL) ? 0 : ReturnedBufferSize("WebPDecodeBGRA", arg3, arg4)); } if (SWIG_IsTmpObj(res3)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg3))); @@ -3735,8 +3748,7 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeRGB(PyObject *SWIGUNUSEDPARM(self), Py int arg6 ; int arg7 ; float arg8 ; - void *argp1 = 0 ; - int res1 = 0 ; + Py_buffer rgb_buffer1 ; int temp2 ; int res2 = 0 ; int temp3 ; @@ -3762,11 +3774,21 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeRGB(PyObject *SWIGUNUSEDPARM(self), Py arg4 = &temp4; if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:wrap_WebPEncodeRGB",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_uint8_t, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wrap_WebPEncodeRGB" "', argument " "1"" of type '" "uint8_t const *""'"); + { + // NB: with Python < 2.6 the old style buffer protocol may be used: + // Py_ssize_t unused; + // PyObject_AsReadBuffer(obj0, (const void**)(&arg1), &unused); + if (!PyObject_CheckBuffer(obj0)) { + SWIG_exception_fail(SWIG_TypeError, + "in method 'wrap_WebPEncodeRGB', argument 1" + " does not support the buffer interface"); + } + if (PyObject_GetBuffer(obj0, &rgb_buffer1, PyBUF_SIMPLE)) { + SWIG_exception_fail(SWIG_RuntimeError, + "in method 'wrap_WebPEncodeRGB', unable to get buffer view"); + } + arg1 = (uint8_t *)rgb_buffer1.buf; } - arg1 = (uint8_t *)(argp1); if (!(SWIG_IsOK((res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2),SWIGTYPE_p_int,0))))) { int val; int ecode = SWIG_AsVal_int(obj1, &val); @@ -3810,7 +3832,8 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeRGB(PyObject *SWIGUNUSEDPARM(self), Py result = (uint8_t *)wrap_WebPEncodeRGB((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); { resultobj = PyString_FromStringAndSize( - (const char*)result, ReturnedBufferSize("wrap_WebPEncodeRGB", arg3, arg4)); + (const char*)result, + (result == NULL) ? 0 : ReturnedBufferSize("wrap_WebPEncodeRGB", arg3, arg4)); } if (SWIG_IsTmpObj(res4)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); @@ -3818,11 +3841,17 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeRGB(PyObject *SWIGUNUSEDPARM(self), Py int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); } + { + PyBuffer_Release(&rgb_buffer1); + } if (SWIG_IsNewObj(res2)) free((char*)arg2); if (SWIG_IsNewObj(res3)) free((char*)arg3); free(result); return resultobj; fail: + { + PyBuffer_Release(&rgb_buffer1); + } if (SWIG_IsNewObj(res2)) free((char*)arg2); if (SWIG_IsNewObj(res3)) free((char*)arg3); return NULL; @@ -3839,8 +3868,7 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeBGR(PyObject *SWIGUNUSEDPARM(self), Py int arg6 ; int arg7 ; float arg8 ; - void *argp1 = 0 ; - int res1 = 0 ; + Py_buffer rgb_buffer1 ; int temp2 ; int res2 = 0 ; int temp3 ; @@ -3866,11 +3894,21 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeBGR(PyObject *SWIGUNUSEDPARM(self), Py arg4 = &temp4; if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:wrap_WebPEncodeBGR",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_uint8_t, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wrap_WebPEncodeBGR" "', argument " "1"" of type '" "uint8_t const *""'"); + { + // NB: with Python < 2.6 the old style buffer protocol may be used: + // Py_ssize_t unused; + // PyObject_AsReadBuffer(obj0, (const void**)(&arg1), &unused); + if (!PyObject_CheckBuffer(obj0)) { + SWIG_exception_fail(SWIG_TypeError, + "in method 'wrap_WebPEncodeBGR', argument 1" + " does not support the buffer interface"); + } + if (PyObject_GetBuffer(obj0, &rgb_buffer1, PyBUF_SIMPLE)) { + SWIG_exception_fail(SWIG_RuntimeError, + "in method 'wrap_WebPEncodeBGR', unable to get buffer view"); + } + arg1 = (uint8_t *)rgb_buffer1.buf; } - arg1 = (uint8_t *)(argp1); if (!(SWIG_IsOK((res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2),SWIGTYPE_p_int,0))))) { int val; int ecode = SWIG_AsVal_int(obj1, &val); @@ -3914,7 +3952,8 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeBGR(PyObject *SWIGUNUSEDPARM(self), Py result = (uint8_t *)wrap_WebPEncodeBGR((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); { resultobj = PyString_FromStringAndSize( - (const char*)result, ReturnedBufferSize("wrap_WebPEncodeBGR", arg3, arg4)); + (const char*)result, + (result == NULL) ? 0 : ReturnedBufferSize("wrap_WebPEncodeBGR", arg3, arg4)); } if (SWIG_IsTmpObj(res4)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); @@ -3922,11 +3961,17 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeBGR(PyObject *SWIGUNUSEDPARM(self), Py int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); } + { + PyBuffer_Release(&rgb_buffer1); + } if (SWIG_IsNewObj(res2)) free((char*)arg2); if (SWIG_IsNewObj(res3)) free((char*)arg3); free(result); return resultobj; fail: + { + PyBuffer_Release(&rgb_buffer1); + } if (SWIG_IsNewObj(res2)) free((char*)arg2); if (SWIG_IsNewObj(res3)) free((char*)arg3); return NULL; @@ -3943,8 +3988,7 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeRGBA(PyObject *SWIGUNUSEDPARM(self), P int arg6 ; int arg7 ; float arg8 ; - void *argp1 = 0 ; - int res1 = 0 ; + Py_buffer rgb_buffer1 ; int temp2 ; int res2 = 0 ; int temp3 ; @@ -3970,11 +4014,21 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeRGBA(PyObject *SWIGUNUSEDPARM(self), P arg4 = &temp4; if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:wrap_WebPEncodeRGBA",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_uint8_t, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wrap_WebPEncodeRGBA" "', argument " "1"" of type '" "uint8_t const *""'"); + { + // NB: with Python < 2.6 the old style buffer protocol may be used: + // Py_ssize_t unused; + // PyObject_AsReadBuffer(obj0, (const void**)(&arg1), &unused); + if (!PyObject_CheckBuffer(obj0)) { + SWIG_exception_fail(SWIG_TypeError, + "in method 'wrap_WebPEncodeRGBA', argument 1" + " does not support the buffer interface"); + } + if (PyObject_GetBuffer(obj0, &rgb_buffer1, PyBUF_SIMPLE)) { + SWIG_exception_fail(SWIG_RuntimeError, + "in method 'wrap_WebPEncodeRGBA', unable to get buffer view"); + } + arg1 = (uint8_t *)rgb_buffer1.buf; } - arg1 = (uint8_t *)(argp1); if (!(SWIG_IsOK((res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2),SWIGTYPE_p_int,0))))) { int val; int ecode = SWIG_AsVal_int(obj1, &val); @@ -4018,7 +4072,8 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeRGBA(PyObject *SWIGUNUSEDPARM(self), P result = (uint8_t *)wrap_WebPEncodeRGBA((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); { resultobj = PyString_FromStringAndSize( - (const char*)result, ReturnedBufferSize("wrap_WebPEncodeRGBA", arg3, arg4)); + (const char*)result, + (result == NULL) ? 0 : ReturnedBufferSize("wrap_WebPEncodeRGBA", arg3, arg4)); } if (SWIG_IsTmpObj(res4)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); @@ -4026,11 +4081,17 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeRGBA(PyObject *SWIGUNUSEDPARM(self), P int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); } + { + PyBuffer_Release(&rgb_buffer1); + } if (SWIG_IsNewObj(res2)) free((char*)arg2); if (SWIG_IsNewObj(res3)) free((char*)arg3); free(result); return resultobj; fail: + { + PyBuffer_Release(&rgb_buffer1); + } if (SWIG_IsNewObj(res2)) free((char*)arg2); if (SWIG_IsNewObj(res3)) free((char*)arg3); return NULL; @@ -4047,8 +4108,7 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeBGRA(PyObject *SWIGUNUSEDPARM(self), P int arg6 ; int arg7 ; float arg8 ; - void *argp1 = 0 ; - int res1 = 0 ; + Py_buffer rgb_buffer1 ; int temp2 ; int res2 = 0 ; int temp3 ; @@ -4074,11 +4134,21 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeBGRA(PyObject *SWIGUNUSEDPARM(self), P arg4 = &temp4; if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:wrap_WebPEncodeBGRA",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_uint8_t, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wrap_WebPEncodeBGRA" "', argument " "1"" of type '" "uint8_t const *""'"); + { + // NB: with Python < 2.6 the old style buffer protocol may be used: + // Py_ssize_t unused; + // PyObject_AsReadBuffer(obj0, (const void**)(&arg1), &unused); + if (!PyObject_CheckBuffer(obj0)) { + SWIG_exception_fail(SWIG_TypeError, + "in method 'wrap_WebPEncodeBGRA', argument 1" + " does not support the buffer interface"); + } + if (PyObject_GetBuffer(obj0, &rgb_buffer1, PyBUF_SIMPLE)) { + SWIG_exception_fail(SWIG_RuntimeError, + "in method 'wrap_WebPEncodeBGRA', unable to get buffer view"); + } + arg1 = (uint8_t *)rgb_buffer1.buf; } - arg1 = (uint8_t *)(argp1); if (!(SWIG_IsOK((res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2),SWIGTYPE_p_int,0))))) { int val; int ecode = SWIG_AsVal_int(obj1, &val); @@ -4122,7 +4192,8 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeBGRA(PyObject *SWIGUNUSEDPARM(self), P result = (uint8_t *)wrap_WebPEncodeBGRA((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8); { resultobj = PyString_FromStringAndSize( - (const char*)result, ReturnedBufferSize("wrap_WebPEncodeBGRA", arg3, arg4)); + (const char*)result, + (result == NULL) ? 0 : ReturnedBufferSize("wrap_WebPEncodeBGRA", arg3, arg4)); } if (SWIG_IsTmpObj(res4)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); @@ -4130,11 +4201,17 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeBGRA(PyObject *SWIGUNUSEDPARM(self), P int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); } + { + PyBuffer_Release(&rgb_buffer1); + } if (SWIG_IsNewObj(res2)) free((char*)arg2); if (SWIG_IsNewObj(res3)) free((char*)arg3); free(result); return resultobj; fail: + { + PyBuffer_Release(&rgb_buffer1); + } if (SWIG_IsNewObj(res2)) free((char*)arg2); if (SWIG_IsNewObj(res3)) free((char*)arg3); return NULL; @@ -4150,8 +4227,7 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessRGB(PyObject *SWIGUNUSEDPARM(s int arg5 ; int arg6 ; int arg7 ; - void *argp1 = 0 ; - int res1 = 0 ; + Py_buffer rgb_buffer1 ; int temp2 ; int res2 = 0 ; int temp3 ; @@ -4174,11 +4250,21 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessRGB(PyObject *SWIGUNUSEDPARM(s arg4 = &temp4; if (!PyArg_ParseTuple(args,(char *)"OOOOOO:wrap_WebPEncodeLosslessRGB",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_uint8_t, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wrap_WebPEncodeLosslessRGB" "', argument " "1"" of type '" "uint8_t const *""'"); + { + // NB: with Python < 2.6 the old style buffer protocol may be used: + // Py_ssize_t unused; + // PyObject_AsReadBuffer(obj0, (const void**)(&arg1), &unused); + if (!PyObject_CheckBuffer(obj0)) { + SWIG_exception_fail(SWIG_TypeError, + "in method 'wrap_WebPEncodeLosslessRGB', argument 1" + " does not support the buffer interface"); + } + if (PyObject_GetBuffer(obj0, &rgb_buffer1, PyBUF_SIMPLE)) { + SWIG_exception_fail(SWIG_RuntimeError, + "in method 'wrap_WebPEncodeLosslessRGB', unable to get buffer view"); + } + arg1 = (uint8_t *)rgb_buffer1.buf; } - arg1 = (uint8_t *)(argp1); if (!(SWIG_IsOK((res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2),SWIGTYPE_p_int,0))))) { int val; int ecode = SWIG_AsVal_int(obj1, &val); @@ -4217,7 +4303,8 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessRGB(PyObject *SWIGUNUSEDPARM(s result = (uint8_t *)wrap_WebPEncodeLosslessRGB((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7); { resultobj = PyString_FromStringAndSize( - (const char*)result, ReturnedBufferSize("wrap_WebPEncodeLosslessRGB", arg3, arg4)); + (const char*)result, + (result == NULL) ? 0 : ReturnedBufferSize("wrap_WebPEncodeLosslessRGB", arg3, arg4)); } if (SWIG_IsTmpObj(res4)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); @@ -4225,11 +4312,17 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessRGB(PyObject *SWIGUNUSEDPARM(s int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); } + { + PyBuffer_Release(&rgb_buffer1); + } if (SWIG_IsNewObj(res2)) free((char*)arg2); if (SWIG_IsNewObj(res3)) free((char*)arg3); free(result); return resultobj; fail: + { + PyBuffer_Release(&rgb_buffer1); + } if (SWIG_IsNewObj(res2)) free((char*)arg2); if (SWIG_IsNewObj(res3)) free((char*)arg3); return NULL; @@ -4245,8 +4338,7 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessBGR(PyObject *SWIGUNUSEDPARM(s int arg5 ; int arg6 ; int arg7 ; - void *argp1 = 0 ; - int res1 = 0 ; + Py_buffer rgb_buffer1 ; int temp2 ; int res2 = 0 ; int temp3 ; @@ -4269,11 +4361,21 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessBGR(PyObject *SWIGUNUSEDPARM(s arg4 = &temp4; if (!PyArg_ParseTuple(args,(char *)"OOOOOO:wrap_WebPEncodeLosslessBGR",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_uint8_t, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wrap_WebPEncodeLosslessBGR" "', argument " "1"" of type '" "uint8_t const *""'"); + { + // NB: with Python < 2.6 the old style buffer protocol may be used: + // Py_ssize_t unused; + // PyObject_AsReadBuffer(obj0, (const void**)(&arg1), &unused); + if (!PyObject_CheckBuffer(obj0)) { + SWIG_exception_fail(SWIG_TypeError, + "in method 'wrap_WebPEncodeLosslessBGR', argument 1" + " does not support the buffer interface"); + } + if (PyObject_GetBuffer(obj0, &rgb_buffer1, PyBUF_SIMPLE)) { + SWIG_exception_fail(SWIG_RuntimeError, + "in method 'wrap_WebPEncodeLosslessBGR', unable to get buffer view"); + } + arg1 = (uint8_t *)rgb_buffer1.buf; } - arg1 = (uint8_t *)(argp1); if (!(SWIG_IsOK((res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2),SWIGTYPE_p_int,0))))) { int val; int ecode = SWIG_AsVal_int(obj1, &val); @@ -4312,7 +4414,8 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessBGR(PyObject *SWIGUNUSEDPARM(s result = (uint8_t *)wrap_WebPEncodeLosslessBGR((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7); { resultobj = PyString_FromStringAndSize( - (const char*)result, ReturnedBufferSize("wrap_WebPEncodeLosslessBGR", arg3, arg4)); + (const char*)result, + (result == NULL) ? 0 : ReturnedBufferSize("wrap_WebPEncodeLosslessBGR", arg3, arg4)); } if (SWIG_IsTmpObj(res4)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); @@ -4320,11 +4423,17 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessBGR(PyObject *SWIGUNUSEDPARM(s int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); } + { + PyBuffer_Release(&rgb_buffer1); + } if (SWIG_IsNewObj(res2)) free((char*)arg2); if (SWIG_IsNewObj(res3)) free((char*)arg3); free(result); return resultobj; fail: + { + PyBuffer_Release(&rgb_buffer1); + } if (SWIG_IsNewObj(res2)) free((char*)arg2); if (SWIG_IsNewObj(res3)) free((char*)arg3); return NULL; @@ -4340,8 +4449,7 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessRGBA(PyObject *SWIGUNUSEDPARM( int arg5 ; int arg6 ; int arg7 ; - void *argp1 = 0 ; - int res1 = 0 ; + Py_buffer rgb_buffer1 ; int temp2 ; int res2 = 0 ; int temp3 ; @@ -4364,11 +4472,21 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessRGBA(PyObject *SWIGUNUSEDPARM( arg4 = &temp4; if (!PyArg_ParseTuple(args,(char *)"OOOOOO:wrap_WebPEncodeLosslessRGBA",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_uint8_t, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wrap_WebPEncodeLosslessRGBA" "', argument " "1"" of type '" "uint8_t const *""'"); + { + // NB: with Python < 2.6 the old style buffer protocol may be used: + // Py_ssize_t unused; + // PyObject_AsReadBuffer(obj0, (const void**)(&arg1), &unused); + if (!PyObject_CheckBuffer(obj0)) { + SWIG_exception_fail(SWIG_TypeError, + "in method 'wrap_WebPEncodeLosslessRGBA', argument 1" + " does not support the buffer interface"); + } + if (PyObject_GetBuffer(obj0, &rgb_buffer1, PyBUF_SIMPLE)) { + SWIG_exception_fail(SWIG_RuntimeError, + "in method 'wrap_WebPEncodeLosslessRGBA', unable to get buffer view"); + } + arg1 = (uint8_t *)rgb_buffer1.buf; } - arg1 = (uint8_t *)(argp1); if (!(SWIG_IsOK((res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2),SWIGTYPE_p_int,0))))) { int val; int ecode = SWIG_AsVal_int(obj1, &val); @@ -4407,7 +4525,8 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessRGBA(PyObject *SWIGUNUSEDPARM( result = (uint8_t *)wrap_WebPEncodeLosslessRGBA((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7); { resultobj = PyString_FromStringAndSize( - (const char*)result, ReturnedBufferSize("wrap_WebPEncodeLosslessRGBA", arg3, arg4)); + (const char*)result, + (result == NULL) ? 0 : ReturnedBufferSize("wrap_WebPEncodeLosslessRGBA", arg3, arg4)); } if (SWIG_IsTmpObj(res4)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); @@ -4415,11 +4534,17 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessRGBA(PyObject *SWIGUNUSEDPARM( int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); } + { + PyBuffer_Release(&rgb_buffer1); + } if (SWIG_IsNewObj(res2)) free((char*)arg2); if (SWIG_IsNewObj(res3)) free((char*)arg3); free(result); return resultobj; fail: + { + PyBuffer_Release(&rgb_buffer1); + } if (SWIG_IsNewObj(res2)) free((char*)arg2); if (SWIG_IsNewObj(res3)) free((char*)arg3); return NULL; @@ -4435,8 +4560,7 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessBGRA(PyObject *SWIGUNUSEDPARM( int arg5 ; int arg6 ; int arg7 ; - void *argp1 = 0 ; - int res1 = 0 ; + Py_buffer rgb_buffer1 ; int temp2 ; int res2 = 0 ; int temp3 ; @@ -4459,11 +4583,21 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessBGRA(PyObject *SWIGUNUSEDPARM( arg4 = &temp4; if (!PyArg_ParseTuple(args,(char *)"OOOOOO:wrap_WebPEncodeLosslessBGRA",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail; - res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_uint8_t, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "wrap_WebPEncodeLosslessBGRA" "', argument " "1"" of type '" "uint8_t const *""'"); + { + // NB: with Python < 2.6 the old style buffer protocol may be used: + // Py_ssize_t unused; + // PyObject_AsReadBuffer(obj0, (const void**)(&arg1), &unused); + if (!PyObject_CheckBuffer(obj0)) { + SWIG_exception_fail(SWIG_TypeError, + "in method 'wrap_WebPEncodeLosslessBGRA', argument 1" + " does not support the buffer interface"); + } + if (PyObject_GetBuffer(obj0, &rgb_buffer1, PyBUF_SIMPLE)) { + SWIG_exception_fail(SWIG_RuntimeError, + "in method 'wrap_WebPEncodeLosslessBGRA', unable to get buffer view"); + } + arg1 = (uint8_t *)rgb_buffer1.buf; } - arg1 = (uint8_t *)(argp1); if (!(SWIG_IsOK((res2 = SWIG_ConvertPtr(obj1,SWIG_as_voidptrptr(&arg2),SWIGTYPE_p_int,0))))) { int val; int ecode = SWIG_AsVal_int(obj1, &val); @@ -4502,7 +4636,8 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessBGRA(PyObject *SWIGUNUSEDPARM( result = (uint8_t *)wrap_WebPEncodeLosslessBGRA((uint8_t const *)arg1,arg2,arg3,arg4,arg5,arg6,arg7); { resultobj = PyString_FromStringAndSize( - (const char*)result, ReturnedBufferSize("wrap_WebPEncodeLosslessBGRA", arg3, arg4)); + (const char*)result, + (result == NULL) ? 0 : ReturnedBufferSize("wrap_WebPEncodeLosslessBGRA", arg3, arg4)); } if (SWIG_IsTmpObj(res4)) { resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_From_int((*arg4))); @@ -4510,11 +4645,17 @@ SWIGINTERN PyObject *_wrap_wrap_WebPEncodeLosslessBGRA(PyObject *SWIGUNUSEDPARM( int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ; resultobj = SWIG_Python_AppendOutput(resultobj, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_int, new_flags)); } + { + PyBuffer_Release(&rgb_buffer1); + } if (SWIG_IsNewObj(res2)) free((char*)arg2); if (SWIG_IsNewObj(res3)) free((char*)arg3); free(result); return resultobj; fail: + { + PyBuffer_Release(&rgb_buffer1); + } if (SWIG_IsNewObj(res2)) free((char*)arg2); if (SWIG_IsNewObj(res3)) free((char*)arg3); return NULL; @@ -4522,24 +4663,24 @@ fail: static PyMethodDef SwigMethods[] = { - { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL}, - { (char *)"WebPGetDecoderVersion", _wrap_WebPGetDecoderVersion, METH_VARARGS, NULL}, - { (char *)"WebPGetInfo", _wrap_WebPGetInfo, METH_VARARGS, NULL}, - { (char *)"WebPDecodeRGB", _wrap_WebPDecodeRGB, METH_VARARGS, NULL}, - { (char *)"WebPDecodeRGBA", _wrap_WebPDecodeRGBA, METH_VARARGS, NULL}, - { (char *)"WebPDecodeARGB", _wrap_WebPDecodeARGB, METH_VARARGS, NULL}, - { (char *)"WebPDecodeBGR", _wrap_WebPDecodeBGR, METH_VARARGS, NULL}, - { (char *)"WebPDecodeBGRA", _wrap_WebPDecodeBGRA, METH_VARARGS, NULL}, - { (char *)"WebPGetEncoderVersion", _wrap_WebPGetEncoderVersion, METH_VARARGS, NULL}, - { (char *)"wrap_WebPEncodeRGB", _wrap_wrap_WebPEncodeRGB, METH_VARARGS, NULL}, - { (char *)"wrap_WebPEncodeBGR", _wrap_wrap_WebPEncodeBGR, METH_VARARGS, NULL}, - { (char *)"wrap_WebPEncodeRGBA", _wrap_wrap_WebPEncodeRGBA, METH_VARARGS, NULL}, - { (char *)"wrap_WebPEncodeBGRA", _wrap_wrap_WebPEncodeBGRA, METH_VARARGS, NULL}, - { (char *)"wrap_WebPEncodeLosslessRGB", _wrap_wrap_WebPEncodeLosslessRGB, METH_VARARGS, NULL}, - { (char *)"wrap_WebPEncodeLosslessBGR", _wrap_wrap_WebPEncodeLosslessBGR, METH_VARARGS, NULL}, - { (char *)"wrap_WebPEncodeLosslessRGBA", _wrap_wrap_WebPEncodeLosslessRGBA, METH_VARARGS, NULL}, - { (char *)"wrap_WebPEncodeLosslessBGRA", _wrap_wrap_WebPEncodeLosslessBGRA, METH_VARARGS, NULL}, - { NULL, NULL, 0, NULL } + { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL}, + { (char *)"WebPGetDecoderVersion", _wrap_WebPGetDecoderVersion, METH_VARARGS, NULL}, + { (char *)"WebPGetInfo", _wrap_WebPGetInfo, METH_VARARGS, NULL}, + { (char *)"WebPDecodeRGB", _wrap_WebPDecodeRGB, METH_VARARGS, NULL}, + { (char *)"WebPDecodeRGBA", _wrap_WebPDecodeRGBA, METH_VARARGS, NULL}, + { (char *)"WebPDecodeARGB", _wrap_WebPDecodeARGB, METH_VARARGS, NULL}, + { (char *)"WebPDecodeBGR", _wrap_WebPDecodeBGR, METH_VARARGS, NULL}, + { (char *)"WebPDecodeBGRA", _wrap_WebPDecodeBGRA, METH_VARARGS, NULL}, + { (char *)"WebPGetEncoderVersion", _wrap_WebPGetEncoderVersion, METH_VARARGS, NULL}, + { (char *)"wrap_WebPEncodeRGB", _wrap_wrap_WebPEncodeRGB, METH_VARARGS, NULL}, + { (char *)"wrap_WebPEncodeBGR", _wrap_wrap_WebPEncodeBGR, METH_VARARGS, NULL}, + { (char *)"wrap_WebPEncodeRGBA", _wrap_wrap_WebPEncodeRGBA, METH_VARARGS, NULL}, + { (char *)"wrap_WebPEncodeBGRA", _wrap_wrap_WebPEncodeBGRA, METH_VARARGS, NULL}, + { (char *)"wrap_WebPEncodeLosslessRGB", _wrap_wrap_WebPEncodeLosslessRGB, METH_VARARGS, NULL}, + { (char *)"wrap_WebPEncodeLosslessBGR", _wrap_wrap_WebPEncodeLosslessBGR, METH_VARARGS, NULL}, + { (char *)"wrap_WebPEncodeLosslessRGBA", _wrap_wrap_WebPEncodeLosslessRGBA, METH_VARARGS, NULL}, + { (char *)"wrap_WebPEncodeLosslessBGRA", _wrap_wrap_WebPEncodeLosslessBGRA, METH_VARARGS, NULL}, + { NULL, NULL, 0, NULL } }; From bddd9b0a93e4f94c42b53ff800053b1b25d5c910 Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 20 May 2013 16:40:29 -0700 Subject: [PATCH 37/57] swig/python: add minimal documentation uses autodoc to display the function arguments rather than the inscrutable va_args (*args). Change-Id: Iec2ff8276c1533b14c3032836d822fbdae632521 (cherry picked from commit 825b64db53368f18f4546f99c04d1af5c558613e) --- swig/libwebp.i | 19 ++++++++++++++++++ swig/libwebp.py | 40 +++++++++++++++++++++++--------------- swig/libwebp_python_wrap.c | 32 +++++++++++++++--------------- 3 files changed, 59 insertions(+), 32 deletions(-) diff --git a/swig/libwebp.i b/swig/libwebp.i index 20977c77..5e887184 100644 --- a/swig/libwebp.i +++ b/swig/libwebp.i @@ -75,6 +75,18 @@ JAVA_ARRAYS_TYPEMAPS(uint8_t, byte, jbyte, Uint8, "[B") %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 */ //------------------------------------------------------------------------------ @@ -247,6 +259,11 @@ static uint8_t* EncodeLossless(const uint8_t* rgb, %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 @@ -343,6 +360,7 @@ _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: @@ -354,6 +372,7 @@ def func(rgb, width, height, stride, quality_factor): %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 diff --git a/swig/libwebp.py b/swig/libwebp.py index 31ad4d5b..4ff11f80 100644 --- a/swig/libwebp.py +++ b/swig/libwebp.py @@ -69,71 +69,72 @@ except AttributeError: def WebPGetDecoderVersion(): + """WebPGetDecoderVersion() -> int""" return _libwebp.WebPGetDecoderVersion() -WebPGetDecoderVersion = _libwebp.WebPGetDecoderVersion def WebPGetInfo(*args): + """WebPGetInfo(uint8_t data) -> (width, height)""" return _libwebp.WebPGetInfo(*args) -WebPGetInfo = _libwebp.WebPGetInfo def WebPDecodeRGB(*args): + """WebPDecodeRGB(uint8_t data) -> (rgb, width, height)""" return _libwebp.WebPDecodeRGB(*args) -WebPDecodeRGB = _libwebp.WebPDecodeRGB def WebPDecodeRGBA(*args): + """WebPDecodeRGBA(uint8_t data) -> (rgb, width, height)""" return _libwebp.WebPDecodeRGBA(*args) -WebPDecodeRGBA = _libwebp.WebPDecodeRGBA def WebPDecodeARGB(*args): + """WebPDecodeARGB(uint8_t data) -> (rgb, width, height)""" return _libwebp.WebPDecodeARGB(*args) -WebPDecodeARGB = _libwebp.WebPDecodeARGB def WebPDecodeBGR(*args): + """WebPDecodeBGR(uint8_t data) -> (rgb, width, height)""" return _libwebp.WebPDecodeBGR(*args) -WebPDecodeBGR = _libwebp.WebPDecodeBGR def WebPDecodeBGRA(*args): + """WebPDecodeBGRA(uint8_t data) -> (rgb, width, height)""" return _libwebp.WebPDecodeBGRA(*args) -WebPDecodeBGRA = _libwebp.WebPDecodeBGRA def WebPGetEncoderVersion(): + """WebPGetEncoderVersion() -> int""" return _libwebp.WebPGetEncoderVersion() -WebPGetEncoderVersion = _libwebp.WebPGetEncoderVersion def wrap_WebPEncodeRGB(*args): + """private, do not call directly.""" return _libwebp.wrap_WebPEncodeRGB(*args) -wrap_WebPEncodeRGB = _libwebp.wrap_WebPEncodeRGB def wrap_WebPEncodeBGR(*args): + """private, do not call directly.""" return _libwebp.wrap_WebPEncodeBGR(*args) -wrap_WebPEncodeBGR = _libwebp.wrap_WebPEncodeBGR def wrap_WebPEncodeRGBA(*args): + """private, do not call directly.""" return _libwebp.wrap_WebPEncodeRGBA(*args) -wrap_WebPEncodeRGBA = _libwebp.wrap_WebPEncodeRGBA def wrap_WebPEncodeBGRA(*args): + """private, do not call directly.""" return _libwebp.wrap_WebPEncodeBGRA(*args) -wrap_WebPEncodeBGRA = _libwebp.wrap_WebPEncodeBGRA def wrap_WebPEncodeLosslessRGB(*args): + """private, do not call directly.""" return _libwebp.wrap_WebPEncodeLosslessRGB(*args) -wrap_WebPEncodeLosslessRGB = _libwebp.wrap_WebPEncodeLosslessRGB def wrap_WebPEncodeLosslessBGR(*args): + """private, do not call directly.""" return _libwebp.wrap_WebPEncodeLosslessBGR(*args) -wrap_WebPEncodeLosslessBGR = _libwebp.wrap_WebPEncodeLosslessBGR def wrap_WebPEncodeLosslessRGBA(*args): + """private, do not call directly.""" return _libwebp.wrap_WebPEncodeLosslessRGBA(*args) -wrap_WebPEncodeLosslessRGBA = _libwebp.wrap_WebPEncodeLosslessRGBA def wrap_WebPEncodeLosslessBGRA(*args): + """private, do not call directly.""" return _libwebp.wrap_WebPEncodeLosslessBGRA(*args) -wrap_WebPEncodeLosslessBGRA = _libwebp.wrap_WebPEncodeLosslessBGRA _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: @@ -141,6 +142,7 @@ def WebPEncodeRGB(rgb, width, height, stride, quality_factor): 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: @@ -148,6 +150,7 @@ def WebPEncodeRGBA(rgb, width, height, stride, quality_factor): 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: @@ -155,6 +158,7 @@ def WebPEncodeBGR(rgb, width, height, stride, quality_factor): 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: @@ -162,24 +166,28 @@ def WebPEncodeBGRA(rgb, width, height, stride, quality_factor): 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 diff --git a/swig/libwebp_python_wrap.c b/swig/libwebp_python_wrap.c index 5e8e89ca..b29f8349 100644 --- a/swig/libwebp_python_wrap.c +++ b/swig/libwebp_python_wrap.c @@ -4664,22 +4664,22 @@ fail: static PyMethodDef SwigMethods[] = { { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL}, - { (char *)"WebPGetDecoderVersion", _wrap_WebPGetDecoderVersion, METH_VARARGS, NULL}, - { (char *)"WebPGetInfo", _wrap_WebPGetInfo, METH_VARARGS, NULL}, - { (char *)"WebPDecodeRGB", _wrap_WebPDecodeRGB, METH_VARARGS, NULL}, - { (char *)"WebPDecodeRGBA", _wrap_WebPDecodeRGBA, METH_VARARGS, NULL}, - { (char *)"WebPDecodeARGB", _wrap_WebPDecodeARGB, METH_VARARGS, NULL}, - { (char *)"WebPDecodeBGR", _wrap_WebPDecodeBGR, METH_VARARGS, NULL}, - { (char *)"WebPDecodeBGRA", _wrap_WebPDecodeBGRA, METH_VARARGS, NULL}, - { (char *)"WebPGetEncoderVersion", _wrap_WebPGetEncoderVersion, METH_VARARGS, NULL}, - { (char *)"wrap_WebPEncodeRGB", _wrap_wrap_WebPEncodeRGB, METH_VARARGS, NULL}, - { (char *)"wrap_WebPEncodeBGR", _wrap_wrap_WebPEncodeBGR, METH_VARARGS, NULL}, - { (char *)"wrap_WebPEncodeRGBA", _wrap_wrap_WebPEncodeRGBA, METH_VARARGS, NULL}, - { (char *)"wrap_WebPEncodeBGRA", _wrap_wrap_WebPEncodeBGRA, METH_VARARGS, NULL}, - { (char *)"wrap_WebPEncodeLosslessRGB", _wrap_wrap_WebPEncodeLosslessRGB, METH_VARARGS, NULL}, - { (char *)"wrap_WebPEncodeLosslessBGR", _wrap_wrap_WebPEncodeLosslessBGR, METH_VARARGS, NULL}, - { (char *)"wrap_WebPEncodeLosslessRGBA", _wrap_wrap_WebPEncodeLosslessRGBA, METH_VARARGS, NULL}, - { (char *)"wrap_WebPEncodeLosslessBGRA", _wrap_wrap_WebPEncodeLosslessBGRA, METH_VARARGS, NULL}, + { (char *)"WebPGetDecoderVersion", _wrap_WebPGetDecoderVersion, METH_VARARGS, (char *)"WebPGetDecoderVersion() -> int"}, + { (char *)"WebPGetInfo", _wrap_WebPGetInfo, METH_VARARGS, (char *)"WebPGetInfo(uint8_t data) -> (width, height)"}, + { (char *)"WebPDecodeRGB", _wrap_WebPDecodeRGB, METH_VARARGS, (char *)"WebPDecodeRGB(uint8_t data) -> (rgb, width, height)"}, + { (char *)"WebPDecodeRGBA", _wrap_WebPDecodeRGBA, METH_VARARGS, (char *)"WebPDecodeRGBA(uint8_t data) -> (rgb, width, height)"}, + { (char *)"WebPDecodeARGB", _wrap_WebPDecodeARGB, METH_VARARGS, (char *)"WebPDecodeARGB(uint8_t data) -> (rgb, width, height)"}, + { (char *)"WebPDecodeBGR", _wrap_WebPDecodeBGR, METH_VARARGS, (char *)"WebPDecodeBGR(uint8_t data) -> (rgb, width, height)"}, + { (char *)"WebPDecodeBGRA", _wrap_WebPDecodeBGRA, METH_VARARGS, (char *)"WebPDecodeBGRA(uint8_t data) -> (rgb, width, height)"}, + { (char *)"WebPGetEncoderVersion", _wrap_WebPGetEncoderVersion, METH_VARARGS, (char *)"WebPGetEncoderVersion() -> int"}, + { (char *)"wrap_WebPEncodeRGB", _wrap_wrap_WebPEncodeRGB, METH_VARARGS, (char *)"private, do not call directly."}, + { (char *)"wrap_WebPEncodeBGR", _wrap_wrap_WebPEncodeBGR, METH_VARARGS, (char *)"private, do not call directly."}, + { (char *)"wrap_WebPEncodeRGBA", _wrap_wrap_WebPEncodeRGBA, METH_VARARGS, (char *)"private, do not call directly."}, + { (char *)"wrap_WebPEncodeBGRA", _wrap_wrap_WebPEncodeBGRA, METH_VARARGS, (char *)"private, do not call directly."}, + { (char *)"wrap_WebPEncodeLosslessRGB", _wrap_wrap_WebPEncodeLosslessRGB, METH_VARARGS, (char *)"private, do not call directly."}, + { (char *)"wrap_WebPEncodeLosslessBGR", _wrap_wrap_WebPEncodeLosslessBGR, METH_VARARGS, (char *)"private, do not call directly."}, + { (char *)"wrap_WebPEncodeLosslessRGBA", _wrap_wrap_WebPEncodeLosslessRGBA, METH_VARARGS, (char *)"private, do not call directly."}, + { (char *)"wrap_WebPEncodeLosslessBGRA", _wrap_wrap_WebPEncodeLosslessBGRA, METH_VARARGS, (char *)"private, do not call directly."}, { NULL, NULL, 0, NULL } }; From 850e956f9bad7dbc5f276476a530a8610c271b34 Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 21 May 2013 14:58:32 -0700 Subject: [PATCH 38/57] README: update swig notes add python, required version notes Change-Id: Iec2e94075f6cf54455ce5a658f9b7258109f4d01 (cherry picked from commit 4a7627c2152539dcf02a30ddc9d14eb58645f45c) --- README | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/README b/README index aa6bca45..2aeca088 100644 --- a/README +++ b/README @@ -80,8 +80,8 @@ more options. SWIG bindings: -------------- -To generate language bindings from swig/libwebp.i swig-1.3 -(http://www.swig.org) is required. 2.0 may work, but has not been tested. +To generate language bindings from swig/libwebp.i at least swig-1.3 +(http://www.swig.org) is required. Currently the following functions are mapped: Decode: @@ -104,12 +104,20 @@ Encode: WebPEncodeLosslessRGB WebPEncodeLosslessBGR +See swig/README for more detailed build instructions. + Java bindings: To build the swig-generated JNI wrapper code at least JDK-1.5 (or equivalent) is necessary for enum support. The output is intended to be a shared object / DLL that can be loaded via System.loadLibrary("webp_jni"). +Python bindings: + +To build the swig-generated Python extension code at least Python 2.6 is +required. Python < 2.6 may build with some minor changes to libwebp.i or the +generated code, but is untested. + Encoding tool: ============== From db5095d5b644c166a3097228989130d1505ff68c Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 21 May 2013 15:01:15 -0700 Subject: [PATCH 39/57] remove some cruft from swig/libwebp.jar picked up a few unnecessary classes from a dirty tree in the last commit Change-Id: I98be16a0bc8716476ce440da542d113f254aee78 (cherry picked from commit 325d15ff30a6379cbd7fb09d33d05a815399b0d5) --- swig/libwebp.jar | Bin 3099 -> 2143 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/swig/libwebp.jar b/swig/libwebp.jar index 6cc574b2d8d163b9aade3b5857e0bc646398ea94..4014dfa86fb0c97d8d30a5cd3aa25f7fef816530 100644 GIT binary patch delta 155 zcmbO&abJKpz?+#xgn@&DgQ2E;>qK5FW)S6752nt@gQ<6FAZoHWqc(`%?8-Qi8O*rJ zvYC;Wkx7IBu7C1cP7AQw7o7HBT8m2`OviAUf$6DS)?oTFmj{@Z<8~BbWn%yWb|Bo( K$iUDA<^ceAt1lz~ delta 1118 zcmcaFFk6B*z?+#xgn@&DgQ2i}%S2u)W)S67&z#)7V&WNjF!fH2`B&=3$>NOKAj!?H zj1!r`jGHW*8S9aBJ24;u6(Bn~KUY6JKR-PuRlhtnsX#wC+|xZIGQc&yAU-p%L@zlf zvADRl-_iT9gFx&3WtrPOgQahGnY-@UVkvQO@gvn05v#18}? z4hP)ger#|%U1OV7_}gN(tDfsvo!3eqdsJff@kq&oDnZTGXu&n z0B5z{o-6O-W#oDFs@V^hNF2MFH~Z7-zh}N4SI^t!aq;)boLAk41I&8wAGmg6Z+$6m zK?sjXU{b{I|BP(GLS;{mHP$}sZJD3g{BPBz`;sCv9nEhRPw~9CVzb!3Jlp2T*Zu)= zpEBpZ5~|#^YQ@DhGmEFn%lv+}#eRp?S@Vo-oXviv2XimWOZZk$0#4_C77p-c=ivD2_`{g7o`K;QBLf3UETY7N2L5;`1xAELJTxv^ zC-{Tn;wU68qHlZkFA~2k)APVJV2_BX_f@CvMbjr7QC(6$DQNpQ<;qVA8cpo=>zm}g z=JdLcB0YoqIL0zgNePoGI^~oHmj>8_RU+-Udc3}5codOY^l!?g^ z|LX;uBLmN!=yra7M!v%#srTO6%k~BttN8DRoSUeAbitXpAItvoq^-AetoB&#+vWXa z<%-2FTc1wR{`265dHSD&p)2-zZ8eQ3>Eh1o{uU5(v5wjN-GR668Q)bhG-r9Awc5(C zcJ)*BXe-X8SM=(cKvBZ@OJB+o7#o+sF~Z0s!T`@%lV`G7fHKYGD{S_lOf^}IT^~$) zu$zH%S0lSMSbjgd2bkvKaI8l$!3h%KkoX4WE(GXeBQCE6c%zz#>|RhhK>&UZpozA) avoA`r3GikGI)H(J6A06p7#QYpf_MNSQn+aV From 0b18b9eef667b5359f6f44581de92a09d78142d3 Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 22 May 2013 00:58:53 +0200 Subject: [PATCH 40/57] fix two minor memory leaks in webpmux (only occur in case of error) Change-Id: Icab69bb364b77f8eae6cae91047354c27e610602 (cherry picked from commit 3e59a74d721ed15c8845c9c1215dcb09fdb55fa6) --- examples/webpmux.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/webpmux.c b/examples/webpmux.c index 40592f27..b17d6a6e 100644 --- a/examples/webpmux.c +++ b/examples/webpmux.c @@ -226,11 +226,13 @@ static WebPMuxError DisplayInfo(const WebPMux* mux) { for (i = 1; i <= nFrames; i++) { WebPMuxFrameInfo frame; err = WebPMuxGetFrame(mux, i, &frame); - RETURN_IF_ERROR3("Failed to retrieve %s#%d\n", type_str, i); - printf("%3d: %8d %8d ", i, frame.x_offset, frame.y_offset); - if (is_anim) printf("%8d %7d ", frame.duration, frame.dispose_method); - printf("%10d\n", (int)frame.bitstream.size); + if (err == WEBP_MUX_OK) { + printf("%3d: %8d %8d ", i, frame.x_offset, frame.y_offset); + if (is_anim) printf("%8d %7d ", frame.duration, frame.dispose_method); + printf("%10d\n", (int)frame.bitstream.size); + } WebPDataClear(&frame.bitstream); + RETURN_IF_ERROR3("Failed to retrieve %s#%d\n", type_str, i); } } } @@ -259,8 +261,11 @@ static WebPMuxError DisplayInfo(const WebPMux* mux) { if ((flag & ALPHA_FLAG) && !(flag & (ANIMATION_FLAG | FRAGMENTS_FLAG))) { WebPMuxFrameInfo image; err = WebPMuxGetFrame(mux, 1, &image); + if (err == WEBP_MUX_OK) { + printf("Size of the image (with alpha): %d\n", (int)image.bitstream.size); + } + WebPDataClear(&image.bitstream); RETURN_IF_ERROR("Failed to retrieve the image\n"); - printf("Size of the image (with alpha): %d\n", (int)image.bitstream.size); } return WEBP_MUX_OK; From e19084302947369b41c9668e7471bc28fae2e45d Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 22 May 2013 23:49:24 +0200 Subject: [PATCH 41/57] fix a memory leak in gif2webp (rgba->yuv allocates memory) Also fixed few warning and cleaned the code up. Change-Id: Id904ad3ad8802ea9fc3d34247d27193dfa7b0b99 (cherry picked from commit 764fdffaac562cc14a6d93475ed08cb04b2de2bb) --- examples/gif2webp.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/examples/gif2webp.c b/examples/gif2webp.c index 14a29718..7dae76c4 100644 --- a/examples/gif2webp.c +++ b/examples/gif2webp.c @@ -188,8 +188,6 @@ int main(int argc, const char *argv[]) { FILE* out = NULL; GifFileType* gif = NULL; WebPPicture picture; - WebPPicture view; - WebPMemoryWriter memory; WebPMuxFrameInfo frame; WebPMuxAnimParams anim = { WHITE_COLOR, 0 }; @@ -276,9 +274,7 @@ int main(int argc, const char *argv[]) { picture.width = gif->SWidth; picture.height = gif->SHeight; picture.use_argb = 1; - picture.writer = WebPMemoryWrite; - picture.custom_ptr = &memory; - if (!WebPPictureAlloc(&picture)) goto End; + if (!WebPPictureAlloc(&picture)) goto End; mux = WebPMuxNew(); if (mux == NULL) { @@ -294,27 +290,33 @@ int main(int argc, const char *argv[]) { switch (type) { case IMAGE_DESC_RECORD_TYPE: { + WebPPicture sub_image; + WebPMemoryWriter memory; + if (frame.dispose_method == WEBP_MUX_DISPOSE_BACKGROUND) { ClearPicture(&picture, anim.bgcolor); } if (!DGifGetImageDesc(gif)) goto End; - if (!ReadSubImage(gif, &picture, &view)) goto End; + if (!ReadSubImage(gif, &picture, &sub_image)) goto End; - WebPMemoryWriterInit(&memory); if (!config.lossless) { - // We need to call BGRA variant because of the way we do Remap(). - // TODO(later): This works for little-endian only due to uint32_t to - // uint8_t conversion. Make it work for big-endian too. - WebPPictureImportBGRA(&view, (uint8_t*)view.argb, - view.argb_stride * sizeof(*view.argb)); - view.use_argb = 0; + // We need to call BGRA variant because of the way we do Remap(). Note + // that 'sub_image' will no longer be a view and own some memory. + WebPPictureImportBGRA( + &sub_image, (uint8_t*)sub_image.argb, + sub_image.argb_stride * sizeof(*sub_image.argb)); + sub_image.use_argb = 0; } else { - view.use_argb = 1; + sub_image.use_argb = 1; } - if (!WebPEncode(&config, &view)) { + + sub_image.writer = WebPMemoryWrite; + sub_image.custom_ptr = &memory; + WebPMemoryWriterInit(&memory); + if (!WebPEncode(&config, &sub_image)) { fprintf(stderr, "Error! Cannot encode picture as WebP\n"); - fprintf(stderr, "Error code: %d\n", view.error_code); + fprintf(stderr, "Error code: %d\n", sub_image.error_code); goto End; } @@ -333,12 +335,14 @@ int main(int argc, const char *argv[]) { } if (verbose) { printf("Added frame %dx%d (offset:%d,%d duration:%d) ", - view.width, view.height, frame.x_offset, frame.y_offset, + sub_image.width, sub_image.height, + frame.x_offset, frame.y_offset, frame.duration); printf("dispose:%d transparent index:%d\n", frame.dispose_method, transparent_index); } WebPDataClear(&frame.bitstream); + WebPPictureFree(&sub_image); break; } case EXTENSION_RECORD_TYPE: { @@ -398,7 +402,7 @@ int main(int argc, const char *argv[]) { const int is_icc = !stored_icc && !memcmp(data + 1, "ICCRGBG1012", 11); if (is_xmp || is_icc) { - const char fourccs[2][4] = { "XMP " , "ICCP" }; + const char* const fourccs[2] = { "XMP " , "ICCP" }; const char* const features[2] = { "XMP" , "ICC" }; WebPData metadata = { NULL, 0 }; // Construct metadata from sub-blocks. @@ -427,7 +431,7 @@ int main(int argc, const char *argv[]) { goto End; } metadata.size += subblock.size; - memcpy((void*)metadata.bytes + prev_metadata.size, + memcpy((void*)(metadata.bytes + prev_metadata.size), subblock.bytes, subblock.size); } if (is_xmp) { From 8287012ec7fa450cd91cbaf8bcd4e75999b3f0de Mon Sep 17 00:00:00 2001 From: skal Date: Thu, 23 May 2013 13:52:24 +0200 Subject: [PATCH 42/57] remove datatype qualifier for vmnv this fix is for clang (LLVM v4.2). gcc was fine. Change-Id: Id4076cda84813f6f9548a01775b094cff22b4be9 (cherry picked from commit 3fe91635df8734b23f3c1b9d1f0c4fa8cfaf4e39) --- src/dsp/enc_neon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dsp/enc_neon.c b/src/dsp/enc_neon.c index 06b6b09c..7c78f041 100644 --- a/src/dsp/enc_neon.c +++ b/src/dsp/enc_neon.c @@ -322,7 +322,7 @@ static void FTransform(const uint8_t* src, const uint8_t* ref, "vmlal.s16 q11, d6, d17 \n" // c1*2217 + d1*5352 + 12000 "vmlsl.s16 q12, d6, d16 \n" // d1*2217 - c1*5352 + 51000 - "vmvn.s16 d4, d4 \n" + "vmvn d4, d4 \n" // !(d1 == 0) // op[4] = (c1*2217 + d1*5352 + 12000)>>16 "vshrn.s32 d1, q11, #16 \n" // op[4] += (d1!=0) From a71e5d84e915074778b81e450795f8a55caaf907 Mon Sep 17 00:00:00 2001 From: skal Date: Fri, 31 May 2013 10:41:19 +0200 Subject: [PATCH 43/57] add doc precision for WebPPictureCopy() and WebPPictureView() output picture object is overwritten, not free'd or destroyed. Change-Id: Ibb47ab444063e7ad90ff3d296260807ffe7ddbf9 (cherry picked from commit 23d28e216dfb67ea308bba23dbd5a6d3364c3a27) --- src/webp/encode.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/webp/encode.h b/src/webp/encode.h index d635fcf0..628b8887 100644 --- a/src/webp/encode.h +++ b/src/webp/encode.h @@ -360,8 +360,9 @@ WEBP_EXTERN(int) WebPPictureAlloc(WebPPicture* picture); // preserved. WEBP_EXTERN(void) WebPPictureFree(WebPPicture* picture); -// Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return, -// *dst will fully own the copied pixels (this is not a view). +// Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return, *dst +// will fully own the copied pixels (this is not a view). The 'dst' picture need +// not be initialized as its content is overwritten. // Returns false in case of memory allocation error. WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* src, WebPPicture* dst); @@ -392,7 +393,9 @@ WEBP_EXTERN(int) WebPPictureCrop(WebPPicture* picture, // the top and left coordinates will be snapped to even values. // Picture 'src' must out-live 'dst' picture. Self-extraction of view is allowed // ('src' equal to 'dst') as a mean of fast-cropping (but note that doing so, -// the original dimension will be lost). +// the original dimension will be lost). Picture 'dst' need not be initialized +// with WebPPictureInit() if it is different from 'src', since its content will +// be overwritten. // Returns false in case of memory allocation error or invalid parameters. WEBP_EXTERN(int) WebPPictureView(const WebPPicture* src, int left, int top, int width, int height, From a94a88dd623533c6f9ca9ce6adcb29569d9a2258 Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 5 Jun 2013 10:07:48 +0200 Subject: [PATCH 44/57] fix EXIF parsing in PNG 'exiftool' puts an 'APP1' chunk for exif, e.g.: https://metacpan.org/source/EXIFTOOL/Image-ExifTool-5.87/lib/Image/ExifTool/PNG.pm#L305 Change-Id: I313d3e6945898526b8a4baf3d9016a2591a1a817 (cherry picked from commit bec11092ca9c32d8f447b9313502963d000e0962) --- examples/pngdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/pngdec.c b/examples/pngdec.c index 78353560..ff9311c7 100644 --- a/examples/pngdec.c +++ b/examples/pngdec.c @@ -108,6 +108,8 @@ static const struct { // See also: ExifTool on CPAN. { "Raw profile type exif", ProcessRawProfile, METADATA_OFFSET(exif) }, { "Raw profile type xmp", ProcessRawProfile, METADATA_OFFSET(xmp) }, + // Exiftool puts exif data in APP1 chunk, too. + { "Raw profile type APP1", ProcessRawProfile, METADATA_OFFSET(exif) }, // XMP Specification Part 3, Section 3 #PNG { "XML:com.adobe.xmp", MetadataCopy, METADATA_OFFSET(xmp) }, { NULL, NULL, 0 }, From a00380d2ed6136427da5cb7bfdf0acd8fda42000 Mon Sep 17 00:00:00 2001 From: James Zern Date: Tue, 4 Jun 2013 23:45:10 -0700 Subject: [PATCH 45/57] configure: remove use of AS_VAR_APPEND This wasn't used often and benefits were likely minimal. Dropping it outright is a bit simpler than adding a compatibility ifdef. provides some compatibility with older versions of autoconf. tested with autoconf 2.59/automake 1.7/aclocal 1.7 Change-Id: Ifed892346cf2329597985704830a96fc58d65607 (cherry picked from commit 9326a56f8d9412a74c83bd8eddc994ac08d2a062) --- configure.ac | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index f4937170..d6378d03 100644 --- a/configure.ac +++ b/configure.ac @@ -40,7 +40,10 @@ AC_DEFUN([TEST_AND_ADD_CFLAGS], dnl Note AC_LANG_PROGRAM([]) uses an old-style main definition. AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) { return 0; }])], [AC_MSG_RESULT([yes])] - [AS_VAR_APPEND([AM_CFLAGS], [" $1"])], + dnl Simply append the variable avoiding a + dnl compatibility ifdef for AS_VAR_APPEND as this + dnl variable shouldn't grow all that large. + [AM_CFLAGS="$AM_CFLAGS $1"], [AC_MSG_RESULT([no])]) CFLAGS="$SAVED_CFLAGS"]) TEST_AND_ADD_CFLAGS([-Wall]) From c7e89cbb02fe0c5ca69da0491394d7f2cad09a8a Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 6 Jun 2013 23:05:58 -0700 Subject: [PATCH 46/57] update copyright text rather than symlink the webm/vpx terms, use the same header as libvpx to reference in-tree files based on the discussion in: https://codereview.chromium.org/12771026/ Change-Id: Ia3067ecddefaa7ee01550136e00f7b3f086d4af4 (cherry picked from commit d640614d544453ce14e2bbeeef8f33c78c8b09fd) --- examples/cwebp.c | 8 +++++--- examples/dwebp.c | 8 +++++--- examples/example_util.c | 8 +++++--- examples/example_util.h | 8 +++++--- examples/gif2webp.c | 8 +++++--- examples/jpegdec.c | 8 +++++--- examples/jpegdec.h | 8 +++++--- examples/metadata.c | 8 +++++--- examples/metadata.h | 8 +++++--- examples/pngdec.c | 8 +++++--- examples/pngdec.h | 8 +++++--- examples/stopwatch.h | 8 +++++--- examples/tiffdec.c | 8 +++++--- examples/tiffdec.h | 8 +++++--- examples/vwebp.c | 8 +++++--- examples/webpmux.c | 8 +++++--- examples/wicdec.c | 8 +++++--- examples/wicdec.h | 8 +++++--- src/dec/alpha.c | 8 +++++--- src/dec/buffer.c | 8 +++++--- src/dec/decode_vp8.h | 8 +++++--- src/dec/frame.c | 8 +++++--- src/dec/idec.c | 8 +++++--- src/dec/io.c | 8 +++++--- src/dec/layer.c | 8 +++++--- src/dec/quant.c | 8 +++++--- src/dec/tree.c | 8 +++++--- src/dec/vp8.c | 8 +++++--- src/dec/vp8i.h | 8 +++++--- src/dec/vp8l.c | 8 +++++--- src/dec/vp8li.h | 8 +++++--- src/dec/webp.c | 8 +++++--- src/dec/webpi.h | 8 +++++--- src/demux/demux.c | 8 +++++--- src/dsp/cpu.c | 8 +++++--- src/dsp/dec.c | 8 +++++--- src/dsp/dec_neon.c | 8 +++++--- src/dsp/dec_sse2.c | 8 +++++--- src/dsp/dsp.h | 8 +++++--- src/dsp/enc.c | 8 +++++--- src/dsp/enc_neon.c | 8 +++++--- src/dsp/enc_sse2.c | 8 +++++--- src/dsp/lossless.c | 8 +++++--- src/dsp/lossless.h | 8 +++++--- src/dsp/upsampling.c | 8 +++++--- src/dsp/upsampling_neon.c | 8 +++++--- src/dsp/upsampling_sse2.c | 8 +++++--- src/dsp/yuv.c | 8 +++++--- src/dsp/yuv.h | 8 +++++--- src/enc/alpha.c | 8 +++++--- src/enc/analysis.c | 8 +++++--- src/enc/backward_references.c | 8 +++++--- src/enc/backward_references.h | 8 +++++--- src/enc/config.c | 8 +++++--- src/enc/cost.c | 8 +++++--- src/enc/cost.h | 8 +++++--- src/enc/filter.c | 8 +++++--- src/enc/frame.c | 8 +++++--- src/enc/histogram.c | 8 +++++--- src/enc/histogram.h | 8 +++++--- src/enc/iterator.c | 8 +++++--- src/enc/layer.c | 8 +++++--- src/enc/picture.c | 8 +++++--- src/enc/quant.c | 8 +++++--- src/enc/syntax.c | 8 +++++--- src/enc/token.c | 8 +++++--- src/enc/tree.c | 8 +++++--- src/enc/vp8enci.h | 8 +++++--- src/enc/vp8l.c | 8 +++++--- src/enc/vp8li.h | 8 +++++--- src/enc/webpenc.c | 8 +++++--- src/mux/muxedit.c | 8 +++++--- src/mux/muxi.h | 8 +++++--- src/mux/muxinternal.c | 8 +++++--- src/mux/muxread.c | 8 +++++--- src/utils/bit_reader.c | 8 +++++--- src/utils/bit_reader.h | 8 +++++--- src/utils/bit_writer.c | 8 +++++--- src/utils/bit_writer.h | 8 +++++--- src/utils/color_cache.c | 8 +++++--- src/utils/color_cache.h | 8 +++++--- src/utils/filters.c | 8 +++++--- src/utils/filters.h | 8 +++++--- src/utils/huffman.c | 8 +++++--- src/utils/huffman.h | 8 +++++--- src/utils/huffman_encode.c | 8 +++++--- src/utils/huffman_encode.h | 8 +++++--- src/utils/quant_levels.c | 8 +++++--- src/utils/quant_levels.h | 8 +++++--- src/utils/quant_levels_dec.c | 8 +++++--- src/utils/quant_levels_dec.h | 8 +++++--- src/utils/rescaler.c | 8 +++++--- src/utils/rescaler.h | 8 +++++--- src/utils/thread.c | 8 +++++--- src/utils/thread.h | 8 +++++--- src/utils/utils.c | 8 +++++--- src/utils/utils.h | 8 +++++--- src/webp/decode.h | 8 +++++--- src/webp/demux.h | 8 +++++--- src/webp/encode.h | 8 +++++--- src/webp/format_constants.h | 8 +++++--- src/webp/mux.h | 8 +++++--- src/webp/mux_types.h | 8 +++++--- src/webp/types.h | 8 +++++--- swig/libwebp.i | 8 +++++--- 105 files changed, 525 insertions(+), 315 deletions(-) diff --git a/examples/cwebp.c b/examples/cwebp.c index 0aee03ea..efdeccfe 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // simple command line calling the WebPEncode function. diff --git a/examples/dwebp.c b/examples/dwebp.c index 59896651..c84b0d1d 100644 --- a/examples/dwebp.c +++ b/examples/dwebp.c @@ -1,8 +1,10 @@ // Copyright 2010 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Command-line tool for decoding a WebP image. diff --git a/examples/example_util.c b/examples/example_util.c index 89172a55..8d31da66 100644 --- a/examples/example_util.c +++ b/examples/example_util.c @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Utility functions used by the example programs. diff --git a/examples/example_util.h b/examples/example_util.h index 7b30dbe1..0122fd3c 100644 --- a/examples/example_util.h +++ b/examples/example_util.h @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Utility functions used by the example programs. diff --git a/examples/gif2webp.c b/examples/gif2webp.c index 7dae76c4..fd5d39a7 100644 --- a/examples/gif2webp.c +++ b/examples/gif2webp.c @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // simple tool to convert animated GIFs to WebP diff --git a/examples/jpegdec.c b/examples/jpegdec.c index a1822d31..0c8fa647 100644 --- a/examples/jpegdec.c +++ b/examples/jpegdec.c @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // JPEG decode. diff --git a/examples/jpegdec.h b/examples/jpegdec.h index afd54175..156620f2 100644 --- a/examples/jpegdec.h +++ b/examples/jpegdec.h @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // JPEG decode. diff --git a/examples/metadata.c b/examples/metadata.c index 38a3d8cc..936f2f4e 100644 --- a/examples/metadata.c +++ b/examples/metadata.c @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Metadata types and functions. diff --git a/examples/metadata.h b/examples/metadata.h index 641f7c73..989a43eb 100644 --- a/examples/metadata.h +++ b/examples/metadata.h @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Metadata types and functions. diff --git a/examples/pngdec.c b/examples/pngdec.c index ff9311c7..814a4774 100644 --- a/examples/pngdec.c +++ b/examples/pngdec.c @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // PNG decode. diff --git a/examples/pngdec.h b/examples/pngdec.h index f53f8631..80c142d2 100644 --- a/examples/pngdec.h +++ b/examples/pngdec.h @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // PNG decode. diff --git a/examples/stopwatch.h b/examples/stopwatch.h index de49ffe2..a705481f 100644 --- a/examples/stopwatch.h +++ b/examples/stopwatch.h @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Helper functions to measure elapsed time. diff --git a/examples/tiffdec.c b/examples/tiffdec.c index 8845afbd..8fc61740 100644 --- a/examples/tiffdec.c +++ b/examples/tiffdec.c @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // TIFF decode. diff --git a/examples/tiffdec.h b/examples/tiffdec.h index f441d5e0..cde1534f 100644 --- a/examples/tiffdec.h +++ b/examples/tiffdec.h @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // TIFF decode. diff --git a/examples/vwebp.c b/examples/vwebp.c index 93897449..df389a61 100644 --- a/examples/vwebp.c +++ b/examples/vwebp.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Simple OpenGL-based WebP file viewer. diff --git a/examples/webpmux.c b/examples/webpmux.c index b17d6a6e..51acefa8 100644 --- a/examples/webpmux.c +++ b/examples/webpmux.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Simple command-line to create a WebP container file and to extract or strip diff --git a/examples/wicdec.c b/examples/wicdec.c index 009401d8..909deaeb 100644 --- a/examples/wicdec.c +++ b/examples/wicdec.c @@ -1,8 +1,10 @@ // Copyright 2013 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Windows Imaging Component (WIC) decode. diff --git a/examples/wicdec.h b/examples/wicdec.h index 4aa7e906..6d797ce0 100644 --- a/examples/wicdec.h +++ b/examples/wicdec.h @@ -1,8 +1,10 @@ // Copyright 2013 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Windows Imaging Component (WIC) decode. diff --git a/src/dec/alpha.c b/src/dec/alpha.c index 5c173718..b5e68919 100644 --- a/src/dec/alpha.c +++ b/src/dec/alpha.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Alpha-plane decompression. diff --git a/src/dec/buffer.c b/src/dec/buffer.c index c159f6f2..38557152 100644 --- a/src/dec/buffer.c +++ b/src/dec/buffer.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Everything about WebPDecBuffer diff --git a/src/dec/decode_vp8.h b/src/dec/decode_vp8.h index 12c77bcb..acdb15aa 100644 --- a/src/dec/decode_vp8.h +++ b/src/dec/decode_vp8.h @@ -1,8 +1,10 @@ // Copyright 2010 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Low-level API for VP8 decoder diff --git a/src/dec/frame.c b/src/dec/frame.c index 911c7ffc..5f6a7d98 100644 --- a/src/dec/frame.c +++ b/src/dec/frame.c @@ -1,8 +1,10 @@ // Copyright 2010 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Frame-reconstruction function. Memory allocation. diff --git a/src/dec/idec.c b/src/dec/idec.c index cbf9638e..5fbf49aa 100644 --- a/src/dec/idec.c +++ b/src/dec/idec.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Incremental decoding diff --git a/src/dec/io.c b/src/dec/io.c index 594804c2..63810b44 100644 --- a/src/dec/io.c +++ b/src/dec/io.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // functions for sample output. diff --git a/src/dec/layer.c b/src/dec/layer.c index a3a5bdcf..9a4b2d90 100644 --- a/src/dec/layer.c +++ b/src/dec/layer.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Enhancement layer (for YUV444/422) diff --git a/src/dec/quant.c b/src/dec/quant.c index d54097af..a4cc693d 100644 --- a/src/dec/quant.c +++ b/src/dec/quant.c @@ -1,8 +1,10 @@ // Copyright 2010 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Quantizer initialization diff --git a/src/dec/tree.c b/src/dec/tree.c index 82484e4c..3f02efe4 100644 --- a/src/dec/tree.c +++ b/src/dec/tree.c @@ -1,8 +1,10 @@ // Copyright 2010 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Coding trees and probas diff --git a/src/dec/vp8.c b/src/dec/vp8.c index 253cb6b6..8632e48e 100644 --- a/src/dec/vp8.c +++ b/src/dec/vp8.c @@ -1,8 +1,10 @@ // Copyright 2010 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // main entry for the decoder diff --git a/src/dec/vp8i.h b/src/dec/vp8i.h index 4f1a91c8..80532ea4 100644 --- a/src/dec/vp8i.h +++ b/src/dec/vp8i.h @@ -1,8 +1,10 @@ // Copyright 2010 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // VP8 decoder: internal header. diff --git a/src/dec/vp8l.c b/src/dec/vp8l.c index 395b36d7..1f618e82 100644 --- a/src/dec/vp8l.c +++ b/src/dec/vp8l.c @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // main entry for the decoder diff --git a/src/dec/vp8li.h b/src/dec/vp8li.h index 8b240585..543a7675 100644 --- a/src/dec/vp8li.h +++ b/src/dec/vp8li.h @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Lossless decoder: internal header. diff --git a/src/dec/webp.c b/src/dec/webp.c index aa3a703f..97e79b64 100644 --- a/src/dec/webp.c +++ b/src/dec/webp.c @@ -1,8 +1,10 @@ // Copyright 2010 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Main decoding functions for WEBP images. diff --git a/src/dec/webpi.h b/src/dec/webpi.h index 9349fcc7..4ae0bfc5 100644 --- a/src/dec/webpi.h +++ b/src/dec/webpi.h @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Internal header: WebP decoding parameters and custom IO on buffer diff --git a/src/demux/demux.c b/src/demux/demux.c index dd75904f..57f6d477 100644 --- a/src/demux/demux.c +++ b/src/demux/demux.c @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // WebP container demux. diff --git a/src/dsp/cpu.c b/src/dsp/cpu.c index 02287344..179901e1 100644 --- a/src/dsp/cpu.c +++ b/src/dsp/cpu.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // CPU detection diff --git a/src/dsp/dec.c b/src/dsp/dec.c index 758c6a57..2fbd6b1a 100644 --- a/src/dsp/dec.c +++ b/src/dsp/dec.c @@ -1,8 +1,10 @@ // Copyright 2010 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Speed-critical decoding functions. diff --git a/src/dsp/dec_neon.c b/src/dsp/dec_neon.c index 5aff0d3f..5dcd3b7e 100644 --- a/src/dsp/dec_neon.c +++ b/src/dsp/dec_neon.c @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // ARM NEON version of dsp functions and loop filtering. diff --git a/src/dsp/dec_sse2.c b/src/dsp/dec_sse2.c index 1cac1b84..6be94678 100644 --- a/src/dsp/dec_sse2.c +++ b/src/dsp/dec_sse2.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // SSE2 version of some decoding functions (idct, loop filtering). diff --git a/src/dsp/dsp.h b/src/dsp/dsp.h index 933df60b..01a95891 100644 --- a/src/dsp/dsp.h +++ b/src/dsp/dsp.h @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Speed-critical functions. diff --git a/src/dsp/enc.c b/src/dsp/enc.c index a6f05a5b..00ee80c9 100644 --- a/src/dsp/enc.c +++ b/src/dsp/enc.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Speed-critical encoding functions. diff --git a/src/dsp/enc_neon.c b/src/dsp/enc_neon.c index 7c78f041..6239a766 100644 --- a/src/dsp/enc_neon.c +++ b/src/dsp/enc_neon.c @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // ARM NEON version of speed-critical encoding functions. diff --git a/src/dsp/enc_sse2.c b/src/dsp/enc_sse2.c index 619e6c5c..bb0b2a29 100644 --- a/src/dsp/enc_sse2.c +++ b/src/dsp/enc_sse2.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // SSE2 version of speed-critical encoding functions. diff --git a/src/dsp/lossless.c b/src/dsp/lossless.c index f9078071..e445924e 100644 --- a/src/dsp/lossless.c +++ b/src/dsp/lossless.c @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Image transforms and color space conversion methods for lossless decoder. diff --git a/src/dsp/lossless.h b/src/dsp/lossless.h index 3fd224e6..7490ec8e 100644 --- a/src/dsp/lossless.h +++ b/src/dsp/lossless.h @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Image transforms and color space conversion methods for lossless decoder. diff --git a/src/dsp/upsampling.c b/src/dsp/upsampling.c index aea4964b..80ba4f8a 100644 --- a/src/dsp/upsampling.c +++ b/src/dsp/upsampling.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // YUV to RGB upsampling functions. diff --git a/src/dsp/upsampling_neon.c b/src/dsp/upsampling_neon.c index 00e2f892..d1188959 100644 --- a/src/dsp/upsampling_neon.c +++ b/src/dsp/upsampling_neon.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // NEON version of YUV to RGB upsampling functions. diff --git a/src/dsp/upsampling_sse2.c b/src/dsp/upsampling_sse2.c index ba075d11..f31d0484 100644 --- a/src/dsp/upsampling_sse2.c +++ b/src/dsp/upsampling_sse2.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // SSE2 version of YUV to RGB upsampling functions. diff --git a/src/dsp/yuv.c b/src/dsp/yuv.c index f8988bae..1a59f744 100644 --- a/src/dsp/yuv.c +++ b/src/dsp/yuv.c @@ -1,8 +1,10 @@ // Copyright 2010 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // YUV->RGB conversion function diff --git a/src/dsp/yuv.h b/src/dsp/yuv.h index 126404b6..3844d8ca 100644 --- a/src/dsp/yuv.h +++ b/src/dsp/yuv.h @@ -1,8 +1,10 @@ // Copyright 2010 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // inline YUV<->RGB conversion function diff --git a/src/enc/alpha.c b/src/enc/alpha.c index 60391c11..e636c967 100644 --- a/src/enc/alpha.c +++ b/src/enc/alpha.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Alpha-plane compression. diff --git a/src/enc/analysis.c b/src/enc/analysis.c index 221e9d06..4ff3edd2 100644 --- a/src/enc/analysis.c +++ b/src/enc/analysis.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Macroblock analysis diff --git a/src/enc/backward_references.c b/src/enc/backward_references.c index 67dd7e94..db4f430d 100644 --- a/src/enc/backward_references.c +++ b/src/enc/backward_references.c @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Author: Jyrki Alakuijala (jyrki@google.com) diff --git a/src/enc/backward_references.h b/src/enc/backward_references.h index 8cb1a7a6..b0d18135 100644 --- a/src/enc/backward_references.h +++ b/src/enc/backward_references.h @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Author: Jyrki Alakuijala (jyrki@google.com) diff --git a/src/enc/config.c b/src/enc/config.c index bb88111b..acf96b0f 100644 --- a/src/enc/config.c +++ b/src/enc/config.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Coding tools configuration diff --git a/src/enc/cost.c b/src/enc/cost.c index 89b60ba6..d4916d7c 100644 --- a/src/enc/cost.c +++ b/src/enc/cost.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Cost tables for level and modes diff --git a/src/enc/cost.h b/src/enc/cost.h index e264d321..7d7c2c79 100644 --- a/src/enc/cost.h +++ b/src/enc/cost.h @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Cost tables for level and modes. diff --git a/src/enc/filter.c b/src/enc/filter.c index 7fb78a39..aae2723d 100644 --- a/src/enc/filter.c +++ b/src/enc/filter.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Selecting filter level diff --git a/src/enc/frame.c b/src/enc/frame.c index 95206185..c56abed7 100644 --- a/src/enc/frame.c +++ b/src/enc/frame.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // frame coding and analysis diff --git a/src/enc/histogram.c b/src/enc/histogram.c index 69e5fa36..787ea5d1 100644 --- a/src/enc/histogram.c +++ b/src/enc/histogram.c @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Author: Jyrki Alakuijala (jyrki@google.com) diff --git a/src/enc/histogram.h b/src/enc/histogram.h index fe7cea6f..583b5a4f 100644 --- a/src/enc/histogram.h +++ b/src/enc/histogram.h @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Author: Jyrki Alakuijala (jyrki@google.com) diff --git a/src/enc/iterator.c b/src/enc/iterator.c index 86e473bc..07466590 100644 --- a/src/enc/iterator.c +++ b/src/enc/iterator.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // VP8Iterator: block iterator diff --git a/src/enc/layer.c b/src/enc/layer.c index 423127df..fa896609 100644 --- a/src/enc/layer.c +++ b/src/enc/layer.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Enhancement layer (for YUV444/422) diff --git a/src/enc/picture.c b/src/enc/picture.c index e9f78e1e..4176240e 100644 --- a/src/enc/picture.c +++ b/src/enc/picture.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // WebPPicture utils: colorspace conversion, crop, ... diff --git a/src/enc/quant.c b/src/enc/quant.c index dcfd4d16..462d4e9e 100644 --- a/src/enc/quant.c +++ b/src/enc/quant.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Quantization diff --git a/src/enc/syntax.c b/src/enc/syntax.c index e81fa2be..b0f7676b 100644 --- a/src/enc/syntax.c +++ b/src/enc/syntax.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Header syntax writing diff --git a/src/enc/token.c b/src/enc/token.c index 4e2f6c00..6a63371f 100644 --- a/src/enc/token.c +++ b/src/enc/token.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Paginated token buffer diff --git a/src/enc/tree.c b/src/enc/tree.c index 8b25e5e4..ecd8fb91 100644 --- a/src/enc/tree.c +++ b/src/enc/tree.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Token probabilities diff --git a/src/enc/vp8enci.h b/src/enc/vp8enci.h index 6aa3f436..66c89394 100644 --- a/src/enc/vp8enci.h +++ b/src/enc/vp8enci.h @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // WebP encoder: internal header. diff --git a/src/enc/vp8l.c b/src/enc/vp8l.c index 6422c544..945870ca 100644 --- a/src/enc/vp8l.c +++ b/src/enc/vp8l.c @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // main entry for the lossless encoder. diff --git a/src/enc/vp8li.h b/src/enc/vp8li.h index eae90dd6..01f01f57 100644 --- a/src/enc/vp8li.h +++ b/src/enc/vp8li.h @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Lossless encoder: internal header. diff --git a/src/enc/webpenc.c b/src/enc/webpenc.c index 93d34dae..d420d063 100644 --- a/src/enc/webpenc.c +++ b/src/enc/webpenc.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // WebP encoder: main entry point diff --git a/src/mux/muxedit.c b/src/mux/muxedit.c index a486229c..67fc7095 100644 --- a/src/mux/muxedit.c +++ b/src/mux/muxedit.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Set and delete APIs for mux. diff --git a/src/mux/muxi.h b/src/mux/muxi.h index 97b7f43d..d670bb00 100644 --- a/src/mux/muxi.h +++ b/src/mux/muxi.h @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Internal header for mux library. diff --git a/src/mux/muxinternal.c b/src/mux/muxinternal.c index 3fa91f7d..9543c0ee 100644 --- a/src/mux/muxinternal.c +++ b/src/mux/muxinternal.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Internal objects and utils for mux. diff --git a/src/mux/muxread.c b/src/mux/muxread.c index 0e074fb2..2179ccb7 100644 --- a/src/mux/muxread.c +++ b/src/mux/muxread.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Read APIs for mux. diff --git a/src/utils/bit_reader.c b/src/utils/bit_reader.c index d6cfd864..ab7a8273 100644 --- a/src/utils/bit_reader.c +++ b/src/utils/bit_reader.c @@ -1,8 +1,10 @@ // Copyright 2010 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Boolean decoder diff --git a/src/utils/bit_reader.h b/src/utils/bit_reader.h index 7c5b3b1f..588222b3 100644 --- a/src/utils/bit_reader.h +++ b/src/utils/bit_reader.h @@ -1,8 +1,10 @@ // Copyright 2010 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Boolean decoder diff --git a/src/utils/bit_writer.c b/src/utils/bit_writer.c index 671159ca..3827a13a 100644 --- a/src/utils/bit_writer.c +++ b/src/utils/bit_writer.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Bit writing and boolean coder diff --git a/src/utils/bit_writer.h b/src/utils/bit_writer.h index f7ca0849..cbb095c1 100644 --- a/src/utils/bit_writer.h +++ b/src/utils/bit_writer.h @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Bit writing and boolean coder diff --git a/src/utils/color_cache.c b/src/utils/color_cache.c index 560f81db..749db612 100644 --- a/src/utils/color_cache.c +++ b/src/utils/color_cache.c @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Color Cache for WebP Lossless diff --git a/src/utils/color_cache.h b/src/utils/color_cache.h index 13be629f..e5a0bd6f 100644 --- a/src/utils/color_cache.h +++ b/src/utils/color_cache.h @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Color Cache for WebP Lossless diff --git a/src/utils/filters.c b/src/utils/filters.c index ad847746..eb5bb34f 100644 --- a/src/utils/filters.c +++ b/src/utils/filters.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Spatial prediction using various filters diff --git a/src/utils/filters.h b/src/utils/filters.h index 89825232..1f5fa164 100644 --- a/src/utils/filters.h +++ b/src/utils/filters.h @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Spatial prediction using various filters diff --git a/src/utils/huffman.c b/src/utils/huffman.c index 41529cc9..0ba9d05c 100644 --- a/src/utils/huffman.c +++ b/src/utils/huffman.c @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Utilities for building and looking up Huffman trees. diff --git a/src/utils/huffman.h b/src/utils/huffman.h index 70220a67..83a517ee 100644 --- a/src/utils/huffman.h +++ b/src/utils/huffman.h @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Utilities for building and looking up Huffman trees. diff --git a/src/utils/huffman_encode.c b/src/utils/huffman_encode.c index 2d680e3e..96086663 100644 --- a/src/utils/huffman_encode.c +++ b/src/utils/huffman_encode.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Author: Jyrki Alakuijala (jyrki@google.com) diff --git a/src/utils/huffman_encode.h b/src/utils/huffman_encode.h index cc3b38d3..0b81f470 100644 --- a/src/utils/huffman_encode.h +++ b/src/utils/huffman_encode.h @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Author: Jyrki Alakuijala (jyrki@google.com) diff --git a/src/utils/quant_levels.c b/src/utils/quant_levels.c index 649aae65..42c7245d 100644 --- a/src/utils/quant_levels.c +++ b/src/utils/quant_levels.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Quantize levels for specified number of quantization-levels ([2, 256]). diff --git a/src/utils/quant_levels.h b/src/utils/quant_levels.h index 9f85f34b..2d90828d 100644 --- a/src/utils/quant_levels.h +++ b/src/utils/quant_levels.h @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Alpha plane quantization utility diff --git a/src/utils/quant_levels_dec.c b/src/utils/quant_levels_dec.c index 95142b1b..d93594b3 100644 --- a/src/utils/quant_levels_dec.c +++ b/src/utils/quant_levels_dec.c @@ -1,8 +1,10 @@ // Copyright 2013 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // TODO(skal): implement gradient smoothing. diff --git a/src/utils/quant_levels_dec.h b/src/utils/quant_levels_dec.h index 470cf479..58910676 100644 --- a/src/utils/quant_levels_dec.h +++ b/src/utils/quant_levels_dec.h @@ -1,8 +1,10 @@ // Copyright 2013 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Alpha plane de-quantization utility diff --git a/src/utils/rescaler.c b/src/utils/rescaler.c index 61530cfe..e5ddc296 100644 --- a/src/utils/rescaler.c +++ b/src/utils/rescaler.c @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Rescaling functions diff --git a/src/utils/rescaler.h b/src/utils/rescaler.h index ef93d465..aedce462 100644 --- a/src/utils/rescaler.h +++ b/src/utils/rescaler.h @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Rescaling functions diff --git a/src/utils/thread.c b/src/utils/thread.c index a14af559..b1615d0f 100644 --- a/src/utils/thread.c +++ b/src/utils/thread.c @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Multi-threaded worker diff --git a/src/utils/thread.h b/src/utils/thread.h index 9afe0967..13a61a4c 100644 --- a/src/utils/thread.h +++ b/src/utils/thread.h @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Multi-threaded worker diff --git a/src/utils/utils.c b/src/utils/utils.c index b1db2f9d..7eb06105 100644 --- a/src/utils/utils.c +++ b/src/utils/utils.c @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Misc. common utility functions diff --git a/src/utils/utils.h b/src/utils/utils.h index e5d6d630..e10aeeb9 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Misc. common utility functions diff --git a/src/webp/decode.h b/src/webp/decode.h index fc2a83ab..141f8618 100644 --- a/src/webp/decode.h +++ b/src/webp/decode.h @@ -1,8 +1,10 @@ // Copyright 2010 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Main decoding functions for WebP images. diff --git a/src/webp/demux.h b/src/webp/demux.h index 2006b94f..c7cd5d66 100644 --- a/src/webp/demux.h +++ b/src/webp/demux.h @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Demux API. diff --git a/src/webp/encode.h b/src/webp/encode.h index 628b8887..317be872 100644 --- a/src/webp/encode.h +++ b/src/webp/encode.h @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // WebP encoder: main interface diff --git a/src/webp/format_constants.h b/src/webp/format_constants.h index a6f76d8d..4c04b50c 100644 --- a/src/webp/format_constants.h +++ b/src/webp/format_constants.h @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Internal header for constants related to WebP file format. diff --git a/src/webp/mux.h b/src/webp/mux.h index f869a2dc..b8c7dc62 100644 --- a/src/webp/mux.h +++ b/src/webp/mux.h @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // RIFF container manipulation for WEBP images. diff --git a/src/webp/mux_types.h b/src/webp/mux_types.h index 7bad0004..b8bce363 100644 --- a/src/webp/mux_types.h +++ b/src/webp/mux_types.h @@ -1,8 +1,10 @@ // Copyright 2012 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Data-types common to the mux and demux libraries. diff --git a/src/webp/types.h b/src/webp/types.h index 3e27190b..568d1f26 100644 --- a/src/webp/types.h +++ b/src/webp/types.h @@ -1,8 +1,10 @@ // Copyright 2010 Google Inc. All Rights Reserved. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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. // ----------------------------------------------------------------------------- // // Common types diff --git a/swig/libwebp.i b/swig/libwebp.i index 5e887184..d9c41b09 100644 --- a/swig/libwebp.i +++ b/swig/libwebp.i @@ -1,8 +1,10 @@ // Copyright 2011 Google Inc. // -// This code is licensed under the same terms as WebM: -// Software License Agreement: http://www.webmproject.org/license/software/ -// Additional IP Rights Grant: http://www.webmproject.org/license/additional/ +// 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 From a2aed1d08c1f17be6165173c0e38f633ea37c4dd Mon Sep 17 00:00:00 2001 From: James Zern Date: Fri, 7 Jun 2013 20:02:44 -0700 Subject: [PATCH 47/57] configure: improve gl/glut library test add a check for a libGL function (glOrtho) in addition to glutMainLoop when establishing the need for libGL at link time. fixes vwebp link failure on ubuntu 13.04+ Change-Id: I537e9a5cab5cf4cd8875e06268d2107f377e625e (cherry picked from commit 2ccf58d64810fcdf0ee42a9d53fa7034ffa62597) --- configure.ac | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index d6378d03..2d9cb37e 100644 --- a/configure.ac +++ b/configure.ac @@ -170,18 +170,31 @@ if test "$glut_headers" = "yes"; then LIBS="$GL_SAVED_LIBS" # A direct link to libGL may not be necessary on e.g., linux. - for lib in "" $ac_cv_search_glBegin; do - unset ac_cv_search_glutMainLoop - AC_SEARCH_LIBS([glutMainLoop], [glut], [glut_support=yes], [], [$lib]) + GLUT_SAVED_LIBS="$LIBS" + for lib in "" "-lglut" "-lglut $ac_cv_search_glBegin"; do + LIBS="$lib" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([ + #ifdef __cplusplus + # define EXTERN_C extern "C" + #else + # define EXTERN_C + #endif + EXTERN_C char glOrtho(); + EXTERN_C char glutMainLoop(); + ],[ + glOrtho(); + glutMainLoop(); + ]) + ], + [glut_support=yes], [] + ) if test "$glut_support" = "yes"; then - GL_LIBS="$LDFLAGS" - if test "$ac_cv_search_glutMainLoop" != "none required"; then - GL_LIBS="$GL_LIBS $ac_cv_search_glutMainLoop" - fi - GL_LIBS="$GL_LIBS $lib" + GL_LIBS="$LDFLAGS $lib" break fi done + LIBS="$GLUT_SAVED_LIBS" LDFLAGS="$GLUT_SAVED_LDFLAGS" test "$glut_support" = "yes" && break done From f32097e0df8aa256fc360d3d8d8a0996e039515d Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Mon, 10 Jun 2013 05:46:22 -0700 Subject: [PATCH 48/57] probe input file and quick-check for WebP format. Error message is clearer that 'can't create demux object'. Change-Id: Iec008601892f7cd8399e1948751747ac23305eef (cherry picked from commit 830f72b7e988ae0650435f7a285d12e098d7e6ae) --- examples/vwebp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/vwebp.c b/examples/vwebp.c index df389a61..f13b88fc 100644 --- a/examples/vwebp.c +++ b/examples/vwebp.c @@ -436,6 +436,11 @@ int main(int argc, char *argv[]) { goto Error; } + if (!WebPGetInfo(kParams.data.bytes, kParams.data.size, NULL, NULL)) { + fprintf(stderr, "Input file doesn't appear to be WebP format.\n"); + goto Error; + } + kParams.dmux = WebPDemux(&kParams.data); if (kParams.dmux == NULL) { fprintf(stderr, "Could not create demuxing object!\n"); From 38cc011408915c9743d822c323bc181fbad239e8 Mon Sep 17 00:00:00 2001 From: skal Date: Fri, 26 Apr 2013 08:55:31 +0200 Subject: [PATCH 49/57] Simplify forward-WHT + SSE2 version no precision loss observed speed is not really faster (0.5% at max), as forward-WHT isn't called often. also: replaced a "int << 3" (undefined by C-spec) by a "int * 8" ( supersedes https://gerrit.chromium.org/gerrit/#/c/48739/ ) Change-Id: I2d980ec2f20f4ff6be5636105ff4f1c70ffde401 (cherry picked from commit 9c4ce971a8dc8a606ada99c068795f4e33fdbf50) --- src/dsp/enc.c | 29 +++++++++++++++-------------- src/dsp/enc_neon.c | 42 +++++++++--------------------------------- src/dsp/enc_sse2.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 47 deletions(-) diff --git a/src/dsp/enc.c b/src/dsp/enc.c index 00ee80c9..552807ad 100644 --- a/src/dsp/enc.c +++ b/src/dsp/enc.c @@ -144,9 +144,9 @@ static void FTransform(const uint8_t* src, const uint8_t* ref, int16_t* out) { const int a1 = (d1 + d2); const int a2 = (d1 - d2); const int a3 = (d0 - d3); - tmp[0 + i * 4] = (a0 + a1) << 3; // 14b [-8160,8160] + tmp[0 + i * 4] = (a0 + a1) * 8; // 14b [-8160,8160] tmp[1 + i * 4] = (a2 * 2217 + a3 * 5352 + 1812) >> 9; // [-7536,7542] - tmp[2 + i * 4] = (a0 - a1) << 3; + tmp[2 + i * 4] = (a0 - a1) * 8; tmp[3 + i * 4] = (a3 * 2217 - a2 * 5352 + 937) >> 9; } for (i = 0; i < 4; ++i) { @@ -189,31 +189,32 @@ static void ITransformWHT(const int16_t* in, int16_t* out) { } static void FTransformWHT(const int16_t* in, int16_t* out) { - int tmp[16]; + // input is 12b signed + int16_t tmp[16]; int i; for (i = 0; i < 4; ++i, in += 64) { - const int a0 = (in[0 * 16] + in[2 * 16]) << 2; - const int a1 = (in[1 * 16] + in[3 * 16]) << 2; - const int a2 = (in[1 * 16] - in[3 * 16]) << 2; - const int a3 = (in[0 * 16] - in[2 * 16]) << 2; - tmp[0 + i * 4] = (a0 + a1) + (a0 != 0); + const int a0 = (in[0 * 16] + in[2 * 16]); // 13b + const int a1 = (in[1 * 16] + in[3 * 16]); + const int a2 = (in[1 * 16] - in[3 * 16]); + const int a3 = (in[0 * 16] - in[2 * 16]); + tmp[0 + i * 4] = a0 + a1; // 14b tmp[1 + i * 4] = a3 + a2; tmp[2 + i * 4] = a3 - a2; tmp[3 + i * 4] = a0 - a1; } for (i = 0; i < 4; ++i) { - const int a0 = (tmp[0 + i] + tmp[8 + i]); + const int a0 = (tmp[0 + i] + tmp[8 + i]); // 15b const int a1 = (tmp[4 + i] + tmp[12+ i]); const int a2 = (tmp[4 + i] - tmp[12+ i]); const int a3 = (tmp[0 + i] - tmp[8 + i]); - const int b0 = a0 + a1; + const int b0 = a0 + a1; // 16b const int b1 = a3 + a2; const int b2 = a3 - a2; const int b3 = a0 - a1; - out[ 0 + i] = (b0 + (b0 > 0) + 3) >> 3; - out[ 4 + i] = (b1 + (b1 > 0) + 3) >> 3; - out[ 8 + i] = (b2 + (b2 > 0) + 3) >> 3; - out[12 + i] = (b3 + (b3 > 0) + 3) >> 3; + out[ 0 + i] = b0 >> 1; // 15b + out[ 4 + i] = b1 >> 1; + out[ 8 + i] = b2 >> 1; + out[12 + i] = b3 >> 1; } } diff --git a/src/dsp/enc_neon.c b/src/dsp/enc_neon.c index 6239a766..eb256e68 100644 --- a/src/dsp/enc_neon.c +++ b/src/dsp/enc_neon.c @@ -365,19 +365,12 @@ static void FTransformWHT(const int16_t* in, int16_t* out) { "vld1.16 d2[3], [%[in]], %[kStep] \n" "vld1.16 d3[3], [%[in]], %[kStep] \n" - "vaddl.s16 q2, d0, d2 \n" - "vshl.s32 q2, q2, #2 \n" // a0=(in[0*16]+in[2*16])<<2 - "vaddl.s16 q3, d1, d3 \n" - "vshl.s32 q3, q3, #2 \n" // a1=(in[1*16]+in[3*16])<<2 - "vsubl.s16 q4, d1, d3 \n" - "vshl.s32 q4, q4, #2 \n" // a2=(in[1*16]-in[3*16])<<2 - "vsubl.s16 q5, d0, d2 \n" - "vshl.s32 q5, q5, #2 \n" // a3=(in[0*16]-in[2*16])<<2 + "vaddl.s16 q2, d0, d2 \n" // a0=(in[0*16]+in[2*16]) + "vaddl.s16 q3, d1, d3 \n" // a1=(in[1*16]+in[3*16]) + "vsubl.s16 q4, d1, d3 \n" // a2=(in[1*16]-in[3*16]) + "vsubl.s16 q5, d0, d2 \n" // a3=(in[0*16]-in[2*16]) - "vceq.s32 q10, q2, #0 \n" - "vmvn.s32 q10, q10 \n" // (a0 != 0) - "vqadd.s32 q6, q2, q3 \n" // (a0 + a1) - "vqsub.s32 q6, q6, q10 \n" // (a0 + a1) + (a0 != 0) + "vqadd.s32 q6, q2, q3 \n" // a0 + a1 "vqadd.s32 q7, q5, q4 \n" // a3 + a2 "vqsub.s32 q8, q5, q4 \n" // a3 - a2 "vqsub.s32 q9, q2, q3 \n" // a0 - a1 @@ -400,27 +393,10 @@ static void FTransformWHT(const int16_t* in, int16_t* out) { "vqsub.s32 q6, q3, q2 \n" // b2 = a3 - a2 "vqsub.s32 q7, q0, q1 \n" // b3 = a0 - a1 - "vmov.s32 q0, #3 \n" // q0 = 3 - - "vcgt.s32 q1, q4, #0 \n" // (b0>0) - "vqsub.s32 q2, q4, q1 \n" // (b0+(b0>0)) - "vqadd.s32 q3, q2, q0 \n" // (b0+(b0>0)+3) - "vshrn.s32 d18, q3, #3 \n" // (b0+(b0>0)+3) >> 3 - - "vcgt.s32 q1, q5, #0 \n" // (b1>0) - "vqsub.s32 q2, q5, q1 \n" // (b1+(b1>0)) - "vqadd.s32 q3, q2, q0 \n" // (b1+(b1>0)+3) - "vshrn.s32 d19, q3, #3 \n" // (b1+(b1>0)+3) >> 3 - - "vcgt.s32 q1, q6, #0 \n" // (b2>0) - "vqsub.s32 q2, q6, q1 \n" // (b2+(b2>0)) - "vqadd.s32 q3, q2, q0 \n" // (b2+(b2>0)+3) - "vshrn.s32 d20, q3, #3 \n" // (b2+(b2>0)+3) >> 3 - - "vcgt.s32 q1, q7, #0 \n" // (b3>0) - "vqsub.s32 q2, q7, q1 \n" // (b3+(b3>0)) - "vqadd.s32 q3, q2, q0 \n" // (b3+(b3>0)+3) - "vshrn.s32 d21, q3, #3 \n" // (b3+(b3>0)+3) >> 3 + "vshrn.s32 d18, q4, #1 \n" // b0 >> 1 + "vshrn.s32 d19, q5, #1 \n" // b1 >> 1 + "vshrn.s32 d20, q6, #1 \n" // b2 >> 1 + "vshrn.s32 d21, q7, #1 \n" // b3 >> 1 "vst1.16 {q9, q10}, [%[out]] \n" diff --git a/src/dsp/enc_sse2.c b/src/dsp/enc_sse2.c index bb0b2a29..032e9907 100644 --- a/src/dsp/enc_sse2.c +++ b/src/dsp/enc_sse2.c @@ -455,6 +455,39 @@ static void FTransformSSE2(const uint8_t* src, const uint8_t* ref, } } +static void FTransformWHTSSE2(const int16_t* in, int16_t* out) { + int16_t tmp[16]; + int i; + for (i = 0; i < 4; ++i, in += 64) { + const int a0 = (in[0 * 16] + in[2 * 16]); + const int a1 = (in[1 * 16] + in[3 * 16]); + const int a2 = (in[1 * 16] - in[3 * 16]); + const int a3 = (in[0 * 16] - in[2 * 16]); + tmp[0 + i * 4] = a0 + a1; + tmp[1 + i * 4] = a3 + a2; + tmp[2 + i * 4] = a3 - a2; + tmp[3 + i * 4] = a0 - a1; + } + { + const __m128i src0 = _mm_loadl_epi64((__m128i*)&tmp[0]); + const __m128i src1 = _mm_loadl_epi64((__m128i*)&tmp[4]); + const __m128i src2 = _mm_loadl_epi64((__m128i*)&tmp[8]); + const __m128i src3 = _mm_loadl_epi64((__m128i*)&tmp[12]); + const __m128i a0 = _mm_add_epi16(src0, src2); + const __m128i a1 = _mm_add_epi16(src1, src3); + const __m128i a2 = _mm_sub_epi16(src1, src3); + const __m128i a3 = _mm_sub_epi16(src0, src2); + const __m128i b0 = _mm_srai_epi16(_mm_adds_epi16(a0, a1), 1); + const __m128i b1 = _mm_srai_epi16(_mm_adds_epi16(a3, a2), 1); + const __m128i b2 = _mm_srai_epi16(_mm_subs_epi16(a3, a2), 1); + const __m128i b3 = _mm_srai_epi16(_mm_subs_epi16(a0, a1), 1); + _mm_storel_epi64((__m128i*)&out[ 0], b0); + _mm_storel_epi64((__m128i*)&out[ 4], b1); + _mm_storel_epi64((__m128i*)&out[ 8], b2); + _mm_storel_epi64((__m128i*)&out[12], b3); + } +} + //------------------------------------------------------------------------------ // Metric @@ -921,6 +954,7 @@ void VP8EncDspInitSSE2(void) { VP8EncQuantizeBlock = QuantizeBlockSSE2; VP8ITransform = ITransformSSE2; VP8FTransform = FTransformSSE2; + VP8FTransformWHT = FTransformWHTSSE2; VP8SSE16x16 = SSE16x16SSE2; VP8SSE16x8 = SSE16x8SSE2; VP8SSE8x8 = SSE8x8SSE2; From 67bc353e6d5ef9f4e2ae059d36189b256cad2c5d Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 12 Jun 2013 14:43:27 -0700 Subject: [PATCH 50/57] Revert "add WebPBlendAlpha() function to blend colors against background" This reverts commit dcbb1ca54aae57fadd220b269cd4907f89085ca4. Dropping this for now to maintain compatibility for 0.3.1. Change-Id: I44e032a072d317bb67e1439c42cff923e603038f --- README | 4 -- examples/cwebp.c | 16 +------- examples/pngdec.c | 1 - examples/tiffdec.c | 1 - examples/wicdec.c | 1 - man/cwebp.1 | 7 +--- src/enc/picture.c | 92 ++-------------------------------------------- src/webp/encode.h | 5 --- 8 files changed, 6 insertions(+), 121 deletions(-) diff --git a/README b/README index 2aeca088..0d0476c1 100644 --- a/README +++ b/README @@ -178,10 +178,6 @@ options: -alpha_filter . predictive filtering for alpha plane. One of: none, fast (default) or best. -alpha_cleanup ......... Clean RGB values in transparent area. - -blend_alpha ..... Blend colors against background color - expressed as RGB values written in - hexadecimal, e.g. 0xc0e0d0 for red=0xc0 - green=0xe0 and blue=0xd0. -noalpha ............... discard any transparency information. -lossless .............. Encode image losslessly. -hint ......... Specify image characteristics hint. diff --git a/examples/cwebp.c b/examples/cwebp.c index efdeccfe..c87720c1 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -596,10 +596,6 @@ static void HelpLong(void) { printf(" -alpha_filter . predictive filtering for alpha plane.\n"); printf(" One of: none, fast (default) or best.\n"); printf(" -alpha_cleanup ......... Clean RGB values in transparent area.\n"); - printf(" -blend_alpha ..... Blend colors against background color\n" - " expressed as RGB values written in\n" - " hexadecimal, e.g. 0xc0e0d0 for red=0xc0\n" - " green=0xe0 and blue=0xd0.\n"); printf(" -noalpha ............... discard any transparency information.\n"); printf(" -lossless .............. Encode image losslessly.\n"); printf(" -hint ......... Specify image characteristics hint.\n"); @@ -662,8 +658,6 @@ int main(int argc, const char *argv[]) { int short_output = 0; int quiet = 0; int keep_alpha = 1; - int blend_alpha = 0; - uint32_t background_color = 0xffffffu; int crop = 0, crop_x = 0, crop_y = 0, crop_w = 0, crop_h = 0; int resize_w = 0, resize_h = 0; int show_progress = 0; @@ -728,10 +722,6 @@ int main(int argc, const char *argv[]) { config.alpha_compression = strtol(argv[++c], NULL, 0); } else if (!strcmp(argv[c], "-alpha_cleanup")) { keep_alpha = keep_alpha ? 2 : 0; - } else if (!strcmp(argv[c], "-blend_alpha") && c < argc - 1) { - blend_alpha = 1; - background_color = strtol(argv[++c], NULL, 16); // <- parses '0x' prefix - background_color = background_color & 0x00ffffffu; } else if (!strcmp(argv[c], "-alpha_filter") && c < argc - 1) { ++c; if (!strcmp(argv[c], "none")) { @@ -748,6 +738,7 @@ int main(int argc, const char *argv[]) { keep_alpha = 0; } else if (!strcmp(argv[c], "-lossless")) { config.lossless = 1; + picture.use_argb = 1; } else if (!strcmp(argv[c], "-hint") && c < argc - 1) { ++c; if (!strcmp(argv[c], "photo")) { @@ -935,11 +926,6 @@ int main(int argc, const char *argv[]) { goto Error; } picture.progress_hook = (show_progress && !quiet) ? ProgressReport : NULL; - - if (blend_alpha) { - WebPBlendAlpha(&picture, background_color); - } - if (keep_alpha == 2) { WebPCleanupTransparentArea(&picture); } diff --git a/examples/pngdec.c b/examples/pngdec.c index 814a4774..f0c965f0 100644 --- a/examples/pngdec.c +++ b/examples/pngdec.c @@ -270,7 +270,6 @@ int ReadPNG(FILE* in_file, WebPPicture* const pic, int keep_alpha, pic->width = width; pic->height = height; - pic->use_argb = 1; ok = has_alpha ? WebPPictureImportRGBA(pic, rgb, stride) : WebPPictureImportRGB(pic, rgb, stride); diff --git a/examples/tiffdec.c b/examples/tiffdec.c index 8fc61740..3a3f59e2 100644 --- a/examples/tiffdec.c +++ b/examples/tiffdec.c @@ -100,7 +100,6 @@ int ReadTIFF(const char* const filename, #ifdef __BIG_ENDIAN__ TIFFSwabArrayOfLong(raster, width * height); #endif - pic->use_argb = 1; ok = keep_alpha ? WebPPictureImportRGBA(pic, (const uint8_t*)raster, stride) : WebPPictureImportRGBX(pic, (const uint8_t*)raster, stride); diff --git a/examples/wicdec.c b/examples/wicdec.c index 909deaeb..2902520f 100644 --- a/examples/wicdec.c +++ b/examples/wicdec.c @@ -308,7 +308,6 @@ int ReadPictureWithWIC(const char* const filename, int ok; pic->width = width; pic->height = height; - pic->use_argb = 1; ok = importer->import(pic, rgb, stride); if (!ok) hr = E_FAIL; } diff --git a/man/cwebp.1 b/man/cwebp.1 index 9c3c7338..2e5dbb08 100644 --- a/man/cwebp.1 +++ b/man/cwebp.1 @@ -1,5 +1,5 @@ .\" Hey, EMACS: -*- nroff -*- -.TH CWEBP 1 "March 28, 2013" +.TH CWEBP 1 "March 13, 2013" .SH NAME cwebp \- compress an image file to a WebP file .SH SYNOPSIS @@ -187,11 +187,6 @@ no compression, 1 uses WebP lossless format for compression. The default is 1. Modify unseen RGB values under fully transparent area, to help compressibility. The default is off. .TP -.BI \-blend_alpha " int -This option blends the alpha channel (if present) with the source using the -background color specified in hexadecimal as 0xrrggbb. The alpha channel is -afterward reset to the opaque value 255. -.TP .B \-noalpha Using this option will discard the alpha channel. .TP diff --git a/src/enc/picture.c b/src/enc/picture.c index 4176240e..5aaa385d 100644 --- a/src/enc/picture.c +++ b/src/enc/picture.c @@ -34,10 +34,6 @@ static const union { } test_endian = { 0xff000000u }; #define ALPHA_IS_LAST (test_endian.bytes[3] == 0xff) -static WEBP_INLINE uint32_t MakeARGB32(int r, int g, int b) { - return (0xff000000u | (r << 16) | (g << 8) | b); -} - //------------------------------------------------------------------------------ // WebPPicture //------------------------------------------------------------------------------ @@ -702,7 +698,10 @@ static int Import(WebPPicture* const picture, for (x = 0; x < width; ++x) { const int offset = step * x + y * rgb_stride; const uint32_t argb = - MakeARGB32(r_ptr[offset], g_ptr[offset], b_ptr[offset]); + 0xff000000u | + (r_ptr[offset] << 16) | + (g_ptr[offset] << 8) | + (b_ptr[offset]); picture->argb[x + y * picture->argb_stride] = argb; } } @@ -913,89 +912,6 @@ void WebPCleanupTransparentArea(WebPPicture* pic) { #undef SIZE #undef SIZE2 -//------------------------------------------------------------------------------ -// Blend color and remove transparency info - -#define BLEND(V0, V1, ALPHA) \ - ((((V0) * (255 - (ALPHA)) + (V1) * (ALPHA)) * 0x101) >> 16) -#define BLEND_10BIT(V0, V1, ALPHA) \ - ((((V0) * (1020 - (ALPHA)) + (V1) * (ALPHA)) * 0x101) >> 18) - -void WebPBlendAlpha(WebPPicture* pic, uint32_t background_rgb) { - const int red = (background_rgb >> 16) & 0xff; - const int green = (background_rgb >> 8) & 0xff; - const int blue = (background_rgb >> 0) & 0xff; - int x, y; - if (pic == NULL) return; - if (!pic->use_argb) { - const int uv_width = (pic->width >> 1); // omit last pixel during u/v loop - const int Y0 = VP8RGBToY(red, green, blue); - // VP8RGBToU/V expects the u/v values summed over four pixels - const int U0 = VP8RGBToU(4 * red, 4 * green, 4 * blue); - const int V0 = VP8RGBToV(4 * red, 4 * green, 4 * blue); - const int has_alpha = pic->colorspace & WEBP_CSP_ALPHA_BIT; - if (!has_alpha || pic->a == NULL) return; // nothing to do - for (y = 0; y < pic->height; ++y) { - // Luma blending - uint8_t* const y_ptr = pic->y + y * pic->y_stride; - uint8_t* const a_ptr = pic->a + y * pic->a_stride; - for (x = 0; x < pic->width; ++x) { - const int alpha = a_ptr[x]; - if (alpha < 0xff) { - y_ptr[x] = BLEND(Y0, y_ptr[x], a_ptr[x]); - } - } - // Chroma blending every even line - if ((y & 1) == 0) { - uint8_t* const u = pic->u + (y >> 1) * pic->uv_stride; - uint8_t* const v = pic->v + (y >> 1) * pic->uv_stride; - uint8_t* const a_ptr2 = - (y + 1 == pic->height) ? a_ptr : a_ptr + pic->a_stride; - for (x = 0; x < uv_width; ++x) { - // Average four alpha values into a single blending weight. - // TODO(skal): might lead to visible contouring. Can we do better? - const int alpha = - a_ptr[2 * x + 0] + a_ptr[2 * x + 1] + - a_ptr2[2 * x + 0] + a_ptr2[2 * x + 1]; - u[x] = BLEND_10BIT(U0, u[x], alpha); - v[x] = BLEND_10BIT(V0, v[x], alpha); - } - if (pic->width & 1) { // rightmost pixel - const int alpha = 2 * (a_ptr[2 * x + 0] + a_ptr2[2 * x + 0]); - u[x] = BLEND_10BIT(U0, u[x], alpha); - v[x] = BLEND_10BIT(V0, v[x], alpha); - } - } - memset(a_ptr, 0xff, pic->width); - } - } else { - uint32_t* argb = pic->argb; - const uint32_t background = MakeARGB32(red, green, blue); - for (y = 0; y < pic->height; ++y) { - for (x = 0; x < pic->width; ++x) { - const int alpha = (argb[x] >> 24) & 0xff; - if (alpha != 0xff) { - if (alpha > 0) { - int r = (argb[x] >> 16) & 0xff; - int g = (argb[x] >> 8) & 0xff; - int b = (argb[x] >> 0) & 0xff; - r = BLEND(red, r, alpha); - g = BLEND(green, g, alpha); - b = BLEND(blue, b, alpha); - argb[x] = MakeARGB32(r, g, b); - } else { - argb[x] = background; - } - } - } - argb += pic->argb_stride; - } - } -} - -#undef BLEND -#undef BLEND_10BIT - //------------------------------------------------------------------------------ // local-min distortion // diff --git a/src/webp/encode.h b/src/webp/encode.h index 317be872..726992f5 100644 --- a/src/webp/encode.h +++ b/src/webp/encode.h @@ -461,11 +461,6 @@ WEBP_EXTERN(void) WebPCleanupTransparentArea(WebPPicture* picture); // alpha plane can be ignored altogether e.g.). WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* picture); -// Remove the transparency information (if present) by blending the color with -// the background color 'background_rgb' (specified as 24bit RGB triplet). -// After this call, all alpha values are reset to 0xff. -WEBP_EXTERN(void) WebPBlendAlpha(WebPPicture* pic, uint32_t background_rgb); - //------------------------------------------------------------------------------ // Main call From 5a92c1a5e99fbc87a48a7694979fd518e8e98037 Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 12 Jun 2013 14:58:32 -0700 Subject: [PATCH 51/57] bump version to 0.3.1 libwebp{,decoder} - 0.3.1 libwebp libtool - 4.3.0 (compatible release) libwebpdecoder libtool - 0.1.0 (compatible release) mux/demux - 0.1.1 libtool - 0.1.0 (compatible release) Change-Id: Icc8329a6bcd9eea5a715ea83f1535a66d6ba4b58 --- README | 2 +- README.mux | 2 +- configure.ac | 2 +- src/Makefile.am | 4 ++-- src/dec/vp8i.h | 2 +- src/demux/Makefile.am | 2 +- src/demux/demux.c | 2 +- src/enc/vp8enci.h | 2 +- src/mux/Makefile.am | 2 +- src/mux/muxi.h | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README b/README index 0d0476c1..d0d95e63 100644 --- a/README +++ b/README @@ -4,7 +4,7 @@ \__\__/\____/\_____/__/ ____ ___ / _/ / \ \ / _ \/ _/ / \_/ / / \ \ __/ \__ - \____/____/\_____/_____/____/v0.3.0 + \____/____/\_____/_____/____/v0.3.1 Description: ============ diff --git a/README.mux b/README.mux index a1491bb9..a5a87d49 100644 --- a/README.mux +++ b/README.mux @@ -1,7 +1,7 @@  __ __ ____ ____ ____ __ __ _ __ __ / \\/ \/ _ \/ _ \/ _ \/ \ \/ \___/_ / _\ \ / __/ _ \ __/ / / (_/ /__ - \__\__/\_____/_____/__/ \__//_/\_____/__/___/v0.1.0 + \__\__/\_____/_____/__/ \__//_/\_____/__/___/v0.1.1 Description: diff --git a/configure.ac b/configure.ac index 2d9cb37e..c31adf88 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([libwebp], [0.3.0], +AC_INIT([libwebp], [0.3.1], [http://code.google.com/p/webp/issues],, [http://developers.google.com/speed/webp]) AC_CANONICAL_TARGET diff --git a/src/Makefile.am b/src/Makefile.am index db289da6..8f3557c0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -36,7 +36,7 @@ libwebp_la_LIBADD += utils/libwebputils.la # other than the ones listed on the command line, i.e., after linking, it will # not have unresolved symbols. Some platforms (Windows among them) require all # symbols in shared libraries to be resolved at library creation. -libwebp_la_LDFLAGS = -no-undefined -version-info 4:2:0 +libwebp_la_LDFLAGS = -no-undefined -version-info 4:3:0 libwebpincludedir = $(includedir)/webp pkgconfig_DATA = libwebp.pc @@ -48,7 +48,7 @@ if BUILD_LIBWEBPDECODER libwebpdecoder_la_LIBADD += dsp/libwebpdspdecode.la libwebpdecoder_la_LIBADD += utils/libwebputilsdecode.la - libwebpdecoder_la_LDFLAGS = -no-undefined -version-info 0:0:0 + libwebpdecoder_la_LDFLAGS = -no-undefined -version-info 0:1:0 pkgconfig_DATA += libwebpdecoder.pc endif diff --git a/src/dec/vp8i.h b/src/dec/vp8i.h index 80532ea4..1d0d4077 100644 --- a/src/dec/vp8i.h +++ b/src/dec/vp8i.h @@ -30,7 +30,7 @@ extern "C" { // version numbers #define DEC_MAJ_VERSION 0 #define DEC_MIN_VERSION 3 -#define DEC_REV_VERSION 0 +#define DEC_REV_VERSION 1 #define ONLY_KEYFRAME_CODE // to remove any code related to P-Frames diff --git a/src/demux/Makefile.am b/src/demux/Makefile.am index d1f126e5..7d4d2285 100644 --- a/src/demux/Makefile.am +++ b/src/demux/Makefile.am @@ -10,6 +10,6 @@ libwebpdemuxinclude_HEADERS += ../webp/mux_types.h libwebpdemuxinclude_HEADERS += ../webp/types.h libwebpdemux_la_LIBADD = ../libwebp.la -libwebpdemux_la_LDFLAGS = -no-undefined -version-info 0:0:0 +libwebpdemux_la_LDFLAGS = -no-undefined -version-info 0:1:0 libwebpdemuxincludedir = $(includedir)/webp pkgconfig_DATA = libwebpdemux.pc diff --git a/src/demux/demux.c b/src/demux/demux.c index 57f6d477..bd17ff7f 100644 --- a/src/demux/demux.c +++ b/src/demux/demux.c @@ -29,7 +29,7 @@ extern "C" { #define DMUX_MAJ_VERSION 0 #define DMUX_MIN_VERSION 1 -#define DMUX_REV_VERSION 0 +#define DMUX_REV_VERSION 1 typedef struct { size_t start_; // start location of the data diff --git a/src/enc/vp8enci.h b/src/enc/vp8enci.h index 66c89394..61d56be5 100644 --- a/src/enc/vp8enci.h +++ b/src/enc/vp8enci.h @@ -30,7 +30,7 @@ extern "C" { // version numbers #define ENC_MAJ_VERSION 0 #define ENC_MIN_VERSION 3 -#define ENC_REV_VERSION 0 +#define ENC_REV_VERSION 1 // intra prediction modes enum { B_DC_PRED = 0, // 4x4 modes diff --git a/src/mux/Makefile.am b/src/mux/Makefile.am index 19b033d3..fa4a5cfe 100644 --- a/src/mux/Makefile.am +++ b/src/mux/Makefile.am @@ -13,6 +13,6 @@ libwebpmuxinclude_HEADERS += ../webp/mux_types.h libwebpmuxinclude_HEADERS += ../webp/types.h libwebpmux_la_LIBADD = ../libwebp.la -libwebpmux_la_LDFLAGS = -no-undefined -version-info 0:0:0 +libwebpmux_la_LDFLAGS = -no-undefined -version-info 0:1:0 libwebpmuxincludedir = $(includedir)/webp pkgconfig_DATA = libwebpmux.pc diff --git a/src/mux/muxi.h b/src/mux/muxi.h index d670bb00..eaed558b 100644 --- a/src/mux/muxi.h +++ b/src/mux/muxi.h @@ -28,7 +28,7 @@ extern "C" { #define MUX_MAJ_VERSION 0 #define MUX_MIN_VERSION 1 -#define MUX_REV_VERSION 0 +#define MUX_REV_VERSION 1 // Chunk object. typedef struct WebPChunk WebPChunk; From abf6f6915f05add62630d8afac716d281706977f Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 12 Jun 2013 16:19:12 -0700 Subject: [PATCH 52/57] update NEWS Change-Id: Ie831ecc6995679acaf238686e2f287bfaa0221a7 --- NEWS | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 3f956e00..aa4aa0f8 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ -- Next version: +- 6/13/13: version 0.3.1 + This is a binary compatible release. * Add incremental decoding support for images containing ALPH and ICCP chunks. + * Python bindings via swig for the simple encode/decode interfaces similar to + Java. - 3/20/13: version 0.3.0 This is a binary compatible release. From 825e73b1a6f277a2bd00c077feb4dde357460e33 Mon Sep 17 00:00:00 2001 From: James Zern Date: Wed, 12 Jun 2013 16:51:28 -0700 Subject: [PATCH 53/57] update ChangeLog Change-Id: I2e67e5d80cb8f8e4453cee45144bcc01e9a3efeb --- ChangeLog | 67 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 60 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index e813034e..972c50db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,56 @@ +abf6f69 update NEWS +5a92c1a bump version to 0.3.1 +67bc353 Revert "add WebPBlendAlpha() function to blend colors against background" +38cc011 Simplify forward-WHT + SSE2 version +f32097e probe input file and quick-check for WebP format. +a2aed1d configure: improve gl/glut library test +c7e89cb update copyright text +a00380d configure: remove use of AS_VAR_APPEND +a94a88d fix EXIF parsing in PNG +a71e5d8 add doc precision for WebPPictureCopy() and WebPPictureView() +8287012 remove datatype qualifier for vmnv +e190843 fix a memory leak in gif2webp +0b18b9e fix two minor memory leaks in webpmux +db5095d remove some cruft from swig/libwebp.jar +850e956 README: update swig notes +bddd9b0 swig/python: add minimal documentation +d573a8d swig: add python encode support +6b93187 swig/java: reduce wrapper function code duplication +6fe536f swig/java: rework uint8_t typemap +a2ea464 Fix the bug in ApplyPalette. +7bb28d2 webp/lossless: fix big endian BGRA output +f036d4b Speed up ApplyPalette for ARGB pixels. +8112c8c remove some warnings: +cc128e0 Further reduce memory to decode lossy+alpha images +07db70d fix for big-endian +eda8a7d gif2webp: Fix signed/unsigned comparison mismatch +31f346f Makefile.vc: fix libwebpdemux dll variable typo +6c76d28 swig: add python (decode) support +b4f5bb6 swig: cosmetics +498d4dd WebP-Lossless encoding improvements. +26e7244 swig: ifdef some Java specific code +8ecec68 configure: add warning related flags +e676b04 configure: add GLUT detection; build vwebp +b0ffc43 Alpha decoding: significantly reduce memory usage +20aa7a8 configure: add --enable-everything +b8307cc configure.ac: add some helper macros +980e7ae Remove the gcc compilation comments +7f25ff9 gif2webp: Fix ICC and XMP support +d8e5321 Add missing name to AUTHORS +11edf5e Demux: Fix a potential memleak +c7b9218 don't forward declare enums +7a650c6 prevent signed int overflow in left shift ops +31bea32 add precision about dynamic output reallocation with IDecoder +c22877f Add incremental support for extended format files +5051245 Makefile.vc: have 'all' target build everything +8191dec Makefile.vc: flags cleanup +b9d7473 Makefile.vc: drop /FD flag +5568dbc update gitignore +f4c7b65 WebPEncode: An additional check. Start VP8EncLoop/VP8EncTokenLoop only if VP8EncStartAlpha succeeded. +1fb04be pngdec: Avoid a double-free. +dcbb1ca add WebPBlendAlpha() function to blend colors against background +bc9f5fb configure.ac: add AM_PROG_AR for automake >= 1.12 +1e0d4b8 Update ChangeLog (tag: v0.3.0-rc7, tag: v0.3.0) d52b405 Cosmetic fixes 6cb4a61 misc style fix 68111ab add missing YUVA->ARGB automatic conversion in WebPEncode() @@ -18,7 +71,7 @@ a5ebd14 gif2webp: Bgcolor fix for a special case 3c8eb9a fix bad saturation order in QuantizeBlock 04c7a2e vwebp/animation: fix background dispose 81a5069 Makefile.vc: fix dynamic builds -5f25c39 update ChangeLog +5f25c39 update ChangeLog (tag: v0.3.0-rc6) 14d42af examples: don't use C99 %zu 5ccf1fe update ChangeLog 2560c24 update NEWS @@ -324,7 +377,7 @@ a61a824 Merge "Add NULL check in chunk APIs" a077072 mux struct naming 6c66dde Merge "Tune Lossless encoder" ab5ea21 Tune Lossless encoder -74fefc8 Update ChangeLog (v0.2.1, origin/0.2.0) +74fefc8 Update ChangeLog (tag: v0.2.1, origin/0.2.0) 92f8059 Rename some chunks: 3bb4bbe Merge "Mux API change:" d0c79f0 Mux API change: @@ -394,7 +447,7 @@ c7eb457 make VP8DspInitNEON() public ab3234a Create WebPMuxFrameInfo struct for Mux APIs e3990fd Alignment fixes e55fbd6 Merge branch '0.2.0' -4238bc0 Update ChangeLog (v0.2.0) +4238bc0 Update ChangeLog (tag: v0.2.0) c655380 dec/io.c: cosmetics fe1958f RGBA4444: harmonize lossless/lossy alpha values 681cb30 fix RGBA4444 output w/fancy upsampling @@ -405,7 +458,7 @@ f56e98f Alignment fix a0a4885 Lossless decoder fix for a special transform order 62dd9bb Update encoding heuristic w.r.t palette colors. 6f4272b remove unused ApplyInverseTransform() -93bf0fa Update ChangeLog (v0.2.0-rc1) +93bf0fa Update ChangeLog (tag: v0.2.0-rc1) 5934fc5 update AUTHORS 014a711 update NEWS 43b0d61 add support for ARGB -> YUVA conversion for lossless decoder @@ -448,7 +501,7 @@ cbee59e Merge commit 'v0.1.99' 3bc3f7c Merge "dwebp: add PAM output support" into 0.2.0 d919ed0 dwebp: add PAM output support 85e215d README/manpages/configure: update website link -c3a207b Update ChangeLog (v0.1.99) +c3a207b Update ChangeLog (tag: v0.1.99) d1fd782 Merge "add extra precision about default values and behaviour" into 0.2.0 efc826e add extra precision about default values and behaviour 9f29635 header/doc clean up @@ -1073,7 +1126,7 @@ f3bf4c7 Added Mux Container Spec & README for MUX-API. 9f761cf Changed function signature for WebPMuxCreate 5f31b5e Merge "Add Mux library for manipulating WebP container." 2315785 Add Mux library for manipulating WebP container. -7e198ab update ChangeLog (v0.1.3) +7e198ab update ChangeLog (tag: v0.1.3) dfc9c1e Harmonize the dates 28ad70c Fix PNG decoding bug 846e93c Update AUTHORS & add .mailmap @@ -1214,7 +1267,7 @@ cfbf88a add SSE2 functions. ~2x faster encoding on average. e7ff3f9 merge two ITransforms together when applicable and change the TTransform to return the sum directly. ca55413 fix WebPIDecGetRGB() to accept any RGB(A) mode, not just MODE_RGB 8aa50ef fix some 'man' typos -d3f3bdd update ChangeLog (v0.1.2) +d3f3bdd update ChangeLog (tag: v0.1.2) d7e9a69 update contributor list 261abb8 add a 'superclean' section 276ae82 Remove files not mean to be in git, and update .gitignore From ad9e42a6fe50c0486bb91631996ea14e1e741080 Mon Sep 17 00:00:00 2001 From: James Zern Date: Fri, 14 Jun 2013 19:01:58 -0700 Subject: [PATCH 54/57] muxedit: silence some uninitialized warnings src/mux/muxedit.c:490: warning: 'x_offset' may be used uninitialized in this function src/mux/muxedit.c:490: warning: 'y_offset' may be used uninitialized in this function Change-Id: I4fd27f717e59a556354d0560b633d0edafe7a4d8 (cherry picked from commit 14cd5c6c401fd769995030c135d07fae56f2ecca) --- src/mux/muxedit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mux/muxedit.c b/src/mux/muxedit.c index 67fc7095..2d25a14d 100644 --- a/src/mux/muxedit.c +++ b/src/mux/muxedit.c @@ -477,7 +477,7 @@ static WebPMuxError GetImageCanvasWidthHeight( int64_t image_area = 0; // Aggregate the bounding box for animation frames & fragmented images. for (; wpi != NULL; wpi = wpi->next_) { - int x_offset, y_offset, duration, w, h; + int x_offset = 0, y_offset = 0, duration = 0, w = 0, h = 0; const WebPMuxError err = GetImageInfo(wpi, &x_offset, &y_offset, &duration, &w, &h); const int max_x_pos = x_offset + w; From 2e377b53b0640552b814d5dab70b55fc371fa6c1 Mon Sep 17 00:00:00 2001 From: James Zern Date: Fri, 14 Jun 2013 18:44:59 -0700 Subject: [PATCH 55/57] wicdec: silence a format warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit from x86_64-w64-mingw32-gcc examples/wicdec.c: In function ‘ExtractICCP’: examples/wicdec.c:131:21: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 4 has type ‘size_t’ [-Wformat] Change-Id: I6642dae62265a2276ae9ac96dd8ce6f1e2d37ca5 (cherry picked from commit ffae9f31e80ed7344987b24b21af831806fa2e69) --- examples/wicdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/wicdec.c b/examples/wicdec.c index 2902520f..61c733c2 100644 --- a/examples/wicdec.c +++ b/examples/wicdec.c @@ -128,7 +128,7 @@ static HRESULT ExtractICCP(IWICImagingFactory* const factory, &size)); if (SUCCEEDED(hr) && size != iccp->size) { fprintf(stderr, "Warning! ICC profile size (%u) != expected (%u)\n", - size, iccp->size); + size, (uint32_t)iccp->size); iccp->size = size; } break; From 7288950b883dd1981e3d0a4f05b301ce6390dac5 Mon Sep 17 00:00:00 2001 From: Urvang Joshi Date: Mon, 17 Jun 2013 03:45:09 -0700 Subject: [PATCH 56/57] Regression fix for alpha channels using color cache: Considering the fact that insert to/lookup from the color cache is always 32 bit, use DecodeImageData() variant in that case. Conflicts: src/dec/vp8l.c Change-Id: I6c665a6cfbd9bd10651c1e82fa54e687cbd54a2b (cherry picked from commit a37eff47d6b6f0a3721a9710235cd894c2982e9b) --- src/dec/vp8l.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/dec/vp8l.c b/src/dec/vp8l.c index 1f618e82..89b5b4bf 100644 --- a/src/dec/vp8l.c +++ b/src/dec/vp8l.c @@ -1142,11 +1142,12 @@ int VP8LDecodeAlphaImageStream(int width, int height, const uint8_t* const data, dec->action_ = READ_HDR; if (!DecodeImageStream(width, height, 1, dec, NULL)) goto Err; - // Special case: if alpha data contains only the color indexing transform - // (a frequent case), we will use DecodeAlphaData() method that only needs - // allocation of 1 byte per pixel (alpha channel). + // Special case: if alpha data uses only the color indexing transform and + // doesn't use color cache (a frequent case), we will use DecodeAlphaData() + // method that only needs allocation of 1 byte per pixel (alpha channel). if (dec->next_transform_ == 1 && - dec->transforms_[0].type_ == COLOR_INDEXING_TRANSFORM) { + dec->transforms_[0].type_ == COLOR_INDEXING_TRANSFORM && + dec->hdr_.color_cache_size_ == 0) { bytes_per_pixel = sizeof(uint8_t); } From 2a04b034f7c6d57e08831b235b3b5af7e143ca54 Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 17 Jun 2013 16:53:22 -0700 Subject: [PATCH 57/57] update ChangeLog Change-Id: Idea3464bbcb28896179c99488e7b96a4341b508a --- ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog b/ChangeLog index 972c50db..2042ccf5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +7288950 Regression fix for alpha channels using color cache: +2e377b5 wicdec: silence a format warning +ad9e42a muxedit: silence some uninitialized warnings +825e73b update ChangeLog abf6f69 update NEWS 5a92c1a bump version to 0.3.1 67bc353 Revert "add WebPBlendAlpha() function to blend colors against background"