Initial Commit
Initial commit of Code Base.
This commit is contained in:
parent
293b1213e1
commit
c11a4ebbc2
653 changed files with 36893 additions and 1 deletions
31
addons/twitcher/media/native/gif-lzw/lsbbitpacker.gd
Normal file
31
addons/twitcher/media/native/gif-lzw/lsbbitpacker.gd
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
@tool
|
||||
extends RefCounted
|
||||
|
||||
class LSBLZWBitPacker:
|
||||
var bit_index: int = 0
|
||||
var stream: int = 0
|
||||
|
||||
var chunks: PackedByteArray = PackedByteArray([])
|
||||
|
||||
func put_byte():
|
||||
chunks.append(stream & 0xff)
|
||||
bit_index -= 8
|
||||
stream >>= 8
|
||||
|
||||
func write_bits(value: int, bits_count: int) -> void:
|
||||
value &= (1 << bits_count) - 1
|
||||
value <<= bit_index
|
||||
stream |= value
|
||||
bit_index += bits_count
|
||||
while bit_index >= 8:
|
||||
put_byte()
|
||||
|
||||
func pack() -> PackedByteArray:
|
||||
if bit_index != 0:
|
||||
put_byte()
|
||||
return chunks
|
||||
|
||||
func reset() -> void:
|
||||
bit_index = 0
|
||||
stream = 0
|
||||
chunks = PackedByteArray([])
|
||||
Loading…
Add table
Add a link
Reference in a new issue