From bb3acac4d2d2f8f32f7a0176b280b5354996b2c3 Mon Sep 17 00:00:00 2001 From: Ynse Hoornenborg Date: Sun, 4 Sep 2022 17:44:14 +0200 Subject: [PATCH] Remove dead code --- .../Processors/Convolution/MedianBlurProcessor{TPixel}.cs | 7 ++++--- .../Processors/Convolution/MedianRowOperation{TPixel}.cs | 4 ---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/ImageSharp/Processing/Processors/Convolution/MedianBlurProcessor{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/MedianBlurProcessor{TPixel}.cs index a44a81725..bc09d3bd8 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/MedianBlurProcessor{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/MedianBlurProcessor{TPixel}.cs @@ -30,9 +30,10 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution var interest = Rectangle.Intersect(this.SourceRectangle, source.Bounds()); - // We use a rectangle with width set to 2 * kernelSize^2 + width, to allocate a buffer big enough - // for kernel source and target bulk pixel conversion. - var operationBounds = new Rectangle(interest.X, interest.Y, (2 * kernelSize * kernelSize) + interest.Width + (kernelSize * interest.Width), interest.Height); + // We use a rectangle with width set wider, to allocate a buffer big enough + // for kernel source, channel buffers, source rows and target bulk pixel conversion. + int operationWidth = (2 * kernelSize * kernelSize) + interest.Width + (kernelSize * interest.Width); + var operationBounds = new Rectangle(interest.X, interest.Y, operationWidth, interest.Height); using var map = new KernelSamplingMap(this.Configuration.MemoryAllocator); map.BuildSamplingOffsetMap(kernelSize, kernelSize, interest, this.definition.BorderWrapModeX, this.definition.BorderWrapModeY); diff --git a/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs b/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs index 8296e064d..76987abf8 100644 --- a/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs +++ b/src/ImageSharp/Processing/Processors/Convolution/MedianRowOperation{TPixel}.cs @@ -85,7 +85,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution ref Vector4 target = ref Unsafe.Add(ref targetBase, x); for (int kY = 0; kY < state.Kernel.Rows; kY++) { - int currentYIndex = Unsafe.Add(ref sampleRowBase, kY); Span sourceRow = sourceVectorBuffer.Slice(kY * boundsWidth); ref Vector4 sourceRowBase = ref MemoryMarshal.GetReference(sourceRow); for (int kX = 0; kX < state.Kernel.Columns; kX++) @@ -98,7 +97,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution } target = this.FindMedian3(state.Kernel.Span, xChannel, yChannel, zChannel, kernelCount); - state.Kernel.Clear(); } } else @@ -111,7 +109,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution ref Vector4 target = ref Unsafe.Add(ref targetBase, x); for (int kY = 0; kY < state.Kernel.Rows; kY++) { - int currentYIndex = Unsafe.Add(ref sampleRowBase, kY); Span sourceRow = sourceVectorBuffer.Slice(kY * boundsWidth); ref Vector4 sourceRowBase = ref MemoryMarshal.GetReference(sourceRow); for (int kX = 0; kX < state.Kernel.Columns; kX++) @@ -124,7 +121,6 @@ namespace SixLabors.ImageSharp.Processing.Processors.Convolution } target = this.FindMedian4(state.Kernel.Span, xChannel, yChannel, zChannel, wChannel, kernelCount); - state.Kernel.Clear(); } }