1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
/*
* Copyright 1994-2012 Olivier Girondel
*
* This file is part of lebiniou.
*
* lebiniou is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* lebiniou is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with lebiniou. If not, see <http://www.gnu.org/licenses/>.
*/
#include "context.h"
u_long id = 1329763807;
u_long options = BE_GFX|BEQ_PICTURE|BEQ_BYPASS;
char desc[] = "DiffTV";
u_long mode = OVERLAY;
extern int webcams;
#if 0
// #define PALETTE 1
#ifdef PALETTE
#define MaxColor 120
#endif
#define Decay 15
#define MAGIC_THRESHOLD 50
static Buffer8_t *buffer = NULL, *diff = NULL;
#ifdef PALETTE
static Cmap8_t *palette = NULL;
#endif
/*
* fastrand - fast fake random number generator
* Warning: The low-order bits of numbers generated by fastrand()
* are bad as random numbers. For example, fastrand()%4
* generates 1,2,3,0,1,2,3,0...
* You should use high-order bits.
*/
static unsigned int fastrand_val;
static unsigned int
fastrand()
{
return (fastrand_val = fastrand_val * 1103515245 + 12345);
}
static void
fastsrand(unsigned int seed)
{
fastrand_val = seed;
}
#ifdef PALETTE
static void
HSItoRGB(double h, double s, double i, int *r, int *g, int *b)
{
double t, rv, gv, bv;
rv = 1 + s * sin(h - 2 * M_PI / 3);
gv = 1 + s * sin(h);
bv = 1 + s * sin(h + 2 * M_PI / 3);
t = 255.999 * i / 2;
*r = trunc(rv * t);
*g = trunc(gv * t);
*b = trunc(bv * t);
}
static void
make_palette(Cmap8_t *palette)
{
int i, r, g, b;
for (i = 0; i < MaxColor; i++) {
HSItoRGB(4.6 - 1.5 * i / MaxColor, (double)i / MaxColor, (double)i / MaxColor, &r, &g, &b);
palette->colors[i].col.r = r;
palette->colors[i].col.g = g;
palette->colors[i].col.b = b;
}
for (i = MaxColor; i < 256; i++) {
if (r < 255) r++;
if (r < 255) r++;
if (r < 255) r++;
if (g < 255) g++;
if (g < 255) g++;
if (b < 255) b++;
if (b < 255) b++;
palette->colors[i].col.r = r;
palette->colors[i].col.g = g;
palette->colors[i].col.b = b;
}
}
#endif
#endif /* 0liv3 */
void
create(__attribute__ ((unused)) Context_t *ctx)
{
if (!webcams)
options |= BEQ_DISABLED;
/*
else {
buffer = Buffer8_new();
diff = Buffer8_new();
fastsrand(time(NULL));
}
*/
}
void
on_switch_on(Context_t *ctx)
{
ctx->ref_taken[ctx->cam] = 0;
}
void
delete(__attribute__ ((unused)) Context_t *ctx)
{
/*
Buffer8_delete(buffer);
Buffer8_delete(diff);
*/
}
void
run(Context_t *ctx)
{
Pixel_t *src1, *start, *src2, *dst;
if (!webcams)
return;
dst = start = passive_buffer(ctx)->buffer;
pthread_mutex_lock(&ctx->cam_mtx[ctx->cam]);
src1 = ctx->cam_save[ctx->cam][0]->buffer;
src2 = ctx->cam_ref[ctx->cam]->buffer;
for (; dst < start+BUFFSIZE*sizeof(Pixel_t); src1++, src2++, dst++)
*dst = abs(*src1 - *src2);
pthread_mutex_unlock(&ctx->cam_mtx[ctx->cam]);
}
|