summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/global_config.cpp8
-rw-r--r--core/io/compression.cpp10
2 files changed, 13 insertions, 5 deletions
diff --git a/core/global_config.cpp b/core/global_config.cpp
index 896384d9c8..0729d4c482 100644
--- a/core/global_config.cpp
+++ b/core/global_config.cpp
@@ -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;
}
diff --git a/core/io/compression.cpp b/core/io/compression.cpp
index 9c3e0e8eca..9ae54c38af 100644
--- a/core/io/compression.cpp
+++ b/core/io/compression.cpp
@@ -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;
}