Skip to content

Commit 4a6b51b

Browse files
Rename
1 parent 1102eb5 commit 4a6b51b

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

src/ImageSharp/Formats/DecoderOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public sealed class DecoderOptions
5858
/// <summary>
5959
/// Gets the segment error handling strategy to use during decoding.
6060
/// </summary>
61-
public SegmentErrorHandling SegmentErrorHandling { get; init; } = SegmentErrorHandling.IgnoreNonCritical;
61+
public SegmentIntegrityHandling SegmentIntegrityHandling { get; init; } = SegmentIntegrityHandling.IgnoreNonCritical;
6262

6363
internal void SetConfiguration(Configuration configuration) => this.configuration = configuration;
6464
}

src/ImageSharp/Formats/Png/PngChunk.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ public PngChunk(int length, PngChunkType type, IMemoryOwner<byte> data = null)
4242
/// Gets a value indicating whether the given chunk is critical to decoding
4343
/// </summary>
4444
/// <param name="handling">The segment handling behavior.</param>
45-
public bool IsCritical(SegmentErrorHandling handling)
45+
public bool IsCritical(SegmentIntegrityHandling handling)
4646
=> handling switch
4747
{
48-
SegmentErrorHandling.IgnoreNone => true,
49-
SegmentErrorHandling.IgnoreNonCritical => this.Type is PngChunkType.Header or PngChunkType.Palette or PngChunkType.Data or PngChunkType.FrameData,
50-
SegmentErrorHandling.IgnoreData => this.Type is PngChunkType.Header or PngChunkType.Palette,
48+
SegmentIntegrityHandling.IgnoreNone => true,
49+
SegmentIntegrityHandling.IgnoreNonCritical => this.Type is PngChunkType.Header or PngChunkType.Palette or PngChunkType.Data or PngChunkType.FrameData,
50+
SegmentIntegrityHandling.IgnoreData => this.Type is PngChunkType.Header or PngChunkType.Palette,
5151
_ => false,
5252
};
5353
}

src/ImageSharp/Formats/Png/PngDecoderCore.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore
119119
/// <summary>
120120
/// How to handle CRC errors.
121121
/// </summary>
122-
private readonly SegmentErrorHandling segmentErrorHandling;
122+
private readonly SegmentIntegrityHandling segmentIntegrityHandling;
123123

124124
/// <summary>
125125
/// A reusable Crc32 hashing instance.
@@ -142,7 +142,7 @@ public PngDecoderCore(PngDecoderOptions options)
142142
this.maxFrames = options.GeneralOptions.MaxFrames;
143143
this.skipMetadata = options.GeneralOptions.SkipMetadata;
144144
this.memoryAllocator = this.configuration.MemoryAllocator;
145-
this.segmentErrorHandling = options.GeneralOptions.SegmentErrorHandling;
145+
this.segmentIntegrityHandling = options.GeneralOptions.SegmentIntegrityHandling;
146146
this.maxUncompressedLength = options.MaxUncompressedAncillaryChunkSizeBytes;
147147
}
148148

@@ -154,7 +154,7 @@ internal PngDecoderCore(PngDecoderOptions options, bool colorMetadataOnly)
154154
this.skipMetadata = true;
155155
this.configuration = options.GeneralOptions.Configuration;
156156
this.memoryAllocator = this.configuration.MemoryAllocator;
157-
this.segmentErrorHandling = options.GeneralOptions.SegmentErrorHandling;
157+
this.segmentIntegrityHandling = options.GeneralOptions.SegmentIntegrityHandling;
158158
this.maxUncompressedLength = options.MaxUncompressedAncillaryChunkSizeBytes;
159159
}
160160

@@ -833,7 +833,7 @@ private void DecodePixelData<TPixel>(
833833
break;
834834

835835
default:
836-
if (this.segmentErrorHandling is SegmentErrorHandling.IgnoreData or SegmentErrorHandling.IgnoreAll)
836+
if (this.segmentIntegrityHandling is SegmentIntegrityHandling.IgnoreData or SegmentIntegrityHandling.IgnoreAll)
837837
{
838838
goto EXIT;
839839
}
@@ -939,7 +939,7 @@ private void DecodeInterlacedPixelData<TPixel>(
939939
break;
940940

941941
default:
942-
if (this.segmentErrorHandling is SegmentErrorHandling.IgnoreData or SegmentErrorHandling.IgnoreAll)
942+
if (this.segmentIntegrityHandling is SegmentIntegrityHandling.IgnoreData or SegmentIntegrityHandling.IgnoreAll)
943943
{
944944
goto EXIT;
945945
}
@@ -1927,7 +1927,7 @@ private bool TryReadChunk(Span<byte> buffer, out PngChunk chunk)
19271927
private void ValidateChunk(in PngChunk chunk, Span<byte> buffer)
19281928
{
19291929
uint inputCrc = this.ReadChunkCrc(buffer);
1930-
if (chunk.IsCritical(this.segmentErrorHandling))
1930+
if (chunk.IsCritical(this.segmentIntegrityHandling))
19311931
{
19321932
Span<byte> chunkType = stackalloc byte[4];
19331933
BinaryPrimitives.WriteUInt32BigEndian(chunkType, (uint)chunk.Type);

src/ImageSharp/Formats/SegmentErrorHandling.cs renamed to src/ImageSharp/Formats/SegmentIntegrityHandling.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace SixLabors.ImageSharp.Formats;
66
/// <summary>
77
/// Specifies how to handle validation of errors in different segments of encoded image files.
88
/// </summary>
9-
public enum SegmentErrorHandling
9+
public enum SegmentIntegrityHandling
1010
{
1111
/// <summary>
1212
/// Do not ignore any errors.

tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ public void Identify_IgnoreCrcErrors(string imagePath, int expectedPixelSize)
389389
TestFile testFile = TestFile.Create(imagePath);
390390
using MemoryStream stream = new(testFile.Bytes, false);
391391

392-
ImageInfo imageInfo = Image.Identify(new DecoderOptions() { SegmentErrorHandling = SegmentErrorHandling.IgnoreData }, stream);
392+
ImageInfo imageInfo = Image.Identify(new DecoderOptions() { SegmentIntegrityHandling = SegmentIntegrityHandling.IgnoreData }, stream);
393393

394394
Assert.NotNull(imageInfo);
395395
Assert.Equal(expectedPixelSize, imageInfo.PixelType.BitsPerPixel);
@@ -493,7 +493,7 @@ public void Decode_InvalidDataChunkCrc_ThrowsException<TPixel>(TestImageProvider
493493
public void Decode_InvalidDataChunkCrc_IgnoreCrcErrors<TPixel>(TestImageProvider<TPixel> provider, bool compare)
494494
where TPixel : unmanaged, IPixel<TPixel>
495495
{
496-
using Image<TPixel> image = provider.GetImage(PngDecoder.Instance, new DecoderOptions() { SegmentErrorHandling = SegmentErrorHandling.IgnoreData });
496+
using Image<TPixel> image = provider.GetImage(PngDecoder.Instance, new DecoderOptions() { SegmentIntegrityHandling = SegmentIntegrityHandling.IgnoreData });
497497

498498
image.DebugSave(provider);
499499
if (compare)
@@ -674,7 +674,7 @@ static void RunTest(string providerDump, string nonContiguousBuffersStr)
674674
public void Binary_PrematureEof()
675675
{
676676
PngDecoder decoder = PngDecoder.Instance;
677-
PngDecoderOptions options = new() { GeneralOptions = new() { SegmentErrorHandling = SegmentErrorHandling.IgnoreData } };
677+
PngDecoderOptions options = new() { GeneralOptions = new() { SegmentIntegrityHandling = SegmentIntegrityHandling.IgnoreData } };
678678
using EofHitCounter eofHitCounter = EofHitCounter.RunDecoder(TestImages.Png.Bad.FlagOfGermany0000016446, decoder, options);
679679

680680
// TODO: Try to reduce this to 1.

0 commit comments

Comments
 (0)