Browse Source

Added docs & stylecop fixes

pull/1632/head
Dmitry Pentin 5 years ago
parent
commit
b9b853b523
  1. 10
      src/ImageSharp/Formats/Jpeg/Components/Encoder/YCbCrForwardConverter420{TPixel}.cs
  2. 23
      src/ImageSharp/Formats/Jpeg/Components/Encoder/YCbCrForwardConverter444{TPixel}.cs
  3. 2
      src/ImageSharp/Formats/Jpeg/Components/FastFloatingPointDCT.cs
  4. 5
      src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs
  5. 2
      tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs

10
src/ImageSharp/Formats/Jpeg/Components/Encoder/YCbCrForwardConverter420{TPixel}.cs

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System; using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
@ -66,13 +65,16 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
/// </summary> /// </summary>
private Span<Rgb24> rgbSpan; private Span<Rgb24> rgbSpan;
// TODO: docs /// <summary>
/// Sampled pixel buffer size
/// </summary>
private Size samplingAreaSize; private Size samplingAreaSize;
// TODO: docs /// <summary>
/// <see cref="Configuration"/> for internal operations
/// </summary>
private Configuration config; private Configuration config;
public YCbCrForwardConverter420(ImageFrame<TPixel> frame) public YCbCrForwardConverter420(ImageFrame<TPixel> frame)
{ {
// matrices would be filled during convert calls // matrices would be filled during convert calls

23
src/ImageSharp/Formats/Jpeg/Components/Encoder/YCbCrForwardConverter444{TPixel}.cs

@ -15,16 +15,21 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
internal ref struct YCbCrForwardConverter444<TPixel> internal ref struct YCbCrForwardConverter444<TPixel>
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
// TODO: docs /// <summary>
/// Number of pixels processed per single <see cref="Convert(int, int, ref RowOctet{TPixel})"/> call
/// </summary>
private const int PixelsPerSample = 8 * 8; private const int PixelsPerSample = 8 * 8;
// TODO: docs /// <summary>
/// Total byte size of processed pixels converted from TPixel to <see cref="Rgb24"/>
/// </summary>
private const int RgbSpanByteSize = PixelsPerSample * 3; private const int RgbSpanByteSize = PixelsPerSample * 3;
// TODO: docs /// <summary>
/// <see cref="Size"/> of sampling area from given frame pixel buffer
/// </summary>
private static readonly Size SampleSize = new Size(8, 8); private static readonly Size SampleSize = new Size(8, 8);
/// <summary> /// <summary>
/// The Y component /// The Y component
/// </summary> /// </summary>
@ -55,11 +60,15 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder
/// </summary> /// </summary>
private Span<Rgb24> rgbSpan; private Span<Rgb24> rgbSpan;
// TODO: docs /// <summary>
/// Sampled pixel buffer size
/// </summary>
private Size samplingAreaSize; private Size samplingAreaSize;
// TODO: docs /// <summary>
private readonly Configuration config; /// <see cref="Configuration"/> for internal operations
/// </summary>
private Configuration config;
public YCbCrForwardConverter444(ImageFrame<TPixel> frame) public YCbCrForwardConverter444(ImageFrame<TPixel> frame)
{ {

2
src/ImageSharp/Formats/Jpeg/Components/FastFloatingPointDCT.cs

@ -273,7 +273,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
/// <summary> /// <summary>
/// Apply floating point FDCT from src into dest /// Apply floating point FDCT from src into dest
/// </summary> /// </summary>
/// <remarks></remarks>
/// <param name="src">Source</param> /// <param name="src">Source</param>
/// <param name="dest">Destination</param> /// <param name="dest">Destination</param>
/// <param name="temp">Temporary block provided by the caller for optimization</param> /// <param name="temp">Temporary block provided by the caller for optimization</param>
@ -467,7 +466,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
Vector256<float> mb1 = Avx.Add(SimdUtils.HwIntrinsics.MultiplyAdd(mz1, my3, C_V_3_0727), mz2); Vector256<float> mb1 = Avx.Add(SimdUtils.HwIntrinsics.MultiplyAdd(mz1, my3, C_V_3_0727), mz2);
Vector256<float> mb0 = Avx.Add(SimdUtils.HwIntrinsics.MultiplyAdd(mz0, my1, C_V_1_5013), mz3); Vector256<float> mb0 = Avx.Add(SimdUtils.HwIntrinsics.MultiplyAdd(mz0, my1, C_V_1_5013), mz3);
Vector256<float> my2 = s.V2; Vector256<float> my2 = s.V2;
Vector256<float> my6 = s.V6; Vector256<float> my6 = s.V6;
mz4 = Avx.Multiply(Avx.Add(my2, my6), C_V_0_5411); mz4 = Avx.Multiply(Avx.Add(my2, my6), C_V_0_5411);

5
src/ImageSharp/Formats/Jpeg/JpegEncoderCore.cs

@ -5,14 +5,11 @@ using System;
using System.Buffers.Binary; using System.Buffers.Binary;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using SixLabors.ImageSharp.Common.Helpers; using SixLabors.ImageSharp.Common.Helpers;
using SixLabors.ImageSharp.Formats.Jpeg.Components; using SixLabors.ImageSharp.Formats.Jpeg.Components;
using SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder; using SixLabors.ImageSharp.Formats.Jpeg.Components.Decoder;
using SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder; using SixLabors.ImageSharp.Formats.Jpeg.Components.Encoder;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.Metadata; using SixLabors.ImageSharp.Metadata;
using SixLabors.ImageSharp.Metadata.Profiles.Exif; using SixLabors.ImageSharp.Metadata.Profiles.Exif;
using SixLabors.ImageSharp.Metadata.Profiles.Icc; using SixLabors.ImageSharp.Metadata.Profiles.Icc;
@ -69,7 +66,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
}; };
/// <summary> /// <summary>
/// A scratch buffer to reduce allocations. /// A scratch buffer to reduce allocations.
/// </summary> /// </summary>
@ -625,7 +621,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
private void WriteStartOfScan<TPixel>(Image<TPixel> image, int componentCount, CancellationToken cancellationToken) private void WriteStartOfScan<TPixel>(Image<TPixel> image, int componentCount, CancellationToken cancellationToken)
where TPixel : unmanaged, IPixel<TPixel> where TPixel : unmanaged, IPixel<TPixel>
{ {
// TODO: Need a JpegScanEncoder<TPixel> class or struct that encapsulates the scan-encoding implementation. (Similar to JpegScanDecoder.)
Span<byte> componentId = stackalloc byte[] Span<byte> componentId = stackalloc byte[]
{ {
0x01, 0x01,

2
tests/ImageSharp.Tests/Formats/Jpg/DCTTests.cs

@ -63,7 +63,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
this.CompareBlocks(expected, actual, 1f); this.CompareBlocks(expected, actual, 1f);
} }
// Inverse transform // Inverse transform
[Theory] [Theory]
[InlineData(1)] [InlineData(1)]
@ -182,7 +181,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
Assert.Equal(actualDest, expectedDest, new ApproximateFloatComparer(1f)); Assert.Equal(actualDest, expectedDest, new ApproximateFloatComparer(1f));
} }
// Forward transform // Forward transform
[Theory] [Theory]
[InlineData(1)] [InlineData(1)]

Loading…
Cancel
Save