From a99cc55082b05bf50ddd7a2c68b0ba070b9764b5 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Sun, 25 Aug 2024 15:27:05 -0400 Subject: [PATCH] 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> --- pkg/format/rtpmjpeg/encoder.go | 2 +- pkg/format/rtpmjpeg/header_jpeg.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/format/rtpmjpeg/encoder.go b/pkg/format/rtpmjpeg/encoder.go index 75ed46f6..49328451 100644 --- a/pkg/format/rtpmjpeg/encoder.go +++ b/pkg/format/rtpmjpeg/encoder.go @@ -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) } diff --git a/pkg/format/rtpmjpeg/header_jpeg.go b/pkg/format/rtpmjpeg/header_jpeg.go index 426b743b..37711144 100644 --- a/pkg/format/rtpmjpeg/header_jpeg.go +++ b/pkg/format/rtpmjpeg/header_jpeg.go @@ -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) }