Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c7d4360

Browse files
committed
reducev: remove seq line cache
This partially reverts commit 3ca2068.
1 parent 4de99f8 commit c7d4360

File tree

1 file changed

+9
-34
lines changed

1 file changed

+9
-34
lines changed

libvips/resample/reducev.cpp

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* - speed up the mask construction for uchar/ushort images
2424
* 22/4/22 kleisauke
2525
* - add @gap option
26+
* 22/8/25 kleisauke
27+
* - remove seq line cache
2628
*/
2729

2830
/*
@@ -830,7 +832,7 @@ vips_reducev_build(VipsObject *object)
830832
VipsResample *resample = VIPS_RESAMPLE(object);
831833
VipsReducev *reducev = (VipsReducev *) object;
832834
VipsImage **t = (VipsImage **)
833-
vips_object_local_array(object, 5);
835+
vips_object_local_array(object, 3);
834836

835837
VipsImage *in;
836838
VipsGenerateFn generate;
@@ -983,8 +985,7 @@ vips_reducev_build(VipsObject *object)
983985
*/
984986
generate = vips_reducev_gen;
985987

986-
t[3] = vips_image_new();
987-
if (vips_image_pipelinev(t[3],
988+
if (vips_image_pipelinev(resample->out,
988989
VIPS_DEMAND_STYLE_FATSTRIP, in, nullptr))
989990
return -1;
990991

@@ -995,8 +996,8 @@ vips_reducev_build(VipsObject *object)
995996
* example, vipsthumbnail knows the true reduce factor (including the
996997
* fractional part), we just see the integer part here.
997998
*/
998-
t[3]->Ysize = height;
999-
if (t[3]->Ysize <= 0) {
999+
resample->out->Ysize = height;
1000+
if (resample->out->Ysize <= 0) {
10001001
vips_error(object_class->nickname,
10011002
"%s", _("image has shrunk to nothing"));
10021003
return -1;
@@ -1005,41 +1006,15 @@ vips_reducev_build(VipsObject *object)
10051006
#ifdef DEBUG
10061007
printf("vips_reducev_build: reducing %d x %d image to %d x %d\n",
10071008
in->Xsize, in->Ysize,
1008-
t[3]->Xsize, t[3]->Ysize);
1009+
resample->out->Xsize, resample->out->Ysize);
10091010
#endif /*DEBUG*/
10101011

1011-
if (vips_image_generate(t[3],
1012+
if (vips_image_generate(resample->out,
10121013
vips_reducev_start, generate, vips_reducev_stop,
10131014
in, reducev))
10141015
return -1;
10151016

1016-
in = t[3];
1017-
1018-
vips_reorder_margin_hint(in, reducev->n_point);
1019-
1020-
/* Large reducev will throw off sequential mode. Suppose thread1 is
1021-
* generating tile (0, 0), but stalls. thread2 generates tile
1022-
* (0, 1), 128 lines further down the output. After it has done,
1023-
* thread1 tries to generate (0, 0), but by then the pixels it needs
1024-
* have gone from the input image line cache if the reducev is large.
1025-
*
1026-
* To fix this, put another seq on the output of reducev. Now we'll
1027-
* always have the previous XX lines of the shrunk image, and we won't
1028-
* fetch out of order.
1029-
*/
1030-
if (vips_image_is_sequential(in)) {
1031-
g_info("reducev sequential line cache");
1032-
1033-
if (vips_sequential(in, &t[4],
1034-
"tile_height", 10,
1035-
// "trace", TRUE,
1036-
nullptr))
1037-
return -1;
1038-
in = t[4];
1039-
}
1040-
1041-
if (vips_image_write(in, resample->out))
1042-
return -1;
1017+
vips_reorder_margin_hint(resample->out, reducev->n_point);
10431018

10441019
return 0;
10451020
}

0 commit comments

Comments
 (0)