summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2012-05-29 12:15:47 -0400
committerKristian Høgsberg <krh@bitplanet.net>2012-05-29 12:15:47 -0400
commit053be42a4ed4910e5d1f4c89c94a8d04da4842b9 (patch)
treebb0546b0e6a80643c93dc2eaaba7be2b66919ab0
parentdb0623a5f054324b27aa9cf40474aa9f283e6723 (diff)
wcap: Compute per-component deltas
-rw-r--r--src/screenshooter.c14
-rw-r--r--wcap/wcap-decode.c11
2 files changed, 22 insertions, 3 deletions
diff --git a/src/screenshooter.c b/src/screenshooter.c
index da06ae3..246796e 100644
--- a/src/screenshooter.c
+++ b/src/screenshooter.c
@@ -240,6 +240,18 @@ output_run(uint32_t *p, uint32_t delta, int run)
return p;
}
+static uint32_t
+component_delta(uint32_t next, uint32_t prev)
+{
+ unsigned char dr, dg, db;
+
+ dr = (next >> 16) - (prev >> 16);
+ dg = (next >> 8) - (prev >> 8);
+ db = (next >> 0) - (prev >> 0);
+
+ return (dr << 16) | (dg << 8) | (db << 0);
+}
+
static void
weston_recorder_frame_notify(struct wl_listener *listener, void *data)
{
@@ -295,7 +307,7 @@ weston_recorder_frame_notify(struct wl_listener *listener, void *data)
stride * (r[i].y2 - j - 1) + r[i].x1;
for (k = 0; k < width; k++) {
next = *s++;
- delta = (next - *d) & 0x00ffffff;
+ delta = component_delta(next, *d);
*d++ = next;
if (run == 0 || delta == prev) {
run++;
diff --git a/wcap/wcap-decode.c b/wcap/wcap-decode.c
index 3ce7a19..425ccff 100644
--- a/wcap/wcap-decode.c
+++ b/wcap/wcap-decode.c
@@ -42,7 +42,8 @@ wcap_decoder_decode_rectangle(struct wcap_decoder *decoder,
uint32_t v, *p = decoder->p, *d;
int width = rect->x2 - rect->x1, height = rect->y2 - rect->y1;
int x, i, j, k, l, count = width * height;
-
+ unsigned char r, g, b, dr, dg, db;
+
d = decoder->frame + (rect->y2 - 1) * decoder->width;
x = rect->x1;
i = 0;
@@ -55,8 +56,14 @@ wcap_decoder_decode_rectangle(struct wcap_decoder *decoder,
j = 1 << (l - 0xe0 + 7);
}
+ dr = (v >> 16);
+ dg = (v >> 8);
+ db = (v >> 0);
for (k = 0; k < j; k++) {
- d[x] = (d[x] + v) | 0xff000000;
+ r = (d[x] >> 16) + dr;
+ g = (d[x] >> 8) + dg;
+ b = (d[x] >> 0) + db;
+ d[x] = 0xff000000 | (r << 16) | (g << 8) | b;
x++;
if (x == rect->x2) {
x = rect->x1;