 	KernelContext *ctx = (KernelContext*) calloc(1, sizeof(KernelContext));
 	cudaMalloc(&ctx->dbacklogs, sizeof(ctx->backlogs));
 	cudaMalloc(&ctx->ddiffs, sizeof(ctx->diffs));
+	cudaMalloc(&ctx->dmotions, sizeof(ctx->motions));
 	return ctx;
 }
 

		g = ((u >> 8) & 0xff) - ((v >> 8) & 0xff),
		b = ((u >> 16) & 0xff) - ((v >> 16) & 0xff);
	return sqrt(double(r * r + g * g + b * b));
}

__device__ uint32_t diff(uint32_t u, uint32_t v) {
	double d = distance(u, v);
	return d * 0x10000;
}

__device__ uint32_t lum(uint32_t u) {

	KNN_FRAMES = 5,
};

enum {
	Z_THRM = 10 * 0x10000,
	Z_THRD = 10,
};

typedef struct {
	uint32_t v;
	double d;
