JFLib

img_webp#

WebP -- crate root lib/img_webp/lib.rs

img_webp -- WebP: VP8 (lossy) and VP8L (lossless) decoder and encoders
                               [src/img/webp.s, webp_vp8.s, webp_vp8l.s, webp_vp8_enc.s, webp_vp8l_enc.s]

  CODEC                         the IMGCODEC descriptor (probe, decode, encode, caps, iom)
  container::{probe, decode, encode, enc_alpha, parse, alpha}   webp.s
  vp8l::{decode, decode_alpha, build_table}                     webp_vp8l.s
  vp8::{decode, itx, itx_dc, wht, yuv_rgb}                      webp_vp8.s
  vp8l_enc::{encode, enc_argb}                                  webp_vp8l_enc.s
  vp8_enc::{encode, enc_argb}                                   webp_vp8_enc.s
  Cfg                           the WEBPENC record of the encoders (effort, quality,
                                flags WEF_*, preset WPP_*, cancel flag)

Modules: container (RIFF walk, metadata, ALPH, the file writer), vp8l (lossless
decoder), vp8 (lossy decoder), vp8l_enc, vp8_enc (encoders), tab (the big tables,
generated by tools/gen_webp_tab.py).  No worker threads: the assembly uses none.

img_webp API#

WebP encoder options (img.inc CE)

IO_WEBPPRESET: usize = 36  // ImgOpt field (the IO_DDSFMT slot; ImgOpt::ddsfmt)
IOM_PRESET: u32 = 1 << 19  // the preset is honoured
WPP_DEFAULT: u32 = 0  // paint.net "Standard" (libwebp WEBP_PRESET_DEFAULT)
WPP_PICTURE: u32 = 1
WPP_PHOTO: u32 = 2
WPP_DRAWING: u32 = 3
WPP_ICON: u32 = 4
WPP_TEXT: u32 = 5
IOF_WEBP_NOEXACT: u32 = 0x20000  // RGB under alpha 0 may change (default: kept exactly)
IOF_WEBP_SHARPYUV: u32 = 0x40000  // lossy: sharp RGB -> YUV 4:2:0
IOF_WEBP_1THREAD: u32 = 0x80000  // accepted, no effect: the encoder runs on the calling thread
// WEBPENC flags (Cfg::flags)
WEF_NOEXACT: u32 = 1
WEF_NOHDR: u32 = 2  // VP8L: header-less stream (ALPH chunk)
WEF_1THREAD: u32 = 4  // accepted, no effect (no worker threads)
WEF_SHARPYUV: u32 = 8
// test-only flags (codectest ops 126..128): force a configuration / predictor mode, switch
// off stages
WEF_T_CFG_SHIFT: u32 = 8  // 4 bits: VP8L configuration + 1 (0 = automatic)
WEF_T_NOCROSS: u32 = 0x1000
WEF_T_DUMPM: u32 = 0x2000  // return the main image's match array (u32 dist | (len - 1) << 20)
WEF_T_MODE_SHIFT: u32 = 16  // 4 bits: predictor mode + 1 for every tile
WEF_T_NOCACHE: u32 = 0x10_0000
WEF_T_NOMETA: u32 = 0x20_0000
WEF_T_NODP: u32 = 0x40_0000
WEF_T_NOGREEDY: u32 = 0x80_0000
WEF_T_NORLE: u32 = 0x100_0000
WEF_T_KEEPDP: u32 = 0x200_0000
WEF_T_CACHE_SHIFT: u32 = 26  // 4 bits: colour cache bits + 1 (0 = estimate)
WEF_T_REPORT: u32 = 0x4000_0000  // return 0x1000000 + (cache bits | groups << 8), no stream
  • struct Cfg<'a> the WEBPENC record (WE_*): effort 1..9 (0 = 5), lossy quality 0..100 (0 = 95), WEF_* flags, WPP_* preset, cancel flag
    • effort: u32
    • quality: u32
    • flags: u32
    • preset: u32
    • cancel: Option<&'a AtomicU32>

impl Cfg<'_>

  • fn cancelled(&self) -> bool

  • static CODEC: Codec the codec descriptor [webp_codec]

img_webp modules#

The codec's building blocks (public for the codec test app codectest; see their source headers):

ModuleContent
img_webp::containerWebP container (RIFF "WEBP") reader and writer: simple VP8 / VP8L, extended VP8X (ALPH, ICCP, EXIF, XMP, ANIM / ANMF)
img_webp::tabthe big lookup tables of the WebP codec, generated by tools/gen_webp_tab.py from the .rodata of ASMLIB/src/img/webp_vp8.s and webp_vp8_enc.s (do not edit by ...
img_webp::vp8WebP lossy (VP8 key frame) decoder, bit-exact with libwebp 1.3
img_webp::vp8_encWebP lossy (VP8 key frame) encoder
img_webp::vp8lWebP lossless (VP8L) bitstream decoder, bit-exact with libwebp 1.3
img_webp::vp8l_encWebP lossless (VP8L) encoder

Source: docs/API.md in the JFLib repository.