~ubuntu-branches/ubuntu/utopic/lebiniou/utopic

« back to all changes in this revision

Viewing changes to plugins/stable/main/PredatorTV/PredatorTV.c

  • Committer: Package Import Robot
  • Author(s): Olivier Girondel
  • Date: 2012-04-22 22:07:40 UTC
  • mfrom: (6.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20120422220740-xncgwhc3g71nopnu
Tags: 3.18-1
* New upstream release 3.18.
* Support older libswscale.
* Add missing Build-Depends: libfreetype6-dev, libasound2-dev,
  libpulse-dev. (Closes: #669437)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright 1994-2012 Olivier Girondel
 
3
 *
 
4
 *  This file is part of lebiniou.
 
5
 *
 
6
 *  lebiniou is free software: you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation, either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  lebiniou is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with lebiniou. If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
/*
 
20
 * EffecTV - Realtime Digital Video Effector
 
21
 * Copyright (C) 2001-2006 FUKUCHI Kentaro
 
22
 *
 
23
 * PredatorTV - makes incoming objects invisible like the Predator.
 
24
 * Copyright (C) 2001-2002 FUKUCHI Kentaro
 
25
 *
 
26
 */
 
27
 
 
28
#include "context.h"
 
29
 
 
30
 
 
31
u_long id = 1325445400;
 
32
u_long options = BE_GFX|BEQ_PICTURE|BEQ_BYPASS;
 
33
char desc[] = "PredatorTV plugin from the EffecTV project";
 
34
u_long mode = OVERLAY;
 
35
 
 
36
#define MAGIC_THRESHOLD 40
 
37
 
 
38
static Buffer8_t *diff = NULL;
 
39
extern int webcams;
 
40
 
 
41
 
 
42
void
 
43
create(__attribute__ ((unused)) Context_t *ctx)
 
44
{
 
45
  if (!webcams)
 
46
    options |= BEQ_DISABLED;
 
47
  else
 
48
    diff = Buffer8_new();
 
49
}
 
50
 
 
51
 
 
52
void
 
53
delete(__attribute__ ((unused)) Context_t *ctx)
 
54
{
 
55
  Buffer8_delete(diff);
 
56
}
 
57
 
 
58
 
 
59
void
 
60
on_switch_on(Context_t *ctx)
 
61
{
 
62
  ctx->ref_taken[ctx->cam] = 0;
 
63
}
 
64
 
 
65
 
 
66
#if 0
 
67
static unsigned char *
 
68
image_diff_filter(unsigned char *diff)
 
69
{
 
70
#if 0
 
71
/* noise filter for subtracted image. */
 
72
unsigned char *image_diff_filter(unsigned char *diff)
 
73
{
 
74
        int x, y;
 
75
        unsigned char *src, *dest;
 
76
        unsigned int count;
 
77
        unsigned int sum1, sum2, sum3;
 
78
        const int width = video_width;
 
79
 
 
80
        src = diff;
 
81
        dest = diff2 + width +1;
 
82
        for(y=1; y<video_height-1; y++) {
 
83
                sum1 = src[0] + src[width] + src[width*2];
 
84
                sum2 = src[1] + src[width+1] + src[width*2+1];
 
85
                src += 2;
 
86
                for(x=1; x<width-1; x++) {
 
87
                        sum3 = src[0] + src[width] + src[width*2];
 
88
                        count = sum1 + sum2 + sum3;
 
89
                        sum1 = sum2;
 
90
                        sum2 = sum3;
 
91
                        *dest++ = (0xff*3 - count)>>24;
 
92
                        src++;
 
93
                }
 
94
                dest += 2;
 
95
        }
 
96
        
 
97
        return diff2;
 
98
}
 
99
#endif
 
100
}
 
101
#endif
 
102
 
 
103
 
 
104
void
 
105
run(Context_t *ctx)
 
106
{
 
107
  Buffer8_t *src1;
 
108
  Buffer8_t *src2;
 
109
  Pixel_t *d, *src;
 
110
  Pixel_t *dst;
 
111
  uint16_t x, y;
 
112
 
 
113
  if (!webcams)
 
114
    return;
 
115
 
 
116
  pthread_mutex_lock(&ctx->cam_mtx[ctx->cam]);
 
117
  src1 = ctx->cam_save[ctx->cam][0];
 
118
  src2 = ctx->cam_ref[ctx->cam];
 
119
  Buffer8_substract_y(src1, src2, MAGIC_THRESHOLD, diff);
 
120
 
 
121
  d = diff->buffer;
 
122
 
 
123
  dst = passive_buffer(ctx)->buffer;
 
124
  dst += WIDTH * sizeof(Pixel_t);
 
125
  d += WIDTH * sizeof(Pixel_t);
 
126
  src = ctx->cam_ref[ctx->cam]->buffer + (WIDTH * sizeof(Pixel_t));
 
127
 
 
128
  for (y = 1; y < MAXY; y++) {
 
129
    for (x = 0; x < WIDTH; x++) {
 
130
      if (*d)
 
131
        *dst = src[4] & 0xfc;
 
132
      else
 
133
        *dst = *src;
 
134
 
 
135
      d++;
 
136
      src++;
 
137
      dst++;
 
138
    }
 
139
  }
 
140
  pthread_mutex_unlock(&ctx->cam_mtx[ctx->cam]);
 
141
}
 
142
 
 
143
 
 
144
#if 0
 
145
static int draw(RGB32 *src, RGB32 *dest)
 
146
{
 
147
        int x, y;
 
148
        unsigned char *diff;
 
149
 
 
150
        diff = image_bgsubtract_y(src);
 
151
        diff = image_diff_filter(diff);
 
152
 
 
153
        dest += video_width;
 
154
        diff += video_width;
 
155
        src = bgimage + video_width;
 
156
        for(y=1; y<video_height-1; y++) {
 
157
                for(x=0; x<video_width; x++) {
 
158
                        if(*diff){
 
159
                                *dest = src[4] & 0xfcfcfc;
 
160
                        } else {
 
161
                                *dest = *src;
 
162
                        }
 
163
                        diff++;
 
164
                        src++;
 
165
                        dest++;
 
166
                }
 
167
        }
 
168
 
 
169
        return 0;
 
170
}
 
171
#endif /* 0 */