From 6bdfdb1f2a01e2e7c856eac9c74ae113e92803c1 Mon Sep 17 00:00:00 2001 From: Saxon Date: Wed, 1 Jan 2020 19:15:32 +1030 Subject: [PATCH] codec/mjpeg/jpeg.go: defining consts for SOF0 header fields --- codec/mjpeg/jpeg.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/codec/mjpeg/jpeg.go b/codec/mjpeg/jpeg.go index 572a9eda..015ad8d3 100644 --- a/codec/mjpeg/jpeg.go +++ b/codec/mjpeg/jpeg.go @@ -55,8 +55,8 @@ const ( // Density units. const ( unitNone = iota - unitPxIN - unitPxCM + unitPxIN // Pixels per inch. + unitPxCM // Pixels per centimeter. ) // JFIF header fields. @@ -71,6 +71,13 @@ const ( jfifHeadLen = 16 // Length of JFIF header segment excluding APP0 marker. ) +// SOF0 (start of scan) header fields. +const ( + sofLen = 17 + sofPrecision = 8 + sofNoOfComponents = 3 +) + var ( errNoQTable = errors.New("no quantization table") errReservedQ = errors.New("q value is reserved") @@ -333,11 +340,13 @@ func writeHeader(p *putBuffer, _type, width, height, nbqTab, dri int, qtable []b mtxNo = 1 } - p.put16(17) - p.put8(8) + p.put16(sofLen) + p.put8(sofPrecision) p.put16(uint16(height)) p.put16(uint16(width)) - p.put8(3) + p.put8(sofNoOfComponents) + + // TODO: find meaning of these fields. p.put8(1) p.put8(uint8((2 << 4) | sample)) p.put8(0)