-
-
Notifications
You must be signed in to change notification settings - Fork 855
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP Replace Jpeg Decoder #274
Merged
Changes from 47 commits
Commits
Show all changes
156 commits
Select commit
Hold shift + click to select a range
1555f09
Begin port
JimBobSquarePants 1abe631
Fix header finder
JimBobSquarePants d4d74b4
Add js source link
JimBobSquarePants f63f85a
Use buffer
JimBobSquarePants 2c629c7
Remove offset
JimBobSquarePants b025ed6
Fix progressive bool assignment
JimBobSquarePants 3728b82
(╯°□°)╯︵ ┻━┻
JimBobSquarePants 0ea7a6f
Can now build huffman tables
JimBobSquarePants a718bf8
Begin ProcessStartOfScan
JimBobSquarePants cd72206
Merge branch 'master' into jpeg-port
JimBobSquarePants 1629819
Can now decode a scan
JimBobSquarePants 8bbc63f
Begin second phase of decoding
JimBobSquarePants c1025a6
Impove disposal
JimBobSquarePants 549e61f
Experiment with new file marker finder
JimBobSquarePants ba8a5b3
Merge branch 'master' into jpeg-port
JimBobSquarePants 2f501eb
Decoder now doesn't break tests
JimBobSquarePants 4a4e94d
Fix progressive decoding
JimBobSquarePants 472d6ba
baseline decode works progressive nearly
JimBobSquarePants 28a8aca
Fix progressive scan decoding
JimBobSquarePants ca9bd35
Can now decode many images
JimBobSquarePants 69c15e3
Merge branch 'master' into jpeg-port
JimBobSquarePants 59c0793
Can now decode that bad progressive image
JimBobSquarePants 827ca83
Now decodes all images
JimBobSquarePants e2d26eb
Fix #159
JimBobSquarePants 76e91db
use an offset span instead of buffer
tocsoft db2b712
additional usages of Span
tocsoft 5439240
fixed Sandbox46 execution
antonfirsov ea0abc9
Rough working better Huffman
JimBobSquarePants 0f60242
Better Huffman decoding
JimBobSquarePants 0323d00
Almost got Huffman LUT working
JimBobSquarePants a360614
Better Huffman indexing.
JimBobSquarePants 2703e22
Merge branch 'master' into jpeg-port
JimBobSquarePants 8241314
Getting close with that lookup now.
JimBobSquarePants 2c64ed6
Fix build
JimBobSquarePants 2b4abd2
introduced CoreCompat.SystemDrawing as reference utility for tests, i…
antonfirsov 7d12830
ReferencePngDecoder
antonfirsov f026778
migrate to a Image.Generate/Image.Mutate context api
tocsoft 24433e9
ReferenceOutput + ResizeTests prototype
antonfirsov 1e8f899
Merge branch 'master' into jpeg-port
JimBobSquarePants 5086b08
Use properties
JimBobSquarePants 290646a
store scale as vector + remove unneeded bit or operations
tocsoft 456e139
fix demo
tocsoft 88e30a0
fix apply processors to frames
tocsoft a61fcc9
Rename Generate -> Clone
tocsoft 09d8fac
refactor
antonfirsov 738fc20
Add WIP faster IDCT method
JimBobSquarePants 9ff1b56
This works. High allocations though
JimBobSquarePants 8c22c11
A little cleanup
JimBobSquarePants a236a80
Simplify indexing
JimBobSquarePants 1cd137d
Reduce allocations
JimBobSquarePants 0ff77ec
Move check into if statement
JimBobSquarePants 996da79
Fix tests
JimBobSquarePants 215345e
Merge branch 'master' into jpeg-port
JimBobSquarePants 3272518
Fix broken EXIF test
JimBobSquarePants ae6d91a
Fix ImageMetaData test
JimBobSquarePants 001e3ca
Fix stack overflow
tocsoft b4fbf17
merge with master
tocsoft 4d931e6
more benchmarks
antonfirsov 961e202
initail image operations tests
tocsoft c3f7f83
move methods
tocsoft ccee50b
Merge branch 'tocsoft/mutate-api' of https://github.com/JimBobSquareP…
tocsoft f7cbb27
test extensions methods
tocsoft 04b6ad8
fix warnings
tocsoft c12f993
fix sandbox test
tocsoft 6270568
blank to force rebuild
tocsoft ab30013
Renameing classes + simplifying Image<TPixel>
tocsoft 9b86525
fix some comments
tocsoft cb165fa
Merge remote-tracking branch 'origin/master' into tocsoft/mutate-api
tocsoft 41cadf9
fix broken tests
tocsoft c421e6d
Cloneing Image Processor
tocsoft 7635558
internalise cloning processor + rename context
tocsoft 3e23313
made FormatsDirectory a lazy value -> folders are no longer walked in…
antonfirsov d9fb5bd
clean up TestFile.cs
antonfirsov 7d932dc
Merge branch 'master' into tocsoft/mutate-api
tocsoft 06271fa
Fix spelling errors
JimBobSquarePants e824a1b
Merge remote-tracking branch 'origin/master' into tocsoft/mutate-api
tocsoft 2af76f6
refactored GetFormatsDirectory() to GetInputImagesDirectoryFullPath()
antonfirsov 7eca259
always DebugSave() png-s
antonfirsov 70892a1
Cleanup + Rename Run to Apply
JimBobSquarePants 0136a6c
ResizeTests working with CalliphoraPartial.png
antonfirsov fe874b6
Merge remote-tracking branch 'origin/master' into antonfirsov/qa-lab
antonfirsov 572db70
build fix + clean up ImageDataAttributeBase code duplication
antonfirsov 3251941
use TestPatternImages in ResizeTests
antonfirsov 5dff018
moving input test images into ./tests/TestImages/Input
antonfirsov e170f80
update .gitignore to match the new test output directory
antonfirsov f53a788
test utility refactors
antonfirsov 5fb4461
Merge remote-tracking branch 'origin/tocsoft/mutate-api' into antonfi…
antonfirsov 355a4ac
re-apply DebugSave() changes after merging mutate-api
antonfirsov 9c5798b
Intellisense docs cleanup
JimBobSquarePants d855c6e
reduced resize output by 75%
antonfirsov f357f31
moving images again
antonfirsov 15a7b5a
Merge branch 'master' into tocsoft/mutate-api
JimBobSquarePants f8a0ed3
Update rotate test to use new API
JimBobSquarePants cd2e0a1
optimized ResizeTests output further, added Bike.png
antonfirsov 0e06480
optimized DetectEdgesTest
antonfirsov de964e5
added comments, docs + a CloneAndConvertToAvatarWithoutApply() example
antonfirsov 9245631
fix typo
antonfirsov 81ee6d0
smaller Bike.png, optimized RotateTests & RotateFlipTests
antonfirsov e01cc2b
docs & formatting
antonfirsov a00aec7
ImageComparer refactors, ExactComparer
antonfirsov 0b0ba13
implemented ExactImageComparer
antonfirsov 619ad53
changed ImageComparer design again
antonfirsov d9238a5
implemented TolerantImageComparer
antonfirsov f9cd6b6
replaced old comparer everywhere
antonfirsov 8d091b5
looks like ApplyOilPaintFilterInBox() is failing with a very good reason
antonfirsov 105d445
PixelTypes bugfix + polishing ResizeTests
antonfirsov 985ed92
added submodule as "External"
antonfirsov fe79f4a
TestImageExtensionsTests + TolerantImageComparer bugfix + update subm…
antonfirsov 2b292d4
ResizeTests use CompareToReferenceOutput now!
antonfirsov 747aa7f
JpegDecoderTests using reference images
antonfirsov 2c8e29c
copied pdfjs classes from the jpeg-port branch
antonfirsov 692c4f7
prefixed every ported class with PdfJs... to avoid naming conflicts
antonfirsov 0a80231
shut up StyleStalin, I'm working! :P
antonfirsov 85f880d
so what's the deal with submodule branches?
antonfirsov f460c2a
maybe this?
antonfirsov a5c901f
now what?
antonfirsov febe9c6
TestImageProvider can use custom decoder now
antonfirsov cd3f391
TestImageProvider can use custom decoder now
antonfirsov 59705ee
introducing the "doNotAppendPixelType" feature
antonfirsov a284598
CompareToReferenceOutput() no longer triggers DebugSave(). Need to be…
antonfirsov 55d814c
with 'appendPixelTypeToFileName: false' there is no need to duplicate…
antonfirsov 9af66a6
Merge remote-tracking branch 'origin/antonfirsov/qa-lab' into jpeg-lab
antonfirsov 48f3fde
comparing decoders
antonfirsov 94c60cb
inital rename packages and namespaces
tocsoft 3653f1f
fix some tests and updated packages
tocsoft fbe9d25
add missing stylecop.json
tocsoft 8f53b5b
tweek codecov cmd file
tocsoft 58281ef
Use more accurate IDCT for now
JimBobSquarePants f5b9a8c
Use more accurate IDCT
JimBobSquarePants 9da4345
.
antonfirsov 2d80a6f
Merge branch 'jpeg-lab' of https://github.com/JimBobSquarePants/Image…
antonfirsov 9be5ba0
skip tests in build on CI server as they are ran from CodeCoverage.cmd
tocsoft 9a4d048
publish both packages
tocsoft c9db035
ensure local running of build scripts runs tests from correct build
tocsoft 4c8ba59
fix broken test
tocsoft 4f38761
Fix skew
JimBobSquarePants 84852a8
good by GenericFactory!
antonfirsov 1562e32
Using Corecompat.System.Drawing as reference encoder/decoder for PNG.…
antonfirsov 02eb5f2
PngDecoder is covered now, and proven to be buggy :P
antonfirsov 1df0010
covered DetectEdges
antonfirsov f6904d9
Merge remote-tracking branch 'origin/antonfirsov/qa-lab' into jpeg-lab
antonfirsov a103cb8
TestImageProvider.FileProvider cache is now aware of decoder parameters
antonfirsov a798d5a
Merge remote-tracking branch 'origin/antonfirsov/qa-lab' into jpeg-lab
antonfirsov 385ed88
provider.GetImage(new JpegDecoder())
antonfirsov c4953b0
let's merge jpeg-port to have the changelog!
antonfirsov 1959c4a
Merge remote-tracking branch 'origin/jpeg-port' into jpeg-lab
antonfirsov 7383124
grouping files for decoders
antonfirsov 4676d8a
moving a few more files
antonfirsov b6d4f35
GolangPort namespaces following folder structure
antonfirsov 1c75403
move Block8x8F into ImageSharp.Formats.Jpeg.Common
antonfirsov 80380d9
adjust PdfJsPort namespaces
antonfirsov 51b430b
prefixing GolangPort stuff with Old*** #Round1
antonfirsov 493deda
renaming is hard
antonfirsov b3b4827
introduced OldJpegDecoder : IImageDecoder for the GolangPort decoder
antonfirsov 9b34d09
Merge pull request #297 from SixLabors/tocsoft/sixlabors_rename
JimBobSquarePants 0baf7d0
Merge branch 'tocsoft/mutate-api' into jpeg-port
JimBobSquarePants File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// <copyright file="ListExtensions.cs" company="James Jackson-South"> | ||
// Copyright (c) James Jackson-South and contributors. | ||
// Licensed under the Apache License, Version 2.0. | ||
// </copyright> | ||
|
||
namespace ImageSharp.Common.Extensions | ||
{ | ||
using System.Collections.Generic; | ||
|
||
/// <summary> | ||
/// Encapsulates a series of time saving extension methods to the <see cref="T:System.Collections.Generic.List"/> class. | ||
/// </summary> | ||
internal static class ListExtensions | ||
{ | ||
/// <summary> | ||
/// Inserts an item at the given index automatically expanding the capacity if required. | ||
/// </summary> | ||
/// <typeparam name="T">The type of object within the list</typeparam> | ||
/// <param name="list">The list</param> | ||
/// <param name="index">The index</param> | ||
/// <param name="item">The item to insert</param> | ||
public static void SafeInsert<T>(this List<T> list, int index, T item) | ||
{ | ||
if (index >= list.Count) | ||
{ | ||
list.Add(item); | ||
} | ||
else | ||
{ | ||
list[index] = item; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Removes the last element from a list and returns that element. This method changes the length of the list. | ||
/// </summary> | ||
/// <typeparam name="T">The type of object within the list</typeparam> | ||
/// <param name="list">The list</param> | ||
/// <returns>The last element in the specified sequence.</returns> | ||
public static T Pop<T>(this List<T> list) | ||
{ | ||
int last = list.Count - 1; | ||
T item = list[last]; | ||
list.RemoveAt(last); | ||
return item; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ public static void Skip(this Stream stream, int count) | |
|
||
if (stream.CanSeek) | ||
{ | ||
stream.Position += count; | ||
stream.Seek(count, SeekOrigin.Current); // Position += count; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is supposedly faster |
||
} | ||
else | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// <copyright file="Adobe.cs" company="James Jackson-South"> | ||
// Copyright (c) James Jackson-South and contributors. | ||
// Licensed under the Apache License, Version 2.0. | ||
// </copyright> | ||
|
||
// ReSharper disable InconsistentNaming | ||
namespace ImageSharp.Formats.Jpeg.Port.Components | ||
{ | ||
using System; | ||
|
||
/// <summary> | ||
/// Provides information about the Adobe marker segment | ||
/// </summary> | ||
internal struct Adobe : IEquatable<Adobe> | ||
{ | ||
/// <summary> | ||
/// The DCT Encode Version | ||
/// </summary> | ||
public short DCTEncodeVersion; | ||
|
||
/// <summary> | ||
/// 0x0 : (none) | ||
/// Bit 15 : Encoded with Blend=1 downsampling | ||
/// </summary> | ||
public short APP14Flags0; | ||
|
||
/// <summary> | ||
/// 0x0 : (none) | ||
/// </summary> | ||
public short APP14Flags1; | ||
|
||
/// <summary> | ||
/// Determines the colorspace transform | ||
/// 00 : Unknown (RGB or CMYK) | ||
/// 01 : YCbCr | ||
/// 02 : YCCK | ||
/// </summary> | ||
public byte ColorTransform; | ||
|
||
/// <inheritdoc/> | ||
public bool Equals(Adobe other) | ||
{ | ||
return this.DCTEncodeVersion == other.DCTEncodeVersion | ||
&& this.APP14Flags0 == other.APP14Flags0 | ||
&& this.APP14Flags1 == other.APP14Flags1 | ||
&& this.ColorTransform == other.ColorTransform; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override bool Equals(object obj) | ||
{ | ||
if (ReferenceEquals(null, obj)) | ||
{ | ||
return false; | ||
} | ||
|
||
return obj is Adobe && this.Equals((Adobe)obj); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override int GetHashCode() | ||
{ | ||
unchecked | ||
{ | ||
// TODO: Merge and use HashCodeHelpers | ||
int hashCode = this.DCTEncodeVersion.GetHashCode(); | ||
hashCode = (hashCode * 397) ^ this.APP14Flags0.GetHashCode(); | ||
hashCode = (hashCode * 397) ^ this.APP14Flags1.GetHashCode(); | ||
hashCode = (hashCode * 397) ^ this.ColorTransform.GetHashCode(); | ||
return hashCode; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// <copyright file="Component.cs" company="James Jackson-South"> | ||
// Copyright (c) James Jackson-South and contributors. | ||
// Licensed under the Apache License, Version 2.0. | ||
// </copyright> | ||
|
||
namespace ImageSharp.Formats.Jpeg.Port.Components | ||
{ | ||
using System; | ||
using System.Numerics; | ||
using ImageSharp.Memory; | ||
|
||
/// <summary> | ||
/// Represents a component block | ||
/// </summary> | ||
internal struct Component : IDisposable | ||
{ | ||
/// <summary> | ||
/// Gets or sets the output | ||
/// </summary> | ||
public Buffer<short> Output; | ||
|
||
/// <summary> | ||
/// Gets or sets the scaling factors | ||
/// </summary> | ||
public Vector2 Scale; | ||
|
||
/// <summary> | ||
/// Gets or sets the number of blocks per line | ||
/// </summary> | ||
public int BlocksPerLine; | ||
|
||
/// <summary> | ||
/// Gets or sets the number of blocks per column | ||
/// </summary> | ||
public int BlocksPerColumn; | ||
|
||
/// <inheritdoc/> | ||
public void Dispose() | ||
{ | ||
this.Output?.Dispose(); | ||
this.Output = null; | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/ImageSharp/Formats/Jpeg/Port/Components/ComponentBlocks.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// <copyright file="Components.cs" company="James Jackson-South"> | ||
// Copyright (c) James Jackson-South and contributors. | ||
// Licensed under the Apache License, Version 2.0. | ||
// </copyright> | ||
|
||
namespace ImageSharp.Formats.Jpeg.Port.Components | ||
{ | ||
using System; | ||
|
||
/// <summary> | ||
/// Contains all the decoded component blocks | ||
/// </summary> | ||
internal sealed class ComponentBlocks : IDisposable | ||
{ | ||
/// <summary> | ||
/// Gets or sets the component blocks | ||
/// </summary> | ||
public Component[] Components { get; set; } | ||
|
||
/// <inheritdoc/> | ||
public void Dispose() | ||
{ | ||
if (this.Components != null) | ||
{ | ||
for (int i = 0; i < this.Components.Length; i++) | ||
{ | ||
this.Components[i].Dispose(); | ||
} | ||
|
||
this.Components = null; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// <copyright file="HuffmanTables.cs" company="James Jackson-South"> | ||
// Copyright (c) James Jackson-South and contributors. | ||
// Licensed under the Apache License, Version 2.0. | ||
// </copyright> | ||
|
||
namespace ImageSharp.Formats.Jpeg.Port.Components | ||
{ | ||
/// <summary> | ||
/// Represents a jpeg file marker | ||
/// </summary> | ||
internal struct FileMarker | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="FileMarker"/> struct. | ||
/// </summary> | ||
/// <param name="marker">The marker</param> | ||
/// <param name="position">The position within the stream</param> | ||
public FileMarker(ushort marker, long position) | ||
{ | ||
this.Marker = marker; | ||
this.Position = position; | ||
this.Invalid = false; | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="FileMarker"/> struct. | ||
/// </summary> | ||
/// <param name="marker">The marker</param> | ||
/// <param name="position">The position within the stream</param> | ||
/// <param name="invalid">Whether the current marker is invalid</param> | ||
public FileMarker(ushort marker, long position, bool invalid) | ||
{ | ||
this.Marker = marker; | ||
this.Position = position; | ||
this.Invalid = invalid; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets a value indicating whether the current marker is invalid | ||
/// </summary> | ||
public bool Invalid { get; set; } | ||
|
||
/// <summary> | ||
/// Gets the position of the marker within a stream | ||
/// </summary> | ||
public ushort Marker { get; } | ||
|
||
/// <summary> | ||
/// Gets the position of the marker within a stream | ||
/// </summary> | ||
public long Position { get; } | ||
|
||
/// <inheritdoc/> | ||
public override string ToString() | ||
{ | ||
return this.Marker.ToString("X"); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I'm using any of this anymore. It can go.