Added bit sequence state apply

master
Xavier Arteaga 4 years ago committed by Andre Puschmann
parent fe0dc77c03
commit d66dac0ab2

@ -38,6 +38,9 @@ SRSRAN_API void srsran_sequence_state_gen_f(srsran_sequence_state_t* s, float va
SRSRAN_API void srsran_sequence_state_apply_f(srsran_sequence_state_t* s, const float* in, float* out, uint32_t length); SRSRAN_API void srsran_sequence_state_apply_f(srsran_sequence_state_t* s, const float* in, float* out, uint32_t length);
SRSRAN_API void
srsran_sequence_state_apply_bit(srsran_sequence_state_t* s, const uint8_t* in, uint8_t* out, uint32_t length);
SRSRAN_API void srsran_sequence_state_advance(srsran_sequence_state_t* s, uint32_t length); SRSRAN_API void srsran_sequence_state_advance(srsran_sequence_state_t* s, uint32_t length);
typedef struct SRSRAN_API { typedef struct SRSRAN_API {

@ -611,16 +611,13 @@ void srsran_sequence_apply_c(const int8_t* in, int8_t* out, uint32_t length, uin
} }
} }
void srsran_sequence_apply_bit(const uint8_t* in, uint8_t* out, uint32_t length, uint32_t seed) void srsran_sequence_state_apply_bit(srsran_sequence_state_t* s, const uint8_t* in, uint8_t* out, uint32_t length)
{ {
uint32_t x1 = sequence_x1_init; // X1 initial state is fix
uint32_t x2 = sequence_get_x2_init(seed); // loads x2 initial state
uint32_t i = 0; uint32_t i = 0;
if (length >= SEQUENCE_PAR_BITS) { if (length >= SEQUENCE_PAR_BITS) {
for (; i < length - (SEQUENCE_PAR_BITS - 1); i += SEQUENCE_PAR_BITS) { for (; i < length - (SEQUENCE_PAR_BITS - 1); i += SEQUENCE_PAR_BITS) {
uint32_t c = (uint32_t)(x1 ^ x2); uint32_t c = (uint32_t)(s->x1 ^ s->x2);
uint32_t j = 0; uint32_t j = 0;
#ifdef LV_HAVE_SSE #ifdef LV_HAVE_SSE
@ -656,20 +653,27 @@ void srsran_sequence_apply_bit(const uint8_t* in, uint8_t* out, uint32_t length,
} }
// Step sequences // Step sequences
x1 = sequence_gen_LTE_pr_memless_step_par_x1(x1); s->x1 = sequence_gen_LTE_pr_memless_step_par_x1(s->x1);
x2 = sequence_gen_LTE_pr_memless_step_par_x2(x2); s->x2 = sequence_gen_LTE_pr_memless_step_par_x2(s->x2);
} }
} }
for (; i < length; i++) { for (; i < length; i++) {
out[i] = in[i] ^ ((x1 ^ x2) & 1U); out[i] = in[i] ^ ((s->x1 ^ s->x2) & 1U);
// Step sequences // Step sequences
x1 = sequence_gen_LTE_pr_memless_step_x1(x1); s->x1 = sequence_gen_LTE_pr_memless_step_x1(s->x1);
x2 = sequence_gen_LTE_pr_memless_step_x2(x2); s->x2 = sequence_gen_LTE_pr_memless_step_x2(s->x2);
} }
} }
void srsran_sequence_apply_bit(const uint8_t* in, uint8_t* out, uint32_t length, uint32_t seed)
{
srsran_sequence_state_t sequence_state = {};
srsran_sequence_state_init(&sequence_state, seed);
srsran_sequence_state_apply_bit(&sequence_state, in, out, length);
}
void srsran_sequence_apply_packed(const uint8_t* in, uint8_t* out, uint32_t length, uint32_t seed) void srsran_sequence_apply_packed(const uint8_t* in, uint8_t* out, uint32_t length, uint32_t seed)
{ {
uint32_t x1 = sequence_x1_init; // X1 initial state is fix uint32_t x1 = sequence_x1_init; // X1 initial state is fix
@ -750,7 +754,7 @@ void srsran_sequence_apply_packed(const uint8_t* in, uint8_t* out, uint32_t leng
out[i] = in[i] ^ reverse_lut[buffer & ((1U << rem8) - 1U) & 255U]; out[i] = in[i] ^ reverse_lut[buffer & ((1U << rem8) - 1U) & 255U];
} }
#else // SEQUENCE_PAR_BITS % 8 == 0 #else // SEQUENCE_PAR_BITS % 8 == 0
while (i < (length / 8 - (SEQUENCE_PAR_BITS - 1) / 8)) { while (i < (length / 8 - (SEQUENCE_PAR_BITS - 1) / 8)) {
uint32_t c = (uint32_t)(x1 ^ x2); uint32_t c = (uint32_t)(x1 ^ x2);

Loading…
Cancel
Save