Debian Codegraph @

src/mixer3/RGB/RGB.c

raw symbols SCIP
1 /* RGB.c
2 * Copyright (C) 2007 Richard Spindler ([email protected])
3 * This file is a Frei0r plugin.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include <stdlib.h>
21 #include <assert.h>
22
23 #include "frei0r.h"
24
25 typedef struct RGB_instance
26 {
27 unsigned int width;
28 unsigned int height;
29 } RGB_instance_t;
30
31 int f0r_init()
32 {
33 return 1;
34 }
35
36 void f0r_deinit()
37 { /* no initialization required */ }
38
39 void f0r_get_plugin_info(f0r_plugin_info_t* RGBInfo)
40 {
41 RGBInfo->name = "RGB";
42 RGBInfo->author = "Richard Spindler";
43 RGBInfo->plugin_type = F0R_PLUGIN_TYPE_MIXER3;
44 RGBInfo->color_model = F0R_COLOR_MODEL_RGBA8888;
45 RGBInfo->frei0r_version = FREI0R_MAJOR_VERSION;
46 RGBInfo->major_version = 0;
47 RGBInfo->minor_version = 9;
48 RGBInfo->num_params = 0;
49 RGBInfo->explanation = "Averages each Input and uses each as R, G or B channel of the Output";
50 }
51
52 void f0r_get_param_info(f0r_param_info_t* info, int param_index)
53 {
54 /* no params */
55 }
56
57 f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
58 {
59 RGB_instance_t* inst = (RGB_instance_t*)calloc(1, sizeof(*inst));
60 inst->width = width; inst->height = height;
61 return (f0r_instance_t)inst;
62 }
63
64 void f0r_destruct(f0r_instance_t instance)
65 {
66 free(instance);
67 }
68
69 void f0r_set_param_value(f0r_instance_t instance,
70 f0r_param_t param, int param_index)
71 { /* no params */ }
72
73 void f0r_get_param_value(f0r_instance_t instance,
74 f0r_param_t param, int param_index)
75 { /* no params */ }
76
77
78 void f0r_update2(f0r_instance_t instance,
79 double time,
80 const uint32_t* inframe1,
81 const uint32_t* inframe2,
82 const uint32_t* inframe3,
83 uint32_t* outframe)
84 {
85 assert(instance);
86 RGB_instance_t* inst = (RGB_instance_t*)instance;
87 unsigned int w = inst->width;
88 unsigned int h = inst->height;
89 unsigned int x,y;
90
91 uint32_t* dst = outframe;
92 const uint32_t* src1 = inframe1;
93 const uint32_t* src2 = inframe2;
94 const uint32_t* src3 = inframe3;
95 for(y=0;y<h;++y)
96 for(x=0;x<w;++x) {
97 int tmpbw1;
98 int tmpbw2;
99 int tmpbw3;
100 unsigned char* tmpc1 = (unsigned char*)src1;
101 unsigned char* tmpc2 = (unsigned char*)src2;
102 unsigned char* tmpc3 = (unsigned char*)src3;
103 tmpbw1 = (tmpc1[0] + tmpc1[1] + tmpc1[2]) / 3;
104 tmpbw2 = (tmpc2[0] + tmpc2[1] + tmpc2[2]) / 3;
105 tmpbw3 = (tmpc3[0] + tmpc3[1] + tmpc3[2]) / 3;
106
107 *dst++ = ( 0xff000000 ) | (tmpbw3 << 16)| (tmpbw2 << 8)| (tmpbw1);
108
109 src1++;
110 src2++;
111 src3++;
112 }
113 }
114
115