Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down Expand Up @@ -538,6 +538,27 @@ public void LoadFromInt16ExtendedAvx2(ref Block8x8 source)
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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ public static int EstimateQuality(Block8x8F[] quantizationTables)
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];
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ public partial class JpegDecoderTests
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]
Expand Down
1 change: 1 addition & 0 deletions tests/ImageSharp.Tests/TestImages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public static class Issues
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
{
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.