Skip to content

Commit bd2d455

Browse files
committed
refactor to follow style rules
1 parent dbb8960 commit bd2d455

22 files changed

+99
-149
lines changed

src/ImageSharp/Formats/Webp/AlphaDecoder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public AlphaDecoder(int width, int height, IMemoryOwner<byte> data, byte alphaCh
5959

6060
if (this.Compressed)
6161
{
62-
Vp8LBitReader bitReader = new(data);
62+
Vp8LBitReader bitReader = new Vp8LBitReader(data);
6363
this.LosslessDecoder = new WebpLosslessDecoder(bitReader, memoryAllocator, configuration);
6464
this.LosslessDecoder.DecodeImageStream(this.Vp8LDec, width, height, true);
6565

src/ImageSharp/Formats/Webp/AlphaEncoder.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,8 @@ public static IMemoryOwner<byte> EncodeAlpha<TPixel>(
4343
{
4444
const WebpEncodingMethod effort = WebpEncodingMethod.Default;
4545
const int quality = 8 * (int)effort;
46-
using Vp8LEncoder lossLessEncoder = new(
47-
memoryAllocator,
48-
configuration,
49-
width,
50-
height,
51-
quality,
52-
skipMetadata,
53-
effort,
54-
WebpTransparentColorMode.Preserve,
55-
false,
56-
0);
46+
using Vp8LEncoder lossLessEncoder = new Vp8LEncoder(memoryAllocator, configuration, width, height, quality,
47+
skipMetadata, effort, WebpTransparentColorMode.Preserve, false, 0);
5748

5849
// The transparency information will be stored in the green channel of the ARGB quadruplet.
5950
// The green channel is allowed extra transformation steps in the specification -- unlike the other channels,
@@ -81,7 +72,7 @@ private static ImageFrame<Rgba32> DispatchAlphaToGreen<TPixel>(ImageFrame<TPixel
8172
{
8273
int width = frame.Width;
8374
int height = frame.Height;
84-
ImageFrame<Rgba32> alphaAsFrame = new(Configuration.Default, width, height);
75+
ImageFrame<Rgba32> alphaAsFrame = new ImageFrame<Rgba32>(Configuration.Default, width, height);
8576

8677
for (int y = 0; y < height; y++)
8778
{
@@ -91,7 +82,7 @@ private static ImageFrame<Rgba32> DispatchAlphaToGreen<TPixel>(ImageFrame<TPixel
9182
for (int x = 0; x < width; x++)
9283
{
9384
// Leave A/R/B channels zero'd.
94-
pixelRow[x] = new(0, alphaRow[x], 0, 0);
85+
pixelRow[x] = new Rgba32(0, alphaRow[x], 0, 0);
9586
}
9687
}
9788

src/ImageSharp/Formats/Webp/AnimationFrameData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static AnimationFrameData Parse(BufferedReadStream stream)
6262
{
6363
Span<byte> buffer = stackalloc byte[4];
6464

65-
AnimationFrameData data = new()
65+
AnimationFrameData data = new AnimationFrameData
6666
{
6767
DataSize = WebpChunkParsingUtils.ReadChunkSize(stream, buffer),
6868

src/ImageSharp/Formats/Webp/BitWriter/Vp8BitWriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ public override void WriteEncodedImageToStream(Stream stream)
399399
int mbSize = this.enc.Mbw * this.enc.Mbh;
400400
int expectedSize = (int)((uint)mbSize * 7 / 8);
401401

402-
Vp8BitWriter bitWriterPartZero = new(expectedSize, this.enc);
402+
Vp8BitWriter bitWriterPartZero = new Vp8BitWriter(expectedSize, this.enc);
403403

404404
// Partition #0 with header and partition sizes.
405405
uint size0 = bitWriterPartZero.GeneratePartition0();
@@ -545,7 +545,7 @@ private void WriteProbas()
545545
// Writes the partition #0 modes (that is: all intra modes)
546546
private void CodeIntraModes()
547547
{
548-
Vp8EncIterator it = new(this.enc);
548+
Vp8EncIterator it = new Vp8EncIterator(this.enc);
549549
int predsWidth = this.enc.PredsWidth;
550550

551551
do

src/ImageSharp/Formats/Webp/BitWriter/Vp8LBitWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public Vp8LBitWriter Clone()
102102
{
103103
byte[] clonedBuffer = new byte[this.Buffer.Length];
104104
System.Buffer.BlockCopy(this.Buffer, 0, clonedBuffer, 0, this.cur);
105-
return new(clonedBuffer, this.bits, this.used, this.cur);
105+
return new Vp8LBitWriter(clonedBuffer, this.bits, this.used, this.cur);
106106
}
107107

108108
/// <inheritdoc/>

src/ImageSharp/Formats/Webp/Lossless/BackwardReferenceEncoder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ private static void BackwardReferencesRle(int xSize, int ySize, ReadOnlySpan<uin
775775
private static void BackwardRefsWithLocalCache(ReadOnlySpan<uint> bgra, int cacheBits, Vp8LBackwardRefs refs)
776776
{
777777
int pixelIndex = 0;
778-
ColorCache colorCache = new(cacheBits);
778+
ColorCache colorCache = new ColorCache(cacheBits);
779779
for (int idx = 0; idx < refs.Refs.Count; idx++)
780780
{
781781
PixOrCopy v = refs.Refs[idx];

src/ImageSharp/Formats/Webp/Lossless/CostManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal sealed class CostManager : IDisposable
1717

1818
private const int FreeIntervalsStartCount = 25;
1919

20-
private readonly Stack<CostInterval> freeIntervals = new(FreeIntervalsStartCount);
20+
private readonly Stack<CostInterval> freeIntervals = new Stack<CostInterval>(FreeIntervalsStartCount);
2121

2222
public CostManager(MemoryAllocator memoryAllocator, IMemoryOwner<ushort> distArray, int pixCount, CostModel costModel)
2323
{

src/ImageSharp/Formats/Webp/Lossless/PixOrCopy.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,23 @@ internal sealed class PixOrCopy
1515
public uint BgraOrDistance { get; set; }
1616

1717
public static PixOrCopy CreateCacheIdx(int idx) =>
18-
new()
18+
new PixOrCopy
1919
{
2020
Mode = PixOrCopyMode.CacheIdx,
2121
BgraOrDistance = (uint)idx,
2222
Len = 1
2323
};
2424

2525
public static PixOrCopy CreateLiteral(uint bgra) =>
26-
new()
26+
new PixOrCopy
2727
{
2828
Mode = PixOrCopyMode.Literal,
2929
BgraOrDistance = bgra,
3030
Len = 1
3131
};
3232

33-
public static PixOrCopy CreateCopy(uint distance, ushort len) => new()
33+
public static PixOrCopy CreateCopy(uint distance, ushort len) =>
34+
new PixOrCopy
3435
{
3536
Mode = PixOrCopyMode.Copy,
3637
BgraOrDistance = distance,

src/ImageSharp/Formats/Webp/Lossless/Vp8LEncoder.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public void Encode<TPixel>(ImageFrame<TPixel> frame, Stream stream, bool hasAnim
304304

305305
if (hasAnimation)
306306
{
307-
prevPosition = BitWriterBase.WriteAnimationFrame(stream, new()
307+
prevPosition = BitWriterBase.WriteAnimationFrame(stream, new AnimationFrameData
308308
{
309309
Width = (uint)frame.Width,
310310
Height = (uint)frame.Height,
@@ -547,7 +547,7 @@ private CrunchConfig[] EncoderAnalyze(ReadOnlySpan<uint> bgra, int width, int he
547547
EntropyIx entropyIdx = this.AnalyzeEntropy(bgra, width, height, usePalette, this.PaletteSize, this.TransformBits, out redAndBlueAlwaysZero);
548548

549549
bool doNotCache = false;
550-
List<CrunchConfig> crunchConfigs = new();
550+
List<CrunchConfig> crunchConfigs = new List<CrunchConfig>();
551551

552552
if (this.method == WebpEncodingMethod.BestQuality && this.quality == 100)
553553
{
@@ -641,8 +641,8 @@ private void EncodeImage(int width, int height, bool useCache, CrunchConfig conf
641641
Vp8LBackwardRefs refsTmp = this.Refs[refsBest.Equals(this.Refs[0]) ? 1 : 0];
642642

643643
this.bitWriter.Reset(bwInit);
644-
Vp8LHistogram tmpHisto = new(cacheBits);
645-
List<Vp8LHistogram> histogramImage = new(histogramImageXySize);
644+
Vp8LHistogram tmpHisto = new Vp8LHistogram(cacheBits);
645+
List<Vp8LHistogram> histogramImage = new List<Vp8LHistogram>(histogramImageXySize);
646646
for (int i = 0; i < histogramImageXySize; i++)
647647
{
648648
histogramImage.Add(new Vp8LHistogram(cacheBits));
@@ -839,9 +839,9 @@ private void EncodeImageNoHuffman(Span<uint> bgra, Vp8LHashChain hashChain, Vp8L
839839
refsTmp1,
840840
refsTmp2);
841841

842-
List<Vp8LHistogram> histogramImage = new()
842+
List<Vp8LHistogram> histogramImage = new List<Vp8LHistogram>
843843
{
844-
new(cacheBits)
844+
new Vp8LHistogram(cacheBits)
845845
};
846846

847847
// Build histogram image and symbols from backward references.
@@ -941,7 +941,7 @@ private void StoreFullHuffmanCode(Span<HuffmanTree> huffTree, HuffmanTreeToken[]
941941
int i;
942942
byte[] codeLengthBitDepth = new byte[WebpConstants.CodeLengthCodes];
943943
short[] codeLengthBitDepthSymbols = new short[WebpConstants.CodeLengthCodes];
944-
HuffmanTreeCode huffmanCode = new()
944+
HuffmanTreeCode huffmanCode = new HuffmanTreeCode
945945
{
946946
NumSymbols = WebpConstants.CodeLengthCodes,
947947
CodeLengths = codeLengthBitDepth,
@@ -1192,7 +1192,7 @@ private EntropyIx AnalyzeEntropy(ReadOnlySpan<uint> bgra, int width, int height,
11921192
histo[(int)HistoIx.HistoBluePred * 256]++;
11931193
histo[(int)HistoIx.HistoAlphaPred * 256]++;
11941194

1195-
Vp8LBitEntropy bitEntropy = new();
1195+
Vp8LBitEntropy bitEntropy = new Vp8LBitEntropy();
11961196
for (int j = 0; j < (int)HistoIx.HistoTotal; j++)
11971197
{
11981198
bitEntropy.Init();
@@ -1318,7 +1318,7 @@ private bool AnalyzeAndCreatePalette(ReadOnlySpan<uint> bgra, int width, int hei
13181318
/// <returns>The number of palette entries.</returns>
13191319
private static int GetColorPalette(ReadOnlySpan<uint> bgra, int width, int height, Span<uint> palette)
13201320
{
1321-
HashSet<uint> colors = new();
1321+
HashSet<uint> colors = new HashSet<uint>();
13221322
for (int y = 0; y < height; y++)
13231323
{
13241324
ReadOnlySpan<uint> bgraRow = bgra.Slice(y * width, width);

src/ImageSharp/Formats/Webp/Lossless/WebpLosslessDecoder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public WebpLosslessDecoder(Vp8LBitReader bitReader, MemoryAllocator memoryAlloca
9595
public void Decode<TPixel>(Buffer2D<TPixel> pixels, int width, int height)
9696
where TPixel : unmanaged, IPixel<TPixel>
9797
{
98-
using (Vp8LDecoder decoder = new(width, height, this.memoryAllocator))
98+
using (Vp8LDecoder decoder = new Vp8LDecoder(width, height, this.memoryAllocator))
9999
{
100100
this.DecodeImageStream(decoder, width, height, true);
101101
this.DecodeImageData(decoder, decoder.Pixels.Memory.Span);
@@ -616,7 +616,7 @@ private void ReadHuffmanCodeLengths(Span<HuffmanCode> table, int[] codeLengthCod
616616
private void ReadTransformation(int xSize, int ySize, Vp8LDecoder decoder)
617617
{
618618
Vp8LTransformType transformType = (Vp8LTransformType)this.bitReader.ReadValue(2);
619-
Vp8LTransform transform = new(transformType, xSize, ySize);
619+
Vp8LTransform transform = new Vp8LTransform(transformType, xSize, ySize);
620620

621621
// Each transform is allowed to be used only once.
622622
foreach (Vp8LTransform decoderTransform in decoder.Transforms)

0 commit comments

Comments
 (0)