Repository navigation
Improve pasting onto I;16 images - #10398
Conversation
| int in_i16 = imIn->type == IMAGING_TYPE_I16; | ||
| int out_i16 = imOut->type == IMAGING_TYPE_I16; | ||
| for (; y != y_end; y += offset) { | ||
| UINT8 *out = imOut->image8[y + dy] + dx; | ||
| if (out_i16) { | ||
| out += dx; | ||
| } | ||
| UINT8 *in = imIn->image8[y + sy] + sx; | ||
| if (in_i16) { | ||
| in += sx; | ||
| } | ||
| UINT8 *mask = imMask->image8[y + sy] + sx; | ||
| for (x = 0; x < xsize; x++) { | ||
| *out = BLEND(*mask, *out, *in, tmp1); | ||
| if (in_i16) { | ||
| in++; | ||
| } | ||
| if (out_i16) { | ||
| out++; | ||
| *out = BLEND(*mask, *out, *in, tmp1); | ||
| } |
There was a problem hiding this comment.
For performance, this would be better unswitched to separate loops for the I16 case...
There was a problem hiding this comment.
the i16 case
Isn't there one case where in_i16 is true, another where out_i16 is true, and one where both are true? I don't think three loops instead of one is a very elegant solution.
There was a problem hiding this comment.
Sorry, yeah, meant cases.
Anyway, ran a quick benchmark locally (we don't seem to have one that covers paste so CodSpeed is happy here) and this makes L-L and P-P some 4 times slower, likely since the BLEND can't be vectorized anymore.
I think just splitting the loop into 2 would be enough, though: one for the "something might be 16-bit" case and the other for the common "everything is 8-bit" case.
There was a problem hiding this comment.
A commit has now been pushed for this.
Co-authored-by: Aarni Koskela <akx@iki.fi>
Resolves #10388