Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
What did you do?
While writing a small app to decode and process the JPEG frames from webcams running in Motion-JPEG mode, I found that images from a Logitech C270 webcam failed to decode when using the
I isolated a frame that caused the decoder to fail and stepped through the decoding with a debugger and compared it to the part of the jpeg spec in F1.2.3 from https://www.w3.org/Graphics/JPEG/itu-t81.pdf#page=36&zoom=auto,-200,43.
Turns out the jpeg decoder doesn't handle
Here's an example frame from the stream:
And here's a play.golang.org link with a reproducer: https://play.golang.org/p/QTTKiHRfrLe
I've experimented with a fix in the handling of the rst marker in the
What did you expect to see?
Expected the frame to decode successfully as it is in other software like VLC and web browsers.
What did you see instead?
Does this issue reproduce with the latest release (go1.11.2)?
JPEG standard allows for stuffed bytes just before the reset markers in order to align bytes (refer to B 1, D 1.6, and F 1.2.3 of JPEG spec). Some JPEG encoders seem to use these even when byte alignment is not strictly necessary. This fix checks for and skips over the escaped stuffed byte. Fixes golang#28717
The patch in the OP looks plausible (although I'd like the comment to mention F1.2.3 in the spec), but we are deep in the release cycle (https://github.com/golang/go/wiki/Go-Release-Cycle) for Go 1.13. As it is not a regression, it will probably land in 1.14 at the earliest.
Sorry for the late reply. I can't remember why I didn't see the "CC @nigeltao" note earlier.