mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
commit
5ceec06bd3
|
@ -113,13 +113,6 @@ static int encoder_state_config_tile_init(encoder_state_t * const state,
|
|||
state->tile->wf_jobs = NULL;
|
||||
}
|
||||
state->tile->id = encoder->tiles_tile_id[state->tile->lcu_offset_in_ts];
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -131,7 +124,7 @@ static void encoder_state_config_tile_finalize(encoder_state_t * const state) {
|
|||
|
||||
kvz_videoframe_free(state->tile->frame);
|
||||
state->tile->frame = NULL;
|
||||
if (state->encoder_control->cfg->crypto_features) {
|
||||
if (state->encoder_control->cfg->crypto_features && state->tile->dbs_g) {
|
||||
DeleteCryptoC(state->tile->dbs_g);
|
||||
}
|
||||
FREE_POINTER(state->tile->wf_jobs);
|
||||
|
@ -327,6 +320,8 @@ int kvz_encoder_state_init(encoder_state_t * const child_state, encoder_state_t
|
|||
fprintf(stderr, "Could not initialize encoder_state->tile!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
child_state->tile->dbs_g = NULL; // Not used. The used state is in the sub-tile.
|
||||
child_state->slice = MALLOC(encoder_state_config_slice_t, 1);
|
||||
if (!child_state->slice || !encoder_state_config_slice_init(child_state, 0, encoder->in.width_in_lcu * encoder->in.height_in_lcu - 1)) {
|
||||
fprintf(stderr, "Could not initialize encoder_state->slice!\n");
|
||||
|
@ -456,6 +451,9 @@ int kvz_encoder_state_init(encoder_state_t * const child_state, encoder_state_t
|
|||
new_child->type = ENCODER_STATE_TYPE_TILE;
|
||||
new_child->frame = child_state->frame;
|
||||
new_child->tile = MALLOC(encoder_state_config_tile_t, 1);
|
||||
if (child_state->encoder_control->cfg->crypto_features) {
|
||||
new_child->tile->dbs_g = CreateC();
|
||||
}
|
||||
new_child->slice = child_state->slice;
|
||||
new_child->wfrow = child_state->wfrow;
|
||||
|
||||
|
|
|
@ -297,7 +297,10 @@ static void encoder_state_encode_leaf(encoder_state_t * const state) {
|
|||
assert(state->lcu_order_count > 0);
|
||||
|
||||
const kvz_config *cfg = state->encoder_control->cfg;
|
||||
|
||||
if ( state->encoder_control->cfg->crypto_features) {
|
||||
InitC(state->tile->dbs_g);
|
||||
state->tile->m_prev_pos = 0;
|
||||
}
|
||||
// Select whether to encode the frame/tile in current thread or to define
|
||||
// wavefront jobs for other threads to handle.
|
||||
bool wavefront = state->type == ENCODER_STATE_TYPE_WAVEFRONT_ROW;
|
||||
|
|
|
@ -19,9 +19,12 @@ typedef struct AESDecoder {
|
|||
} AESDecoder;
|
||||
|
||||
|
||||
AESDecoder* Init() {
|
||||
AESDecoder* Create() {
|
||||
AESDecoder * AESdecoder = (AESDecoder *)malloc(sizeof(AESDecoder));
|
||||
return AESdecoder;
|
||||
}
|
||||
void Init(AESDecoder* AESdecoder) {
|
||||
int init_val[32] = {201, 75, 219, 152, 6, 245, 237, 107, 179, 194, 81, 29, 66, 98, 198, 0, 16, 213, 27, 56, 255, 127, 242, 112, 97, 126, 197, 204, 25, 59, 38, 30};
|
||||
AESDecoder * AESdecoder = (AESDecoder *)malloc(sizeof(AESDecoder));
|
||||
for(int i=0;i<16; i++) {
|
||||
AESdecoder->iv [i] = init_val[i];
|
||||
AESdecoder->counter[i] = init_val[5+i];
|
||||
|
@ -35,7 +38,6 @@ AESDecoder* Init() {
|
|||
AESdecoder->couter_avail = 0;
|
||||
AESdecoder->counter_index = 0;
|
||||
AESdecoder->counter_index_pos = 0;
|
||||
return AESdecoder;
|
||||
}
|
||||
|
||||
void DeleteCrypto(AESDecoder * AESdecoder) {
|
||||
|
@ -105,11 +107,15 @@ unsigned int get_key (AESDecoder * AESdecoder, int nb_bits) {
|
|||
return key_;
|
||||
}
|
||||
#endif
|
||||
|
||||
Crypto_Handle InitC(){
|
||||
AESDecoder* AESdecoder = Init();
|
||||
return AESdecoder;
|
||||
Crypto_Handle CreateC() {
|
||||
AESDecoder* AESdecoder = Create();
|
||||
return AESdecoder;
|
||||
}
|
||||
|
||||
void InitC(Crypto_Handle hdl) {
|
||||
Init((AESDecoder*)hdl);
|
||||
}
|
||||
|
||||
#if AESEncryptionStreamMode
|
||||
unsigned int ff_get_key (Crypto_Handle *hdl, int nb_bits) {
|
||||
return get_key ((AESDecoder*)*hdl, nb_bits);
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
typedef void* Crypto_Handle;
|
||||
|
||||
STUBBED Crypto_Handle InitC();
|
||||
STUBBED Crypto_Handle CreateC();
|
||||
STUBBED void InitC(Crypto_Handle hdl);
|
||||
STUBBED void DecryptC(Crypto_Handle hdl, const unsigned char *in_stream, int size_bits, unsigned char *out_stream);
|
||||
#if AESEncryptionStreamMode
|
||||
STUBBED unsigned int ff_get_key(Crypto_Handle *hdl, int nb_bits);
|
||||
|
@ -36,27 +36,36 @@ extern "C" {
|
|||
// 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>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
static INLINE Crypto_Handle InitC()
|
||||
{
|
||||
// Stub.
|
||||
assert(0);
|
||||
return 0;
|
||||
static uint64_t handle_id = 1;
|
||||
|
||||
static INLINE Crypto_Handle CreateC() {
|
||||
printf("Crypto CreateC %" PRIu64 "\n", (uint64_t)handle_id);
|
||||
return (void*)(handle_id++);
|
||||
}
|
||||
static INLINE void InitC(Crypto_Handle hdl) {
|
||||
printf("Crypto InitC %" PRIu64 "\n", (uint64_t)hdl);
|
||||
}
|
||||
|
||||
static INLINE void DecryptC(Crypto_Handle hdl, const unsigned char *in_stream,
|
||||
int size_bits, unsigned char *out_stream)
|
||||
{
|
||||
// Stub.
|
||||
assert(0);
|
||||
printf("Crypto DecryptC %" PRIu64 "\n", (uint64_t)hdl);
|
||||
}
|
||||
|
||||
#if AESEncryptionStreamMode
|
||||
static INLINE unsigned int ff_get_key(Crypto_Handle *hdl, int nb_bits)
|
||||
{
|
||||
// Stub.
|
||||
assert(0);
|
||||
static Crypto_Handle ff_get_key_last_hdl = 0;
|
||||
if (*hdl != ff_get_key_last_hdl) {
|
||||
printf("Crypto ff_get_key %" PRIu64 "\n", (uint64_t)*hdl);
|
||||
}
|
||||
ff_get_key_last_hdl = *hdl;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -64,7 +73,7 @@ static INLINE unsigned int ff_get_key(Crypto_Handle *hdl, int nb_bits)
|
|||
static INLINE void DeleteCryptoC(Crypto_Handle hdl)
|
||||
{
|
||||
// Stub.
|
||||
assert(0);
|
||||
printf("Crypto DeleteCryptoC %" PRIu64 "\n", (uint64_t)hdl);
|
||||
}
|
||||
|
||||
#endif // KVZ_SEL_ENCRYPTION
|
||||
|
|
Loading…
Reference in a new issue