Make VisualStudio ignore the crypto stuff

Add stubs for the crypto functions so we can refer to them, even if we
never use them.
This commit is contained in:
Ari Koivula 2016-06-07 12:06:03 +03:00
parent 1354b9a997
commit 8eb087120e
6 changed files with 77 additions and 7 deletions

View file

@ -125,6 +125,7 @@
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\extras\crypto.cpp" />
<ClCompile Include="..\..\src\extras\libmd5.c" />
<ClCompile Include="..\..\src\input_frame_buffer.c" />
<ClCompile Include="..\..\src\kvazaar.c" />
@ -177,6 +178,7 @@
<ClCompile Include="..\..\src\strategies\strategies-quant.c" />
<ClInclude Include="..\..\src\checkpoint.h" />
<ClInclude Include="..\..\src\cu.h" />
<ClInclude Include="..\..\src\extras\crypto.h" />
<ClInclude Include="..\..\src\extras\libmd5.h" />
<ClInclude Include="..\..\src\image.h" />
<ClInclude Include="..\..\src\imagelist.h" />

View file

@ -217,6 +217,7 @@
<Filter>Optimization\strategies\avx2</Filter>
</ClCompile>
<ClCompile Include="..\..\src\extras\libmd5.c" />
<ClCompile Include="..\..\src\extras\crypto.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\bitstream.h">
@ -403,6 +404,7 @@
<Filter>Optimization\strategies\avx2</Filter>
</ClInclude>
<ClInclude Include="..\..\src\extras\libmd5.h" />
<ClInclude Include="..\..\src\extras\crypto.h" />
</ItemGroup>
<ItemGroup>
<YASM Include="..\..\src\extras\x86inc.asm">

View file

@ -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);
}

View file

@ -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;

View file

@ -1,4 +1,9 @@
#include <extras/crypto.h>
#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 <cryptopp/aes.h>
#include <cryptopp/modes.h>
#include <cryptopp/osrng.h>
@ -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

View file

@ -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 <stdio.h>
#include <math.h>
@ -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 <assert.h>
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_