Browse Source

Reduce errors & refine documentation

pull/3153/head
winscripter 1 week ago
parent
commit
315ea0fb9e
  1. 3
      src/ImageSharp/Formats/Jxl/Processing/Decoder/JxlBoxContentDecoder.cs
  2. 14
      src/ImageSharp/Formats/Jxl/Processing/Decoder/JxlDecoderCore.cs

3
src/ImageSharp/Formats/Jxl/Processing/Decoder/JxlBoxContentDecoder.cs

@ -8,7 +8,8 @@ using SixLabors.ImageSharp.Formats.Jxl.IO;
namespace SixLabors.ImageSharp.Formats.Jxl.Processing.Decoder; namespace SixLabors.ImageSharp.Formats.Jxl.Processing.Decoder;
/// <summary> /// <summary>
/// Allows decoding and decompressing box data. /// Allows decoding and decompressing box data in JPEG XL
/// container format.
/// </summary> /// </summary>
internal sealed class JxlBoxContentDecoder internal sealed class JxlBoxContentDecoder
{ {

14
src/ImageSharp/Formats/Jxl/Processing/Decoder/JxlDecoderCore.cs

@ -347,7 +347,7 @@ internal sealed class JxlDecoderCore : ImageDecoderCore, IDisposable
/// OOO jxlp payloads keyed by counter. Keys are: codestream bytes without /// OOO jxlp payloads keyed by counter. Keys are: codestream bytes without
/// 4byte header, and is_last. /// 4byte header, and is_last.
/// </summary> /// </summary>
private Dictionary<int, JxlOooEntry> jxlpOooBuffer = []; private readonly Dictionary<int, JxlOooEntry> jxlpOooBuffer = [];
private long jxlpOooBufferTotal; private long jxlpOooBufferTotal;
@ -358,14 +358,14 @@ internal sealed class JxlDecoderCore : ImageDecoderCore, IDisposable
/// <summary> /// <summary>
/// Decompresses box contents. /// Decompresses box contents.
/// </summary> /// </summary>
private JxlBoxContentDecoder? boxContentDecoder; private readonly JxlBoxContentDecoder? boxContentDecoder;
/// <summary> /// <summary>
/// Decodes JPEG XL to JPEG. /// Decodes JPEG XL to JPEG.
/// </summary> /// </summary>
private JxlToJpegDecoder? jpegDecoder; private JxlToJpegDecoder? jpegDecoder;
private JxlBoxContentDecoder? metadataDecoder; private readonly JxlBoxContentDecoder? metadataDecoder;
/// <summary> /// <summary>
/// Raw bytes for EXIF metadata. /// Raw bytes for EXIF metadata.
@ -2363,13 +2363,13 @@ internal sealed class JxlDecoderCore : ImageDecoderCore, IDisposable
if ((this.eventsWanted & Box) != 0) if ((this.eventsWanted & Box) != 0)
{ {
bool decompress = this.decompressBoxes && this.boxType == JxlBoxTypes.Brob; bool decompress = this.decompressBoxes && this.boxType == JxlBoxTypes.Brob;
this.boxContentDecoder.StartBox(decompress, this.boxContentsUnbounded, this.boxContentsSize); this.boxContentDecoder!.Initialize(decompress, this.boxContentsUnbounded, (ulong)this.boxContentsSize);
} }
if (this.storeExif == 1 || this.storeXmp == 1) if (this.storeExif == 1 || this.storeXmp == 1)
{ {
bool brob = this.boxType == JxlBoxTypes.Brob; bool brob = this.boxType == JxlBoxTypes.Brob;
this.metadataDecoder.StartBox(brob, this.boxContentsUnbounded, this.boxContentsSize); this.metadataDecoder!.Initialize(brob, this.boxContentsUnbounded, (ulong)this.boxContentsSize);
} }
if (this.boxType == JxlBoxTypes.FileType) if (this.boxType == JxlBoxTypes.FileType)
@ -2631,7 +2631,7 @@ internal sealed class JxlDecoderCore : ImageDecoderCore, IDisposable
} }
this.AdvanceInput(this.availableInput); this.AdvanceInput(this.availableInput);
return NeedMoreInput; ThrowNotEnoughData();
} }
long remaining = this.boxContentsEnd - this.filePosition; long remaining = this.boxContentsEnd - this.filePosition;
@ -2639,7 +2639,7 @@ internal sealed class JxlDecoderCore : ImageDecoderCore, IDisposable
{ {
this.basicInfoSizeHint = InitialBasicInfoSizeHint() + this.boxContentsEnd - this.filePosition; this.basicInfoSizeHint = InitialBasicInfoSizeHint() + this.boxContentsEnd - this.filePosition;
this.AdvanceInput(this.availableInput); this.AdvanceInput(this.availableInput);
return NeedMoreInput; ThrowNotEnoughData();
} }
else else
{ {

Loading…
Cancel
Save