codec/mjpeg/jpeg.go: simplified copies

This commit is contained in:
Saxon 2020-01-07 13:53:26 +10:30
parent 52f18cdc58
commit 7fb5ed00a2
1 changed files with 3 additions and 10 deletions

View File

@ -336,9 +336,7 @@ func writeHeader(p []byte, _type, width, height, nbqTab int, dri uint16, qtable
p[idx] = byte(i)
idx++
src := qtable[64*i : (64*i)+64]
copy(p[idx:], src)
idx += len(src)
copy(p[idx:], qtable[64*i:(64*i)+64])
}
// Define huffman table.
@ -402,13 +400,8 @@ func writeHuffman(p []byte, class, id int, bits, values []byte) int {
n += int(bits[i])
}
src := bits[1:17]
copy(p[idx:], src)
idx += len(src)
src = values[0:n]
copy(p[idx:], src)
idx += len(src)
idx += copy(p[idx:], bits[1:17])
idx += copy(p[idx:], values[0:n])
return idx
}