tiny fixups for the webp commit

just small formatting changes, plus an unneeded var

see

	https://github.com/jcupitt/libvips/pull/430
This commit is contained in:
John Cupitt 2016-05-02 09:55:16 +01:00
parent c88b94cb29
commit 48ef215479
6 changed files with 64 additions and 38 deletions

View File

@ -1,3 +1,6 @@
1/5/16 started 8.4
- many more wepsave options [Felix Bünemann]
15/4/16 started 8.3.1
- rename vips wrapper script, it was still vips-8.2, thanks Benjamin
- export C++ operator overloads for MSVC linking [Lovell]

2
TODO
View File

@ -1,3 +1,5 @@
- add "*" before each optional arg description
- I like the new int mask creator in reducev, can we use it in im_vips2imask()
as well?

View File

@ -2,7 +2,7 @@
# also update the version number in the m4 macros below
AC_INIT([vips], [8.3.1], [vipsip@jiscmail.ac.uk])
AC_INIT([vips], [8.4.0], [vipsip@jiscmail.ac.uk])
# required for gobject-introspection
AC_PREREQ(2.62)
@ -17,8 +17,8 @@ AC_CONFIG_MACRO_DIR([m4])
# user-visible library versioning
m4_define([vips_major_version], [8])
m4_define([vips_minor_version], [3])
m4_define([vips_micro_version], [1])
m4_define([vips_minor_version], [4])
m4_define([vips_micro_version], [0])
m4_define([vips_version],
[vips_major_version.vips_minor_version.vips_micro_version])
@ -38,7 +38,7 @@ VIPS_VERSION_STRING=$VIPS_VERSION-`date`
# binary interface changes not backwards compatible?: reset age to 0
LIBRARY_CURRENT=46
LIBRARY_REVISION=1
LIBRARY_REVISION=2
LIBRARY_AGE=4
# patched into include/vips/version.h

View File

@ -2457,12 +2457,27 @@ vips_webpload_buffer( void *buf, size_t len, VipsImage **out, ... )
*
* Optional arguments:
*
* @Q: quality factor
* @lossless: enables lossless compression
* @preset: #VipsForeignWebpPreset choose lossy compression preset
* @smart_subsample: enables high quality chroma subsampling
* @near_lossless: use preprocessing in lossless mode (controlled by Q)
* @alpha_q: set alpha quality in lossless mode
* * @Q: %gint quality factor
* * @lossless: %gboolean enables lossless compression
* * @preset: #VipsForeignWebpPreset choose lossy compression preset
* * @smart_subsample: %gboolean enables high quality chroma subsampling
* * @near_lossless: %gboolean use preprocessing in lossless mode (controlled by Q)
* * @alpha_q: %gint set alpha quality in lossless mode
*
* Write an image to a file in WebP format.
*
* Use @Q to set the WebP quality factor. It has the range 0 - 100, with the
* default 75.
*
* Use @preset to hint the image type to lossy compressor. The default is
* #VIPS_FOREIGN_WEBP_PRESET_DEFAULT.
*
* Set @smart_subsample to enable high quality chroma subsampling.
*
* Use @alpha_q to set the quality for the alpha channel in lossy mode. It has
* the range 1 - 100, with the default 100.
*
* Set @lossless to enable lossless save.
*
* See also: vips_webpload(), vips_image_write_to_file().
*
@ -2490,18 +2505,18 @@ vips_webpsave( VipsImage *in, const char *filename, ... )
*
* Optional arguments:
*
* @Q: JPEG quality factor
* @lossless: enables lossless compression
* @Q: %gint quality factor
* @lossless: %gboolean enables lossless compression
* @preset: #VipsForeignWebpPreset choose lossy compression preset
* @smart_subsample: enables high quality chroma subsampling
* @near_lossless: use preprocessing in lossless mode (controlled by Q)
* @alpha_q: set alpha quality in lossless mode
* @smart_subsample: %gboolean enables high quality chroma subsampling
* @near_lossless: %gboolean use preprocessing in lossless mode (controlled by Q)
* @alpha_q: %gint set alpha quality in lossless mode
*
* As vips_webpsave(), but save to a memory buffer.
*
* The address of the buffer is returned in @obuf, the length of the buffer in
* @olen. You are responsible for freeing the buffer with g_free() when you
* are done with it. The buffer is freed for you on error.
* are done with it.
*
* See also: vips_webpsave().
*
@ -2542,7 +2557,12 @@ vips_webpsave_buffer( VipsImage *in, void **buf, size_t *len, ... )
*
* Optional arguments:
*
* @Q: quality factor
* @Q: %gint quality factor
* @lossless: %gboolean enables lossless compression
* @preset: #VipsForeignWebpPreset choose lossy compression preset
* @smart_subsample: %gboolean enables high quality chroma subsampling
* @near_lossless: %gboolean use preprocessing in lossless mode (controlled by Q)
* @alpha_q: %gint set alpha quality in lossless mode
*
* As vips_webpsave(), but save as a mime webp on stdout.
*

View File

@ -4,6 +4,8 @@
* - from vips2jpeg.c
* 31/5/16
* - buffer write ignored lossless, thanks aaron42net
* 2/5/16 Felix Bünemann
* - used advanced encoding API, expose controls
*/
/*
@ -99,34 +101,36 @@ init_memory_writer( VipsWebPMemoryWriter *writer ) {
static int
memory_write( const uint8_t *data, size_t data_size,
const WebPPicture *picture ) {
VipsWebPMemoryWriter* const w = (VipsWebPMemoryWriter*) picture->custom_ptr;
VipsWebPMemoryWriter * const writer =
(VipsWebPMemoryWriter*) picture->custom_ptr;
size_t next_size;
if( w == NULL )
if( !writer )
return( 0 );
next_size = w->size + data_size;
next_size = writer->size + data_size;
if( next_size > w->max_size ) {
if( next_size > writer->max_size ) {
uint8_t *new_mem;
const size_t next_max_size =
VIPS_MAX( 8192, VIPS_MAX( next_size, w->max_size * 2 ) );
VIPS_MAX( 8192, VIPS_MAX( next_size,
writer->max_size * 2 ) );
new_mem = (uint8_t*) g_try_malloc( next_max_size );
if( new_mem == NULL )
if( !(new_mem = (uint8_t*) g_try_malloc( next_max_size )) )
return( 0 );
if( w->size > 0 )
memcpy( new_mem, w->mem, w->size );
if( writer->size > 0 )
memcpy( new_mem, writer->mem, writer->size );
g_free( w->mem );
w->mem = new_mem;
w->max_size = next_max_size;
g_free( writer->mem );
writer->mem = new_mem;
writer->max_size = next_max_size;
}
if( data_size > 0 ) {
memcpy( w->mem + w->size, data, data_size );
w->size += data_size;
memcpy( writer->mem + writer->size, data, data_size );
writer->size += data_size;
}
return( 1 );
@ -142,7 +146,7 @@ write_webp( WebPPicture *pic, VipsImage *in,
WebPConfig config;
webp_import import;
if ( !WebPConfigPreset(&config, get_preset( preset ), Q) ) {
if ( !WebPConfigPreset( &config, get_preset( preset ), Q ) ) {
vips_error( "vips2webp",
"%s", _( "config version error" ) );
return( -1 );
@ -178,7 +182,7 @@ write_webp( WebPPicture *pic, VipsImage *in,
"%s", _( "smart_subsample unsupported" ) );
#endif
if( !WebPValidateConfig(&config) ) {
if( !WebPValidateConfig( &config ) ) {
vips_error( "vips2webp",
"%s", _( "invalid configuration" ) );
return( -1 );
@ -269,7 +273,6 @@ vips__webp_write_buffer( VipsImage *in, void **obuf, size_t *olen,
{
WebPPicture pic;
VipsWebPMemoryWriter writer;
FILE *fp;
if( !WebPPictureInit( &pic ) ) {
vips_error( "vips2webp",

View File

@ -341,11 +341,9 @@ int vips_jpegsave_mime( VipsImage *in, ... )
/**
* VipsForeignWebpPreset:
* @VIPS_FOREIGN_WEBP_PRESET_DEFAULT: default preset
* @VIPS_FOREIGN_WEBP_PRESET_PICTURE: digital picture, like portrait,
* inner shot
* @VIPS_FOREIGN_WEBP_PRESET_PICTURE: digital picture, like portrait, inner shot
* @VIPS_FOREIGN_WEBP_PRESET_PHOTO: outdoor photograph, with natural lighting
* @VIPS_FOREIGN_WEBP_PRESET_DRAWING: hand or line drawing, with high-contrast
* details
* @VIPS_FOREIGN_WEBP_PRESET_DRAWING: hand or line drawing, with high-contrast details
* @VIPS_FOREIGN_WEBP_PRESET_ICON: small-sized colorful images
* @VIPS_FOREIGN_WEBP_PRESET_TEXT: text-like
*