Browse Source

Merge remote-tracking branch 'refs/remotes/origin/master' into feature/icc

af/merge-core
James Jackson-South 9 years ago
parent
commit
1392d4a2e0
  1. 5
      src/ImageSharp/Common/Extensions/Vector4Extensions.cs
  2. 2
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs
  3. 52
      src/ImageSharp/Formats/Jpeg/Components/DCT.cs
  4. 5
      tests/ImageSharp.Benchmarks/Samplers/Resize.cs
  5. 2
      tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs

5
src/ImageSharp/Common/Extensions/Vector4Extensions.cs

@ -5,7 +5,6 @@
namespace ImageSharp
{
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using ImageSharp.PixelFormats;
@ -13,7 +12,7 @@ namespace ImageSharp
/// <summary>
/// Extension methods for the <see cref="Vector4"/> struct.
/// </summary>
public static class Vector4Extensions
internal static class Vector4Extensions
{
/// <summary>
/// Compresses a linear color signal to its sRGB equivalent.
@ -22,6 +21,7 @@ namespace ImageSharp
/// </summary>
/// <param name="linear">The <see cref="Vector4"/> whose signal to compress.</param>
/// <returns>The <see cref="Vector4"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 Compress(this Vector4 linear)
{
// TODO: Is there a faster way to do this?
@ -35,6 +35,7 @@ namespace ImageSharp
/// </summary>
/// <param name="gamma">The <see cref="Rgba32"/> whose signal to expand.</param>
/// <returns>The <see cref="Vector4"/>.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector4 Expand(this Vector4 gamma)
{
// TODO: Is there a faster way to do this?

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

@ -235,7 +235,7 @@ namespace ImageSharp.Formats.Jpg
/// </summary>
/// <param name="scaleVec">Vector to multiply by</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void MultiplyAllInplace(Vector4 scaleVec)
public void MultiplyAllInplace(float scaleVec)
{
this.V0L *= scaleVec;
this.V0R *= scaleVec;

52
src/ImageSharp/Formats/Jpeg/Components/DCT.cs

@ -15,31 +15,31 @@ namespace ImageSharp.Formats.Jpg
internal static class DCT
{
#pragma warning disable SA1310 // FieldNamesMustNotContainUnderscore
private static readonly Vector4 C_1_175876 = new Vector4(1.175876f);
private static readonly float C_1_175876 = 1.175876f;
private static readonly Vector4 C_1_961571 = new Vector4(-1.961571f);
private static readonly float C_1_961571 = -1.961571f;
private static readonly Vector4 C_0_390181 = new Vector4(-0.390181f);
private static readonly float C_0_390181 = -0.390181f;
private static readonly Vector4 C_0_899976 = new Vector4(-0.899976f);
private static readonly float C_0_899976 = -0.899976f;
private static readonly Vector4 C_2_562915 = new Vector4(-2.562915f);
private static readonly float C_2_562915 = -2.562915f;
private static readonly Vector4 C_0_298631 = new Vector4(0.298631f);
private static readonly float C_0_298631 = 0.298631f;
private static readonly Vector4 C_2_053120 = new Vector4(2.053120f);
private static readonly float C_2_053120 = 2.053120f;
private static readonly Vector4 C_3_072711 = new Vector4(3.072711f);
private static readonly float C_3_072711 = 3.072711f;
private static readonly Vector4 C_1_501321 = new Vector4(1.501321f);
private static readonly float C_1_501321 = 1.501321f;
private static readonly Vector4 C_0_541196 = new Vector4(0.541196f);
private static readonly float C_0_541196 = 0.541196f;
private static readonly Vector4 C_1_847759 = new Vector4(-1.847759f);
private static readonly float C_1_847759 = -1.847759f;
private static readonly Vector4 C_0_765367 = new Vector4(0.765367f);
private static readonly float C_0_765367 = 0.765367f;
private static readonly Vector4 C_0_125 = new Vector4(0.1250f);
private static readonly float C_0_125 = 0.1250f;
#pragma warning restore SA1310 // FieldNamesMustNotContainUnderscore
private static readonly Vector4 InvSqrt2 = new Vector4(0.707107f);
@ -216,26 +216,26 @@ namespace ImageSharp.Formats.Jpg
d.V0L = c0 + c1;
d.V4L = c0 - c1;
Vector4 w0 = new Vector4(0.541196f);
Vector4 w1 = new Vector4(1.306563f);
float w0 = 0.541196f;
float w1 = 1.306563f;
d.V2L = (w0 * c2) + (w1 * c3);
d.V6L = (w0 * c3) - (w1 * c2);
w0 = new Vector4(1.175876f);
w1 = new Vector4(0.785695f);
w0 = 1.175876f;
w1 = 0.785695f;
c3 = (w0 * t4) + (w1 * t7);
c0 = (w0 * t7) - (w1 * t4);
w0 = new Vector4(1.387040f);
w1 = new Vector4(0.275899f);
w0 = 1.387040f;
w1 = 0.275899f;
c2 = (w0 * t5) + (w1 * t6);
c1 = (w0 * t6) - (w1 * t5);
d.V3L = c0 - c2;
d.V5L = c3 - c1;
Vector4 invsqrt2 = new Vector4(0.707107f);
float invsqrt2 = 0.707107f;
c0 = (c0 + c2) * invsqrt2;
c3 = (c3 + c1) * invsqrt2;
@ -281,19 +281,19 @@ namespace ImageSharp.Formats.Jpg
d.V0R = c0 + c1;
d.V4R = c0 - c1;
Vector4 w0 = new Vector4(0.541196f);
Vector4 w1 = new Vector4(1.306563f);
float w0 = 0.541196f;
float w1 = 1.306563f;
d.V2R = (w0 * c2) + (w1 * c3);
d.V6R = (w0 * c3) - (w1 * c2);
w0 = new Vector4(1.175876f);
w1 = new Vector4(0.785695f);
w0 = 1.175876f;
w1 = 0.785695f;
c3 = (w0 * t4) + (w1 * t7);
c0 = (w0 * t7) - (w1 * t4);
w0 = new Vector4(1.387040f);
w1 = new Vector4(0.275899f);
w0 = 1.387040f;
w1 = 0.275899f;
c2 = (w0 * t5) + (w1 * t6);
c1 = (w0 * t6) - (w1 * t5);

5
tests/ImageSharp.Benchmarks/Samplers/Resize.cs

@ -14,6 +14,7 @@ namespace ImageSharp.Benchmarks
using CoreSize = ImageSharp.Size;
using CoreImage = ImageSharp.Image;
using CoreImageVector = ImageSharp.Image<PixelFormats.RgbaVector>;
public class Resize : BenchmarkBase
{
@ -50,7 +51,7 @@ namespace ImageSharp.Benchmarks
[Benchmark(Description = "ImageSharp Vector Resize")]
public CoreSize ResizeCoreVector()
{
using (CoreImage image = new CoreImage(2000, 2000))
using (CoreImageVector image = new CoreImageVector(2000, 2000))
{
image.Resize(400, 400);
return new CoreSize(image.Width, image.Height);
@ -70,7 +71,7 @@ namespace ImageSharp.Benchmarks
[Benchmark(Description = "ImageSharp Vector Compand Resize")]
public CoreSize ResizeCoreVectorCompand()
{
using (CoreImage image = new CoreImage(2000, 2000))
using (CoreImageVector image = new CoreImageVector(2000, 2000))
{
image.Resize(400, 400, true);
return new CoreSize(image.Width, image.Height);

2
tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs

@ -309,7 +309,7 @@ namespace ImageSharp.Tests
float[] data = Create8x8FloatData();
Block8x8F block = new Block8x8F();
block.LoadFrom(data);
block.MultiplyAllInplace(new Vector4(5, 5, 5, 5));
block.MultiplyAllInplace(5);
int stride = 256;
int height = 42;

Loading…
Cancel
Save