komakai / libjpeg-turbo

Main libjpeg-turbo repository
Other
2 stars 1 forks source link

A picture decode fail using "Low memory progressive JPEG decode" method... #2

Closed TWhaoli closed 8 years ago

TWhaoli commented 8 years ago

Thanks for the method, Low memory progressive JPEG decode, help me to do the more resolution picture decoding in my system. But a problem is that the 60x44prg.jpg(given in 60x44prg.zip) is decoded fail with error message "Corrupt JPEG data: bad Huffman code." And if I mark the config, LOWMEM_PROGRESSIVE_DECODE, it's success! Thanks Giles Payne for responsing my report. And hope the issue will make this method better.

60x44prg.zip

komakai commented 8 years ago

TWhaoli - thanks for reporting this. Please try pulling the latest commit and check if that solves the problem.

TWhaoli commented 8 years ago

Sorry, I don't know that which one is the latest commit. My system use the jpeg-6b library. And the final patch I use is the "low-memory-progressive-jpeg-decode-3.patch."

komakai commented 8 years ago

If you have git then you can get the fix doing: git clone https://github.com/komakai/libjpeg-turbo.git and then build from this repository.

Alternatively you can just apply these changes to your existing source: https://github.com/komakai/libjpeg-turbo/commit/1b6b792fb106782de8e888b43507b65c71bddd92 to test the fix.

TWhaoli commented 8 years ago

It's OK! Thanks for your help! I merge the changes you provided into my source can solve the problem. It means the file size is less than 4kb can't fill the buffer, so the decode data is got wrong?

komakai commented 8 years ago

It means the file size is less than 4kb can't fill the buffer, so the decode data is got wrong?

The problem happens when the first scan is less than 4kb from the start of the JPEG file. Usually this never happens because typical JPEG files have about 12-15kb of header data before the first scan.