]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/linux/lz4.h
6 * Copyright (C) 2013, LG Electronics, Kyungsik Lee <kyungsik.lee@lge.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 #define LZ4_MEM_COMPRESS (4096 * sizeof(unsigned char *))
13 #define LZ4HC_MEM_COMPRESS (65538 * sizeof(unsigned char *))
17 * Provides the maximum size that LZ4 may output in a "worst case" scenario
18 * (input data not compressible)
20 static inline size_t lz4_compressbound(size_t isize
)
22 return isize
+ (isize
/ 255) + 16;
27 * src : source address of the original data
28 * src_len : size of the original data
29 * dst : output buffer address of the compressed data
30 * This requires 'dst' of size LZ4_COMPRESSBOUND.
31 * dst_len : is the output size, which is returned after compress done
32 * workmem : address of the working memory.
33 * This requires 'workmem' of size LZ4_MEM_COMPRESS.
34 * return : Success if return 0
35 * Error if return (< 0)
36 * note : Destination buffer and workmem must be already allocated with
39 int lz4_compress(const unsigned char *src
, size_t src_len
,
40 unsigned char *dst
, size_t *dst_len
, void *wrkmem
);
44 * src : source address of the original data
45 * src_len : size of the original data
46 * dst : output buffer address of the compressed data
47 * This requires 'dst' of size LZ4_COMPRESSBOUND.
48 * dst_len : is the output size, which is returned after compress done
49 * workmem : address of the working memory.
50 * This requires 'workmem' of size LZ4HC_MEM_COMPRESS.
51 * return : Success if return 0
52 * Error if return (< 0)
53 * note : Destination buffer and workmem must be already allocated with
56 int lz4hc_compress(const unsigned char *src
, size_t src_len
,
57 unsigned char *dst
, size_t *dst_len
, void *wrkmem
);
61 * src : source address of the compressed data
62 * src_len : is the input size, whcih is returned after decompress done
63 * dest : output buffer address of the decompressed data
64 * actual_dest_len: is the size of uncompressed data, supposing it's known
65 * return : Success if return 0
66 * Error if return (< 0)
67 * note : Destination buffer must be already allocated.
68 * slightly faster than lz4_decompress_unknownoutputsize()
70 int lz4_decompress(const unsigned char *src
, size_t *src_len
,
71 unsigned char *dest
, size_t actual_dest_len
);
74 * lz4_decompress_unknownoutputsize()
75 * src : source address of the compressed data
76 * src_len : is the input size, therefore the compressed size
77 * dest : output buffer address of the decompressed data
78 * dest_len: is the max size of the destination buffer, which is
79 * returned with actual size of decompressed data after
81 * return : Success if return 0
82 * Error if return (< 0)
83 * note : Destination buffer must be already allocated.
85 int lz4_decompress_unknownoutputsize(const unsigned char *src
, size_t src_len
,
86 unsigned char *dest
, size_t *dest_len
);