Skip to content

Commit 09e9233

Browse files
committed
Merge branch 'master' of github.com:libvips/libvips
2 parents 0ecefba + 27b2f39 commit 09e9233

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+309
-204
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- tiff: add threadsafe warning/error handlers (requires libtiff 4.5.0+) [lovell]
66
- tiffload: add support for fail_on flag [lovell]
77
- tiffload: add support for unlimited flag (requires libtiff 4.7.0+) [lovell]
8+
- much more reliable operation caching
89

910
8.16.1
1011

libvips/arithmetic/measure.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ vips_measure_build(VipsObject *object)
117117
/* left/top/width/height default to the size of the image.
118118
*/
119119
if (!vips_object_argument_isset(object, "width"))
120-
measure->width = vips_image_get_width(ready);
120+
measure->width = vips_image_get_width(ready); // FIXME: Invalidates operation cache
121121
if (!vips_object_argument_isset(object, "height"))
122-
measure->height = vips_image_get_height(ready);
122+
measure->height = vips_image_get_height(ready); // FIXME: Invalidates operation cache
123123

124124
/* How large are the patches we are to measure?
125125
*/

libvips/colour/icc_transform.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ vips_icc_transform_build(VipsObject *object)
11741174
code->in &&
11751175
(code->in->Type == VIPS_INTERPRETATION_RGB16 ||
11761176
code->in->Type == VIPS_INTERPRETATION_GREY16))
1177-
icc->depth = 16;
1177+
icc->depth = 16; // FIXME: Invalidates operation cache
11781178

11791179
if (vips_icc_set_import(icc,
11801180
transform->embedded, transform->input_profile_filename))

libvips/conversion/arrayjoin.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ typedef struct _VipsArrayjoin {
6464
VipsArrayImage *in;
6565
int across;
6666
int shim;
67-
VipsArea *background;
67+
VipsArrayDouble *background;
6868
VipsAlign halign;
6969
VipsAlign valign;
7070
int hspacing;
@@ -224,7 +224,7 @@ vips_arrayjoin_build(VipsObject *object)
224224
*/
225225
band = (VipsImage **) vips_object_local_array(object, n);
226226
if (vips__bandalike_vec(class->nickname,
227-
in, band, n, join->background->n))
227+
in, band, n, VIPS_AREA(join->background)->n))
228228
return -1;
229229
in = band;
230230

@@ -240,15 +240,15 @@ vips_arrayjoin_build(VipsObject *object)
240240
}
241241

242242
if (!vips_object_argument_isset(object, "hspacing"))
243-
join->hspacing = hspacing;
243+
join->hspacing = hspacing; // FIXME: Invalidates operation cache
244244
if (!vips_object_argument_isset(object, "vspacing"))
245-
join->vspacing = vspacing;
245+
join->vspacing = vspacing; // FIXME: Invalidates operation cache
246246

247247
hspacing = join->hspacing;
248248
vspacing = join->vspacing;
249249

250250
if (!vips_object_argument_isset(object, "across"))
251-
join->across = n;
251+
join->across = n; // FIXME: Invalidates operation cache
252252

253253
/* How many images down the grid?
254254
*/
@@ -452,9 +452,7 @@ vips_arrayjoin_init(VipsArrayjoin *join)
452452
{
453453
/* Init our instance fields.
454454
*/
455-
join->background =
456-
vips_area_new_array(G_TYPE_DOUBLE, sizeof(double), 1);
457-
((double *) (join->background->data))[0] = 0.0;
455+
join->background = vips_array_double_newv(1, 0.0);
458456
}
459457

460458
static int

libvips/conversion/bandfold.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ vips_bandfold_build(VipsObject *object)
116116
return -1;
117117

118118
if (bandfold->factor == 0)
119-
bandfold->factor = bandfold->in->Xsize;
119+
bandfold->factor = bandfold->in->Xsize; // FIXME: Invalidates operation cache
120+
120121
if (bandfold->in->Xsize % bandfold->factor != 0) {
121122
vips_error(class->nickname,
122123
"%s", _("@factor must be a factor of image width"));

libvips/conversion/bandrank.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ vips_bandrank_build(VipsObject *object)
223223
bandary->out_bands = band[0]->Bands;
224224

225225
if (bandrank->index == -1)
226-
bandrank->index = bandary->n / 2;
226+
bandrank->index = bandary->n / 2; // FIXME: Invalidates operation cache
227227
}
228228

229229
if (VIPS_OBJECT_CLASS(vips_bandrank_parent_class)->build(object))

libvips/conversion/bandunfold.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ vips_bandunfold_build(VipsObject *object)
119119
return -1;
120120

121121
if (bandunfold->factor == 0)
122-
bandunfold->factor = bandunfold->in->Bands;
122+
bandunfold->factor = bandunfold->in->Bands; // FIXME: Invalidates operation cache
123+
123124
if (bandunfold->in->Bands % bandunfold->factor != 0) {
124125
vips_error(class->nickname,
125126
"%s", _("@factor must be a factor of image bands"));

libvips/conversion/composite.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ vips_composite_base_build(VipsObject *object)
13871387
break;
13881388
}
13891389

1390-
composite->compositing_space = any_16
1390+
composite->compositing_space = any_16 // FIXME: Invalidates operation cache
13911391
? (all_grey
13921392
? VIPS_INTERPRETATION_GREY16
13931393
: VIPS_INTERPRETATION_RGB16)

libvips/conversion/embed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ vips_embed_base_build(VipsObject *object)
371371

372372
if (!vips_object_argument_isset(object, "extend") &&
373373
vips_object_argument_isset(object, "background"))
374-
base->extend = VIPS_EXTEND_BACKGROUND;
374+
base->extend = VIPS_EXTEND_BACKGROUND; // FIXME: Invalidates operation cache
375375

376376
if (base->extend == VIPS_EXTEND_BACKGROUND)
377377
if (!(base->ink = vips__vector_to_ink(

libvips/conversion/flatten.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ vips_flatten_build(VipsObject *object)
326326
* interpretation.
327327
*/
328328
if (!vips_object_argument_isset(object, "max_alpha"))
329-
flatten->max_alpha = vips_interpretation_max_alpha(in->Type);
329+
flatten->max_alpha = vips_interpretation_max_alpha(in->Type); // FIXME: Invalidates operation cache
330330

331331
/* Is max_alpha less than the numeric range of this image? If it is,
332332
* we can get int overflow.

libvips/conversion/join.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ typedef struct _VipsJoin {
8181
VipsDirection direction;
8282
gboolean expand;
8383
int shim;
84-
VipsArea *background;
84+
VipsArrayDouble *background;
8585
VipsAlign align;
8686
} VipsJoin;
8787

@@ -286,9 +286,7 @@ vips_join_init(VipsJoin *join)
286286
{
287287
/* Init our instance fields.
288288
*/
289-
join->background =
290-
vips_area_new_array(G_TYPE_DOUBLE, sizeof(double), 1);
291-
((double *) (join->background->data))[0] = 0.0;
289+
join->background = vips_array_double_newv(1, 0.0);
292290
}
293291

294292
/**

libvips/conversion/premultiply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ vips_premultiply_build(VipsObject *object)
224224
* interpretation.
225225
*/
226226
if (!vips_object_argument_isset(object, "max_alpha"))
227-
premultiply->max_alpha = vips_interpretation_max_alpha(in->Type);
227+
premultiply->max_alpha = vips_interpretation_max_alpha(in->Type); // FIXME: Invalidates operation cache
228228

229229
if (in->BandFmt == VIPS_FORMAT_DOUBLE)
230230
conversion->out->BandFmt = VIPS_FORMAT_DOUBLE;

libvips/conversion/smartcrop.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,8 @@ vips_smartcrop_build(VipsObject *object)
386386
case VIPS_INTERESTING_ALL:
387387
left = 0;
388388
top = 0;
389-
smartcrop->width = in->Xsize;
390-
smartcrop->height = in->Ysize;
389+
smartcrop->width = in->Xsize; // FIXME: Invalidates operation cache
390+
smartcrop->height = in->Ysize; // FIXME: Invalidates operation cache
391391
break;
392392

393393
default:

libvips/conversion/tilecache.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ vips_line_cache_gen(VipsRegion *out_region,
897897
*/
898898
if (out_region->valid.height >
899899
block_cache->max_tiles * block_cache->tile_height) {
900-
block_cache->max_tiles =
900+
block_cache->max_tiles = // FIXME: Invalidates operation cache
901901
1 + (out_region->valid.height / block_cache->tile_height);
902902
VIPS_DEBUG_MSG("vips_line_cache_gen: bumped max_tiles to %d\n",
903903
block_cache->max_tiles);
@@ -922,7 +922,7 @@ vips_line_cache_build(VipsObject *object)
922922
VIPS_DEBUG_MSG("vips_line_cache_build\n");
923923

924924
if (!vips_object_argument_isset(object, "access"))
925-
block_cache->access = VIPS_ACCESS_SEQUENTIAL;
925+
block_cache->access = VIPS_ACCESS_SEQUENTIAL; // FIXME: Invalidates operation cache
926926

927927
if (VIPS_OBJECT_CLASS(vips_line_cache_parent_class)->build(object))
928928
return -1;
@@ -931,7 +931,7 @@ vips_line_cache_build(VipsObject *object)
931931
*/
932932
vips_get_tile_size(block_cache->in,
933933
&tile_width, &tile_height, &n_lines);
934-
block_cache->tile_width = block_cache->in->Xsize;
934+
block_cache->tile_width = block_cache->in->Xsize; // FIXME: Invalidates operation cache
935935

936936
/* Output has two buffers n_lines height, so 2 * n_lines is the maximum
937937
* non-locality from threading. Double again for conv, rounding, etc.
@@ -941,7 +941,7 @@ vips_line_cache_build(VipsObject *object)
941941
* minimum of two strips, so we can handle requests that straddle a
942942
* tile boundary.
943943
*/
944-
block_cache->max_tiles = VIPS_MAX(2,
944+
block_cache->max_tiles = VIPS_MAX(2, // FIXME: Invalidates operation cache
945945
4 * n_lines / block_cache->tile_height);
946946

947947
VIPS_DEBUG_MSG("vips_line_cache_build: n_lines = %d\n",

libvips/conversion/transpose3d.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ vips_transpose3d_build(VipsObject *object)
126126

127127
if (!vips_object_argument_isset(object, "page_height")) {
128128
if (vips_image_get_int(in,
129-
VIPS_META_PAGE_HEIGHT, &transpose3d->page_height))
129+
VIPS_META_PAGE_HEIGHT, &transpose3d->page_height)) // FIXME: Invalidates operation cache
130130
return -1;
131131
}
132132

libvips/conversion/unpremultiply.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,12 @@ vips_unpremultiply_build(VipsObject *object)
281281
* interpretation.
282282
*/
283283
if (!vips_object_argument_isset(object, "max_alpha"))
284-
unpremultiply->max_alpha = vips_interpretation_max_alpha(in->Type);
284+
unpremultiply->max_alpha = vips_interpretation_max_alpha(in->Type); // FIXME: Invalidates operation cache
285285

286286
/* Is alpha-band unset? Default to the final band for this image.
287287
*/
288288
if (!vips_object_argument_isset(object, "alpha_band"))
289-
unpremultiply->alpha_band = in->Bands - 1;
289+
unpremultiply->alpha_band = in->Bands - 1; // FIXME: Invalidates operation cache
290290

291291
if (in->BandFmt == VIPS_FORMAT_DOUBLE)
292292
conversion->out->BandFmt = VIPS_FORMAT_DOUBLE;

libvips/conversion/wrap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ vips_wrap_build(VipsObject *object)
7676
return -1;
7777

7878
if (!vips_object_argument_isset(object, "x"))
79-
wrap->x = wrap->in->Xsize / 2;
79+
wrap->x = wrap->in->Xsize / 2; // FIXME: Invalidates operation cache
8080
if (!vips_object_argument_isset(object, "y"))
81-
wrap->y = wrap->in->Ysize / 2;
81+
wrap->y = wrap->in->Ysize / 2; // FIXME: Invalidates operation cache
8282

8383
/* Clock arithmetic: we want negative x/y to wrap around
8484
* nicely.

libvips/convolution/conva.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ vips_conva_decompose_hlines(VipsConva *conva)
334334
layers_above = VIPS_CEIL(max / depth);
335335
depth = max / layers_above;
336336
layers_below = VIPS_FLOOR(min / depth);
337-
conva->layers = layers_above - layers_below;
337+
conva->layers = layers_above - layers_below; // FIXME: Invalidates operation cache
338338

339339
VIPS_DEBUG_MSG("vips_conva_decompose_hlines: depth = %g, layers = %d\n",
340340
depth, conva->layers);

libvips/convolution/sharpen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ vips_sharpen_build(VipsObject *object)
189189
*/
190190
if (!vips_object_argument_isset(object, "sigma") &&
191191
vips_object_argument_isset(object, "radius"))
192-
sharpen->sigma = 1 + sharpen->radius / 2;
192+
sharpen->sigma = 1 + sharpen->radius / 2; // FIXME: Invalidates operation cache
193193

194194
in = sharpen->in;
195195

libvips/create/gaussmat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ vips_gaussmat_build(VipsObject *object)
114114
if (vips_object_argument_isset(object, "integer") &&
115115
!vips_object_argument_isset(object, "precision") &&
116116
!gaussmat->integer)
117-
gaussmat->precision = VIPS_PRECISION_FLOAT;
117+
gaussmat->precision = VIPS_PRECISION_FLOAT; // FIXME: Invalidates operation cache
118118

119119
/* Find the size of the mask. Limit the mask size to 10k x 10k for
120120
* sanity. We allow x == 0, meaning a 1x1 mask.

libvips/create/logmat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ vips_logmat_build(VipsObject *object)
106106
if (vips_object_argument_isset(object, "integer") &&
107107
!vips_object_argument_isset(object, "precision") &&
108108
!logmat->integer)
109-
logmat->precision = VIPS_PRECISION_FLOAT;
109+
logmat->precision = VIPS_PRECISION_FLOAT; // FIXME: Invalidates operation cache
110110

111111
if (vips_check_precision_intfloat(class->nickname,
112112
logmat->precision))

libvips/create/text.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ vips_text_autofit(VipsText *text)
314314
previous_difference = difference;
315315
previous_dpi = text->dpi;
316316

317-
text->dpi = difference < 0 ? text->dpi * 2 : text->dpi / 2;
317+
text->dpi = difference < 0 ? text->dpi * 2 : text->dpi / 2; // FIXME: Invalidates operation cache
318318

319319
/* This can happen with fixed-size fonts.
320320
*/
@@ -343,7 +343,7 @@ vips_text_autofit(VipsText *text)
343343
*/
344344
while (upper_dpi - lower_dpi > 1 &&
345345
difference != 0) {
346-
text->dpi = (upper_dpi + lower_dpi) / 2;
346+
text->dpi = (upper_dpi + lower_dpi) / 2; // FIXME: Invalidates operation cache
347347
if (vips_text_get_extents(text, &extents))
348348
return -1;
349349
target.left = extents.left;
@@ -361,9 +361,9 @@ vips_text_autofit(VipsText *text)
361361
* must take lower.
362362
*/
363363
if (difference == 0)
364-
text->dpi = upper_dpi;
364+
text->dpi = upper_dpi; // FIXME: Invalidates operation cache
365365
else
366-
text->dpi = lower_dpi;
366+
text->dpi = lower_dpi; // FIXME: Invalidates operation cache
367367
g_object_set(text, "autofit_dpi", text->dpi, NULL);
368368

369369
#ifdef DEBUG

libvips/draw/draw.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ vips_draw_class_init(VipsDrawClass *class)
122122
{
123123
GObjectClass *gobject_class = G_OBJECT_CLASS(class);
124124
VipsObjectClass *vobject_class = VIPS_OBJECT_CLASS(class);
125+
VipsOperationClass *operation_class = VIPS_OPERATION_CLASS(class);
125126

126127
gobject_class->set_property = vips_object_set_property;
127128
gobject_class->get_property = vips_object_get_property;
@@ -130,6 +131,9 @@ vips_draw_class_init(VipsDrawClass *class)
130131
vobject_class->description = _("draw operations");
131132
vobject_class->build = vips_draw_build;
132133

134+
// no draw operation is cached
135+
operation_class->flags |= VIPS_OPERATION_NOCACHE;
136+
133137
VIPS_ARG_IMAGE(class, "image", 1,
134138
_("Image"),
135139
_("Image to draw on"),

libvips/foreign/dzsave.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,21 +2009,6 @@ vips_foreign_save_dz_build(VipsObject *object)
20092009
return -1;
20102010
}
20112011

2012-
/* Default to white background. vips_foreign_save_init() defaults to
2013-
* black.
2014-
*/
2015-
if (!vips_object_argument_isset(object, "background")) {
2016-
VipsArrayDouble *background;
2017-
2018-
/* Using g_object_set() to set an input param in build will
2019-
* change the hash and confuse caching, but we don't cache
2020-
* savers, so it's fine.
2021-
*/
2022-
background = vips_array_double_newv(1, 255.0);
2023-
g_object_set(object, "background", background, NULL);
2024-
vips_area_unref(VIPS_AREA(background));
2025-
}
2026-
20272012
/* DeepZoom stops at 1x1 pixels, others when the image fits within a
20282013
* tile.
20292014
*/
@@ -2499,6 +2484,12 @@ vips_foreign_save_dz_init(VipsForeignSaveDz *dz)
24992484
dz->region_shrink = VIPS_REGION_SHRINK_MEAN;
25002485
dz->skip_blanks = -1;
25012486
dz->Q = 75;
2487+
2488+
// we default background to 255 (not 0), see vips_foreign_save_init()
2489+
VipsForeignSave *save = (VipsForeignSave *) dz;
2490+
if (save->background)
2491+
vips_area_unref(VIPS_AREA(save->background));
2492+
save->background = vips_array_double_newv(1, 255.0);
25022493
}
25032494

25042495
typedef struct _VipsForeignSaveDzTarget {

libvips/foreign/fits.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ vips_fits_new_write(VipsImage *in, const char *filename)
575575
VIPS_IMAGE_SIZEOF_ELEMENT(in) * in->Xsize, VipsPel)))
576576
return NULL;
577577

578-
/* fits_create_file() will fail if there's a file of thet name, unless
578+
/* fits_create_file() will fail if there's a file of that name, unless
579579
* we put a "!" in front of the filename. This breaks conventions with
580580
* the rest of vips, so just unlink explicitly.
581581
*/

libvips/foreign/heifload.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,10 +810,10 @@ vips_foreign_load_heif_header(VipsForeignLoad *load)
810810
*/
811811
if (!vips_object_argument_isset(VIPS_OBJECT(load), "page") &&
812812
!vips_object_argument_isset(VIPS_OBJECT(load), "n"))
813-
heif->page = heif->primary_page;
813+
heif->page = heif->primary_page; // FIXME: Invalidates operation cache
814814

815815
if (heif->n == -1)
816-
heif->n = heif->n_top - heif->page;
816+
heif->n = heif->n_top - heif->page; // FIXME: Invalidates operation cache
817817
if (heif->page < 0 ||
818818
heif->n <= 0 ||
819819
heif->page + heif->n > heif->n_top) {

0 commit comments

Comments
 (0)