mjpeg: fix decoding and encoding JPEG types 1-63 (#605)

Type 0 corresponds to YUV 4:2:2. Since this header is passed directly to the JPEG header, no additional changes are necessary for support. See the type field here: https://datatracker.ietf.org/doc/html/rfc2435#section-4.1

Co-authored-by: aler9 <46489434+aler9@users.noreply.github.com>
This commit is contained in:
Kevin Wang
2024-08-25 15:27:05 -04:00
committed by GitHub
parent ff5bda0e67
commit a99cc55082
2 changed files with 2 additions and 2 deletions

View File

@@ -187,7 +187,7 @@ outer:
return nil, fmt.Errorf("SOF not found")
}
if sof.Type != 1 {
if sof.Type > 63 {
return nil, fmt.Errorf("JPEG type %d is not supported", sof.Type)
}

View File

@@ -22,7 +22,7 @@ func (h *headerJPEG) unmarshal(byts []byte) (int, error) {
h.FragmentOffset = uint32(byts[1])<<16 | uint32(byts[2])<<8 | uint32(byts[3])
h.Type = byts[4]
if h.Type != 1 {
if h.Type > 63 {
return 0, fmt.Errorf("type %d is not supported", h.Type)
}