Skip to content

Commit

Permalink
v0.13.2
Browse files Browse the repository at this point in the history
  • Loading branch information
saucecontrol committed Nov 8, 2022
1 parent 804db39 commit e362a7c
Show file tree
Hide file tree
Showing 26 changed files with 196 additions and 157 deletions.
Binary file added doc/images/IMG_2301-ImageFlow.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/images/IMG_2301-ImageSharp.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/images/IMG_2301-MagicScaler.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/images/IMG_2301-NetVips.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/IMG_2445-ImageFlow.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/images/IMG_2445-ImageSharp.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/images/IMG_2445-MagicScaler.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/images/IMG_2445-NetVips.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/IMG_2525-ImageFlow.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/images/IMG_2525-ImageSharp.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/images/IMG_2525-MagicScaler.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/images/IMG_2525-NetVips.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/sample-ImageFlow.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/images/sample-ImageSharp.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/images/sample-MagicScaler.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/images/sample-NetVips.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
282 changes: 156 additions & 126 deletions readme.md

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions src/MagicScaler/Magic/Processors/ChannelChanger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,7 @@ unsafe void IConversionProcessor.ConvertLine(byte* istart, byte* ostart, nint cb
var v0 = Avx.LoadVector256((byte*)ip);
ip += Vector256<byte>.Count;

v0 = Avx2.Shuffle(v0, vmask);

Avx.Store((byte*)op, v0);
Avx.Store((byte*)op, Avx2.Shuffle(v0, vmask));
op += Vector256<byte>.Count;
}
while (ip <= ipe);
Expand All @@ -572,9 +570,7 @@ unsafe void IConversionProcessor.ConvertLine(byte* istart, byte* ostart, nint cb
var v0 = Sse2.LoadVector128((byte*)ip);
ip += Vector128<byte>.Count;

v0 = Ssse3.Shuffle(v0, vmask);

Sse2.Store((byte*)op, v0);
Sse2.Store((byte*)op, Ssse3.Shuffle(v0, vmask));
op += Vector128<byte>.Count;
}
while (ip <= ipe);
Expand Down
6 changes: 3 additions & 3 deletions src/MagicScaler/Magic/Processors/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,13 @@ private static void convertIntrinsic(byte* ip, byte* ipe)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void convertScalar(byte* ip, byte* ipe)
{
while (ip < ipe - sizeof(nuint))
while (ip <= ipe - sizeof(nuint))
{
*(nuint*)ip = ~*(nuint*)ip;
ip += sizeof(nuint);
}

while (ip < ipe)
*ip++ = (byte)~(uint)*ip;
if (ip < ipe)
*(uint*)ip = ~*(uint*)ip;
}
}
4 changes: 2 additions & 2 deletions src/MagicScaler/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Speed and efficiency are unmatched by anything else on the .NET platform.
Requirements
------------

MagicScaler currently has full functionality only on Windows 10+.
MagicScaler currently has full functionality only on Windows.

Work is in progress to reach full feature parity on Linux. A growing collection of codecs for Linux is available on [nuget.org](https://www.nuget.org/packages?q=photosauce.nativecodecs), and at this point most use cases are covered. Notable exceptions are support for BMP and TIFF images and CMYK JPEG.
Work is in progress to reach full feature parity on Linux. A growing collection of cross-platform codecs is available on [nuget.org](https://www.nuget.org/packages?q=photosauce.nativecodecs), and at this point most use cases are covered. Notable exceptions are support for BMP and TIFF images and CMYK JPEG.

Usage
-----
Expand Down
14 changes: 8 additions & 6 deletions src/NativeCodecs/Giflib/GifDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,20 +328,22 @@ private void dispose(bool disposing)
if (handle is null)
return;

palette.Dispose();
palette = default;

iccpData.Dispose();
iccpData = default;

GCHandle.FromIntPtr((IntPtr)handle->UserData).Free();

int err;
_ = DGifCloseFile(handle, &err);
handle = null;

if (disposing)
{
palette.Dispose();
palette = default;

iccpData.Dispose();
iccpData = default;

GC.SuppressFinalize(this);
}
}

public void Dispose() => dispose(true);
Expand Down
8 changes: 8 additions & 0 deletions src/NativeCodecs/Giflib/GifEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ private void dispose(bool disposing)

var gch = GCHandle.FromIntPtr((IntPtr)handle->UserData);

// EGifCloseFile will attempt to write GIF trailer byte before cleaning up.
// We prevent that during finalization by taking the file handle away from it.
if (!disposing)
handle->UserData = null;

int err;
_ = EGifCloseFile(handle, &err);
handle = null;
Expand Down Expand Up @@ -206,6 +211,9 @@ private int writeCallback(GifFileType* pinst, byte* buff, int cb)
{
try
{
if (pinst->UserData is null)
return 0;

var stm = Unsafe.As<Stream>(GCHandle.FromIntPtr((IntPtr)pinst->UserData).Target!);
stm.Write(new ReadOnlySpan<byte>(buff, cb));

Expand Down
14 changes: 8 additions & 6 deletions src/NativeCodecs/Libjxl/JxlDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,19 @@ private void dispose(bool disposing)
if (decoder is null)
return;

iccpData.Dispose();
iccpData = default;

exifData.Dispose();
exifData= default;

JxlDecoderDestroy(decoder);
decoder = null;

if (disposing)
{
iccpData.Dispose();
iccpData = default;

exifData.Dispose();
exifData= default;

GC.SuppressFinalize(this);
}
}

public void Dispose() => dispose(true);
Expand Down
9 changes: 5 additions & 4 deletions src/NativeCodecs/Libpng/PngDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,14 +351,15 @@ private void dispose(bool disposing)
if (handle is null)
return;

_ = PngReadEnd(handle, null);
if (disposing)
{
_ = PngReadEnd(handle, null);
GC.SuppressFinalize(this);
}

GCHandle.FromIntPtr(handle->io_ptr->stream_handle).Free();
PngDestroyRead(handle);
handle = null;

if (disposing)
GC.SuppressFinalize(this);
}

public void Dispose() => dispose(true);
Expand Down
6 changes: 3 additions & 3 deletions src/NativeCodecs/Libwebp/WebpDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,14 @@ public bool TryGetMetadata<T>([NotNullWhen(true)] out T? metadata) where T : IMe

protected virtual void Dispose(bool disposing)
{
if (disposing)
GC.SuppressFinalize(this);

if (!buffer.IsAllocated())
return;

fixed (WebPDecBuffer* pbuff = &buffer)
WebPFreeDecBuffer(pbuff);

if (disposing)
GC.SuppressFinalize(this);
}

public void Dispose() => Dispose(true);
Expand Down
2 changes: 1 addition & 1 deletion src/WebRSize/WebRSize.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<VersionPrefix>0.6.6</VersionPrefix>
<VersionPrefix>0.6.7</VersionPrefix>
<TargetFrameworks>net472</TargetFrameworks>
<TargetFrameworks Condition="'$(Configuration)'=='Dist' Or '$(Configuration)'=='Coverage'">$(TargetFrameworks);net461</TargetFrameworks>
</PropertyGroup>
Expand Down

0 comments on commit e362a7c

Please sign in to comment.