summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2014-02-14 14:28:59 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2014-02-14 14:34:47 +0100
commitf15d21389a81f8df36b00113aed5c81d27143861 (patch)
treec7a6247afd73254c202a8ccbb1e93bb43287b315 /plugins
parentdf1ae54168a7dda396050077f14fed33c4882c47 (diff)
downloaduca-f15d21389a81f8df36b00113aed5c81d27143861.tar.gz
uca-f15d21389a81f8df36b00113aed5c81d27143861.tar.bz2
uca-f15d21389a81f8df36b00113aed5c81d27143861.tar.xz
uca-f15d21389a81f8df36b00113aed5c81d27143861.zip
Use read-write ring buffer
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mock/uca-mock-camera.c49
1 files changed, 19 insertions, 30 deletions
diff --git a/plugins/mock/uca-mock-camera.c b/plugins/mock/uca-mock-camera.c
index 18ac7db..b75882e 100644
--- a/plugins/mock/uca-mock-camera.c
+++ b/plugins/mock/uca-mock-camera.c
@@ -155,6 +155,7 @@ static void
print_current_frame (UcaMockCameraPrivate *priv, gchar *buffer)
{
guint number = priv->current_frame;
+ char default_line[priv->width];
guint divisor = 10000000;
int x = 1;
@@ -165,45 +166,33 @@ print_current_frame (UcaMockCameraPrivate *priv, gchar *buffer)
x += DIGIT_WIDTH + 1;
}
-
- //Rainbow pattern is the same for every row. Just calculate one single
- //Scanline, so we can reuse it and dont have to do the whole calculation
- //for every row again.
- char default_line[priv->width];
for (int p = 0; p < priv->width; p++) {
default_line[p] = (char) ((p*256) / (priv->width));
}
-
- //Use memcpy to quickly fill every row with the precalculated rainbow
- //pattern
for (guint y = 16; y < priv->height; y++) {
guint index = y * priv->width;
- memcpy(&buffer[index], &default_line[0], priv->width);
+ memcpy (&buffer[index], &default_line[0], priv->width);
}
- #ifdef __CREATE_RANDOM_IMAGE_DATA__
-
- //This block will fill a square at the center of the image with noraml
- //distributed random data
- const double mean = 128.0;
- const double std = 32.0;
-
- for (guint y = (priv->height/3); y < ((priv->height*2)/3); y++) {
- guint row_start = y * priv->width;
- for (guint i = (priv->width/3); i < ((priv->width*2)/3); i++) {
- int index = row_start + i;
- double u1 = g_rand_double(priv->rand);
- double u2 = g_rand_double(priv->rand);
- double r = sqrt(-2 * log(u1)) * cos(2 * G_PI * u2);
- buffer[index] = (guint8) (r * std + mean);
- }
+#ifdef __CREATE_RANDOM_IMAGE_DATA__
+ //This block will fill a square at the center of the image with noraml
+ //distributed random data
+ const double mean = 128.0;
+ const double std = 32.0;
+
+ for (guint y = (priv->height/3); y < ((priv->height*2)/3); y++) {
+ guint row_start = y * priv->width;
+
+ for (guint i = (priv->width/3); i < ((priv->width*2)/3); i++) {
+ int index = row_start + i;
+ double u1 = g_rand_double (priv->rand);
+ double u2 = g_rand_double (priv->rand);
+ double r = sqrt (-2 * log(u1)) * cos(2 * G_PI * u2);
+ buffer[index] = (guint8) (r * std + mean);
}
-
- #endif
-
-
-
+ }
+#endif
}
static gpointer