diff --git a/build/kvazaar_lib/kvazaar_lib.vcxproj b/build/kvazaar_lib/kvazaar_lib.vcxproj
index 6951eb61..408d93eb 100644
--- a/build/kvazaar_lib/kvazaar_lib.vcxproj
+++ b/build/kvazaar_lib/kvazaar_lib.vcxproj
@@ -125,6 +125,7 @@
+
@@ -177,6 +178,7 @@
+
diff --git a/build/kvazaar_lib/kvazaar_lib.vcxproj.filters b/build/kvazaar_lib/kvazaar_lib.vcxproj.filters
index ce554e70..496e9f3d 100644
--- a/build/kvazaar_lib/kvazaar_lib.vcxproj.filters
+++ b/build/kvazaar_lib/kvazaar_lib.vcxproj.filters
@@ -217,6 +217,7 @@
Optimization\strategies\avx2
+
@@ -403,6 +404,7 @@
Optimization\strategies\avx2
+
diff --git a/src/encoder_state-ctors_dtors.c b/src/encoder_state-ctors_dtors.c
index 7d4001b3..c5606f5f 100644
--- a/src/encoder_state-ctors_dtors.c
+++ b/src/encoder_state-ctors_dtors.c
@@ -106,8 +106,12 @@ static int encoder_state_config_tile_init(encoder_state_t * const state,
}
state->tile->id = encoder->tiles_tile_id[state->tile->lcu_offset_in_ts];
- state->tile->dbs_g = InitC();
+ state->tile->dbs_g = NULL;
+ if (state->encoder_control->cfg->crypto_features) {
+ state->tile->dbs_g = InitC();
+ }
state->tile->m_prev_pos = 0;
+
return 1;
}
@@ -119,7 +123,9 @@ static void encoder_state_config_tile_finalize(encoder_state_t * const state) {
kvz_videoframe_free(state->tile->frame);
state->tile->frame = NULL;
- DeleteCryptoC(state->tile->dbs_g);
+ if (state->encoder_control->cfg->crypto_features) {
+ DeleteCryptoC(state->tile->dbs_g);
+ }
FREE_POINTER(state->tile->wf_jobs);
}
diff --git a/src/encoderstate.h b/src/encoderstate.h
index ad9b619d..bcdd0f4b 100644
--- a/src/encoderstate.h
+++ b/src/encoderstate.h
@@ -116,7 +116,7 @@ typedef struct {
threadqueue_job_t **wf_jobs;
// Instance of encryption generator by tile
- Crypto_Handle dbs_g;
+ Crypto_Handle dbs_g;
uint32_t m_prev_pos;
} encoder_state_config_tile_t;
diff --git a/src/extras/crypto.cpp b/src/extras/crypto.cpp
index 3ed0c596..58a5f11d 100644
--- a/src/extras/crypto.cpp
+++ b/src/extras/crypto.cpp
@@ -1,4 +1,9 @@
#include
+
+#ifndef KVZ_SEL_ENCRYPTION
+extern int kvz_make_vs_ignore_crypto_not_having_symbols;
+int kvz_make_vs_ignore_crypto_not_having_symbols = 0;
+#else
#include
#include
#include
@@ -117,3 +122,5 @@ void DecryptC(Crypto_Handle hdl, const unsigned char *in_stream, int size_bits,
void DeleteCryptoC(Crypto_Handle hdl) {
DeleteCryptoC(hdl);
}
+
+#endif // KVZ_SEL_ENCRYPTION
diff --git a/src/extras/crypto.h b/src/extras/crypto.h
index a63e1e95..22efedf5 100644
--- a/src/extras/crypto.h
+++ b/src/extras/crypto.h
@@ -1,3 +1,13 @@
+#ifndef CRYPTO_H_
+#define CRYPTO_H_
+
+#include "global.h"
+
+#ifdef KVZ_SEL_ENCRYPTION
+#define STUBBED extern
+#else
+#define STUBBED static
+#endif
#include
#include
@@ -6,14 +16,57 @@
extern "C" {
#endif
typedef void* Crypto_Handle;
- Crypto_Handle InitC();
- void DecryptC(Crypto_Handle hdl, const unsigned char *in_stream, int size_bits, unsigned char *out_stream);
+
+ STUBBED Crypto_Handle InitC();
+ STUBBED void DecryptC(Crypto_Handle hdl, const unsigned char *in_stream, int size_bits, unsigned char *out_stream);
#if AESEncryptionStreamMode
- unsigned int ff_get_key (Crypto_Handle *hdl, int nb_bits);
+ STUBBED unsigned int ff_get_key(Crypto_Handle *hdl, int nb_bits);
#endif
- void DeleteCryptoC(Crypto_Handle hdl);
+ STUBBED void DeleteCryptoC(Crypto_Handle hdl);
#ifdef __cplusplus
}
#endif
+
+#ifndef KVZ_SEL_ENCRYPTION
+// Provide static stubs to allow linking without libcryptopp and allows us to
+// avoid sprinkling ifdefs everywhere and having a bunch of code that's not
+// compiled during normal development.
+// Provide them in the header so we can avoid compiling the cpp file, which
+// means we don't need a C++ compiler when crypto is not enabled.
+
+#include
+
+static INLINE Crypto_Handle InitC()
+{
+ // Stub.
+ assert(0);
+ return 0;
+}
+
+static INLINE void DecryptC(Crypto_Handle hdl, const unsigned char *in_stream,
+ int size_bits, unsigned char *out_stream)
+{
+ // Stub.
+ assert(0);
+}
+
+#if AESEncryptionStreamMode
+static INLINE unsigned int ff_get_key(Crypto_Handle *hdl, int nb_bits)
+{
+ // Stub.
+ assert(0);
+ return 0;
+}
+#endif
+
+static INLINE void DeleteCryptoC(Crypto_Handle hdl)
+{
+ // Stub.
+ assert(0);
+}
+
+#endif // KVZ_SEL_ENCRYPTION
+
+#endif // CRYPTO_H_