‹ BackHN Continuity

Thread

Memory-Safe WebP Decoding

69 points · 28 comments · computerbuster

  1. omoikane · · focus · HN ↗
    I am not sure what's the current status of Wuffs-based WebP decoder, but that would be another implementation worth comparing since it shares the same goals of safety and speed.

    <a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;wuffs&#x2F;tree&#x2F;main&#x2F;std&#x2F;webp" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;wuffs&#x2F;tree&#x2F;main&#x2F;std&#x2F;webp

    1. computerbuster · · focus · HN ↗
      Thanks for the heads-up, I didn&#x27;t know wuffs had a WebP decoder. Just benchmarked it (b2e6da3), and wpd is about 2-3x faster on lossy stills, 5-7x faster on lossy with alpha, and 7-8x faster on lossless on my M5 Pro (even single-threaded).

      Also, wuffs is not bit-identical to libwebp, and animated WebP is completely unsupported, so I&#x27;m not sure it is a real option for WebP decoding.

      1. nigeltao · · focus · HN ↗
        Wuffs author here.

        We got a pull request (<a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;wuffs&#x2F;pull&#x2F;168" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;wuffs&#x2F;pull&#x2F;168) in February to add lossy WebP support. Lossless WebP (which in some sense is an entirely different format, just reusing the WebP &quot;brand&quot;) has had a Wuffs implementation for a couple of years now.

        Anyway, the PR included SIMD acceleration and performance was on par with libwebp (C code).

        The PR&#x27;s code was, as far as I could tell, somewhat or mostly AI assisted. While that&#x27;s great in terms of features, I still have more confidence in hand-crafted code.

        I have since been working to manually rewrite the PR. I&#x27;d also like to add animation support, and last month I landed some Wuffs tooling changes re animated PNG, to be better able to (as a comparison baseline) decode and test animated WebP.

        A lot of that manual rewrite has been committed, but the SIMD parts haven&#x27;t landed yet. So yes, for what&#x27;s on the main branch (not the PR), performance is not as good as libwebp yet, but landing the SIMD parts should fix that.

        &gt; wuffs is not bit-identical to libwebp

        That&#x27;s news to me. PR 168 says it produces pixel-identical output to libwebp. And what&#x27;s in the main branch aims to be pixel-identical, e.g. for YUV to RGB conversion, it implements libwebp&#x27;s formulae, not libjpeg&#x27;s formulae. Both use BT.601, but libwebp uses studio range and libjpeg uses full range.

        Can you link to some example .webp images that are not bit-identical?

        1. computerbuster · · focus · HN ↗
          Would love to help all implementations improve – would you be able to send Halide an email so we can take this offline? Happy to help if possible!
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.