Browse Source

Split webp encoder into lossless and lossy

pull/1552/head
Brian Popow 6 years ago
parent
commit
7d34ceacc3
  1. 4
      src/ImageSharp/Formats/WebP/BitWriter/Vp8LBitWriter.cs
  2. 4
      src/ImageSharp/Formats/WebP/Lossless/DominantCostRange.cs
  3. 4
      src/ImageSharp/Formats/WebP/Lossless/HistogramEncoder.cs
  4. 1363
      src/ImageSharp/Formats/WebP/Lossless/Vp8LEncoder.cs
  5. 46
      src/ImageSharp/Formats/WebP/Lossy/Vp8Encoder.cs
  6. 15
      src/ImageSharp/Formats/WebP/WebPEncoder.cs
  7. 1361
      src/ImageSharp/Formats/WebP/WebPEncoderCore.cs

4
src/ImageSharp/Formats/WebP/BitWriter/Vp8LBitWriter.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.Buffers.Binary;

4
src/ImageSharp/Formats/WebP/Lossless/DominantCostRange.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/HistogramEncoder.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;

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

File diff suppressed because it is too large

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

@ -0,0 +1,46 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System;
using System.IO;
using SixLabors.ImageSharp.Formats.WebP.BitWriter;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Formats.WebP.Lossy
{
/// <summary>
/// Encoder for lossy webp images.
/// </summary>
internal class Vp8Encoder
{
/// <summary>
/// The <see cref="MemoryAllocator"/> to use for buffer allocations.
/// </summary>
private MemoryAllocator memoryAllocator;
/// <summary>
/// A bit writer for writing lossy webp streams.
/// </summary>
private Vp8BitWriter bitWriter;
/// <summary>
/// Initializes a new instance of the <see cref="Vp8Encoder"/> class.
/// </summary>
/// <param name="memoryAllocator">The memory allocator.</param>
/// <param name="width">The width of the input image.</param>
/// <param name="height">The height of the input image.</param>
public Vp8Encoder(MemoryAllocator memoryAllocator, int width, int height)
{
this.memoryAllocator = memoryAllocator;
// TODO: initialize bitwriter
}
public void Encode<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : unmanaged, IPixel<TPixel>
{
throw new NotImplementedException();
}
}
}

15
src/ImageSharp/Formats/WebP/WebPEncoder.cs

@ -1,14 +1,15 @@
// 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;
using System.Threading.Tasks;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp.Formats.WebP
{
/// <summary>
/// Image encoder for writing an image to a stream in the WebP format.
/// Image encoder for writing an image to a stream in the WebP format.
/// </summary>
public sealed class WebPEncoder : IImageEncoder, IWebPEncoderOptions
{
@ -34,5 +35,13 @@ namespace SixLabors.ImageSharp.Formats.WebP
var encoder = new WebPEncoderCore(this, image.GetMemoryAllocator());
encoder.Encode(image, stream);
}
/// <inheritdoc/>
public Task EncodeAsync<TPixel>(Image<TPixel> image, Stream stream)
where TPixel : unmanaged, IPixel<TPixel>
{
var encoder = new WebPEncoderCore(this, image.GetMemoryAllocator());
return encoder.EncodeAsync(image, stream);
}
}
}

1361
src/ImageSharp/Formats/WebP/WebPEncoderCore.cs

File diff suppressed because it is too large
Loading…
Cancel
Save