##// END OF EJS Templates
hgperf: update to conform with import style checks
hgperf: update to conform with import style checks

File last commit:

r31847:39d36c2d default
r33893:78f644fd default
Show More
python-zstandard.h
285 lines | 7.1 KiB | text/x-c | CLexer
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 /**
* Copyright (c) 2016-present, Gregory Szorc
* All rights reserved.
*
* This software may be modified and distributed under the terms
* of the BSD license. See the LICENSE file for details.
*/
#define PY_SSIZE_T_CLEAN
#include <Python.h>
Gregory Szorc
zstd: vendor python-zstandard 0.7.0...
r30895 #include "structmember.h"
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435
#define ZSTD_STATIC_LINKING_ONLY
#define ZDICT_STATIC_LINKING_ONLY
#include "mem.h"
#include "zstd.h"
#include "zdict.h"
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 #include "zstdmt_compress.h"
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435
Gregory Szorc
zstd: vendor python-zstandard 0.8.1...
r31847 #define PYTHON_ZSTANDARD_VERSION "0.8.1"
Gregory Szorc
zstd: vendor python-zstandard 0.6.0...
r30822
typedef enum {
compressorobj_flush_finish,
compressorobj_flush_block,
} CompressorObj_Flush;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /*
Represents a CompressionParameters type.
This type is basically a wrapper around ZSTD_compressionParameters.
*/
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 typedef struct {
PyObject_HEAD
unsigned windowLog;
unsigned chainLog;
unsigned hashLog;
unsigned searchLog;
unsigned searchLength;
unsigned targetLength;
ZSTD_strategy strategy;
} CompressionParametersObject;
extern PyTypeObject CompressionParametersType;
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /*
Represents a FrameParameters type.
This type is basically a wrapper around ZSTD_frameParams.
*/
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 typedef struct {
PyObject_HEAD
Gregory Szorc
zstd: vendor python-zstandard 0.7.0...
r30895 unsigned long long frameContentSize;
unsigned windowSize;
unsigned dictID;
char checksumFlag;
} FrameParametersObject;
extern PyTypeObject FrameParametersType;
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /*
Represents a ZstdCompressionDict type.
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 Instances hold data used for a zstd compression dictionary.
*/
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 typedef struct {
PyObject_HEAD
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /* Pointer to dictionary data. Owned by self. */
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 void* dictData;
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /* Size of dictionary data. */
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 size_t dictSize;
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /* k parameter for cover dictionaries. Only populated by train_cover_dict(). */
unsigned k;
/* d parameter for cover dictionaries. Only populated by train_cover_dict(). */
unsigned d;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 } ZstdCompressionDict;
extern PyTypeObject ZstdCompressionDictType;
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /*
Represents a ZstdCompressor type.
*/
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 typedef struct {
PyObject_HEAD
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /* Configured compression level. Should be always set. */
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 int compressionLevel;
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /* Number of threads to use for operations. */
unsigned int threads;
/* Pointer to compression dictionary to use. NULL if not using dictionary
compression. */
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 ZstdCompressionDict* dict;
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /* Compression context to use. Populated during object construction. NULL
if using multi-threaded compression. */
Gregory Szorc
zstd: vendor python-zstandard 0.6.0...
r30822 ZSTD_CCtx* cctx;
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /* Multi-threaded compression context to use. Populated during object
construction. NULL if not using multi-threaded compression. */
ZSTDMT_CCtx* mtcctx;
/* Digest compression dictionary. NULL initially. Populated on first use. */
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 ZSTD_CDict* cdict;
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /* Low-level compression parameter control. NULL unless passed to
constructor. Takes precedence over `compressionLevel` if defined. */
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 CompressionParametersObject* cparams;
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /* Controls zstd frame options. */
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 ZSTD_frameParameters fparams;
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 /* Holds state for streaming compression. Shared across all invocation.
Populated on first use. */
ZSTD_CStream* cstream;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 } ZstdCompressor;
extern PyTypeObject ZstdCompressorType;
typedef struct {
PyObject_HEAD
ZstdCompressor* compressor;
ZSTD_outBuffer output;
Gregory Szorc
zstd: vendor python-zstandard 0.6.0...
r30822 int finished;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 } ZstdCompressionObj;
extern PyTypeObject ZstdCompressionObjType;
typedef struct {
PyObject_HEAD
ZstdCompressor* compressor;
PyObject* writer;
Py_ssize_t sourceSize;
size_t outSize;
int entered;
} ZstdCompressionWriter;
extern PyTypeObject ZstdCompressionWriterType;
typedef struct {
PyObject_HEAD
ZstdCompressor* compressor;
PyObject* reader;
Py_buffer* buffer;
Py_ssize_t bufferOffset;
Py_ssize_t sourceSize;
size_t inSize;
size_t outSize;
ZSTD_inBuffer input;
ZSTD_outBuffer output;
int finishedOutput;
int finishedInput;
PyObject* readResult;
} ZstdCompressorIterator;
extern PyTypeObject ZstdCompressorIteratorType;
typedef struct {
PyObject_HEAD
Gregory Szorc
zstd: vendor python-zstandard 0.7.0...
r30895 ZSTD_DCtx* dctx;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435
ZstdCompressionDict* dict;
ZSTD_DDict* ddict;
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 ZSTD_DStream* dstream;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 } ZstdDecompressor;
extern PyTypeObject ZstdDecompressorType;
typedef struct {
PyObject_HEAD
ZstdDecompressor* decompressor;
int finished;
} ZstdDecompressionObj;
extern PyTypeObject ZstdDecompressionObjType;
typedef struct {
PyObject_HEAD
ZstdDecompressor* decompressor;
PyObject* writer;
size_t outSize;
int entered;
} ZstdDecompressionWriter;
extern PyTypeObject ZstdDecompressionWriterType;
typedef struct {
PyObject_HEAD
ZstdDecompressor* decompressor;
PyObject* reader;
Py_buffer* buffer;
Py_ssize_t bufferOffset;
size_t inSize;
size_t outSize;
size_t skipBytes;
ZSTD_inBuffer input;
ZSTD_outBuffer output;
Py_ssize_t readCount;
int finishedInput;
int finishedOutput;
} ZstdDecompressorIterator;
extern PyTypeObject ZstdDecompressorIteratorType;
typedef struct {
int errored;
PyObject* chunk;
} DecompressorIteratorResult;
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 typedef struct {
unsigned long long offset;
unsigned long long length;
} BufferSegment;
typedef struct {
PyObject_HEAD
PyObject* parent;
BufferSegment* segments;
Py_ssize_t segmentCount;
} ZstdBufferSegments;
extern PyTypeObject ZstdBufferSegmentsType;
typedef struct {
PyObject_HEAD
PyObject* parent;
void* data;
Py_ssize_t dataSize;
unsigned long long offset;
} ZstdBufferSegment;
extern PyTypeObject ZstdBufferSegmentType;
typedef struct {
PyObject_HEAD
Py_buffer parent;
void* data;
unsigned long long dataSize;
BufferSegment* segments;
Py_ssize_t segmentCount;
int useFree;
} ZstdBufferWithSegments;
extern PyTypeObject ZstdBufferWithSegmentsType;
/**
* An ordered collection of BufferWithSegments exposed as a squashed collection.
*
* This type provides a virtual view spanning multiple BufferWithSegments
* instances. It allows multiple instances to be "chained" together and
* exposed as a single collection. e.g. if there are 2 buffers holding
* 10 segments each, then o[14] will access the 5th segment in the 2nd buffer.
*/
typedef struct {
PyObject_HEAD
/* An array of buffers that should be exposed through this instance. */
ZstdBufferWithSegments** buffers;
/* Number of elements in buffers array. */
Py_ssize_t bufferCount;
/* Array of first offset in each buffer instance. 0th entry corresponds
to number of elements in the 0th buffer. 1st entry corresponds to the
sum of elements in 0th and 1st buffers. */
Py_ssize_t* firstElements;
} ZstdBufferWithSegmentsCollection;
extern PyTypeObject ZstdBufferWithSegmentsCollectionType;
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 void ztopy_compression_parameters(CompressionParametersObject* params, ZSTD_compressionParameters* zparams);
CompressionParametersObject* get_compression_parameters(PyObject* self, PyObject* args);
Gregory Szorc
zstd: vendor python-zstandard 0.7.0...
r30895 FrameParametersObject* get_frame_parameters(PyObject* self, PyObject* args);
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 PyObject* estimate_compression_context_size(PyObject* self, PyObject* args);
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 int init_cstream(ZstdCompressor* compressor, unsigned long long sourceSize);
int init_mtcstream(ZstdCompressor* compressor, Py_ssize_t sourceSize);
int init_dstream(ZstdDecompressor* decompressor);
Gregory Szorc
zstd: vendor python-zstandard 0.5.0...
r30435 ZstdCompressionDict* train_dictionary(PyObject* self, PyObject* args, PyObject* kwargs);
Gregory Szorc
zstd: vendor python-zstandard 0.8.0...
r31796 ZstdCompressionDict* train_cover_dictionary(PyObject* self, PyObject* args, PyObject* kwargs);
ZstdBufferWithSegments* BufferWithSegments_FromMemory(void* data, unsigned long long dataSize, BufferSegment* segments, Py_ssize_t segmentsSize);
Py_ssize_t BufferWithSegmentsCollection_length(ZstdBufferWithSegmentsCollection*);
int cpu_count(void);
size_t roundpow2(size_t);