Browse Source

test Ycck as well ..

pull/322/head
Anton Firszov 9 years ago
parent
commit
61e39c7350
  1. 16
      src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigComponent.cs
  2. 13
      src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/SubsampleRatio.cs
  3. 10
      src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs
  4. 7
      tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs
  5. 2
      tests/Images/External

16
src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/OrigComponent.cs

@ -7,6 +7,8 @@ using SixLabors.ImageSharp.Memory;
namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
{
using SixLabors.Primitives;
/// <summary>
/// Represents a single color component
/// </summary>
@ -222,6 +224,20 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
this.VerticalSamplingFactor = v;
}
public Size CalculateJpegChannelSize(SubsampleRatio ratio)
{
Size size = new Size(this.WidthInBlocks, this.HeightInBlocks) * 8;
if (this.Index > 0 && this.Index < 3) // Chroma component:
{
return ratio.CalculateChrominanceSize(size.Width, size.Height);
}
else
{
return size;
}
}
public void Dispose()
{
this.SpectralBlocks.Dispose();

13
src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/SubsampleRatio.cs

@ -1,11 +1,10 @@
namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
{
using System.Collections.Generic;
using System.Linq;
using SixLabors.ImageSharp.Formats.Jpeg.Common;
using SixLabors.Primitives;
using System.Collections.Generic;
using System.Linq;
using SixLabors.ImageSharp.Formats.Jpeg.Common;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder
{
/// <summary>
/// Provides enumeration of the various available subsample ratios.
/// https://en.wikipedia.org/wiki/Chroma_subsampling

10
src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs

@ -203,10 +203,10 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort
where TPixel : struct, IPixel<TPixel>
{
this.ParseStream(stream);
this.ProcessBlocksIntoJpegImageChannels<TPixel>();
Image<TPixel> image = this.ConvertJpegPixelsToImagePixels<TPixel>();
return image;
this.ProcessBlocksIntoJpegImageChannels();
return this.ConvertJpegPixelsToImagePixels<TPixel>();
}
/// <inheritdoc />
@ -464,9 +464,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort
/// <see cref="OrigComponent.SpectralBlocks"/> are in a "raw" frequency-domain form. We need to apply IDCT, dequantization and unzigging to transform them into color-space blocks.
/// We can copy these blocks into <see cref="OrigJpegPixelArea"/>-s afterwards.
/// </summary>
/// <typeparam name="TPixel">The pixel type</typeparam>
private void ProcessBlocksIntoJpegImageChannels<TPixel>()
where TPixel : struct, IPixel<TPixel>
private void ProcessBlocksIntoJpegImageChannels()
{
this.InitJpegImageChannels();

7
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs

@ -24,8 +24,11 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
{
public static string[] BaselineTestJpegs =
{
TestImages.Jpeg.Baseline.Calliphora, TestImages.Jpeg.Baseline.Cmyk,
TestImages.Jpeg.Baseline.Jpeg400, TestImages.Jpeg.Baseline.Jpeg444,
TestImages.Jpeg.Baseline.Calliphora,
TestImages.Jpeg.Baseline.Cmyk,
TestImages.Jpeg.Baseline.Ycck,
TestImages.Jpeg.Baseline.Jpeg400,
TestImages.Jpeg.Baseline.Jpeg444,
TestImages.Jpeg.Baseline.Testimgorig,
TestImages.Jpeg.Baseline.Bad.BadEOF,
TestImages.Jpeg.Baseline.Bad.ExifUndefType,

2
tests/Images/External

@ -1 +1 @@
Subproject commit 3b80ee0684fedab0f5798eea5c5ed7b75cbff714
Subproject commit 2f6b226b9fbaf8b23808755bd7e7752a0560644e
Loading…
Cancel
Save