support decoding M-JPEG streams with any quantization (#566) (#583)

This commit is contained in:
Alessandro Ros
2024-06-22 23:32:31 +02:00
committed by GitHub
parent 3ee5fbdcf7
commit 4750375772
6 changed files with 198 additions and 19 deletions

View File

@@ -23,12 +23,13 @@ func (h *headerJPEG) unmarshal(byts []byte) (int, error) {
h.Type = byts[4]
if h.Type != 1 {
return 0, fmt.Errorf("Type %d is not supported", h.Type)
return 0, fmt.Errorf("type %d is not supported", h.Type)
}
h.Quantization = byts[5]
if h.Quantization != 255 {
return 0, fmt.Errorf("Q %d is not supported", h.Quantization)
if h.Quantization == 0 ||
(h.Quantization > 99 && h.Quantization < 127) {
return 0, fmt.Errorf("quantization %d is invalid", h.Quantization)
}
h.Width = int(byts[6]) * 8