Lettore e scrittore WebP di casa (C1, passo 4)

Il lettore WebP, scritto dalla RFC 9649 e dalla RFC 6386, prende il posto di
SkiaSharp per i WebP: VP8 con perdita, VP8L senza perdita, ALPH grezzo e
compresso con ogni filtro, VP8X con ICCP, EXIF e XMP, e di un'animazione il
primo fotogramma fuso sulla tela, con il numero dei fotogrammi. La facciata
ImageDecoder ora legge i WebP.

Contro i riferimenti di SkiaSharp i quattro WebP senza perdita coincidono byte
per byte; i quattro con perdita stanno fra 68,7 e 74,4 dB per canale, scarto
massimo 1, alfa esatta. File danneggiati, tagliati o fuori dai limiti si
rifiutano; i limiti si controllano prima di allocare.

Lo scrittore fa WebP senza perdita (tavolozza, sottrazione del verde,
predittore, trasformata del colore, LZ77, cache dei colori, Huffman) e il
formato esteso solo quando ci sono metadati: i 57 riferimenti tornano esatti e
pesano l'88% del PNG di casa. Niente componenti esterni.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-18 15:01:47 +01:00
1 parent 36196526bb
commit b4383a6110
21 files changed
+6637 -13

No files matched your search

+3 -1
View File
@@ -7,7 +7,7 @@ namespace Febe.Core.Codecs.Images;
public static class ImageDecoder
{
/// <summary>Whether Febe has a decoder for <paramref name="format"/>.</summary>
public static bool CanDecode(ImageFormat format) => format is ImageFormat.Png or ImageFormat.Jpeg or ImageFormat.Gif or ImageFormat.Bmp;
public static bool CanDecode(ImageFormat format) => format is ImageFormat.Png or ImageFormat.Jpeg or ImageFormat.Gif or ImageFormat.Bmp or ImageFormat.WebP;
/// <summary>Size, frames and metadata of an image, without decoding the pixels.</summary>
/// <exception cref="ImageFormatNotSupportedException">The format is not known or has no decoder yet.</exception>
@@ -19,6 +19,7 @@ public static class ImageDecoder
ImageFormat.Jpeg => JpegDecoder.Identify(data, limits),
ImageFormat.Gif => GifDecoder.Identify(data, limits),
ImageFormat.Bmp => BmpDecoder.Identify(data, limits),
ImageFormat.WebP => WebPDecoder.Identify(data, limits),
var other => throw NotSupported(other),
};
@@ -33,6 +34,7 @@ public static class ImageDecoder
ImageFormat.Jpeg => JpegDecoder.Decode(data, limits, pooled),
ImageFormat.Gif => GifDecoder.Decode(data, limits, pooled),
ImageFormat.Bmp => BmpDecoder.Decode(data, limits, pooled),
ImageFormat.WebP => WebPDecoder.Decode(data, limits, pooled),
var other => throw NotSupported(other),
};