Ensure only one StaySequential operation per pipeline

This should reduce memory consumption for more complex pipelines
that combine multiple operations without sequential access support
e.g. flip and Gaussian blur.
This commit is contained in:
Lovell Fuller 2024-04-19 11:27:51 +01:00
parent 397ee492d9
commit 3e8a0fc522

View File

@ -1082,8 +1082,10 @@ namespace sharp {
Ensure decoding remains sequential.
*/
VImage StaySequential(VImage image, VipsAccess access, bool condition) {
if (access == VIPS_ACCESS_SEQUENTIAL && condition) {
return image.copy_memory();
static const char* meta = "sharp-copy-memory";
if (access == VIPS_ACCESS_SEQUENTIAL && condition && image.get_typeof(meta) != G_TYPE_INT) {
image = image.copy_memory();
image.set(meta, 1);
}
return image;
}