File: compressor.h

package info (click to toggle)
erofs-utils 1.3-1
  • links: PTS
  • area: main
  • in suites: bookworm, sid
  • size: 428 kB
  • sloc: ansic: 5,712; makefile: 69; sh: 5
file content (56 lines) | stat: -rw-r--r-- 1,337 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * erofs-utils/lib/compressor.h
 *
 * Copyright (C) 2018-2019 HUAWEI, Inc.
 *             http://www.huawei.com/
 * Created by Gao Xiang <gaoxiang25@huawei.com>
 */
#ifndef __EROFS_LIB_COMPRESSOR_H
#define __EROFS_LIB_COMPRESSOR_H

#include "erofs/defs.h"

struct erofs_compress;

struct erofs_compressor {
	const char *name;

	int default_level;
	int best_level;

	int (*init)(struct erofs_compress *c);
	int (*exit)(struct erofs_compress *c);

	int (*compress_destsize)(struct erofs_compress *c,
				 int compress_level,
				 void *src, unsigned int *srcsize,
				 void *dst, unsigned int dstsize);
};

struct erofs_compress {
	struct erofs_compressor *alg;

	unsigned int compress_threshold;

	/* *_destsize specific */
	unsigned int destsize_alignsize;
	unsigned int destsize_redzone_begin;
	unsigned int destsize_redzone_end;

	void *private_data;
};

/* list of compression algorithms */
extern struct erofs_compressor erofs_compressor_lz4;
extern struct erofs_compressor erofs_compressor_lz4hc;

int erofs_compress_destsize(struct erofs_compress *c, int compression_level,
			    void *src, unsigned int *srcsize,
			    void *dst, unsigned int dstsize);

int erofs_compressor_init(struct erofs_compress *c, char *alg_name);
int erofs_compressor_exit(struct erofs_compress *c);

#endif