Merge branch 'dev' into btultra2
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
cxx_library(
|
||||
name='zstd',
|
||||
header_namespace='',
|
||||
exported_headers=['zstd.h'],
|
||||
visibility=['PUBLIC'],
|
||||
deps=[
|
||||
':common',
|
||||
@@ -17,7 +18,7 @@ cxx_library(
|
||||
exported_headers=subdir_glob([
|
||||
('compress', 'zstd*.h'),
|
||||
]),
|
||||
srcs=glob(['compress/zstd*.c']),
|
||||
srcs=glob(['compress/zstd*.c', 'compress/hist.c']),
|
||||
deps=[':common'],
|
||||
)
|
||||
|
||||
@@ -40,7 +41,7 @@ cxx_library(
|
||||
header_namespace='',
|
||||
visibility=['PUBLIC'],
|
||||
exported_headers=subdir_glob([
|
||||
('decprecated', '*.h'),
|
||||
('deprecated', '*.h'),
|
||||
]),
|
||||
srcs=glob(['deprecated/*.c']),
|
||||
deps=[':common'],
|
||||
@@ -118,6 +119,7 @@ cxx_library(
|
||||
'decompress/huf_decompress.c',
|
||||
],
|
||||
deps=[
|
||||
':debug',
|
||||
':bitstream',
|
||||
':compiler',
|
||||
':errors',
|
||||
@@ -204,9 +206,20 @@ cxx_library(
|
||||
],
|
||||
)
|
||||
|
||||
cxx_library(
|
||||
name='debug',
|
||||
header_namespace='',
|
||||
visibility=['PUBLIC'],
|
||||
exported_headers=subdir_glob([
|
||||
('common', 'debug.h'),
|
||||
]),
|
||||
srcs=['common/debug.c'],
|
||||
)
|
||||
|
||||
cxx_library(
|
||||
name='common',
|
||||
deps=[
|
||||
':debug',
|
||||
':bitstream',
|
||||
':compiler',
|
||||
':cpu',
|
||||
|
||||
+6
-1
@@ -31,7 +31,12 @@ DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
|
||||
CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
|
||||
FLAGS = $(CPPFLAGS) $(CFLAGS)
|
||||
|
||||
GREP = grep --color=never
|
||||
HAVE_COLORNEVER = $(shell echo a | grep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0)
|
||||
GREP_OPTIONS ?=
|
||||
ifeq ($HAVE_COLORNEVER, 1)
|
||||
GREP_OPTIONS += --color=never
|
||||
endif
|
||||
GREP = grep $(GREP_OPTIONS)
|
||||
|
||||
ZSTDCOMMON_FILES := $(sort $(wildcard common/*.c))
|
||||
ZSTDCOMP_FILES := $(sort $(wildcard compress/*.c))
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ MEM_STATIC ZSTD_cpuid_t ZSTD_cpuid(void) {
|
||||
__asm__(
|
||||
"pushl %%ebx\n\t"
|
||||
"cpuid\n\t"
|
||||
"movl %%ebx, %%eax\n\r"
|
||||
"movl %%ebx, %%eax\n\t"
|
||||
"popl %%ebx"
|
||||
: "=a"(f7b), "=c"(f7c)
|
||||
: "a"(7), "c"(0)
|
||||
|
||||
@@ -4091,19 +4091,21 @@ size_t ZSTD_compress2(ZSTD_CCtx* cctx,
|
||||
void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize)
|
||||
{
|
||||
size_t oPos = 0;
|
||||
size_t iPos = 0;
|
||||
size_t const result = ZSTD_compressStream2_simpleArgs(cctx,
|
||||
dst, dstCapacity, &oPos,
|
||||
src, srcSize, &iPos,
|
||||
ZSTD_e_end);
|
||||
assert(iPos == srcSize);
|
||||
if (ZSTD_isError(result)) return result;
|
||||
if (result != 0) { /* compression not completed, due to lack of output space */
|
||||
assert(oPos == dstCapacity);
|
||||
return ERROR(dstSize_tooSmall);
|
||||
ZSTD_CCtx_reset(cctx, ZSTD_reset_session_only);
|
||||
{ size_t oPos = 0;
|
||||
size_t iPos = 0;
|
||||
size_t const result = ZSTD_compressStream2_simpleArgs(cctx,
|
||||
dst, dstCapacity, &oPos,
|
||||
src, srcSize, &iPos,
|
||||
ZSTD_e_end);
|
||||
if (ZSTD_isError(result)) return result;
|
||||
if (result != 0) { /* compression not completed, due to lack of output space */
|
||||
assert(oPos == dstCapacity);
|
||||
return ERROR(dstSize_tooSmall);
|
||||
}
|
||||
assert(iPos == srcSize); /* all input is expected consumed */
|
||||
return oPos;
|
||||
}
|
||||
return oPos;
|
||||
}
|
||||
|
||||
/*====== Finalize ======*/
|
||||
|
||||
+14
-7
@@ -583,8 +583,9 @@ typedef enum {
|
||||
|
||||
/* frame parameters */
|
||||
ZSTD_c_contentSizeFlag=200, /* Content size will be written into frame header _whenever known_ (default:1)
|
||||
* Content size must be known at the beginning of compression,
|
||||
* it is provided using ZSTD_CCtx_setPledgedSrcSize() */
|
||||
* Content size must be known at the beginning of compression.
|
||||
* This is automatically the case when using ZSTD_compress2(),
|
||||
* For streaming variants, content size must be provided with ZSTD_CCtx_setPledgedSrcSize() */
|
||||
ZSTD_c_checksumFlag=201, /* A 32-bits checksum of content is written at end of frame (default:0) */
|
||||
ZSTD_c_dictIDFlag=202, /* When applicable, dictionary's ID is written into frame header (default:1) */
|
||||
|
||||
@@ -620,12 +621,13 @@ typedef enum {
|
||||
* ZSTD_c_forceMaxWindow
|
||||
* ZSTD_c_forceAttachDict
|
||||
* Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them.
|
||||
* note : never ever use experimentalParam? names directly
|
||||
* note : never ever use experimentalParam? names directly;
|
||||
* also, the enums values themselves are unstable and can still change.
|
||||
*/
|
||||
ZSTD_c_experimentalParam1=500,
|
||||
ZSTD_c_experimentalParam2=10,
|
||||
ZSTD_c_experimentalParam3=1000,
|
||||
ZSTD_c_experimentalParam4
|
||||
ZSTD_c_experimentalParam4=1001
|
||||
} ZSTD_cParameter;
|
||||
|
||||
|
||||
@@ -659,14 +661,17 @@ ZSTDLIB_API size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param
|
||||
|
||||
/*! ZSTD_CCtx_setPledgedSrcSize() :
|
||||
* Total input data size to be compressed as a single frame.
|
||||
* This value will be controlled at end of frame, and trigger an error if not respected.
|
||||
* Value will be written in frame header, unless if explicitly forbidden using ZSTD_c_contentSizeFlag.
|
||||
* This value will also be controlled at end of frame, and trigger an error if not respected.
|
||||
* @result : 0, or an error code (which can be tested with ZSTD_isError()).
|
||||
* Note 1 : pledgedSrcSize==0 actually means zero, aka an empty frame.
|
||||
* In order to mean "unknown content size", pass constant ZSTD_CONTENTSIZE_UNKNOWN.
|
||||
* ZSTD_CONTENTSIZE_UNKNOWN is default value for any new frame.
|
||||
* Note 2 : pledgedSrcSize is only valid once, for the next frame.
|
||||
* It's discarded at the end of the frame.
|
||||
* Note 3 : If all data is provided and consumed in a single round,
|
||||
* It's discarded at the end of the frame, and replaced by ZSTD_CONTENTSIZE_UNKNOWN.
|
||||
* Note 3 : Whenever all input data is provided and consumed in a single round,
|
||||
* for example with ZSTD_compress2(),
|
||||
* or invoking immediately ZSTD_compressStream2(,,,ZSTD_e_end),
|
||||
* this value is automatically overriden by srcSize instead.
|
||||
*/
|
||||
ZSTDLIB_API size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSrcSize);
|
||||
@@ -750,6 +755,8 @@ ZSTDLIB_API size_t ZSTD_CCtx_reset(ZSTD_CCtx* cctx, ZSTD_ResetDirective reset);
|
||||
|
||||
/*! ZSTD_compress2() :
|
||||
* Behave the same as ZSTD_compressCCtx(), but compression parameters are set using the advanced API.
|
||||
* ZSTD_compress2() always starts a new frame.
|
||||
* Should cctx hold data from a previously unfinished frame, everything about it is forgotten.
|
||||
* - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*()
|
||||
* - The function is always blocking, returns when compression is completed.
|
||||
* Hint : compression runs faster if `dstCapacity` >= `ZSTD_compressBound(srcSize)`.
|
||||
|
||||
Reference in New Issue
Block a user