codec/mjpeg/jpeg.go: defining consts for SOF0 header fields

This commit is contained in:
Saxon 2020-01-01 19:15:32 +10:30
parent 3f4561da5b
commit 49138ce021
1 changed files with 14 additions and 5 deletions

View File

@ -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")
@ -334,11 +341,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)