Browse Source

Cleanup Compressor/Decompressors: Remove not needed fields

pull/3096/head
Brian Popow 2 months ago
parent
commit
f212af812d
  1. 11
      src/ImageSharp/Formats/Exr/Compression/Compressors/NoneExrCompressor.cs
  2. 11
      src/ImageSharp/Formats/Exr/Compression/Compressors/ZipExrCompressor.cs
  3. 13
      src/ImageSharp/Formats/Exr/Compression/Decompressors/B44ExrCompression.cs
  4. 6
      src/ImageSharp/Formats/Exr/Compression/Decompressors/NoneExrCompression.cs
  5. 6
      src/ImageSharp/Formats/Exr/Compression/Decompressors/RunLengthExrCompression.cs
  6. 6
      src/ImageSharp/Formats/Exr/Compression/Decompressors/ZipExrCompression.cs
  7. 5
      src/ImageSharp/Formats/Exr/Compression/ExrBaseCompression.cs
  8. 4
      src/ImageSharp/Formats/Exr/Compression/ExrBaseDecompressor.cs
  9. 11
      src/ImageSharp/Formats/Exr/Compression/ExrCompressorFactory.cs
  10. 12
      src/ImageSharp/Formats/Exr/Compression/ExrDecompressorFactory.cs
  11. 17
      src/ImageSharp/Formats/Exr/ExrBaseCompressor.cs
  12. 4
      src/ImageSharp/Formats/Exr/ExrDecoderCore.cs
  13. 20
      src/ImageSharp/Formats/Exr/ExrEncoderCore.cs

11
src/ImageSharp/Formats/Exr/Compression/Compressors/NoneExrCompressor.cs

@ -8,8 +8,8 @@ namespace SixLabors.ImageSharp.Formats.Exr.Compression.Compressors;
internal class NoneExrCompressor : ExrBaseCompressor internal class NoneExrCompressor : ExrBaseCompressor
{ {
public NoneExrCompressor(Stream output, MemoryAllocator allocator, uint bytesPerBlock) public NoneExrCompressor(Stream output, MemoryAllocator allocator, uint bytesPerBlock, uint bytesPerRow)
: base(output, allocator, bytesPerBlock) : base(output, allocator, bytesPerBlock, bytesPerRow)
{ {
} }
@ -17,12 +17,7 @@ internal class NoneExrCompressor : ExrBaseCompressor
public override ExrCompression Method => ExrCompression.Zip; public override ExrCompression Method => ExrCompression.Zip;
/// <inheritdoc/> /// <inheritdoc/>
public override void Initialize(int rowsPerBlock) public override uint CompressRowBlock(Span<byte> rows, int rowCount)
{
}
/// <inheritdoc/>
public override uint CompressRowBlock(Span<byte> rows, int height)
{ {
this.Output.Write(rows); this.Output.Write(rows);
return (uint)rows.Length; return (uint)rows.Length;

11
src/ImageSharp/Formats/Exr/Compression/Compressors/ZipExrCompressor.cs

@ -15,8 +15,8 @@ internal class ZipExrCompressor : ExrBaseCompressor
private readonly System.Buffers.IMemoryOwner<byte> buffer; private readonly System.Buffers.IMemoryOwner<byte> buffer;
public ZipExrCompressor(Stream output, MemoryAllocator allocator, uint bytesPerBlock, DeflateCompressionLevel compressionLevel) public ZipExrCompressor(Stream output, MemoryAllocator allocator, uint bytesPerBlock, uint bytesPerRow, DeflateCompressionLevel compressionLevel)
: base(output, allocator, bytesPerBlock) : base(output, allocator, bytesPerBlock, bytesPerRow)
{ {
this.compressionLevel = compressionLevel; this.compressionLevel = compressionLevel;
this.buffer = allocator.Allocate<byte>((int)bytesPerBlock); this.buffer = allocator.Allocate<byte>((int)bytesPerBlock);
@ -26,12 +26,7 @@ internal class ZipExrCompressor : ExrBaseCompressor
public override ExrCompression Method => ExrCompression.Zip; public override ExrCompression Method => ExrCompression.Zip;
/// <inheritdoc/> /// <inheritdoc/>
public override void Initialize(int rowsPerBlock) public override uint CompressRowBlock(Span<byte> rows, int rowCount)
{
}
/// <inheritdoc/>
public override uint CompressRowBlock(Span<byte> rows, int height)
{ {
// Re-oder pixel values. // Re-oder pixel values.
int n = rows.Length; int n = rows.Length;

13
src/ImageSharp/Formats/Exr/Compression/Decompressors/B44ExrCompression.cs

@ -12,28 +12,26 @@ internal class B44ExrCompression : ExrBaseDecompressor
{ {
private readonly int width; private readonly int width;
private readonly int height;
private readonly uint rowsPerBlock; private readonly uint rowsPerBlock;
private readonly int channelCount; private readonly int channelCount;
private byte[] scratch = new byte[14]; private readonly byte[] scratch = new byte[14];
private ushort[] s = new ushort[16]; private ushort[] s = new ushort[16];
private IMemoryOwner<ushort> tmpBuffer; private readonly IMemoryOwner<ushort> tmpBuffer;
public B44ExrCompression(MemoryAllocator allocator, uint bytesPerBlock, int width, int height, uint rowsPerBlock, int channelCount) public B44ExrCompression(MemoryAllocator allocator, uint bytesPerBlock, uint bytesPerRow, uint rowsPerBlock, int width, int channelCount)
: base(allocator, bytesPerBlock) : base(allocator, bytesPerBlock, bytesPerRow)
{ {
this.width = width; this.width = width;
this.height = height;
this.rowsPerBlock = rowsPerBlock; this.rowsPerBlock = rowsPerBlock;
this.channelCount = channelCount; this.channelCount = channelCount;
this.tmpBuffer = allocator.Allocate<ushort>((int)(width * rowsPerBlock * channelCount)); this.tmpBuffer = allocator.Allocate<ushort>((int)(width * rowsPerBlock * channelCount));
} }
/// <inheritdoc/>
public override void Decompress(BufferedReadStream stream, uint compressedBytes, Span<byte> buffer) public override void Decompress(BufferedReadStream stream, uint compressedBytes, Span<byte> buffer)
{ {
Span<ushort> outputBuffer = MemoryMarshal.Cast<byte, ushort>(buffer); Span<ushort> outputBuffer = MemoryMarshal.Cast<byte, ushort>(buffer);
@ -187,5 +185,6 @@ internal class B44ExrCompression : ExrBaseDecompressor
} }
} }
/// <inheritdoc/>
protected override void Dispose(bool disposing) => this.tmpBuffer.Dispose(); protected override void Dispose(bool disposing) => this.tmpBuffer.Dispose();
} }

6
src/ImageSharp/Formats/Exr/Compression/Decompressors/NoneExrCompression.cs

@ -8,14 +8,16 @@ namespace SixLabors.ImageSharp.Formats.Exr.Compression.Decompressors;
internal class NoneExrCompression : ExrBaseDecompressor internal class NoneExrCompression : ExrBaseDecompressor
{ {
public NoneExrCompression(MemoryAllocator allocator, uint bytesPerBlock) public NoneExrCompression(MemoryAllocator allocator, uint bytesPerBlock, uint bytesPerRow)
: base(allocator, bytesPerBlock) : base(allocator, bytesPerBlock, bytesPerRow)
{ {
} }
/// <inheritdoc/>
public override void Decompress(BufferedReadStream stream, uint compressedBytes, Span<byte> buffer) public override void Decompress(BufferedReadStream stream, uint compressedBytes, Span<byte> buffer)
=> stream.Read(buffer, 0, Math.Min(buffer.Length, (int)this.BytesPerBlock)); => stream.Read(buffer, 0, Math.Min(buffer.Length, (int)this.BytesPerBlock));
/// <inheritdoc/>
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
} }

6
src/ImageSharp/Formats/Exr/Compression/Decompressors/RunLengthExrCompression.cs

@ -13,9 +13,10 @@ internal class RunLengthExrCompression : ExrBaseDecompressor
private readonly ushort[] s = new ushort[16]; private readonly ushort[] s = new ushort[16];
public RunLengthExrCompression(MemoryAllocator allocator, uint uncompressedBytes) public RunLengthExrCompression(MemoryAllocator allocator, uint bytesPerBlock, uint bytesPerRow)
: base(allocator, uncompressedBytes) => this.tmpBuffer = allocator.Allocate<byte>((int)uncompressedBytes); : base(allocator, bytesPerBlock, bytesPerRow) => this.tmpBuffer = allocator.Allocate<byte>((int)bytesPerBlock);
/// <inheritdoc/>
public override void Decompress(BufferedReadStream stream, uint compressedBytes, Span<byte> buffer) public override void Decompress(BufferedReadStream stream, uint compressedBytes, Span<byte> buffer)
{ {
Span<byte> uncompressed = this.tmpBuffer.GetSpan(); Span<byte> uncompressed = this.tmpBuffer.GetSpan();
@ -78,5 +79,6 @@ internal class RunLengthExrCompression : ExrBaseDecompressor
return (byte)nextByte; return (byte)nextByte;
} }
/// <inheritdoc/>
protected override void Dispose(bool disposing) => this.tmpBuffer.Dispose(); protected override void Dispose(bool disposing) => this.tmpBuffer.Dispose();
} }

6
src/ImageSharp/Formats/Exr/Compression/Decompressors/ZipExrCompression.cs

@ -13,9 +13,10 @@ internal class ZipExrCompression : ExrBaseDecompressor
{ {
private readonly IMemoryOwner<byte> tmpBuffer; private readonly IMemoryOwner<byte> tmpBuffer;
public ZipExrCompression(MemoryAllocator allocator, uint bytesPerBlock) public ZipExrCompression(MemoryAllocator allocator, uint bytesPerBlock, uint bytesPerRow)
: base(allocator, bytesPerBlock) => this.tmpBuffer = allocator.Allocate<byte>((int)bytesPerBlock); : base(allocator, bytesPerBlock, bytesPerRow) => this.tmpBuffer = allocator.Allocate<byte>((int)bytesPerBlock);
/// <inheritdoc/>
public override void Decompress(BufferedReadStream stream, uint compressedBytes, Span<byte> buffer) public override void Decompress(BufferedReadStream stream, uint compressedBytes, Span<byte> buffer)
{ {
Span<byte> uncompressed = this.tmpBuffer.GetSpan(); Span<byte> uncompressed = this.tmpBuffer.GetSpan();
@ -52,5 +53,6 @@ internal class ZipExrCompression : ExrBaseDecompressor
Interleave(uncompressed, (uint)totalRead, buffer); Interleave(uncompressed, (uint)totalRead, buffer);
} }
/// <inheritdoc/>
protected override void Dispose(bool disposing) => this.tmpBuffer.Dispose(); protected override void Dispose(bool disposing) => this.tmpBuffer.Dispose();
} }

5
src/ImageSharp/Formats/Exr/Compression/ExrBaseCompression.cs

@ -9,10 +9,11 @@ internal abstract class ExrBaseCompression : IDisposable
{ {
private bool isDisposed; private bool isDisposed;
protected ExrBaseCompression(MemoryAllocator allocator, uint bytesPerBlock) protected ExrBaseCompression(MemoryAllocator allocator, uint bytesPerBlock, uint bytesPerRow)
{ {
this.Allocator = allocator; this.Allocator = allocator;
this.BytesPerBlock = bytesPerBlock; this.BytesPerBlock = bytesPerBlock;
this.BytesPerRow = bytesPerRow;
} }
/// <summary> /// <summary>
@ -28,7 +29,7 @@ internal abstract class ExrBaseCompression : IDisposable
/// <summary> /// <summary>
/// Gets the bytes per row. /// Gets the bytes per row.
/// </summary> /// </summary>
public int BytesPerRow { get; } public uint BytesPerRow { get; }
/// <summary> /// <summary>
/// Gets the uncompressed bytes per block. /// Gets the uncompressed bytes per block.

4
src/ImageSharp/Formats/Exr/Compression/ExrBaseDecompressor.cs

@ -8,8 +8,8 @@ namespace SixLabors.ImageSharp.Formats.Exr.Compression;
internal abstract class ExrBaseDecompressor : ExrBaseCompression internal abstract class ExrBaseDecompressor : ExrBaseCompression
{ {
protected ExrBaseDecompressor(MemoryAllocator allocator, uint bytesPerBlock) protected ExrBaseDecompressor(MemoryAllocator allocator, uint bytesPerBlock, uint bytesPerRow)
: base(allocator, bytesPerBlock) : base(allocator, bytesPerBlock, bytesPerRow)
{ {
} }

11
src/ImageSharp/Formats/Exr/Compression/ExrCompressorFactory.cs

@ -14,19 +14,18 @@ internal static class ExrCompressorFactory
ExrCompression method, ExrCompression method,
MemoryAllocator allocator, MemoryAllocator allocator,
Stream output, Stream output,
int width,
int height,
uint bytesPerBlock, uint bytesPerBlock,
uint rowsPerBlock, uint bytesPerRow,
int channelCount,
DeflateCompressionLevel compressionLevel = DeflateCompressionLevel.DefaultCompression) DeflateCompressionLevel compressionLevel = DeflateCompressionLevel.DefaultCompression)
{ {
switch (method) switch (method)
{ {
case ExrCompression.None: case ExrCompression.None:
return new NoneExrCompressor(output, allocator, bytesPerBlock); return new NoneExrCompressor(output, allocator, bytesPerBlock, bytesPerRow);
case ExrCompression.Zips: case ExrCompression.Zips:
return new ZipExrCompressor(output, allocator, bytesPerBlock, compressionLevel); return new ZipExrCompressor(output, allocator, bytesPerBlock, bytesPerRow, compressionLevel);
case ExrCompression.Zip:
return new ZipExrCompressor(output, allocator, bytesPerBlock, bytesPerRow, compressionLevel);
default: default:
throw ExrThrowHelper.NotSupportedCompressor(method.ToString()); throw ExrThrowHelper.NotSupportedCompressor(method.ToString());

12
src/ImageSharp/Formats/Exr/Compression/ExrDecompressorFactory.cs

@ -13,23 +13,23 @@ internal static class ExrDecompressorFactory
ExrCompression method, ExrCompression method,
MemoryAllocator memoryAllocator, MemoryAllocator memoryAllocator,
int width, int width,
int height,
uint bytesPerBlock, uint bytesPerBlock,
uint bytesPerRow,
uint rowsPerBlock, uint rowsPerBlock,
int channelCount) int channelCount)
{ {
switch (method) switch (method)
{ {
case ExrCompression.None: case ExrCompression.None:
return new NoneExrCompression(memoryAllocator, bytesPerBlock); return new NoneExrCompression(memoryAllocator, bytesPerBlock, bytesPerRow);
case ExrCompression.Zips: case ExrCompression.Zips:
return new ZipExrCompression(memoryAllocator, bytesPerBlock); return new ZipExrCompression(memoryAllocator, bytesPerBlock, bytesPerRow);
case ExrCompression.Zip: case ExrCompression.Zip:
return new ZipExrCompression(memoryAllocator, bytesPerBlock); return new ZipExrCompression(memoryAllocator, bytesPerBlock, bytesPerRow);
case ExrCompression.RunLengthEncoded: case ExrCompression.RunLengthEncoded:
return new RunLengthExrCompression(memoryAllocator, bytesPerBlock); return new RunLengthExrCompression(memoryAllocator, bytesPerBlock, bytesPerRow);
case ExrCompression.B44: case ExrCompression.B44:
return new B44ExrCompression(memoryAllocator, bytesPerBlock, width, height, rowsPerBlock, channelCount); return new B44ExrCompression(memoryAllocator, bytesPerBlock, bytesPerRow, rowsPerBlock, width, channelCount);
default: default:
throw ExrThrowHelper.NotSupportedDecompressor(nameof(method)); throw ExrThrowHelper.NotSupportedDecompressor(nameof(method));
} }

17
src/ImageSharp/Formats/Exr/ExrBaseCompressor.cs

@ -13,9 +13,10 @@ internal abstract class ExrBaseCompressor : ExrBaseCompression
/// </summary> /// </summary>
/// <param name="output">The output stream to write the compressed image to.</param> /// <param name="output">The output stream to write the compressed image to.</param>
/// <param name="allocator">The memory allocator.</param> /// <param name="allocator">The memory allocator.</param>
/// <param name="bytesPerBlock">Bytes per block.</param> /// <param name="bytesPerBlock">Bytes per row block.</param>
protected ExrBaseCompressor(Stream output, MemoryAllocator allocator, uint bytesPerBlock) /// <param name="bytesPerRow">Bytes per pixel row.</param>
: base(allocator, bytesPerBlock) protected ExrBaseCompressor(Stream output, MemoryAllocator allocator, uint bytesPerBlock, uint bytesPerRow)
: base(allocator, bytesPerBlock, bytesPerRow)
=> this.Output = output; => this.Output = output;
/// <summary> /// <summary>
@ -28,17 +29,11 @@ internal abstract class ExrBaseCompressor : ExrBaseCompression
/// </summary> /// </summary>
public Stream Output { get; } public Stream Output { get; }
/// <summary>
/// Does any initialization required for the compression.
/// </summary>
/// <param name="rowsPerBlock">The number of rows per block.</param>
public abstract void Initialize(int rowsPerBlock);
/// <summary> /// <summary>
/// Compresses a block of rows of the image. /// Compresses a block of rows of the image.
/// </summary> /// </summary>
/// <param name="rows">Image rows to compress.</param> /// <param name="rows">Image rows to compress.</param>
/// <param name="height">Image height.</param> /// <param name="rowCount">The number of rows to compress.</param>
/// <returns>Number of bytes of of the compressed data.</returns> /// <returns>Number of bytes of of the compressed data.</returns>
public abstract uint CompressRowBlock(Span<byte> rows, int height); public abstract uint CompressRowBlock(Span<byte> rows, int rowCount);
} }

4
src/ImageSharp/Formats/Exr/ExrDecoderCore.cs

@ -147,7 +147,7 @@ internal sealed class ExrDecoderCore : ImageDecoderCore
Span<float> bluePixelData = rowBuffer.GetSpan().Slice(width * 2, width); Span<float> bluePixelData = rowBuffer.GetSpan().Slice(width * 2, width);
Span<float> alphaPixelData = rowBuffer.GetSpan().Slice(width * 3, width); Span<float> alphaPixelData = rowBuffer.GetSpan().Slice(width * 3, width);
using ExrBaseDecompressor decompressor = ExrDecompressorFactory.Create(this.Compression, this.memoryAllocator, width, height, bytesPerBlock, rowsPerBlock, channelCount); using ExrBaseDecompressor decompressor = ExrDecompressorFactory.Create(this.Compression, this.memoryAllocator, width, bytesPerBlock, bytesPerRow, rowsPerBlock, channelCount);
for (uint y = 0; y < height; y += rowsPerBlock) for (uint y = 0; y < height; y += rowsPerBlock)
{ {
@ -200,7 +200,7 @@ internal sealed class ExrDecoderCore : ImageDecoderCore
Span<uint> bluePixelData = rowBuffer.GetSpan().Slice(width * 2, width); Span<uint> bluePixelData = rowBuffer.GetSpan().Slice(width * 2, width);
Span<uint> alphaPixelData = rowBuffer.GetSpan().Slice(width * 3, width); Span<uint> alphaPixelData = rowBuffer.GetSpan().Slice(width * 3, width);
using ExrBaseDecompressor decompressor = ExrDecompressorFactory.Create(this.Compression, this.memoryAllocator, width, height, bytesPerBlock, rowsPerBlock, channelCount); using ExrBaseDecompressor decompressor = ExrDecompressorFactory.Create(this.Compression, this.memoryAllocator, width, bytesPerBlock, bytesPerRow, rowsPerBlock, channelCount);
for (uint y = 0; y < height; y += rowsPerBlock) for (uint y = 0; y < height; y += rowsPerBlock)
{ {

20
src/ImageSharp/Formats/Exr/ExrEncoderCore.cs

@ -5,7 +5,6 @@ using System.Buffers;
using System.Buffers.Binary; using System.Buffers.Binary;
using System.Numerics; using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading.Channels;
using SixLabors.ImageSharp.Formats.Exr.Compression; using SixLabors.ImageSharp.Formats.Exr.Compression;
using SixLabors.ImageSharp.Formats.Exr.Constants; using SixLabors.ImageSharp.Formats.Exr.Constants;
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
@ -32,7 +31,7 @@ internal sealed class ExrEncoderCore
/// <summary> /// <summary>
/// The global configuration. /// The global configuration.
/// </summary> /// </summary>
private Configuration configuration; private readonly Configuration configuration;
/// <summary> /// <summary>
/// The encoder with options. /// The encoder with options.
@ -170,7 +169,7 @@ internal sealed class ExrEncoderCore
Span<float> greenBuffer = rgbBuffer.GetSpan().Slice(width, width); Span<float> greenBuffer = rgbBuffer.GetSpan().Slice(width, width);
Span<float> blueBuffer = rgbBuffer.GetSpan().Slice(width * 2, width); Span<float> blueBuffer = rgbBuffer.GetSpan().Slice(width * 2, width);
using ExrBaseCompressor compressor = ExrCompressorFactory.Create(compression, this.memoryAllocator, stream, width, height, bytesPerBlock, rowsPerBlock, channelCount); using ExrBaseCompressor compressor = ExrCompressorFactory.Create(compression, this.memoryAllocator, stream, bytesPerBlock, bytesPerRow);
ulong[] rowOffsets = new ulong[height]; ulong[] rowOffsets = new ulong[height];
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
@ -181,7 +180,7 @@ internal sealed class ExrEncoderCore
BinaryPrimitives.WriteUInt32LittleEndian(this.buffer, (uint)y); BinaryPrimitives.WriteUInt32LittleEndian(this.buffer, (uint)y);
stream.Write(this.buffer.AsSpan(0, 4)); stream.Write(this.buffer.AsSpan(0, 4));
// At this point, it is not yet known how mcuh bytes the compressed data will take up, keep stream position. // At this point, it is not yet known how much bytes the compressed data will take up, keep stream position.
long pixelDataSizePos = stream.Position; long pixelDataSizePos = stream.Position;
Span<TPixel> pixelRowSpan = pixels.DangerousGetRowSpan(y); Span<TPixel> pixelRowSpan = pixels.DangerousGetRowSpan(y);
stream.Position = pixelDataSizePos + 4; stream.Position = pixelDataSizePos + 4;
@ -195,18 +194,19 @@ internal sealed class ExrEncoderCore
} }
// Write pixel data to buffer. // Write pixel data to buffer.
Span<byte> rowBlockSpan = rowBlockBuffer.GetSpan();
switch (this.pixelType) switch (this.pixelType)
{ {
case ExrPixelType.Float: case ExrPixelType.Float:
this.WriteSingleRow(rowBlockBuffer.GetSpan(), width, blueBuffer, greenBuffer, redBuffer); this.WriteSingleRow(rowBlockSpan, width, blueBuffer, greenBuffer, redBuffer);
break; break;
case ExrPixelType.Half: case ExrPixelType.Half:
this.WriteHalfSingleRow(rowBlockBuffer.GetSpan(), width, blueBuffer, greenBuffer, redBuffer); this.WriteHalfSingleRow(rowBlockSpan, width, blueBuffer, greenBuffer, redBuffer);
break; break;
} }
// Write compressed pixel row data to stream. // Write compressed pixel row data to the stream.
uint compressedBytes = compressor.CompressRowBlock(rowBlockBuffer.GetSpan(), 1); uint compressedBytes = compressor.CompressRowBlock(rowBlockSpan, (int)rowsPerBlock);
long positionAfterPixelData = stream.Position; long positionAfterPixelData = stream.Position;
// Write pixel row data size. // Write pixel row data size.
@ -239,7 +239,7 @@ internal sealed class ExrEncoderCore
Span<uint> greenBuffer = rgbBuffer.GetSpan().Slice(width, width); Span<uint> greenBuffer = rgbBuffer.GetSpan().Slice(width, width);
Span<uint> blueBuffer = rgbBuffer.GetSpan().Slice(width * 2, width); Span<uint> blueBuffer = rgbBuffer.GetSpan().Slice(width * 2, width);
using ExrBaseCompressor compressor = ExrCompressorFactory.Create(compression, this.memoryAllocator, stream, width, height, bytesPerBlock, rowsPerBlock, channelCount); using ExrBaseCompressor compressor = ExrCompressorFactory.Create(compression, this.memoryAllocator, stream, bytesPerBlock, bytesPerRow);
Rgb96 rgb = default; Rgb96 rgb = default;
ulong[] rowOffsets = new ulong[height]; ulong[] rowOffsets = new ulong[height];
@ -251,7 +251,7 @@ internal sealed class ExrEncoderCore
BinaryPrimitives.WriteUInt32LittleEndian(this.buffer, (uint)y); BinaryPrimitives.WriteUInt32LittleEndian(this.buffer, (uint)y);
stream.Write(this.buffer.AsSpan(0, 4)); stream.Write(this.buffer.AsSpan(0, 4));
// At this point, it is not yet known how mcuh bytes the compressed data will take up, keep stream position. // At this point, it is not yet known how much bytes the compressed data will take up, keep stream position.
long pixelDataSizePos = stream.Position; long pixelDataSizePos = stream.Position;
Span<TPixel> pixelRowSpan = pixels.DangerousGetRowSpan(y); Span<TPixel> pixelRowSpan = pixels.DangerousGetRowSpan(y);
stream.Position = pixelDataSizePos + 4; stream.Position = pixelDataSizePos + 4;

Loading…
Cancel
Save