Browse Source

Add JPEG parser

pull/3153/head
winscripter 4 weeks ago
parent
commit
133116741e
  1. 14
      src/ImageSharp/Formats/Jxl/IO/Jpeg/JpegDebug.cs
  2. 4
      src/ImageSharp/Formats/Jxl/IO/Jpeg/JpegHuffmanDecoder.cs
  3. 13
      src/ImageSharp/Formats/Jxl/IO/Jpeg/JpegReadMode.cs
  4. 1497
      src/ImageSharp/Formats/Jxl/IO/Jpeg/JpegReader.cs
  5. 14
      src/ImageSharp/Formats/Jxl/IO/Metadata/JxlExtraChannelInfo.cs

14
src/ImageSharp/Formats/Jxl/IO/Jpeg/JpegDebug.cs

@ -0,0 +1,14 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System.Diagnostics;
namespace SixLabors.ImageSharp.Formats.Jxl.IO.Jpeg;
internal static class JpegDebug
{
[Conditional("DEBUG")]
public static void LogWarning(string message) =>
// TODO: do we allow Debug.WriteLine in this codebase?
Debug.WriteLine($"⚠️ JPEG XL [JPEG parser]: {message}");
}

4
src/ImageSharp/Formats/Jxl/IO/Jpeg/JpegHuffmanDecoder.cs

@ -8,8 +8,8 @@ namespace SixLabors.ImageSharp.Formats.Jxl.IO.Jpeg;
/// </summary>
internal static class JpegHuffmanDecoder
{
private const int RootTableBits = 8;
private const int LookupSize = 8;
public const int RootTableBits = 8;
public const int LookupSize = 8;
private static int NextTableBitSize(Span<int> count, int length)
{

13
src/ImageSharp/Formats/Jxl/IO/Jpeg/JpegReadMode.cs

@ -0,0 +1,13 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Formats.Jxl.IO.Jpeg;
internal enum JpegReadMode : byte
{
ReadHeader,
ReadTables,
ReadEverything
}

1497
src/ImageSharp/Formats/Jxl/IO/Jpeg/JpegReader.cs

File diff suppressed because it is too large

14
src/ImageSharp/Formats/Jxl/IO/Metadata/JxlExtraChannelInfo.cs

@ -23,5 +23,17 @@ internal sealed class JxlExtraChannelInfo : IJxlFields
public int CfaChannel { get; set; }
public bool Visit(JxlVisitor visitor) => throw new NotImplementedException();
public bool Visit(JxlVisitor visitor)
{
if (visitor.AllDefault(this, ref this.allDefault))
{
visitor.SetDefault(this);
return true;
}
if (!visitor.Enum(JxlExtraChannel.Alpha, ref this.Type))
{
return false;
}
}
}

Loading…
Cancel
Save