Browse Source

+ add 'random' sampler : for testing

master
Alex 'AdUser' Z 8 years ago
parent
commit
38ab5ab60d
  1. 2
      CMakeLists.txt
  2. 36
      src/samplers/random.c

2
CMakeLists.txt

@ -23,6 +23,8 @@ endif ()
if (${SAMPLER} STREQUAL "dummy")
set(SAMPLER "dummy")
elseif (${SAMPLER} STREQUAL "random")
set(SAMPLER "random")
else ()
set(SAMPLER "magick")
endif ()

36
src/samplers/random.c

@ -0,0 +1,36 @@
#include "../common.h"
#include "../record.h"
#include "../simdb.h"
simdb_urec_t *
simdb_record_create(const char * const path) {
simdb_urec_t *tmp;
uint8_t pattern;
uint16_t size;
float ratio = 0;
assert(path != NULL);
(void)(path);
if ((tmp = calloc(1, sizeof(simdb_urec_t))) == NULL)
return NULL;
tmp->used = 0xFF;
size = 200 + rand() % 2000; /* [200, 2200] */
ratio = ((50 + rand() % 100) / (float) 100); /* [0.5, 1.5] */
tmp->image_w = size;
tmp->image_h = size * ratio;
pattern = rand() % 256;
for (size_t i = 0; i < 16; i += 2)
tmp->bitmap[i + 0] = pattern,
tmp->bitmap[i + 1] = ~pattern;
pattern = rand() % 256;
for (size_t i = 16; i < 32; i += 2)
tmp->bitmap[i + 0] = pattern,
tmp->bitmap[i + 1] = ~pattern;
return tmp;
}
Loading…
Cancel
Save