FileOnQ / Imaging.Heif

A C#/.NET wrapper around libheif for decoding and processing high efficiency image formats (heif, heic).
GNU Lesser General Public License v3.0
15 stars 4 forks source link

Adds Memory Buffer APIs #30

Closed SkyeHoefling closed 3 years ago

SkyeHoefling commented 3 years ago

Fixes: #9

Description

Adds new Memory Buffer APIs, unit tests and benchmarks

IImage - New APIs

byte[] ToArray(int quality = 90);
ReadOnlySpan<byte> ToSpan(int quality = 90);
Stream ToStream(int quality = 90);

Merge Checklist

github-actions[bot] commented 3 years ago

Benchmark Comparison

Benchmarking comparison between this Pull Request and the comitted values at benchmarks/results

thumbnail

 summary:
better: 1, geomean: 1.148
total diff: 1

No Slower results for the provided threshold = 10% and noise filter = 0.3ns.

| Faster                                                    | base/diff | Base Median (ns) | Diff Median (ns) | Modality|
| --------------------------------------------------------- | ---------:| ----------------:| ----------------:| -------- |
| FileOnQ.Imaging.Heif.Benchmarks.Thumbnail.Thumbnail_Write |      1.15 |      60288300.00 |      52499750.00 | several?|

No file given

primary

 No differences found between the benchmark results with threshold 10%.

Benchmark Results

thumbnail

``` ini BenchmarkDotNet=v0.13.0, OS=Windows 10.0.17763.2114 (1809/October2018Update/Redstone5) Intel Xeon CPU E5-2673 v4 2.30GHz, 1 CPU, 2 logical and 2 physical cores .NET SDK=5.0.400 [Host] : .NET 5.0.9 (5.0.921.35908), X64 RyuJIT Job-FJVQTT : .NET 5.0.9 (5.0.921.35908), X64 RyuJIT Runtime=.NET 5.0 InvocationCount=1 LaunchCount=1 UnrollFactor=1 ``` | Method | Mean | Error | StdDev | Median | Gen 0 | Gen 1 | Gen 2 | Allocated | Allocated native memory | Native memory leak | |------------------- |---------:|---------:|---------:|---------:|------:|------:|------:|----------:|------------------------:|-------------------:| | Thumbnail_Write | 52.41 ms | 1.036 ms | 2.746 ms | 52.50 ms | - | - | - | 288 B | 5,125,137 B | - | | Thumbnail_ToArray | 48.68 ms | 1.194 ms | 3.503 ms | 47.95 ms | - | - | - | 66,408 B | 5,124,581 B | - | | Thumbnail_ToSpan | 50.10 ms | 1.206 ms | 3.555 ms | 49.83 ms | - | - | - | 120 B | 5,124,581 B | - | | Thumbnail_ToStream | 48.84 ms | 1.220 ms | 3.577 ms | 47.63 ms | - | - | - | 66,472 B | 5,124,581 B | - |

primary

``` ini BenchmarkDotNet=v0.13.0, OS=Windows 10.0.17763.2114 (1809/October2018Update/Redstone5) Intel Xeon CPU E5-2673 v4 2.30GHz, 1 CPU, 2 logical and 2 physical cores .NET SDK=5.0.400 [Host] : .NET 5.0.9 (5.0.921.35908), X64 RyuJIT Job-UAQZJA : .NET 5.0.9 (5.0.921.35908), X64 RyuJIT Runtime=.NET 5.0 InvocationCount=1 LaunchCount=1 UnrollFactor=1 ``` | Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated | Allocated native memory | Native memory leak | |---------------------- |--------:|---------:|---------:|------:|------:|------:|------------:|------------------------:|-------------------:| | PrimaryImage_Write | 2.736 s | 0.0409 s | 0.0341 s | - | - | - | 256 B | 222,029,948 B | - | | PrimaryImage_ToArray | 2.896 s | 0.0486 s | 0.0596 s | - | - | - | 1,943,008 B | 222,029,376 B | - | | PrimaryImage_ToSpan | 2.775 s | 0.0372 s | 0.0310 s | - | - | - | 88 B | 222,029,424 B | - | | PrimaryImage_ToStream | 2.738 s | 0.0416 s | 0.0389 s | - | - | - | 1,943,072 B | 222,029,552 B | - |

SkyeHoefling commented 3 years ago

This PR requires new benchmark results to be uploaded prior to merging. I added a new checklist item to the PR description

SkyeHoefling commented 3 years ago

I just looked through the code changes and it appears there is issues with tabs in several areas of the code. There are extra tabs or not enough tabs.

I am going to do another pass and push changes

SkyeHoefling commented 3 years ago

@mitchelsellers I think this PR is good, can you take a look and see if I missed any typos or anything. If you think it is good to go please merge it.

I did not add XML docs to this PR as we are going to do all XML docs in #22 for the 1.0.0 release