Mercurial > core / lisp/ffi/zstd/pkg.lisp
changeset 392: |
077e7b391758 |
parent: |
757b91ddcb2a
|
child: |
6b87df03cdaf |
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Sat, 01 Jun 2024 15:44:55 -0400 |
permissions: |
-rw-r--r-- |
description: |
finish zstd init |
1 ;;; ffi/zstd/pkg.lisp --- ZSTD FFI 7 zstd, short for Zstandard, is a fast lossless compression algorithm, targeting 8 real-time compression scenarios at zlib-level and better compression ratios. 9 The zstd compression library provides in-memory compression and decompression 12 The library supports regular compression levels from 1 up to ZSTD_maxCLevel(), 13 which is currently 22. Levels >= 20, labeled `--ultra`, should be used with 14 caution, as they require more memory. The library also offers negative 15 compression levels, which extend the range of speed vs. ratio preferences. 16 The lower the level, the faster the speed (at the cost of compression). 18 Compression can be done in: 19 - a single step (described as Simple API) 20 - a single step, reusing a context (described as Explicit context) 21 - unbounded multiple steps (described as Streaming compression) 23 The compression ratio achievable on small data can be highly improved using 24 a dictionary. Dictionary compression can be performed in: 25 - a single step (described as Simple dictionary API) 26 - a single step, reusing a dictionary (described as Bulk-processing 29 Advanced experimental functions can be accessed using 30 `#define ZSTD_STATIC_LINKING_ONLY` before including zstd.h. 32 Advanced experimental APIs should never be used with a dynamically-linked 33 library. They are not "stable"; their definitions or signatures may change in 34 the future. Only static linking is allowed. 39 (:use :cl :std :sb-alien) 44 (define-alien-loader "zstd" t "/usr/lib/") 47 (define-alien-routine "ZSTD_versionNumber" 50 (define-alien-routine "ZSTD_versionString" c-string) 52 (define-alien-routine "ZSTD_compressBound" size-t (src-size size-t)) 53 (define-alien-routine "ZSTD_isError" unsigned (code size-t)) 54 (define-alien-routine "ZSTD_getErrorName" c-string (code size-t)) 55 (define-alien-routine "ZSTD_minCLevel" int) 56 (define-alien-routine "ZSTD_maxCLevel" int) 57 (define-alien-routine "ZSTD_defaultCLevel" int) 60 (define-alien-routine "ZSTD_compress" size-t 61 (dst (* t)) (dst-capacity size-t) 62 (src (* t)) (src-size size-t) 65 (define-alien-routine "ZSTD_decompress" size-t 66 (dst (* t)) (dst-capacity size-t) 67 (src (* t)) (compressed-size size-t)) 69 ;;; Explicit Context API 70 (define-alien-type zstd-cctx (struct zstd-cctx-s)) 72 (define-alien-routine "ZSTD_createCCtx" (* zstd-cctx)) 73 (define-alien-routine "ZSTD_freeCCtx" void (cctx (* zstd-cctx))) 74 (define-alien-routine "ZSTD_compressCCtx" size-t 76 (dst (* t)) (dst-capacity size-t) 77 (src (* t)) (src-size size-t) 78 (compression-level int)) 80 (define-alien-type zstd-dctx (struct zstd-dctx-s)) 82 (define-alien-routine "ZSTD_createDCtx" (* zstd-dctx)) 83 (define-alien-routine "ZSTD_freeDCtx" void (dctx (* zstd-dctx))) 84 (define-alien-routine "ZSTD_decompressDCtx" size-t 86 (dst (* t)) (dst-capacity size-t) 87 (src (* t)) (src-size size-t)) 90 (define-alien-type zstd-inbuffer (struct zstd-inbuffer-s 95 (define-alien-type zstd-outbuffer (struct zstd-outbuffer-s 100 (define-alien-type zstd-cstream zstd-cctx) 102 (define-alien-routine "ZSTD_createCStream" (* zstd-cstream)) 103 (define-alien-routine "ZSTD_freeCStream" void (zcs (* zstd-cstream))) 105 (define-alien-type zstd-enddirective int) 107 (define-alien-routine "ZSTD_compressStream2" size-t 109 (output (* zstd-outbuffer)) 110 (input (* zstd-inbuffer)) 111 (end-op zstd-enddirective)) 113 (define-alien-routine "ZSTD_CStreamInSize" size-t) 114 (define-alien-routine "ZSTD_CStreamOutSize" size-t) 116 (define-alien-type zstd-dstream zstd-dctx) 118 (define-alien-routine "ZSTD_createDStream" (* zstd-dstream)) 119 (define-alien-routine "ZSTD_freeDStream" void (zds (* zstd-dstream))) 120 (define-alien-routine "ZSTD_initDStream" size-t (zds (* zstd-dstream))) 122 (define-alien-routine "ZSTD_decompressStream" size-t 123 (zds (* zstd-dstream)) 124 (output (* zstd-outbuffer)) 125 (input (* zstd-inbuffer))) 127 (define-alien-routine "ZSTD_DStreamInSize" size-t) 128 (define-alien-routine "ZSTD_DStreamOutSize" size-t) 130 ;;; Simple Dictionary API 131 (define-alien-routine "ZSTD_compress_usingDict" size-t 134 (dst-capacity size-t) 139 (compression-level int)) 141 (define-alien-routine "ZSTD_decompress_usingDict" size-t 144 (dst-capacity size-t) 150 ;;; Bulk-processing Dictionary API 151 (define-alien-type zstd-cdict (struct zstd-cdict-s)) 153 (define-alien-routine "ZSTD_createCDict" (* zstd-cdict) 156 (compression-level int)) 158 (define-alien-routine "ZSTD_freeCDict" size-t (cdict (* zstd-cdict))) 160 (define-alien-routine "ZSTD_compress_usingCDict" size-t 163 (dst-capacity size-t) 166 (cdict (* zstd-cdict))) 168 (define-alien-type zstd-ddict (struct zstd-ddict-s)) 170 (define-alien-routine "ZSTD_createDDict" (* zstd-ddict) 174 (define-alien-routine "ZSTD_freeDDict" size-t (ddict (* zstd-ddict))) 176 (define-alien-routine "ZSTD_compress_usingDDict" size-t 179 (dst-capacity size-t) 182 (ddict (* zstd-ddict))) 185 (define-alien-routine "ZSTD_getDictID_fromDict" unsigned 189 (define-alien-routine "ZSTD_getDictID_fromCDict" unsigned 190 (cdict (* zstd-cdict))) 192 (define-alien-routine "ZSTD_getDictID_fromDDict" unsigned 193 (cdict (* zstd-ddict))) 195 (define-alien-routine "ZSTD_getDictID_fromFrame" unsigned