Browse Source

Merge branch 'main' into bp/arithmeticcoding

pull/2073/head
Brian Popow 4 years ago
committed by GitHub
parent
commit
5ed690da94
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs
  2. 11
      src/ImageSharp/Formats/Webp/Lossy/Vp8Matrix.cs

5
src/ImageSharp/Formats/Webp/Lossy/QuantEnc.cs

@ -16,8 +16,6 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy
/// </summary>
internal static unsafe class QuantEnc
{
private static readonly byte[] Zigzag = { 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15 };
private static readonly ushort[] WeightY = { 38, 32, 20, 9, 32, 28, 17, 7, 20, 17, 10, 4, 9, 7, 4, 2 };
private const int MaxLevel = 2047;
@ -47,6 +45,9 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy
private const int DSHIFT = 4;
private const int DSCALE = 1; // storage descaling, needed to make the error fit byte
// This uses C#'s optimization to refer to the static data segment of the assembly, no allocation occurs.
private static ReadOnlySpan<byte> Zigzag => new byte[] { 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15 };
public static void PickBestIntra16(Vp8EncIterator it, ref Vp8ModeScore rd, Vp8SegmentInfo[] segmentInfos, Vp8EncProba proba)
{
const int numBlocks = 16;

11
src/ImageSharp/Formats/Webp/Lossy/Vp8Matrix.cs

@ -1,6 +1,8 @@
// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System;
namespace SixLabors.ImageSharp.Formats.Webp.Lossy
{
internal unsafe struct Vp8Matrix
@ -13,10 +15,6 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy
new[] { 110, 115 }
};
// Sharpening by (slightly) raising the hi-frequency coeffs.
// Hack-ish but helpful for mid-bitrate range. Use with care.
private static readonly byte[] FreqSharpening = { 0, 30, 60, 90, 30, 60, 90, 90, 60, 90, 90, 90, 90, 90, 90, 90 };
/// <summary>
/// Number of descaling bits for sharpening bias.
/// </summary>
@ -47,6 +45,11 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossy
/// </summary>
public fixed short Sharpen[16];
// Sharpening by (slightly) raising the hi-frequency coeffs.
// Hack-ish but helpful for mid-bitrate range. Use with care.
// This uses C#'s optimization to refer to the static data segment of the assembly, no allocation occurs.
private static ReadOnlySpan<byte> FreqSharpening => new byte[] { 0, 30, 60, 90, 30, 60, 90, 90, 60, 90, 90, 90, 90, 90, 90, 90 };
/// <summary>
/// Returns the average quantizer.
/// </summary>

Loading…
Cancel
Save