Browse Source

Fix warnings and license headers

pull/1552/head
Brian Popow 6 years ago
parent
commit
ee08904d7b
  1. 10
      src/ImageSharp/Formats/WebP/BitWriter/Vp8BitWriter.cs
  2. 2
      src/ImageSharp/Formats/WebP/BitWriter/Vp8LBitWriter.cs
  3. 4
      src/ImageSharp/Formats/WebP/EntropyIx.cs
  4. 4
      src/ImageSharp/Formats/WebP/HistoIx.cs
  5. 4
      src/ImageSharp/Formats/WebP/IWebPEncoderOptions.cs
  6. 4
      src/ImageSharp/Formats/WebP/ImageExtensions.cs
  7. 20
      src/ImageSharp/Formats/WebP/Lossless/BackwardReferenceEncoder.cs
  8. 4
      src/ImageSharp/Formats/WebP/Lossless/CostCacheInterval.cs
  9. 4
      src/ImageSharp/Formats/WebP/Lossless/CostInterval.cs
  10. 5
      src/ImageSharp/Formats/WebP/Lossless/CostManager.cs
  11. 4
      src/ImageSharp/Formats/WebP/Lossless/CostModel.cs
  12. 4
      src/ImageSharp/Formats/WebP/Lossless/HistogramBinInfo.cs
  13. 5
      src/ImageSharp/Formats/WebP/Lossless/HistogramEncoder.cs
  14. 4
      src/ImageSharp/Formats/WebP/Lossless/HistogramPair.cs
  15. 4
      src/ImageSharp/Formats/WebP/Lossless/HuffmanTree.cs
  16. 4
      src/ImageSharp/Formats/WebP/Lossless/HuffmanTreeCode.cs
  17. 4
      src/ImageSharp/Formats/WebP/Lossless/HuffmanTreeToken.cs
  18. 2
      src/ImageSharp/Formats/WebP/Lossless/HuffmanUtils.cs
  19. 2
      src/ImageSharp/Formats/WebP/Lossless/LosslessUtils.cs
  20. 7
      src/ImageSharp/Formats/WebP/Lossless/PixOrCopy.cs
  21. 4
      src/ImageSharp/Formats/WebP/Lossless/PixOrCopyMode.cs
  22. 60
      src/ImageSharp/Formats/WebP/Lossless/PredictorEncoder.cs
  23. 9
      src/ImageSharp/Formats/WebP/Lossless/Vp8LBackwardRefs.cs
  24. 4
      src/ImageSharp/Formats/WebP/Lossless/Vp8LBitEntropy.cs
  25. 12
      src/ImageSharp/Formats/WebP/Lossless/Vp8LEncoder.cs
  26. 8
      src/ImageSharp/Formats/WebP/Lossless/Vp8LHashChain.cs
  27. 10
      src/ImageSharp/Formats/WebP/Lossless/Vp8LHistogram.cs
  28. 4
      src/ImageSharp/Formats/WebP/Lossless/Vp8LLz77Type.cs
  29. 4
      src/ImageSharp/Formats/WebP/Lossless/Vp8LMultipliers.cs
  30. 18
      src/ImageSharp/Formats/WebP/Lossless/Vp8LRefsCursor.cs
  31. 8
      src/ImageSharp/Formats/WebP/Lossless/Vp8LStreaks.cs
  32. 5
      src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs
  33. 12
      src/ImageSharp/Formats/WebP/WebPCommonUtils.cs
  34. 5
      src/ImageSharp/Formats/WebP/WebPLookupTables.cs

10
src/ImageSharp/Formats/WebP/BitWriter/Vp8BitWriter.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Formats.WebP.BitWriter
{
@ -8,7 +8,7 @@ namespace SixLabors.ImageSharp.Formats.WebP.BitWriter
/// </summary>
internal class Vp8BitWriter
{
private uint range;
/*private uint range;
private uint value;
@ -40,7 +40,7 @@ namespace SixLabors.ImageSharp.Formats.WebP.BitWriter
this.maxPos = 0;
this.error = false;
//BitWriterResize(expected_size);
}
// BitWriterResize(expected_size);
}*/
}
}

2
src/ImageSharp/Formats/WebP/BitWriter/Vp8LBitWriter.cs

@ -102,7 +102,7 @@ namespace SixLabors.ImageSharp.Formats.WebP.BitWriter
public Vp8LBitWriter Clone()
{
byte[] clonedBuffer = new byte[this.buffer.Length];
var clonedBuffer = new byte[this.buffer.Length];
Buffer.BlockCopy(this.buffer, 0, clonedBuffer, 0, this.cur);
return new Vp8LBitWriter(clonedBuffer, this.bits, this.used, this.cur);
}

4
src/ImageSharp/Formats/WebP/EntropyIx.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Formats.WebP
{

4
src/ImageSharp/Formats/WebP/HistoIx.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Formats.WebP
{

4
src/ImageSharp/Formats/WebP/IWebPEncoderOptions.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Formats.WebP
{

4
src/ImageSharp/Formats/WebP/ImageExtensions.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System.IO;

20
src/ImageSharp/Formats/WebP/Lossless/BackwardReferenceEncoder.cs

@ -1,9 +1,8 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.Collections.Generic;
using SixLabors.ImageSharp.Formats.WebP.Lossy;
namespace SixLabors.ImageSharp.Formats.WebP.Lossless
{
@ -238,8 +237,16 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
/// The return value is the pointer to the best of the two backward refs viz,
/// refs[0] or refs[1].
/// </summary>
public static Vp8LBackwardRefs GetBackwardReferences(int width, int height, Span<uint> bgra, int quality,
int lz77TypesToTry, ref int cacheBits, Vp8LHashChain hashChain, Vp8LBackwardRefs best, Vp8LBackwardRefs worst)
public static Vp8LBackwardRefs GetBackwardReferences(
int width,
int height,
Span<uint> bgra,
int quality,
int lz77TypesToTry,
ref int cacheBits,
Vp8LHashChain hashChain,
Vp8LBackwardRefs best,
Vp8LBackwardRefs worst)
{
var histo = new Vp8LHistogram[WebPConstants.MaxColorCacheBits];
int lz77TypeBest = 0;
@ -248,7 +255,6 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
Vp8LHashChain hashChainBox = null;
for (int lz77Type = 1; lz77TypesToTry > 0; lz77TypesToTry &= ~lz77Type, lz77Type <<= 1)
{
double bitCost;
int cacheBitsTmp = cacheBitsInitial;
if ((lz77TypesToTry & lz77Type) == 0)
{
@ -279,7 +285,7 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
// Keep the best backward references.
histo[0] = new Vp8LHistogram(worst, cacheBitsTmp);
bitCost = histo[0].EstimateBits();
var bitCost = histo[0].EstimateBits();
if (lz77TypeBest == 0 || bitCost < bitCostBest)
{

4
src/ImageSharp/Formats/WebP/Lossless/CostCacheInterval.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System.Diagnostics;

4
src/ImageSharp/Formats/WebP/Lossless/CostInterval.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System.Diagnostics;

5
src/ImageSharp/Formats/WebP/Lossless/CostManager.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System.Collections.Generic;
using System.Linq;
@ -222,7 +222,6 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
private void InsertInterval(double cost, int position, int start, int end)
{
// TODO: use COST_CACHE_INTERVAL_SIZE_MAX
var interval = new CostCacheInterval()
{
Cost = cost,

4
src/ImageSharp/Formats/WebP/Lossless/CostModel.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System;

4
src/ImageSharp/Formats/WebP/Lossless/HistogramBinInfo.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Formats.WebP.Lossless
{

5
src/ImageSharp/Formats/WebP/Lossless/HistogramEncoder.cs

@ -32,8 +32,8 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
int histoYSize = histoBits > 0 ? LosslessUtils.SubSampleSize(ySize, histoBits) : 1;
int imageHistoRawSize = histoXSize * histoYSize;
int entropyCombineNumBins = BinSize;
short[] mapTmp = new short[imageHistoRawSize];
short[] clusterMappings = new short[imageHistoRawSize];
var mapTmp = new short[imageHistoRawSize];
var clusterMappings = new short[imageHistoRawSize];
int numUsed = imageHistoRawSize;
var origHisto = new List<Vp8LHistogram>(imageHistoRawSize);
for (int i = 0; i < imageHistoRawSize; i++)
@ -370,6 +370,7 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
// Pop bestIdx2 from mappings.
var mappingIndex = Array.BinarySearch(mappings, bestIdx2);
// TODO: memmove(mapping_index, mapping_index + 1, sizeof(*mapping_index) *((*num_used) - (mapping_index - mappings) - 1));
// Merge the histograms and remove bestIdx2 from the queue.

4
src/ImageSharp/Formats/WebP/Lossless/HistogramPair.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System.Diagnostics;

4
src/ImageSharp/Formats/WebP/Lossless/HuffmanTree.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System.Diagnostics;

4
src/ImageSharp/Formats/WebP/Lossless/HuffmanTreeCode.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Formats.WebP.Lossless
{

4
src/ImageSharp/Formats/WebP/Lossless/HuffmanTreeToken.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System.Diagnostics;

2
src/ImageSharp/Formats/WebP/Lossless/HuffmanUtils.cs

@ -154,7 +154,7 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
/// <summary>
/// Create an optimal Huffman tree.
/// </summary>
/// <see cref="http://en.wikipedia.org/wiki/Huffman_coding"/>
/// <see href="http://en.wikipedia.org/wiki/Huffman_coding"/>
/// <param name="tree">The huffman tree.</param>
/// <param name="histogram">The histogram.</param>
/// <param name="histogramSize">The size of the histogram.</param>

2
src/ImageSharp/Formats/WebP/Lossless/LosslessUtils.cs

@ -205,7 +205,7 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
newBlue -= ColorTransformDelta((sbyte)m.GreenToBlue, green);
newBlue -= ColorTransformDelta((sbyte)m.RedToBlue, red);
newBlue &= 0xff;
data[i] = (uint)((argb & 0xff00ff00u) | (newRed << 16) | newBlue);
data[i] = (argb & 0xff00ff00u) | ((uint)newRed << 16) | (uint)newBlue;
}
}

7
src/ImageSharp/Formats/WebP/Lossless/PixOrCopy.cs

@ -1,8 +1,11 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System.Diagnostics;
namespace SixLabors.ImageSharp.Formats.WebP.Lossless
{
[DebuggerDisplay("Mode: {Mode}, Len: {Len}, BgraOrDistance: {BgraOrDistance}")]
internal class PixOrCopy
{
public PixOrCopyMode Mode { get; set; }

4
src/ImageSharp/Formats/WebP/Lossless/PixOrCopyMode.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Formats.WebP.Lossless
{

60
src/ImageSharp/Formats/WebP/Lossless/PredictorEncoder.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.Runtime.CompilerServices;
@ -24,7 +24,7 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
/// <summary>
/// Finds the best predictor for each tile, and converts the image to residuals
/// with respect to predictions. If nearLosslessQuality < 100, applies
/// with respect to predictions. If nearLosslessQuality &lt; 100, applies
/// near lossless processing, shaving off more bits of residuals for lower qualities.
/// </summary>
public static void ResidualImage(int width, int height, int bits, Span<uint> argb, Span<uint> argbScratch, Span<uint> image, int nearLosslessQuality, bool exact, bool usedSubtractGreen)
@ -32,7 +32,7 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
int tilesPerRow = LosslessUtils.SubSampleSize(width, bits);
int tilesPerCol = LosslessUtils.SubSampleSize(height, bits);
int maxQuantization = 1 << LosslessUtils.NearLosslessBits(nearLosslessQuality);
int[][] histo = new int[4][];
var histo = new int[4][];
for (int i = 0; i < 4; i++)
{
histo[i] = new int[256];
@ -73,12 +73,18 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
LosslessUtils.ColorCodeToMultipliers(image[offset - tileXSize], ref prevY);
}
prevX = GetBestColorTransformForTile(tileX, tileY, bits,
prevX, prevY,
quality, width, height,
accumulatedRedHisto,
accumulatedBlueHisto,
argb);
prevX = GetBestColorTransformForTile(
tileX,
tileY,
bits,
prevX,
prevY,
quality,
width,
height,
accumulatedRedHisto,
accumulatedBlueHisto,
argb);
image[offset] = MultipliersToColorCode(prevX);
CopyTileWithColorTransform(width, height, tileXOffset, tileYOffset, maxTileSize, prevX, argb);
@ -118,9 +124,19 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
/// the given pixel).
/// </summary>
/// <returns>Best predictor.</returns>
private static int GetBestPredictorForTile(int width, int height, int tileX, int tileY,
int bits, int[][] accumulated, Span<uint> argbScratch, Span<uint> argb,
int maxQuantization, bool exact, bool usedSubtractGreen, Span<uint> modes)
private static int GetBestPredictorForTile(
int width,
int height,
int tileX,
int tileY,
int bits,
int[][] accumulated,
Span<uint> argbScratch,
Span<uint> argb,
int maxQuantization,
bool exact,
bool usedSubtractGreen,
Span<uint> modes)
{
const int numPredModes = 14;
int startX = tileX << bits;
@ -501,9 +517,21 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
xEnd = width;
}
GetResidual(width, height, upperRow, currentRow, currentMaxDiffs,
mode, x, xEnd, y, maxQuantization, exact,
usedSubtractGreen, argb.Slice((y * width) + x));
GetResidual(
width,
height,
upperRow,
currentRow,
currentMaxDiffs,
mode,
x,
xEnd,
y,
maxQuantization,
exact,
usedSubtractGreen,
argb.Slice((y * width) + x));
x = xEnd;
}
}

9
src/ImageSharp/Formats/WebP/Lossless/Vp8LBackwardRefs.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System.Collections.Generic;
@ -13,10 +13,13 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
}
/// <summary>
/// Common block-size.
/// Gets or sets the common block-size.
/// </summary>
public int BlockSize { get; set; }
/// <summary>
/// Gets the backward references.
/// </summary>
public List<PixOrCopy> Refs { get; }
public void Add(PixOrCopy pixOrCopy)

4
src/ImageSharp/Formats/WebP/Lossless/Vp8LBitEntropy.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System;

12
src/ImageSharp/Formats/WebP/Lossless/Vp8LEncoder.cs

@ -315,7 +315,7 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
cacheBits = 0;
}
// Calculate backward references from ARGB image.
// Calculate backward references from BGRA image.
BackwardReferenceEncoder.HashChainFill(hashChain, bgra, quality, width, height);
Vp8LBitWriter bitWriterBest = null;
@ -333,7 +333,6 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
Vp8LBackwardRefs refsTmp = refsArray[refsBest.Equals(refsArray[0]) ? 1 : 0];
// TODO: this.bitWriter.Reset();
var tmpHisto = new Vp8LHistogram(cacheBits);
var histogramImage = new List<Vp8LHistogram>(histogramImageXySize);
for (int i = 0; i < histogramImageXySize; i++)
@ -419,7 +418,6 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
this.StoreImageToBitMask(width, histogramBits, refsBest, histogramSymbols, huffmanCodes);
// TODO: Keep track of the smallest image so far.
if (bitWriterBest != null && this.bitWriter.NumBytes() < bitWriterBest.NumBytes())
{
// TODO : This was done in the reference by swapping references, this will be slower
@ -711,7 +709,7 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
}
}
private void StoreHuffmanTreeOfHuffmanTreeToBitMask(byte[] codeLengthBitdepth)
private void StoreHuffmanTreeOfHuffmanTreeToBitMask(byte[] codeLengthBitDepth)
{
// RFC 1951 will calm you down if you are worried about this funny sequence.
// This sequence is tuned from that, but more weighted for lower symbol count,
@ -722,7 +720,7 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
int codesToStore = WebPConstants.CodeLengthCodes;
for (; codesToStore > 4; codesToStore--)
{
if (codeLengthBitdepth[storageOrder[codesToStore - 1]] != 0)
if (codeLengthBitDepth[storageOrder[codesToStore - 1]] != 0)
{
break;
}
@ -731,7 +729,7 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
this.bitWriter.PutBits((uint)codesToStore - 4, 4);
for (int i = 0; i < codesToStore; i++)
{
this.bitWriter.PutBits(codeLengthBitdepth[storageOrder[i]], 3);
this.bitWriter.PutBits(codeLengthBitDepth[storageOrder[i]], 3);
}
}
@ -1353,7 +1351,7 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
}
// Create Huffman trees.
bool[] bufRle = new bool[maxNumSymbols];
var bufRle = new bool[maxNumSymbols];
var huffTree = new HuffmanTree[3 * maxNumSymbols];
for (int i = 0; i < huffTree.Length; i++)
{

8
src/ImageSharp/Formats/WebP/Lossless/Vp8LHashChain.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System;
@ -19,13 +19,15 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
}
/// <summary>
/// Gets the offset length.
/// The 20 most significant bits contain the offset at which the best match is found.
/// These 20 bits are the limit defined by GetWindowSizeForHashChain (through WindowSize = 1 << 20).
/// These 20 bits are the limit defined by GetWindowSizeForHashChain (through WindowSize = 1 &lt;&lt; 20).
/// The lower 12 bits contain the length of the match.
/// </summary>
public uint[] OffsetLength { get; }
/// <summary>
/// Gets the size of the hash chain.
/// This is the maximum size of the hash_chain that can be constructed.
/// Typically this is the pixel count (width x height) for a given image.
/// </summary>

10
src/ImageSharp/Formats/WebP/Lossless/Vp8LHistogram.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.Collections.Generic;
@ -67,9 +67,6 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
this.IsUsed = new bool[5];
}
/// <inheritdoc/>
public IDeepCloneable DeepClone() => new Vp8LHistogram(this);
/// <summary>
/// Gets or sets the palette code bits.
/// </summary>
@ -109,6 +106,9 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
public bool[] IsUsed { get; }
/// <inheritdoc/>
public IDeepCloneable DeepClone() => new Vp8LHistogram(this);
/// <summary>
/// Collect all the references into a histogram (without reset).
/// </summary>

4
src/ImageSharp/Formats/WebP/Lossless/Vp8LLz77Type.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Formats.WebP.Lossless
{

4
src/ImageSharp/Formats/WebP/Lossless/Vp8LMultipliers.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Formats.WebP.Lossless
{

18
src/ImageSharp/Formats/WebP/Lossless/Vp8LRefsCursor.cs

@ -1,18 +0,0 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
namespace SixLabors.ImageSharp.Formats.WebP.Lossless
{
internal class Vp8LRefsCursor
{
public Vp8LRefsCursor(Vp8LBackwardRefs refs)
{
//this.Refs = refs;
//this.CurrentPos = 0;
}
//public PixOrCopy Refs { get; }
public PixOrCopy CurrentPos { get; }
}
}

8
src/ImageSharp/Formats/WebP/Lossless/Vp8LStreaks.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
namespace SixLabors.ImageSharp.Formats.WebP.Lossless
{
@ -17,12 +17,14 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossless
}
/// <summary>
/// Gets the streak count.
/// index: 0=zero streak, 1=non-zero streak.
/// </summary>
public int[] Counts { get; }
/// <summary>
/// [zero/non-zero][streak < 3 / streak >= 3].
/// Gets the streaks.
/// [zero/non-zero][streak &lt; 3 / streak >= 3].
/// </summary>
public int[][] Streaks { get; }

5
src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs

@ -22,7 +22,7 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossy
/// <summary>
/// A bit writer for writing lossy webp streams.
/// </summary>
private Vp8BitWriter bitWriter;
private readonly Vp8BitWriter bitWriter;
/// <summary>
/// Initializes a new instance of the <see cref="Vp8Encoder"/> class.
@ -34,7 +34,8 @@ namespace SixLabors.ImageSharp.Formats.WebP.Lossy
{
this.memoryAllocator = memoryAllocator;
// TODO: initialize bitwriter
// TODO: properly initialize the bitwriter
this.bitWriter = new Vp8BitWriter();
}
public void Encode<TPixel>(Image<TPixel> image, Stream stream)

12
src/ImageSharp/Formats/WebP/WebPCommonUtils.cs

@ -1,5 +1,5 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the GNU Affero General Public License, Version 3.
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System.Runtime.CompilerServices;
@ -8,9 +8,11 @@ namespace SixLabors.ImageSharp.Formats.WebP
/// <summary>
/// Utility methods for lossy and lossless webp format.
/// </summary>
public static class WebPCommonUtils
internal static class WebPCommonUtils
{
// Returns 31 ^ clz(n) = log2(n).Returns 31 ^ clz(n) = log2(n).
/// <summary>
/// Returns 31 ^ clz(n) = log2(n).Returns 31 ^ clz(n) = log2(n).
/// </summary>
[MethodImpl(InliningOptions.ShortMethod)]
public static int BitsLog2Floor(uint n)
{
@ -21,7 +23,7 @@ namespace SixLabors.ImageSharp.Formats.WebP
n >>= 8;
}
return logValue + WebPLookupTables.LogTable8bit[n];
return logValue + WebPLookupTables.LogTable8Bit[n];
}
}
}

5
src/ImageSharp/Formats/WebP/WebPLookupTables.cs

@ -236,7 +236,8 @@ namespace SixLabors.ImageSharp.Formats.WebP
0x40, 0x72, 0x7e, 0x61, 0x6f, 0x50, 0x71, 0x7f, 0x60, 0x70
};
public static readonly uint[] PlaneToCodeLut = {
public static readonly uint[] PlaneToCodeLut =
{
96, 73, 55, 39, 23, 13, 5, 1, 255, 255, 255, 255, 255, 255, 255, 255,
101, 78, 58, 42, 26, 16, 8, 2, 0, 3, 9, 17, 27, 43, 59, 79,
102, 86, 62, 46, 32, 20, 10, 6, 4, 7, 11, 21, 33, 47, 63, 87,
@ -248,7 +249,7 @@ namespace SixLabors.ImageSharp.Formats.WebP
};
// 31 ^ clz(i)
public static readonly byte[] LogTable8bit =
public static readonly byte[] LogTable8Bit =
{
0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,

Loading…
Cancel
Save