This code reduces a unsigned 32 bit integer into a 8bit as per our requirement.
Currently this operation takes almost 2.1 mili sec to complete. Can it be optimized to complete at least under 0.9 mili sec.
Currently running it on an embedded system running on Arm Cortex-A53
#define BUFFER_SIZE 0x10000
#define POSTBIN_BUFF_SIZE 0x4000
#define MOD_VAL 0x3FFF
#define BINNING 256
#define RESOLUTION MOD_VAL+1
uint8_t *local_buff = malloc(BUFFER_SIZE);
uint32_t *buffer = (uint32_t *)malloc(BUFFER_SIZE);
for (int index = 0; index < POSTBIN_BUFF_SIZE; index++)
{
mod_val = (buffer[index] & MOD_VAL);
local_buff[index] = ((mod_val * BINNING) / RESOLUTION);
}
I tried to do a right shift operation instead of division(RESOLUTION), but it only increased the time of operation instead of reducing it.