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) p[idx] = byte(i)
idx++ idx++
src := qtable[64*i : (64*i)+64] copy(p[idx:], qtable[64*i:(64*i)+64])
copy(p[idx:], src)
idx += len(src)
} }
// Define huffman table. // Define huffman table.
@ -402,13 +400,8 @@ func writeHuffman(p []byte, class, id int, bits, values []byte) int {
n += int(bits[i]) n += int(bits[i])
} }
src := bits[1:17] idx += copy(p[idx:], bits[1:17])
copy(p[idx:], src) idx += copy(p[idx:], values[0:n])
idx += len(src)
src = values[0:n]
copy(p[idx:], src)
idx += len(src)
return idx return idx
} }