From 323cc185dc845d975f4b7a92f8bbde879b4a756e Mon Sep 17 00:00:00 2001 From: Saxon Date: Thu, 2 Jan 2020 11:20:21 +1030 Subject: [PATCH] codec/mjpeg/jpeg.go: defining consts for SOS header fields --- codec/mjpeg/jpeg.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/codec/mjpeg/jpeg.go b/codec/mjpeg/jpeg.go index 41ae5489..1cd7b92b 100644 --- a/codec/mjpeg/jpeg.go +++ b/codec/mjpeg/jpeg.go @@ -71,13 +71,19 @@ const ( jfifHeadLen = 16 // Length of JFIF header segment excluding APP0 marker. ) -// SOF0 (start of scan) header fields. +// SOF0 (start of frame) header fields. const ( sofLen = 17 sofPrecision = 8 sofNoOfComponents = 3 ) +// SOS (start of scan) header fields. +const ( + sosLen = 12 + sosComponentsInScan = 3 +) + var ( errNoQTable = errors.New("no quantization table") errReservedQ = errors.New("q value is reserved") @@ -360,8 +366,10 @@ func writeHeader(p *putBuffer, _type, width, height, nbqTab, dri int, qtable []b // Write start of scan. mark(p, codeSOS) - p.put16(12) - p.put8(3) + p.put16(sosLen) + p.put8(sosComponentsInScan) + + // TODO: find out what remaining fields are. p.put8(1) p.put8(0) p.put8(2)