no longer need ffmpeg patch0 which was for Termux
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / colorspace / colorspace.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program 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  * This program 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 this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef __COLORSPACE_H__
23 #define __COLORSPACE_H__
24
25 class ColorSpaceMain;
26
27 #include "bchash.h"
28 #include "mutex.h"
29 #include "loadbalance.h"
30 #include "pluginvclient.h"
31 #include "colorspacewindow.h"
32 #include <sys/types.h>
33
34 class ColorSpaceConfig;
35 class ColorSpaceMain;
36 class ColorSpacePackage;
37 class ColorSpaceUnit;
38 class ColorSpaceEngine;
39
40 class XTable {
41 public:
42         typedef int lut_t;
43         enum lut_typ { yuv2yuv, rgb2yuv, yuv2rgb, rgb2rgb };
44
45         XTable();
46         ~XTable();
47         int init_yuv2yuv(double iKr, double iKb, double oKr, double oKb);
48         int init_rgb2yuv(double Kr, double Kb);
49         int init_yuv2rgb(double Kr, double Kb);
50         int init_rgb2rgb(double iKr, double iKb, double oKr, double oKb);
51
52         void init(int len, int inv,
53                 int inp_model, int inp_space, int inp_range,
54                 int out_model, int out_space, int out_range);
55         void alloc_lut(int len);
56         void create_table(lut_t **lut, int len, float *vars);
57         void create_tables(int len);
58         int inverse();
59         void process(VFrame *inp, VFrame *out, int row1, int row2);
60
61         int typ, len, inv;
62         int inp_model, inp_space, inp_range;
63         int out_model, out_space, out_range;
64
65         lut_t imin[3], omin[3], imax[3], omax[3];
66         lut_t izro[3], ozro[3], irng[3], orng[3];
67         float izrf[3], ozrf[3], omnf[3], omxf[3];
68
69         union {
70                 struct {
71                         float Yy, Uy, Vy;
72                         float Yu, Uu, Vu;
73                         float Yv, Uv, Vv;
74                 };
75                 struct {
76                         float Ry, Gy, By;
77                         float Ru, Gu, Bu;
78                         float Rv, Gv, Bv;
79                 };
80                 struct {
81                         float Yr, Ur, Vr;
82                         float Yg, Ug, Vg;
83                         float Yb, Ub, Vb;
84                 };
85                 struct {
86                         float Rr, Gr, Br;
87                         float Rg, Gg, Bg;
88                         float Rb, Gb, Bb;
89                 };
90                 float eqns[3][3];
91         };
92         lut_t *luts[3][3];
93 };
94
95
96 class ColorSpaceConfig
97 {
98 public:
99         ColorSpaceConfig();
100         int inverse;
101         int inp_colorspace, inp_colorrange;
102         int out_colorspace, out_colorrange;
103 };
104
105 class ColorSpacePackage : public LoadPackage
106 {
107 public:
108         ColorSpacePackage();
109         int row1, row2;
110 };
111
112 class ColorSpaceUnit : public LoadClient
113 {
114 public:
115         ColorSpaceUnit(ColorSpaceMain *plugin, ColorSpaceEngine *engine);
116         void process_package(LoadPackage *package);
117         ColorSpaceEngine *engine;
118         ColorSpaceMain *plugin;
119
120 };
121
122 class ColorSpaceEngine : public LoadServer
123 {
124 public:
125         ColorSpaceEngine(ColorSpaceMain *plugin, int cpus);
126         void init_packages();
127         LoadClient* new_client();
128         LoadPackage* new_package();
129         ColorSpaceMain *plugin;
130 };
131
132
133 class ColorSpaceMain : public PluginVClient
134 {
135 public:
136         ColorSpaceMain(PluginServer *server);
137         ~ColorSpaceMain();
138
139         PLUGIN_CLASS_MEMBERS(ColorSpaceConfig);
140         int process_realtime(VFrame *input, VFrame *output);
141         int is_realtime();
142         void update_gui();
143         void save_data(KeyFrame *keyframe);
144         void read_data(KeyFrame *keyframe);
145         int handle_opengl();
146         int create_luts();
147
148         int inp_color_space, inp_color_range;
149         int out_color_space, out_color_range;
150         VFrame *inp, *out;
151         XTable *xtable;
152         ColorSpaceEngine *engine;
153 };
154
155
156 #endif