Skip to content

Fix further loop filtering issues #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 29, 2025

Conversation

tristanphease
Copy link
Contributor

@tristanphease tristanphease commented Jun 29, 2025

From #148 a few images were still failing to match the libwebp output precisely so investigated and found 2 further issues:

  1. From the spec: https://datatracker.ietf.org/doc/html/rfc6386#section-15
    Note carefully that loop filtering must be skipped entirely if loop_filter_level at either the frame header level or macroblock override level is 0. In no case should the loop filter be run with a value of 0; it should instead be skipped.
    We are currently only checking if the final loop filter value is set to 0 then we skip loop filtering but if the frame has loop filter level set to 0 we should skip altogether. Therefore just return early if we detect that.
  2. We're not actually using the loop filter adjustments decoded in the frame header. The spec is a bit confusing here so just tried to match libwebp where if it's enabled we just add the first value. https://github.com/webmproject/libwebp/blob/85e098e58d3fb89fee93b09c6c4515dbc4593c46/src/dec/frame_dec.c#L295C1-L300C10
    edit: checked the spec's implementation and now it makes sense, we only use the first value since it matches the first frame of the vp8

After these changes, those images that were not matching now do in my local tests, so change the decoder tests to match exactly.

@tristanphease
Copy link
Contributor Author

Hey @Shnatsel would appreciate if you could run your tests again on all your images with this change, my method of checking the images isn't very clean.

@Shnatsel
Copy link
Member

Shnatsel commented Jun 29, 2025

With this change decoding is bit-exact with dwebp -nofancy on the entire corpus 🎉

@Shnatsel Shnatsel merged commit 604226e into image-rs:main Jun 29, 2025
7 checks passed
@tristanphease tristanphease deleted the further-loop-filtering-issues branch June 30, 2025 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants