Porting mozjpeg to Rust ($10k gig)

Alternatives to a complete rewrite:

It should be possible to refactor mozjpeg/libjpeg-turbo to use non-unwinding error handling. i.e. everywhere in the code where it does ERREXIT() change it to something like return -1 and ensure these return values are handled/forwarded correctly all the way up. The maintainer of libjpeg-turbo doesn't want such a widespread change, so it'd be a fork.

A less intrusive variant of this is to use C++ exceptions for unwinding and translate catch to error codes only on the highest level of the API.

Another option is to ignore the classic libjpeg API and use libjpeg-turbo API (which is a high-level wrapper on top of libjpeg API, uses setjmp/longjmp only internally, exposes error codes to the world). The downside is that it's a simple high-level API, so it probably won't satisfy advanced use-cases.

7 Likes