toojpeg
toojpeg copied to clipboard
Support for YUVU source images
Hi, Thank you for your library. I needed to create a JPEG image from an YUVU image in memory, directly, without the overhead of transcoding in RGB back and forth. I Tryed to keep the modifications to your clean and nice code as little as possible... take a look and see if could be useful to others. Not extensively tested, at the moment.
Thanks for your contribution ! Currently I’m on a vacation and will take a look at your code when I come back home (mid-May). At first glance it’ll probably make sense to support YUV444 (input) as well. Have a nice day, Stephan
Wow! I thought no one would care to encode JPEG directly from YUV444 or YUV420 buffer.
I do have a similar patch to support YUV420 buffer input with custom padding/stride between Y colorspace and UV colorspace. I will prepare a PR then.
By the way, @stbrumme, could you suggest a best practice to pass the following info to the toojpeg API?
- 8-bit U and V values needs an offset prior to JPEG compression, i.e.
uint8_t corrected_U[i][j] = uint8_t(U[i][j]) - 128
- "horizontal" / "vertical" paddings, as shown in the illustration below; and
Edit: There is a very similar question at https://github.com/stbrumme/toojpeg/issues/5.
+-------------------------------------------+
|-------------------------------+ |
|| | |
|| | |
|| Y space | right |
|| | padding |
|| | for |
|| | alignment|
+-------------------------------+ |
| padding between Y and UV |
| |
+-------------------------------+ |
|| UV space | |
|| | |
|-------------------------------+ |
+-------------------------------------------+