package core:compress

⌘K
Ctrl+K
or
/

    Types

    Context_Memory_Input ¶

    Context_Memory_Input :: struct #packed {
    	input_data:    []u8,
    	output:        ^bytes.Buffer,
    	bytes_written: i64,
    	code_buffer:   u64,
    	num_bits:      u64,
    	size_packed:   i64,
    	size_unpacked: i64,
    }
     

    General I/O context for ZLIB, LZW, etc.

    Related Procedures With Parameters

    Context_Stream_Input ¶

    Context_Stream_Input :: struct #packed {
    	input_data:            []u8,
    	input:                 io.Stream,
    	output:                ^bytes.Buffer,
    	bytes_written:         i64,
    	code_buffer:           u64,
    	num_bits:              u64,
    	size_packed:           i64,
    	size_unpacked:         i64,
    	input_fully_in_memory: b8,
    	padding:               [1]u8,
    }
    Related Procedures With Parameters

    Deflate_Error ¶

    Deflate_Error :: enum int {
    	None                     = 0, 
    	Huffman_Bad_Sizes, 
    	Huffman_Bad_Code_Lengths, 
    	Inflate_Error, 
    	Bad_Distance, 
    	Bad_Huffman_Code, 
    	Len_Nlen_Mismatch, 
    	BType_3, 
    }

    Error ¶

    Related Procedures With Returns

    GZIP_Error ¶

    GZIP_Error :: enum int {
    	None                                        = 0, 
    	Invalid_GZIP_Signature, 
    	Reserved_Flag_Set, 
    	Invalid_Extra_Data, 
    	Original_Name_Too_Long, 
    	Comment_Too_Long, 
    	Payload_Length_Invalid, 
    	Payload_CRC_Invalid, 
    	Payload_Size_Exceeds_Max_Payload, 
    	Output_Exceeds_COMPRESS_OUTPUT_ALLOCATE_MAX, 
    }

    General_Error ¶

    General_Error :: enum int {
    	None                       = 0, 
    	File_Not_Found, 
    	Cannot_Open_File, 
    	File_Too_Short, 
    	Stream_Too_Short, 
    	Output_Too_Short, 
    	Unknown_Compression_Method, 
    	Checksum_Failed, 
    	Incompatible_Options, 
    	Unimplemented, 
    	Allocation_Failed, 
    	Resize_Failed, 
    }

    ZIP_Error ¶

    ZIP_Error :: enum int {
    	None                                     = 0, 
    	Invalid_ZIP_File_Signature, 
    	Unexpected_Signature, 
    	Insert_Next_Disk, 
    	Expected_End_of_Central_Directory_Record, 
    }

    ZLIB_Error ¶

    ZLIB_Error :: enum int {
    	None                          = 0, 
    	Unsupported_Window_Size, 
    	FDICT_Unsupported, 
    	Unsupported_Compression_Level, 
    	Code_Buffer_Malformed, 
    }

    Constants

    COMPRESS_OUTPUT_ALLOCATE_MAX ¶

    COMPRESS_OUTPUT_ALLOCATE_MAX :: int(#config(COMPRESS_OUTPUT_ALLOCATE_MAX, 1 << 32))
     

    For 64-bit platforms, we set the default max buffer size to 4 GiB, which is GZIP and PKZIP's max payload size.

    COMPRESS_OUTPUT_ALLOCATE_MIN ¶

    COMPRESS_OUTPUT_ALLOCATE_MIN :: int(#config(COMPRESS_OUTPUT_ALLOCATE_MIN, 1 << 20))
     

    When a decompression routine doesn't stream its output, but writes to a buffer, we pre-allocate an output buffer to speed up decompression. The default is 1 MiB.

    Variables

    This section is empty.

    Procedures

    consume_bits_lsb_from_memory ¶

    consume_bits_lsb_from_memory :: proc(z: ^Context_Memory_Input, width: u8) {…}

    consume_bits_lsb_from_stream ¶

    consume_bits_lsb_from_stream :: proc(z: ^Context_Stream_Input, width: u8) {…}

    discard_to_next_byte_lsb_from_memory ¶

    discard_to_next_byte_lsb_from_memory :: proc(z: ^Context_Memory_Input) {…}

    discard_to_next_byte_lsb_from_stream ¶

    discard_to_next_byte_lsb_from_stream :: proc(z: ^Context_Stream_Input) {…}

    input_size_from_memory ¶

    input_size_from_memory :: proc(z: ^Context_Memory_Input) -> (res: i64, err: Error) {…}

    input_size_from_stream ¶

    input_size_from_stream :: proc(z: ^Context_Stream_Input) -> (res: i64, err: Error) {…}

    peek_back_byte ¶

    peek_back_byte :: proc(z: ^$T, offset: i64) -> (res: u8, err: io.Error) {…}
     

    Sliding window read back

    peek_bits_lsb_from_memory ¶

    peek_bits_lsb_from_memory :: proc(z: ^Context_Memory_Input, width: u8) -> u32 {…}

    peek_bits_lsb_from_stream ¶

    peek_bits_lsb_from_stream :: proc(z: ^Context_Stream_Input, width: u8) -> u32 {…}

    peek_bits_no_refill_lsb_from_memory ¶

    peek_bits_no_refill_lsb_from_memory :: proc(z: ^Context_Memory_Input, width: u8) -> u32 {…}

    peek_bits_no_refill_lsb_from_stream ¶

    peek_bits_no_refill_lsb_from_stream :: proc(z: ^Context_Stream_Input, width: u8) -> u32 {…}

    peek_data_at_offset_from_memory ¶

    peek_data_at_offset_from_memory :: proc(z: ^Context_Memory_Input, $T: typeid, #any_int offset: int) -> (res: typeid, err: io.Error) {…}

    peek_data_at_offset_from_stream ¶

    peek_data_at_offset_from_stream :: proc(z: ^Context_Stream_Input, $T: typeid, #any_int offset: int) -> (res: typeid, err: io.Error) {…}

    peek_data_from_memory ¶

    peek_data_from_memory :: proc(z: ^Context_Memory_Input, $T: typeid) -> (res: typeid, err: io.Error) {…}

    peek_data_from_stream ¶

    peek_data_from_stream :: proc(z: ^Context_Stream_Input, $T: typeid) -> (res: typeid, err: io.Error) {…}

    read_bits_lsb_from_memory ¶

    read_bits_lsb_from_memory :: proc(z: ^Context_Memory_Input, width: u8) -> u32 {…}

    read_bits_lsb_from_stream ¶

    read_bits_lsb_from_stream :: proc(z: ^Context_Stream_Input, width: u8) -> u32 {…}

    read_bits_no_refill_lsb_from_memory ¶

    read_bits_no_refill_lsb_from_memory :: proc(z: ^Context_Memory_Input, width: u8) -> u32 {…}

    read_bits_no_refill_lsb_from_stream ¶

    read_bits_no_refill_lsb_from_stream :: proc(z: ^Context_Stream_Input, width: u8) -> u32 {…}

    read_data ¶

    read_data :: proc(z: ^$T, $T: typeid) -> (res: typeid, err: io.Error) {…}

    read_slice_from_memory ¶

    read_slice_from_memory :: proc(z: ^Context_Memory_Input, size: int) -> (res: []u8, err: io.Error) {…}

    read_slice_from_stream ¶

    read_slice_from_stream :: proc(z: ^Context_Stream_Input, size: int) -> (res: []u8, err: io.Error) {…}

    read_u8_from_memory ¶

    read_u8_from_memory :: proc(z: ^Context_Memory_Input) -> (res: u8, err: io.Error) {…}

    read_u8_from_stream ¶

    read_u8_from_stream :: proc(z: ^Context_Stream_Input) -> (res: u8, err: io.Error) {…}

    read_u8_prefer_code_buffer_lsb ¶

    read_u8_prefer_code_buffer_lsb :: proc(z: ^$T) -> (res: u8, err: io.Error) {…}
     

    You would typically only use this at the end of Inflate, to drain bits from the code buffer preferentially.

    refill_lsb_from_memory ¶

    refill_lsb_from_memory :: proc(z: ^Context_Memory_Input, width: i8 = i8(48)) {…}
     

    Generalized bit reader LSB

    refill_lsb_from_stream ¶

    refill_lsb_from_stream :: proc(z: ^Context_Stream_Input, width: i8 = i8(24)) {…}
     

    Generalized bit reader LSB

    Procedure Groups

    Source Files

    Generation Information

    Generated with odin version dev-2024-04 (vendor "odin") Windows_amd64 @ 2024-04-25 21:10:21.679304400 +0000 UTC