Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / gaborobj / gaborobj.h
1 /*
2  * CINELERRA
3  * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #ifndef GABOROBJ_H
21 #define GABOROBJ_H
22
23 #include "pluginvclient.h"
24 #include "loadbalance.h"
25 #include "mutex.inc"
26
27 #include "opencv2/core/types.hpp"
28 #include "opencv2/core/mat.hpp"
29 #include "opencv2/calib3d.hpp"
30 #include "opencv2/video/video.hpp"
31
32 #include <vector>
33
34 using namespace std;
35 using namespace cv;
36
37
38 class GaborObjConfig;
39 class GaborObj;
40
41
42 class GaborObjConfig
43 {
44 public:
45         GaborObjConfig();
46
47         int equivalent(GaborObjConfig &that);
48         void copy_from(GaborObjConfig &that);
49         void interpolate(GaborObjConfig &prev, GaborObjConfig &next, 
50                 long prev_frame, long next_frame, long current_frame);
51         void limits();
52 };
53
54 class GaborObjFilterPackage : public LoadPackage
55 {
56 public:
57         GaborObjFilterPackage();
58         int i;
59 };
60
61 class GaborObjFilterEngine : public LoadServer
62 {
63 public:
64         GaborObjFilterEngine(GaborObj *plugin, int cpus);
65         ~GaborObjFilterEngine();
66
67         void init_packages();
68         LoadClient* new_client();
69         LoadPackage* new_package();
70
71         GaborObj *plugin;
72 };
73
74 class GaborObjFilterUnit : public LoadClient
75 {
76 public:
77         GaborObjFilterUnit(GaborObjFilterEngine *engine, GaborObj *plugin);
78         ~GaborObjFilterUnit();
79
80         void process_package(LoadPackage *pkg);
81         void process_filter(GaborObjFilterPackage *pkg);
82
83         GaborObjFilterEngine *engine;
84         GaborObj *plugin;
85 };
86
87 class GaborObj : public PluginVClient
88 {
89 public:
90         GaborObj(PluginServer *server);
91         ~GaborObj();
92         PLUGIN_CLASS_MEMBERS2(GaborObjConfig)
93         int is_realtime();
94         void update_gui();
95         void save_data(KeyFrame *keyframe);
96         void read_data(KeyFrame *keyframe);
97         int process_buffer(VFrame *frame, int64_t start_position, double frame_rate);
98         void to_mat(Mat &mat, int mcols, int mrows,
99                 VFrame *inp, int ix,int iy, int mcolor_model);
100         void from_mat(VFrame *out, int ox, int oy, int ow, int oh,
101                 Mat &mat, int mcolor_model);
102
103         int width, height, color_model;
104         VFrame *input, *output, *accum;
105         ::Mutex *remap_lock;
106
107         Mat next_img;
108         vector<Mat> filters;
109         GaborObjFilterEngine *gabor_engine;
110 };
111
112 #endif