Browse Source

minor cleanup

af/merge-core
Anton Firszov 8 years ago
parent
commit
af26343acc
  1. 2
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromCmyk.cs
  2. 2
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs
  3. 2
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromRgb.cs
  4. 2
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromYCbCrBasic.cs
  5. 2
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromYCbCrSimd.cs
  6. 2
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromYCbCrSimdAvx2.cs
  7. 2
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromYccK.cs
  8. 4
      src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.cs
  9. 2
      src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs
  10. 2
      src/ImageSharp/Formats/Jpeg/Components/GenericBlock8x8.cs
  11. 14
      tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs
  12. 6
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.MetaData.cs

2
src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromCmyk.cs

@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters
{ {
} }
public override void ConvertToRGBA(ComponentValues values, Span<Vector4> result) public override void ConvertToRgba(ComponentValues values, Span<Vector4> result)
{ {
// TODO: We can optimize a lot here with Vector<float> and SRCS.Unsafe()! // TODO: We can optimize a lot here with Vector<float> and SRCS.Unsafe()!
ReadOnlySpan<float> cVals = values.Component0; ReadOnlySpan<float> cVals = values.Component0;

2
src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromGrayScale.cs

@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters
{ {
} }
public override void ConvertToRGBA(ComponentValues values, Span<Vector4> result) public override void ConvertToRgba(ComponentValues values, Span<Vector4> result)
{ {
// TODO: We can optimize a lot here with Vector<float> and SRCS.Unsafe()! // TODO: We can optimize a lot here with Vector<float> and SRCS.Unsafe()!
ReadOnlySpan<float> yVals = values.Component0; ReadOnlySpan<float> yVals = values.Component0;

2
src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromRgb.cs

@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters
{ {
} }
public override void ConvertToRGBA(ComponentValues values, Span<Vector4> result) public override void ConvertToRgba(ComponentValues values, Span<Vector4> result)
{ {
// TODO: We can optimize a lot here with Vector<float> and SRCS.Unsafe()! // TODO: We can optimize a lot here with Vector<float> and SRCS.Unsafe()!
ReadOnlySpan<float> rVals = values.Component0; ReadOnlySpan<float> rVals = values.Component0;

2
src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromYCbCrBasic.cs

@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters
{ {
} }
public override void ConvertToRGBA(ComponentValues values, Span<Vector4> result) public override void ConvertToRgba(ComponentValues values, Span<Vector4> result)
{ {
ConvertCore(values, result); ConvertCore(values, result);
} }

2
src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromYCbCrSimd.cs

@ -19,7 +19,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters
{ {
} }
public override void ConvertToRGBA(ComponentValues values, Span<Vector4> result) public override void ConvertToRgba(ComponentValues values, Span<Vector4> result)
{ {
int remainder = result.Length % 8; int remainder = result.Length % 8;
int simdCount = result.Length - remainder; int simdCount = result.Length - remainder;

2
src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromYCbCrSimdAvx2.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters
public static bool IsAvailable => Vector.IsHardwareAccelerated && SimdUtils.IsAvx2CompatibleArchitecture; public static bool IsAvailable => Vector.IsHardwareAccelerated && SimdUtils.IsAvx2CompatibleArchitecture;
public override void ConvertToRGBA(ComponentValues values, Span<Vector4> result) public override void ConvertToRgba(ComponentValues values, Span<Vector4> result)
{ {
int remainder = result.Length % 8; int remainder = result.Length % 8;
int simdCount = result.Length - remainder; int simdCount = result.Length - remainder;

2
src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.FromYccK.cs

@ -15,7 +15,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters
{ {
} }
public override void ConvertToRGBA(ComponentValues values, Span<Vector4> result) public override void ConvertToRgba(ComponentValues values, Span<Vector4> result)
{ {
// TODO: We can optimize a lot here with Vector<float> and SRCS.Unsafe()! // TODO: We can optimize a lot here with Vector<float> and SRCS.Unsafe()!
ReadOnlySpan<float> yVals = values.Component0; ReadOnlySpan<float> yVals = values.Component0;

4
src/ImageSharp/Formats/Jpeg/Components/Decoder/ColorConverters/JpegColorConverter.cs

@ -21,7 +21,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters
/// </summary> /// </summary>
private static readonly JpegColorConverter[] Converters = private static readonly JpegColorConverter[] Converters =
{ {
GetYCbCrConverter(), new JpegColorConverter.FromYccK(), new JpegColorConverter.FromCmyk(), new JpegColorConverter.FromGrayscale(), new JpegColorConverter.FromRgb() GetYCbCrConverter(), new FromYccK(), new FromCmyk(), new FromGrayscale(), new FromRgb()
}; };
/// <summary> /// <summary>
@ -56,7 +56,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder.ColorConverters
/// </summary> /// </summary>
/// <param name="values">The input as a stack-only <see cref="ComponentValues"/> struct</param> /// <param name="values">The input as a stack-only <see cref="ComponentValues"/> struct</param>
/// <param name="result">The destination buffer of <see cref="Vector4"/> values</param> /// <param name="result">The destination buffer of <see cref="Vector4"/> values</param>
public abstract void ConvertToRGBA(ComponentValues values, Span<Vector4> result); public abstract void ConvertToRgba(ComponentValues values, Span<Vector4> result);
/// <summary> /// <summary>
/// Returns the <see cref="JpegColorConverter"/> for the YCbCr colorspace that matches the current CPU architecture. /// Returns the <see cref="JpegColorConverter"/> for the YCbCr colorspace that matches the current CPU architecture.

2
src/ImageSharp/Formats/Jpeg/Components/Decoder/JpegImagePostProcessor.cs

@ -155,7 +155,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder
int y = yy - this.PixelRowCounter; int y = yy - this.PixelRowCounter;
var values = new JpegColorConverter.ComponentValues(buffers, y); var values = new JpegColorConverter.ComponentValues(buffers, y);
this.colorConverter.ConvertToRGBA(values, this.rgbaBuffer.Span); this.colorConverter.ConvertToRgba(values, this.rgbaBuffer.Span);
Span<TPixel> destRow = destination.GetPixelRowSpan(yy); Span<TPixel> destRow = destination.GetPixelRowSpan(yy);

2
src/ImageSharp/Formats/Jpeg/Components/GenericBlock8x8.cs

@ -21,8 +21,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
{ {
public const int Size = 64; public const int Size = 64;
public const int SizeInBytes = Size * 3;
/// <summary> /// <summary>
/// FOR TESTING ONLY! /// FOR TESTING ONLY!
/// Gets or sets a <see cref="Rgb24"/> value at the given index /// Gets or sets a <see cref="Rgb24"/> value at the given index

14
tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs

@ -140,13 +140,13 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
JpegColorConverter converter = simd ? (JpegColorConverter)new JpegColorConverter.FromYCbCrSimd() : new JpegColorConverter.FromYCbCrBasic(); JpegColorConverter converter = simd ? (JpegColorConverter)new JpegColorConverter.FromYCbCrSimd() : new JpegColorConverter.FromYCbCrBasic();
// Warm up: // Warm up:
converter.ConvertToRGBA(values, result); converter.ConvertToRgba(values, result);
using (new MeasureGuard(this.Output, $"{converter.GetType().Name} x {times}")) using (new MeasureGuard(this.Output, $"{converter.GetType().Name} x {times}"))
{ {
for (int i = 0; i < times; i++) for (int i = 0; i < times; i++)
{ {
converter.ConvertToRGBA(values, result); converter.ConvertToRgba(values, result);
} }
} }
} }
@ -162,7 +162,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
JpegColorConverter.ComponentValues values = CreateRandomValues(4, inputBufferLength, seed); JpegColorConverter.ComponentValues values = CreateRandomValues(4, inputBufferLength, seed);
var result = new Vector4[resultBufferLength]; var result = new Vector4[resultBufferLength];
converter.ConvertToRGBA(values, result); converter.ConvertToRgba(values, result);
for (int i = 0; i < resultBufferLength; i++) for (int i = 0; i < resultBufferLength; i++)
{ {
@ -195,7 +195,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
JpegColorConverter.ComponentValues values = CreateRandomValues(1, inputBufferLength, seed); JpegColorConverter.ComponentValues values = CreateRandomValues(1, inputBufferLength, seed);
var result = new Vector4[resultBufferLength]; var result = new Vector4[resultBufferLength];
converter.ConvertToRGBA(values, result); converter.ConvertToRgba(values, result);
for (int i = 0; i < resultBufferLength; i++) for (int i = 0; i < resultBufferLength; i++)
{ {
@ -217,7 +217,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
JpegColorConverter.ComponentValues values = CreateRandomValues(3, inputBufferLength, seed); JpegColorConverter.ComponentValues values = CreateRandomValues(3, inputBufferLength, seed);
var result = new Vector4[resultBufferLength]; var result = new Vector4[resultBufferLength];
converter.ConvertToRGBA(values, result); converter.ConvertToRgba(values, result);
for (int i = 0; i < resultBufferLength; i++) for (int i = 0; i < resultBufferLength; i++)
{ {
@ -244,7 +244,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
JpegColorConverter.ComponentValues values = CreateRandomValues(4, inputBufferLength, seed); JpegColorConverter.ComponentValues values = CreateRandomValues(4, inputBufferLength, seed);
var result = new Vector4[resultBufferLength]; var result = new Vector4[resultBufferLength];
converter.ConvertToRGBA(values, result); converter.ConvertToRgba(values, result);
for (int i = 0; i < resultBufferLength; i++) for (int i = 0; i < resultBufferLength; i++)
{ {
@ -320,7 +320,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
JpegColorConverter.ComponentValues values = CreateRandomValues(componentCount, inputBufferLength, seed); JpegColorConverter.ComponentValues values = CreateRandomValues(componentCount, inputBufferLength, seed);
var result = new Vector4[resultBufferLength]; var result = new Vector4[resultBufferLength];
converter.ConvertToRGBA(values, result); converter.ConvertToRgba(values, result);
for (int i = 0; i < resultBufferLength; i++) for (int i = 0; i < resultBufferLength; i++)
{ {

6
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.MetaData.cs

@ -191,12 +191,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
Assert.Equal(72, imageInfo.MetaData.HorizontalResolution); Assert.Equal(72, imageInfo.MetaData.HorizontalResolution);
Assert.Equal(72, imageInfo.MetaData.VerticalResolution); Assert.Equal(72, imageInfo.MetaData.VerticalResolution);
}); });
using (Image<Rgba32> image = TestFile.Create(TestImages.Jpeg.Baseline.Jpeg420Exif).CreateImage())
{
Assert.Equal(72, image.MetaData.HorizontalResolution);
Assert.Equal(72, image.MetaData.VerticalResolution);
}
} }
} }
} }
Loading…
Cancel
Save