Merge pull request #9125 from tagcup/zstd_level
Expose zstd and zlib compression levels as global config.
This commit is contained in:
commit
b7117ffda0
2 changed files with 13 additions and 5 deletions
|
@ -39,6 +39,8 @@
|
|||
#include "os/os.h"
|
||||
#include "variant_parser.h"
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
#define FORMAT_VERSION 3
|
||||
|
||||
GlobalConfig *GlobalConfig::singleton = NULL;
|
||||
|
@ -967,6 +969,12 @@ GlobalConfig::GlobalConfig() {
|
|||
custom_prop_info["physics/2d/thread_model"] = PropertyInfo(Variant::INT, "physics/2d/thread_model", PROPERTY_HINT_ENUM, "Single-Unsafe,Single-Safe,Multi-Threaded");
|
||||
|
||||
GLOBAL_DEF("debug/profiler/max_functions", 16384);
|
||||
|
||||
GLOBAL_DEF("compression/zstd_compression_level", 3);
|
||||
custom_prop_info["compression/zstd_compression_level"] = PropertyInfo(Variant::INT, "compression/zstd_compression_level", PROPERTY_HINT_RANGE, "1,22,1");
|
||||
GLOBAL_DEF("compression/zlib_compression_level", Z_DEFAULT_COMPRESSION);
|
||||
custom_prop_info["compression/zlib_compression_level"] = PropertyInfo(Variant::INT, "compression/zlib_compression_level", PROPERTY_HINT_RANGE, "-1,9,1");
|
||||
|
||||
using_datapack = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#include "compression.h"
|
||||
|
||||
#include "global_config.h"
|
||||
#include "os/copymem.h"
|
||||
#include "zip_io.h"
|
||||
|
||||
|
@ -37,8 +37,6 @@
|
|||
|
||||
#include <zlib.h>
|
||||
|
||||
#define ZSTD_DEFAULT_COMPRESSION 3
|
||||
|
||||
int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size, Mode p_mode) {
|
||||
|
||||
switch (p_mode) {
|
||||
|
@ -60,7 +58,8 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,
|
|||
strm.zalloc = zipio_alloc;
|
||||
strm.zfree = zipio_free;
|
||||
strm.opaque = Z_NULL;
|
||||
int err = deflateInit(&strm, Z_DEFAULT_COMPRESSION);
|
||||
int level = GLOBAL_GET("compression/zlib_compression_level");
|
||||
int err = deflateInit(&strm, level);
|
||||
if (err != Z_OK)
|
||||
return -1;
|
||||
|
||||
|
@ -82,7 +81,8 @@ int Compression::compress(uint8_t *p_dst, const uint8_t *p_src, int p_src_size,
|
|||
case MODE_ZSTD: {
|
||||
|
||||
int max_dst_size = get_max_compressed_buffer_size(p_src_size, MODE_ZSTD);
|
||||
return ZSTD_compress(p_dst, max_dst_size, p_src, p_src_size, ZSTD_DEFAULT_COMPRESSION);
|
||||
int level = GLOBAL_GET("compression/zstd_compression_level");
|
||||
return ZSTD_compress(p_dst, max_dst_size, p_src, p_src_size, level);
|
||||
} break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue