Skip to content

Commit

Permalink
Merge pull request #6418 from hmaarrfk/parallel_matrix_convert
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Oct 25, 2022
2 parents 7a06bc6 + 02e90e2 commit 9bbf56b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/libImaging/Matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Imaging
ImagingConvertMatrix(Imaging im, const char *mode, float m[]) {
Imaging imOut;
int x, y;
ImagingSectionCookie cookie;

/* Assume there's enough data in the buffer */
if (!im) {
Expand All @@ -33,6 +34,7 @@ ImagingConvertMatrix(Imaging im, const char *mode, float m[]) {
return NULL;
}

ImagingSectionEnter(&cookie);
for (y = 0; y < im->ysize; y++) {
UINT8 *in = (UINT8 *)im->image[y];
UINT8 *out = (UINT8 *)imOut->image[y];
Expand All @@ -43,6 +45,7 @@ ImagingConvertMatrix(Imaging im, const char *mode, float m[]) {
in += 4;
}
}
ImagingSectionLeave(&cookie);

} else if (strlen(mode) == 3 && im->bands == 3) {
imOut = ImagingNewDirty(mode, im->xsize, im->ysize);
Expand All @@ -54,6 +57,7 @@ ImagingConvertMatrix(Imaging im, const char *mode, float m[]) {
UINT8 *in = (UINT8 *)im->image[y];
UINT8 *out = (UINT8 *)imOut->image[y];

ImagingSectionEnter(&cookie);
for (x = 0; x < im->xsize; x++) {
float v0 = m[0] * in[0] + m[1] * in[1] + m[2] * in[2] + m[3] + 0.5;
float v1 = m[4] * in[0] + m[5] * in[1] + m[6] * in[2] + m[7] + 0.5;
Expand All @@ -64,6 +68,7 @@ ImagingConvertMatrix(Imaging im, const char *mode, float m[]) {
in += 4;
out += 4;
}
ImagingSectionLeave(&cookie);
}
} else {
return (Imaging)ImagingError_ModeError();
Expand Down

0 comments on commit 9bbf56b

Please sign in to comment.