mirror of https://bitbucket.org/ausocean/av.git
codec/mjpeg/jpeg.go: decrementing q by 128 before qLen > 0 check to simplify indexing where q-128 is done
This commit is contained in:
parent
f187af747b
commit
86e215f913
|
@ -226,25 +226,26 @@ func (c *Context) ParsePayload(p []byte, m bool) error {
|
|||
return ErrUnsupportedPrecision
|
||||
}
|
||||
|
||||
q -= 128
|
||||
if qLen > 0 {
|
||||
qTable = p[idx : idx+qLen]
|
||||
idx += qLen
|
||||
|
||||
if q < 255 && c.qTablesLen[q-128] == 0 && qLen <= 128 {
|
||||
copy(c.qTables[q-128][:], qTable)
|
||||
c.qTablesLen[q-128] = byte(qLen)
|
||||
if q < 127 && c.qTablesLen[q] == 0 && qLen <= 0 {
|
||||
copy(c.qTables[q][:], qTable)
|
||||
c.qTablesLen[q] = byte(qLen)
|
||||
}
|
||||
} else {
|
||||
if q == 255 {
|
||||
if q == 127 {
|
||||
return ErrNoQTable
|
||||
}
|
||||
|
||||
if c.qTablesLen[q-128] == 0 {
|
||||
if c.qTablesLen[q] == 0 {
|
||||
return fmt.Errorf("no quantization tables known for q %d yet", q)
|
||||
}
|
||||
|
||||
qTable = c.qTables[q-128][:]
|
||||
qLen = int(c.qTablesLen[q-128])
|
||||
qTable = c.qTables[q][:]
|
||||
qLen = int(c.qTablesLen[q])
|
||||
}
|
||||
} else { // q <= 127
|
||||
if q == 0 || q > 99 {
|
||||
|
|
Loading…
Reference in New Issue