diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/JpegEncoderCore.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/JpegEncoderCore.cs
index d9ebd265c..ba40ef72b 100644
--- a/src/ImageSharp/Formats/Jpeg/GolangPort/JpegEncoderCore.cs
+++ b/src/ImageSharp/Formats/Jpeg/GolangPort/JpegEncoderCore.cs
@@ -7,7 +7,6 @@ using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Formats.Jpeg.Common;
using SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components;
using SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Encoder;
-using SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Utils;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.MetaData.Profiles.Exif;
using SixLabors.ImageSharp.MetaData.Profiles.Icc;
@@ -283,64 +282,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort
}
}
- ///
- /// Converts the 8x8 region of the image whose top-left corner is x,y to its YCbCr values.
- ///
- /// The pixel format.
- /// The pixel accessor.
- /// The reference to the tables instance.
- /// The x-position within the image.
- /// The y-position within the image.
- /// The luminance block.
- /// The red chroma block.
- /// The blue chroma block.
- /// Temporal provided by the caller
- private static void ToYCbCr(
- PixelAccessor pixels,
- RgbToYCbCrTables* tables,
- int x,
- int y,
- ref Block8x8F yBlock,
- ref Block8x8F cbBlock,
- ref Block8x8F crBlock,
- PixelArea rgbBytes)
- where TPixel : struct, IPixel
- {
- ref float yBlockStart = ref Unsafe.As(ref yBlock);
- ref float cbBlockStart = ref Unsafe.As(ref cbBlock);
- ref float crBlockStart = ref Unsafe.As(ref crBlock);
-
- pixels.CopyRGBBytesStretchedTo(rgbBytes, y, x);
-
- ref byte data0 = ref rgbBytes.Bytes[0];
- int dataIdx = 0;
-
- for (int j = 0; j < 8; j++)
- {
- int j8 = j * 8;
- for (int i = 0; i < 8; i++)
- {
- // Convert returned bytes into the YCbCr color space. Assume RGBA
- int r = Unsafe.Add(ref data0, dataIdx);
- int g = Unsafe.Add(ref data0, dataIdx + 1);
- int b = Unsafe.Add(ref data0, dataIdx + 2);
-
- int index = j8 + i;
-
- // RgbToYCbCrTables.Rgb2YCbCr(tables, yBlockRaw, cbBlockRaw, crBlockRaw, index, r, g, b);
- tables->ConvertPixelInto(
- r,
- g,
- b,
- ref Unsafe.Add(ref yBlockStart, index),
- ref Unsafe.Add(ref cbBlockStart, index),
- ref Unsafe.Add(ref crBlockStart, index));
-
- dataIdx += 3;
- }
- }
- }
-
///
/// Emits the least significant count of bits of bits to the bit-stream.
/// The precondition is bits
diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Utils/OrigJpegUtils.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Utils/OrigJpegUtils.cs
deleted file mode 100644
index ef52f6af3..000000000
--- a/src/ImageSharp/Formats/Jpeg/GolangPort/Utils/OrigJpegUtils.cs
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright (c) Six Labors and contributors.
-// Licensed under the Apache License, Version 2.0.
-
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using SixLabors.ImageSharp.Formats.Jpeg.Common;
-using SixLabors.ImageSharp.PixelFormats;
-
-namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Utils
-{
- ///
- /// Jpeg specific utilities and extension methods
- ///
- internal static class OrigJpegUtils
- {
- ///
- /// Stack only TPixel -> Rgb24 conversion method on 8x8 blocks.
- ///
- public static void ConvertToRgbUnsafe(ref GenericBlock8x8 source, ref GenericBlock8x8 dest)
- where TPixel : struct, IPixel
- {
- PixelOperations.Instance.ToRgb24(source.AsSpanUnsafe(), dest.AsSpanUnsafe(), 64);
- }
-
- ///
- /// Copy a region of an image into dest. De "outlier" area will be stretched out with pixels on the right and bottom of the image.
- ///
- /// The pixel type
- /// The input pixel acessor
- /// The destination
- /// Starting Y coord
- /// Starting X coord
- public static void CopyRGBBytesStretchedTo(
- this PixelAccessor pixels,
- PixelArea dest,
- int sourceY,
- int sourceX)
- where TPixel : struct, IPixel
- {
- pixels.SafeCopyTo(dest, sourceY, sourceX);
- int stretchFromX = pixels.Width - sourceX;
- int stretchFromY = pixels.Height - sourceY;
- StretchPixels(dest, stretchFromX, stretchFromY);
- }
-
- // Nothing to stretch if (fromX, fromY) is outside the area, or is at (0,0)
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static bool IsInvalidStretchStartingPosition(PixelArea area, int fromX, int fromY)
- where TPixel : struct, IPixel
- {
- return fromX <= 0 || fromY <= 0 || fromX >= area.Width || fromY >= area.Height;
- }
-
- private static void StretchPixels(PixelArea area, int fromX, int fromY)
- where TPixel : struct, IPixel
- {
- if (IsInvalidStretchStartingPosition(area, fromX, fromY))
- {
- return;
- }
-
- for (int y = 0; y < fromY; y++)
- {
- ref RGB24 ptrBase = ref GetRowStart(area, y);
-
- for (int x = fromX; x < area.Width; x++)
- {
- // Copy the left neighbour pixel to the current one
- Unsafe.Add(ref ptrBase, x) = Unsafe.Add(ref ptrBase, x - 1);
- }
- }
-
- for (int y = fromY; y < area.Height; y++)
- {
- ref RGB24 currBase = ref GetRowStart(area, y);
- ref RGB24 prevBase = ref GetRowStart(area, y - 1);
-
- for (int x = 0; x < area.Width; x++)
- {
- // Copy the top neighbour pixel to the current one
- Unsafe.Add(ref currBase, x) = Unsafe.Add(ref prevBase, x);
- }
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static ref RGB24 GetRowStart(PixelArea area, int y)
- where TPixel : struct, IPixel
- {
- return ref Unsafe.As(ref area.GetRowSpan(y).DangerousGetPinnableReference());
- }
-
- [StructLayout(LayoutKind.Sequential, Size = 3)]
- private struct RGB24
- {
- }
- }
-}
\ No newline at end of file
diff --git a/src/ImageSharp/ImageSharp.csproj b/src/ImageSharp/ImageSharp.csproj
index 8b89499ea..833b9b96d 100644
--- a/src/ImageSharp/ImageSharp.csproj
+++ b/src/ImageSharp/ImageSharp.csproj
@@ -127,4 +127,7 @@
PorterDuffFunctions.Generated.tt
+
+
+
\ No newline at end of file
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegUtilsTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegUtilsTests.cs
deleted file mode 100644
index 6fe6a9bfd..000000000
--- a/tests/ImageSharp.Tests/Formats/Jpg/JpegUtilsTests.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (c) Six Labors and contributors.
-// Licensed under the Apache License, Version 2.0.
-
-using System.Numerics;
-using SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Utils;
-using SixLabors.ImageSharp.PixelFormats;
-using Xunit;
-
-// ReSharper disable InconsistentNaming
-namespace SixLabors.ImageSharp.Tests.Formats.Jpg
-{
- public class JpegUtilsTests
- {
- public static Image CreateTestImage()
- where TPixel : struct, IPixel
- {
- var image = new Image(10, 10);
- using (PixelAccessor pixels = image.Lock())
- {
- for (int i = 0; i < 10; i++)
- {
- for (int j = 0; j < 10; j++)
- {
- var v = new Vector4(i / 10f, j / 10f, 0, 1);
-
- var color = default(TPixel);
- color.PackFromVector4(v);
-
- pixels[i, j] = color;
- }
- }
- }
-
- return image;
- }
-
- [Theory]
- [WithMemberFactory(nameof(CreateTestImage), PixelTypes.Rgba32| PixelTypes.Rgba32 | PixelTypes.Argb32)]
- public void CopyStretchedRGBTo_FromOrigo(TestImageProvider provider)
- where TPixel : struct, IPixel
- {
- using (Image src = provider.GetImage())
- using (Image dest = new Image(8,8))
- using (PixelArea area = new PixelArea(8, 8, ComponentOrder.Xyz))
- using (PixelAccessor s = src.Lock())
- using (PixelAccessor d = dest.Lock())
- {
- s.CopyRGBBytesStretchedTo(area, 0, 0);
- d.CopyFrom(area, 0, 0);
-
- Assert.Equal(s[0, 0], d[0, 0]);
- Assert.Equal(s[7, 0], d[7, 0]);
- Assert.Equal(s[0, 7], d[0, 7]);
- Assert.Equal(s[7, 7], d[7, 7]);
- }
-
- }
-
- [Theory]
- [WithMemberFactory(nameof(CreateTestImage), PixelTypes.Rgba32| PixelTypes.Rgba32 | PixelTypes.Argb32)]
- public void CopyStretchedRGBTo_WithOffset(TestImageProvider provider)
- where TPixel : struct, IPixel
- {
- using (Image src = provider.GetImage())
- using (PixelArea area = new PixelArea(8, 8, ComponentOrder.Xyz))
- using (Image dest = new Image(8, 8))
- using (PixelAccessor s = src.Lock())
- using (PixelAccessor d = dest.Lock())
- {
- s.CopyRGBBytesStretchedTo(area, 7, 6);
- d.CopyFrom(area, 0, 0);
-
- Assert.Equal(s[6, 7], d[0, 0]);
- Assert.Equal(s[6, 8], d[0, 1]);
- Assert.Equal(s[7, 8], d[1, 1]);
-
- Assert.Equal(s[6, 9], d[0, 2]);
- Assert.Equal(s[6, 9], d[0, 3]);
- Assert.Equal(s[6, 9], d[0, 7]);
-
- Assert.Equal(s[7, 9], d[1, 2]);
- Assert.Equal(s[7, 9], d[1, 3]);
- Assert.Equal(s[7, 9], d[1, 7]);
-
- Assert.Equal(s[9, 9], d[3, 2]);
- Assert.Equal(s[9, 9], d[3, 3]);
- Assert.Equal(s[9, 9], d[3, 7]);
-
- Assert.Equal(s[9, 7], d[3, 0]);
- Assert.Equal(s[9, 7], d[4, 0]);
- Assert.Equal(s[9, 7], d[7, 0]);
-
- Assert.Equal(s[9, 9], d[3, 2]);
- Assert.Equal(s[9, 9], d[4, 2]);
- Assert.Equal(s[9, 9], d[7, 2]);
-
- Assert.Equal(s[9, 9], d[4, 3]);
- Assert.Equal(s[9, 9], d[7, 7]);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.cs
index 26ec454f9..0276e1708 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/ReferenceImplementationsTests.cs
@@ -1,8 +1,6 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Utils;
-
using Xunit.Abstractions;
// ReSharper disable InconsistentNaming
diff --git a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs
index ef9a73d12..37d42eb72 100644
--- a/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs
+++ b/tests/ImageSharp.Tests/Formats/Jpg/Utils/ReferenceImplementations.LLM_FloatingPoint_DCT.cs
@@ -6,7 +6,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.Formats.Jpeg.Common;
- using SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Utils;
using Xunit.Abstractions;