clean up, add benchmarks
This commit is contained in:
parent
53101929c5
commit
10f1352f6f
27
README.md
27
README.md
@ -14,7 +14,8 @@ Build libspng:
|
|||||||
|
|
||||||
```
|
```
|
||||||
cd libspng
|
cd libspng
|
||||||
meson build --prefix=/home/john/vips --libdir=/home/john/vips/lib
|
meson build --prefix=/home/john/vips --libdir=/home/john/vips/lib \
|
||||||
|
--buildtype=release
|
||||||
cd build
|
cd build
|
||||||
ninja
|
ninja
|
||||||
ninja install
|
ninja install
|
||||||
@ -26,6 +27,30 @@ Sample code:
|
|||||||
|
|
||||||
https://github.com/randy408/libspng/blob/master/examples/example.c
|
https://github.com/randy408/libspng/blob/master/examples/example.c
|
||||||
|
|
||||||
|
libspng benchmark:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ time vips avg wtc.png
|
||||||
|
151.549325
|
||||||
|
|
||||||
|
real 0m3.167s
|
||||||
|
user 0m3.714s
|
||||||
|
sys 0m0.194s
|
||||||
|
```
|
||||||
|
|
||||||
|
And for libpng:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ time vips avg wtc.png
|
||||||
|
117.065766
|
||||||
|
|
||||||
|
real 0m3.816s
|
||||||
|
user 0m4.177s
|
||||||
|
sys 0m0.221s
|
||||||
|
```
|
||||||
|
|
||||||
|
The avg is different since libspng is generating alpha 255.
|
||||||
|
|
||||||
# Introduction
|
# Introduction
|
||||||
|
|
||||||
libvips is a [demand-driven, horizontally
|
libvips is a [demand-driven, horizontally
|
||||||
|
10
configure.ac
10
configure.ac
@ -1176,13 +1176,13 @@ FIND_GIFLIB(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Look for libspng first
|
# Look for libspng first
|
||||||
AC_ARG_WITH([spng],
|
AC_ARG_WITH([libspng],
|
||||||
AS_HELP_STRING([--without-spng], [build without libspng (default: test)]))
|
AS_HELP_STRING([--without-libspng], [build without libspng (default: test)]))
|
||||||
|
|
||||||
if test x"$with_spng" != x"no"; then
|
if test x"$with_libspng" != x"no"; then
|
||||||
PKG_CHECK_MODULES(SPNG, spng >= 0.6,
|
PKG_CHECK_MODULES(SPNG, spng >= 0.6,
|
||||||
[AC_DEFINE(HAVE_SPNG,1,[define if you have libspng installed.])
|
[AC_DEFINE(HAVE_SPNG,1,[define if you have libspng installed.])
|
||||||
with_spng=yes
|
with_libspng=yes
|
||||||
PACKAGES_USED="$PACKAGES_USED spng"
|
PACKAGES_USED="$PACKAGES_USED spng"
|
||||||
with_png=no
|
with_png=no
|
||||||
],
|
],
|
||||||
@ -1413,7 +1413,7 @@ file import with cfitsio: $with_cfitsio
|
|||||||
file import/export with libwebp: $with_libwebp
|
file import/export with libwebp: $with_libwebp
|
||||||
(requires libwebp, libwebpmux, libwebpdemux 0.6.0 or later)
|
(requires libwebp, libwebpmux, libwebpdemux 0.6.0 or later)
|
||||||
text rendering with pangoft2: $with_pangoft2
|
text rendering with pangoft2: $with_pangoft2
|
||||||
file import/export with libspng: $with_spng
|
file import/export with libspng: $with_libspng
|
||||||
(requires libspng-0.6 or later)
|
(requires libspng-0.6 or later)
|
||||||
file import/export with libpng: $with_png
|
file import/export with libpng: $with_png
|
||||||
(requires libpng-1.2.9 or later)
|
(requires libpng-1.2.9 or later)
|
||||||
|
@ -36,6 +36,13 @@
|
|||||||
* an enum for interlace_method would be nice ... ADAM7 == 1,
|
* an enum for interlace_method would be nice ... ADAM7 == 1,
|
||||||
* no interlace == 0.
|
* no interlace == 0.
|
||||||
* an equivalent of png_sig_cmp() from libpng (is_a_png on a memory area)
|
* an equivalent of png_sig_cmp() from libpng (is_a_png on a memory area)
|
||||||
|
*
|
||||||
|
* This always reads RGBA8 or RGBA16. Other formst G8/G16/GA8 etc. etc. are
|
||||||
|
* in the roadmap.
|
||||||
|
*
|
||||||
|
* Most metadata support (eg. XMP, ICC, etc. etc.) is missing.
|
||||||
|
*
|
||||||
|
* Load only, there's no save support for now.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -70,7 +77,6 @@ typedef struct _VipsForeignLoadPng {
|
|||||||
|
|
||||||
spng_ctx *ctx;
|
spng_ctx *ctx;
|
||||||
struct spng_ihdr ihdr;
|
struct spng_ihdr ihdr;
|
||||||
struct spng_trns trns;
|
|
||||||
enum spng_format fmt;
|
enum spng_format fmt;
|
||||||
int bands;
|
int bands;
|
||||||
VipsInterpretation interpretation;
|
VipsInterpretation interpretation;
|
||||||
@ -96,9 +102,6 @@ vips_foreign_load_png_dispose( GObject *gobject )
|
|||||||
dispose( gobject );
|
dispose( gobject );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* libspng read callbacks should copy length bytes to dest and return 0
|
|
||||||
* or SPNG_IO_EOF/SPNG_IO_ERROR on error.
|
|
||||||
*/
|
|
||||||
static int
|
static int
|
||||||
vips_foreign_load_png_stream( spng_ctx *ctx, void *user,
|
vips_foreign_load_png_stream( spng_ctx *ctx, void *user,
|
||||||
void *dest, size_t length )
|
void *dest, size_t length )
|
||||||
@ -123,7 +126,7 @@ vips_foreign_load_png_get_flags_source( VipsSource *source )
|
|||||||
struct spng_ihdr ihdr;
|
struct spng_ihdr ihdr;
|
||||||
VipsForeignFlags flags;
|
VipsForeignFlags flags;
|
||||||
|
|
||||||
ctx = spng_ctx_new( 0 );
|
ctx = spng_ctx_new( SPNG_CTX_IGNORE_ADLER32 );
|
||||||
spng_set_crc_action( ctx, SPNG_CRC_USE, SPNG_CRC_USE );
|
spng_set_crc_action( ctx, SPNG_CRC_USE, SPNG_CRC_USE );
|
||||||
spng_set_png_stream( ctx,
|
spng_set_png_stream( ctx,
|
||||||
vips_foreign_load_png_stream, source );
|
vips_foreign_load_png_stream, source );
|
||||||
@ -317,9 +320,7 @@ vips_foreign_load_png_generate( VipsRegion *or,
|
|||||||
printf( " error %s\n", spng_strerror( error ) );
|
printf( " error %s\n", spng_strerror( error ) );
|
||||||
#endif /*DEBUG*/
|
#endif /*DEBUG*/
|
||||||
|
|
||||||
/* And bail if fail is on. We have to add an error
|
/* And bail if fail is on.
|
||||||
* message, since the handler we install just does
|
|
||||||
* g_warning().
|
|
||||||
*/
|
*/
|
||||||
if( load->fail ) {
|
if( load->fail ) {
|
||||||
vips_error( class->nickname,
|
vips_error( class->nickname,
|
||||||
|
Loading…
Reference in New Issue
Block a user