Skip to content

Commit

Permalink
Ensure only one StaySequential operation per pipeline
Browse files Browse the repository at this point in the history
This should reduce memory consumption for more complex pipelines
that combine multiple operations without sequential access support
e.g. flip and Gaussian blur.
  • Loading branch information
lovell committed Apr 19, 2024
1 parent 397ee49 commit 3e8a0fc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/common.cc
Expand Up @@ -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;
}
Expand Down

0 comments on commit 3e8a0fc

Please sign in to comment.