package core:compress/zlib
⌘K
Ctrl+K
or
/
Overview
Example:
package main
import "core:bytes"
import "core:compress/zlib"
import "core:fmt"
main :: proc() {
ODIN_DEMO := []u8{
120, 218, 101, 144, 65, 110, 131, 48, 16, 69, 215, 246, 41, 190, 44, 69, 73, 32, 148, 182,
75, 75, 28, 32, 251, 46, 217, 88, 238, 0, 86, 192, 32, 219, 36, 170, 170, 172, 122, 137,
238, 122, 197, 30, 161, 70, 162, 20, 81, 203, 139, 25, 191, 255, 191, 60, 51, 40, 125, 81,
53, 33, 144, 15, 156, 155, 110, 232, 93, 128, 208, 189, 35, 89, 117, 65, 112, 222, 41, 99,
33, 37, 6, 215, 235, 195, 17, 239, 156, 197, 170, 118, 170, 131, 44, 32, 82, 164, 72, 240,
253, 245, 249, 129, 12, 185, 224, 76, 105, 61, 118, 99, 171, 66, 239, 38, 193, 35, 103, 85,
172, 66, 127, 33, 139, 24, 244, 235, 141, 49, 204, 223, 76, 208, 205, 204, 166, 7, 173, 60,
97, 159, 238, 37, 214, 41, 105, 129, 167, 5, 102, 27, 152, 173, 97, 178, 129, 73, 129, 231,
5, 230, 27, 152, 175, 225, 52, 192, 127, 243, 170, 157, 149, 18, 121, 142, 115, 109, 227, 122,
64, 87, 114, 111, 161, 49, 182, 6, 181, 158, 162, 226, 206, 167, 27, 215, 246, 48, 56, 99,
67, 117, 16, 47, 13, 45, 35, 151, 98, 231, 75, 1, 173, 90, 61, 101, 146, 71, 136, 244,
170, 218, 145, 176, 123, 45, 173, 56, 113, 134, 191, 51, 219, 78, 235, 95, 28, 249, 253, 7,
159, 150, 133, 125,
}
OUTPUT_SIZE :: 432
buf: bytes.Buffer
// We can pass ", true" to inflate a raw DEFLATE stream instead of a ZLIB wrapped one.
err := zlib.inflate(input=ODIN_DEMO, buf=&buf, expected_output_size=OUTPUT_SIZE)
defer bytes.buffer_destroy(&buf)
if err != nil {
fmt.printf("\nError: %v\n", err)
}
s := bytes.buffer_to_string(&buf)
fmt.printf("Input: %v bytes, output (%v bytes):\n%v\n", len(ODIN_DEMO), len(s), s)
assert(len(s) == OUTPUT_SIZE)
}
Index
Procedure Groups (1)
Types
Compression_Level ¶
Compression_Level :: enum u8 { Fastest = 0, Fast = 1, Default = 2, Maximum = 3, }
Compression_Method ¶
Compression_Method :: enum u8 { DEFLATE = 8, Reserved = 15, }
Deflate_Error ¶
Deflate_Error :: compress.Deflate_Error
General_Error ¶
General_Error :: compress.General_Error
Huffman_Table ¶
Huffman_Table :: struct { fast: [512]u16, firstcode: [17]u16, maxcode: [17]int, firstsymbol: [17]u16, size: [288]u8, value: [288]u16, }
ZLIB-style Huffman encoding. JPEG packs from left, ZLIB from right. We can't share code.
Related Procedures With Parameters
Related Procedures With Returns
ZLIB_Error ¶
ZLIB_Error :: compress.ZLIB_Error
Constants
DEFLATE_MAX_CHUNK_SIZE ¶
DEFLATE_MAX_CHUNK_SIZE :: 65535
DEFLATE_MAX_DISTANCE ¶
DEFLATE_MAX_DISTANCE :: 32768
DEFLATE_MAX_LENGTH ¶
DEFLATE_MAX_LENGTH :: 258
DEFLATE_MAX_LITERAL_SIZE ¶
DEFLATE_MAX_LITERAL_SIZE :: 65535
HUFFMAN_FAST_BITS ¶
HUFFMAN_FAST_BITS :: 9
HUFFMAN_FAST_MASK ¶
HUFFMAN_FAST_MASK :: (1 << HUFFMAN_FAST_BITS) - 1
HUFFMAN_MAX_BITS ¶
HUFFMAN_MAX_BITS :: 16
ZFAST_MASK ¶
ZFAST_MASK :: (1 << ZFAST_BITS) - 1
Variables
Z_DIST_BASE ¶
Z_DIST_BASE: [32]u16 = …
Z_DIST_EXTRA ¶
Z_DIST_EXTRA: [32]u8 = …
Z_FIXED_DIST ¶
Z_FIXED_DIST: [32]u8 = …
Z_FIXED_LENGTH ¶
Z_FIXED_LENGTH: [288]u8 = …
Z_LENGTH_BASE ¶
Z_LENGTH_BASE: [31]u16 = …
Z_LENGTH_DEZIGZAG ¶
Z_LENGTH_DEZIGZAG: []u8 = …
Z_LENGTH_EXTRA ¶
Z_LENGTH_EXTRA: [31]u8 = …
Procedures
allocate_huffman_table ¶
allocate_huffman_table :: proc(allocator := context.allocator) -> (z: ^Huffman_Table, err: compress.Error) {…}
build_huffman ¶
build_huffman :: proc(z: ^Huffman_Table, code_lengths: []u8) -> (err: compress.Error) {…}
decode_huffman ¶
decode_huffman :: proc(z: ^$T, t: ^Huffman_Table) -> (r: u16, err: compress.Error) {…}
decode_huffman_slowpath ¶
decode_huffman_slowpath :: proc(z: ^$T, t: ^Huffman_Table) -> (r: u16, err: compress.Error) {…}
inflate_from_context ¶
inflate_from_context :: proc(using ctx: ^compress.Context_Memory_Input, raw: bool = false, expected_output_size: int = -1, allocator := context.allocator) -> (err: compress.Error) {…}
inflate_raw ¶
inflate_raw :: proc(z: ^$T, expected_output_size: int = -1, allocator := context.allocator) -> (err: compress.Error) {…}
parse_huffman_block ¶
parse_huffman_block :: proc(z: ^$T, z_repeat, z_offset: ^Huffman_Table) -> (err: compress.Error) {…}
z_bit_reverse ¶
Implementation starts here
Procedure Groups
inflate ¶
inflate :: proc{ inflate_from_context, inflate_from_byte_array, }
Source Files
Generation Information
Generated with odin version dev-2024-11 (vendor "odin") Windows_amd64 @ 2024-11-16 21:10:09.798305300 +0000 UTC