IMG_webp.c: update to accomodate libwebp abi changes since v0.1.99: SDL-1.2
authorOzkan Sezer <sezeroz@gmail.com>
Wed, 17 Oct 2018 01:00:32 +0300
branchSDL-1.2
changeset 609e14e00a2754d
parent 607 1a1189c2978f
child 611 b39ee38ead19
IMG_webp.c: update to accomodate libwebp abi changes since v0.1.99:

libwebp < v0.1.99 is incompatible with current versions of the library
because the decode function signatures have changed to use size_t over
int/uint32_t.

This changeset backports three SDL2 commits listed below and copies the
Windows and OSX binaries to match it. It also adds compile time checks
for (WEBP_DECODER_ABI_VERSION < 0x0100) in order to properly define the
function pointers: WEBP_DECODER_ABI_VERSION values are from decoder.h
header as found in libwebp git tags at:
https://chromium.googlesource.com/webm/libwebp/+refs
0x0100 corresponds to the abi version in 0.1.99 prerelease version.

Backported SDL2 commits are as follows:
r360: https://hg.libsdl.org/SDL_image/rev/3d002acf103d
r378: https://hg.libsdl.org/SDL_image/rev/f83e70f2ec6c
r531: https://hg.libsdl.org/SDL_image/rev/4491ac456363
IMG_webp.c
VisualC/SDL_image.sln
VisualC/SDL_image.vcproj
VisualC/Version.rc
VisualC/clean.sh
VisualC/external/include/jconfig.h
VisualC/external/include/jerror.h
VisualC/external/include/jmorecfg.h
VisualC/external/include/jpeglib.h
VisualC/external/include/png.h
VisualC/external/include/pngconf.h
VisualC/external/include/tiff.h
VisualC/external/include/tiffconf.h
VisualC/external/include/tiffio.h
VisualC/external/include/tiffvers.h
VisualC/external/include/webp/decode.h
VisualC/external/include/webp/decode_vp8.h
VisualC/external/include/webp/encode.h
VisualC/external/include/webp/mux.h
VisualC/external/include/webp/types.h
VisualC/external/include/zconf.h
VisualC/external/include/zlib.h
VisualC/external/lib/x64/libjpeg-8.dll
VisualC/external/lib/x64/libpng15-15.dll
VisualC/external/lib/x64/libtiff-5.dll
VisualC/external/lib/x64/libwebp-2.dll
VisualC/external/lib/x64/libwebp-7.dll
VisualC/external/lib/x64/zlib1.dll
VisualC/external/lib/x86/libjpeg-8.dll
VisualC/external/lib/x86/libpng15-15.dll
VisualC/external/lib/x86/libtiff-5.dll
VisualC/external/lib/x86/libwebp-2.dll
VisualC/external/lib/x86/libwebp-7.dll
VisualC/external/lib/x86/zlib1.dll
VisualC/resource.h
VisualC/showimage/showimage.sln
VisualC/showimage/showimage.vcproj
Xcode-iOS/SDL_image.xcodeproj/project.pbxproj
Xcode/Frameworks/webp.framework/LICENSE.webp.txt
Xcode/Frameworks/webp.framework/Versions/A/Headers/webp/decode.h
Xcode/Frameworks/webp.framework/Versions/A/Headers/webp/decode_vp8.h
Xcode/Frameworks/webp.framework/Versions/A/Headers/webp/encode.h
Xcode/Frameworks/webp.framework/Versions/A/Headers/webp/mux.h
Xcode/Frameworks/webp.framework/Versions/A/Headers/webp/types.h
Xcode/Frameworks/webp.framework/Versions/A/Resources/English.lproj/InfoPlist.strings
Xcode/Frameworks/webp.framework/Versions/A/Resources/Info.plist
Xcode/Frameworks/webp.framework/Versions/A/Resources/LICENSE.webp.txt
Xcode/Frameworks/webp.framework/Versions/A/webp
Xcode/SDL_image.xcodeproj/project.pbxproj
     1.1 --- a/IMG_webp.c	Tue Oct 16 20:02:02 2018 +0300
     1.2 +++ b/IMG_webp.c	Wed Oct 17 01:00:32 2018 +0300
     1.3 @@ -47,9 +47,15 @@
     1.4  static struct {
     1.5  	int loaded;
     1.6  	void *handle;
     1.7 +#if WEBP_DECODER_ABI_VERSION < 0x0100
     1.8  	int/*VP8StatuCode*/ (*webp_get_features_internal) (const uint8_t *data, uint32_t data_size, WebPBitstreamFeatures* const features, int decoder_abi_version);
     1.9  	uint8_t*	(*webp_decode_rgb_into) (const uint8_t* data, uint32_t data_size, uint8_t* output_buffer, int output_buffer_size, int output_stride);
    1.10  	uint8_t*	(*webp_decode_rgba_into) (const uint8_t* data, uint32_t data_size, uint8_t* output_buffer, int output_buffer_size, int output_stride);
    1.11 +#else
    1.12 +	VP8StatusCode (*webp_get_features_internal) (const uint8_t *data, size_t data_size, WebPBitstreamFeatures* features, int decoder_abi_version);
    1.13 +	uint8_t*	(*webp_decode_rgb_into) (const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
    1.14 +	uint8_t*	(*webp_decode_rgba_into) (const uint8_t* data, size_t data_size, uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
    1.15 +#endif
    1.16  } lib;
    1.17  
    1.18  #ifdef LOAD_WEBP_DYNAMIC
    1.19 @@ -60,8 +66,13 @@
    1.20  		if ( lib.handle == NULL ) {
    1.21  			return -1;
    1.22  		}
    1.23 +
    1.24  		lib.webp_get_features_internal = 
    1.25 +			#if WEBP_DECODER_ABI_VERSION < 0x0100
    1.26  			( int (*) (const uint8_t *, uint32_t, WebPBitstreamFeatures* const, int) )
    1.27 +			#else
    1.28 +			( VP8StatusCode (*) (const uint8_t *, size_t, WebPBitstreamFeatures*, int) )
    1.29 +			#endif
    1.30  			SDL_LoadFunction(lib.handle, "WebPGetFeaturesInternal" );
    1.31  		if ( lib.webp_get_features_internal == NULL ) {
    1.32  			SDL_UnloadObject(lib.handle);
    1.33 @@ -69,7 +80,11 @@
    1.34  		}
    1.35  
    1.36  		lib.webp_decode_rgb_into = 
    1.37 +			#if WEBP_DECODER_ABI_VERSION < 0x0100
    1.38  			( uint8_t* (*) (const uint8_t*, uint32_t, uint8_t*, int, int ) )
    1.39 +			#else
    1.40 +			( uint8_t* (*) (const uint8_t*, size_t, uint8_t*, size_t, int ) )
    1.41 +			#endif
    1.42  			SDL_LoadFunction(lib.handle, "WebPDecodeRGBInto" );
    1.43  		if ( lib.webp_decode_rgb_into == NULL ) {
    1.44  			SDL_UnloadObject(lib.handle);
    1.45 @@ -77,8 +92,12 @@
    1.46  		}
    1.47  
    1.48  		lib.webp_decode_rgba_into = 
    1.49 +			#if WEBP_DECODER_ABI_VERSION < 0x0100
    1.50  			( uint8_t* (*) (const uint8_t*, uint32_t, uint8_t*, int, int ) )
    1.51 -			SDL_LoadFunction(lib.handle, "WebPDecodeRGBInto" );
    1.52 +			#else
    1.53 +			( uint8_t* (*) (const uint8_t*, size_t, uint8_t*, size_t, int ) )
    1.54 +			#endif
    1.55 +			SDL_LoadFunction(lib.handle, "WebPDecodeRGBAInto" );
    1.56  		if ( lib.webp_decode_rgba_into == NULL ) {
    1.57  			SDL_UnloadObject(lib.handle);
    1.58  			return -1;
    1.59 @@ -124,30 +143,36 @@
    1.60  static int webp_getinfo( SDL_RWops *src, int *datasize ) {
    1.61  	int start;
    1.62  	int is_WEBP;
    1.63 -	int data;
    1.64  	Uint8 magic[20];
    1.65  
    1.66 -	if ( !src )
    1.67 +	if ( !src ) {
    1.68  		return 0;
    1.69 +	}
    1.70  	start = SDL_RWtell(src);
    1.71  	is_WEBP = 0;
    1.72  	if ( SDL_RWread(src, magic, 1, sizeof(magic)) == sizeof(magic) ) {
    1.73  		if ( magic[ 0] == 'R' &&
    1.74 -                     magic[ 1] == 'I' &&
    1.75 -                     magic[ 2] == 'F' &&
    1.76 -                     magic[ 3] == 'F' &&
    1.77 -										 magic[ 8] == 'W' &&
    1.78 -										 magic[ 9] == 'E' &&
    1.79 -										 magic[10] == 'B' &&
    1.80 -										 magic[11] == 'P' &&
    1.81 -										 magic[12] == 'V' &&
    1.82 -										 magic[13] == 'P' &&
    1.83 -										 magic[14] == '8' &&
    1.84 -										 magic[15] == ' '  ) {
    1.85 +		     magic[ 1] == 'I' &&
    1.86 +		     magic[ 2] == 'F' &&
    1.87 +		     magic[ 3] == 'F' &&
    1.88 +		     magic[ 8] == 'W' &&
    1.89 +		     magic[ 9] == 'E' &&
    1.90 +		     magic[10] == 'B' &&
    1.91 +		     magic[11] == 'P' &&
    1.92 +		     magic[12] == 'V' &&
    1.93 +		     magic[13] == 'P' &&
    1.94 +		     magic[14] == '8' &&
    1.95 +		/* old versions don't support VP8X and VP8L */
    1.96 +		#if (WEBP_DECODER_ABI_VERSION < 0x0003)
    1.97 +		     magic[15] == ' '
    1.98 +		#else
    1.99 +		    (magic[15] == ' ' || magic[15] == 'X' || magic[15] == 'L')
   1.100 +		#endif
   1.101 +		 ) {
   1.102  			is_WEBP = 1;
   1.103 -			data = magic[16] | magic[17]<<8 | magic[18]<<16 | magic[19]<<24;
   1.104 -			if ( datasize )
   1.105 -				*datasize = data;
   1.106 +			if ( datasize ) {
   1.107 +				*datasize = SDL_RWseek(src, 0, RW_SEEK_END) - start;
   1.108 +			}
   1.109  		}
   1.110  	}
   1.111  	SDL_RWseek(src, start, RW_SEEK_SET);
   1.112 @@ -192,12 +217,9 @@
   1.113  		goto error;
   1.114  	}
   1.115  
   1.116 -	// skip header
   1.117 -	SDL_RWseek(src, start+20, RW_SEEK_SET );
   1.118 -
   1.119  	raw_data = (uint8_t*) malloc( raw_data_size );
   1.120  	if ( raw_data == NULL ) {
   1.121 -		error = "Failed to allocate enought buffer for WEBP";
   1.122 +		error = "Failed to allocate enough buffer for WEBP";
   1.123  		goto error;
   1.124  	}
   1.125  
     2.1 --- a/VisualC/SDL_image.vcproj	Tue Oct 16 20:02:02 2018 +0300
     2.2 +++ b/VisualC/SDL_image.vcproj	Wed Oct 17 01:00:32 2018 +0300
     2.3 @@ -51,7 +51,7 @@
     2.4  				Name="VCCLCompilerTool"
     2.5  				Optimization="0"
     2.6  				AdditionalIncludeDirectories="external\include"
     2.7 -				PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_JPG_DYNAMIC=\&quot;libjpeg-8.dll\&quot;;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNG_DYNAMIC=\&quot;libpng15-15.dll\&quot;;LOAD_PNM;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC=\&quot;libtiff-5.dll\&quot;;LOAD_WEBP;LOAD_WEBP_DYNAMIC=\&quot;libwebp-2.dll\&quot;;LOAD_XPM;LOAD_XV;PNG_USE_DLL;ZLIB_DLL"
     2.8 +				PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_JPG_DYNAMIC=\&quot;libjpeg-8.dll\&quot;;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNG_DYNAMIC=\&quot;libpng15-15.dll\&quot;;LOAD_PNM;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC=\&quot;libtiff-5.dll\&quot;;LOAD_WEBP;LOAD_WEBP_DYNAMIC=\&quot;libwebp-7.dll\&quot;;LOAD_XPM;LOAD_XV;PNG_USE_DLL;ZLIB_DLL"
     2.9  				MinimalRebuild="true"
    2.10  				RuntimeLibrary="2"
    2.11  				PrecompiledHeaderFile=".\Debug/SDL_image.pch"
    2.12 @@ -138,7 +138,7 @@
    2.13  				Optimization="2"
    2.14  				InlineFunctionExpansion="1"
    2.15  				AdditionalIncludeDirectories="external\include"
    2.16 -				PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_JPG_DYNAMIC=\&quot;libjpeg-8.dll\&quot;;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNG_DYNAMIC=\&quot;libpng15-15.dll\&quot;;LOAD_PNM;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC=\&quot;libtiff-5.dll\&quot;;LOAD_WEBP;LOAD_WEBP_DYNAMIC=\&quot;libwebp-2.dll\&quot;;LOAD_XPM;LOAD_XV;PNG_USE_DLL;ZLIB_DLL"
    2.17 +				PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_JPG_DYNAMIC=\&quot;libjpeg-8.dll\&quot;;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNG_DYNAMIC=\&quot;libpng15-15.dll\&quot;;LOAD_PNM;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC=\&quot;libtiff-5.dll\&quot;;LOAD_WEBP;LOAD_WEBP_DYNAMIC=\&quot;libwebp-7.dll\&quot;;LOAD_XPM;LOAD_XV;PNG_USE_DLL;ZLIB_DLL"
    2.18  				StringPooling="true"
    2.19  				RuntimeLibrary="2"
    2.20  				EnableFunctionLevelLinking="true"
    2.21 @@ -223,7 +223,7 @@
    2.22  				Name="VCCLCompilerTool"
    2.23  				Optimization="0"
    2.24  				AdditionalIncludeDirectories="external\include"
    2.25 -				PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_JPG_DYNAMIC=\&quot;libjpeg-8.dll\&quot;;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNG_DYNAMIC=\&quot;libpng15-15.dll\&quot;;LOAD_PNM;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC=\&quot;libtiff-5.dll\&quot;;LOAD_WEBP;LOAD_WEBP_DYNAMIC=\&quot;libwebp-2.dll\&quot;;LOAD_XPM;LOAD_XV;PNG_USE_DLL;ZLIB_DLL"
    2.26 +				PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_JPG_DYNAMIC=\&quot;libjpeg-8.dll\&quot;;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNG_DYNAMIC=\&quot;libpng15-15.dll\&quot;;LOAD_PNM;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC=\&quot;libtiff-5.dll\&quot;;LOAD_WEBP;LOAD_WEBP_DYNAMIC=\&quot;libwebp-7.dll\&quot;;LOAD_XPM;LOAD_XV;PNG_USE_DLL;ZLIB_DLL"
    2.27  				MinimalRebuild="true"
    2.28  				RuntimeLibrary="2"
    2.29  				PrecompiledHeaderFile=".\Debug/SDL_image.pch"
    2.30 @@ -310,7 +310,7 @@
    2.31  				Optimization="2"
    2.32  				InlineFunctionExpansion="1"
    2.33  				AdditionalIncludeDirectories="external\include"
    2.34 -				PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_JPG_DYNAMIC=\&quot;libjpeg-8.dll\&quot;;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNG_DYNAMIC=\&quot;libpng15-15.dll\&quot;;LOAD_PNM;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC=\&quot;libtiff-5.dll\&quot;;LOAD_WEBP;LOAD_WEBP_DYNAMIC=\&quot;libwebp-2.dll\&quot;;LOAD_XPM;LOAD_XV;PNG_USE_DLL;ZLIB_DLL"
    2.35 +				PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_JPG_DYNAMIC=\&quot;libjpeg-8.dll\&quot;;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNG_DYNAMIC=\&quot;libpng15-15.dll\&quot;;LOAD_PNM;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC=\&quot;libtiff-5.dll\&quot;;LOAD_WEBP;LOAD_WEBP_DYNAMIC=\&quot;libwebp-7.dll\&quot;;LOAD_XPM;LOAD_XV;PNG_USE_DLL;ZLIB_DLL"
    2.36  				StringPooling="true"
    2.37  				RuntimeLibrary="2"
    2.38  				EnableFunctionLevelLinking="true"
     3.1 --- a/VisualC/external/include/webp/decode.h	Tue Oct 16 20:02:02 2018 +0300
     3.2 +++ b/VisualC/external/include/webp/decode.h	Wed Oct 17 01:00:32 2018 +0300
     3.3 @@ -1,11 +1,13 @@
     3.4 -// Copyright 2010 Google Inc.
     3.5 +// Copyright 2010 Google Inc. All Rights Reserved.
     3.6  //
     3.7 -// This code is licensed under the same terms as WebM:
     3.8 -//  Software License Agreement:  http://www.webmproject.org/license/software/
     3.9 -//  Additional IP Rights Grant:  http://www.webmproject.org/license/additional/
    3.10 +// Use of this source code is governed by a BSD-style license
    3.11 +// that can be found in the COPYING file in the root of the source
    3.12 +// tree. An additional intellectual property rights grant can be found
    3.13 +// in the file PATENTS. All contributing project authors may
    3.14 +// be found in the AUTHORS file in the root of the source tree.
    3.15  // -----------------------------------------------------------------------------
    3.16  //
    3.17 -//  Main decoding functions for WEBP images.
    3.18 +//  Main decoding functions for WebP images.
    3.19  //
    3.20  // Author: Skal (pascal.massimino@gmail.com)
    3.21  
    3.22 @@ -14,59 +16,78 @@
    3.23  
    3.24  #include "./types.h"
    3.25  
    3.26 -#if defined(__cplusplus) || defined(c_plusplus)
    3.27 +#ifdef __cplusplus
    3.28  extern "C" {
    3.29  #endif
    3.30  
    3.31 -#define WEBP_DECODER_ABI_VERSION 0x0002
    3.32 +#define WEBP_DECODER_ABI_VERSION 0x0208    // MAJOR(8b) + MINOR(8b)
    3.33 +
    3.34 +// Note: forward declaring enumerations is not allowed in (strict) C and C++,
    3.35 +// the types are left here for reference.
    3.36 +// typedef enum VP8StatusCode VP8StatusCode;
    3.37 +// typedef enum WEBP_CSP_MODE WEBP_CSP_MODE;
    3.38 +typedef struct WebPRGBABuffer WebPRGBABuffer;
    3.39 +typedef struct WebPYUVABuffer WebPYUVABuffer;
    3.40 +typedef struct WebPDecBuffer WebPDecBuffer;
    3.41 +typedef struct WebPIDecoder WebPIDecoder;
    3.42 +typedef struct WebPBitstreamFeatures WebPBitstreamFeatures;
    3.43 +typedef struct WebPDecoderOptions WebPDecoderOptions;
    3.44 +typedef struct WebPDecoderConfig WebPDecoderConfig;
    3.45  
    3.46  // Return the decoder's version number, packed in hexadecimal using 8bits for
    3.47  // each of major/minor/revision. E.g: v2.5.7 is 0x020507.
    3.48  WEBP_EXTERN(int) WebPGetDecoderVersion(void);
    3.49  
    3.50  // Retrieve basic header information: width, height.
    3.51 -// This function will also validate the header and return 0 in
    3.52 -// case of formatting error.
    3.53 -// Pointers *width/*height can be passed NULL if deemed irrelevant.
    3.54 -WEBP_EXTERN(int) WebPGetInfo(const uint8_t* data, uint32_t data_size,
    3.55 +// This function will also validate the header, returning true on success,
    3.56 +// false otherwise. '*width' and '*height' are only valid on successful return.
    3.57 +// Pointers 'width' and 'height' can be passed NULL if deemed irrelevant.
    3.58 +WEBP_EXTERN(int) WebPGetInfo(const uint8_t* data, size_t data_size,
    3.59                               int* width, int* height);
    3.60  
    3.61 -// Decodes WEBP images pointed to by *data and returns RGB samples, along
    3.62 -// with the dimensions in *width and *height.
    3.63 -// The returned pointer should be deleted calling free().
    3.64 +// Decodes WebP images pointed to by 'data' and returns RGBA samples, along
    3.65 +// with the dimensions in *width and *height. The ordering of samples in
    3.66 +// memory is R, G, B, A, R, G, B, A... in scan order (endian-independent).
    3.67 +// The returned pointer should be deleted calling WebPFree().
    3.68  // Returns NULL in case of error.
    3.69 -WEBP_EXTERN(uint8_t*) WebPDecodeRGB(const uint8_t* data, uint32_t data_size,
    3.70 +WEBP_EXTERN(uint8_t*) WebPDecodeRGBA(const uint8_t* data, size_t data_size,
    3.71 +                                     int* width, int* height);
    3.72 +
    3.73 +// Same as WebPDecodeRGBA, but returning A, R, G, B, A, R, G, B... ordered data.
    3.74 +WEBP_EXTERN(uint8_t*) WebPDecodeARGB(const uint8_t* data, size_t data_size,
    3.75 +                                     int* width, int* height);
    3.76 +
    3.77 +// Same as WebPDecodeRGBA, but returning B, G, R, A, B, G, R, A... ordered data.
    3.78 +WEBP_EXTERN(uint8_t*) WebPDecodeBGRA(const uint8_t* data, size_t data_size,
    3.79 +                                     int* width, int* height);
    3.80 +
    3.81 +// Same as WebPDecodeRGBA, but returning R, G, B, R, G, B... ordered data.
    3.82 +// If the bitstream contains transparency, it is ignored.
    3.83 +WEBP_EXTERN(uint8_t*) WebPDecodeRGB(const uint8_t* data, size_t data_size,
    3.84                                      int* width, int* height);
    3.85  
    3.86 -// Same as WebPDecodeRGB, but returning RGBA data.
    3.87 -WEBP_EXTERN(uint8_t*) WebPDecodeRGBA(const uint8_t* data, uint32_t data_size,
    3.88 -                                     int* width, int* height);
    3.89 +// Same as WebPDecodeRGB, but returning B, G, R, B, G, R... ordered data.
    3.90 +WEBP_EXTERN(uint8_t*) WebPDecodeBGR(const uint8_t* data, size_t data_size,
    3.91 +                                    int* width, int* height);
    3.92  
    3.93 -// Same as WebPDecodeRGBA, but returning ARGB data.
    3.94 -WEBP_EXTERN(uint8_t*) WebPDecodeARGB(const uint8_t* data, uint32_t data_size,
    3.95 -                                     int* width, int* height);
    3.96  
    3.97 -// This variant decode to BGR instead of RGB.
    3.98 -WEBP_EXTERN(uint8_t*) WebPDecodeBGR(const uint8_t* data, uint32_t data_size,
    3.99 -                                    int* width, int* height);
   3.100 -// This variant decodes to BGRA instead of RGBA.
   3.101 -WEBP_EXTERN(uint8_t*) WebPDecodeBGRA(const uint8_t* data, uint32_t data_size,
   3.102 -                                     int* width, int* height);
   3.103 -
   3.104 -// Decode WEBP images stored in *data in Y'UV format(*). The pointer returned is
   3.105 -// the Y samples buffer. Upon return, *u and *v will point to the U and V
   3.106 -// chroma data. These U and V buffers need NOT be free()'d, unlike the returned
   3.107 -// Y luma one. The dimension of the U and V planes are both (*width + 1) / 2
   3.108 -// and (*height + 1)/ 2.
   3.109 +// Decode WebP images pointed to by 'data' to Y'UV format(*). The pointer
   3.110 +// returned is the Y samples buffer. Upon return, *u and *v will point to
   3.111 +// the U and V chroma data. These U and V buffers need NOT be passed to
   3.112 +// WebPFree(), unlike the returned Y luma one. The dimension of the U and V
   3.113 +// planes are both (*width + 1) / 2 and (*height + 1)/ 2.
   3.114  // Upon return, the Y buffer has a stride returned as '*stride', while U and V
   3.115  // have a common stride returned as '*uv_stride'.
   3.116  // Return NULL in case of error.
   3.117  // (*) Also named Y'CbCr. See: http://en.wikipedia.org/wiki/YCbCr
   3.118 -WEBP_EXTERN(uint8_t*) WebPDecodeYUV(const uint8_t* data, uint32_t data_size,
   3.119 +WEBP_EXTERN(uint8_t*) WebPDecodeYUV(const uint8_t* data, size_t data_size,
   3.120                                      int* width, int* height,
   3.121                                      uint8_t** u, uint8_t** v,
   3.122                                      int* stride, int* uv_stride);
   3.123  
   3.124 +// Releases memory returned by the WebPDecode*() functions above.
   3.125 +WEBP_EXTERN(void) WebPFree(void* ptr);
   3.126 +
   3.127  // These five functions are variants of the above ones, that decode the image
   3.128  // directly into a pre-allocated buffer 'output_buffer'. The maximum storage
   3.129  // available in this buffer is indicated by 'output_buffer_size'. If this
   3.130 @@ -75,22 +96,24 @@
   3.131  // The parameter 'output_stride' specifies the distance (in bytes)
   3.132  // between scanlines. Hence, output_buffer_size is expected to be at least
   3.133  // output_stride x picture-height.
   3.134 +WEBP_EXTERN(uint8_t*) WebPDecodeRGBAInto(
   3.135 +    const uint8_t* data, size_t data_size,
   3.136 +    uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
   3.137 +WEBP_EXTERN(uint8_t*) WebPDecodeARGBInto(
   3.138 +    const uint8_t* data, size_t data_size,
   3.139 +    uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
   3.140 +WEBP_EXTERN(uint8_t*) WebPDecodeBGRAInto(
   3.141 +    const uint8_t* data, size_t data_size,
   3.142 +    uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
   3.143 +
   3.144 +// RGB and BGR variants. Here too the transparency information, if present,
   3.145 +// will be dropped and ignored.
   3.146  WEBP_EXTERN(uint8_t*) WebPDecodeRGBInto(
   3.147 -    const uint8_t* data, uint32_t data_size,
   3.148 -    uint8_t* output_buffer, int output_buffer_size, int output_stride);
   3.149 -WEBP_EXTERN(uint8_t*) WebPDecodeRGBAInto(
   3.150 -    const uint8_t* data, uint32_t data_size,
   3.151 -    uint8_t* output_buffer, int output_buffer_size, int output_stride);
   3.152 -WEBP_EXTERN(uint8_t*) WebPDecodeARGBInto(
   3.153 -    const uint8_t* data, uint32_t data_size,
   3.154 -    uint8_t* output_buffer, int output_buffer_size, int output_stride);
   3.155 -// BGR variants
   3.156 +    const uint8_t* data, size_t data_size,
   3.157 +    uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
   3.158  WEBP_EXTERN(uint8_t*) WebPDecodeBGRInto(
   3.159 -    const uint8_t* data, uint32_t data_size,
   3.160 -    uint8_t* output_buffer, int output_buffer_size, int output_stride);
   3.161 -WEBP_EXTERN(uint8_t*) WebPDecodeBGRAInto(
   3.162 -    const uint8_t* data, uint32_t data_size,
   3.163 -    uint8_t* output_buffer, int output_buffer_size, int output_stride);
   3.164 +    const uint8_t* data, size_t data_size,
   3.165 +    uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
   3.166  
   3.167  // WebPDecodeYUVInto() is a variant of WebPDecodeYUV() that operates directly
   3.168  // into pre-allocated luma/chroma plane buffers. This function requires the
   3.169 @@ -100,72 +123,112 @@
   3.170  // Pointer to the luma plane ('*luma') is returned or NULL if an error occurred
   3.171  // during decoding (or because some buffers were found to be too small).
   3.172  WEBP_EXTERN(uint8_t*) WebPDecodeYUVInto(
   3.173 -    const uint8_t* data, uint32_t data_size,
   3.174 -    uint8_t* luma, int luma_size, int luma_stride,
   3.175 -    uint8_t* u, int u_size, int u_stride,
   3.176 -    uint8_t* v, int v_size, int v_stride);
   3.177 +    const uint8_t* data, size_t data_size,
   3.178 +    uint8_t* luma, size_t luma_size, int luma_stride,
   3.179 +    uint8_t* u, size_t u_size, int u_stride,
   3.180 +    uint8_t* v, size_t v_size, int v_stride);
   3.181  
   3.182  //------------------------------------------------------------------------------
   3.183  // Output colorspaces and buffer
   3.184  
   3.185  // Colorspaces
   3.186 -typedef enum { MODE_RGB = 0, MODE_RGBA = 1,
   3.187 -               MODE_BGR = 2, MODE_BGRA = 3,
   3.188 -               MODE_ARGB = 4, MODE_RGBA_4444 = 5,
   3.189 -               MODE_RGB_565 = 6,
   3.190 -               // YUV modes must come after RGB ones.
   3.191 -               MODE_YUV = 7, MODE_YUVA = 8,  // yuv 4:2:0
   3.192 -               MODE_LAST = 9
   3.193 -             } WEBP_CSP_MODE;
   3.194 +// Note: the naming describes the byte-ordering of packed samples in memory.
   3.195 +// For instance, MODE_BGRA relates to samples ordered as B,G,R,A,B,G,R,A,...
   3.196 +// Non-capital names (e.g.:MODE_Argb) relates to pre-multiplied RGB channels.
   3.197 +// RGBA-4444 and RGB-565 colorspaces are represented by following byte-order:
   3.198 +// RGBA-4444: [r3 r2 r1 r0 g3 g2 g1 g0], [b3 b2 b1 b0 a3 a2 a1 a0], ...
   3.199 +// RGB-565: [r4 r3 r2 r1 r0 g5 g4 g3], [g2 g1 g0 b4 b3 b2 b1 b0], ...
   3.200 +// In the case WEBP_SWAP_16BITS_CSP is defined, the bytes are swapped for
   3.201 +// these two modes:
   3.202 +// RGBA-4444: [b3 b2 b1 b0 a3 a2 a1 a0], [r3 r2 r1 r0 g3 g2 g1 g0], ...
   3.203 +// RGB-565: [g2 g1 g0 b4 b3 b2 b1 b0], [r4 r3 r2 r1 r0 g5 g4 g3], ...
   3.204  
   3.205 -// Generic structure for describing the sample buffer.
   3.206 -typedef struct {    // view as RGBA
   3.207 +typedef enum WEBP_CSP_MODE {
   3.208 +  MODE_RGB = 0, MODE_RGBA = 1,
   3.209 +  MODE_BGR = 2, MODE_BGRA = 3,
   3.210 +  MODE_ARGB = 4, MODE_RGBA_4444 = 5,
   3.211 +  MODE_RGB_565 = 6,
   3.212 +  // RGB-premultiplied transparent modes (alpha value is preserved)
   3.213 +  MODE_rgbA = 7,
   3.214 +  MODE_bgrA = 8,
   3.215 +  MODE_Argb = 9,
   3.216 +  MODE_rgbA_4444 = 10,
   3.217 +  // YUV modes must come after RGB ones.
   3.218 +  MODE_YUV = 11, MODE_YUVA = 12,  // yuv 4:2:0
   3.219 +  MODE_LAST = 13
   3.220 +} WEBP_CSP_MODE;
   3.221 +
   3.222 +// Some useful macros:
   3.223 +static WEBP_INLINE int WebPIsPremultipliedMode(WEBP_CSP_MODE mode) {
   3.224 +  return (mode == MODE_rgbA || mode == MODE_bgrA || mode == MODE_Argb ||
   3.225 +          mode == MODE_rgbA_4444);
   3.226 +}
   3.227 +
   3.228 +static WEBP_INLINE int WebPIsAlphaMode(WEBP_CSP_MODE mode) {
   3.229 +  return (mode == MODE_RGBA || mode == MODE_BGRA || mode == MODE_ARGB ||
   3.230 +          mode == MODE_RGBA_4444 || mode == MODE_YUVA ||
   3.231 +          WebPIsPremultipliedMode(mode));
   3.232 +}
   3.233 +
   3.234 +static WEBP_INLINE int WebPIsRGBMode(WEBP_CSP_MODE mode) {
   3.235 +  return (mode < MODE_YUV);
   3.236 +}
   3.237 +
   3.238 +//------------------------------------------------------------------------------
   3.239 +// WebPDecBuffer: Generic structure for describing the output sample buffer.
   3.240 +
   3.241 +struct WebPRGBABuffer {    // view as RGBA
   3.242    uint8_t* rgba;    // pointer to RGBA samples
   3.243    int stride;       // stride in bytes from one scanline to the next.
   3.244 -  int size;         // total size of the *rgba buffer.
   3.245 -} WebPRGBABuffer;
   3.246 +  size_t size;      // total size of the *rgba buffer.
   3.247 +};
   3.248  
   3.249 -typedef struct {              // view as YUVA
   3.250 +struct WebPYUVABuffer {              // view as YUVA
   3.251    uint8_t* y, *u, *v, *a;     // pointer to luma, chroma U/V, alpha samples
   3.252    int y_stride;               // luma stride
   3.253    int u_stride, v_stride;     // chroma strides
   3.254    int a_stride;               // alpha stride
   3.255 -  int y_size;                 // luma plane size
   3.256 -  int u_size, v_size;         // chroma planes size
   3.257 -  int a_size;                 // alpha-plane size
   3.258 -} WebPYUVABuffer;
   3.259 +  size_t y_size;              // luma plane size
   3.260 +  size_t u_size, v_size;      // chroma planes size
   3.261 +  size_t a_size;              // alpha-plane size
   3.262 +};
   3.263  
   3.264  // Output buffer
   3.265 -typedef struct {
   3.266 +struct WebPDecBuffer {
   3.267    WEBP_CSP_MODE colorspace;  // Colorspace.
   3.268    int width, height;         // Dimensions.
   3.269 -  int is_external_memory;    // If true, 'internal_memory' pointer is not used.
   3.270 +  int is_external_memory;    // If non-zero, 'internal_memory' pointer is not
   3.271 +                             // used. If value is '2' or more, the external
   3.272 +                             // memory is considered 'slow' and multiple
   3.273 +                             // read/write will be avoided.
   3.274    union {
   3.275      WebPRGBABuffer RGBA;
   3.276      WebPYUVABuffer YUVA;
   3.277    } u;                       // Nameless union of buffer parameters.
   3.278 +  uint32_t       pad[4];     // padding for later use
   3.279 +
   3.280    uint8_t* private_memory;   // Internally allocated memory (only when
   3.281 -                             // is_external_memory is false). Should not be used
   3.282 +                             // is_external_memory is 0). Should not be used
   3.283                               // externally, but accessed via the buffer union.
   3.284 -} WebPDecBuffer;
   3.285 +};
   3.286  
   3.287  // Internal, version-checked, entry point
   3.288 -WEBP_EXTERN(int) WebPInitDecBufferInternal(WebPDecBuffer* const, int);
   3.289 +WEBP_EXTERN(int) WebPInitDecBufferInternal(WebPDecBuffer*, int);
   3.290  
   3.291  // Initialize the structure as empty. Must be called before any other use.
   3.292  // Returns false in case of version mismatch
   3.293 -static WEBP_INLINE int WebPInitDecBuffer(WebPDecBuffer* const buffer) {
   3.294 +static WEBP_INLINE int WebPInitDecBuffer(WebPDecBuffer* buffer) {
   3.295    return WebPInitDecBufferInternal(buffer, WEBP_DECODER_ABI_VERSION);
   3.296  }
   3.297  
   3.298  // Free any memory associated with the buffer. Must always be called last.
   3.299  // Note: doesn't free the 'buffer' structure itself.
   3.300 -WEBP_EXTERN(void) WebPFreeDecBuffer(WebPDecBuffer* const buffer);
   3.301 +WEBP_EXTERN(void) WebPFreeDecBuffer(WebPDecBuffer* buffer);
   3.302  
   3.303  //------------------------------------------------------------------------------
   3.304  // Enumeration of the status codes
   3.305  
   3.306 -typedef enum {
   3.307 +typedef enum VP8StatusCode {
   3.308    VP8_STATUS_OK = 0,
   3.309    VP8_STATUS_OUT_OF_MEMORY,
   3.310    VP8_STATUS_INVALID_PARAM,
   3.311 @@ -185,64 +248,84 @@
   3.312  // picture is only partially decoded, pending additional input.
   3.313  // Code example:
   3.314  //
   3.315 -//   WebPIDecoder* const idec = WebPINew(mode);
   3.316 -//   while (has_more_data) {
   3.317 -//     // ... (get additional data)
   3.318 +//   WebPInitDecBuffer(&output_buffer);
   3.319 +//   output_buffer.colorspace = mode;
   3.320 +//   ...
   3.321 +//   WebPIDecoder* idec = WebPINewDecoder(&output_buffer);
   3.322 +//   while (additional_data_is_available) {
   3.323 +//     // ... (get additional data in some new_data[] buffer)
   3.324  //     status = WebPIAppend(idec, new_data, new_data_size);
   3.325 -//     if (status != VP8_STATUS_SUSPENDED ||
   3.326 -//       break;
   3.327 +//     if (status != VP8_STATUS_OK && status != VP8_STATUS_SUSPENDED) {
   3.328 +//       break;    // an error occurred.
   3.329  //     }
   3.330  //
   3.331  //     // The above call decodes the current available buffer.
   3.332 -//     // Part of the image can now be refreshed by calling to
   3.333 -//     // WebPIDecGetRGB()/WebPIDecGetYUV() etc.
   3.334 +//     // Part of the image can now be refreshed by calling
   3.335 +//     // WebPIDecGetRGB()/WebPIDecGetYUVA() etc.
   3.336  //   }
   3.337  //   WebPIDelete(idec);
   3.338  
   3.339 -typedef struct WebPIDecoder WebPIDecoder;
   3.340 -
   3.341  // Creates a new incremental decoder with the supplied buffer parameter.
   3.342  // This output_buffer can be passed NULL, in which case a default output buffer
   3.343  // is used (with MODE_RGB). Otherwise, an internal reference to 'output_buffer'
   3.344  // is kept, which means that the lifespan of 'output_buffer' must be larger than
   3.345  // that of the returned WebPIDecoder object.
   3.346 +// The supplied 'output_buffer' content MUST NOT be changed between calls to
   3.347 +// WebPIAppend() or WebPIUpdate() unless 'output_buffer.is_external_memory' is
   3.348 +// not set to 0. In such a case, it is allowed to modify the pointers, size and
   3.349 +// stride of output_buffer.u.RGBA or output_buffer.u.YUVA, provided they remain
   3.350 +// within valid bounds.
   3.351 +// All other fields of WebPDecBuffer MUST remain constant between calls.
   3.352  // Returns NULL if the allocation failed.
   3.353 -WEBP_EXTERN(WebPIDecoder*) WebPINewDecoder(WebPDecBuffer* const output_buffer);
   3.354 -
   3.355 -// Creates a WebPIDecoder object. Returns NULL in case of failure.
   3.356 -// TODO(skal): DEPRECATED. Prefer using WebPINewDecoder().
   3.357 -WEBP_EXTERN(WebPIDecoder*) WebPINew(WEBP_CSP_MODE mode);
   3.358 +WEBP_EXTERN(WebPIDecoder*) WebPINewDecoder(WebPDecBuffer* output_buffer);
   3.359  
   3.360  // This function allocates and initializes an incremental-decoder object, which
   3.361 -// will output the r/g/b(/a) samples specified by 'mode' into a preallocated
   3.362 +// will output the RGB/A samples specified by 'csp' into a preallocated
   3.363  // buffer 'output_buffer'. The size of this buffer is at least
   3.364  // 'output_buffer_size' and the stride (distance in bytes between two scanlines)
   3.365 -// is specified by 'output_stride'. Returns NULL if the allocation failed.
   3.366 +// is specified by 'output_stride'.
   3.367 +// Additionally, output_buffer can be passed NULL in which case the output
   3.368 +// buffer will be allocated automatically when the decoding starts. The
   3.369 +// colorspace 'csp' is taken into account for allocating this buffer. All other
   3.370 +// parameters are ignored.
   3.371 +// Returns NULL if the allocation failed, or if some parameters are invalid.
   3.372  WEBP_EXTERN(WebPIDecoder*) WebPINewRGB(
   3.373 -    WEBP_CSP_MODE mode,
   3.374 -    uint8_t* output_buffer, int output_buffer_size, int output_stride);
   3.375 +    WEBP_CSP_MODE csp,
   3.376 +    uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
   3.377  
   3.378  // This function allocates and initializes an incremental-decoder object, which
   3.379 -// will output the raw luma/chroma samples into a preallocated planes. The luma
   3.380 -// plane is specified by its pointer 'luma', its size 'luma_size' and its stride
   3.381 -// 'luma_stride'. Similarly, the chroma-u plane is specified by the 'u',
   3.382 -// 'u_size' and 'u_stride' parameters, and the chroma-v plane by 'v', 'v_size'
   3.383 -// and 'v_size'.
   3.384 -// Returns NULL if the allocation failed.
   3.385 +// will output the raw luma/chroma samples into a preallocated planes if
   3.386 +// supplied. The luma plane is specified by its pointer 'luma', its size
   3.387 +// 'luma_size' and its stride 'luma_stride'. Similarly, the chroma-u plane
   3.388 +// is specified by the 'u', 'u_size' and 'u_stride' parameters, and the chroma-v
   3.389 +// plane by 'v' and 'v_size'. And same for the alpha-plane. The 'a' pointer
   3.390 +// can be pass NULL in case one is not interested in the transparency plane.
   3.391 +// Conversely, 'luma' can be passed NULL if no preallocated planes are supplied.
   3.392 +// In this case, the output buffer will be automatically allocated (using
   3.393 +// MODE_YUVA) when decoding starts. All parameters are then ignored.
   3.394 +// Returns NULL if the allocation failed or if a parameter is invalid.
   3.395 +WEBP_EXTERN(WebPIDecoder*) WebPINewYUVA(
   3.396 +    uint8_t* luma, size_t luma_size, int luma_stride,
   3.397 +    uint8_t* u, size_t u_size, int u_stride,
   3.398 +    uint8_t* v, size_t v_size, int v_stride,
   3.399 +    uint8_t* a, size_t a_size, int a_stride);
   3.400 +
   3.401 +// Deprecated version of the above, without the alpha plane.
   3.402 +// Kept for backward compatibility.
   3.403  WEBP_EXTERN(WebPIDecoder*) WebPINewYUV(
   3.404 -    uint8_t* luma, int luma_size, int luma_stride,
   3.405 -    uint8_t* u, int u_size, int u_stride,
   3.406 -    uint8_t* v, int v_size, int v_stride);
   3.407 +    uint8_t* luma, size_t luma_size, int luma_stride,
   3.408 +    uint8_t* u, size_t u_size, int u_stride,
   3.409 +    uint8_t* v, size_t v_size, int v_stride);
   3.410  
   3.411  // Deletes the WebPIDecoder object and associated memory. Must always be called
   3.412 -// if WebPINew, WebPINewRGB or WebPINewYUV succeeded.
   3.413 -WEBP_EXTERN(void) WebPIDelete(WebPIDecoder* const idec);
   3.414 +// if WebPINewDecoder, WebPINewRGB or WebPINewYUV succeeded.
   3.415 +WEBP_EXTERN(void) WebPIDelete(WebPIDecoder* idec);
   3.416  
   3.417  // Copies and decodes the next available data. Returns VP8_STATUS_OK when
   3.418  // the image is successfully decoded. Returns VP8_STATUS_SUSPENDED when more
   3.419  // data is expected. Returns error in other cases.
   3.420  WEBP_EXTERN(VP8StatusCode) WebPIAppend(
   3.421 -    WebPIDecoder* const idec, const uint8_t* data, uint32_t data_size);
   3.422 +    WebPIDecoder* idec, const uint8_t* data, size_t data_size);
   3.423  
   3.424  // A variant of the above function to be used when data buffer contains
   3.425  // partial data from the beginning. In this case data buffer is not copied
   3.426 @@ -250,23 +333,34 @@
   3.427  // Note that the value of the 'data' pointer can change between calls to
   3.428  // WebPIUpdate, for instance when the data buffer is resized to fit larger data.
   3.429  WEBP_EXTERN(VP8StatusCode) WebPIUpdate(
   3.430 -    WebPIDecoder* const idec, const uint8_t* data, uint32_t data_size);
   3.431 +    WebPIDecoder* idec, const uint8_t* data, size_t data_size);
   3.432  
   3.433 -// Returns the r/g/b/(a) image decoded so far. Returns NULL if output params
   3.434 -// are not initialized yet. The r/g/b/(a) output type corresponds to the mode
   3.435 -// specified in WebPINew()/WebPINewRGB(). *last_y is the index of last decoded
   3.436 -// row in raster scan order. Some pointers (*last_y, *width etc.) can be NULL if
   3.437 -// corresponding information is not needed.
   3.438 +// Returns the RGB/A image decoded so far. Returns NULL if output params
   3.439 +// are not initialized yet. The RGB/A output type corresponds to the colorspace
   3.440 +// specified during call to WebPINewDecoder() or WebPINewRGB().
   3.441 +// *last_y is the index of last decoded row in raster scan order. Some pointers
   3.442 +// (*last_y, *width etc.) can be NULL if corresponding information is not
   3.443 +// needed.
   3.444  WEBP_EXTERN(uint8_t*) WebPIDecGetRGB(
   3.445 -    const WebPIDecoder* const idec, int* last_y,
   3.446 +    const WebPIDecoder* idec, int* last_y,
   3.447      int* width, int* height, int* stride);
   3.448  
   3.449 -// Same as above function to get YUV image. Returns pointer to the luma plane
   3.450 -// or NULL in case of error.
   3.451 -WEBP_EXTERN(uint8_t*) WebPIDecGetYUV(
   3.452 -    const WebPIDecoder* const idec, int* last_y,
   3.453 -    uint8_t** u, uint8_t** v,
   3.454 -    int* width, int* height, int* stride, int* uv_stride);
   3.455 +// Same as above function to get a YUVA image. Returns pointer to the luma
   3.456 +// plane or NULL in case of error. If there is no alpha information
   3.457 +// the alpha pointer '*a' will be returned NULL.
   3.458 +WEBP_EXTERN(uint8_t*) WebPIDecGetYUVA(
   3.459 +    const WebPIDecoder* idec, int* last_y,
   3.460 +    uint8_t** u, uint8_t** v, uint8_t** a,
   3.461 +    int* width, int* height, int* stride, int* uv_stride, int* a_stride);
   3.462 +
   3.463 +// Deprecated alpha-less version of WebPIDecGetYUVA(): it will ignore the
   3.464 +// alpha information (if present). Kept for backward compatibility.
   3.465 +static WEBP_INLINE uint8_t* WebPIDecGetYUV(
   3.466 +    const WebPIDecoder* idec, int* last_y, uint8_t** u, uint8_t** v,
   3.467 +    int* width, int* height, int* stride, int* uv_stride) {
   3.468 +  return WebPIDecGetYUVA(idec, last_y, u, v, NULL, width, height,
   3.469 +                         stride, uv_stride, NULL);
   3.470 +}
   3.471  
   3.472  // Generic call to retrieve information about the displayable area.
   3.473  // If non NULL, the left/right/width/height pointers are filled with the visible
   3.474 @@ -275,9 +369,7 @@
   3.475  // Otherwise returns the pointer to the internal representation. This structure
   3.476  // is read-only, tied to WebPIDecoder's lifespan and should not be modified.
   3.477  WEBP_EXTERN(const WebPDecBuffer*) WebPIDecodedArea(
   3.478 -    const WebPIDecoder* const idec,
   3.479 -    int* const left, int* const top,
   3.480 -    int* const width, int* const height);
   3.481 +    const WebPIDecoder* idec, int* left, int* top, int* width, int* height);
   3.482  
   3.483  //------------------------------------------------------------------------------
   3.484  // Advanced decoding parametrization
   3.485 @@ -292,7 +384,7 @@
   3.486       CHECK(WebPGetFeatures(data, data_size, &config.input) == VP8_STATUS_OK);
   3.487  
   3.488       // C) Adjust 'config', if needed
   3.489 -     config.no_fancy = 1;
   3.490 +     config.no_fancy_upsampling = 1;
   3.491       config.output.colorspace = MODE_BGRA;
   3.492       // etc.
   3.493  
   3.494 @@ -313,34 +405,34 @@
   3.495  */
   3.496  
   3.497  // Features gathered from the bitstream
   3.498 -typedef struct {
   3.499 -  int width;        // the original width, as read from the bitstream
   3.500 -  int height;       // the original height, as read from the bitstream
   3.501 -  int has_alpha;    // true if bitstream contains an alpha channel
   3.502 -  int no_incremental_decoding;  // if true, using incremental decoding is not
   3.503 -                                // recommended.
   3.504 -  int rotate;                   // TODO(later)
   3.505 -  int uv_sampling;              // should be 0 for now. TODO(later)
   3.506 -  int bitstream_version;        // should be 0 for now. TODO(later)
   3.507 -} WebPBitstreamFeatures;
   3.508 +struct WebPBitstreamFeatures {
   3.509 +  int width;          // Width in pixels, as read from the bitstream.
   3.510 +  int height;         // Height in pixels, as read from the bitstream.
   3.511 +  int has_alpha;      // True if the bitstream contains an alpha channel.
   3.512 +  int has_animation;  // True if the bitstream is an animation.
   3.513 +  int format;         // 0 = undefined (/mixed), 1 = lossy, 2 = lossless
   3.514 +
   3.515 +  uint32_t pad[5];    // padding for later use
   3.516 +};
   3.517  
   3.518  // Internal, version-checked, entry point
   3.519  WEBP_EXTERN(VP8StatusCode) WebPGetFeaturesInternal(
   3.520 -    const uint8_t*, uint32_t, WebPBitstreamFeatures* const, int);
   3.521 +    const uint8_t*, size_t, WebPBitstreamFeatures*, int);
   3.522  
   3.523  // Retrieve features from the bitstream. The *features structure is filled
   3.524  // with information gathered from the bitstream.
   3.525 -// Returns false in case of error or version mismatch.
   3.526 -// In case of error, features->bitstream_status will reflect the error code.
   3.527 +// Returns VP8_STATUS_OK when the features are successfully retrieved. Returns
   3.528 +// VP8_STATUS_NOT_ENOUGH_DATA when more data is needed to retrieve the
   3.529 +// features from headers. Returns error in other cases.
   3.530  static WEBP_INLINE VP8StatusCode WebPGetFeatures(
   3.531 -    const uint8_t* data, uint32_t data_size,
   3.532 -    WebPBitstreamFeatures* const features) {
   3.533 +    const uint8_t* data, size_t data_size,
   3.534 +    WebPBitstreamFeatures* features) {
   3.535    return WebPGetFeaturesInternal(data, data_size, features,
   3.536                                   WEBP_DECODER_ABI_VERSION);
   3.537  }
   3.538  
   3.539  // Decoding options
   3.540 -typedef struct {
   3.541 +struct WebPDecoderOptions {
   3.542    int bypass_filtering;               // if true, skip the in-loop filtering
   3.543    int no_fancy_upsampling;            // if true, use faster pointwise upsampler
   3.544    int use_cropping;                   // if true, cropping is applied _first_
   3.545 @@ -349,47 +441,52 @@
   3.546    int crop_width, crop_height;        // dimension of the cropping area
   3.547    int use_scaling;                    // if true, scaling is applied _afterward_
   3.548    int scaled_width, scaled_height;    // final resolution
   3.549 -  int force_rotation;                 // forced rotation (to be applied _last_)
   3.550 -  int no_enhancement;                 // if true, discard enhancement layer
   3.551    int use_threads;                    // if true, use multi-threaded decoding
   3.552 -} WebPDecoderOptions;
   3.553 +  int dithering_strength;             // dithering strength (0=Off, 100=full)
   3.554 +  int flip;                           // flip output vertically
   3.555 +  int alpha_dithering_strength;       // alpha dithering strength in [0..100]
   3.556 +
   3.557 +  uint32_t pad[5];                    // padding for later use
   3.558 +};
   3.559  
   3.560  // Main object storing the configuration for advanced decoding.
   3.561 -typedef struct {
   3.562 +struct WebPDecoderConfig {
   3.563    WebPBitstreamFeatures input;  // Immutable bitstream features (optional)
   3.564    WebPDecBuffer output;         // Output buffer (can point to external mem)
   3.565    WebPDecoderOptions options;   // Decoding options
   3.566 -} WebPDecoderConfig;
   3.567 +};
   3.568  
   3.569  // Internal, version-checked, entry point
   3.570 -WEBP_EXTERN(int) WebPInitDecoderConfigInternal(WebPDecoderConfig* const, int);
   3.571 +WEBP_EXTERN(int) WebPInitDecoderConfigInternal(WebPDecoderConfig*, int);
   3.572  
   3.573  // Initialize the configuration as empty. This function must always be
   3.574  // called first, unless WebPGetFeatures() is to be called.
   3.575  // Returns false in case of mismatched version.
   3.576 -static WEBP_INLINE int WebPInitDecoderConfig(WebPDecoderConfig* const config) {
   3.577 +static WEBP_INLINE int WebPInitDecoderConfig(WebPDecoderConfig* config) {
   3.578    return WebPInitDecoderConfigInternal(config, WEBP_DECODER_ABI_VERSION);
   3.579  }
   3.580  
   3.581 -// Instantiate a new incremental decoder object with requested configuration.
   3.582 -// The bitstream can be passed using *data and data_size parameter,
   3.583 -// in which case the features will be parsed and stored into config->input.
   3.584 -// Otherwise, 'data' can be NULL and now parsing will occur.
   3.585 -// Note that 'config' can be NULL too, in which case a default configuration is
   3.586 -// used.
   3.587 +// Instantiate a new incremental decoder object with the requested
   3.588 +// configuration. The bitstream can be passed using 'data' and 'data_size'
   3.589 +// parameter, in which case the features will be parsed and stored into
   3.590 +// config->input. Otherwise, 'data' can be NULL and no parsing will occur.
   3.591 +// Note that 'config' can be NULL too, in which case a default configuration
   3.592 +// is used. If 'config' is not NULL, it must outlive the WebPIDecoder object
   3.593 +// as some references to its fields will be used. No internal copy of 'config'
   3.594 +// is made.
   3.595  // The return WebPIDecoder object must always be deleted calling WebPIDelete().
   3.596  // Returns NULL in case of error (and config->status will then reflect
   3.597 -// the error condition).
   3.598 -WEBP_EXTERN(WebPIDecoder*) WebPIDecode(const uint8_t* data, uint32_t data_size,
   3.599 -                                       WebPDecoderConfig* const config);
   3.600 +// the error condition, if available).
   3.601 +WEBP_EXTERN(WebPIDecoder*) WebPIDecode(const uint8_t* data, size_t data_size,
   3.602 +                                       WebPDecoderConfig* config);
   3.603  
   3.604  // Non-incremental version. This version decodes the full data at once, taking
   3.605 -// 'config' into account. Return decoding status (VP8_STATUS_OK if decoding
   3.606 -// was successful).
   3.607 -WEBP_EXTERN(VP8StatusCode) WebPDecode(const uint8_t* data, uint32_t data_size,
   3.608 -                                      WebPDecoderConfig* const config);
   3.609 +// 'config' into account. Returns decoding status (which should be VP8_STATUS_OK
   3.610 +// if the decoding was successful). Note that 'config' cannot be NULL.
   3.611 +WEBP_EXTERN(VP8StatusCode) WebPDecode(const uint8_t* data, size_t data_size,
   3.612 +                                      WebPDecoderConfig* config);
   3.613  
   3.614 -#if defined(__cplusplus) || defined(c_plusplus)
   3.615 +#ifdef __cplusplus
   3.616  }    // extern "C"
   3.617  #endif
   3.618  
     4.1 --- a/VisualC/external/include/webp/decode_vp8.h	Tue Oct 16 20:02:02 2018 +0300
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,157 +0,0 @@
     4.4 -// Copyright 2010 Google Inc.
     4.5 -//
     4.6 -// This code is licensed under the same terms as WebM:
     4.7 -//  Software License Agreement:  http://www.webmproject.org/license/software/
     4.8 -//  Additional IP Rights Grant:  http://www.webmproject.org/license/additional/
     4.9 -// -----------------------------------------------------------------------------
    4.10 -//
    4.11 -//  Low-level API for VP8 decoder
    4.12 -//
    4.13 -// Author: Skal (pascal.massimino@gmail.com)
    4.14 -
    4.15 -#ifndef WEBP_WEBP_DECODE_VP8_H_
    4.16 -#define WEBP_WEBP_DECODE_VP8_H_
    4.17 -
    4.18 -#include "./decode.h"
    4.19 -
    4.20 -#if defined(__cplusplus) || defined(c_plusplus)
    4.21 -extern "C" {
    4.22 -#endif
    4.23 -
    4.24 -//------------------------------------------------------------------------------
    4.25 -// Lower-level API
    4.26 -//
    4.27 -// These functions provide fine-grained control of the decoding process.
    4.28 -// The call flow should resemble:
    4.29 -//
    4.30 -//   VP8Io io;
    4.31 -//   VP8InitIo(&io);
    4.32 -//   io.data = data;
    4.33 -//   io.data_size = size;
    4.34 -//   /* customize io's functions (setup()/put()/teardown()) if needed. */
    4.35 -//
    4.36 -//   VP8Decoder* dec = VP8New();
    4.37 -//   bool ok = VP8Decode(dec);
    4.38 -//   if (!ok) printf("Error: %s\n", VP8StatusMessage(dec));
    4.39 -//   VP8Delete(dec);
    4.40 -//   return ok;
    4.41 -
    4.42 -// Input / Output
    4.43 -typedef struct VP8Io VP8Io;
    4.44 -typedef int (*VP8IoPutHook)(const VP8Io* io);
    4.45 -typedef int (*VP8IoSetupHook)(VP8Io* io);
    4.46 -typedef void (*VP8IoTeardownHook)(const VP8Io* io);
    4.47 -
    4.48 -struct VP8Io {
    4.49 -  // set by VP8GetHeaders()
    4.50 -  int width, height;         // picture dimensions, in pixels (invariable).
    4.51 -                             // These are the original, uncropped dimensions.
    4.52 -                             // The actual area passed to put() is stored
    4.53 -                             // in mb_w / mb_h fields.
    4.54 -
    4.55 -  // set before calling put()
    4.56 -  int mb_y;                  // position of the current rows (in pixels)
    4.57 -  int mb_w;                  // number of columns in the sample
    4.58 -  int mb_h;                  // number of rows in the sample
    4.59 -  const uint8_t* y, *u, *v;  // rows to copy (in yuv420 format)
    4.60 -  int y_stride;              // row stride for luma
    4.61 -  int uv_stride;             // row stride for chroma
    4.62 -
    4.63 -  void* opaque;              // user data
    4.64 -
    4.65 -  // called when fresh samples are available. Currently, samples are in
    4.66 -  // YUV420 format, and can be up to width x 24 in size (depending on the
    4.67 -  // in-loop filtering level, e.g.). Should return false in case of error
    4.68 -  // or abort request. The actual size of the area to update is mb_w x mb_h
    4.69 -  // in size, taking cropping into account.
    4.70 -  VP8IoPutHook put;
    4.71 -
    4.72 -  // called just before starting to decode the blocks.
    4.73 -  // Must return false in case of setup error, true otherwise. If false is
    4.74 -  // returned, teardown() will NOT be called. But if the setup succeeded
    4.75 -  // and true is returned, then teardown() will always be called afterward.
    4.76 -  VP8IoSetupHook setup;
    4.77 -
    4.78 -  // Called just after block decoding is finished (or when an error occurred
    4.79 -  // during put()). Is NOT called if setup() failed.
    4.80 -  VP8IoTeardownHook teardown;
    4.81 -
    4.82 -  // this is a recommendation for the user-side yuv->rgb converter. This flag
    4.83 -  // is set when calling setup() hook and can be overwritten by it. It then
    4.84 -  // can be taken into consideration during the put() method.
    4.85 -  int fancy_upsampling;
    4.86 -
    4.87 -  // Input buffer.
    4.88 -  uint32_t data_size;
    4.89 -  const uint8_t* data;
    4.90 -
    4.91 -  // If true, in-loop filtering will not be performed even if present in the
    4.92 -  // bitstream. Switching off filtering may speed up decoding at the expense
    4.93 -  // of more visible blocking. Note that output will also be non-compliant
    4.94 -  // with the VP8 specifications.
    4.95 -  int bypass_filtering;
    4.96 -
    4.97 -  // Cropping parameters.
    4.98 -  int use_cropping;
    4.99 -  int crop_left, crop_right, crop_top, crop_bottom;
   4.100 -
   4.101 -  // Scaling parameters.
   4.102 -  int use_scaling;
   4.103 -  int scaled_width, scaled_height;
   4.104 -
   4.105 -  // pointer to the alpha data (if present) corresponding to the rows
   4.106 -  const uint8_t* a;
   4.107 -};
   4.108 -
   4.109 -// Internal, version-checked, entry point
   4.110 -WEBP_EXTERN(int) VP8InitIoInternal(VP8Io* const, int);
   4.111 -
   4.112 -// Set the custom IO function pointers and user-data. The setter for IO hooks
   4.113 -// should be called before initiating incremental decoding. Returns true if
   4.114 -// WebPIDecoder object is successfully modified, false otherwise.
   4.115 -WEBP_EXTERN(int) WebPISetIOHooks(WebPIDecoder* const idec,
   4.116 -                                 VP8IoPutHook put,
   4.117 -                                 VP8IoSetupHook setup,
   4.118 -                                 VP8IoTeardownHook teardown,
   4.119 -                                 void* user_data);
   4.120 -
   4.121 -// Main decoding object. This is an opaque structure.
   4.122 -typedef struct VP8Decoder VP8Decoder;
   4.123 -
   4.124 -// Create a new decoder object.
   4.125 -WEBP_EXTERN(VP8Decoder*) VP8New(void);
   4.126 -
   4.127 -// Must be called to make sure 'io' is initialized properly.
   4.128 -// Returns false in case of version mismatch. Upon such failure, no other
   4.129 -// decoding function should be called (VP8Decode, VP8GetHeaders, ...)
   4.130 -static WEBP_INLINE int VP8InitIo(VP8Io* const io) {
   4.131 -  return VP8InitIoInternal(io, WEBP_DECODER_ABI_VERSION);
   4.132 -}
   4.133 -
   4.134 -// Start decoding a new picture. Returns true if ok.
   4.135 -WEBP_EXTERN(int) VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io);
   4.136 -
   4.137 -// Decode a picture. Will call VP8GetHeaders() if it wasn't done already.
   4.138 -// Returns false in case of error.
   4.139 -WEBP_EXTERN(int) VP8Decode(VP8Decoder* const dec, VP8Io* const io);
   4.140 -
   4.141 -// Return current status of the decoder:
   4.142 -WEBP_EXTERN(VP8StatusCode) VP8Status(VP8Decoder* const dec);
   4.143 -
   4.144 -// return readable string corresponding to the last status.
   4.145 -WEBP_EXTERN(const char*) VP8StatusMessage(VP8Decoder* const dec);
   4.146 -
   4.147 -// Resets the decoder in its initial state, reclaiming memory.
   4.148 -// Not a mandatory call between calls to VP8Decode().
   4.149 -WEBP_EXTERN(void) VP8Clear(VP8Decoder* const dec);
   4.150 -
   4.151 -// Destroy the decoder object.
   4.152 -WEBP_EXTERN(void) VP8Delete(VP8Decoder* const dec);
   4.153 -
   4.154 -//------------------------------------------------------------------------------
   4.155 -
   4.156 -#if defined(__cplusplus) || defined(c_plusplus)
   4.157 -}    // extern "C"
   4.158 -#endif
   4.159 -
   4.160 -#endif  /* WEBP_WEBP_DECODE_VP8_H_ */
     5.1 --- a/VisualC/external/include/webp/encode.h	Tue Oct 16 20:02:02 2018 +0300
     5.2 +++ b/VisualC/external/include/webp/encode.h	Wed Oct 17 01:00:32 2018 +0300
     5.3 @@ -1,8 +1,10 @@
     5.4 -// Copyright 2011 Google Inc.
     5.5 +// Copyright 2011 Google Inc. All Rights Reserved.
     5.6  //
     5.7 -// This code is licensed under the same terms as WebM:
     5.8 -//  Software License Agreement:  http://www.webmproject.org/license/software/
     5.9 -//  Additional IP Rights Grant:  http://www.webmproject.org/license/additional/
    5.10 +// Use of this source code is governed by a BSD-style license
    5.11 +// that can be found in the COPYING file in the root of the source
    5.12 +// tree. An additional intellectual property rights grant can be found
    5.13 +// in the file PATENTS. All contributing project authors may
    5.14 +// be found in the AUTHORS file in the root of the source tree.
    5.15  // -----------------------------------------------------------------------------
    5.16  //
    5.17  //   WebP encoder: main interface
    5.18 @@ -12,15 +14,24 @@
    5.19  #ifndef WEBP_WEBP_ENCODE_H_
    5.20  #define WEBP_WEBP_ENCODE_H_
    5.21  
    5.22 -#include <stdlib.h>
    5.23 -
    5.24  #include "./types.h"
    5.25  
    5.26 -#if defined(__cplusplus) || defined(c_plusplus)
    5.27 +#ifdef __cplusplus
    5.28  extern "C" {
    5.29  #endif
    5.30  
    5.31 -#define WEBP_ENCODER_ABI_VERSION 0x0003
    5.32 +#define WEBP_ENCODER_ABI_VERSION 0x020e    // MAJOR(8b) + MINOR(8b)
    5.33 +
    5.34 +// Note: forward declaring enumerations is not allowed in (strict) C and C++,
    5.35 +// the types are left here for reference.
    5.36 +// typedef enum WebPImageHint WebPImageHint;
    5.37 +// typedef enum WebPEncCSP WebPEncCSP;
    5.38 +// typedef enum WebPPreset WebPPreset;
    5.39 +// typedef enum WebPEncodingError WebPEncodingError;
    5.40 +typedef struct WebPConfig WebPConfig;
    5.41 +typedef struct WebPPicture WebPPicture;   // main structure for I/O
    5.42 +typedef struct WebPAuxStats WebPAuxStats;
    5.43 +typedef struct WebPMemoryWriter WebPMemoryWriter;
    5.44  
    5.45  // Return the encoder's version number, packed in hexadecimal using 8bits for
    5.46  // each of major/minor/revision. E.g: v2.5.7 is 0x020507.
    5.47 @@ -31,7 +42,10 @@
    5.48  
    5.49  // Returns the size of the compressed data (pointed to by *output), or 0 if
    5.50  // an error occurred. The compressed data must be released by the caller
    5.51 -// using the call 'free(*output)'.
    5.52 +// using the call 'WebPFree(*output)'.
    5.53 +// These functions compress using the lossy format, and the quality_factor
    5.54 +// can go from 0 (smaller output, lower quality) to 100 (best quality,
    5.55 +// larger output).
    5.56  WEBP_EXTERN(size_t) WebPEncodeRGB(const uint8_t* rgb,
    5.57                                    int width, int height, int stride,
    5.58                                    float quality_factor, uint8_t** output);
    5.59 @@ -45,42 +59,97 @@
    5.60                                     int width, int height, int stride,
    5.61                                     float quality_factor, uint8_t** output);
    5.62  
    5.63 +// These functions are the equivalent of the above, but compressing in a
    5.64 +// lossless manner. Files are usually larger than lossy format, but will
    5.65 +// not suffer any compression loss.
    5.66 +WEBP_EXTERN(size_t) WebPEncodeLosslessRGB(const uint8_t* rgb,
    5.67 +                                          int width, int height, int stride,
    5.68 +                                          uint8_t** output);
    5.69 +WEBP_EXTERN(size_t) WebPEncodeLosslessBGR(const uint8_t* bgr,
    5.70 +                                          int width, int height, int stride,
    5.71 +                                          uint8_t** output);
    5.72 +WEBP_EXTERN(size_t) WebPEncodeLosslessRGBA(const uint8_t* rgba,
    5.73 +                                           int width, int height, int stride,
    5.74 +                                           uint8_t** output);
    5.75 +WEBP_EXTERN(size_t) WebPEncodeLosslessBGRA(const uint8_t* bgra,
    5.76 +                                           int width, int height, int stride,
    5.77 +                                           uint8_t** output);
    5.78 +
    5.79 +// Releases memory returned by the WebPEncode*() functions above.
    5.80 +WEBP_EXTERN(void) WebPFree(void* ptr);
    5.81 +
    5.82  //------------------------------------------------------------------------------
    5.83  // Coding parameters
    5.84  
    5.85 -typedef struct {
    5.86 -  float quality;         // between 0 (smallest file) and 100 (biggest)
    5.87 -  int target_size;       // if non-zero, set the desired target size in bytes.
    5.88 -                         // Takes precedence over the 'compression' parameter.
    5.89 -  float target_PSNR;     // if non-zero, specifies the minimal distortion to
    5.90 -                         // try to achieve. Takes precedence over target_size.
    5.91 -  int method;            // quality/speed trade-off (0=fast, 6=slower-better)
    5.92 -  int segments;          // maximum number of segments to use, in [1..4]
    5.93 -  int sns_strength;      // Spatial Noise Shaping. 0=off, 100=maximum.
    5.94 -  int filter_strength;   // range: [0 = off .. 100 = strongest]
    5.95 -  int filter_sharpness;  // range: [0 = off .. 7 = least sharp]
    5.96 -  int filter_type;       // filtering type: 0 = simple, 1 = strong
    5.97 -                         // (only used if filter_strength > 0 or autofilter > 0)
    5.98 -  int autofilter;        // Auto adjust filter's strength [0 = off, 1 = on]
    5.99 -  int pass;              // number of entropy-analysis passes (in [1..10]).
   5.100 +// Image characteristics hint for the underlying encoder.
   5.101 +typedef enum WebPImageHint {
   5.102 +  WEBP_HINT_DEFAULT = 0,  // default preset.
   5.103 +  WEBP_HINT_PICTURE,      // digital picture, like portrait, inner shot
   5.104 +  WEBP_HINT_PHOTO,        // outdoor photograph, with natural lighting
   5.105 +  WEBP_HINT_GRAPH,        // Discrete tone image (graph, map-tile etc).
   5.106 +  WEBP_HINT_LAST
   5.107 +} WebPImageHint;
   5.108  
   5.109 -  int show_compressed;   // if true, export the compressed picture back.
   5.110 -                         // In-loop filtering is not applied.
   5.111 -  int preprocessing;     // preprocessing filter (0=none, 1=segment-smooth)
   5.112 -  int partitions;        // log2(number of token partitions) in [0..3]
   5.113 -                         // Default is set to 0 for easier progressive decoding.
   5.114 -  int partition_limit;   // quality degradation allowed to fit the 512k limit on
   5.115 -                         // prediction modes coding (0=no degradation, 100=full)
   5.116 +// Compression parameters.
   5.117 +struct WebPConfig {
   5.118 +  int lossless;           // Lossless encoding (0=lossy(default), 1=lossless).
   5.119 +  float quality;          // between 0 (smallest file) and 100 (biggest)
   5.120 +  int method;             // quality/speed trade-off (0=fast, 6=slower-better)
   5.121 +
   5.122 +  WebPImageHint image_hint;  // Hint for image type (lossless only for now).
   5.123 +
   5.124 +  // Parameters related to lossy compression only:
   5.125 +  int target_size;        // if non-zero, set the desired target size in bytes.
   5.126 +                          // Takes precedence over the 'compression' parameter.
   5.127 +  float target_PSNR;      // if non-zero, specifies the minimal distortion to
   5.128 +                          // try to achieve. Takes precedence over target_size.
   5.129 +  int segments;           // maximum number of segments to use, in [1..4]
   5.130 +  int sns_strength;       // Spatial Noise Shaping. 0=off, 100=maximum.
   5.131 +  int filter_strength;    // range: [0 = off .. 100 = strongest]
   5.132 +  int filter_sharpness;   // range: [0 = off .. 7 = least sharp]
   5.133 +  int filter_type;        // filtering type: 0 = simple, 1 = strong (only used
   5.134 +                          // if filter_strength > 0 or autofilter > 0)
   5.135 +  int autofilter;         // Auto adjust filter's strength [0 = off, 1 = on]
   5.136    int alpha_compression;  // Algorithm for encoding the alpha plane (0 = none,
   5.137 -                          // 1 = backward reference counts encoded with
   5.138 -                          // arithmetic encoder). Default is 1.
   5.139 +                          // 1 = compressed with WebP lossless). Default is 1.
   5.140 +  int alpha_filtering;    // Predictive filtering method for alpha plane.
   5.141 +                          //  0: none, 1: fast, 2: best. Default if 1.
   5.142    int alpha_quality;      // Between 0 (smallest size) and 100 (lossless).
   5.143                            // Default is 100.
   5.144 -} WebPConfig;
   5.145 +  int pass;               // number of entropy-analysis passes (in [1..10]).
   5.146 +
   5.147 +  int show_compressed;    // if true, export the compressed picture back.
   5.148 +                          // In-loop filtering is not applied.
   5.149 +  int preprocessing;      // preprocessing filter:
   5.150 +                          // 0=none, 1=segment-smooth, 2=pseudo-random dithering
   5.151 +  int partitions;         // log2(number of token partitions) in [0..3]. Default
   5.152 +                          // is set to 0 for easier progressive decoding.
   5.153 +  int partition_limit;    // quality degradation allowed to fit the 512k limit
   5.154 +                          // on prediction modes coding (0: no degradation,
   5.155 +                          // 100: maximum possible degradation).
   5.156 +  int emulate_jpeg_size;  // If true, compression parameters will be remapped
   5.157 +                          // to better match the expected output size from
   5.158 +                          // JPEG compression. Generally, the output size will
   5.159 +                          // be similar but the degradation will be lower.
   5.160 +  int thread_level;       // If non-zero, try and use multi-threaded encoding.
   5.161 +  int low_memory;         // If set, reduce memory usage (but increase CPU use).
   5.162 +
   5.163 +  int near_lossless;      // Near lossless encoding [0 = max loss .. 100 = off
   5.164 +                          // (default)].
   5.165 +  int exact;              // if non-zero, preserve the exact RGB values under
   5.166 +                          // transparent area. Otherwise, discard this invisible
   5.167 +                          // RGB information for better compression. The default
   5.168 +                          // value is 0.
   5.169 +
   5.170 +  int use_delta_palette;  // reserved for future lossless feature
   5.171 +  int use_sharp_yuv;      // if needed, use sharp (and slow) RGB->YUV conversion
   5.172 +
   5.173 +  uint32_t pad[2];        // padding for later use
   5.174 +};
   5.175  
   5.176  // Enumerate some predefined settings for WebPConfig, depending on the type
   5.177  // of source picture. These presets are used when calling WebPConfigPreset().
   5.178 -typedef enum {
   5.179 +typedef enum WebPPreset {
   5.180    WEBP_PRESET_DEFAULT = 0,  // default preset.
   5.181    WEBP_PRESET_PICTURE,      // digital picture, like portrait, inner shot
   5.182    WEBP_PRESET_PHOTO,        // outdoor photograph, with natural lighting
   5.183 @@ -90,13 +159,13 @@
   5.184  } WebPPreset;
   5.185  
   5.186  // Internal, version-checked, entry point
   5.187 -WEBP_EXTERN(int) WebPConfigInitInternal(
   5.188 -    WebPConfig* const, WebPPreset, float, int);
   5.189 +WEBP_EXTERN(int) WebPConfigInitInternal(WebPConfig*, WebPPreset, float, int);
   5.190  
   5.191  // Should always be called, to initialize a fresh WebPConfig structure before
   5.192 -// modification. Returns 0 in case of version mismatch. WebPConfigInit() must
   5.193 -// have succeeded before using the 'config' object.
   5.194 -static WEBP_INLINE int WebPConfigInit(WebPConfig* const config) {
   5.195 +// modification. Returns false in case of version mismatch. WebPConfigInit()
   5.196 +// must have succeeded before using the 'config' object.
   5.197 +// Note that the default values are lossless=0 and quality=75.
   5.198 +static WEBP_INLINE int WebPConfigInit(WebPConfig* config) {
   5.199    return WebPConfigInitInternal(config, WEBP_PRESET_DEFAULT, 75.f,
   5.200                                  WEBP_ENCODER_ABI_VERSION);
   5.201  }
   5.202 @@ -104,25 +173,33 @@
   5.203  // This function will initialize the configuration according to a predefined
   5.204  // set of parameters (referred to by 'preset') and a given quality factor.
   5.205  // This function can be called as a replacement to WebPConfigInit(). Will
   5.206 -// return 0 in case of error.
   5.207 -static WEBP_INLINE int WebPConfigPreset(WebPConfig* const config,
   5.208 +// return false in case of error.
   5.209 +static WEBP_INLINE int WebPConfigPreset(WebPConfig* config,
   5.210                                          WebPPreset preset, float quality) {
   5.211    return WebPConfigInitInternal(config, preset, quality,
   5.212                                  WEBP_ENCODER_ABI_VERSION);
   5.213  }
   5.214  
   5.215 -// Returns 1 if all parameters are in valid range and the configuration is OK.
   5.216 -WEBP_EXTERN(int) WebPValidateConfig(const WebPConfig* const config);
   5.217 +// Activate the lossless compression mode with the desired efficiency level
   5.218 +// between 0 (fastest, lowest compression) and 9 (slower, best compression).
   5.219 +// A good default level is '6', providing a fair tradeoff between compression
   5.220 +// speed and final compressed size.
   5.221 +// This function will overwrite several fields from config: 'method', 'quality'
   5.222 +// and 'lossless'. Returns false in case of parameter error.
   5.223 +WEBP_EXTERN(int) WebPConfigLosslessPreset(WebPConfig* config, int level);
   5.224 +
   5.225 +// Returns true if 'config' is non-NULL and all configuration parameters are
   5.226 +// within their valid ranges.
   5.227 +WEBP_EXTERN(int) WebPValidateConfig(const WebPConfig* config);
   5.228  
   5.229  //------------------------------------------------------------------------------
   5.230  // Input / Output
   5.231 +// Structure for storing auxiliary statistics (mostly for lossy encoding).
   5.232  
   5.233 -typedef struct WebPPicture WebPPicture;   // main structure for I/O
   5.234 +struct WebPAuxStats {
   5.235 +  int coded_size;         // final size
   5.236  
   5.237 -// non-essential structure for storing auxiliary statistics
   5.238 -typedef struct {
   5.239 -  float PSNR[4];          // peak-signal-to-noise ratio for Y/U/V/All
   5.240 -  int coded_size;         // final size
   5.241 +  float PSNR[5];          // peak-signal-to-noise ratio for Y/U/V/All/Alpha
   5.242    int block_count[3];     // number of intra4/intra16/skipped macroblocks
   5.243    int header_bytes[2];    // approximate number of bytes spent for header
   5.244                            // and mode-partition #0
   5.245 @@ -135,37 +212,63 @@
   5.246    int alpha_data_size;    // size of the transparency data
   5.247    int layer_data_size;    // size of the enhancement layer data
   5.248  
   5.249 -  void* user_data;        // this field is free to be set to any value and
   5.250 -                          // used during callbacks (like progress-report e.g.).
   5.251 -} WebPAuxStats;
   5.252 +  // lossless encoder statistics
   5.253 +  uint32_t lossless_features;  // bit0:predictor bit1:cross-color transform
   5.254 +                               // bit2:subtract-green bit3:color indexing
   5.255 +  int histogram_bits;          // number of precision bits of histogram
   5.256 +  int transform_bits;          // precision bits for transform
   5.257 +  int cache_bits;              // number of bits for color cache lookup
   5.258 +  int palette_size;            // number of color in palette, if used
   5.259 +  int lossless_size;           // final lossless size
   5.260 +  int lossless_hdr_size;       // lossless header (transform, huffman etc) size
   5.261 +  int lossless_data_size;      // lossless image data size
   5.262  
   5.263 -// Signature for output function. Should return 1 if writing was successful.
   5.264 +  uint32_t pad[2];        // padding for later use
   5.265 +};
   5.266 +
   5.267 +// Signature for output function. Should return true if writing was successful.
   5.268  // data/data_size is the segment of data to write, and 'picture' is for
   5.269  // reference (and so one can make use of picture->custom_ptr).
   5.270  typedef int (*WebPWriterFunction)(const uint8_t* data, size_t data_size,
   5.271 -                                  const WebPPicture* const picture);
   5.272 +                                  const WebPPicture* picture);
   5.273  
   5.274 -// Progress hook, called from time to time to report progress. It can return 0
   5.275 -// to request an abort of the encoding process, or 1 otherwise if all is OK.
   5.276 -typedef int (*WebPProgressHook)(int percent, const WebPPicture* const picture);
   5.277 +// WebPMemoryWrite: a special WebPWriterFunction that writes to memory using
   5.278 +// the following WebPMemoryWriter object (to be set as a custom_ptr).
   5.279 +struct WebPMemoryWriter {
   5.280 +  uint8_t* mem;       // final buffer (of size 'max_size', larger than 'size').
   5.281 +  size_t   size;      // final size
   5.282 +  size_t   max_size;  // total capacity
   5.283 +  uint32_t pad[1];    // padding for later use
   5.284 +};
   5.285  
   5.286 -typedef enum {
   5.287 +// The following must be called first before any use.
   5.288 +WEBP_EXTERN(void) WebPMemoryWriterInit(WebPMemoryWriter* writer);
   5.289 +
   5.290 +// The following must be called to deallocate writer->mem memory. The 'writer'
   5.291 +// object itself is not deallocated.
   5.292 +WEBP_EXTERN(void) WebPMemoryWriterClear(WebPMemoryWriter* writer);
   5.293 +// The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon
   5.294 +// completion, writer.mem and writer.size will hold the coded data.
   5.295 +// writer.mem must be freed by calling WebPMemoryWriterClear.
   5.296 +WEBP_EXTERN(int) WebPMemoryWrite(const uint8_t* data, size_t data_size,
   5.297 +                                 const WebPPicture* picture);
   5.298 +
   5.299 +// Progress hook, called from time to time to report progress. It can return
   5.300 +// false to request an abort of the encoding process, or true otherwise if
   5.301 +// everything is OK.
   5.302 +typedef int (*WebPProgressHook)(int percent, const WebPPicture* picture);
   5.303 +
   5.304 +// Color spaces.
   5.305 +typedef enum WebPEncCSP {
   5.306    // chroma sampling
   5.307 -  WEBP_YUV420 = 0,   // 4:2:0
   5.308 -  WEBP_YUV422 = 1,   // 4:2:2
   5.309 -  WEBP_YUV444 = 2,   // 4:4:4
   5.310 -  WEBP_YUV400 = 3,   // grayscale
   5.311 -  WEBP_CSP_UV_MASK = 3,   // bit-mask to get the UV sampling factors
   5.312 -  // alpha channel variants
   5.313 -  WEBP_YUV420A = 4,
   5.314 -  WEBP_YUV422A = 5,
   5.315 -  WEBP_YUV444A = 6,
   5.316 -  WEBP_YUV400A = 7,   // grayscale + alpha
   5.317 +  WEBP_YUV420  = 0,        // 4:2:0
   5.318 +  WEBP_YUV420A = 4,        // alpha channel variant
   5.319 +  WEBP_CSP_UV_MASK = 3,    // bit-mask to get the UV sampling factors
   5.320    WEBP_CSP_ALPHA_BIT = 4   // bit that is set if alpha is present
   5.321  } WebPEncCSP;
   5.322  
   5.323  // Encoding error conditions.
   5.324 -typedef enum {
   5.325 +typedef enum WebPEncodingError {
   5.326    VP8_ENC_OK = 0,
   5.327    VP8_ENC_ERROR_OUT_OF_MEMORY,            // memory error allocating objects
   5.328    VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY,  // memory error while flushing bits
   5.329 @@ -183,20 +286,37 @@
   5.330  // maximum width/height allowed (inclusive), in pixels
   5.331  #define WEBP_MAX_DIMENSION 16383
   5.332  
   5.333 +// Main exchange structure (input samples, output bytes, statistics)
   5.334  struct WebPPicture {
   5.335 -  // input
   5.336 +  //   INPUT
   5.337 +  //////////////
   5.338 +  // Main flag for encoder selecting between ARGB or YUV input.
   5.339 +  // It is recommended to use ARGB input (*argb, argb_stride) for lossless
   5.340 +  // compression, and YUV input (*y, *u, *v, etc.) for lossy compression
   5.341 +  // since these are the respective native colorspace for these formats.
   5.342 +  int use_argb;
   5.343 +
   5.344 +  // YUV input (mostly used for input to lossy compression)
   5.345    WebPEncCSP colorspace;     // colorspace: should be YUV420 for now (=Y'CbCr).
   5.346    int width, height;         // dimensions (less or equal to WEBP_MAX_DIMENSION)
   5.347    uint8_t *y, *u, *v;        // pointers to luma/chroma planes.
   5.348    int y_stride, uv_stride;   // luma/chroma strides.
   5.349 -  uint8_t *a;                // pointer to the alpha plane
   5.350 +  uint8_t* a;                // pointer to the alpha plane
   5.351    int a_stride;              // stride of the alpha plane
   5.352 +  uint32_t pad1[2];          // padding for later use
   5.353  
   5.354 -  // output
   5.355 +  // ARGB input (mostly used for input to lossless compression)
   5.356 +  uint32_t* argb;            // Pointer to argb (32 bit) plane.
   5.357 +  int argb_stride;           // This is stride in pixels units, not bytes.
   5.358 +  uint32_t pad2[3];          // padding for later use
   5.359 +
   5.360 +  //   OUTPUT
   5.361 +  ///////////////
   5.362 +  // Byte-emission hook, to store compressed bytes as they are ready.
   5.363    WebPWriterFunction writer;  // can be NULL
   5.364    void* custom_ptr;           // can be used by the writer.
   5.365  
   5.366 -  // map for extra information
   5.367 +  // map for extra information (only for lossy compression mode)
   5.368    int extra_info_type;    // 1: intra type, 2: segment, 3: quant
   5.369                            // 4: intra-16 prediction mode,
   5.370                            // 5: chroma prediction mode,
   5.371 @@ -206,25 +326,41 @@
   5.372                            // will be filled with a macroblock map, depending
   5.373                            // on extra_info_type.
   5.374  
   5.375 -  // where to store statistics, if not NULL:
   5.376 +  //   STATS AND REPORTS
   5.377 +  ///////////////////////////
   5.378 +  // Pointer to side statistics (updated only if not NULL)
   5.379    WebPAuxStats* stats;
   5.380  
   5.381 -  // original samples (for non-YUV420 modes)
   5.382 -  uint8_t *u0, *v0;
   5.383 -  int uv0_stride;
   5.384 +  // Error code for the latest error encountered during encoding
   5.385 +  WebPEncodingError error_code;
   5.386  
   5.387 -  WebPEncodingError error_code;   // error code in case of problem.
   5.388 +  // If not NULL, report progress during encoding.
   5.389 +  WebPProgressHook progress_hook;
   5.390  
   5.391 -  WebPProgressHook progress_hook;  // if not NULL, called while encoding.
   5.392 +  void* user_data;        // this field is free to be set to any value and
   5.393 +                          // used during callbacks (like progress-report e.g.).
   5.394 +
   5.395 +  uint32_t pad3[3];       // padding for later use
   5.396 +
   5.397 +  // Unused for now
   5.398 +  uint8_t *pad4, *pad5;
   5.399 +  uint32_t pad6[8];       // padding for later use
   5.400 +
   5.401 +  // PRIVATE FIELDS
   5.402 +  ////////////////////
   5.403 +  void* memory_;          // row chunk of memory for yuva planes
   5.404 +  void* memory_argb_;     // and for argb too.
   5.405 +  void* pad7[2];          // padding for later use
   5.406  };
   5.407  
   5.408  // Internal, version-checked, entry point
   5.409 -WEBP_EXTERN(int) WebPPictureInitInternal(WebPPicture* const, int);
   5.410 +WEBP_EXTERN(int) WebPPictureInitInternal(WebPPicture*, int);
   5.411  
   5.412 -// Should always be called, to initialize the structure. Returns 0 in case of
   5.413 -// version mismatch. WebPPictureInit() must have succeeded before using the
   5.414 +// Should always be called, to initialize the structure. Returns false in case
   5.415 +// of version mismatch. WebPPictureInit() must have succeeded before using the
   5.416  // 'picture' object.
   5.417 -static WEBP_INLINE int WebPPictureInit(WebPPicture* const picture) {
   5.418 +// Note that, by default, use_argb is false and colorspace is WEBP_YUV420.
   5.419 +static WEBP_INLINE int WebPPictureInit(WebPPicture* picture) {
   5.420    return WebPPictureInitInternal(picture, WEBP_ENCODER_ABI_VERSION);
   5.421  }
   5.422  
   5.423 @@ -234,45 +370,153 @@
   5.424  // Convenience allocation / deallocation based on picture->width/height:
   5.425  // Allocate y/u/v buffers as per colorspace/width/height specification.
   5.426  // Note! This function will free the previous buffer if needed.
   5.427 -// Returns 0 in case of memory error.
   5.428 -WEBP_EXTERN(int) WebPPictureAlloc(WebPPicture* const picture);
   5.429 +// Returns false in case of memory error.
   5.430 +WEBP_EXTERN(int) WebPPictureAlloc(WebPPicture* picture);
   5.431  
   5.432 -// Release memory allocated by WebPPictureAlloc() or WebPPictureImport*()
   5.433 -// Note that this function does _not_ free the memory pointed to by 'picture'.
   5.434 -WEBP_EXTERN(void) WebPPictureFree(WebPPicture* const picture);
   5.435 +// Release the memory allocated by WebPPictureAlloc() or WebPPictureImport*().
   5.436 +// Note that this function does _not_ free the memory used by the 'picture'
   5.437 +// object itself.
   5.438 +// Besides memory (which is reclaimed) all other fields of 'picture' are
   5.439 +// preserved.
   5.440 +WEBP_EXTERN(void) WebPPictureFree(WebPPicture* picture);
   5.441  
   5.442 -// Copy the pixels of *src into *dst, using WebPPictureAlloc.
   5.443 -// Returns 0 in case of memory allocation error.
   5.444 -WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* const src,
   5.445 -                                 WebPPicture* const dst);
   5.446 +// Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return, *dst
   5.447 +// will fully own the copied pixels (this is not a view). The 'dst' picture need
   5.448 +// not be initialized as its content is overwritten.
   5.449 +// Returns false in case of memory allocation error.
   5.450 +WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* src, WebPPicture* dst);
   5.451 +
   5.452 +// Compute the single distortion for packed planes of samples.
   5.453 +// 'src' will be compared to 'ref', and the raw distortion stored into
   5.454 +// '*distortion'. The refined metric (log(MSE), log(1 - ssim),...' will be
   5.455 +// stored in '*result'.
   5.456 +// 'x_step' is the horizontal stride (in bytes) between samples.
   5.457 +// 'src/ref_stride' is the byte distance between rows.
   5.458 +// Returns false in case of error (bad parameter, memory allocation error, ...).
   5.459 +WEBP_EXTERN(int) WebPPlaneDistortion(const uint8_t* src, size_t src_stride,
   5.460 +                                     const uint8_t* ref, size_t ref_stride,
   5.461 +                                     int width, int height,
   5.462 +                                     size_t x_step,
   5.463 +                                     int type,   // 0 = PSNR, 1 = SSIM, 2 = LSIM
   5.464 +                                     float* distortion, float* result);
   5.465 +
   5.466 +// Compute PSNR, SSIM or LSIM distortion metric between two pictures. Results
   5.467 +// are in dB, stored in result[] in the B/G/R/A/All order. The distortion is
   5.468 +// always performed using ARGB samples. Hence if the input is YUV(A), the
   5.469 +// picture will be internally converted to ARGB (just for the measurement).
   5.470 +// Warning: this function is rather CPU-intensive.
   5.471 +WEBP_EXTERN(int) WebPPictureDistortion(
   5.472 +    const WebPPicture* src, const WebPPicture* ref,
   5.473 +    int metric_type,           // 0 = PSNR, 1 = SSIM, 2 = LSIM
   5.474 +    float result[5]);
   5.475  
   5.476  // self-crops a picture to the rectangle defined by top/left/width/height.
   5.477 -// Returns 0 in case of memory allocation error, or if the rectangle is
   5.478 +// Returns false in case of memory allocation error, or if the rectangle is
   5.479  // outside of the source picture.
   5.480 -WEBP_EXTERN(int) WebPPictureCrop(WebPPicture* const picture,
   5.481 +// The rectangle for the view is defined by the top-left corner pixel
   5.482 +// coordinates (left, top) as well as its width and height. This rectangle
   5.483 +// must be fully be comprised inside the 'src' source picture. If the source
   5.484 +// picture uses the YUV420 colorspace, the top and left coordinates will be
   5.485 +// snapped to even values.
   5.486 +WEBP_EXTERN(int) WebPPictureCrop(WebPPicture* picture,
   5.487                                   int left, int top, int width, int height);
   5.488  
   5.489 +// Extracts a view from 'src' picture into 'dst'. The rectangle for the view
   5.490 +// is defined by the top-left corner pixel coordinates (left, top) as well
   5.491 +// as its width and height. This rectangle must be fully be comprised inside
   5.492 +// the 'src' source picture. If the source picture uses the YUV420 colorspace,
   5.493 +// the top and left coordinates will be snapped to even values.
   5.494 +// Picture 'src' must out-live 'dst' picture. Self-extraction of view is allowed
   5.495 +// ('src' equal to 'dst') as a mean of fast-cropping (but note that doing so,
   5.496 +// the original dimension will be lost). Picture 'dst' need not be initialized
   5.497 +// with WebPPictureInit() if it is different from 'src', since its content will
   5.498 +// be overwritten.
   5.499 +// Returns false in case of memory allocation error or invalid parameters.
   5.500 +WEBP_EXTERN(int) WebPPictureView(const WebPPicture* src,
   5.501 +                                 int left, int top, int width, int height,
   5.502 +                                 WebPPicture* dst);
   5.503 +
   5.504 +// Returns true if the 'picture' is actually a view and therefore does
   5.505 +// not own the memory for pixels.
   5.506 +WEBP_EXTERN(int) WebPPictureIsView(const WebPPicture* picture);
   5.507 +
   5.508  // Rescale a picture to new dimension width x height.
   5.509 -// Now gamma correction is applied.
   5.510 +// If either 'width' or 'height' (but not both) is 0 the corresponding
   5.511 +// dimension will be calculated preserving the aspect ratio.
   5.512 +// No gamma correction is applied.
   5.513  // Returns false in case of error (invalid parameter or insufficient memory).
   5.514 -WEBP_EXTERN(int) WebPPictureRescale(WebPPicture* const pic,
   5.515 -                                    int width, int height);
   5.516 +WEBP_EXTERN(int) WebPPictureRescale(WebPPicture* pic, int width, int height);
   5.517  
   5.518  // Colorspace conversion function to import RGB samples.
   5.519  // Previous buffer will be free'd, if any.
   5.520  // *rgb buffer should have a size of at least height * rgb_stride.
   5.521 -// Returns 0 in case of memory error.
   5.522 +// Returns false in case of memory error.
   5.523  WEBP_EXTERN(int) WebPPictureImportRGB(
   5.524 -    WebPPicture* const picture, const uint8_t* const rgb, int rgb_stride);
   5.525 -// Same, but for RGBA buffer
   5.526 +    WebPPicture* picture, const uint8_t* rgb, int rgb_stride);
   5.527 +// Same, but for RGBA buffer.
   5.528  WEBP_EXTERN(int) WebPPictureImportRGBA(
   5.529 -    WebPPicture* const picture, const uint8_t* const rgba, int rgba_stride);
   5.530 +    WebPPicture* picture, const uint8_t* rgba, int rgba_stride);
   5.531 +// Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format
   5.532 +// input buffer ignoring the alpha channel. Avoids needing to copy the data
   5.533 +// to a temporary 24-bit RGB buffer to import the RGB only.
   5.534 +WEBP_EXTERN(int) WebPPictureImportRGBX(
   5.535 +    WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride);
   5.536  
   5.537 -// Variant of the above, but taking BGR(A) input:
   5.538 +// Variants of the above, but taking BGR(A|X) input.
   5.539  WEBP_EXTERN(int) WebPPictureImportBGR(
   5.540 -    WebPPicture* const picture, const uint8_t* const bgr, int bgr_stride);
   5.541 +    WebPPicture* picture, const uint8_t* bgr, int bgr_stride);
   5.542  WEBP_EXTERN(int) WebPPictureImportBGRA(
   5.543 -    WebPPicture* const picture, const uint8_t* const bgra, int bgra_stride);
   5.544 +    WebPPicture* picture, const uint8_t* bgra, int bgra_stride);
   5.545 +WEBP_EXTERN(int) WebPPictureImportBGRX(
   5.546 +    WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride);
   5.547 +
   5.548 +// Converts picture->argb data to the YUV420A format. The 'colorspace'
   5.549 +// parameter is deprecated and should be equal to WEBP_YUV420.
   5.550 +// Upon return, picture->use_argb is set to false. The presence of real
   5.551 +// non-opaque transparent values is detected, and 'colorspace' will be
   5.552 +// adjusted accordingly. Note that this method is lossy.
   5.553 +// Returns false in case of error.
   5.554 +WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture,
   5.555 +                                       WebPEncCSP /*colorspace = WEBP_YUV420*/);
   5.556 +
   5.557 +// Same as WebPPictureARGBToYUVA(), but the conversion is done using
   5.558 +// pseudo-random dithering with a strength 'dithering' between
   5.559 +// 0.0 (no dithering) and 1.0 (maximum dithering). This is useful
   5.560 +// for photographic picture.
   5.561 +WEBP_EXTERN(int) WebPPictureARGBToYUVADithered(
   5.562 +    WebPPicture* picture, WebPEncCSP colorspace, float dithering);
   5.563 +
   5.564 +// Performs 'sharp' RGBA->YUVA420 downsampling and colorspace conversion.
   5.565 +// Downsampling is handled with extra care in case of color clipping. This
   5.566 +// method is roughly 2x slower than WebPPictureARGBToYUVA() but produces better
   5.567 +// and sharper YUV representation.
   5.568 +// Returns false in case of error.
   5.569 +WEBP_EXTERN(int) WebPPictureSharpARGBToYUVA(WebPPicture* picture);
   5.570 +// kept for backward compatibility:
   5.571 +WEBP_EXTERN(int) WebPPictureSmartARGBToYUVA(WebPPicture* picture);
   5.572 +
   5.573 +// Converts picture->yuv to picture->argb and sets picture->use_argb to true.
   5.574 +// The input format must be YUV_420 or YUV_420A. The conversion from YUV420 to
   5.575 +// ARGB incurs a small loss too.
   5.576 +// Note that the use of this colorspace is discouraged if one has access to the
   5.577 +// raw ARGB samples, since using YUV420 is comparatively lossy.
   5.578 +// Returns false in case of error.
   5.579 +WEBP_EXTERN(int) WebPPictureYUVAToARGB(WebPPicture* picture);
   5.580 +
   5.581 +// Helper function: given a width x height plane of RGBA or YUV(A) samples
   5.582 +// clean-up the YUV or RGB samples under fully transparent area, to help
   5.583 +// compressibility (no guarantee, though).
   5.584 +WEBP_EXTERN(void) WebPCleanupTransparentArea(WebPPicture* picture);
   5.585 +
   5.586 +// Scan the picture 'picture' for the presence of non fully opaque alpha values.
   5.587 +// Returns true in such case. Otherwise returns false (indicating that the
   5.588 +// alpha plane can be ignored altogether e.g.).
   5.589 +WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* picture);
   5.590 +
   5.591 +// Remove the transparency information (if present) by blending the color with
   5.592 +// the background color 'background_rgb' (specified as 24bit RGB triplet).
   5.593 +// After this call, all alpha values are reset to 0xff.
   5.594 +WEBP_EXTERN(void) WebPBlendAlpha(WebPPicture* pic, uint32_t background_rgb);
   5.595  
   5.596  //------------------------------------------------------------------------------
   5.597  // Main call
   5.598 @@ -282,12 +526,16 @@
   5.599  // and the 'config' object must be a valid one.
   5.600  // Returns false in case of error, true otherwise.
   5.601  // In case of error, picture->error_code is updated accordingly.
   5.602 -WEBP_EXTERN(int) WebPEncode(
   5.603 -    const WebPConfig* const config, WebPPicture* const picture);
   5.604 +// 'picture' can hold the source samples in both YUV(A) or ARGB input, depending
   5.605 +// on the value of 'picture->use_argb'. It is highly recommended to use
   5.606 +// the former for lossy encoding, and the latter for lossless encoding
   5.607 +// (when config.lossless is true). Automatic conversion from one format to
   5.608 +// another is provided but they both incur some loss.
   5.609 +WEBP_EXTERN(int) WebPEncode(const WebPConfig* config, WebPPicture* picture);
   5.610  
   5.611  //------------------------------------------------------------------------------
   5.612  
   5.613 -#if defined(__cplusplus) || defined(c_plusplus)
   5.614 +#ifdef __cplusplus
   5.615  }    // extern "C"
   5.616  #endif
   5.617  
     6.1 --- a/VisualC/external/include/webp/mux.h	Tue Oct 16 20:02:02 2018 +0300
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,467 +0,0 @@
     6.4 -// Copyright 2011 Google Inc.
     6.5 -//
     6.6 -// This code is licensed under the same terms as WebM:
     6.7 -//  Software License Agreement:  http://www.webmproject.org/license/software/
     6.8 -//  Additional IP Rights Grant:  http://www.webmproject.org/license/additional/
     6.9 -// -----------------------------------------------------------------------------
    6.10 -//
    6.11 -//  RIFF container manipulation for WEBP images.
    6.12 -//
    6.13 -// Authors: Urvang (urvang@google.com)
    6.14 -//          Vikas (vikasa@google.com)
    6.15 -
    6.16 -// This API allows manipulation of WebP container images containing features
    6.17 -// like Color profile, XMP metadata, Animation & Tiling.
    6.18 -//
    6.19 -// Code Example#1: Creating a MUX with image data, color profile & XMP metadata.
    6.20 -//
    6.21 -//   int copy_data = 0;
    6.22 -//   WebPMux* mux = WebPMuxNew();
    6.23 -//   // ... (Prepare image data).
    6.24 -//   WebPMuxSetImage(mux, image_data, image_data_size, alpha_data, alpha_size,
    6.25 -//                   copy_data);
    6.26 -//   // ... (Prepare ICCP color profile data).
    6.27 -//   WebPMuxSetColorProfile(mux, icc_data, icc_data_size, copy_data);
    6.28 -//   // ... (Prepare XMP metadata).
    6.29 -//   WebPMuxSetMetadata(mux, xmp_data, xmp_data_size, copy_data);
    6.30 -//   // Get data from mux in WebP RIFF format.
    6.31 -//   WebPMuxAssemble(mux, &output_data, &output_data_size);
    6.32 -//   WebPMuxDelete(mux);
    6.33 -//   // ... (Consume output_data; e.g. write output_data to file).
    6.34 -//   free(output_data);
    6.35 -//
    6.36 -// Code Example#2: Get image & color profile data from a WebP file.
    6.37 -//
    6.38 -//   int copy_data = 0;
    6.39 -//   // ... (Read data from file).
    6.40 -//   WebPMux* mux = WebPMuxCreate(data, data_size, copy_data);
    6.41 -//   WebPMuxGetImage(mux, &image_data, &image_data_size,
    6.42 -//                   &alpha_data, &alpha_size);
    6.43 -//   // ... (Consume image_data; e.g. call WebPDecode() to decode the data).
    6.44 -//   WebPMuxGetColorProfile(mux, &icc_data, &icc_data_size);
    6.45 -//   // ... (Consume icc_data).
    6.46 -//   WebPMuxDelete(mux);
    6.47 -//   free(data);
    6.48 -
    6.49 -#ifndef WEBP_WEBP_MUX_H_
    6.50 -#define WEBP_WEBP_MUX_H_
    6.51 -
    6.52 -#include "./types.h"
    6.53 -
    6.54 -#if defined(__cplusplus) || defined(c_plusplus)
    6.55 -extern "C" {
    6.56 -#endif
    6.57 -
    6.58 -// Error codes
    6.59 -typedef enum {
    6.60 -  WEBP_MUX_OK                 =  1,
    6.61 -  WEBP_MUX_ERROR              =  0,
    6.62 -  WEBP_MUX_NOT_FOUND          = -1,
    6.63 -  WEBP_MUX_INVALID_ARGUMENT   = -2,
    6.64 -  WEBP_MUX_INVALID_PARAMETER  = -3,
    6.65 -  WEBP_MUX_BAD_DATA           = -4,
    6.66 -  WEBP_MUX_MEMORY_ERROR       = -5
    6.67 -} WebPMuxError;
    6.68 -
    6.69 -// Flag values for different features used in VP8X chunk.
    6.70 -typedef enum {
    6.71 -  TILE_FLAG       = 0x00000001,
    6.72 -  ANIMATION_FLAG  = 0x00000002,
    6.73 -  ICCP_FLAG       = 0x00000004,
    6.74 -  META_FLAG       = 0x00000008,
    6.75 -  ALPHA_FLAG      = 0x00000010
    6.76 -} FeatureFlags;
    6.77 -
    6.78 -typedef struct WebPMux WebPMux;   // main opaque object.
    6.79 -
    6.80 -//------------------------------------------------------------------------------
    6.81 -// Life of a Mux object
    6.82 -
    6.83 -// Creates an empty mux object.
    6.84 -// Returns:
    6.85 -//   A pointer to the newly created empty mux object.
    6.86 -WEBP_EXTERN(WebPMux*) WebPMuxNew(void);
    6.87 -
    6.88 -// Deletes the mux object.
    6.89 -// Parameters:
    6.90 -//   mux - (in/out) object to be deleted
    6.91 -WEBP_EXTERN(void) WebPMuxDelete(WebPMux* const mux);
    6.92 -
    6.93 -//------------------------------------------------------------------------------
    6.94 -// Mux creation.
    6.95 -
    6.96 -// Creates a mux object from raw data given in WebP RIFF format.
    6.97 -// Parameters:
    6.98 -//   data - (in) the raw data in WebP RIFF format
    6.99 -//   size - (in) size of raw data
   6.100 -//   copy_data - (in) value 1 indicates given data WILL copied to the mux, and
   6.101 -//               value 0 indicates data will NOT be copied.
   6.102 -// Returns:
   6.103 -//   A pointer to the mux object created from given data - on success.
   6.104 -//   NULL - In case of invalid data or memory error.
   6.105 -WEBP_EXTERN(WebPMux*) WebPMuxCreate(const uint8_t* data, uint32_t size,
   6.106 -                                    int copy_data);
   6.107 -
   6.108 -//------------------------------------------------------------------------------
   6.109 -// Single Image.
   6.110 -
   6.111 -// Sets the image in the mux object. Any existing images (including frame/tile)
   6.112 -// will be removed.
   6.113 -// Parameters:
   6.114 -//   mux - (in/out) object in which the image is to be set
   6.115 -//   data - (in) the image data to be set. The data can be either a VP8
   6.116 -//          bitstream or a single-image WebP file (non-animated & non-tiled)
   6.117 -//   size - (in) size of the image data
   6.118 -//   alpha_data - (in) the alpha data corresponding to the image (if present)
   6.119 -//   alpha_size - (in) size of alpha chunk data
   6.120 -//   copy_data - (in) value 1 indicates given data WILL copied to the mux, and
   6.121 -//               value 0 indicates data will NOT be copied.
   6.122 -// Returns:
   6.123 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or data is NULL.
   6.124 -//   WEBP_MUX_MEMORY_ERROR - on memory allocation error.
   6.125 -//   WEBP_MUX_OK - on success.
   6.126 -WEBP_EXTERN(WebPMuxError) WebPMuxSetImage(WebPMux* const mux,
   6.127 -                                          const uint8_t* data, uint32_t size,
   6.128 -                                          const uint8_t* alpha_data,
   6.129 -                                          uint32_t alpha_size, int copy_data);
   6.130 -
   6.131 -// Gets a reference to the image in the mux object.
   6.132 -// The caller should NOT free the returned data.
   6.133 -// Parameters:
   6.134 -//   mux - (in) object from which the image is to be fetched
   6.135 -//   data - (out) the returned image data
   6.136 -//   size - (out) size of the returned image data
   6.137 -//   alpha_data - (in) the returned alpha data of the image (if present)
   6.138 -//   alpha_size - (in) size of alpha chunk data
   6.139 -// Returns:
   6.140 -//   WEBP_MUX_INVALID_ARGUMENT - if either of mux, data or size is NULL
   6.141 -//                               OR if mux contains animation/tiling.
   6.142 -//   WEBP_MUX_NOT_FOUND - if image is not present in mux object.
   6.143 -//   WEBP_MUX_OK - on success.
   6.144 -WEBP_EXTERN(WebPMuxError) WebPMuxGetImage(const WebPMux* const mux,
   6.145 -                                          const uint8_t** data, uint32_t* size,
   6.146 -                                          const uint8_t** alpha_data,
   6.147 -                                          uint32_t* alpha_size);
   6.148 -
   6.149 -// Deletes the image in the mux object.
   6.150 -// Parameters:
   6.151 -//   mux - (in/out) object from which the image is to be deleted
   6.152 -// Returns:
   6.153 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
   6.154 -//                               OR if mux contains animation/tiling.
   6.155 -//   WEBP_MUX_NOT_FOUND - if image is not present in mux object.
   6.156 -//   WEBP_MUX_OK - on success.
   6.157 -WEBP_EXTERN(WebPMuxError) WebPMuxDeleteImage(WebPMux* const mux);
   6.158 -
   6.159 -//------------------------------------------------------------------------------
   6.160 -// XMP Metadata.
   6.161 -
   6.162 -// Sets the XMP metadata in the mux object. Any existing metadata chunk(s) will
   6.163 -// be removed.
   6.164 -// Parameters:
   6.165 -//   mux - (in/out) object to which the XMP metadata is to be added
   6.166 -//   data - (in) the XMP metadata data to be added
   6.167 -//   size - (in) size of the XMP metadata data
   6.168 -//   copy_data - (in) value 1 indicates given data WILL copied to the mux, and
   6.169 -//               value 0 indicates data will NOT be copied.
   6.170 -// Returns:
   6.171 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or data is NULL.
   6.172 -//   WEBP_MUX_MEMORY_ERROR - on memory allocation error.
   6.173 -//   WEBP_MUX_OK - on success.
   6.174 -WEBP_EXTERN(WebPMuxError) WebPMuxSetMetadata(WebPMux* const mux,
   6.175 -                                             const uint8_t* data,
   6.176 -                                             uint32_t size, int copy_data);
   6.177 -
   6.178 -// Gets a reference to the XMP metadata in the mux object.
   6.179 -// The caller should NOT free the returned data.
   6.180 -// Parameters:
   6.181 -//   mux - (in) object from which the XMP metadata is to be fetched
   6.182 -//   data - (out) the returned XMP metadata
   6.183 -//   size - (out) size of the returned XMP metadata
   6.184 -// Returns:
   6.185 -//   WEBP_MUX_INVALID_ARGUMENT - if either of mux, data or size is NULL
   6.186 -//   WEBP_MUX_NOT_FOUND - if metadata is not present in mux object.
   6.187 -//   WEBP_MUX_OK - on success.
   6.188 -WEBP_EXTERN(WebPMuxError) WebPMuxGetMetadata(const WebPMux* const mux,
   6.189 -                                             const uint8_t** data,
   6.190 -                                             uint32_t* size);
   6.191 -
   6.192 -// Deletes the XMP metadata in the mux object.
   6.193 -// Parameters:
   6.194 -//   mux - (in/out) object from which XMP metadata is to be deleted
   6.195 -// Returns:
   6.196 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
   6.197 -//   WEBP_MUX_NOT_FOUND - If mux does not contain metadata.
   6.198 -//   WEBP_MUX_OK - on success.
   6.199 -WEBP_EXTERN(WebPMuxError) WebPMuxDeleteMetadata(WebPMux* const mux);
   6.200 -
   6.201 -//------------------------------------------------------------------------------
   6.202 -// ICC Color Profile.
   6.203 -
   6.204 -// Sets the color profile in the mux object. Any existing color profile chunk(s)
   6.205 -// will be removed.
   6.206 -// Parameters:
   6.207 -//   mux - (in/out) object to which the color profile is to be added
   6.208 -//   data - (in) the color profile data to be added
   6.209 -//   size - (in) size of the color profile data
   6.210 -//   copy_data - (in) value 1 indicates given data WILL copied to the mux, and
   6.211 -//               value 0 indicates data will NOT be copied.
   6.212 -// Returns:
   6.213 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or data is NULL
   6.214 -//   WEBP_MUX_MEMORY_ERROR - on memory allocation error
   6.215 -//   WEBP_MUX_OK - on success
   6.216 -WEBP_EXTERN(WebPMuxError) WebPMuxSetColorProfile(WebPMux* const mux,
   6.217 -                                                 const uint8_t* data,
   6.218 -                                                 uint32_t size, int copy_data);
   6.219 -
   6.220 -// Gets a reference to the color profile in the mux object.
   6.221 -// The caller should NOT free the returned data.
   6.222 -// Parameters:
   6.223 -//   mux - (in) object from which the color profile data is to be fetched
   6.224 -//   data - (out) the returned color profile data
   6.225 -//   size - (out) size of the returned color profile data
   6.226 -// Returns:
   6.227 -//   WEBP_MUX_INVALID_ARGUMENT - if either of mux, data or size is NULL
   6.228 -//   WEBP_MUX_NOT_FOUND - if color profile is not present in mux object.
   6.229 -//   WEBP_MUX_OK - on success.
   6.230 -WEBP_EXTERN(WebPMuxError) WebPMuxGetColorProfile(const WebPMux* const mux,
   6.231 -                                                 const uint8_t** data,
   6.232 -                                                 uint32_t* size);
   6.233 -
   6.234 -// Deletes the color profile in the mux object.
   6.235 -// Parameters:
   6.236 -//   mux - (in/out) object from which color profile is to be deleted
   6.237 -// Returns:
   6.238 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
   6.239 -//   WEBP_MUX_NOT_FOUND - If mux does not contain color profile.
   6.240 -//   WEBP_MUX_OK - on success.
   6.241 -WEBP_EXTERN(WebPMuxError) WebPMuxDeleteColorProfile(WebPMux* const mux);
   6.242 -
   6.243 -//------------------------------------------------------------------------------
   6.244 -// Animation.
   6.245 -
   6.246 -// Adds an animation frame to the mux object.
   6.247 -// nth=0 has a special meaning - last position.
   6.248 -// Parameters:
   6.249 -//   mux - (in/out) object to which an animation frame is to be added
   6.250 -//   nth - (in) The position at which the frame is to be added.
   6.251 -//   data - (in) the raw VP8 image data corresponding to frame image. The data
   6.252 -//          can be either a VP8 bitstream or a single-image WebP file
   6.253 -//          (non-animated & non-tiled)
   6.254 -//   size - (in) size of frame chunk data
   6.255 -//   alpha_data - (in) the alpha data corresponding to frame image (if present)
   6.256 -//   alpha_size - (in) size of alpha chunk data
   6.257 -//   x_offset - (in) x-offset of the frame to be added
   6.258 -//   y_offset - (in) y-offset of the frame to be added
   6.259 -//   duration - (in) duration of the frame to be added (in milliseconds)
   6.260 -//   copy_data - (in) value 1 indicates given data WILL copied to the mux, and
   6.261 -//               value 0 indicates data will NOT be copied.
   6.262 -// Returns:
   6.263 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or data is NULL
   6.264 -//   WEBP_MUX_NOT_FOUND - If we have less than (nth-1) frames before adding.
   6.265 -//   WEBP_MUX_MEMORY_ERROR - on memory allocation error.
   6.266 -//   WEBP_MUX_OK - on success.
   6.267 -WEBP_EXTERN(WebPMuxError) WebPMuxAddFrame(WebPMux* const mux, uint32_t nth,
   6.268 -                                          const uint8_t* data, uint32_t size,
   6.269 -                                          const uint8_t* alpha_data,
   6.270 -                                          uint32_t alpha_size,
   6.271 -                                          uint32_t x_offset, uint32_t y_offset,
   6.272 -                                          uint32_t duration, int copy_data);
   6.273 -
   6.274 -// TODO(urvang): Create a struct as follows to reduce argument list size:
   6.275 -// typedef struct {
   6.276 -//  int nth;
   6.277 -//  uint8_t* data;
   6.278 -//  uint32_t data_size;
   6.279 -//  uint8_t* alpha;
   6.280 -//  uint32_t alpha_size;
   6.281 -//  uint32_t x_offset, y_offset;
   6.282 -//  uint32_t duration;
   6.283 -// } FrameInfo;
   6.284 -
   6.285 -// Gets a reference to the nth animation frame from the mux object.
   6.286 -// The caller should NOT free the returned data.
   6.287 -// nth=0 has a special meaning - last position.
   6.288 -// Parameters:
   6.289 -//   mux - (in) object from which the info is to be fetched
   6.290 -//   nth - (in) index of the frame in the mux object
   6.291 -//   data - (out) the returned image data
   6.292 -//   size - (out) size of the returned image data
   6.293 -//   alpha_data - (in) the alpha data corresponding to frame image (if present)
   6.294 -//   alpha_size - (in) size of alpha chunk data
   6.295 -//   x_offset - (out) x-offset of the returned frame
   6.296 -//   y_offset - (out) y-offset of the returned frame
   6.297 -//   duration - (out) duration of the returned frame (in milliseconds)
   6.298 -// Returns:
   6.299 -//   WEBP_MUX_INVALID_ARGUMENT - if either mux, data, size, x_offset,
   6.300 -//                               y_offset, or duration is NULL
   6.301 -//   WEBP_MUX_NOT_FOUND - if there are less than nth frames in the mux object.
   6.302 -//   WEBP_MUX_BAD_DATA - if nth frame chunk in mux is invalid.
   6.303 -//   WEBP_MUX_OK - on success.
   6.304 -WEBP_EXTERN(WebPMuxError) WebPMuxGetFrame(const WebPMux* const mux,
   6.305 -                                          uint32_t nth,
   6.306 -                                          const uint8_t** data, uint32_t* size,
   6.307 -                                          const uint8_t** alpha_data,
   6.308 -                                          uint32_t* alpha_size,
   6.309 -                                          uint32_t* x_offset,
   6.310 -                                          uint32_t* y_offset,
   6.311 -                                          uint32_t* duration);
   6.312 -
   6.313 -// Deletes an animation frame from the mux object.
   6.314 -// nth=0 has a special meaning - last position.
   6.315 -// Parameters:
   6.316 -//   mux - (in/out) object from which a frame is to be deleted
   6.317 -//   nth - (in) The position from which the frame is to be deleted
   6.318 -// Returns:
   6.319 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
   6.320 -//   WEBP_MUX_NOT_FOUND - If there are less than nth frames in the mux object
   6.321 -//                        before deletion.
   6.322 -//   WEBP_MUX_OK - on success.
   6.323 -WEBP_EXTERN(WebPMuxError) WebPMuxDeleteFrame(WebPMux* const mux, uint32_t nth);
   6.324 -
   6.325 -// Sets the animation loop count in the mux object. Any existing loop count
   6.326 -// value(s) will be removed.
   6.327 -// Parameters:
   6.328 -//   mux - (in/out) object in which loop chunk is to be set/added
   6.329 -//   loop_count - (in) animation loop count value.
   6.330 -//                Note that loop_count of zero denotes infinite loop.
   6.331 -// Returns:
   6.332 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
   6.333 -//   WEBP_MUX_MEMORY_ERROR - on memory allocation error.
   6.334 -//   WEBP_MUX_OK - on success.
   6.335 -WEBP_EXTERN(WebPMuxError) WebPMuxSetLoopCount(WebPMux* const mux,
   6.336 -                                              uint32_t loop_count);
   6.337 -
   6.338 -// Gets the animation loop count from the mux object.
   6.339 -// Parameters:
   6.340 -//   mux - (in) object from which the loop count is to be fetched
   6.341 -//   loop_count - (out) the loop_count value present in the LOOP chunk
   6.342 -// Returns:
   6.343 -//   WEBP_MUX_INVALID_ARGUMENT - if either of mux or loop_count is NULL
   6.344 -//   WEBP_MUX_NOT_FOUND - if loop chunk is not present in mux object.
   6.345 -//   WEBP_MUX_OK - on success.
   6.346 -WEBP_EXTERN(WebPMuxError) WebPMuxGetLoopCount(const WebPMux* const mux,
   6.347 -                                              uint32_t* loop_count);
   6.348 -
   6.349 -//------------------------------------------------------------------------------
   6.350 -// Tiling.
   6.351 -
   6.352 -// Adds a tile to the mux object.
   6.353 -// nth=0 has a special meaning - last position.
   6.354 -// Parameters:
   6.355 -//   mux - (in/out) object to which a tile is to be added
   6.356 -//   nth - (in) The position at which the tile is to be added.
   6.357 -//   data - (in) the raw VP8 image data corresponding to tile image.  The data
   6.358 -//          can be either a VP8 bitstream or a single-image WebP file
   6.359 -//          (non-animated & non-tiled)
   6.360 -//   size - (in) size of tile chunk data
   6.361 -//   alpha_data - (in) the alpha data corresponding to tile image (if present)
   6.362 -//   alpha_size - (in) size of alpha chunk data
   6.363 -//   x_offset - (in) x-offset of the tile to be added
   6.364 -//   y_offset - (in) y-offset of the tile to be added
   6.365 -//   copy_data - (in) value 1 indicates given data WILL copied to the mux, and
   6.366 -//               value 0 indicates data will NOT be copied.
   6.367 -// Returns:
   6.368 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or data is NULL
   6.369 -//   WEBP_MUX_NOT_FOUND - If we have less than (nth-1) tiles before adding.
   6.370 -//   WEBP_MUX_MEMORY_ERROR - on memory allocation error.
   6.371 -//   WEBP_MUX_OK - on success.
   6.372 -WEBP_EXTERN(WebPMuxError) WebPMuxAddTile(WebPMux* const mux, uint32_t nth,
   6.373 -                                         const uint8_t* data, uint32_t size,
   6.374 -                                         const uint8_t* alpha_data,
   6.375 -                                         uint32_t alpha_size,
   6.376 -                                         uint32_t x_offset, uint32_t y_offset,
   6.377 -                                         int copy_data);
   6.378 -
   6.379 -// Gets a reference to the nth tile from the mux object.
   6.380 -// The caller should NOT free the returned data.
   6.381 -// nth=0 has a special meaning - last position.
   6.382 -// Parameters:
   6.383 -//   mux - (in) object from which the info is to be fetched
   6.384 -//   nth - (in) index of the tile in the mux object
   6.385 -//   data - (out) the returned image data
   6.386 -//   size - (out) size of the returned image data
   6.387 -//   alpha_data - (in) the alpha data corresponding to tile image (if present)
   6.388 -//   alpha_size - (in) size of alpha chunk data
   6.389 -//   x_offset - (out) x-offset of the returned tile
   6.390 -//   y_offset - (out) y-offset of the returned tile
   6.391 -// Returns:
   6.392 -//   WEBP_MUX_INVALID_ARGUMENT - if either mux, data, size, x_offset or
   6.393 -//                               y_offset is NULL
   6.394 -//   WEBP_MUX_NOT_FOUND - if there are less than nth tiles in the mux object.
   6.395 -//   WEBP_MUX_BAD_DATA - if nth tile chunk in mux is invalid.
   6.396 -//   WEBP_MUX_OK - on success.
   6.397 -WEBP_EXTERN(WebPMuxError) WebPMuxGetTile(const WebPMux* const mux, uint32_t nth,
   6.398 -                                         const uint8_t** data, uint32_t* size,
   6.399 -                                         const uint8_t** alpha_data,
   6.400 -                                         uint32_t* alpha_size,
   6.401 -                                         uint32_t* x_offset,
   6.402 -                                         uint32_t* y_offset);
   6.403 -
   6.404 -// Deletes a tile from the mux object.
   6.405 -// nth=0 has a special meaning - last position
   6.406 -// Parameters:
   6.407 -//   mux - (in/out) object from which a tile is to be deleted
   6.408 -//   nth - (in) The position from which the tile is to be deleted
   6.409 -// Returns:
   6.410 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
   6.411 -//   WEBP_MUX_NOT_FOUND - If there are less than nth tiles in the mux object
   6.412 -//                        before deletion.
   6.413 -//   WEBP_MUX_OK - on success.
   6.414 -WEBP_EXTERN(WebPMuxError) WebPMuxDeleteTile(WebPMux* const mux, uint32_t nth);
   6.415 -
   6.416 -//------------------------------------------------------------------------------
   6.417 -// Misc Utilities.
   6.418 -
   6.419 -// Gets the feature flags from the mux object.
   6.420 -// Parameters:
   6.421 -//   mux - (in) object from which the features are to be fetched
   6.422 -//   flags - (out) the flags specifying which features are present in the
   6.423 -//           mux object. This will be an OR of various flag values.
   6.424 -//           Enum 'FeatureFlags' can be used to test for individual flag values.
   6.425 -// Returns:
   6.426 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or flags is NULL
   6.427 -//   WEBP_MUX_NOT_FOUND - if VP8X chunk is not present in mux object.
   6.428 -//   WEBP_MUX_BAD_DATA - if VP8X chunk in mux is invalid.
   6.429 -//   WEBP_MUX_OK - on success.
   6.430 -WEBP_EXTERN(WebPMuxError) WebPMuxGetFeatures(const WebPMux* const mux,
   6.431 -                                             uint32_t* flags);
   6.432 -
   6.433 -// Gets number of chunks having tag value tag in the mux object.
   6.434 -// Parameters:
   6.435 -//   mux - (in) object from which the info is to be fetched
   6.436 -//   tag - (in) tag name specifying the type of chunk
   6.437 -//   num_elements - (out) number of chunks corresponding to the specified tag
   6.438 -// Returns:
   6.439 -//   WEBP_MUX_INVALID_ARGUMENT - if either mux, tag or num_elements is NULL
   6.440 -//   WEBP_MUX_OK - on success.
   6.441 -WEBP_EXTERN(WebPMuxError) WebPMuxNumNamedElements(const WebPMux* const mux,
   6.442 -                                                  const char* tag,
   6.443 -                                                  int* num_elements);
   6.444 -
   6.445 -// Assembles all chunks in WebP RIFF format and returns in output_data.
   6.446 -// This function also validates the mux object.
   6.447 -// The content of '*output_data' is allocated using malloc(), and NOT
   6.448 -// owned by the 'mux' object.
   6.449 -// It MUST be deallocated by the caller by calling free().
   6.450 -// Parameters:
   6.451 -//   mux - (in/out) object whose chunks are to be assembled
   6.452 -//   output_data - (out) byte array where assembled WebP data is returned
   6.453 -//   output_size - (out) size of returned data
   6.454 -// Returns:
   6.455 -//   WEBP_MUX_BAD_DATA - if mux object is invalid.
   6.456 -//   WEBP_MUX_INVALID_ARGUMENT - if either mux, output_data or output_size is
   6.457 -//                               NULL.
   6.458 -//   WEBP_MUX_MEMORY_ERROR - on memory allocation error.
   6.459 -//   WEBP_MUX_OK - on success
   6.460 -WEBP_EXTERN(WebPMuxError) WebPMuxAssemble(WebPMux* const mux,
   6.461 -                                          uint8_t** output_data,
   6.462 -                                          uint32_t* output_size);
   6.463 -
   6.464 -//------------------------------------------------------------------------------
   6.465 -
   6.466 -#if defined(__cplusplus) || defined(c_plusplus)
   6.467 -}    // extern "C"
   6.468 -#endif
   6.469 -
   6.470 -#endif  /* WEBP_WEBP_MUX_H_ */
     7.1 --- a/VisualC/external/include/webp/types.h	Tue Oct 16 20:02:02 2018 +0300
     7.2 +++ b/VisualC/external/include/webp/types.h	Wed Oct 17 01:00:32 2018 +0300
     7.3 @@ -1,8 +1,10 @@
     7.4 -// Copyright 2010 Google Inc.
     7.5 +// Copyright 2010 Google Inc. All Rights Reserved.
     7.6  //
     7.7 -// This code is licensed under the same terms as WebM:
     7.8 -//  Software License Agreement:  http://www.webmproject.org/license/software/
     7.9 -//  Additional IP Rights Grant:  http://www.webmproject.org/license/additional/
    7.10 +// Use of this source code is governed by a BSD-style license
    7.11 +// that can be found in the COPYING file in the root of the source
    7.12 +// tree. An additional intellectual property rights grant can be found
    7.13 +// in the file PATENTS. All contributing project authors may
    7.14 +// be found in the AUTHORS file in the root of the source tree.
    7.15  // -----------------------------------------------------------------------------
    7.16  //
    7.17  //  Common types
    7.18 @@ -12,12 +14,15 @@
    7.19  #ifndef WEBP_WEBP_TYPES_H_
    7.20  #define WEBP_WEBP_TYPES_H_
    7.21  
    7.22 +#include <stddef.h>  // for size_t
    7.23 +
    7.24  #ifndef _MSC_VER
    7.25  #include <inttypes.h>
    7.26 -#ifdef __STRICT_ANSI__
    7.27 +#if defined(__cplusplus) || !defined(__STRICT_ANSI__) || \
    7.28 +    (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
    7.29 +#define WEBP_INLINE inline
    7.30 +#else
    7.31  #define WEBP_INLINE
    7.32 -#else  /* __STRICT_ANSI__ */
    7.33 -#define WEBP_INLINE inline
    7.34  #endif
    7.35  #else
    7.36  typedef signed   char int8_t;
    7.37 @@ -34,7 +39,14 @@
    7.38  #ifndef WEBP_EXTERN
    7.39  // This explicitly marks library functions and allows for changing the
    7.40  // signature for e.g., Windows DLL builds.
    7.41 -#define WEBP_EXTERN(type) extern type
    7.42 +# if defined(__GNUC__) && __GNUC__ >= 4
    7.43 +#  define WEBP_EXTERN(type) extern __attribute__ ((visibility ("default"))) type
    7.44 +# else
    7.45 +#  define WEBP_EXTERN(type) extern type
    7.46 +# endif  /* __GNUC__ >= 4 */
    7.47  #endif  /* WEBP_EXTERN */
    7.48  
    7.49 +// Macro to check ABI compatibility (same major revision number)
    7.50 +#define WEBP_ABI_IS_INCOMPATIBLE(a, b) (((a) >> 8) != ((b) >> 8))
    7.51 +
    7.52  #endif  /* WEBP_WEBP_TYPES_H_ */
     8.1 Binary file VisualC/external/lib/x64/libwebp-2.dll has changed
     9.1 Binary file VisualC/external/lib/x64/libwebp-7.dll has changed
    10.1 Binary file VisualC/external/lib/x86/libwebp-2.dll has changed
    11.1 Binary file VisualC/external/lib/x86/libwebp-7.dll has changed
    12.1 --- a/Xcode/Frameworks/webp.framework/LICENSE.webp.txt	Tue Oct 16 20:02:02 2018 +0300
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,34 +0,0 @@
    12.4 -The source code to this library used with SDL_image can be found here:
    12.5 -http://www.libsdl.org/projects/SDL_image/libs/
    12.6 ----
    12.7 -
    12.8 -Copyright (c) 2010, Google Inc. All rights reserved.
    12.9 -
   12.10 -Redistribution and use in source and binary forms, with or without
   12.11 -modification, are permitted provided that the following conditions are
   12.12 -met:
   12.13 -
   12.14 -  * Redistributions of source code must retain the above copyright
   12.15 -    notice, this list of conditions and the following disclaimer.
   12.16 -
   12.17 -  * Redistributions in binary form must reproduce the above copyright
   12.18 -    notice, this list of conditions and the following disclaimer in
   12.19 -    the documentation and/or other materials provided with the
   12.20 -    distribution.
   12.21 -
   12.22 -  * Neither the name of Google nor the names of its contributors may
   12.23 -    be used to endorse or promote products derived from this software
   12.24 -    without specific prior written permission.
   12.25 -
   12.26 -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   12.27 -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   12.28 -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   12.29 -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   12.30 -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   12.31 -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   12.32 -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   12.33 -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   12.34 -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   12.35 -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
   12.36 -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   12.37 -
    13.1 --- a/Xcode/Frameworks/webp.framework/Versions/A/Headers/webp/decode.h	Tue Oct 16 20:02:02 2018 +0300
    13.2 +++ b/Xcode/Frameworks/webp.framework/Versions/A/Headers/webp/decode.h	Wed Oct 17 01:00:32 2018 +0300
    13.3 @@ -1,11 +1,13 @@
    13.4 -// Copyright 2010 Google Inc.
    13.5 +// Copyright 2010 Google Inc. All Rights Reserved.
    13.6  //
    13.7 -// This code is licensed under the same terms as WebM:
    13.8 -//  Software License Agreement:  http://www.webmproject.org/license/software/
    13.9 -//  Additional IP Rights Grant:  http://www.webmproject.org/license/additional/
   13.10 +// Use of this source code is governed by a BSD-style license
   13.11 +// that can be found in the COPYING file in the root of the source
   13.12 +// tree. An additional intellectual property rights grant can be found
   13.13 +// in the file PATENTS. All contributing project authors may
   13.14 +// be found in the AUTHORS file in the root of the source tree.
   13.15  // -----------------------------------------------------------------------------
   13.16  //
   13.17 -//  Main decoding functions for WEBP images.
   13.18 +//  Main decoding functions for WebP images.
   13.19  //
   13.20  // Author: Skal (pascal.massimino@gmail.com)
   13.21  
   13.22 @@ -14,59 +16,78 @@
   13.23  
   13.24  #include "./types.h"
   13.25  
   13.26 -#if defined(__cplusplus) || defined(c_plusplus)
   13.27 +#ifdef __cplusplus
   13.28  extern "C" {
   13.29  #endif
   13.30  
   13.31 -#define WEBP_DECODER_ABI_VERSION 0x0002
   13.32 +#define WEBP_DECODER_ABI_VERSION 0x0208    // MAJOR(8b) + MINOR(8b)
   13.33 +
   13.34 +// Note: forward declaring enumerations is not allowed in (strict) C and C++,
   13.35 +// the types are left here for reference.
   13.36 +// typedef enum VP8StatusCode VP8StatusCode;
   13.37 +// typedef enum WEBP_CSP_MODE WEBP_CSP_MODE;
   13.38 +typedef struct WebPRGBABuffer WebPRGBABuffer;
   13.39 +typedef struct WebPYUVABuffer WebPYUVABuffer;
   13.40 +typedef struct WebPDecBuffer WebPDecBuffer;
   13.41 +typedef struct WebPIDecoder WebPIDecoder;
   13.42 +typedef struct WebPBitstreamFeatures WebPBitstreamFeatures;
   13.43 +typedef struct WebPDecoderOptions WebPDecoderOptions;
   13.44 +typedef struct WebPDecoderConfig WebPDecoderConfig;
   13.45  
   13.46  // Return the decoder's version number, packed in hexadecimal using 8bits for
   13.47  // each of major/minor/revision. E.g: v2.5.7 is 0x020507.
   13.48  WEBP_EXTERN(int) WebPGetDecoderVersion(void);
   13.49  
   13.50  // Retrieve basic header information: width, height.
   13.51 -// This function will also validate the header and return 0 in
   13.52 -// case of formatting error.
   13.53 -// Pointers *width/*height can be passed NULL if deemed irrelevant.
   13.54 -WEBP_EXTERN(int) WebPGetInfo(const uint8_t* data, uint32_t data_size,
   13.55 +// This function will also validate the header, returning true on success,
   13.56 +// false otherwise. '*width' and '*height' are only valid on successful return.
   13.57 +// Pointers 'width' and 'height' can be passed NULL if deemed irrelevant.
   13.58 +WEBP_EXTERN(int) WebPGetInfo(const uint8_t* data, size_t data_size,
   13.59                               int* width, int* height);
   13.60  
   13.61 -// Decodes WEBP images pointed to by *data and returns RGB samples, along
   13.62 -// with the dimensions in *width and *height.
   13.63 -// The returned pointer should be deleted calling free().
   13.64 +// Decodes WebP images pointed to by 'data' and returns RGBA samples, along
   13.65 +// with the dimensions in *width and *height. The ordering of samples in
   13.66 +// memory is R, G, B, A, R, G, B, A... in scan order (endian-independent).
   13.67 +// The returned pointer should be deleted calling WebPFree().
   13.68  // Returns NULL in case of error.
   13.69 -WEBP_EXTERN(uint8_t*) WebPDecodeRGB(const uint8_t* data, uint32_t data_size,
   13.70 +WEBP_EXTERN(uint8_t*) WebPDecodeRGBA(const uint8_t* data, size_t data_size,
   13.71 +                                     int* width, int* height);
   13.72 +
   13.73 +// Same as WebPDecodeRGBA, but returning A, R, G, B, A, R, G, B... ordered data.
   13.74 +WEBP_EXTERN(uint8_t*) WebPDecodeARGB(const uint8_t* data, size_t data_size,
   13.75 +                                     int* width, int* height);
   13.76 +
   13.77 +// Same as WebPDecodeRGBA, but returning B, G, R, A, B, G, R, A... ordered data.
   13.78 +WEBP_EXTERN(uint8_t*) WebPDecodeBGRA(const uint8_t* data, size_t data_size,
   13.79 +                                     int* width, int* height);
   13.80 +
   13.81 +// Same as WebPDecodeRGBA, but returning R, G, B, R, G, B... ordered data.
   13.82 +// If the bitstream contains transparency, it is ignored.
   13.83 +WEBP_EXTERN(uint8_t*) WebPDecodeRGB(const uint8_t* data, size_t data_size,
   13.84                                      int* width, int* height);
   13.85  
   13.86 -// Same as WebPDecodeRGB, but returning RGBA data.
   13.87 -WEBP_EXTERN(uint8_t*) WebPDecodeRGBA(const uint8_t* data, uint32_t data_size,
   13.88 -                                     int* width, int* height);
   13.89 +// Same as WebPDecodeRGB, but returning B, G, R, B, G, R... ordered data.
   13.90 +WEBP_EXTERN(uint8_t*) WebPDecodeBGR(const uint8_t* data, size_t data_size,
   13.91 +                                    int* width, int* height);
   13.92  
   13.93 -// Same as WebPDecodeRGBA, but returning ARGB data.
   13.94 -WEBP_EXTERN(uint8_t*) WebPDecodeARGB(const uint8_t* data, uint32_t data_size,
   13.95 -                                     int* width, int* height);
   13.96  
   13.97 -// This variant decode to BGR instead of RGB.
   13.98 -WEBP_EXTERN(uint8_t*) WebPDecodeBGR(const uint8_t* data, uint32_t data_size,
   13.99 -                                    int* width, int* height);
  13.100 -// This variant decodes to BGRA instead of RGBA.
  13.101 -WEBP_EXTERN(uint8_t*) WebPDecodeBGRA(const uint8_t* data, uint32_t data_size,
  13.102 -                                     int* width, int* height);
  13.103 -
  13.104 -// Decode WEBP images stored in *data in Y'UV format(*). The pointer returned is
  13.105 -// the Y samples buffer. Upon return, *u and *v will point to the U and V
  13.106 -// chroma data. These U and V buffers need NOT be free()'d, unlike the returned
  13.107 -// Y luma one. The dimension of the U and V planes are both (*width + 1) / 2
  13.108 -// and (*height + 1)/ 2.
  13.109 +// Decode WebP images pointed to by 'data' to Y'UV format(*). The pointer
  13.110 +// returned is the Y samples buffer. Upon return, *u and *v will point to
  13.111 +// the U and V chroma data. These U and V buffers need NOT be passed to
  13.112 +// WebPFree(), unlike the returned Y luma one. The dimension of the U and V
  13.113 +// planes are both (*width + 1) / 2 and (*height + 1)/ 2.
  13.114  // Upon return, the Y buffer has a stride returned as '*stride', while U and V
  13.115  // have a common stride returned as '*uv_stride'.
  13.116  // Return NULL in case of error.
  13.117  // (*) Also named Y'CbCr. See: http://en.wikipedia.org/wiki/YCbCr
  13.118 -WEBP_EXTERN(uint8_t*) WebPDecodeYUV(const uint8_t* data, uint32_t data_size,
  13.119 +WEBP_EXTERN(uint8_t*) WebPDecodeYUV(const uint8_t* data, size_t data_size,
  13.120                                      int* width, int* height,
  13.121                                      uint8_t** u, uint8_t** v,
  13.122                                      int* stride, int* uv_stride);
  13.123  
  13.124 +// Releases memory returned by the WebPDecode*() functions above.
  13.125 +WEBP_EXTERN(void) WebPFree(void* ptr);
  13.126 +
  13.127  // These five functions are variants of the above ones, that decode the image
  13.128  // directly into a pre-allocated buffer 'output_buffer'. The maximum storage
  13.129  // available in this buffer is indicated by 'output_buffer_size'. If this
  13.130 @@ -75,22 +96,24 @@
  13.131  // The parameter 'output_stride' specifies the distance (in bytes)
  13.132  // between scanlines. Hence, output_buffer_size is expected to be at least
  13.133  // output_stride x picture-height.
  13.134 +WEBP_EXTERN(uint8_t*) WebPDecodeRGBAInto(
  13.135 +    const uint8_t* data, size_t data_size,
  13.136 +    uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
  13.137 +WEBP_EXTERN(uint8_t*) WebPDecodeARGBInto(
  13.138 +    const uint8_t* data, size_t data_size,
  13.139 +    uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
  13.140 +WEBP_EXTERN(uint8_t*) WebPDecodeBGRAInto(
  13.141 +    const uint8_t* data, size_t data_size,
  13.142 +    uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
  13.143 +
  13.144 +// RGB and BGR variants. Here too the transparency information, if present,
  13.145 +// will be dropped and ignored.
  13.146  WEBP_EXTERN(uint8_t*) WebPDecodeRGBInto(
  13.147 -    const uint8_t* data, uint32_t data_size,
  13.148 -    uint8_t* output_buffer, int output_buffer_size, int output_stride);
  13.149 -WEBP_EXTERN(uint8_t*) WebPDecodeRGBAInto(
  13.150 -    const uint8_t* data, uint32_t data_size,
  13.151 -    uint8_t* output_buffer, int output_buffer_size, int output_stride);
  13.152 -WEBP_EXTERN(uint8_t*) WebPDecodeARGBInto(
  13.153 -    const uint8_t* data, uint32_t data_size,
  13.154 -    uint8_t* output_buffer, int output_buffer_size, int output_stride);
  13.155 -// BGR variants
  13.156 +    const uint8_t* data, size_t data_size,
  13.157 +    uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
  13.158  WEBP_EXTERN(uint8_t*) WebPDecodeBGRInto(
  13.159 -    const uint8_t* data, uint32_t data_size,
  13.160 -    uint8_t* output_buffer, int output_buffer_size, int output_stride);
  13.161 -WEBP_EXTERN(uint8_t*) WebPDecodeBGRAInto(
  13.162 -    const uint8_t* data, uint32_t data_size,
  13.163 -    uint8_t* output_buffer, int output_buffer_size, int output_stride);
  13.164 +    const uint8_t* data, size_t data_size,
  13.165 +    uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
  13.166  
  13.167  // WebPDecodeYUVInto() is a variant of WebPDecodeYUV() that operates directly
  13.168  // into pre-allocated luma/chroma plane buffers. This function requires the
  13.169 @@ -100,72 +123,112 @@
  13.170  // Pointer to the luma plane ('*luma') is returned or NULL if an error occurred
  13.171  // during decoding (or because some buffers were found to be too small).
  13.172  WEBP_EXTERN(uint8_t*) WebPDecodeYUVInto(
  13.173 -    const uint8_t* data, uint32_t data_size,
  13.174 -    uint8_t* luma, int luma_size, int luma_stride,
  13.175 -    uint8_t* u, int u_size, int u_stride,
  13.176 -    uint8_t* v, int v_size, int v_stride);
  13.177 +    const uint8_t* data, size_t data_size,
  13.178 +    uint8_t* luma, size_t luma_size, int luma_stride,
  13.179 +    uint8_t* u, size_t u_size, int u_stride,
  13.180 +    uint8_t* v, size_t v_size, int v_stride);
  13.181  
  13.182  //------------------------------------------------------------------------------
  13.183  // Output colorspaces and buffer
  13.184  
  13.185  // Colorspaces
  13.186 -typedef enum { MODE_RGB = 0, MODE_RGBA = 1,
  13.187 -               MODE_BGR = 2, MODE_BGRA = 3,
  13.188 -               MODE_ARGB = 4, MODE_RGBA_4444 = 5,
  13.189 -               MODE_RGB_565 = 6,
  13.190 -               // YUV modes must come after RGB ones.
  13.191 -               MODE_YUV = 7, MODE_YUVA = 8,  // yuv 4:2:0
  13.192 -               MODE_LAST = 9
  13.193 -             } WEBP_CSP_MODE;
  13.194 +// Note: the naming describes the byte-ordering of packed samples in memory.
  13.195 +// For instance, MODE_BGRA relates to samples ordered as B,G,R,A,B,G,R,A,...
  13.196 +// Non-capital names (e.g.:MODE_Argb) relates to pre-multiplied RGB channels.
  13.197 +// RGBA-4444 and RGB-565 colorspaces are represented by following byte-order:
  13.198 +// RGBA-4444: [r3 r2 r1 r0 g3 g2 g1 g0], [b3 b2 b1 b0 a3 a2 a1 a0], ...
  13.199 +// RGB-565: [r4 r3 r2 r1 r0 g5 g4 g3], [g2 g1 g0 b4 b3 b2 b1 b0], ...
  13.200 +// In the case WEBP_SWAP_16BITS_CSP is defined, the bytes are swapped for
  13.201 +// these two modes:
  13.202 +// RGBA-4444: [b3 b2 b1 b0 a3 a2 a1 a0], [r3 r2 r1 r0 g3 g2 g1 g0], ...
  13.203 +// RGB-565: [g2 g1 g0 b4 b3 b2 b1 b0], [r4 r3 r2 r1 r0 g5 g4 g3], ...
  13.204  
  13.205 -// Generic structure for describing the sample buffer.
  13.206 -typedef struct {    // view as RGBA
  13.207 +typedef enum WEBP_CSP_MODE {
  13.208 +  MODE_RGB = 0, MODE_RGBA = 1,
  13.209 +  MODE_BGR = 2, MODE_BGRA = 3,
  13.210 +  MODE_ARGB = 4, MODE_RGBA_4444 = 5,
  13.211 +  MODE_RGB_565 = 6,
  13.212 +  // RGB-premultiplied transparent modes (alpha value is preserved)
  13.213 +  MODE_rgbA = 7,
  13.214 +  MODE_bgrA = 8,
  13.215 +  MODE_Argb = 9,
  13.216 +  MODE_rgbA_4444 = 10,
  13.217 +  // YUV modes must come after RGB ones.
  13.218 +  MODE_YUV = 11, MODE_YUVA = 12,  // yuv 4:2:0
  13.219 +  MODE_LAST = 13
  13.220 +} WEBP_CSP_MODE;
  13.221 +
  13.222 +// Some useful macros:
  13.223 +static WEBP_INLINE int WebPIsPremultipliedMode(WEBP_CSP_MODE mode) {
  13.224 +  return (mode == MODE_rgbA || mode == MODE_bgrA || mode == MODE_Argb ||
  13.225 +          mode == MODE_rgbA_4444);
  13.226 +}
  13.227 +
  13.228 +static WEBP_INLINE int WebPIsAlphaMode(WEBP_CSP_MODE mode) {
  13.229 +  return (mode == MODE_RGBA || mode == MODE_BGRA || mode == MODE_ARGB ||
  13.230 +          mode == MODE_RGBA_4444 || mode == MODE_YUVA ||
  13.231 +          WebPIsPremultipliedMode(mode));
  13.232 +}
  13.233 +
  13.234 +static WEBP_INLINE int WebPIsRGBMode(WEBP_CSP_MODE mode) {
  13.235 +  return (mode < MODE_YUV);
  13.236 +}
  13.237 +
  13.238 +//------------------------------------------------------------------------------
  13.239 +// WebPDecBuffer: Generic structure for describing the output sample buffer.
  13.240 +
  13.241 +struct WebPRGBABuffer {    // view as RGBA
  13.242    uint8_t* rgba;    // pointer to RGBA samples
  13.243    int stride;       // stride in bytes from one scanline to the next.
  13.244 -  int size;         // total size of the *rgba buffer.
  13.245 -} WebPRGBABuffer;
  13.246 +  size_t size;      // total size of the *rgba buffer.
  13.247 +};
  13.248  
  13.249 -typedef struct {              // view as YUVA
  13.250 +struct WebPYUVABuffer {              // view as YUVA
  13.251    uint8_t* y, *u, *v, *a;     // pointer to luma, chroma U/V, alpha samples
  13.252    int y_stride;               // luma stride
  13.253    int u_stride, v_stride;     // chroma strides
  13.254    int a_stride;               // alpha stride
  13.255 -  int y_size;                 // luma plane size
  13.256 -  int u_size, v_size;         // chroma planes size
  13.257 -  int a_size;                 // alpha-plane size
  13.258 -} WebPYUVABuffer;
  13.259 +  size_t y_size;              // luma plane size
  13.260 +  size_t u_size, v_size;      // chroma planes size
  13.261 +  size_t a_size;              // alpha-plane size
  13.262 +};
  13.263  
  13.264  // Output buffer
  13.265 -typedef struct {
  13.266 +struct WebPDecBuffer {
  13.267    WEBP_CSP_MODE colorspace;  // Colorspace.
  13.268    int width, height;         // Dimensions.
  13.269 -  int is_external_memory;    // If true, 'internal_memory' pointer is not used.
  13.270 +  int is_external_memory;    // If non-zero, 'internal_memory' pointer is not
  13.271 +                             // used. If value is '2' or more, the external
  13.272 +                             // memory is considered 'slow' and multiple
  13.273 +                             // read/write will be avoided.
  13.274    union {
  13.275      WebPRGBABuffer RGBA;
  13.276      WebPYUVABuffer YUVA;
  13.277    } u;                       // Nameless union of buffer parameters.
  13.278 +  uint32_t       pad[4];     // padding for later use
  13.279 +
  13.280    uint8_t* private_memory;   // Internally allocated memory (only when
  13.281 -                             // is_external_memory is false). Should not be used
  13.282 +                             // is_external_memory is 0). Should not be used
  13.283                               // externally, but accessed via the buffer union.
  13.284 -} WebPDecBuffer;
  13.285 +};
  13.286  
  13.287  // Internal, version-checked, entry point
  13.288 -WEBP_EXTERN(int) WebPInitDecBufferInternal(WebPDecBuffer* const, int);
  13.289 +WEBP_EXTERN(int) WebPInitDecBufferInternal(WebPDecBuffer*, int);
  13.290  
  13.291  // Initialize the structure as empty. Must be called before any other use.
  13.292  // Returns false in case of version mismatch
  13.293 -static WEBP_INLINE int WebPInitDecBuffer(WebPDecBuffer* const buffer) {
  13.294 +static WEBP_INLINE int WebPInitDecBuffer(WebPDecBuffer* buffer) {
  13.295    return WebPInitDecBufferInternal(buffer, WEBP_DECODER_ABI_VERSION);
  13.296  }
  13.297  
  13.298  // Free any memory associated with the buffer. Must always be called last.
  13.299  // Note: doesn't free the 'buffer' structure itself.
  13.300 -WEBP_EXTERN(void) WebPFreeDecBuffer(WebPDecBuffer* const buffer);
  13.301 +WEBP_EXTERN(void) WebPFreeDecBuffer(WebPDecBuffer* buffer);
  13.302  
  13.303  //------------------------------------------------------------------------------
  13.304  // Enumeration of the status codes
  13.305  
  13.306 -typedef enum {
  13.307 +typedef enum VP8StatusCode {
  13.308    VP8_STATUS_OK = 0,
  13.309    VP8_STATUS_OUT_OF_MEMORY,
  13.310    VP8_STATUS_INVALID_PARAM,
  13.311 @@ -185,64 +248,84 @@
  13.312  // picture is only partially decoded, pending additional input.
  13.313  // Code example:
  13.314  //
  13.315 -//   WebPIDecoder* const idec = WebPINew(mode);
  13.316 -//   while (has_more_data) {
  13.317 -//     // ... (get additional data)
  13.318 +//   WebPInitDecBuffer(&output_buffer);
  13.319 +//   output_buffer.colorspace = mode;
  13.320 +//   ...
  13.321 +//   WebPIDecoder* idec = WebPINewDecoder(&output_buffer);
  13.322 +//   while (additional_data_is_available) {
  13.323 +//     // ... (get additional data in some new_data[] buffer)
  13.324  //     status = WebPIAppend(idec, new_data, new_data_size);
  13.325 -//     if (status != VP8_STATUS_SUSPENDED ||
  13.326 -//       break;
  13.327 +//     if (status != VP8_STATUS_OK && status != VP8_STATUS_SUSPENDED) {
  13.328 +//       break;    // an error occurred.
  13.329  //     }
  13.330  //
  13.331  //     // The above call decodes the current available buffer.
  13.332 -//     // Part of the image can now be refreshed by calling to
  13.333 -//     // WebPIDecGetRGB()/WebPIDecGetYUV() etc.
  13.334 +//     // Part of the image can now be refreshed by calling
  13.335 +//     // WebPIDecGetRGB()/WebPIDecGetYUVA() etc.
  13.336  //   }
  13.337  //   WebPIDelete(idec);
  13.338  
  13.339 -typedef struct WebPIDecoder WebPIDecoder;
  13.340 -
  13.341  // Creates a new incremental decoder with the supplied buffer parameter.
  13.342  // This output_buffer can be passed NULL, in which case a default output buffer
  13.343  // is used (with MODE_RGB). Otherwise, an internal reference to 'output_buffer'
  13.344  // is kept, which means that the lifespan of 'output_buffer' must be larger than
  13.345  // that of the returned WebPIDecoder object.
  13.346 +// The supplied 'output_buffer' content MUST NOT be changed between calls to
  13.347 +// WebPIAppend() or WebPIUpdate() unless 'output_buffer.is_external_memory' is
  13.348 +// not set to 0. In such a case, it is allowed to modify the pointers, size and
  13.349 +// stride of output_buffer.u.RGBA or output_buffer.u.YUVA, provided they remain
  13.350 +// within valid bounds.
  13.351 +// All other fields of WebPDecBuffer MUST remain constant between calls.
  13.352  // Returns NULL if the allocation failed.
  13.353 -WEBP_EXTERN(WebPIDecoder*) WebPINewDecoder(WebPDecBuffer* const output_buffer);
  13.354 -
  13.355 -// Creates a WebPIDecoder object. Returns NULL in case of failure.
  13.356 -// TODO(skal): DEPRECATED. Prefer using WebPINewDecoder().
  13.357 -WEBP_EXTERN(WebPIDecoder*) WebPINew(WEBP_CSP_MODE mode);
  13.358 +WEBP_EXTERN(WebPIDecoder*) WebPINewDecoder(WebPDecBuffer* output_buffer);
  13.359  
  13.360  // This function allocates and initializes an incremental-decoder object, which
  13.361 -// will output the r/g/b(/a) samples specified by 'mode' into a preallocated
  13.362 +// will output the RGB/A samples specified by 'csp' into a preallocated
  13.363  // buffer 'output_buffer'. The size of this buffer is at least
  13.364  // 'output_buffer_size' and the stride (distance in bytes between two scanlines)
  13.365 -// is specified by 'output_stride'. Returns NULL if the allocation failed.
  13.366 +// is specified by 'output_stride'.
  13.367 +// Additionally, output_buffer can be passed NULL in which case the output
  13.368 +// buffer will be allocated automatically when the decoding starts. The
  13.369 +// colorspace 'csp' is taken into account for allocating this buffer. All other
  13.370 +// parameters are ignored.
  13.371 +// Returns NULL if the allocation failed, or if some parameters are invalid.
  13.372  WEBP_EXTERN(WebPIDecoder*) WebPINewRGB(
  13.373 -    WEBP_CSP_MODE mode,
  13.374 -    uint8_t* output_buffer, int output_buffer_size, int output_stride);
  13.375 +    WEBP_CSP_MODE csp,
  13.376 +    uint8_t* output_buffer, size_t output_buffer_size, int output_stride);
  13.377  
  13.378  // This function allocates and initializes an incremental-decoder object, which
  13.379 -// will output the raw luma/chroma samples into a preallocated planes. The luma
  13.380 -// plane is specified by its pointer 'luma', its size 'luma_size' and its stride
  13.381 -// 'luma_stride'. Similarly, the chroma-u plane is specified by the 'u',
  13.382 -// 'u_size' and 'u_stride' parameters, and the chroma-v plane by 'v', 'v_size'
  13.383 -// and 'v_size'.
  13.384 -// Returns NULL if the allocation failed.
  13.385 +// will output the raw luma/chroma samples into a preallocated planes if
  13.386 +// supplied. The luma plane is specified by its pointer 'luma', its size
  13.387 +// 'luma_size' and its stride 'luma_stride'. Similarly, the chroma-u plane
  13.388 +// is specified by the 'u', 'u_size' and 'u_stride' parameters, and the chroma-v
  13.389 +// plane by 'v' and 'v_size'. And same for the alpha-plane. The 'a' pointer
  13.390 +// can be pass NULL in case one is not interested in the transparency plane.
  13.391 +// Conversely, 'luma' can be passed NULL if no preallocated planes are supplied.
  13.392 +// In this case, the output buffer will be automatically allocated (using
  13.393 +// MODE_YUVA) when decoding starts. All parameters are then ignored.
  13.394 +// Returns NULL if the allocation failed or if a parameter is invalid.
  13.395 +WEBP_EXTERN(WebPIDecoder*) WebPINewYUVA(
  13.396 +    uint8_t* luma, size_t luma_size, int luma_stride,
  13.397 +    uint8_t* u, size_t u_size, int u_stride,
  13.398 +    uint8_t* v, size_t v_size, int v_stride,
  13.399 +    uint8_t* a, size_t a_size, int a_stride);
  13.400 +
  13.401 +// Deprecated version of the above, without the alpha plane.
  13.402 +// Kept for backward compatibility.
  13.403  WEBP_EXTERN(WebPIDecoder*) WebPINewYUV(
  13.404 -    uint8_t* luma, int luma_size, int luma_stride,
  13.405 -    uint8_t* u, int u_size, int u_stride,
  13.406 -    uint8_t* v, int v_size, int v_stride);
  13.407 +    uint8_t* luma, size_t luma_size, int luma_stride,
  13.408 +    uint8_t* u, size_t u_size, int u_stride,
  13.409 +    uint8_t* v, size_t v_size, int v_stride);
  13.410  
  13.411  // Deletes the WebPIDecoder object and associated memory. Must always be called
  13.412 -// if WebPINew, WebPINewRGB or WebPINewYUV succeeded.
  13.413 -WEBP_EXTERN(void) WebPIDelete(WebPIDecoder* const idec);
  13.414 +// if WebPINewDecoder, WebPINewRGB or WebPINewYUV succeeded.
  13.415 +WEBP_EXTERN(void) WebPIDelete(WebPIDecoder* idec);
  13.416  
  13.417  // Copies and decodes the next available data. Returns VP8_STATUS_OK when
  13.418  // the image is successfully decoded. Returns VP8_STATUS_SUSPENDED when more
  13.419  // data is expected. Returns error in other cases.
  13.420  WEBP_EXTERN(VP8StatusCode) WebPIAppend(
  13.421 -    WebPIDecoder* const idec, const uint8_t* data, uint32_t data_size);
  13.422 +    WebPIDecoder* idec, const uint8_t* data, size_t data_size);
  13.423  
  13.424  // A variant of the above function to be used when data buffer contains
  13.425  // partial data from the beginning. In this case data buffer is not copied
  13.426 @@ -250,23 +333,34 @@
  13.427  // Note that the value of the 'data' pointer can change between calls to
  13.428  // WebPIUpdate, for instance when the data buffer is resized to fit larger data.
  13.429  WEBP_EXTERN(VP8StatusCode) WebPIUpdate(
  13.430 -    WebPIDecoder* const idec, const uint8_t* data, uint32_t data_size);
  13.431 +    WebPIDecoder* idec, const uint8_t* data, size_t data_size);
  13.432  
  13.433 -// Returns the r/g/b/(a) image decoded so far. Returns NULL if output params
  13.434 -// are not initialized yet. The r/g/b/(a) output type corresponds to the mode
  13.435 -// specified in WebPINew()/WebPINewRGB(). *last_y is the index of last decoded
  13.436 -// row in raster scan order. Some pointers (*last_y, *width etc.) can be NULL if
  13.437 -// corresponding information is not needed.
  13.438 +// Returns the RGB/A image decoded so far. Returns NULL if output params
  13.439 +// are not initialized yet. The RGB/A output type corresponds to the colorspace
  13.440 +// specified during call to WebPINewDecoder() or WebPINewRGB().
  13.441 +// *last_y is the index of last decoded row in raster scan order. Some pointers
  13.442 +// (*last_y, *width etc.) can be NULL if corresponding information is not
  13.443 +// needed.
  13.444  WEBP_EXTERN(uint8_t*) WebPIDecGetRGB(
  13.445 -    const WebPIDecoder* const idec, int* last_y,
  13.446 +    const WebPIDecoder* idec, int* last_y,
  13.447      int* width, int* height, int* stride);
  13.448  
  13.449 -// Same as above function to get YUV image. Returns pointer to the luma plane
  13.450 -// or NULL in case of error.
  13.451 -WEBP_EXTERN(uint8_t*) WebPIDecGetYUV(
  13.452 -    const WebPIDecoder* const idec, int* last_y,
  13.453 -    uint8_t** u, uint8_t** v,
  13.454 -    int* width, int* height, int* stride, int* uv_stride);
  13.455 +// Same as above function to get a YUVA image. Returns pointer to the luma
  13.456 +// plane or NULL in case of error. If there is no alpha information
  13.457 +// the alpha pointer '*a' will be returned NULL.
  13.458 +WEBP_EXTERN(uint8_t*) WebPIDecGetYUVA(
  13.459 +    const WebPIDecoder* idec, int* last_y,
  13.460 +    uint8_t** u, uint8_t** v, uint8_t** a,
  13.461 +    int* width, int* height, int* stride, int* uv_stride, int* a_stride);
  13.462 +
  13.463 +// Deprecated alpha-less version of WebPIDecGetYUVA(): it will ignore the
  13.464 +// alpha information (if present). Kept for backward compatibility.
  13.465 +static WEBP_INLINE uint8_t* WebPIDecGetYUV(
  13.466 +    const WebPIDecoder* idec, int* last_y, uint8_t** u, uint8_t** v,
  13.467 +    int* width, int* height, int* stride, int* uv_stride) {
  13.468 +  return WebPIDecGetYUVA(idec, last_y, u, v, NULL, width, height,
  13.469 +                         stride, uv_stride, NULL);
  13.470 +}
  13.471  
  13.472  // Generic call to retrieve information about the displayable area.
  13.473  // If non NULL, the left/right/width/height pointers are filled with the visible
  13.474 @@ -275,9 +369,7 @@
  13.475  // Otherwise returns the pointer to the internal representation. This structure
  13.476  // is read-only, tied to WebPIDecoder's lifespan and should not be modified.
  13.477  WEBP_EXTERN(const WebPDecBuffer*) WebPIDecodedArea(
  13.478 -    const WebPIDecoder* const idec,
  13.479 -    int* const left, int* const top,
  13.480 -    int* const width, int* const height);
  13.481 +    const WebPIDecoder* idec, int* left, int* top, int* width, int* height);
  13.482  
  13.483  //------------------------------------------------------------------------------
  13.484  // Advanced decoding parametrization
  13.485 @@ -292,7 +384,7 @@
  13.486       CHECK(WebPGetFeatures(data, data_size, &config.input) == VP8_STATUS_OK);
  13.487  
  13.488       // C) Adjust 'config', if needed
  13.489 -     config.no_fancy = 1;
  13.490 +     config.no_fancy_upsampling = 1;
  13.491       config.output.colorspace = MODE_BGRA;
  13.492       // etc.
  13.493  
  13.494 @@ -313,34 +405,34 @@
  13.495  */
  13.496  
  13.497  // Features gathered from the bitstream
  13.498 -typedef struct {
  13.499 -  int width;        // the original width, as read from the bitstream
  13.500 -  int height;       // the original height, as read from the bitstream
  13.501 -  int has_alpha;    // true if bitstream contains an alpha channel
  13.502 -  int no_incremental_decoding;  // if true, using incremental decoding is not
  13.503 -                                // recommended.
  13.504 -  int rotate;                   // TODO(later)
  13.505 -  int uv_sampling;              // should be 0 for now. TODO(later)
  13.506 -  int bitstream_version;        // should be 0 for now. TODO(later)
  13.507 -} WebPBitstreamFeatures;
  13.508 +struct WebPBitstreamFeatures {
  13.509 +  int width;          // Width in pixels, as read from the bitstream.
  13.510 +  int height;         // Height in pixels, as read from the bitstream.
  13.511 +  int has_alpha;      // True if the bitstream contains an alpha channel.
  13.512 +  int has_animation;  // True if the bitstream is an animation.
  13.513 +  int format;         // 0 = undefined (/mixed), 1 = lossy, 2 = lossless
  13.514 +
  13.515 +  uint32_t pad[5];    // padding for later use
  13.516 +};
  13.517  
  13.518  // Internal, version-checked, entry point
  13.519  WEBP_EXTERN(VP8StatusCode) WebPGetFeaturesInternal(
  13.520 -    const uint8_t*, uint32_t, WebPBitstreamFeatures* const, int);
  13.521 +    const uint8_t*, size_t, WebPBitstreamFeatures*, int);
  13.522  
  13.523  // Retrieve features from the bitstream. The *features structure is filled
  13.524  // with information gathered from the bitstream.
  13.525 -// Returns false in case of error or version mismatch.
  13.526 -// In case of error, features->bitstream_status will reflect the error code.
  13.527 +// Returns VP8_STATUS_OK when the features are successfully retrieved. Returns
  13.528 +// VP8_STATUS_NOT_ENOUGH_DATA when more data is needed to retrieve the
  13.529 +// features from headers. Returns error in other cases.
  13.530  static WEBP_INLINE VP8StatusCode WebPGetFeatures(
  13.531 -    const uint8_t* data, uint32_t data_size,
  13.532 -    WebPBitstreamFeatures* const features) {
  13.533 +    const uint8_t* data, size_t data_size,
  13.534 +    WebPBitstreamFeatures* features) {
  13.535    return WebPGetFeaturesInternal(data, data_size, features,
  13.536                                   WEBP_DECODER_ABI_VERSION);
  13.537  }
  13.538  
  13.539  // Decoding options
  13.540 -typedef struct {
  13.541 +struct WebPDecoderOptions {
  13.542    int bypass_filtering;               // if true, skip the in-loop filtering
  13.543    int no_fancy_upsampling;            // if true, use faster pointwise upsampler
  13.544    int use_cropping;                   // if true, cropping is applied _first_
  13.545 @@ -349,47 +441,52 @@
  13.546    int crop_width, crop_height;        // dimension of the cropping area
  13.547    int use_scaling;                    // if true, scaling is applied _afterward_
  13.548    int scaled_width, scaled_height;    // final resolution
  13.549 -  int force_rotation;                 // forced rotation (to be applied _last_)
  13.550 -  int no_enhancement;                 // if true, discard enhancement layer
  13.551    int use_threads;                    // if true, use multi-threaded decoding
  13.552 -} WebPDecoderOptions;
  13.553 +  int dithering_strength;             // dithering strength (0=Off, 100=full)
  13.554 +  int flip;                           // flip output vertically
  13.555 +  int alpha_dithering_strength;       // alpha dithering strength in [0..100]
  13.556 +
  13.557 +  uint32_t pad[5];                    // padding for later use
  13.558 +};
  13.559  
  13.560  // Main object storing the configuration for advanced decoding.
  13.561 -typedef struct {
  13.562 +struct WebPDecoderConfig {
  13.563    WebPBitstreamFeatures input;  // Immutable bitstream features (optional)
  13.564    WebPDecBuffer output;         // Output buffer (can point to external mem)
  13.565    WebPDecoderOptions options;   // Decoding options
  13.566 -} WebPDecoderConfig;
  13.567 +};
  13.568  
  13.569  // Internal, version-checked, entry point
  13.570 -WEBP_EXTERN(int) WebPInitDecoderConfigInternal(WebPDecoderConfig* const, int);
  13.571 +WEBP_EXTERN(int) WebPInitDecoderConfigInternal(WebPDecoderConfig*, int);
  13.572  
  13.573  // Initialize the configuration as empty. This function must always be
  13.574  // called first, unless WebPGetFeatures() is to be called.
  13.575  // Returns false in case of mismatched version.
  13.576 -static WEBP_INLINE int WebPInitDecoderConfig(WebPDecoderConfig* const config) {
  13.577 +static WEBP_INLINE int WebPInitDecoderConfig(WebPDecoderConfig* config) {
  13.578    return WebPInitDecoderConfigInternal(config, WEBP_DECODER_ABI_VERSION);
  13.579  }
  13.580  
  13.581 -// Instantiate a new incremental decoder object with requested configuration.
  13.582 -// The bitstream can be passed using *data and data_size parameter,
  13.583 -// in which case the features will be parsed and stored into config->input.
  13.584 -// Otherwise, 'data' can be NULL and now parsing will occur.
  13.585 -// Note that 'config' can be NULL too, in which case a default configuration is
  13.586 -// used.
  13.587 +// Instantiate a new incremental decoder object with the requested
  13.588 +// configuration. The bitstream can be passed using 'data' and 'data_size'
  13.589 +// parameter, in which case the features will be parsed and stored into
  13.590 +// config->input. Otherwise, 'data' can be NULL and no parsing will occur.
  13.591 +// Note that 'config' can be NULL too, in which case a default configuration
  13.592 +// is used. If 'config' is not NULL, it must outlive the WebPIDecoder object
  13.593 +// as some references to its fields will be used. No internal copy of 'config'
  13.594 +// is made.
  13.595  // The return WebPIDecoder object must always be deleted calling WebPIDelete().
  13.596  // Returns NULL in case of error (and config->status will then reflect
  13.597 -// the error condition).
  13.598 -WEBP_EXTERN(WebPIDecoder*) WebPIDecode(const uint8_t* data, uint32_t data_size,
  13.599 -                                       WebPDecoderConfig* const config);
  13.600 +// the error condition, if available).
  13.601 +WEBP_EXTERN(WebPIDecoder*) WebPIDecode(const uint8_t* data, size_t data_size,
  13.602 +                                       WebPDecoderConfig* config);
  13.603  
  13.604  // Non-incremental version. This version decodes the full data at once, taking
  13.605 -// 'config' into account. Return decoding status (VP8_STATUS_OK if decoding
  13.606 -// was successful).
  13.607 -WEBP_EXTERN(VP8StatusCode) WebPDecode(const uint8_t* data, uint32_t data_size,
  13.608 -                                      WebPDecoderConfig* const config);
  13.609 +// 'config' into account. Returns decoding status (which should be VP8_STATUS_OK
  13.610 +// if the decoding was successful). Note that 'config' cannot be NULL.
  13.611 +WEBP_EXTERN(VP8StatusCode) WebPDecode(const uint8_t* data, size_t data_size,
  13.612 +                                      WebPDecoderConfig* config);
  13.613  
  13.614 -#if defined(__cplusplus) || defined(c_plusplus)
  13.615 +#ifdef __cplusplus
  13.616  }    // extern "C"
  13.617  #endif
  13.618  
    14.1 --- a/Xcode/Frameworks/webp.framework/Versions/A/Headers/webp/decode_vp8.h	Tue Oct 16 20:02:02 2018 +0300
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,157 +0,0 @@
    14.4 -// Copyright 2010 Google Inc.
    14.5 -//
    14.6 -// This code is licensed under the same terms as WebM:
    14.7 -//  Software License Agreement:  http://www.webmproject.org/license/software/
    14.8 -//  Additional IP Rights Grant:  http://www.webmproject.org/license/additional/
    14.9 -// -----------------------------------------------------------------------------
   14.10 -//
   14.11 -//  Low-level API for VP8 decoder
   14.12 -//
   14.13 -// Author: Skal (pascal.massimino@gmail.com)
   14.14 -
   14.15 -#ifndef WEBP_WEBP_DECODE_VP8_H_
   14.16 -#define WEBP_WEBP_DECODE_VP8_H_
   14.17 -
   14.18 -#include "./decode.h"
   14.19 -
   14.20 -#if defined(__cplusplus) || defined(c_plusplus)
   14.21 -extern "C" {
   14.22 -#endif
   14.23 -
   14.24 -//------------------------------------------------------------------------------
   14.25 -// Lower-level API
   14.26 -//
   14.27 -// These functions provide fine-grained control of the decoding process.
   14.28 -// The call flow should resemble:
   14.29 -//
   14.30 -//   VP8Io io;
   14.31 -//   VP8InitIo(&io);
   14.32 -//   io.data = data;
   14.33 -//   io.data_size = size;
   14.34 -//   /* customize io's functions (setup()/put()/teardown()) if needed. */
   14.35 -//
   14.36 -//   VP8Decoder* dec = VP8New();
   14.37 -//   bool ok = VP8Decode(dec);
   14.38 -//   if (!ok) printf("Error: %s\n", VP8StatusMessage(dec));
   14.39 -//   VP8Delete(dec);
   14.40 -//   return ok;
   14.41 -
   14.42 -// Input / Output
   14.43 -typedef struct VP8Io VP8Io;
   14.44 -typedef int (*VP8IoPutHook)(const VP8Io* io);
   14.45 -typedef int (*VP8IoSetupHook)(VP8Io* io);
   14.46 -typedef void (*VP8IoTeardownHook)(const VP8Io* io);
   14.47 -
   14.48 -struct VP8Io {
   14.49 -  // set by VP8GetHeaders()
   14.50 -  int width, height;         // picture dimensions, in pixels (invariable).
   14.51 -                             // These are the original, uncropped dimensions.
   14.52 -                             // The actual area passed to put() is stored
   14.53 -                             // in mb_w / mb_h fields.
   14.54 -
   14.55 -  // set before calling put()
   14.56 -  int mb_y;                  // position of the current rows (in pixels)
   14.57 -  int mb_w;                  // number of columns in the sample
   14.58 -  int mb_h;                  // number of rows in the sample
   14.59 -  const uint8_t* y, *u, *v;  // rows to copy (in yuv420 format)
   14.60 -  int y_stride;              // row stride for luma
   14.61 -  int uv_stride;             // row stride for chroma
   14.62 -
   14.63 -  void* opaque;              // user data
   14.64 -
   14.65 -  // called when fresh samples are available. Currently, samples are in
   14.66 -  // YUV420 format, and can be up to width x 24 in size (depending on the
   14.67 -  // in-loop filtering level, e.g.). Should return false in case of error
   14.68 -  // or abort request. The actual size of the area to update is mb_w x mb_h
   14.69 -  // in size, taking cropping into account.
   14.70 -  VP8IoPutHook put;
   14.71 -
   14.72 -  // called just before starting to decode the blocks.
   14.73 -  // Must return false in case of setup error, true otherwise. If false is
   14.74 -  // returned, teardown() will NOT be called. But if the setup succeeded
   14.75 -  // and true is returned, then teardown() will always be called afterward.
   14.76 -  VP8IoSetupHook setup;
   14.77 -
   14.78 -  // Called just after block decoding is finished (or when an error occurred
   14.79 -  // during put()). Is NOT called if setup() failed.
   14.80 -  VP8IoTeardownHook teardown;
   14.81 -
   14.82 -  // this is a recommendation for the user-side yuv->rgb converter. This flag
   14.83 -  // is set when calling setup() hook and can be overwritten by it. It then
   14.84 -  // can be taken into consideration during the put() method.
   14.85 -  int fancy_upsampling;
   14.86 -
   14.87 -  // Input buffer.
   14.88 -  uint32_t data_size;
   14.89 -  const uint8_t* data;
   14.90 -
   14.91 -  // If true, in-loop filtering will not be performed even if present in the
   14.92 -  // bitstream. Switching off filtering may speed up decoding at the expense
   14.93 -  // of more visible blocking. Note that output will also be non-compliant
   14.94 -  // with the VP8 specifications.
   14.95 -  int bypass_filtering;
   14.96 -
   14.97 -  // Cropping parameters.
   14.98 -  int use_cropping;
   14.99 -  int crop_left, crop_right, crop_top, crop_bottom;
  14.100 -
  14.101 -  // Scaling parameters.
  14.102 -  int use_scaling;
  14.103 -  int scaled_width, scaled_height;
  14.104 -
  14.105 -  // pointer to the alpha data (if present) corresponding to the rows
  14.106 -  const uint8_t* a;
  14.107 -};
  14.108 -
  14.109 -// Internal, version-checked, entry point
  14.110 -WEBP_EXTERN(int) VP8InitIoInternal(VP8Io* const, int);
  14.111 -
  14.112 -// Set the custom IO function pointers and user-data. The setter for IO hooks
  14.113 -// should be called before initiating incremental decoding. Returns true if
  14.114 -// WebPIDecoder object is successfully modified, false otherwise.
  14.115 -WEBP_EXTERN(int) WebPISetIOHooks(WebPIDecoder* const idec,
  14.116 -                                 VP8IoPutHook put,
  14.117 -                                 VP8IoSetupHook setup,
  14.118 -                                 VP8IoTeardownHook teardown,
  14.119 -                                 void* user_data);
  14.120 -
  14.121 -// Main decoding object. This is an opaque structure.
  14.122 -typedef struct VP8Decoder VP8Decoder;
  14.123 -
  14.124 -// Create a new decoder object.
  14.125 -WEBP_EXTERN(VP8Decoder*) VP8New(void);
  14.126 -
  14.127 -// Must be called to make sure 'io' is initialized properly.
  14.128 -// Returns false in case of version mismatch. Upon such failure, no other
  14.129 -// decoding function should be called (VP8Decode, VP8GetHeaders, ...)
  14.130 -static WEBP_INLINE int VP8InitIo(VP8Io* const io) {
  14.131 -  return VP8InitIoInternal(io, WEBP_DECODER_ABI_VERSION);
  14.132 -}
  14.133 -
  14.134 -// Start decoding a new picture. Returns true if ok.
  14.135 -WEBP_EXTERN(int) VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io);
  14.136 -
  14.137 -// Decode a picture. Will call VP8GetHeaders() if it wasn't done already.
  14.138 -// Returns false in case of error.
  14.139 -WEBP_EXTERN(int) VP8Decode(VP8Decoder* const dec, VP8Io* const io);
  14.140 -
  14.141 -// Return current status of the decoder:
  14.142 -WEBP_EXTERN(VP8StatusCode) VP8Status(VP8Decoder* const dec);
  14.143 -
  14.144 -// return readable string corresponding to the last status.
  14.145 -WEBP_EXTERN(const char*) VP8StatusMessage(VP8Decoder* const dec);
  14.146 -
  14.147 -// Resets the decoder in its initial state, reclaiming memory.
  14.148 -// Not a mandatory call between calls to VP8Decode().
  14.149 -WEBP_EXTERN(void) VP8Clear(VP8Decoder* const dec);
  14.150 -
  14.151 -// Destroy the decoder object.
  14.152 -WEBP_EXTERN(void) VP8Delete(VP8Decoder* const dec);
  14.153 -
  14.154 -//------------------------------------------------------------------------------
  14.155 -
  14.156 -#if defined(__cplusplus) || defined(c_plusplus)
  14.157 -}    // extern "C"
  14.158 -#endif
  14.159 -
  14.160 -#endif  /* WEBP_WEBP_DECODE_VP8_H_ */
    15.1 --- a/Xcode/Frameworks/webp.framework/Versions/A/Headers/webp/encode.h	Tue Oct 16 20:02:02 2018 +0300
    15.2 +++ b/Xcode/Frameworks/webp.framework/Versions/A/Headers/webp/encode.h	Wed Oct 17 01:00:32 2018 +0300
    15.3 @@ -1,8 +1,10 @@
    15.4 -// Copyright 2011 Google Inc.
    15.5 +// Copyright 2011 Google Inc. All Rights Reserved.
    15.6  //
    15.7 -// This code is licensed under the same terms as WebM:
    15.8 -//  Software License Agreement:  http://www.webmproject.org/license/software/
    15.9 -//  Additional IP Rights Grant:  http://www.webmproject.org/license/additional/
   15.10 +// Use of this source code is governed by a BSD-style license
   15.11 +// that can be found in the COPYING file in the root of the source
   15.12 +// tree. An additional intellectual property rights grant can be found
   15.13 +// in the file PATENTS. All contributing project authors may
   15.14 +// be found in the AUTHORS file in the root of the source tree.
   15.15  // -----------------------------------------------------------------------------
   15.16  //
   15.17  //   WebP encoder: main interface
   15.18 @@ -12,15 +14,24 @@
   15.19  #ifndef WEBP_WEBP_ENCODE_H_
   15.20  #define WEBP_WEBP_ENCODE_H_
   15.21  
   15.22 -#include <stdlib.h>
   15.23 -
   15.24  #include "./types.h"
   15.25  
   15.26 -#if defined(__cplusplus) || defined(c_plusplus)
   15.27 +#ifdef __cplusplus
   15.28  extern "C" {
   15.29  #endif
   15.30  
   15.31 -#define WEBP_ENCODER_ABI_VERSION 0x0003
   15.32 +#define WEBP_ENCODER_ABI_VERSION 0x020e    // MAJOR(8b) + MINOR(8b)
   15.33 +
   15.34 +// Note: forward declaring enumerations is not allowed in (strict) C and C++,
   15.35 +// the types are left here for reference.
   15.36 +// typedef enum WebPImageHint WebPImageHint;
   15.37 +// typedef enum WebPEncCSP WebPEncCSP;
   15.38 +// typedef enum WebPPreset WebPPreset;
   15.39 +// typedef enum WebPEncodingError WebPEncodingError;
   15.40 +typedef struct WebPConfig WebPConfig;
   15.41 +typedef struct WebPPicture WebPPicture;   // main structure for I/O
   15.42 +typedef struct WebPAuxStats WebPAuxStats;
   15.43 +typedef struct WebPMemoryWriter WebPMemoryWriter;
   15.44  
   15.45  // Return the encoder's version number, packed in hexadecimal using 8bits for
   15.46  // each of major/minor/revision. E.g: v2.5.7 is 0x020507.
   15.47 @@ -31,7 +42,10 @@
   15.48  
   15.49  // Returns the size of the compressed data (pointed to by *output), or 0 if
   15.50  // an error occurred. The compressed data must be released by the caller
   15.51 -// using the call 'free(*output)'.
   15.52 +// using the call 'WebPFree(*output)'.
   15.53 +// These functions compress using the lossy format, and the quality_factor
   15.54 +// can go from 0 (smaller output, lower quality) to 100 (best quality,
   15.55 +// larger output).
   15.56  WEBP_EXTERN(size_t) WebPEncodeRGB(const uint8_t* rgb,
   15.57                                    int width, int height, int stride,
   15.58                                    float quality_factor, uint8_t** output);
   15.59 @@ -45,42 +59,97 @@
   15.60                                     int width, int height, int stride,
   15.61                                     float quality_factor, uint8_t** output);
   15.62  
   15.63 +// These functions are the equivalent of the above, but compressing in a
   15.64 +// lossless manner. Files are usually larger than lossy format, but will
   15.65 +// not suffer any compression loss.
   15.66 +WEBP_EXTERN(size_t) WebPEncodeLosslessRGB(const uint8_t* rgb,
   15.67 +                                          int width, int height, int stride,
   15.68 +                                          uint8_t** output);
   15.69 +WEBP_EXTERN(size_t) WebPEncodeLosslessBGR(const uint8_t* bgr,
   15.70 +                                          int width, int height, int stride,
   15.71 +                                          uint8_t** output);
   15.72 +WEBP_EXTERN(size_t) WebPEncodeLosslessRGBA(const uint8_t* rgba,
   15.73 +                                           int width, int height, int stride,
   15.74 +                                           uint8_t** output);
   15.75 +WEBP_EXTERN(size_t) WebPEncodeLosslessBGRA(const uint8_t* bgra,
   15.76 +                                           int width, int height, int stride,
   15.77 +                                           uint8_t** output);
   15.78 +
   15.79 +// Releases memory returned by the WebPEncode*() functions above.
   15.80 +WEBP_EXTERN(void) WebPFree(void* ptr);
   15.81 +
   15.82  //------------------------------------------------------------------------------
   15.83  // Coding parameters
   15.84  
   15.85 -typedef struct {
   15.86 -  float quality;         // between 0 (smallest file) and 100 (biggest)
   15.87 -  int target_size;       // if non-zero, set the desired target size in bytes.
   15.88 -                         // Takes precedence over the 'compression' parameter.
   15.89 -  float target_PSNR;     // if non-zero, specifies the minimal distortion to
   15.90 -                         // try to achieve. Takes precedence over target_size.
   15.91 -  int method;            // quality/speed trade-off (0=fast, 6=slower-better)
   15.92 -  int segments;          // maximum number of segments to use, in [1..4]
   15.93 -  int sns_strength;      // Spatial Noise Shaping. 0=off, 100=maximum.
   15.94 -  int filter_strength;   // range: [0 = off .. 100 = strongest]
   15.95 -  int filter_sharpness;  // range: [0 = off .. 7 = least sharp]
   15.96 -  int filter_type;       // filtering type: 0 = simple, 1 = strong
   15.97 -                         // (only used if filter_strength > 0 or autofilter > 0)
   15.98 -  int autofilter;        // Auto adjust filter's strength [0 = off, 1 = on]
   15.99 -  int pass;              // number of entropy-analysis passes (in [1..10]).
  15.100 +// Image characteristics hint for the underlying encoder.
  15.101 +typedef enum WebPImageHint {
  15.102 +  WEBP_HINT_DEFAULT = 0,  // default preset.
  15.103 +  WEBP_HINT_PICTURE,      // digital picture, like portrait, inner shot
  15.104 +  WEBP_HINT_PHOTO,        // outdoor photograph, with natural lighting
  15.105 +  WEBP_HINT_GRAPH,        // Discrete tone image (graph, map-tile etc).
  15.106 +  WEBP_HINT_LAST
  15.107 +} WebPImageHint;
  15.108  
  15.109 -  int show_compressed;   // if true, export the compressed picture back.
  15.110 -                         // In-loop filtering is not applied.
  15.111 -  int preprocessing;     // preprocessing filter (0=none, 1=segment-smooth)
  15.112 -  int partitions;        // log2(number of token partitions) in [0..3]
  15.113 -                         // Default is set to 0 for easier progressive decoding.
  15.114 -  int partition_limit;   // quality degradation allowed to fit the 512k limit on
  15.115 -                         // prediction modes coding (0=no degradation, 100=full)
  15.116 +// Compression parameters.
  15.117 +struct WebPConfig {
  15.118 +  int lossless;           // Lossless encoding (0=lossy(default), 1=lossless).
  15.119 +  float quality;          // between 0 (smallest file) and 100 (biggest)
  15.120 +  int method;             // quality/speed trade-off (0=fast, 6=slower-better)
  15.121 +
  15.122 +  WebPImageHint image_hint;  // Hint for image type (lossless only for now).
  15.123 +
  15.124 +  // Parameters related to lossy compression only:
  15.125 +  int target_size;        // if non-zero, set the desired target size in bytes.
  15.126 +                          // Takes precedence over the 'compression' parameter.
  15.127 +  float target_PSNR;      // if non-zero, specifies the minimal distortion to
  15.128 +                          // try to achieve. Takes precedence over target_size.
  15.129 +  int segments;           // maximum number of segments to use, in [1..4]
  15.130 +  int sns_strength;       // Spatial Noise Shaping. 0=off, 100=maximum.
  15.131 +  int filter_strength;    // range: [0 = off .. 100 = strongest]
  15.132 +  int filter_sharpness;   // range: [0 = off .. 7 = least sharp]
  15.133 +  int filter_type;        // filtering type: 0 = simple, 1 = strong (only used
  15.134 +                          // if filter_strength > 0 or autofilter > 0)
  15.135 +  int autofilter;         // Auto adjust filter's strength [0 = off, 1 = on]
  15.136    int alpha_compression;  // Algorithm for encoding the alpha plane (0 = none,
  15.137 -                          // 1 = backward reference counts encoded with
  15.138 -                          // arithmetic encoder). Default is 1.
  15.139 +                          // 1 = compressed with WebP lossless). Default is 1.
  15.140 +  int alpha_filtering;    // Predictive filtering method for alpha plane.
  15.141 +                          //  0: none, 1: fast, 2: best. Default if 1.
  15.142    int alpha_quality;      // Between 0 (smallest size) and 100 (lossless).
  15.143                            // Default is 100.
  15.144 -} WebPConfig;
  15.145 +  int pass;               // number of entropy-analysis passes (in [1..10]).
  15.146 +
  15.147 +  int show_compressed;    // if true, export the compressed picture back.
  15.148 +                          // In-loop filtering is not applied.
  15.149 +  int preprocessing;      // preprocessing filter:
  15.150 +                          // 0=none, 1=segment-smooth, 2=pseudo-random dithering
  15.151 +  int partitions;         // log2(number of token partitions) in [0..3]. Default
  15.152 +                          // is set to 0 for easier progressive decoding.
  15.153 +  int partition_limit;    // quality degradation allowed to fit the 512k limit
  15.154 +                          // on prediction modes coding (0: no degradation,
  15.155 +                          // 100: maximum possible degradation).
  15.156 +  int emulate_jpeg_size;  // If true, compression parameters will be remapped
  15.157 +                          // to better match the expected output size from
  15.158 +                          // JPEG compression. Generally, the output size will
  15.159 +                          // be similar but the degradation will be lower.
  15.160 +  int thread_level;       // If non-zero, try and use multi-threaded encoding.
  15.161 +  int low_memory;         // If set, reduce memory usage (but increase CPU use).
  15.162 +
  15.163 +  int near_lossless;      // Near lossless encoding [0 = max loss .. 100 = off
  15.164 +                          // (default)].
  15.165 +  int exact;              // if non-zero, preserve the exact RGB values under
  15.166 +                          // transparent area. Otherwise, discard this invisible
  15.167 +                          // RGB information for better compression. The default
  15.168 +                          // value is 0.
  15.169 +
  15.170 +  int use_delta_palette;  // reserved for future lossless feature
  15.171 +  int use_sharp_yuv;      // if needed, use sharp (and slow) RGB->YUV conversion
  15.172 +
  15.173 +  uint32_t pad[2];        // padding for later use
  15.174 +};
  15.175  
  15.176  // Enumerate some predefined settings for WebPConfig, depending on the type
  15.177  // of source picture. These presets are used when calling WebPConfigPreset().
  15.178 -typedef enum {
  15.179 +typedef enum WebPPreset {
  15.180    WEBP_PRESET_DEFAULT = 0,  // default preset.
  15.181    WEBP_PRESET_PICTURE,      // digital picture, like portrait, inner shot
  15.182    WEBP_PRESET_PHOTO,        // outdoor photograph, with natural lighting
  15.183 @@ -90,13 +159,13 @@
  15.184  } WebPPreset;
  15.185  
  15.186  // Internal, version-checked, entry point
  15.187 -WEBP_EXTERN(int) WebPConfigInitInternal(
  15.188 -    WebPConfig* const, WebPPreset, float, int);
  15.189 +WEBP_EXTERN(int) WebPConfigInitInternal(WebPConfig*, WebPPreset, float, int);
  15.190  
  15.191  // Should always be called, to initialize a fresh WebPConfig structure before
  15.192 -// modification. Returns 0 in case of version mismatch. WebPConfigInit() must
  15.193 -// have succeeded before using the 'config' object.
  15.194 -static WEBP_INLINE int WebPConfigInit(WebPConfig* const config) {
  15.195 +// modification. Returns false in case of version mismatch. WebPConfigInit()
  15.196 +// must have succeeded before using the 'config' object.
  15.197 +// Note that the default values are lossless=0 and quality=75.
  15.198 +static WEBP_INLINE int WebPConfigInit(WebPConfig* config) {
  15.199    return WebPConfigInitInternal(config, WEBP_PRESET_DEFAULT, 75.f,
  15.200                                  WEBP_ENCODER_ABI_VERSION);
  15.201  }
  15.202 @@ -104,25 +173,33 @@
  15.203  // This function will initialize the configuration according to a predefined
  15.204  // set of parameters (referred to by 'preset') and a given quality factor.
  15.205  // This function can be called as a replacement to WebPConfigInit(). Will
  15.206 -// return 0 in case of error.
  15.207 -static WEBP_INLINE int WebPConfigPreset(WebPConfig* const config,
  15.208 +// return false in case of error.
  15.209 +static WEBP_INLINE int WebPConfigPreset(WebPConfig* config,
  15.210                                          WebPPreset preset, float quality) {
  15.211    return WebPConfigInitInternal(config, preset, quality,
  15.212                                  WEBP_ENCODER_ABI_VERSION);
  15.213  }
  15.214  
  15.215 -// Returns 1 if all parameters are in valid range and the configuration is OK.
  15.216 -WEBP_EXTERN(int) WebPValidateConfig(const WebPConfig* const config);
  15.217 +// Activate the lossless compression mode with the desired efficiency level
  15.218 +// between 0 (fastest, lowest compression) and 9 (slower, best compression).
  15.219 +// A good default level is '6', providing a fair tradeoff between compression
  15.220 +// speed and final compressed size.
  15.221 +// This function will overwrite several fields from config: 'method', 'quality'
  15.222 +// and 'lossless'. Returns false in case of parameter error.
  15.223 +WEBP_EXTERN(int) WebPConfigLosslessPreset(WebPConfig* config, int level);
  15.224 +
  15.225 +// Returns true if 'config' is non-NULL and all configuration parameters are
  15.226 +// within their valid ranges.
  15.227 +WEBP_EXTERN(int) WebPValidateConfig(const WebPConfig* config);
  15.228  
  15.229  //------------------------------------------------------------------------------
  15.230  // Input / Output
  15.231 +// Structure for storing auxiliary statistics (mostly for lossy encoding).
  15.232  
  15.233 -typedef struct WebPPicture WebPPicture;   // main structure for I/O
  15.234 +struct WebPAuxStats {
  15.235 +  int coded_size;         // final size
  15.236  
  15.237 -// non-essential structure for storing auxiliary statistics
  15.238 -typedef struct {
  15.239 -  float PSNR[4];          // peak-signal-to-noise ratio for Y/U/V/All
  15.240 -  int coded_size;         // final size
  15.241 +  float PSNR[5];          // peak-signal-to-noise ratio for Y/U/V/All/Alpha
  15.242    int block_count[3];     // number of intra4/intra16/skipped macroblocks
  15.243    int header_bytes[2];    // approximate number of bytes spent for header
  15.244                            // and mode-partition #0
  15.245 @@ -135,37 +212,63 @@
  15.246    int alpha_data_size;    // size of the transparency data
  15.247    int layer_data_size;    // size of the enhancement layer data
  15.248  
  15.249 -  void* user_data;        // this field is free to be set to any value and
  15.250 -                          // used during callbacks (like progress-report e.g.).
  15.251 -} WebPAuxStats;
  15.252 +  // lossless encoder statistics
  15.253 +  uint32_t lossless_features;  // bit0:predictor bit1:cross-color transform
  15.254 +                               // bit2:subtract-green bit3:color indexing
  15.255 +  int histogram_bits;          // number of precision bits of histogram
  15.256 +  int transform_bits;          // precision bits for transform
  15.257 +  int cache_bits;              // number of bits for color cache lookup
  15.258 +  int palette_size;            // number of color in palette, if used
  15.259 +  int lossless_size;           // final lossless size
  15.260 +  int lossless_hdr_size;       // lossless header (transform, huffman etc) size
  15.261 +  int lossless_data_size;      // lossless image data size
  15.262  
  15.263 -// Signature for output function. Should return 1 if writing was successful.
  15.264 +  uint32_t pad[2];        // padding for later use
  15.265 +};
  15.266 +
  15.267 +// Signature for output function. Should return true if writing was successful.
  15.268  // data/data_size is the segment of data to write, and 'picture' is for
  15.269  // reference (and so one can make use of picture->custom_ptr).
  15.270  typedef int (*WebPWriterFunction)(const uint8_t* data, size_t data_size,
  15.271 -                                  const WebPPicture* const picture);
  15.272 +                                  const WebPPicture* picture);
  15.273  
  15.274 -// Progress hook, called from time to time to report progress. It can return 0
  15.275 -// to request an abort of the encoding process, or 1 otherwise if all is OK.
  15.276 -typedef int (*WebPProgressHook)(int percent, const WebPPicture* const picture);
  15.277 +// WebPMemoryWrite: a special WebPWriterFunction that writes to memory using
  15.278 +// the following WebPMemoryWriter object (to be set as a custom_ptr).
  15.279 +struct WebPMemoryWriter {
  15.280 +  uint8_t* mem;       // final buffer (of size 'max_size', larger than 'size').
  15.281 +  size_t   size;      // final size
  15.282 +  size_t   max_size;  // total capacity
  15.283 +  uint32_t pad[1];    // padding for later use
  15.284 +};
  15.285  
  15.286 -typedef enum {
  15.287 +// The following must be called first before any use.
  15.288 +WEBP_EXTERN(void) WebPMemoryWriterInit(WebPMemoryWriter* writer);
  15.289 +
  15.290 +// The following must be called to deallocate writer->mem memory. The 'writer'
  15.291 +// object itself is not deallocated.
  15.292 +WEBP_EXTERN(void) WebPMemoryWriterClear(WebPMemoryWriter* writer);
  15.293 +// The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon
  15.294 +// completion, writer.mem and writer.size will hold the coded data.
  15.295 +// writer.mem must be freed by calling WebPMemoryWriterClear.
  15.296 +WEBP_EXTERN(int) WebPMemoryWrite(const uint8_t* data, size_t data_size,
  15.297 +                                 const WebPPicture* picture);
  15.298 +
  15.299 +// Progress hook, called from time to time to report progress. It can return
  15.300 +// false to request an abort of the encoding process, or true otherwise if
  15.301 +// everything is OK.
  15.302 +typedef int (*WebPProgressHook)(int percent, const WebPPicture* picture);
  15.303 +
  15.304 +// Color spaces.
  15.305 +typedef enum WebPEncCSP {
  15.306    // chroma sampling
  15.307 -  WEBP_YUV420 = 0,   // 4:2:0
  15.308 -  WEBP_YUV422 = 1,   // 4:2:2
  15.309 -  WEBP_YUV444 = 2,   // 4:4:4
  15.310 -  WEBP_YUV400 = 3,   // grayscale
  15.311 -  WEBP_CSP_UV_MASK = 3,   // bit-mask to get the UV sampling factors
  15.312 -  // alpha channel variants
  15.313 -  WEBP_YUV420A = 4,
  15.314 -  WEBP_YUV422A = 5,
  15.315 -  WEBP_YUV444A = 6,
  15.316 -  WEBP_YUV400A = 7,   // grayscale + alpha
  15.317 +  WEBP_YUV420  = 0,        // 4:2:0
  15.318 +  WEBP_YUV420A = 4,        // alpha channel variant
  15.319 +  WEBP_CSP_UV_MASK = 3,    // bit-mask to get the UV sampling factors
  15.320    WEBP_CSP_ALPHA_BIT = 4   // bit that is set if alpha is present
  15.321  } WebPEncCSP;
  15.322  
  15.323  // Encoding error conditions.
  15.324 -typedef enum {
  15.325 +typedef enum WebPEncodingError {
  15.326    VP8_ENC_OK = 0,
  15.327    VP8_ENC_ERROR_OUT_OF_MEMORY,            // memory error allocating objects
  15.328    VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY,  // memory error while flushing bits
  15.329 @@ -183,20 +286,37 @@
  15.330  // maximum width/height allowed (inclusive), in pixels
  15.331  #define WEBP_MAX_DIMENSION 16383
  15.332  
  15.333 +// Main exchange structure (input samples, output bytes, statistics)
  15.334  struct WebPPicture {
  15.335 -  // input
  15.336 +  //   INPUT
  15.337 +  //////////////
  15.338 +  // Main flag for encoder selecting between ARGB or YUV input.
  15.339 +  // It is recommended to use ARGB input (*argb, argb_stride) for lossless
  15.340 +  // compression, and YUV input (*y, *u, *v, etc.) for lossy compression
  15.341 +  // since these are the respective native colorspace for these formats.
  15.342 +  int use_argb;
  15.343 +
  15.344 +  // YUV input (mostly used for input to lossy compression)
  15.345    WebPEncCSP colorspace;     // colorspace: should be YUV420 for now (=Y'CbCr).
  15.346    int width, height;         // dimensions (less or equal to WEBP_MAX_DIMENSION)
  15.347    uint8_t *y, *u, *v;        // pointers to luma/chroma planes.
  15.348    int y_stride, uv_stride;   // luma/chroma strides.
  15.349 -  uint8_t *a;                // pointer to the alpha plane
  15.350 +  uint8_t* a;                // pointer to the alpha plane
  15.351    int a_stride;              // stride of the alpha plane
  15.352 +  uint32_t pad1[2];          // padding for later use
  15.353  
  15.354 -  // output
  15.355 +  // ARGB input (mostly used for input to lossless compression)
  15.356 +  uint32_t* argb;            // Pointer to argb (32 bit) plane.
  15.357 +  int argb_stride;           // This is stride in pixels units, not bytes.
  15.358 +  uint32_t pad2[3];          // padding for later use
  15.359 +
  15.360 +  //   OUTPUT
  15.361 +  ///////////////
  15.362 +  // Byte-emission hook, to store compressed bytes as they are ready.
  15.363    WebPWriterFunction writer;  // can be NULL
  15.364    void* custom_ptr;           // can be used by the writer.
  15.365  
  15.366 -  // map for extra information
  15.367 +  // map for extra information (only for lossy compression mode)
  15.368    int extra_info_type;    // 1: intra type, 2: segment, 3: quant
  15.369                            // 4: intra-16 prediction mode,
  15.370                            // 5: chroma prediction mode,
  15.371 @@ -206,25 +326,41 @@
  15.372                            // will be filled with a macroblock map, depending
  15.373                            // on extra_info_type.
  15.374  
  15.375 -  // where to store statistics, if not NULL:
  15.376 +  //   STATS AND REPORTS
  15.377 +  ///////////////////////////
  15.378 +  // Pointer to side statistics (updated only if not NULL)
  15.379    WebPAuxStats* stats;
  15.380  
  15.381 -  // original samples (for non-YUV420 modes)
  15.382 -  uint8_t *u0, *v0;
  15.383 -  int uv0_stride;
  15.384 +  // Error code for the latest error encountered during encoding
  15.385 +  WebPEncodingError error_code;
  15.386  
  15.387 -  WebPEncodingError error_code;   // error code in case of problem.
  15.388 +  // If not NULL, report progress during encoding.
  15.389 +  WebPProgressHook progress_hook;
  15.390  
  15.391 -  WebPProgressHook progress_hook;  // if not NULL, called while encoding.
  15.392 +  void* user_data;        // this field is free to be set to any value and
  15.393 +                          // used during callbacks (like progress-report e.g.).
  15.394 +
  15.395 +  uint32_t pad3[3];       // padding for later use
  15.396 +
  15.397 +  // Unused for now
  15.398 +  uint8_t *pad4, *pad5;
  15.399 +  uint32_t pad6[8];       // padding for later use
  15.400 +
  15.401 +  // PRIVATE FIELDS
  15.402 +  ////////////////////
  15.403 +  void* memory_;          // row chunk of memory for yuva planes
  15.404 +  void* memory_argb_;     // and for argb too.
  15.405 +  void* pad7[2];          // padding for later use
  15.406  };
  15.407  
  15.408  // Internal, version-checked, entry point
  15.409 -WEBP_EXTERN(int) WebPPictureInitInternal(WebPPicture* const, int);
  15.410 +WEBP_EXTERN(int) WebPPictureInitInternal(WebPPicture*, int);
  15.411  
  15.412 -// Should always be called, to initialize the structure. Returns 0 in case of
  15.413 -// version mismatch. WebPPictureInit() must have succeeded before using the
  15.414 +// Should always be called, to initialize the structure. Returns false in case
  15.415 +// of version mismatch. WebPPictureInit() must have succeeded before using the
  15.416  // 'picture' object.
  15.417 -static WEBP_INLINE int WebPPictureInit(WebPPicture* const picture) {
  15.418 +// Note that, by default, use_argb is false and colorspace is WEBP_YUV420.
  15.419 +static WEBP_INLINE int WebPPictureInit(WebPPicture* picture) {
  15.420    return WebPPictureInitInternal(picture, WEBP_ENCODER_ABI_VERSION);
  15.421  }
  15.422  
  15.423 @@ -234,45 +370,153 @@
  15.424  // Convenience allocation / deallocation based on picture->width/height:
  15.425  // Allocate y/u/v buffers as per colorspace/width/height specification.
  15.426  // Note! This function will free the previous buffer if needed.
  15.427 -// Returns 0 in case of memory error.
  15.428 -WEBP_EXTERN(int) WebPPictureAlloc(WebPPicture* const picture);
  15.429 +// Returns false in case of memory error.
  15.430 +WEBP_EXTERN(int) WebPPictureAlloc(WebPPicture* picture);
  15.431  
  15.432 -// Release memory allocated by WebPPictureAlloc() or WebPPictureImport*()
  15.433 -// Note that this function does _not_ free the memory pointed to by 'picture'.
  15.434 -WEBP_EXTERN(void) WebPPictureFree(WebPPicture* const picture);
  15.435 +// Release the memory allocated by WebPPictureAlloc() or WebPPictureImport*().
  15.436 +// Note that this function does _not_ free the memory used by the 'picture'
  15.437 +// object itself.
  15.438 +// Besides memory (which is reclaimed) all other fields of 'picture' are
  15.439 +// preserved.
  15.440 +WEBP_EXTERN(void) WebPPictureFree(WebPPicture* picture);
  15.441  
  15.442 -// Copy the pixels of *src into *dst, using WebPPictureAlloc.
  15.443 -// Returns 0 in case of memory allocation error.
  15.444 -WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* const src,
  15.445 -                                 WebPPicture* const dst);
  15.446 +// Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return, *dst
  15.447 +// will fully own the copied pixels (this is not a view). The 'dst' picture need
  15.448 +// not be initialized as its content is overwritten.
  15.449 +// Returns false in case of memory allocation error.
  15.450 +WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* src, WebPPicture* dst);
  15.451 +
  15.452 +// Compute the single distortion for packed planes of samples.
  15.453 +// 'src' will be compared to 'ref', and the raw distortion stored into
  15.454 +// '*distortion'. The refined metric (log(MSE), log(1 - ssim),...' will be
  15.455 +// stored in '*result'.
  15.456 +// 'x_step' is the horizontal stride (in bytes) between samples.
  15.457 +// 'src/ref_stride' is the byte distance between rows.
  15.458 +// Returns false in case of error (bad parameter, memory allocation error, ...).
  15.459 +WEBP_EXTERN(int) WebPPlaneDistortion(const uint8_t* src, size_t src_stride,
  15.460 +                                     const uint8_t* ref, size_t ref_stride,
  15.461 +                                     int width, int height,
  15.462 +                                     size_t x_step,
  15.463 +                                     int type,   // 0 = PSNR, 1 = SSIM, 2 = LSIM
  15.464 +                                     float* distortion, float* result);
  15.465 +
  15.466 +// Compute PSNR, SSIM or LSIM distortion metric between two pictures. Results
  15.467 +// are in dB, stored in result[] in the B/G/R/A/All order. The distortion is
  15.468 +// always performed using ARGB samples. Hence if the input is YUV(A), the
  15.469 +// picture will be internally converted to ARGB (just for the measurement).
  15.470 +// Warning: this function is rather CPU-intensive.
  15.471 +WEBP_EXTERN(int) WebPPictureDistortion(
  15.472 +    const WebPPicture* src, const WebPPicture* ref,
  15.473 +    int metric_type,           // 0 = PSNR, 1 = SSIM, 2 = LSIM
  15.474 +    float result[5]);
  15.475  
  15.476  // self-crops a picture to the rectangle defined by top/left/width/height.
  15.477 -// Returns 0 in case of memory allocation error, or if the rectangle is
  15.478 +// Returns false in case of memory allocation error, or if the rectangle is
  15.479  // outside of the source picture.
  15.480 -WEBP_EXTERN(int) WebPPictureCrop(WebPPicture* const picture,
  15.481 +// The rectangle for the view is defined by the top-left corner pixel
  15.482 +// coordinates (left, top) as well as its width and height. This rectangle
  15.483 +// must be fully be comprised inside the 'src' source picture. If the source
  15.484 +// picture uses the YUV420 colorspace, the top and left coordinates will be
  15.485 +// snapped to even values.
  15.486 +WEBP_EXTERN(int) WebPPictureCrop(WebPPicture* picture,
  15.487                                   int left, int top, int width, int height);
  15.488  
  15.489 +// Extracts a view from 'src' picture into 'dst'. The rectangle for the view
  15.490 +// is defined by the top-left corner pixel coordinates (left, top) as well
  15.491 +// as its width and height. This rectangle must be fully be comprised inside
  15.492 +// the 'src' source picture. If the source picture uses the YUV420 colorspace,
  15.493 +// the top and left coordinates will be snapped to even values.
  15.494 +// Picture 'src' must out-live 'dst' picture. Self-extraction of view is allowed
  15.495 +// ('src' equal to 'dst') as a mean of fast-cropping (but note that doing so,
  15.496 +// the original dimension will be lost). Picture 'dst' need not be initialized
  15.497 +// with WebPPictureInit() if it is different from 'src', since its content will
  15.498 +// be overwritten.
  15.499 +// Returns false in case of memory allocation error or invalid parameters.
  15.500 +WEBP_EXTERN(int) WebPPictureView(const WebPPicture* src,
  15.501 +                                 int left, int top, int width, int height,
  15.502 +                                 WebPPicture* dst);
  15.503 +
  15.504 +// Returns true if the 'picture' is actually a view and therefore does
  15.505 +// not own the memory for pixels.
  15.506 +WEBP_EXTERN(int) WebPPictureIsView(const WebPPicture* picture);
  15.507 +
  15.508  // Rescale a picture to new dimension width x height.
  15.509 -// Now gamma correction is applied.
  15.510 +// If either 'width' or 'height' (but not both) is 0 the corresponding
  15.511 +// dimension will be calculated preserving the aspect ratio.
  15.512 +// No gamma correction is applied.
  15.513  // Returns false in case of error (invalid parameter or insufficient memory).
  15.514 -WEBP_EXTERN(int) WebPPictureRescale(WebPPicture* const pic,
  15.515 -                                    int width, int height);
  15.516 +WEBP_EXTERN(int) WebPPictureRescale(WebPPicture* pic, int width, int height);
  15.517  
  15.518  // Colorspace conversion function to import RGB samples.
  15.519  // Previous buffer will be free'd, if any.
  15.520  // *rgb buffer should have a size of at least height * rgb_stride.
  15.521 -// Returns 0 in case of memory error.
  15.522 +// Returns false in case of memory error.
  15.523  WEBP_EXTERN(int) WebPPictureImportRGB(
  15.524 -    WebPPicture* const picture, const uint8_t* const rgb, int rgb_stride);
  15.525 -// Same, but for RGBA buffer
  15.526 +    WebPPicture* picture, const uint8_t* rgb, int rgb_stride);
  15.527 +// Same, but for RGBA buffer.
  15.528  WEBP_EXTERN(int) WebPPictureImportRGBA(
  15.529 -    WebPPicture* const picture, const uint8_t* const rgba, int rgba_stride);
  15.530 +    WebPPicture* picture, const uint8_t* rgba, int rgba_stride);
  15.531 +// Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format
  15.532 +// input buffer ignoring the alpha channel. Avoids needing to copy the data
  15.533 +// to a temporary 24-bit RGB buffer to import the RGB only.
  15.534 +WEBP_EXTERN(int) WebPPictureImportRGBX(
  15.535 +    WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride);
  15.536  
  15.537 -// Variant of the above, but taking BGR(A) input:
  15.538 +// Variants of the above, but taking BGR(A|X) input.
  15.539  WEBP_EXTERN(int) WebPPictureImportBGR(
  15.540 -    WebPPicture* const picture, const uint8_t* const bgr, int bgr_stride);
  15.541 +    WebPPicture* picture, const uint8_t* bgr, int bgr_stride);
  15.542  WEBP_EXTERN(int) WebPPictureImportBGRA(
  15.543 -    WebPPicture* const picture, const uint8_t* const bgra, int bgra_stride);
  15.544 +    WebPPicture* picture, const uint8_t* bgra, int bgra_stride);
  15.545 +WEBP_EXTERN(int) WebPPictureImportBGRX(
  15.546 +    WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride);
  15.547 +
  15.548 +// Converts picture->argb data to the YUV420A format. The 'colorspace'
  15.549 +// parameter is deprecated and should be equal to WEBP_YUV420.
  15.550 +// Upon return, picture->use_argb is set to false. The presence of real
  15.551 +// non-opaque transparent values is detected, and 'colorspace' will be
  15.552 +// adjusted accordingly. Note that this method is lossy.
  15.553 +// Returns false in case of error.
  15.554 +WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture,
  15.555 +                                       WebPEncCSP /*colorspace = WEBP_YUV420*/);
  15.556 +
  15.557 +// Same as WebPPictureARGBToYUVA(), but the conversion is done using
  15.558 +// pseudo-random dithering with a strength 'dithering' between
  15.559 +// 0.0 (no dithering) and 1.0 (maximum dithering). This is useful
  15.560 +// for photographic picture.
  15.561 +WEBP_EXTERN(int) WebPPictureARGBToYUVADithered(
  15.562 +    WebPPicture* picture, WebPEncCSP colorspace, float dithering);
  15.563 +
  15.564 +// Performs 'sharp' RGBA->YUVA420 downsampling and colorspace conversion.
  15.565 +// Downsampling is handled with extra care in case of color clipping. This
  15.566 +// method is roughly 2x slower than WebPPictureARGBToYUVA() but produces better
  15.567 +// and sharper YUV representation.
  15.568 +// Returns false in case of error.
  15.569 +WEBP_EXTERN(int) WebPPictureSharpARGBToYUVA(WebPPicture* picture);
  15.570 +// kept for backward compatibility:
  15.571 +WEBP_EXTERN(int) WebPPictureSmartARGBToYUVA(WebPPicture* picture);
  15.572 +
  15.573 +// Converts picture->yuv to picture->argb and sets picture->use_argb to true.
  15.574 +// The input format must be YUV_420 or YUV_420A. The conversion from YUV420 to
  15.575 +// ARGB incurs a small loss too.
  15.576 +// Note that the use of this colorspace is discouraged if one has access to the
  15.577 +// raw ARGB samples, since using YUV420 is comparatively lossy.
  15.578 +// Returns false in case of error.
  15.579 +WEBP_EXTERN(int) WebPPictureYUVAToARGB(WebPPicture* picture);
  15.580 +
  15.581 +// Helper function: given a width x height plane of RGBA or YUV(A) samples
  15.582 +// clean-up the YUV or RGB samples under fully transparent area, to help
  15.583 +// compressibility (no guarantee, though).
  15.584 +WEBP_EXTERN(void) WebPCleanupTransparentArea(WebPPicture* picture);
  15.585 +
  15.586 +// Scan the picture 'picture' for the presence of non fully opaque alpha values.
  15.587 +// Returns true in such case. Otherwise returns false (indicating that the
  15.588 +// alpha plane can be ignored altogether e.g.).
  15.589 +WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* picture);
  15.590 +
  15.591 +// Remove the transparency information (if present) by blending the color with
  15.592 +// the background color 'background_rgb' (specified as 24bit RGB triplet).
  15.593 +// After this call, all alpha values are reset to 0xff.
  15.594 +WEBP_EXTERN(void) WebPBlendAlpha(WebPPicture* pic, uint32_t background_rgb);
  15.595  
  15.596  //------------------------------------------------------------------------------
  15.597  // Main call
  15.598 @@ -282,12 +526,16 @@
  15.599  // and the 'config' object must be a valid one.
  15.600  // Returns false in case of error, true otherwise.
  15.601  // In case of error, picture->error_code is updated accordingly.
  15.602 -WEBP_EXTERN(int) WebPEncode(
  15.603 -    const WebPConfig* const config, WebPPicture* const picture);
  15.604 +// 'picture' can hold the source samples in both YUV(A) or ARGB input, depending
  15.605 +// on the value of 'picture->use_argb'. It is highly recommended to use
  15.606 +// the former for lossy encoding, and the latter for lossless encoding
  15.607 +// (when config.lossless is true). Automatic conversion from one format to
  15.608 +// another is provided but they both incur some loss.
  15.609 +WEBP_EXTERN(int) WebPEncode(const WebPConfig* config, WebPPicture* picture);
  15.610  
  15.611  //------------------------------------------------------------------------------
  15.612  
  15.613 -#if defined(__cplusplus) || defined(c_plusplus)
  15.614 +#ifdef __cplusplus
  15.615  }    // extern "C"
  15.616  #endif
  15.617  
    16.1 --- a/Xcode/Frameworks/webp.framework/Versions/A/Headers/webp/mux.h	Tue Oct 16 20:02:02 2018 +0300
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,467 +0,0 @@
    16.4 -// Copyright 2011 Google Inc.
    16.5 -//
    16.6 -// This code is licensed under the same terms as WebM:
    16.7 -//  Software License Agreement:  http://www.webmproject.org/license/software/
    16.8 -//  Additional IP Rights Grant:  http://www.webmproject.org/license/additional/
    16.9 -// -----------------------------------------------------------------------------
   16.10 -//
   16.11 -//  RIFF container manipulation for WEBP images.
   16.12 -//
   16.13 -// Authors: Urvang (urvang@google.com)
   16.14 -//          Vikas (vikasa@google.com)
   16.15 -
   16.16 -// This API allows manipulation of WebP container images containing features
   16.17 -// like Color profile, XMP metadata, Animation & Tiling.
   16.18 -//
   16.19 -// Code Example#1: Creating a MUX with image data, color profile & XMP metadata.
   16.20 -//
   16.21 -//   int copy_data = 0;
   16.22 -//   WebPMux* mux = WebPMuxNew();
   16.23 -//   // ... (Prepare image data).
   16.24 -//   WebPMuxSetImage(mux, image_data, image_data_size, alpha_data, alpha_size,
   16.25 -//                   copy_data);
   16.26 -//   // ... (Prepare ICCP color profile data).
   16.27 -//   WebPMuxSetColorProfile(mux, icc_data, icc_data_size, copy_data);
   16.28 -//   // ... (Prepare XMP metadata).
   16.29 -//   WebPMuxSetMetadata(mux, xmp_data, xmp_data_size, copy_data);
   16.30 -//   // Get data from mux in WebP RIFF format.
   16.31 -//   WebPMuxAssemble(mux, &output_data, &output_data_size);
   16.32 -//   WebPMuxDelete(mux);
   16.33 -//   // ... (Consume output_data; e.g. write output_data to file).
   16.34 -//   free(output_data);
   16.35 -//
   16.36 -// Code Example#2: Get image & color profile data from a WebP file.
   16.37 -//
   16.38 -//   int copy_data = 0;
   16.39 -//   // ... (Read data from file).
   16.40 -//   WebPMux* mux = WebPMuxCreate(data, data_size, copy_data);
   16.41 -//   WebPMuxGetImage(mux, &image_data, &image_data_size,
   16.42 -//                   &alpha_data, &alpha_size);
   16.43 -//   // ... (Consume image_data; e.g. call WebPDecode() to decode the data).
   16.44 -//   WebPMuxGetColorProfile(mux, &icc_data, &icc_data_size);
   16.45 -//   // ... (Consume icc_data).
   16.46 -//   WebPMuxDelete(mux);
   16.47 -//   free(data);
   16.48 -
   16.49 -#ifndef WEBP_WEBP_MUX_H_
   16.50 -#define WEBP_WEBP_MUX_H_
   16.51 -
   16.52 -#include "./types.h"
   16.53 -
   16.54 -#if defined(__cplusplus) || defined(c_plusplus)
   16.55 -extern "C" {
   16.56 -#endif
   16.57 -
   16.58 -// Error codes
   16.59 -typedef enum {
   16.60 -  WEBP_MUX_OK                 =  1,
   16.61 -  WEBP_MUX_ERROR              =  0,
   16.62 -  WEBP_MUX_NOT_FOUND          = -1,
   16.63 -  WEBP_MUX_INVALID_ARGUMENT   = -2,
   16.64 -  WEBP_MUX_INVALID_PARAMETER  = -3,
   16.65 -  WEBP_MUX_BAD_DATA           = -4,
   16.66 -  WEBP_MUX_MEMORY_ERROR       = -5
   16.67 -} WebPMuxError;
   16.68 -
   16.69 -// Flag values for different features used in VP8X chunk.
   16.70 -typedef enum {
   16.71 -  TILE_FLAG       = 0x00000001,
   16.72 -  ANIMATION_FLAG  = 0x00000002,
   16.73 -  ICCP_FLAG       = 0x00000004,
   16.74 -  META_FLAG       = 0x00000008,
   16.75 -  ALPHA_FLAG      = 0x00000010
   16.76 -} FeatureFlags;
   16.77 -
   16.78 -typedef struct WebPMux WebPMux;   // main opaque object.
   16.79 -
   16.80 -//------------------------------------------------------------------------------
   16.81 -// Life of a Mux object
   16.82 -
   16.83 -// Creates an empty mux object.
   16.84 -// Returns:
   16.85 -//   A pointer to the newly created empty mux object.
   16.86 -WEBP_EXTERN(WebPMux*) WebPMuxNew(void);
   16.87 -
   16.88 -// Deletes the mux object.
   16.89 -// Parameters:
   16.90 -//   mux - (in/out) object to be deleted
   16.91 -WEBP_EXTERN(void) WebPMuxDelete(WebPMux* const mux);
   16.92 -
   16.93 -//------------------------------------------------------------------------------
   16.94 -// Mux creation.
   16.95 -
   16.96 -// Creates a mux object from raw data given in WebP RIFF format.
   16.97 -// Parameters:
   16.98 -//   data - (in) the raw data in WebP RIFF format
   16.99 -//   size - (in) size of raw data
  16.100 -//   copy_data - (in) value 1 indicates given data WILL copied to the mux, and
  16.101 -//               value 0 indicates data will NOT be copied.
  16.102 -// Returns:
  16.103 -//   A pointer to the mux object created from given data - on success.
  16.104 -//   NULL - In case of invalid data or memory error.
  16.105 -WEBP_EXTERN(WebPMux*) WebPMuxCreate(const uint8_t* data, uint32_t size,
  16.106 -                                    int copy_data);
  16.107 -
  16.108 -//------------------------------------------------------------------------------
  16.109 -// Single Image.
  16.110 -
  16.111 -// Sets the image in the mux object. Any existing images (including frame/tile)
  16.112 -// will be removed.
  16.113 -// Parameters:
  16.114 -//   mux - (in/out) object in which the image is to be set
  16.115 -//   data - (in) the image data to be set. The data can be either a VP8
  16.116 -//          bitstream or a single-image WebP file (non-animated & non-tiled)
  16.117 -//   size - (in) size of the image data
  16.118 -//   alpha_data - (in) the alpha data corresponding to the image (if present)
  16.119 -//   alpha_size - (in) size of alpha chunk data
  16.120 -//   copy_data - (in) value 1 indicates given data WILL copied to the mux, and
  16.121 -//               value 0 indicates data will NOT be copied.
  16.122 -// Returns:
  16.123 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or data is NULL.
  16.124 -//   WEBP_MUX_MEMORY_ERROR - on memory allocation error.
  16.125 -//   WEBP_MUX_OK - on success.
  16.126 -WEBP_EXTERN(WebPMuxError) WebPMuxSetImage(WebPMux* const mux,
  16.127 -                                          const uint8_t* data, uint32_t size,
  16.128 -                                          const uint8_t* alpha_data,
  16.129 -                                          uint32_t alpha_size, int copy_data);
  16.130 -
  16.131 -// Gets a reference to the image in the mux object.
  16.132 -// The caller should NOT free the returned data.
  16.133 -// Parameters:
  16.134 -//   mux - (in) object from which the image is to be fetched
  16.135 -//   data - (out) the returned image data
  16.136 -//   size - (out) size of the returned image data
  16.137 -//   alpha_data - (in) the returned alpha data of the image (if present)
  16.138 -//   alpha_size - (in) size of alpha chunk data
  16.139 -// Returns:
  16.140 -//   WEBP_MUX_INVALID_ARGUMENT - if either of mux, data or size is NULL
  16.141 -//                               OR if mux contains animation/tiling.
  16.142 -//   WEBP_MUX_NOT_FOUND - if image is not present in mux object.
  16.143 -//   WEBP_MUX_OK - on success.
  16.144 -WEBP_EXTERN(WebPMuxError) WebPMuxGetImage(const WebPMux* const mux,
  16.145 -                                          const uint8_t** data, uint32_t* size,
  16.146 -                                          const uint8_t** alpha_data,
  16.147 -                                          uint32_t* alpha_size);
  16.148 -
  16.149 -// Deletes the image in the mux object.
  16.150 -// Parameters:
  16.151 -//   mux - (in/out) object from which the image is to be deleted
  16.152 -// Returns:
  16.153 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
  16.154 -//                               OR if mux contains animation/tiling.
  16.155 -//   WEBP_MUX_NOT_FOUND - if image is not present in mux object.
  16.156 -//   WEBP_MUX_OK - on success.
  16.157 -WEBP_EXTERN(WebPMuxError) WebPMuxDeleteImage(WebPMux* const mux);
  16.158 -
  16.159 -//------------------------------------------------------------------------------
  16.160 -// XMP Metadata.
  16.161 -
  16.162 -// Sets the XMP metadata in the mux object. Any existing metadata chunk(s) will
  16.163 -// be removed.
  16.164 -// Parameters:
  16.165 -//   mux - (in/out) object to which the XMP metadata is to be added
  16.166 -//   data - (in) the XMP metadata data to be added
  16.167 -//   size - (in) size of the XMP metadata data
  16.168 -//   copy_data - (in) value 1 indicates given data WILL copied to the mux, and
  16.169 -//               value 0 indicates data will NOT be copied.
  16.170 -// Returns:
  16.171 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or data is NULL.
  16.172 -//   WEBP_MUX_MEMORY_ERROR - on memory allocation error.
  16.173 -//   WEBP_MUX_OK - on success.
  16.174 -WEBP_EXTERN(WebPMuxError) WebPMuxSetMetadata(WebPMux* const mux,
  16.175 -                                             const uint8_t* data,
  16.176 -                                             uint32_t size, int copy_data);
  16.177 -
  16.178 -// Gets a reference to the XMP metadata in the mux object.
  16.179 -// The caller should NOT free the returned data.
  16.180 -// Parameters:
  16.181 -//   mux - (in) object from which the XMP metadata is to be fetched
  16.182 -//   data - (out) the returned XMP metadata
  16.183 -//   size - (out) size of the returned XMP metadata
  16.184 -// Returns:
  16.185 -//   WEBP_MUX_INVALID_ARGUMENT - if either of mux, data or size is NULL
  16.186 -//   WEBP_MUX_NOT_FOUND - if metadata is not present in mux object.
  16.187 -//   WEBP_MUX_OK - on success.
  16.188 -WEBP_EXTERN(WebPMuxError) WebPMuxGetMetadata(const WebPMux* const mux,
  16.189 -                                             const uint8_t** data,
  16.190 -                                             uint32_t* size);
  16.191 -
  16.192 -// Deletes the XMP metadata in the mux object.
  16.193 -// Parameters:
  16.194 -//   mux - (in/out) object from which XMP metadata is to be deleted
  16.195 -// Returns:
  16.196 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
  16.197 -//   WEBP_MUX_NOT_FOUND - If mux does not contain metadata.
  16.198 -//   WEBP_MUX_OK - on success.
  16.199 -WEBP_EXTERN(WebPMuxError) WebPMuxDeleteMetadata(WebPMux* const mux);
  16.200 -
  16.201 -//------------------------------------------------------------------------------
  16.202 -// ICC Color Profile.
  16.203 -
  16.204 -// Sets the color profile in the mux object. Any existing color profile chunk(s)
  16.205 -// will be removed.
  16.206 -// Parameters:
  16.207 -//   mux - (in/out) object to which the color profile is to be added
  16.208 -//   data - (in) the color profile data to be added
  16.209 -//   size - (in) size of the color profile data
  16.210 -//   copy_data - (in) value 1 indicates given data WILL copied to the mux, and
  16.211 -//               value 0 indicates data will NOT be copied.
  16.212 -// Returns:
  16.213 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or data is NULL
  16.214 -//   WEBP_MUX_MEMORY_ERROR - on memory allocation error
  16.215 -//   WEBP_MUX_OK - on success
  16.216 -WEBP_EXTERN(WebPMuxError) WebPMuxSetColorProfile(WebPMux* const mux,
  16.217 -                                                 const uint8_t* data,
  16.218 -                                                 uint32_t size, int copy_data);
  16.219 -
  16.220 -// Gets a reference to the color profile in the mux object.
  16.221 -// The caller should NOT free the returned data.
  16.222 -// Parameters:
  16.223 -//   mux - (in) object from which the color profile data is to be fetched
  16.224 -//   data - (out) the returned color profile data
  16.225 -//   size - (out) size of the returned color profile data
  16.226 -// Returns:
  16.227 -//   WEBP_MUX_INVALID_ARGUMENT - if either of mux, data or size is NULL
  16.228 -//   WEBP_MUX_NOT_FOUND - if color profile is not present in mux object.
  16.229 -//   WEBP_MUX_OK - on success.
  16.230 -WEBP_EXTERN(WebPMuxError) WebPMuxGetColorProfile(const WebPMux* const mux,
  16.231 -                                                 const uint8_t** data,
  16.232 -                                                 uint32_t* size);
  16.233 -
  16.234 -// Deletes the color profile in the mux object.
  16.235 -// Parameters:
  16.236 -//   mux - (in/out) object from which color profile is to be deleted
  16.237 -// Returns:
  16.238 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
  16.239 -//   WEBP_MUX_NOT_FOUND - If mux does not contain color profile.
  16.240 -//   WEBP_MUX_OK - on success.
  16.241 -WEBP_EXTERN(WebPMuxError) WebPMuxDeleteColorProfile(WebPMux* const mux);
  16.242 -
  16.243 -//------------------------------------------------------------------------------
  16.244 -// Animation.
  16.245 -
  16.246 -// Adds an animation frame to the mux object.
  16.247 -// nth=0 has a special meaning - last position.
  16.248 -// Parameters:
  16.249 -//   mux - (in/out) object to which an animation frame is to be added
  16.250 -//   nth - (in) The position at which the frame is to be added.
  16.251 -//   data - (in) the raw VP8 image data corresponding to frame image. The data
  16.252 -//          can be either a VP8 bitstream or a single-image WebP file
  16.253 -//          (non-animated & non-tiled)
  16.254 -//   size - (in) size of frame chunk data
  16.255 -//   alpha_data - (in) the alpha data corresponding to frame image (if present)
  16.256 -//   alpha_size - (in) size of alpha chunk data
  16.257 -//   x_offset - (in) x-offset of the frame to be added
  16.258 -//   y_offset - (in) y-offset of the frame to be added
  16.259 -//   duration - (in) duration of the frame to be added (in milliseconds)
  16.260 -//   copy_data - (in) value 1 indicates given data WILL copied to the mux, and
  16.261 -//               value 0 indicates data will NOT be copied.
  16.262 -// Returns:
  16.263 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or data is NULL
  16.264 -//   WEBP_MUX_NOT_FOUND - If we have less than (nth-1) frames before adding.
  16.265 -//   WEBP_MUX_MEMORY_ERROR - on memory allocation error.
  16.266 -//   WEBP_MUX_OK - on success.
  16.267 -WEBP_EXTERN(WebPMuxError) WebPMuxAddFrame(WebPMux* const mux, uint32_t nth,
  16.268 -                                          const uint8_t* data, uint32_t size,
  16.269 -                                          const uint8_t* alpha_data,
  16.270 -                                          uint32_t alpha_size,
  16.271 -                                          uint32_t x_offset, uint32_t y_offset,
  16.272 -                                          uint32_t duration, int copy_data);
  16.273 -
  16.274 -// TODO(urvang): Create a struct as follows to reduce argument list size:
  16.275 -// typedef struct {
  16.276 -//  int nth;
  16.277 -//  uint8_t* data;
  16.278 -//  uint32_t data_size;
  16.279 -//  uint8_t* alpha;
  16.280 -//  uint32_t alpha_size;
  16.281 -//  uint32_t x_offset, y_offset;
  16.282 -//  uint32_t duration;
  16.283 -// } FrameInfo;
  16.284 -
  16.285 -// Gets a reference to the nth animation frame from the mux object.
  16.286 -// The caller should NOT free the returned data.
  16.287 -// nth=0 has a special meaning - last position.
  16.288 -// Parameters:
  16.289 -//   mux - (in) object from which the info is to be fetched
  16.290 -//   nth - (in) index of the frame in the mux object
  16.291 -//   data - (out) the returned image data
  16.292 -//   size - (out) size of the returned image data
  16.293 -//   alpha_data - (in) the alpha data corresponding to frame image (if present)
  16.294 -//   alpha_size - (in) size of alpha chunk data
  16.295 -//   x_offset - (out) x-offset of the returned frame
  16.296 -//   y_offset - (out) y-offset of the returned frame
  16.297 -//   duration - (out) duration of the returned frame (in milliseconds)
  16.298 -// Returns:
  16.299 -//   WEBP_MUX_INVALID_ARGUMENT - if either mux, data, size, x_offset,
  16.300 -//                               y_offset, or duration is NULL
  16.301 -//   WEBP_MUX_NOT_FOUND - if there are less than nth frames in the mux object.
  16.302 -//   WEBP_MUX_BAD_DATA - if nth frame chunk in mux is invalid.
  16.303 -//   WEBP_MUX_OK - on success.
  16.304 -WEBP_EXTERN(WebPMuxError) WebPMuxGetFrame(const WebPMux* const mux,
  16.305 -                                          uint32_t nth,
  16.306 -                                          const uint8_t** data, uint32_t* size,
  16.307 -                                          const uint8_t** alpha_data,
  16.308 -                                          uint32_t* alpha_size,
  16.309 -                                          uint32_t* x_offset,
  16.310 -                                          uint32_t* y_offset,
  16.311 -                                          uint32_t* duration);
  16.312 -
  16.313 -// Deletes an animation frame from the mux object.
  16.314 -// nth=0 has a special meaning - last position.
  16.315 -// Parameters:
  16.316 -//   mux - (in/out) object from which a frame is to be deleted
  16.317 -//   nth - (in) The position from which the frame is to be deleted
  16.318 -// Returns:
  16.319 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
  16.320 -//   WEBP_MUX_NOT_FOUND - If there are less than nth frames in the mux object
  16.321 -//                        before deletion.
  16.322 -//   WEBP_MUX_OK - on success.
  16.323 -WEBP_EXTERN(WebPMuxError) WebPMuxDeleteFrame(WebPMux* const mux, uint32_t nth);
  16.324 -
  16.325 -// Sets the animation loop count in the mux object. Any existing loop count
  16.326 -// value(s) will be removed.
  16.327 -// Parameters:
  16.328 -//   mux - (in/out) object in which loop chunk is to be set/added
  16.329 -//   loop_count - (in) animation loop count value.
  16.330 -//                Note that loop_count of zero denotes infinite loop.
  16.331 -// Returns:
  16.332 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
  16.333 -//   WEBP_MUX_MEMORY_ERROR - on memory allocation error.
  16.334 -//   WEBP_MUX_OK - on success.
  16.335 -WEBP_EXTERN(WebPMuxError) WebPMuxSetLoopCount(WebPMux* const mux,
  16.336 -                                              uint32_t loop_count);
  16.337 -
  16.338 -// Gets the animation loop count from the mux object.
  16.339 -// Parameters:
  16.340 -//   mux - (in) object from which the loop count is to be fetched
  16.341 -//   loop_count - (out) the loop_count value present in the LOOP chunk
  16.342 -// Returns:
  16.343 -//   WEBP_MUX_INVALID_ARGUMENT - if either of mux or loop_count is NULL
  16.344 -//   WEBP_MUX_NOT_FOUND - if loop chunk is not present in mux object.
  16.345 -//   WEBP_MUX_OK - on success.
  16.346 -WEBP_EXTERN(WebPMuxError) WebPMuxGetLoopCount(const WebPMux* const mux,
  16.347 -                                              uint32_t* loop_count);
  16.348 -
  16.349 -//------------------------------------------------------------------------------
  16.350 -// Tiling.
  16.351 -
  16.352 -// Adds a tile to the mux object.
  16.353 -// nth=0 has a special meaning - last position.
  16.354 -// Parameters:
  16.355 -//   mux - (in/out) object to which a tile is to be added
  16.356 -//   nth - (in) The position at which the tile is to be added.
  16.357 -//   data - (in) the raw VP8 image data corresponding to tile image.  The data
  16.358 -//          can be either a VP8 bitstream or a single-image WebP file
  16.359 -//          (non-animated & non-tiled)
  16.360 -//   size - (in) size of tile chunk data
  16.361 -//   alpha_data - (in) the alpha data corresponding to tile image (if present)
  16.362 -//   alpha_size - (in) size of alpha chunk data
  16.363 -//   x_offset - (in) x-offset of the tile to be added
  16.364 -//   y_offset - (in) y-offset of the tile to be added
  16.365 -//   copy_data - (in) value 1 indicates given data WILL copied to the mux, and
  16.366 -//               value 0 indicates data will NOT be copied.
  16.367 -// Returns:
  16.368 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or data is NULL
  16.369 -//   WEBP_MUX_NOT_FOUND - If we have less than (nth-1) tiles before adding.
  16.370 -//   WEBP_MUX_MEMORY_ERROR - on memory allocation error.
  16.371 -//   WEBP_MUX_OK - on success.
  16.372 -WEBP_EXTERN(WebPMuxError) WebPMuxAddTile(WebPMux* const mux, uint32_t nth,
  16.373 -                                         const uint8_t* data, uint32_t size,
  16.374 -                                         const uint8_t* alpha_data,
  16.375 -                                         uint32_t alpha_size,
  16.376 -                                         uint32_t x_offset, uint32_t y_offset,
  16.377 -                                         int copy_data);
  16.378 -
  16.379 -// Gets a reference to the nth tile from the mux object.
  16.380 -// The caller should NOT free the returned data.
  16.381 -// nth=0 has a special meaning - last position.
  16.382 -// Parameters:
  16.383 -//   mux - (in) object from which the info is to be fetched
  16.384 -//   nth - (in) index of the tile in the mux object
  16.385 -//   data - (out) the returned image data
  16.386 -//   size - (out) size of the returned image data
  16.387 -//   alpha_data - (in) the alpha data corresponding to tile image (if present)
  16.388 -//   alpha_size - (in) size of alpha chunk data
  16.389 -//   x_offset - (out) x-offset of the returned tile
  16.390 -//   y_offset - (out) y-offset of the returned tile
  16.391 -// Returns:
  16.392 -//   WEBP_MUX_INVALID_ARGUMENT - if either mux, data, size, x_offset or
  16.393 -//                               y_offset is NULL
  16.394 -//   WEBP_MUX_NOT_FOUND - if there are less than nth tiles in the mux object.
  16.395 -//   WEBP_MUX_BAD_DATA - if nth tile chunk in mux is invalid.
  16.396 -//   WEBP_MUX_OK - on success.
  16.397 -WEBP_EXTERN(WebPMuxError) WebPMuxGetTile(const WebPMux* const mux, uint32_t nth,
  16.398 -                                         const uint8_t** data, uint32_t* size,
  16.399 -                                         const uint8_t** alpha_data,
  16.400 -                                         uint32_t* alpha_size,
  16.401 -                                         uint32_t* x_offset,
  16.402 -                                         uint32_t* y_offset);
  16.403 -
  16.404 -// Deletes a tile from the mux object.
  16.405 -// nth=0 has a special meaning - last position
  16.406 -// Parameters:
  16.407 -//   mux - (in/out) object from which a tile is to be deleted
  16.408 -//   nth - (in) The position from which the tile is to be deleted
  16.409 -// Returns:
  16.410 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL
  16.411 -//   WEBP_MUX_NOT_FOUND - If there are less than nth tiles in the mux object
  16.412 -//                        before deletion.
  16.413 -//   WEBP_MUX_OK - on success.
  16.414 -WEBP_EXTERN(WebPMuxError) WebPMuxDeleteTile(WebPMux* const mux, uint32_t nth);
  16.415 -
  16.416 -//------------------------------------------------------------------------------
  16.417 -// Misc Utilities.
  16.418 -
  16.419 -// Gets the feature flags from the mux object.
  16.420 -// Parameters:
  16.421 -//   mux - (in) object from which the features are to be fetched
  16.422 -//   flags - (out) the flags specifying which features are present in the
  16.423 -//           mux object. This will be an OR of various flag values.
  16.424 -//           Enum 'FeatureFlags' can be used to test for individual flag values.
  16.425 -// Returns:
  16.426 -//   WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or flags is NULL
  16.427 -//   WEBP_MUX_NOT_FOUND - if VP8X chunk is not present in mux object.
  16.428 -//   WEBP_MUX_BAD_DATA - if VP8X chunk in mux is invalid.
  16.429 -//   WEBP_MUX_OK - on success.
  16.430 -WEBP_EXTERN(WebPMuxError) WebPMuxGetFeatures(const WebPMux* const mux,
  16.431 -                                             uint32_t* flags);
  16.432 -
  16.433 -// Gets number of chunks having tag value tag in the mux object.
  16.434 -// Parameters:
  16.435 -//   mux - (in) object from which the info is to be fetched
  16.436 -//   tag - (in) tag name specifying the type of chunk
  16.437 -//   num_elements - (out) number of chunks corresponding to the specified tag
  16.438 -// Returns:
  16.439 -//   WEBP_MUX_INVALID_ARGUMENT - if either mux, tag or num_elements is NULL
  16.440 -//   WEBP_MUX_OK - on success.
  16.441 -WEBP_EXTERN(WebPMuxError) WebPMuxNumNamedElements(const WebPMux* const mux,
  16.442 -                                                  const char* tag,
  16.443 -                                                  int* num_elements);
  16.444 -
  16.445 -// Assembles all chunks in WebP RIFF format and returns in output_data.
  16.446 -// This function also validates the mux object.
  16.447 -// The content of '*output_data' is allocated using malloc(), and NOT
  16.448 -// owned by the 'mux' object.
  16.449 -// It MUST be deallocated by the caller by calling free().
  16.450 -// Parameters:
  16.451 -//   mux - (in/out) object whose chunks are to be assembled
  16.452 -//   output_data - (out) byte array where assembled WebP data is returned
  16.453 -//   output_size - (out) size of returned data
  16.454 -// Returns:
  16.455 -//   WEBP_MUX_BAD_DATA - if mux object is invalid.
  16.456 -//   WEBP_MUX_INVALID_ARGUMENT - if either mux, output_data or output_size is
  16.457 -//                               NULL.
  16.458 -//   WEBP_MUX_MEMORY_ERROR - on memory allocation error.
  16.459 -//   WEBP_MUX_OK - on success
  16.460 -WEBP_EXTERN(WebPMuxError) WebPMuxAssemble(WebPMux* const mux,
  16.461 -                                          uint8_t** output_data,
  16.462 -                                          uint32_t* output_size);
  16.463 -
  16.464 -//------------------------------------------------------------------------------
  16.465 -
  16.466 -#if defined(__cplusplus) || defined(c_plusplus)
  16.467 -}    // extern "C"
  16.468 -#endif
  16.469 -
  16.470 -#endif  /* WEBP_WEBP_MUX_H_ */
    17.1 --- a/Xcode/Frameworks/webp.framework/Versions/A/Headers/webp/types.h	Tue Oct 16 20:02:02 2018 +0300
    17.2 +++ b/Xcode/Frameworks/webp.framework/Versions/A/Headers/webp/types.h	Wed Oct 17 01:00:32 2018 +0300
    17.3 @@ -1,8 +1,10 @@
    17.4 -// Copyright 2010 Google Inc.
    17.5 +// Copyright 2010 Google Inc. All Rights Reserved.
    17.6  //
    17.7 -// This code is licensed under the same terms as WebM:
    17.8 -//  Software License Agreement:  http://www.webmproject.org/license/software/
    17.9 -//  Additional IP Rights Grant:  http://www.webmproject.org/license/additional/
   17.10 +// Use of this source code is governed by a BSD-style license
   17.11 +// that can be found in the COPYING file in the root of the source
   17.12 +// tree. An additional intellectual property rights grant can be found
   17.13 +// in the file PATENTS. All contributing project authors may
   17.14 +// be found in the AUTHORS file in the root of the source tree.
   17.15  // -----------------------------------------------------------------------------
   17.16  //
   17.17  //  Common types
   17.18 @@ -12,12 +14,15 @@
   17.19  #ifndef WEBP_WEBP_TYPES_H_
   17.20  #define WEBP_WEBP_TYPES_H_
   17.21  
   17.22 +#include <stddef.h>  // for size_t
   17.23 +
   17.24  #ifndef _MSC_VER
   17.25  #include <inttypes.h>
   17.26 -#ifdef __STRICT_ANSI__
   17.27 +#if defined(__cplusplus) || !defined(__STRICT_ANSI__) || \
   17.28 +    (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
   17.29 +#define WEBP_INLINE inline
   17.30 +#else
   17.31  #define WEBP_INLINE
   17.32 -#else  /* __STRICT_ANSI__ */
   17.33 -#define WEBP_INLINE inline
   17.34  #endif
   17.35  #else
   17.36  typedef signed   char int8_t;
   17.37 @@ -34,7 +39,14 @@
   17.38  #ifndef WEBP_EXTERN
   17.39  // This explicitly marks library functions and allows for changing the
   17.40  // signature for e.g., Windows DLL builds.
   17.41 -#define WEBP_EXTERN(type) extern type
   17.42 +# if defined(__GNUC__) && __GNUC__ >= 4
   17.43 +#  define WEBP_EXTERN(type) extern __attribute__ ((visibility ("default"))) type
   17.44 +# else
   17.45 +#  define WEBP_EXTERN(type) extern type
   17.46 +# endif  /* __GNUC__ >= 4 */
   17.47  #endif  /* WEBP_EXTERN */
   17.48  
   17.49 +// Macro to check ABI compatibility (same major revision number)
   17.50 +#define WEBP_ABI_IS_INCOMPATIBLE(a, b) (((a) >> 8) != ((b) >> 8))
   17.51 +
   17.52  #endif  /* WEBP_WEBP_TYPES_H_ */
    18.1 Binary file Xcode/Frameworks/webp.framework/Versions/A/Resources/English.lproj/InfoPlist.strings has changed
    19.1 --- a/Xcode/Frameworks/webp.framework/Versions/A/Resources/Info.plist	Tue Oct 16 20:02:02 2018 +0300
    19.2 +++ b/Xcode/Frameworks/webp.framework/Versions/A/Resources/Info.plist	Wed Oct 17 01:00:32 2018 +0300
    19.3 @@ -5,20 +5,20 @@
    19.4  	<key>CFBundleDevelopmentRegion</key>
    19.5  	<string>English</string>
    19.6  	<key>CFBundleExecutable</key>
    19.7 -	<string>FLAC</string>
    19.8 +	<string>webp</string>
    19.9  	<key>CFBundleGetInfoString</key>
   19.10 -	<string>libwebp 0.1.3</string>
   19.11 +	<string>libwebp 0.6.0</string>
   19.12  	<key>CFBundleInfoDictionaryVersion</key>
   19.13  	<string>6.0</string>
   19.14  	<key>CFBundleName</key>
   19.15 -	<string>FLAC</string>
   19.16 +	<string>webp</string>
   19.17  	<key>CFBundlePackageType</key>
   19.18  	<string>FMWK</string>
   19.19  	<key>CFBundleShortVersionString</key>
   19.20 -	<string>0.1.3</string>
   19.21 +	<string>0.6.0</string>
   19.22  	<key>CFBundleSignature</key>
   19.23  	<string>????</string>
   19.24  	<key>CFBundleVersion</key>
   19.25 -	<string>0.1.3</string>
   19.26 +	<string>0.6.0</string>
   19.27  </dict>
   19.28  </plist>
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/Xcode/Frameworks/webp.framework/Versions/A/Resources/LICENSE.webp.txt	Wed Oct 17 01:00:32 2018 +0300
    20.3 @@ -0,0 +1,34 @@
    20.4 +The source code to this library used with SDL_image can be found here:
    20.5 +http://www.libsdl.org/projects/SDL_image/libs/
    20.6 +---
    20.7 +
    20.8 +Copyright (c) 2010, Google Inc. All rights reserved.
    20.9 +
   20.10 +Redistribution and use in source and binary forms, with or without
   20.11 +modification, are permitted provided that the following conditions are
   20.12 +met:
   20.13 +
   20.14 +  * Redistributions of source code must retain the above copyright
   20.15 +    notice, this list of conditions and the following disclaimer.
   20.16 +
   20.17 +  * Redistributions in binary form must reproduce the above copyright
   20.18 +    notice, this list of conditions and the following disclaimer in
   20.19 +    the documentation and/or other materials provided with the
   20.20 +    distribution.
   20.21 +
   20.22 +  * Neither the name of Google nor the names of its contributors may
   20.23 +    be used to endorse or promote products derived from this software
   20.24 +    without specific prior written permission.
   20.25 +
   20.26 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   20.27 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   20.28 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   20.29 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   20.30 +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   20.31 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   20.32 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   20.33 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   20.34 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   20.35 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
   20.36 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   20.37 +
    21.1 Binary file Xcode/Frameworks/webp.framework/Versions/A/webp has changed