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