void sine_mod_amp(QSP_ARG_DECL int nframes,float *phases,int period,float *envelope,const char *lutstem) { float amps[MAX_COMPS]; float arginc; float factor; char str[32]; int i,j; arginc = (float)(8*atan(1)/period); for(i=0;i<nframes;i++){ sprintf(str,"%s%d",lutstem,i); if( new_colormap(QSP_ARG str) == NO_OBJ ) NERROR1("error creating LUT buffer"); if( envelope != ((float *)NULL) ) factor=envelope[i]; else factor=1; for(j=0;j<n_comps;j++){ #ifdef SINE_TBL amps[j]=(float)(factor*t_sin(phases[j])); #else /* ! SINE_TBL */ amps[j]=(float)(factor*sin(phases[j])); #endif /* ! SINE_TBL */ phases[j]+=arginc; } set_comp_amps(QSP_ARG amps); index_alpha(i,0,255); } }
static COMMAND_FUNC( do_index_alpha ) { int index,hv,lv; /* set alpha entries */ index = (int)HOW_MANY("index to display"); lv = (int)HOW_MANY("alpha value for zero bit"); hv = (int)HOW_MANY("alpha value for one bit"); CHECK_DPYP("do_index_alpha") index_alpha(index,lv,hv); }
void fill_segment(const argon2_instance_t *instance, argon2_position_t position) { block *ref_block = NULL, *curr_block = NULL; uint64_t pseudo_rand, ref_index; uint32_t prev_offset, curr_offset; uint8_t i; __m128i state[64]; int data_independent_addressing = (instance->type == Argon2_i); /* Pseudo-random values that determine the reference block position */ uint64_t *pseudo_rands = NULL; pseudo_rands = (uint64_t *)malloc(/*sizeof(uint64_t) * 4*/32); if (data_independent_addressing) { generate_addresses(instance, &position, pseudo_rands); } i = 0; if ((0 == position.pass) && (0 == position.slice)) { i = 2; /* we have already generated the first two blocks */ } /*printf("Position.lane = %d\nPosition.slice = %d\nStarting index : %d\n", position.lane, position.slice, starting_index);*/ /* Offset of the current block */ curr_offset = position.slice * 4 + i; if (0 == curr_offset % 16) { /* Last block in this lane */ prev_offset = curr_offset + /*instance->lane_length - 1*/15; } else { /* Previous block */ prev_offset = curr_offset - 1; } memcpy(state, ((instance->memory + prev_offset)->v), ARGON2_BLOCK_SIZE); for (; i < SEGMENT_LENGTH; ++i, ++curr_offset, ++prev_offset) { /*1.1 Rotating prev_offset if needed */ if (curr_offset % LANE_LENGTH == 1) { prev_offset = curr_offset - 1; } /* 1.2 Computing the index of the reference block */ /* 1.2.1 Taking pseudo-random value from the previous block */ if (data_independent_addressing) { pseudo_rand = pseudo_rands[i]; } else { pseudo_rand = instance->memory[prev_offset].v[0]; } /* 1.2.2 Computing the lane of the reference block */ /* 1.2.3 Computing the number of possible reference block within the * lane. */ position.index = i; ref_index = index_alpha(instance, &position, pseudo_rand & 0xFFFFFFFF,1); /* 2 Creating a new block */ ref_block = instance->memory + ref_index; curr_block = instance->memory + curr_offset; fill_block(state, (__m128i const *)ref_block->v, (__m128i *)curr_block->v); } free(pseudo_rands); }