Browse Source
Implement IEquatable<Block8x8F> and check when summing. (#848)
pull/851/head
James Jackson-South
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
32 additions and
5 deletions
-
src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs
-
src/ImageSharp/Formats/Jpeg/Components/Decoder/QualityEvaluator.cs
-
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.MetaData.cs
-
tests/ImageSharp.Tests/TestImages.cs
-
BIN
tests/Images/Input/Jpg/issues/Issue845-Incorrect-Quality99.jpg
|
|
|
@ -14,7 +14,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components |
|
|
|
/// <summary>
|
|
|
|
/// Represents a Jpeg block with <see cref="float"/> coefficients.
|
|
|
|
/// </summary>
|
|
|
|
internal partial struct Block8x8F |
|
|
|
internal partial struct Block8x8F : IEquatable<Block8x8F> |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// A number of scalar coefficients in a <see cref="Block8x8F"/>
|
|
|
|
@ -538,6 +538,27 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components |
|
|
|
Unsafe.Add(ref dRef, 7) = bottom; |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public bool Equals(Block8x8F other) |
|
|
|
{ |
|
|
|
return this.V0L == other.V0L |
|
|
|
&& this.V0R == other.V0R |
|
|
|
&& this.V1L == other.V1L |
|
|
|
&& this.V1R == other.V1R |
|
|
|
&& this.V2L == other.V2L |
|
|
|
&& this.V2R == other.V2R |
|
|
|
&& this.V3L == other.V3L |
|
|
|
&& this.V3R == other.V3R |
|
|
|
&& this.V4L == other.V4L |
|
|
|
&& this.V4R == other.V4R |
|
|
|
&& this.V5L == other.V5L |
|
|
|
&& this.V5R == other.V5R |
|
|
|
&& this.V6L == other.V6L |
|
|
|
&& this.V6R == other.V6R |
|
|
|
&& this.V7L == other.V7L |
|
|
|
&& this.V7R == other.V7R; |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
public override string ToString() |
|
|
|
{ |
|
|
|
|
|
|
|
@ -84,9 +84,13 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder |
|
|
|
for (int i = 0; i < quantizationTables.Length; i++) |
|
|
|
{ |
|
|
|
ref Block8x8F qTable = ref quantizationTables[i]; |
|
|
|
for (int j = 0; j < Block8x8F.Size; j++) |
|
|
|
|
|
|
|
if (!qTable.Equals(default)) |
|
|
|
{ |
|
|
|
sum += qTable[j]; |
|
|
|
for (int j = 0; j < Block8x8F.Size; j++) |
|
|
|
{ |
|
|
|
sum += qTable[j]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -52,8 +52,9 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg |
|
|
|
public static readonly TheoryData<string, int> QualityFiles = |
|
|
|
new TheoryData<string, int> |
|
|
|
{ |
|
|
|
{ TestImages.Jpeg.Baseline.Calliphora, 80}, |
|
|
|
{ TestImages.Jpeg.Progressive.Fb, 75 } |
|
|
|
{ TestImages.Jpeg.Baseline.Calliphora, 80 }, |
|
|
|
{ TestImages.Jpeg.Progressive.Fb, 75 }, |
|
|
|
{ TestImages.Jpeg.Issues.IncorrectQuality845, 99 } |
|
|
|
}; |
|
|
|
|
|
|
|
[Theory] |
|
|
|
|
|
|
|
@ -172,6 +172,7 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
public const string OrderedInterleavedProgressive723C = "Jpg/issues/Issue723-Ordered-Interleaved-Progressive-C.jpg"; |
|
|
|
public const string ExifGetString750Transform = "Jpg/issues/issue750-exif-tranform.jpg"; |
|
|
|
public const string ExifGetString750Load = "Jpg/issues/issue750-exif-load.jpg"; |
|
|
|
public const string IncorrectQuality845 = "Jpg/issues/Issue845-Incorrect-Quality99.jpg"; |
|
|
|
|
|
|
|
public static class Fuzz |
|
|
|
{ |
|
|
|
|
Width:
|
Height:
|
Size: 2.2 MiB
|