mirror of https://github.com/SixLabors/ImageSharp
12 changed files with 737 additions and 43 deletions
@ -0,0 +1,26 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the GNU Affero General Public License, Version 3.
|
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Formats.WebP.Lossless |
||||
|
{ |
||||
|
internal class Vp8LStreaks |
||||
|
{ |
||||
|
public Vp8LStreaks() |
||||
|
{ |
||||
|
this.Counts = new int[2]; |
||||
|
this.Streaks = new int[2][]; |
||||
|
this.Streaks[0] = new int[2]; |
||||
|
this.Streaks[1] = new int[2]; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// index: 0=zero streak, 1=non-zero streak.
|
||||
|
/// </summary>
|
||||
|
public int[] Counts { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// [zero/non-zero][streak < 3 / streak >= 3].
|
||||
|
/// </summary>
|
||||
|
public int[][] Streaks { get; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the GNU Affero General Public License, Version 3.
|
||||
|
|
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Formats.WebP |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Utility methods for lossy and lossless webp format.
|
||||
|
/// </summary>
|
||||
|
public static class WebPCommonUtils |
||||
|
{ |
||||
|
// Returns 31 ^ clz(n) = log2(n).Returns 31 ^ clz(n) = log2(n).
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
public static int BitsLog2Floor(uint n) |
||||
|
{ |
||||
|
int logValue = 0; |
||||
|
while (n >= 256) |
||||
|
{ |
||||
|
logValue += 8; |
||||
|
n >>= 8; |
||||
|
} |
||||
|
|
||||
|
return logValue + WebPLookupTables.LogTable8bit[n]; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue