首页 > 解决方案 > Fewer than 4 huffman tables in a JPEG file?

问题描述

So I've been attempting to write my own JPEG decoder (In Lua for the ROBLOX platform if that's of any use) and in every guide I find online, it always uses an example where the image has 4 distinct Huffman tables. 1 for DC Luminance, 1 for AC Luminance, 1 for DC Chrominance, and 1 for AC Chrominance. When this is the case, my decoder works fine and everything is happy and nice. However when trying to decode some random jpeg images off the internet, I find that a lot of them have fewer than 4 Huffman tables, and in these cases my decoder fails miserably. I've tried researching for if there are some standard Huffman tables I should use as defaults for when the other tables aren't present, or if I should instead use a duplicate of one of the tables as a replacement for the missing ones, but I have come up empty handed. Any help on the subject would be greatly appreciated, thank you!

标签: jpegdecode

解决方案


Okay so thank you to DaBler in explaining this to me in the comments on my original question, it was extremely helpful.

Apparently you can have multiple Huffman Tables under one DHT marker, which I did not know. I'll see if I can get it working and thank you for the help!


推荐阅读