1
1
/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
2
2
/*
3
- * Copyright (c) Yann Collet, Facebook, Inc.
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates .
4
4
* All rights reserved.
5
5
*
6
6
* This source code is licensed under both the BSD-style license (found in the
@@ -160,7 +160,6 @@ typedef ZSTD_parameters zstd_parameters;
160
160
zstd_parameters zstd_get_params (int level ,
161
161
unsigned long long estimated_src_size );
162
162
163
-
164
163
/**
165
164
* zstd_get_cparams() - returns zstd_compression_parameters for selected level
166
165
* @level: The compression level
@@ -173,9 +172,20 @@ zstd_parameters zstd_get_params(int level,
173
172
zstd_compression_parameters zstd_get_cparams (int level ,
174
173
unsigned long long estimated_src_size , size_t dict_size );
175
174
176
- /* ====== Single-pass Compression ====== */
177
-
178
175
typedef ZSTD_CCtx zstd_cctx ;
176
+ typedef ZSTD_cParameter zstd_cparameter ;
177
+
178
+ /**
179
+ * zstd_cctx_set_param() - sets a compression parameter
180
+ * @cctx: The context. Must have been initialized with zstd_init_cctx().
181
+ * @param: The parameter to set.
182
+ * @value: The value to set the parameter to.
183
+ *
184
+ * Return: Zero or an error, which can be checked using zstd_is_error().
185
+ */
186
+ size_t zstd_cctx_set_param (zstd_cctx * cctx , zstd_cparameter param , int value );
187
+
188
+ /* ====== Single-pass Compression ====== */
179
189
180
190
/**
181
191
* zstd_cctx_workspace_bound() - max memory needed to initialize a zstd_cctx
@@ -190,6 +200,20 @@ typedef ZSTD_CCtx zstd_cctx;
190
200
*/
191
201
size_t zstd_cctx_workspace_bound (const zstd_compression_parameters * parameters );
192
202
203
+ /**
204
+ * zstd_cctx_workspace_bound_with_ext_seq_prod() - max memory needed to
205
+ * initialize a zstd_cctx when using the block-level external sequence
206
+ * producer API.
207
+ * @parameters: The compression parameters to be used.
208
+ *
209
+ * If multiple compression parameters might be used, the caller must call
210
+ * this function for each set of parameters and use the maximum size.
211
+ *
212
+ * Return: A lower bound on the size of the workspace that is passed to
213
+ * zstd_init_cctx().
214
+ */
215
+ size_t zstd_cctx_workspace_bound_with_ext_seq_prod (const zstd_compression_parameters * parameters );
216
+
193
217
/**
194
218
* zstd_init_cctx() - initialize a zstd compression context
195
219
* @workspace: The workspace to emplace the context into. It must outlive
@@ -424,6 +448,16 @@ typedef ZSTD_CStream zstd_cstream;
424
448
*/
425
449
size_t zstd_cstream_workspace_bound (const zstd_compression_parameters * cparams );
426
450
451
+ /**
452
+ * zstd_cstream_workspace_bound_with_ext_seq_prod() - memory needed to initialize
453
+ * a zstd_cstream when using the block-level external sequence producer API.
454
+ * @cparams: The compression parameters to be used for compression.
455
+ *
456
+ * Return: A lower bound on the size of the workspace that is passed to
457
+ * zstd_init_cstream().
458
+ */
459
+ size_t zstd_cstream_workspace_bound_with_ext_seq_prod (const zstd_compression_parameters * cparams );
460
+
427
461
/**
428
462
* zstd_init_cstream() - initialize a zstd streaming compression context
429
463
* @parameters The zstd parameters to use for compression.
@@ -583,6 +617,18 @@ size_t zstd_decompress_stream(zstd_dstream *dstream, zstd_out_buffer *output,
583
617
*/
584
618
size_t zstd_find_frame_compressed_size (const void * src , size_t src_size );
585
619
620
+ /**
621
+ * zstd_register_sequence_producer() - exposes the zstd library function
622
+ * ZSTD_registerSequenceProducer(). This is used for the block-level external
623
+ * sequence producer API. See upstream zstd.h for detailed documentation.
624
+ */
625
+ typedef ZSTD_sequenceProducer_F zstd_sequence_producer_f ;
626
+ void zstd_register_sequence_producer (
627
+ zstd_cctx * cctx ,
628
+ void * sequence_producer_state ,
629
+ zstd_sequence_producer_f sequence_producer
630
+ );
631
+
586
632
/**
587
633
* struct zstd_frame_params - zstd frame parameters stored in the frame header
588
634
* @frameContentSize: The frame content size, or ZSTD_CONTENTSIZE_UNKNOWN if not
@@ -596,7 +642,7 @@ size_t zstd_find_frame_compressed_size(const void *src, size_t src_size);
596
642
*
597
643
* See zstd_lib.h.
598
644
*/
599
- typedef ZSTD_frameHeader zstd_frame_header ;
645
+ typedef ZSTD_FrameHeader zstd_frame_header ;
600
646
601
647
/**
602
648
* zstd_get_frame_header() - extracts parameters from a zstd or skippable frame
@@ -611,4 +657,35 @@ typedef ZSTD_frameHeader zstd_frame_header;
611
657
size_t zstd_get_frame_header (zstd_frame_header * params , const void * src ,
612
658
size_t src_size );
613
659
660
+ /**
661
+ * struct zstd_sequence - a sequence of literals or a match
662
+ *
663
+ * @offset: The offset of the match
664
+ * @litLength: The literal length of the sequence
665
+ * @matchLength: The match length of the sequence
666
+ * @rep: Represents which repeat offset is used
667
+ */
668
+ typedef ZSTD_Sequence zstd_sequence ;
669
+
670
+ /**
671
+ * zstd_compress_sequences_and_literals() - compress an array of zstd_sequence and literals
672
+ *
673
+ * @cctx: The zstd compression context.
674
+ * @dst: The buffer to compress the data into.
675
+ * @dst_capacity: The size of the destination buffer.
676
+ * @in_seqs: The array of zstd_sequence to compress.
677
+ * @in_seqs_size: The number of sequences in in_seqs.
678
+ * @literals: The literals associated to the sequences to be compressed.
679
+ * @lit_size: The size of the literals in the literals buffer.
680
+ * @lit_capacity: The size of the literals buffer.
681
+ * @decompressed_size: The size of the input data
682
+ *
683
+ * Return: The compressed size or an error, which can be checked using
684
+ * zstd_is_error().
685
+ */
686
+ size_t zstd_compress_sequences_and_literals (zstd_cctx * cctx , void * dst , size_t dst_capacity ,
687
+ const zstd_sequence * in_seqs , size_t in_seqs_size ,
688
+ const void * literals , size_t lit_size , size_t lit_capacity ,
689
+ size_t decompressed_size );
690
+
614
691
#endif /* LINUX_ZSTD_H */
0 commit comments