-
Notifications
You must be signed in to change notification settings - Fork 89
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
Support for images not having huffman table #76
Comments
@codec-abc Please upload a sample file and I'll take a look at this. |
I did some reading and it seems that the JPEG standard define some huffman tables (Near the end of the page). I think that how GIMP, Firefox and Chrome are able to display those images. Moreover, it seems that usually most jpg uses these default tables, that's would explain why after pasting the tables from a random jpg it display without problem. I will test my hypothesis and post the result. |
@codec-abc Yes, it seems that it is valid for MJPEG frames to omit the huffman table and expect some default tables to be used. More info can be found here. I plan to add support for this behavior by detecting MJPEGs and falling back to these huffman tables if no others has been defined. Hopefully I'll have a patch for it during the week. |
I ran some test and indeed adding the default huffman tables when none are provided fix this edge case. You may want to look at my commit if you plan to fix this edge case. My fix seems a bit hackish so I am not doing a pull request but feel free to get the huffman tables from it if it's convenient for you. |
Hi,
I try to make use of this library to convert MJPG encoded frames to a format (RGB, RGBA or YUV) that can suite my needs for image processing . This is because on my Windows computer (and maybe others) the only webcam encoding that can provide (somewhat) high resolution with decent framerate is the MJPG one.
Anyway, I am using a modified version of Escapi which is a Rust library around some Windows API for Webcam capture (among other things). I managed to get the MJPG encoded frames buffer but while trying to decode them I got the following error:
After dumping a frame into a file on looking at it in an hex editor I can confirm that the file has no huffman table section. The Windows image viewer cannot open the file but GIMP manage to do it. Plus, inserting some huffman tables before the "start of scan" section from another random jpeg (found on the web) allow me to see it in the Windows image viewer and to decode it using this library. So I am no expert in JPG nor data compression/decompression but it seems that while my buffers are not strictly valid jpeg files because they lack huffman tables, there is a way to decode nonetheless them. Do you think you will be able to add support for this case?
By the way, I can provide some files if you want to take a look at the MJPG buffers.
The text was updated successfully, but these errors were encountered: