Skip to content
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

Add jpeg transform module #22

Merged

Conversation

neslinesli93
Copy link
Contributor

Hi! Thanks for the awesome library!

I wanted to perform some jpeg transforms defined in transupp.h, but I noticed that while the transupp.c module was included with the turbojpeg_api feature, it included too much bloat and the functions/types definitions where missing from lib.rs.

So I went on and generated the bindings just for transupp.h, using:

bindgen vendor/transupp.h > generated/transupp.rs

Admittedly, it needed a bit of tweaking, in particular:

  1. Deal with THREAD_LOCAL, as explained in this issue as well
  2. Add #include "cdjpeg.h" in transupp.h

Then I cherry-picked the transform functions (and de-duped many functions and types that were already defined in lib.rs) and created transform.rs. I decided to create a new feature, called jpegtran, that enables this new file and that is a requirement for the old turbojpeg_api that still needs some fixing.

I've been able to succesfully use this branch to perform some basic jpeg transformation tasks, following the jpegtran.c file

This allows to take advantage of many transform
functions defined in `transupp.c` file.
This module basically expose some functions
that are used in the original `jpegtran`
utility module
So we can play with safely `bindgen`
neslinesli93 added a commit to neslinesli93/mozjpeg-wasm that referenced this pull request Jan 2, 2021
@kornelski
Copy link
Owner

Nice!

Can you remove layout tests from the bindgened file? The bindings are portable between 32 and 64 bit platforms, but the tests aren't.

@neslinesli93
Copy link
Contributor Author

Sorry, missed that!

I saw that inside lib.rs all the layout tests are under a cfg:

#[cfg(target_pointer_width = "32")]

Should I go and just remove the tests, or put them under that cfg flag?

@kornelski
Copy link
Owner

Yeah, you can put them behind appropriate cfg too (make sure it matches your current platform)

@kornelski kornelski merged commit 52bc40d into kornelski:master Jan 6, 2021
@kornelski
Copy link
Owner

Thank you

@neslinesli93 neslinesli93 deleted the feature/jpeg-transform-module branch January 6, 2021 18:59
@neslinesli93 neslinesli93 restored the feature/jpeg-transform-module branch January 6, 2021 18:59
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.

2 participants