Browse Source

Merge pull request #201 from Drawaes/master

Reduce register pressure
af/merge-core
James Jackson-South 9 years ago
committed by GitHub
parent
commit
12ed8b4bc1
  1. 25
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs
  2. 52
      src/ImageSharp/Formats/Jpeg/Components/DCT.cs

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

@ -255,6 +255,31 @@ namespace ImageSharp.Formats.Jpg
this.V7R *= scaleVec;
}
/// <summary>
/// Multiply all elements of the block.
/// </summary>
/// <param name="scaleVec">Vector to multiply by</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void MultiplyAllInplace(float scaleVec)
{
this.V0L *= scaleVec;
this.V0R *= scaleVec;
this.V1L *= scaleVec;
this.V1R *= scaleVec;
this.V2L *= scaleVec;
this.V2R *= scaleVec;
this.V3L *= scaleVec;
this.V3R *= scaleVec;
this.V4L *= scaleVec;
this.V4R *= scaleVec;
this.V5L *= scaleVec;
this.V5R *= scaleVec;
this.V6L *= scaleVec;
this.V6R *= scaleVec;
this.V7L *= scaleVec;
this.V7R *= scaleVec;
}
/// <summary>
/// Adds a vector to all elements of the block.
/// </summary>

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);

Loading…
Cancel
Save