mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Caption support (#2462)
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
25
vendor/github.com/asticode/go-astits/crc32.go
generated
vendored
Normal file
25
vendor/github.com/asticode/go-astits/crc32.go
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
package astits
|
||||
|
||||
const (
|
||||
crc32Polynomial = uint32(0xffffffff)
|
||||
)
|
||||
|
||||
// computeCRC32 computes a CRC32
|
||||
// https://stackoverflow.com/questions/35034042/how-to-calculate-crc32-in-psi-si-packet
|
||||
func computeCRC32(bs []byte) uint32 {
|
||||
return updateCRC32(crc32Polynomial, bs)
|
||||
}
|
||||
|
||||
func updateCRC32(crc32 uint32, bs []byte) uint32 {
|
||||
for _, b := range bs {
|
||||
for i := 0; i < 8; i++ {
|
||||
if (crc32 >= uint32(0x80000000)) != (b >= uint8(0x80)) {
|
||||
crc32 = (crc32 << 1) ^ 0x04C11DB7
|
||||
} else {
|
||||
crc32 = crc32 << 1
|
||||
}
|
||||
b <<= 1
|
||||
}
|
||||
}
|
||||
return crc32
|
||||
}
|
||||
Reference in New Issue
Block a user