Commit Graph

1351 Commits

Author SHA1 Message Date
Lovell Fuller 7eba4ee43f
Introduce support for target_clones attribute (#3280)
This requires GLIBC 2.23+, plus either gcc 6+ or clang 14+.

- Provides build-time feature detection
- Use with (un)premultiply for ~10% perf gain on AVX CPUs
- Slightly increases binary size, so best to use sparingly
2023-01-16 10:45:37 +01:00
John Cupitt e2c2866fc6 tweak docs, add changelog notes
and an assert for semaphore_down_timeout

see https://github.com/libvips/libvips/pull/3253
2023-01-03 12:09:24 +00:00
Kleis Auke Wolthuizen 848a119faa
threadset: stop idle threads after a regular timeout (#3253)
* Add `vips_semaphore_down_timeout` to public API

In preparation for the next commit.

* threadset: stop idle threads after a regular timeout

In line with the previous behaviour of GLib's threadpool.

* threadset: fix a small memory leak

* threadset: ensure idle threads are freed on exit

GLib threads are spawned with `ref_count == 2`, this reference is
decreased during thread exit and associated resources are freed
during `g_thread_join()`. However, idle threads that are stopped
after a regular timeout are not joined. To fix this, decrease the
reference count during `vips_threadset_add()` and increase it just
before joining the thread with `g_thread_join()`.

See:
2d5d990c6a/glib/gthread.c (L522)
2d5d990c6a/glib/gthread-posix.c (L1287)

* Deprecate `vips_g_thread_join()` in favor of `g_thread_join()`

* nit: remove extra semicolon
2023-01-03 12:00:35 +00:00
John Cupitt 9419b3636f add missing vips_thread_isworker compat func
also bump to 8.14.1

see https://github.com/libvips/libvips/issues/3254

thanks remi
2023-01-02 11:57:05 +00:00
Daniel Löbl 6bb0b4dd1e
heifsave: make it possible to use a specific encoder (#3198)
* heifsave: make it possible to use a specific encoder

* argument label: switch to leading capital letter

Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>

* add VipsForeignHeifEncoder enum

* correct type

* implement reviewer feedback

Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>
2022-12-15 11:02:38 +00:00
John Cupitt ef2646ef6a
add a "wrap" option to vips_text() (#3130)
see:

https://github.com/libvips/libvips/discussions/2073

https://github.com/libvips/libvips/discussions/3126
2022-11-10 15:46:46 +00:00
John Cupitt 976db37f84
Revised threading system (#3105)
* reimplement threadpool

just a set of threads that get recycled

"ninja test" passes and dzsave seems to work, though pytest fails for
some reason

* clean up threading code a bit

move base stuff into thread.c, so we have a simple

	thread -> threadset -> threadpool

layering

* start trying to revert g_threadpool

based on the original commit

* working!

nice low systime again

still need to repply cnages to threadpool.c since 80e0cc3d1

* reapply fixes from master

so threadpool.c is now up to date

* rename VipsThread as VipsWorker

a bit less confusing

* use a semaphore to count workers in a pool

* tidy up

* formatting

* dynamic threadpool sizing

based on counting the number of blocked threads in each pool

it works, but the improvement is not great :(

* add "concurrency" metadata item

so operators can hint threadpool size (dzsave especially)

* don't use thinstrip for small images

* add RGB mode to openslide

since flatten was taking 20% of CPU time for dzsave

* fix up rgb mode

now actually works

* make the tile buffer per thread

in the new openslideload rgb mode

* fix dynamic pool downsize

* mild refactoring

* fix the buffer system

oops, turned it off by mistake

* all done!

* revise changelog

* Update libvips/iofuncs/threadset.c

Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>

* Update libvips/iofuncs/threadset.c

Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>

* LSan: add libMagickCore to suppression file

* Revert "Remove mutex lock for VipsThreadStartFn"

This reverts commit 41440491.

* add VIPS_MAX_THREADS

to set a hard limit on the threadset size

* Revert "Revert "Remove mutex lock for VipsThreadStartFn""

This reverts commit 77e8520966ba79194fff3b4e648bbd295cd5c260.

* remove sslock from sink.c

* move fixed threadpool build to init

not first use

* add some doc comments

* revert test suite threshold change

* add a test for MAX_THREADS

and move the test tmp/ area into the builddir

* limit VIPS_MAX_THREADS to sane values

* use tabs rather than spaces

Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>
2022-10-26 15:25:19 +01:00
Kleis Auke Wolthuizen db96adfc00
Ensure `--vips-config` only prints build configuration (#3062)
Also, remove a remnant of Autotools.
2022-09-24 11:26:30 +01:00
John Cupitt 5569022dbd use G_GNUC_* attribute system
Instead of our own compiler attr thing.

see https://github.com/libvips/libvips/issues/2871
2022-09-23 14:37:35 +01:00
John Cupitt a7e754162a
move tiff decompress outside lock (#2969)
* move tiff decompress outside lock

Most time in TIFF read is spent in decompression. If we move this
outside the lock, we can get a useful speedup.

This commit adds the machinery to move the lock to before decompress, so
jp2k decompression is now threaded.

Before:

```
$ vips copy wtc.jpg x.tif[tile,compression=jp2k]
$ time vips avg x.tif
117.249845
real	0m15.085s
user	0m16.155s
sys	0m0.109s
```

After:

```
$ time vips avg x.tif
117.249845
real	0m1.207s
user	0m18.384s
sys	0m0.369s
```

* start moving jpg decode outside the lock

* move jpeg decompress outside the lock

seems to work

* add some more tile size checks

double-check jpeg tile size before decode

* fix tiffload demand hinting

We were not setting the hint correctly in header load, and we were not
hinting smalltile for tiled TIFFs.
2022-09-03 13:10:58 +01:00
John Cupitt 6a154ac9f2 add ".pnm" save
see https://github.com/libvips/libvips/issues/3016
2022-08-30 12:31:47 +01:00
Kleis Auke Wolthuizen 4d5622c217
Simplify `VIPS_CONFIG` definition (#2964) 2022-07-30 19:23:09 +01:00
Kleis Auke Wolthuizen cf97ea3ea1
Deduplicate `--vips-config` with the build summary (#2957)
* Deduplicate `--vips-config` with the build summary

* Ensure output is identical

Helps parses.
2022-07-29 11:09:51 +01:00
Kleis Auke Wolthuizen a24b556b26
Meson: simplify dynamic module handling (#2956) 2022-07-28 15:10:13 +01:00
Kleis Auke Wolthuizen 45bcd74a7a
Fix libpng fall-back when build with `-Dspng=disabled` (#2955) 2022-07-28 14:37:12 +01:00
Kleis Auke Wolthuizen 057703938e
Remove remnant of Autotools (#2950)
* Remove `glib-mkenums` autotools templates and generated files

Meson uses the `enumtypes.c.in` and `enumtypes.h.in` in
`libvips/include/vips` and doesn't use the pre-generated
files.

* Remove man files for no longer existing tools

+ update the `meson.build`.

* Remove Autotools section in `.gitignore`

* Remove `po/messages` left-over

* Remove `g-ir-scanner` entry point

No longer needed by Meson.

* Remove `glib-genmarshal` generated files

Meson doesn't use these pre-generated files.

* Remove Autotools specific Git attributes

* Remove no longer existing tools in `.gitignore`

* Remove Make specific things in `.gitignore`

* Rename COPYING to LICENSE

* Remove no longer needed `.gitignore` sections

Meson only supports out-of-tree builds. This assumes that the
build directory is ignored.

* Remove no longer needed `.editorconfig` sections
2022-07-27 10:56:56 +01:00
John Cupitt 538aa2a841
remove autotools (#2941)
* remove autotools

It seems to all work. I tested with gtk-doc enabled. I probably missed a
few things argh.

* oop, forgot m4/
2022-07-24 11:14:52 +01:00
Kleis Auke Wolthuizen 7010903538
Meson: improve summary table (#2943)
* Meson: improve summary table

* Fix typo

* Remove redundant whitespace
2022-07-24 11:06:40 +01:00
Kleis Auke Wolthuizen a498680094
Update `glib-mkenums` templates (#2939)
* Avoid writing the full path in enumtypes.h

Helps reproducible builds, as build paths can vary between builds.

* Use g_intern_static_string() for enum/flags type names

We are emitting a static string, so use that shortcut function to
intern it, which will save one allocation.

* Use g_once_init_enter/leave to register enum/flags type names

This is the more modern way, and ensures thread-safety.
2022-07-22 15:33:40 +01:00
Kleis Auke Wolthuizen f28e3f1e36
Remove stray soname.h (#2893)
This became obsolete after commit f11b58ff.
2022-06-26 18:59:32 +01:00
John Cupitt 748a99d245 reorder Target struct to improve compat
so fields are at the same position at least

see https://github.com/libvips/libvips/issues/2880
2022-06-21 19:07:35 +01:00
John Cupitt d9f31be67d configure should add meson files to make dist
add meson.build etc. to EXTRA_DIST

see https://github.com/libvips/libvips/issues/2876
2022-06-20 15:04:33 +01:00
Kleis Auke Wolthuizen 7553f60aed
Minor cleanups (#2857)
- Remove `HAVE_LCMS` definition in favor of `HAVE_LCMS2`.
- Remove `HAVE_WINDOWS_H` definition in favor of `G_OS_WIN32`.
- Remove stray `vips_text_get_type` in `conversion.c`.
- Remove duplicated `unistd.h` include.
- Remove redundant `strcasecmp` definition, we use `g_ascii_strcasecmp` everywhere.
- Remove unnecessary header checks in `configure.ac` and `meson.build`.
- Ensure `unistd.h` include is guarded with `HAVE_UNISTD_H`.
- Fail early when `-Dfontconfig=enabled` and `pangoft2` is not found.
2022-06-12 12:22:36 +01:00
John Cupitt a9d64bea54
add dzsave to a target (#2718)
* start adding dzsave to a target

made a thing for gsf to write to a target

* fix stray tabs in dzsave

* fix dzsave write to "."

Early versions of libgsf did not support writing to ".", so we had an ugly
workaround, but this should now be OK.

Fixing this ought to make write to target simple

* dzsave_target compiles

no idea if it works though

* seems to work now

creates stray 0 length files though, very odd

* fix stray files from dzsave

next: save to buffer is returning null

* fix buffer flush in dzsave

all tests pass!

* update changelog
2022-05-20 18:38:46 +01:00
John Cupitt f8003bda67
Add tiffsave target (#2798)
* compiles, but untested

* works, but libtiff needs seek for write

next: add seek methods to target

* add target seek and read

seem to work

next: disc temps for disc output

* add libnsgif COPYING

oops, we were missing the COPYING file

see https://github.com/libvips/libvips/issues/2800

thanks mika-fischer

* tiffsave uses a disc temp if it can

* revise temp target rules

only make a disc temp if we are writing to a filesystem target

* add new target methods to targetcustom
2022-05-20 18:38:17 +01:00
John Cupitt 58b53506ff
add vips_target_end (#2802)
since finish did not return an error code

also make sure we don't call target_end from inside _dispose, since that
can't signal error either

see https://github.com/libvips/libvips/issues/2801
2022-05-20 16:38:04 +01:00
John Cupitt aa5abf3e7e fix background byte ordering in PDF
the `background` param was BGRA rather than vips-style RGBA

see https://github.com/libvips/libvips/pull/2804
2022-05-16 14:28:53 +01:00
John Cupitt 94d8a7d993 tried (and failed) to build against ubuntu nifti
the ubuntu cmake dev files for nifti seem to be broken, and I can't get meson
to add the dependency manually
2022-04-18 15:13:55 +01:00
Kleis Auke Wolthuizen 07edfe37b1
Improve symbol visibility (#2688)
* Improve symbol visibility

* Decorate required internal symbols with VIPS_API

* Remove a couple of stray header decls

* Incorporate review comment

- Ensure symbol visibility is also set on static libraries.
- Prefer to use `cc.has_function_attribute('visibility:hidden')`.

* Don't export internal deprecated symbols

* Move deprecated symbols to vips7compat.h

* `IM_FORMAT_H` -> `VIPS_FORMAT_H`

* Move `vips_window_ref` compat stub to `vips7compat.c`

* Disable deprecation warnings internally

* `vips_image_get_kill` -> `vips_image_iskilled`

* Ensure API compatibility

* Add missing include directives

* Move `vips__init` decl to vips7compat

* Move `vips__get_sizeof_vipsobject` to vips7compat

* Fix introspection build

* Fix 2 introspection warnings

* Ensure compatibility with vipsdisp

/usr/bin/ld: tilesource.o: in function `tile_source_new_from_source':
vipsdisp/tilesource.c:1627: undefined reference to `vips__region_no_ownership'
2022-04-16 10:58:55 +01:00
John Cupitt eba9ec0dd7
Add a way to disable less well tested operations (#2636)
* quick proposal

warn on startup if untrusted operations might run

use vips_block_untrusted_set() to block untrusted operations, set an env
var or make a file to stop the warning

* mark fits, nifti and svg as untrusted

* remove the annoying "untrusted" warning message

better to warn on the download page

leave vips_block_untrusted_set() since it's obviously useful

* separate UNTRUSTED and BLOCKED

* typos

* add VIPS_BLOCK_UNTRUSTED env var

* move BLOCK_UNTRUSTED after plugin load

obviously, ooops

* add a test, disable *magick

although *magick is fuzzed, it's probably safer to disable it in
untrusted environments

* mark some more operations as untrusted
2022-04-11 11:32:32 +01:00
Kleis Auke Wolthuizen 330ebf3cd7
Mosaicing fixes and improvements (#2705)
* Fix segv in `vips_mosaic1`

* Fix ref handling in `rotjoin_search`

* Pass `oarea` to `vips_affine` as `VipsArrayInt` instead

* Flip X/Y positions in `vips__coeff`

* Fix `-Wunused-but-set-variable` warning

* Deprecate unused mosaicing arguments

* Remove a couple of stray header decls
2022-03-03 20:10:20 +00:00
Kleis Auke Wolthuizen a0f9cd95e0
Ensure compatibility with nip2 (#2704)
nip2 uses the `VIPS_EXEEXT` definition.
2022-03-03 18:51:33 +00:00
Kleis Auke Wolthuizen f11b58ff6c
Remove `VIPS_EXEEXT` and `VIPS_SONAME` definitions (#2694)
And the corresponding `soname.h` header.
2022-02-27 15:27:37 +00:00
Kleis Auke Wolthuizen 0337c09700
Cleanup gettext handling (#2695)
Use GLib's i18n support instead of copying and pasting that
logic into its own header. This deprecates the vips/intl.h
header in favour of glib/gi18n.h.
2022-02-27 15:27:28 +00:00
Kleis Auke Wolthuizen 517089fb4b
Meson: don't install deprecated headers when `-Ddeprecated=false` (#2693) 2022-02-27 13:44:09 +00:00
Kleis Auke Wolthuizen 65fbcd351b
Add missing funcs to public C API (#2692) 2022-02-27 13:42:17 +00:00
Kleis Auke Wolthuizen d80185060d
Various improvements to the build systems (#2675)
* Meson: remove space before colon

Since key-value pairs in Python are usually delimited as
colon+space instead of space+colon+space.

* Meson: disable modules by default when building static libraries

Corresponds to autotools. See: #2323.

* Meson: make modules a feature option

Corresponds to autotools, where modules are built
automatically if enabled and supported.

* Meson: specify minimum required GLib version

* Meson: fix indentation

* Remove unused function checks

* Simplify GLib configure checks

* Meson: ensure modules doesn't include enumtypes sources

Since that would cause duplicate symbols.

(`soname_header` can also be safely removed here,
since that is already included in `libvips_headers_dep`)
2022-02-22 14:33:42 +00:00
Corentin Noël 69bf2be12b
Enhance the introspection support by fixing annotations (#2657)
Also refine the .metadata file
2022-02-15 10:54:40 +00:00
John Cupitt 362adae8c6
Revert "Enhance the introspection support by fixing annotations (#2655)" (#2656)
This reverts commit 47796dcda0.
2022-02-15 10:08:07 +00:00
Corentin Noël 47796dcda0
Enhance the introspection support by fixing annotations (#2655)
* Ensure that double asterisk characters are only used for gtk-doc comments

This triggers warnings when parsing the files with the introspection scanner
and gtk-doc

* Enhance the introspection support by fixing annotations

Also refine the .metadata file

Co-authored-by: John Cupitt <jcupitt@gmail.com>
2022-02-15 09:54:32 +00:00
John Cupitt 257d84108e fix some more introspection warnings 2022-02-15 09:48:01 +00:00
Corentin Noël 542dd06999
Refine header inclusion to allow better introspection generation (#2654)
The headers need to be self-contained for the introspection parser
to work correctly. The entry for external users remains vips/vips.h
2022-02-15 05:02:07 +00:00
Corentin Noël 02901436d4
Add meson build system (#2637)
Allows to use the Meson build system to build the project.
2022-02-08 15:19:36 +00:00
John Cupitt 57a0bd82f9 small fixes
update func list in docs
add missing C decls for hyperbolic trig funcs
2021-11-15 11:17:36 +00:00
John Cupitt 3488c6b410 reorder hyperbolic enums to fix an ABI break 2021-11-03 17:57:42 +00:00
Heshy Roskes d8c04011ea
Add hyperbolic functions (#2508)
* add hyperbolic functions
* add hyperbolic function tests
* changelog
* add inverse hyperbolic functions for old compilers
2021-11-02 15:05:37 +00:00
John Cupitt 0c70f3dc7d
add fail-on : better control over loader error handling (#2360)
Instead of a simple fail/don't-fail boolean switch, add fail-on, an enum which sets the sensitivity of loaders to errors. 

There's a new sensitivity level which tries to detect truncated images, but ignores other types of error.
2021-10-31 14:13:18 +00:00
Kleis Auke Wolthuizen 42c8f43432
Improve doc comments (#2504)
* Fix a couple of incorrect doc comments

Helps GIR.

* Add missing doc comment for VIPS_KERNEL_MITCHELL
2021-10-29 13:37:39 +01:00
John Cupitt 47383b5bfc
tell buffer and target savers the file format (#2499)
tell buffer and target savers the file format

Currently, buffer and target savers are not told the format they should
write.

This is usually OK (the JPEG saver already knows it should write JPEG),
but some savers can write several formats, and these currently need an
extra parameter.

For example:

```ruby
buf = x.write_to_buffer ".bmp", format: "bmp"
```

The first ".bmp" gets libvips to pick magicksave, the second
`format:` param is necessary to tell magicksave to write BMP.

This patch adds stub subclasses so that the savers know the exact format. It also improves PPM save.
2021-10-28 18:57:24 +01:00
John Cupitt e815e8ad95
Move the filemode ifdefs to a private header (#2498)
The filemode ifdefs had grown to 30 lines of code duplicated in four
source files. Move to a single copy in a private header (not part of the
public API).
2021-10-27 11:37:51 +01:00