Commit Graph

597 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 feae09e9cd make arrayjoin much faster with large arrays
arrayjoin was making a region on every input image during startup, and
repeating for each thread (!!) so large arrays could be very expensive
to join.

Instead, make input regions on demand, and computre set of required
input images rather than searching for them.

See https://github.com/libvips/libvips/discussions/3247
2022-12-29 20:50:22 +00:00
John Cupitt 09c50bac60 tiny doc fix
see https://github.com/libvips/libvips/discussions/3239#discussioncomment-4490620
2022-12-24 13:03:20 +00:00
Kleis Auke Wolthuizen 0629a5de7f
Ensure consistent formatting of `->format_table` (#3199) 2022-11-30 09:41:05 +00:00
Emanuel Jöbstl 25444cd927
Expose attention center when doing attention-based cropping. (#3164)
* ADded optional output parameter to smartcrop to track the center of
attention.

* Added unit test.

* Added docs & updated changelog.

* Updated argument labels & types in documentation.
2022-11-28 14:10:16 +00:00
John Cupitt 144834a6aa replace memcpy() in d180 with a loop
thanks alantudyk

see https://github.com/libvips/libvips/issues/3149#issuecomment-1309405404
2022-11-10 04:45:50 +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
John Cupitt aa109f102d Merge branch '8.13' 2022-08-14 10:31:09 +01:00
John Cupitt 29e80ca43f better 0 detection in unpremultiply
We were avoiding /0 by testing for alpha==0, however, this will still
allow very small values of alpha to generate +/- Inf. Instead, check for
abs(alpha)<epsilon.

Fixes some artifacts after unpremul.
2022-08-08 16:16:10 +01:00
John Cupitt 7e961b4671 Merge branch '8.13' 2022-08-02 14:22:27 +01:00
Kleis Auke Wolthuizen b808cba14a
Remove unneeded adapter function for Emscripten (#2949)
The `*_class_intern_init` functions have already been patched within
wasm-vips to include the missing `class_data` member, so this adapter
function was not needed.
2022-07-27 09:14:12 +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 e93f56c8bb
Simplify/modernize `vips_crop_get_type()` (#2940) 2022-07-23 10:14:03 +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
Kleis Auke Wolthuizen bae0342d95
Update C++ binding and function list (#2851)
* Update C++ binding and function list

Also, start with a capital letter in descriptions whenever possible.

* Ensure `dzsave_target` is generated
2022-06-10 14:43:44 +01:00
John Cupitt cb1927e1b7 make C and vector path for composite match
one was <, one was <= for HARD_LIGHT
no effect on result, but it's better if they are consistent
2022-06-03 16:15:51 +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 55b857d446 revise cast asserts
since we allow casting between formats ofthe same size with shift enabled

fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=45016&q=libvips&can=2
2022-04-03 15:32:25 +01:00
John Cupitt a77a1071a2 fix a crash with empty image arrays in bandjoin
see https://github.com/libvips/pyvips/pull/310
2022-03-24 22:38:03 +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
John Cupitt c5f2fea8bf fix a gcc warning with clang pragmas 2022-02-22 10:06:43 +00:00
John Cupitt 82a8df2a1f fix some more small introspection warnings 2022-02-15 10:10:21 +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 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 edf63dfeeb fix insert
We were not detecting the shortcut cases for insert correctly, thanks
chreru.

See https://github.com/libvips/libvips/issues/2548
2021-11-21 14:50:55 +00:00
John Cupitt 6f081de0a0 add minimise to insert
This patch makes "insert" issue minimise signals for inputs in sequential
mode. This can drop memory use in some programs, for example:

```python

import sys
import random
import pyvips

image = pyvips.Image.black(20000, 20000)

for filename in sys.argv[2:]:
    tile = pyvips.Image.new_from_file(filename, access='sequential')
    x = random.randint(0, image.width - tile.width)
    y = random.randint(0, image.height - tile.height)
    image = image.insert(tile, x, y)

image.write_to_file(sys.argv[1])
```

Before this patch:

```
$ for i in {0..1000}; do cp ~/pics/k2.jpg $i.jpg; done
$ /usr/bin/time -f %M:%e ../manyjoin.py ../x.jpg *.jpg
5456256:4.34
```

With this patch:

```
$ /usr/bin/time -f %M:%e ../manyjoin.py ../x.jpg *.jpg
2475324:3.38
```
2021-11-05 12:14:50 +00:00
John Cupitt 41e92b9ada tiny arrayjoin polish 2021-11-05 10:09:16 +00:00
John Cupitt 778ff7fce5 wider margin for arrayjoin minimise
This patch makes arrayjoin leave a bigger margin off the end of each
input image. This can help some loaders which have large output caches.

See https://github.com/libvips/libvips/issues/2440
2021-11-04 17:17:17 +00:00
Kleis Auke Wolthuizen 1044dd46eb
Move vips__ink_to_vector and im__vector_to_ink to compat (#2488)
It was only used by getpoint in vips8, which is simpler to inline.
2021-10-20 13:00:01 +01:00
John Cupitt 5e7e914b06 hide some setup loops from --vips-progress
see https://github.com/libvips/libvips/issues/2450
2021-10-19 16:19:20 +01:00
John Cupitt 7e8af07c66
Fix flatten clip (#2432)
* fic gtk-doc typenames in cgif

* fix flatten clipping

flatten could produce out of range values if max_alpha was less than
the limit of the numeric range of the format

https://github.com/libvips/libvips/issues/2431
2021-09-13 11:23:02 +01:00
Kleis Auke Wolthuizen 5ab66e16e1
Fix UBSan errors (#1948)
* Ensure UBSan exits with a non-zero code on error

* Avoid misaligned member access in mosaic_fuzzer

* Add missing VIPS_CLIP in scRGB2sRGB/scRGB2BW

* Fix UBSan error in flatten

By using saturated casts for the int types (copied from vips_cast).

* CI: ensure fuzzer log is printed on error

* Avoid UB in heifload

* Revert flatten change

I could no longer reproduce this with clang 12 locally.

* Indentation fixes [skip ci]
2021-09-12 13:14:24 +01:00
John Cupitt f8c2a36746 arrayjoin signalling minimise also frees memory
By making the sequential line cache non-persistent, and only minimising
when the read point is well past the image.

On large arrayjoin operations, this saves many GB of memory.

See https://github.com/kleisauke/net-vips/issues/135
2021-09-06 23:14:36 +01:00
John Cupitt a20cd4cdc1 minimise arrayjoin inputs during processing
arrayjoin with a sequential pipeline will now minimise inputs when they
are no longer being used. This drops the number of open file handles
needed to construct large arrays.

Sadly, memory savings are minimal.

see https://github.com/kleisauke/net-vips/issues/135
2021-09-06 20:22:29 +01:00
John Cupitt 99724e6097 safer stop-early logic in tilecache
Don't actually stop the tilecache loop early, since that could deadlock,
instead just stop fetching from the pipeline.

see https://github.com/libvips/libvips/pull/2424
2021-09-05 12:55:52 +01:00
John Cupitt e7889ff8e1 stop cache tile generation early on error
We didn't stop tile calculation as early as we could on error.

See https://github.com/libvips/libvips/pull/2424
2021-09-05 12:46:11 +01:00
John Cupitt f39e2e271d don't invalidate in sinkscreen
it was called from a bg thread and could race when under heavy load, eg.
vipsdisp displaying animated jpg images
2021-06-06 16:53:00 +01:00
John Cupitt dca526405e revise old comment 2021-05-25 14:06:47 +01:00
John Cupitt 6ab30ca732 Merge branch '8.10' 2021-03-23 23:18:48 +00:00
Kleis Auke Wolthuizen 305714c978 Move max_band_vec to first position 2021-03-23 16:47:53 +01:00
Kleis Auke Wolthuizen e7faebf6af Tell the compiler that v4f is aligned
It's guaranteed that this is now aligned on a 16-byte boundary.
2021-03-20 11:33:37 +01:00
Kleis Auke Wolthuizen 5ef9c84f97 Use cross-platform functions for allocating aligned memory
A malloc library is expected to provide a better implementation.
2021-03-15 11:10:16 +01:00
Kleis Auke Wolthuizen a55513a194 Ensure max_band vector is aligned on a 16-byte boundary
See https://github.com/mstorsjo/llvm-mingw/issues/190
2021-03-12 14:27:19 +01:00
John Cupitt 2e56828053 Merge branch '8.10' 2021-03-06 11:47:02 +00:00
John Cupitt 0623a05f48 remove vips_recip()
it wasn't really necessary, and it was rather slow
2021-03-05 20:19:05 +00:00
John Cupitt 0407c365d1 better again 2021-02-27 20:47:29 +00:00
John Cupitt d3ccadf212 revise unpremultiply, again
We were not detecting division by zero carefully enough, nor clipping
the alpha range sufficiently in unpremultiply.

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

also see https://github.com/libvips/libvips/pull/1675 for another
difficult test case
2021-02-27 15:16:25 +00:00