Skip to content

Commit ae27c04

Browse files
committed
Use Interlocked.Increment(ref Unsafe.Add(ref histogramBase, luminance));
1 parent 5c8f66c commit ae27c04

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ImageSharp/Processing/Processors/Normalization/GlobalHistogramEqualizationProcessor{TPixel}.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public GrayscaleLevelsRowOperation(
115115
#endif
116116
public void Invoke(int y)
117117
{
118+
ref int histogramBase = ref MemoryMarshal.GetReference(this.histogramBuffer.GetSpan());
118119
ref TPixel pixelBase = ref MemoryMarshal.GetReference(this.source.GetPixelRowSpan(y));
119120
int levels = this.luminanceLevels;
120121

@@ -123,8 +124,7 @@ public void Invoke(int y)
123124
// TODO: We should bulk convert here.
124125
var vector = Unsafe.Add(ref pixelBase, x).ToVector4();
125126
int luminance = ImageMaths.GetBT709Luminance(ref vector, levels);
126-
ref int histogramAtLuminance = ref MemoryMarshal.GetReference(this.histogramBuffer.Slice(luminance));
127-
Interlocked.Increment(ref histogramAtLuminance);
127+
Interlocked.Increment(ref Unsafe.Add(ref histogramBase, luminance));
128128
}
129129
}
130130
}

0 commit comments

Comments
 (0)