Commit Graph

2287 Commits

Author SHA1 Message Date
John Cupitt b8a2d26ad9 Merge branch '8.13' 2022-11-09 14:53:43 +00:00
John Cupitt 557fc76634 faster gif save if interpalette-maxerror is huge
If interpalette-maxerror is very large, we don't need to recompute the
palette for every frame, since we'll never choose a new palette.
2022-11-07 16:49:12 +00:00
John Cupitt 3ebb21491d improve fail-on handling for GIF load
fail-on truncated and warning now works for GIF load
2022-11-05 12:04:47 +00:00
Michael Drake b32bc70de7
libnsgif: Update to latest upstream (#3142)
Allows clients to know if the scan encountered a truncated image.
2022-11-05 11:16:23 +00:00
Michael Drake 2189e49dc7
Update to latest upstream libnsgif and call nsgif_data_complete (#3141)
* libnsgif: update script: Fix to handle dir with no patches

* libnsgif: Update to latest upstream

Fixes loading of broken gifs with truncated final frame.

* nsgifload: Call nsgif_data_complete after data scan

This allows libnsgif to distinguish between awaiting more
data, and a broken truncated GIF. In the latter case we
can display what we have.
2022-11-05 04:14:45 +00:00
John Cupitt 17ca29adc9 tiny formatting fixes 2022-10-27 17:54:09 +01: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
Lovell Fuller c76d74be65
Ensure EXIF is at least 4 bytes before inspection (#3109) 2022-10-22 11:20:53 +01:00
Kleis Auke Wolthuizen ea0912f23b
Fix build with `-Dwebp=disabled` (#3106) 2022-10-20 10:34:08 +01:00
John Cupitt e33796d752 Merge branch '8.13' 2022-10-19 17:35:36 +01:00
Sergey Alexandrovich 982a835eed
spngsave: Don't shift indexed pixels (#3101) 2022-10-19 17:34:43 +01:00
John Cupitt 2335172794 Merge branch '8.13' 2022-10-19 12:47:53 +01:00
Lovell Fuller 1fc01c05e8
exif: ensure prefix is present before parsing (#3100)
Newer Apple devices are creating EXIF without this however libexif
still requires it due to JPEG/JFIF/APP1 marker heritage.
2022-10-19 12:47:23 +01:00
John Cupitt f0bb3e3442 Merge branch '8.13' 2022-10-14 20:06:34 +01:00
Sergey Alexandrovich c6498e5c2c
spngsave: fix transparency (#3074) 2022-10-14 20:05:29 +01:00
Kleis Auke Wolthuizen f38acdef1a
spngsave: ensure quantisation occurs last (#3073)
* spngsave: ensure quantisation occurs last

i.e. after setting the metadata and phyiscal pixel dimensions,
since quantisation will overwrite the image.

* spngsave: avoid over-allocation of temporary buffer

For low-bitdepth write and palette-based output.
2022-10-14 19:29:29 +01:00
Daniel Löbl 9c2accf831
webpsave: switch to g_try_malloc() and limit WebP output dimensions (#3094)
* webpsave: switch to g_try_malloc()

* webpsave: add dimensions limit check

* output the amount of memory requested on malloc error
2022-10-14 15:35:07 +01:00
John Cupitt b661f4bc27 revise formatting 2022-10-12 18:27:10 +01:00
John Cupitt ab2e0bf38c Merge branch '8.13' 2022-10-11 08:49:03 +01:00
John Cupitt fbef674625 better rules for 16-bit heifsave
now parallel 16-bit PNG save

see https://github.com/libvips/libvips/discussions/3087
2022-10-11 08:45:24 +01:00
John Cupitt 69b139dfff Merge branch '8.13' 2022-09-29 05:55:18 +01:00
Lovell Fuller d3a1d4df1b
spngsave: name ICC profiles (#3068)
The PNG spec requires that the iCCP chunk has a profile name with
a minumum length of 1 (we use the same "icc" name as pngsave).
2022-09-28 16:28:44 +01:00
Kleis Auke Wolthuizen 4176ab2106
tiff2vips: avoid `g_assert_not_reached` in the default clause (#3064)
Since that could terminate the application in debug builds. Also,
add the missing case clause for `PHOTOMETRIC_MINISWHITE`.

Resolves: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=51013.
2022-09-24 13:36:02 +01:00
John Cupitt eed0e5b43c Merge branch '8.13' 2022-09-22 14:11:31 +01:00
John Cupitt a86f33769b add changelog note 2022-09-22 14:09:55 +01:00
Ruven 33d44e86fb SubIFD offsets should only be added if smaller pyramid layers actually exist. Otherwise results in corrupted TIFF files for images smaller than the tile size (#3058) 2022-09-22 14:09:03 +01:00
Ruven cdf497d3e2
SubIFD offsets should only be added if smaller pyramid layers actually exist. Otherwise results in corrupted TIFF files for images smaller than the tile size (#3058) 2022-09-22 13:36:27 +01:00
John Cupitt c9a21a7aaa Merge branch '8.13' 2022-09-21 11:50:16 +01:00
John Cupitt fa4b80b74b earlier quit of dzsave on kill
We were only testing "killed" once for each strip of tiles. Check on each
tile as well to make set_kill() faster.

see https://github.com/kleisauke/net-vips/issues/179
2022-09-21 11:48:48 +01:00
John Cupitt 75bd19759f Merge branch '8.13' 2022-09-20 10:04:22 +01:00
John Cupitt 907d17cd06 revise caching of seq mode loaders
We were not caching seq mode loaders used in random access mode.

see https://github.com/libvips/libvips/issues/3044
2022-09-20 10:03:00 +01:00
John Cupitt 3b33d912c4 fix an undefined shift 2022-09-15 12:57:36 +01:00
John Cupitt d2e7d036ae improve HEIF is_a
- fix sign issue with some chunk sizes
- allow larger chunk_len

See https://github.com/libvips/libvips/discussions/3048
2022-09-14 16:56:37 +01:00
Kleis Auke Wolthuizen 6bf1422548
jxlsave: sync quality to distance calculation with libjxl (#3050)
Ensures the quality to distance conversion is continuous at 30.

See:
ea5fa8074d
2022-09-14 13:40:40 +01:00
Ruven 4985fec6b4
Inverted order of TIFF tag writing when saving multi-page subifd pyramids (#3047)
* Inverted order of TIFF tag writing when saving multi-page subifd pyramids to ensure that subifd pyramid layers are correctly tagged as reduced-image subfile type and not as pages

* Use if-else clause to avoid tag overwriting
2022-09-13 17:56:42 +01:00
John Cupitt 3081821636 revert dhint check
We added a check that loader ->header() and ->load() methods set the
same dhint. This commit removes that check -- it's not possible to make
header and load match in all cases since images can take so many routes,
and can change between the two events.

If we see performance issues around inappropriate cache sizing again,
try to fix just those cases.
2022-09-12 10:38:17 +01:00
Lovell Fuller c9de7b2b15
tiff2vips: ensure stdint.h in included for uint32_t (#3040) 2022-09-11 13:41:30 +01:00
Sergey Alexandrovich ce31c04cd2
nsgifload: choose tile-height based on page height (#2996) 2022-09-08 19:05:42 +01:00
Daniel Löbl 2d9c50735f
webpsave: switch to sink_disc (#3018)
* webpsave: switch to sink_disc

* fix some warnings

* distinguish between animated and single image write

* fix some formatting issues

* add missing comments

* fix webpsave_mime

* don't use sink_disc for single image webp write

* fix potential segv/double free

* update changelog

* remove leftover function declaration

* Revert "don't use sink_disc for single image webp write"

This reverts commit a75922ca93ee8987fa5e1ffc52b68e22bd6fb1fb.

* implement review feedback

* adjust to a column size of 80

* get contiguous RGB(A) buffer directly from VipsRegion

* Revert "get contiguous RGB(A) buffer directly from VipsRegion"

This reverts commit 84fc10e52fb223f0208c605dde92d3f821ceee0e.

* accumulate image data directly in frame_bytes buffer

* switch WebP back to Webp naming scheme

* rename page_index to page_number

* revise formatting
2022-09-08 14:32:13 +01:00
John Cupitt a36d382519 oop debug left on 2022-09-08 10:21:19 +01:00
John Cupitt c0e91d139d revise cgifsave to save mem
a bit simpler too

copying dloebl's idea from https://github.com/libvips/libvips/pull/3018
2022-09-08 10:16:50 +01:00
John Cupitt 5d1e26255d Merge branch '8.13' 2022-09-08 09:14:01 +01:00
Lovell Fuller b58b7bd416
pngsave: ensure 8-bit palette images can be created (#3031) 2022-09-08 09:10:02 +01:00
John Cupitt 3191e5cea5 revise cgif save loop 2022-09-07 12:10:20 +01:00
John Cupitt 91986a9778 revise cgif save loop 2022-09-07 11:10:02 +01:00
John Cupitt 5afc4a2df5 Merge branch '8.13' 2022-09-05 09:59:25 +01:00
Kleis Auke Wolthuizen e87c828aa5
dzsave: add missing include directive for errno/EEXIST (#3025)
Resolves: #3024.
2022-09-05 09:58:52 +01:00
John Cupitt 078ac059b7 update spngload for new header test 2022-09-03 22:42:41 +01:00
John Cupitt 19009b15a9 revise loader demand hints
Add a check that header and load methods agree on the demand hint, and
make sure all loaders pass.

If they disagree, you can get bad performance in some cases, since the
pipeline can be built from the header dhint.
2022-09-03 15:31:37 +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