diff --git a/src/ImageSharp/Formats/Jxl/Processing/Decoder/JxlBoxContentDecoder.cs b/src/ImageSharp/Formats/Jxl/Processing/Decoder/JxlBoxContentDecoder.cs
index 7621102ef..5d1beddf3 100644
--- a/src/ImageSharp/Formats/Jxl/Processing/Decoder/JxlBoxContentDecoder.cs
+++ b/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;
///
-/// Allows decoding and decompressing box data.
+/// Allows decoding and decompressing box data in JPEG XL
+/// container format.
///
internal sealed class JxlBoxContentDecoder
{
diff --git a/src/ImageSharp/Formats/Jxl/Processing/Decoder/JxlDecoderCore.cs b/src/ImageSharp/Formats/Jxl/Processing/Decoder/JxlDecoderCore.cs
index 7ca3ace0e..92c0962c8 100644
--- a/src/ImageSharp/Formats/Jxl/Processing/Decoder/JxlDecoderCore.cs
+++ b/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
/// 4byte header, and is_last.
///
- private Dictionary jxlpOooBuffer = [];
+ private readonly Dictionary jxlpOooBuffer = [];
private long jxlpOooBufferTotal;
@@ -358,14 +358,14 @@ internal sealed class JxlDecoderCore : ImageDecoderCore, IDisposable
///
/// Decompresses box contents.
///
- private JxlBoxContentDecoder? boxContentDecoder;
+ private readonly JxlBoxContentDecoder? boxContentDecoder;
///
/// Decodes JPEG XL to JPEG.
///
private JxlToJpegDecoder? jpegDecoder;
- private JxlBoxContentDecoder? metadataDecoder;
+ private readonly JxlBoxContentDecoder? metadataDecoder;
///
/// Raw bytes for EXIF metadata.
@@ -2363,13 +2363,13 @@ internal sealed class JxlDecoderCore : ImageDecoderCore, IDisposable
if ((this.eventsWanted & Box) != 0)
{
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)
{
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)
@@ -2631,7 +2631,7 @@ internal sealed class JxlDecoderCore : ImageDecoderCore, IDisposable
}
this.AdvanceInput(this.availableInput);
- return NeedMoreInput;
+ ThrowNotEnoughData();
}
long remaining = this.boxContentsEnd - this.filePosition;
@@ -2639,7 +2639,7 @@ internal sealed class JxlDecoderCore : ImageDecoderCore, IDisposable
{
this.basicInfoSizeHint = InitialBasicInfoSizeHint() + this.boxContentsEnd - this.filePosition;
this.AdvanceInput(this.availableInput);
- return NeedMoreInput;
+ ThrowNotEnoughData();
}
else
{