File: tv_diff.c

package info (click to toggle)
lebiniou 3.67.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,500 kB
  • sloc: ansic: 28,670; makefile: 1,276; sh: 602; awk: 432; xml: 261; javascript: 23
file content (54 lines) | stat: -rw-r--r-- 1,462 bytes parent folder | download | duplicates (3)
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
/*
 *  Copyright 1994-2022 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"
#include "pthread_utils.h"


uint32_t version = 0;
uint32_t options = BO_GFX | BO_WEBCAM | BO_NORANDOM | BO_SCHEMES;
char desc[] = "DiffTV";
char dname[] = "TV diff";

enum LayerMode mode = LM_OVERLAY;


void
on_switch_on(Context_t *ctx)
{
  ctx->ref_taken[ctx->cam] = 0;
}


void
run(Context_t *ctx)
{
  Pixel_t *src1, *start, *src2, *dst;

  dst = start = passive_buffer(ctx)->buffer;

  if (!xpthread_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);
    }
    xpthread_mutex_unlock(&ctx->cam_mtx[ctx->cam]);
  }
}