ladybird/Userland/Libraries/LibGfx/ImageFormats
Nico Weber 0711e9d749 LibGfx/WebPWriter: Use huffman compression
This implements some of basic webp compression: Huffman coding.
(The other parts of the basics are backreferences, and color cache
entries; and after that there are the four transforms -- predictor,
subtract green, color indexing, color.)

How much huffman coding helps depends on the input's entropy.
Constant-color channels are now encoded in constant space, but
otherwise a huffman code always needs at least one bit per symbol.
This means just huffman coding can at the very best reduce output
size to 1/8th of input size.

For three test input files:

sunset-retro.png (876K): 2.25M -> 2.02M
(helps fairly little; from 2.6x as big as the png input to 2.36x)

giphy.gif (184k): 11M -> 4.9M
(pretty decent, from 61x as big as the gif input to 27x as big)

7z7c.gif (11K): 775K -> 118K
(almost as good as possible an improvement for just huffman coding,
from 70x as big as the gif input to 10.7x as big)

No measurable encoding perf impact for encoding.

The code is pretty similar to Deflate.cpp in LibCompress, with just
enough differences that sharing code doesn't look like it's worth
it to me. I left comments outlining similarities.
2024-05-26 19:02:49 +02:00
..
ISOBMFF LibGfx/JPEG2000: Support jpx extended 'colr' boxes 2024-03-30 10:01:07 +01:00
AnimationWriter.cpp LibGfx/AnimationWriter: Survive animations with two identical frames 2024-05-22 06:41:47 -04:00
AnimationWriter.h LibGfx+animation: Only store changed pixels in animation frames 2024-05-14 13:43:03 -04:00
BMPLoader.cpp LibGfx/BMP: Clear alpha in palette entries 2024-03-05 21:27:41 +00:00
BMPLoader.h
BMPWriter.cpp Everywhere: Use east const in more places 2024-04-19 06:31:19 -04:00
BMPWriter.h
BooleanDecoder.cpp
BooleanDecoder.h
CCITTDecoder.cpp LibGfx/CCITT: Add PDF-specific options for CCITT3 1D 2024-03-19 12:22:28 +01:00
CCITTDecoder.h LibGfx/CCITT: Add PDF-specific options for CCITT3 1D 2024-03-19 12:22:28 +01:00
DDSLoader.cpp Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
DDSLoader.h
ExifOrientedBitmap.h LibGfx/ExifOrientedBitmap: Add support for CMYKBitmap 2024-01-24 22:16:22 -07:00
GIFLoader.cpp LibGfx/GIFLoader: Add more debug logging output 2024-05-22 06:41:47 -04:00
GIFLoader.h LibGfx/GIF: Add a spec link 2024-05-14 12:33:53 -06:00
GIFWriter.cpp LibGfx/GIF: Correctly write frames with a non-null position 2024-05-25 06:42:15 +01:00
GIFWriter.h LibGfx/GIF: Write the netscape extension block 2024-05-22 13:29:05 -04:00
ICOLoader.cpp LibGfx/ICO: Remove unused parameter 2024-02-14 06:56:03 +01:00
ICOLoader.h LibGfx/ICO: Remove unused parameter 2024-02-14 06:56:03 +01:00
ILBMLoader.cpp LibGfx/ILBMLoader: Properly display images with a bitplane mask 2024-01-18 13:59:17 +01:00
ILBMLoader.h
ImageDecoder.cpp LibGfx: Add the start of a JPEG2000 loader 2024-03-25 20:35:00 +01:00
ImageDecoder.h LibGfx+Fallout: Make ImageDecoder return ErrorOr 2024-03-07 11:20:06 -05:00
JBIG2Loader.cpp LibGfx: Explicitly cast literals to size_t in JBIG2Loader 2024-05-02 07:46:53 -06:00
JBIG2Loader.h LibGfx: Move QMArithmeticDecoder to its own file 2024-04-19 10:59:11 +02:00
JPEG2000Loader.cpp LibGfx/JPEG2000: Remove an incorrect VERIFY in TagTree construction 2024-04-28 01:12:20 +02:00
JPEG2000Loader.h LibGfx/JPEG2000: Implement tag trees 2024-04-16 00:40:16 +02:00
JPEGLoader.cpp LibGfx/JPEG: Add a comment to inverse_dct_8x8() 2024-03-23 09:40:29 +01:00
JPEGLoader.h LibGfx/JPEG: Expose the Exif metadata 2024-01-22 20:16:32 -07:00
JPEGShared.h
JPEGWriter.cpp LibGfx/JPEGWriter: Make it possible to write CMYKBitmaps 2024-02-02 07:19:18 +01:00
JPEGWriter.h LibGfx/JPEGWriter: Make it possible to write CMYKBitmaps 2024-02-02 07:19:18 +01:00
JPEGWriterTables.h
JPEGXLLoader.cpp LibGfx/ExifOrientedBitmap: Add support for CMYKBitmap 2024-01-24 22:16:22 -07:00
JPEGXLLoader.h
PAMLoader.cpp LibGfx/PNM: Remove unnecessary line 2024-01-26 14:53:33 +01:00
PAMLoader.h LibGFX/PAM: Allow reading CMYK .pam files 2024-01-26 07:36:53 +01:00
PBMLoader.cpp LibGfx/PNM: Remove unnecessary line 2024-01-26 14:53:33 +01:00
PBMLoader.h
PGMLoader.cpp LibGfx/PNM: Remove unnecessary line 2024-01-26 14:53:33 +01:00
PGMLoader.h
PNGLoader.cpp LibGfx/PNG: Read metadata from the eXIf chunk 2024-05-26 14:54:43 +01:00
PNGLoader.h LibGfx/PNG: Read metadata from the eXIf chunk 2024-05-26 14:54:43 +01:00
PNGShared.h
PNGWriter.cpp
PNGWriter.h
PortableFormatWriter.cpp
PortableFormatWriter.h
PortableImageLoaderCommon.h LibGfx/PNM: Remove two fixmes 2024-02-02 08:26:40 +00:00
PortableImageMapLoader.h LibGFX/PAM: Allow reading CMYK .pam files 2024-01-26 07:36:53 +01:00
PPMLoader.cpp LibGfx/PNM: Remove unnecessary line 2024-01-26 14:53:33 +01:00
PPMLoader.h
QMArithmeticDecoder.cpp LibGfx: Move QMArithmeticDecoder to its own file 2024-04-19 10:59:11 +02:00
QMArithmeticDecoder.h LibGfx: Add a comment to QMArithmeticDecoder.h 2024-04-19 10:59:11 +02:00
QOILoader.cpp
QOILoader.h
QOIWriter.cpp
QOIWriter.h
TGALoader.cpp LibGfx/TGA: Move a variable closer to its use 2024-03-08 08:38:31 +01:00
TGALoader.h LibGfx: Make validate_before_create() create a regular bool 2024-03-08 08:38:31 +01:00
TIFFLoader.cpp LibCompress: Rename LZWDecoder => LzwDecompressor 2024-05-14 12:33:53 -06:00
TIFFLoader.h LibGfx/TIFF: Add an alternative entry point to only request metadata 2024-01-22 20:16:32 -07:00
TinyVGLoader.cpp LibGfx: Simplify path storage and tidy up APIs 2024-03-18 07:09:37 +01:00
TinyVGLoader.h LibGfx+ImageViewer: Replace ImageDecoder::is_vector() with an enum 2024-01-10 09:39:00 +01:00
WebPLoader.cpp LibGfx/WebP: Split out ANMFChunk header data into ANMFChunkHeader 2024-05-16 08:06:50 +02:00
WebPLoader.h
WebPLoaderLossless.cpp LibGfx/WebP: Move kCodeLengthCodeOrder to WebPSharedLossless.h 2024-05-26 19:02:49 +02:00
WebPLoaderLossless.h
WebPLoaderLossy.cpp
WebPLoaderLossy.h
WebPLoaderLossyTables.h Everywhere: Use east const in more places 2024-04-19 06:31:19 -04:00
WebPShared.h LibGfx/WebP: Split out ANMFChunk header data into ANMFChunkHeader 2024-05-16 08:06:50 +02:00
WebPSharedLossless.cpp LibGfx+LibCompress: WebPWriter performance regression reduction 2024-05-20 13:17:34 -04:00
WebPSharedLossless.h LibGfx/WebP: Move kCodeLengthCodeOrder to WebPSharedLossless.h 2024-05-26 19:02:49 +02:00
WebPWriter.cpp LibGfx/WebPWriter: Minor cleanups 2024-05-20 13:17:34 -04:00
WebPWriter.h LibGfx: Move AnimationWriter to its own file 2024-05-14 13:43:03 -04:00
WebPWriterLossless.cpp LibGfx/WebPWriter: Use huffman compression 2024-05-26 19:02:49 +02:00
WebPWriterLossless.h LibGfx/WebPWriter: Move VP8L compression to WebPWriterLossless.{h,cpp} 2024-05-16 08:06:50 +02:00