mask xy scale, mask boundary only overlay, fix 8 char mask nm bug, rework maskgui...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / pluginvclient.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 PLUGINVCLIENT_H
23 #define PLUGINVCLIENT_H
24
25
26 #include "maxbuffers.h"
27 #include "pluginclient.h"
28 #include "vframe.inc"
29
30 // Maximum dimensions for a temporary frame a plugin should retain between
31 // process_buffer calls.  This allows memory conservation.
32 #define PLUGIN_MAX_W 2000
33 #define PLUGIN_MAX_H 1000
34
35
36
37 class PluginVClient : public PluginClient
38 {
39 public:
40         PluginVClient(PluginServer *server);
41         virtual ~PluginVClient();
42
43         int get_render_ptrs();
44         int init_realtime_parameters();
45         int delete_nonrealtime_parameters();
46         int is_video();
47 // Replaced by pull method
48 /*
49  *      void plugin_process_realtime(VFrame **input,
50  *              VFrame **output,
51  *              int64_t current_position,
52  *              int64_t total_len);
53  */
54 // Multichannel buffer process for backwards compatibility
55         virtual int process_realtime(VFrame **input,
56                 VFrame **output);
57 // Single channel buffer process for backwards compatibility and transitions
58         virtual int process_realtime(VFrame *input,
59                 VFrame *output);
60
61 // Process buffer using pull method.  By default this loads the input into *frame
62 //     and calls process_realtime with input and output pointing to frame.
63 // start_position - requested position relative to frame rate. Relative
64 //     to start of EDL.  End of buffer if reverse.
65 // sample_rate - scale of start_position.
66 // These should return 1 if error or 0 if success.
67         virtual int process_buffer(VFrame **frame,
68                 int64_t start_position,
69                 double frame_rate);
70         virtual int process_buffer(VFrame *frame,
71                 int64_t start_position,
72                 double frame_rate);
73
74
75         virtual int process_loop(VFrame **buffers) { return 1; };
76         virtual int process_loop(VFrame *buffer) { return 1; };
77         int plugin_process_loop(VFrame **buffers, int64_t &write_length);
78
79         int plugin_start_loop(int64_t start,
80                 int64_t end,
81                 int64_t buffer_size,
82                 int total_buffers);
83         int plugin_get_parameters();
84
85 // Called by non-realtime client to read frame for processing.
86 // buffer - output frame
87 // channel - channel of the plugin input for a multichannel plugin
88 // start_position - start of frame in forward.  end of frame in reverse.
89 //     Relative to start of EDL.
90         int read_frame(VFrame *buffer,
91                 int channel,
92                 int64_t start_position);
93         int read_frame(VFrame *buffer,
94                 int64_t start_position);
95
96 // Called by realtime plugin to read frame from previous entity
97 // framerate - framerate start_position is relative to.  Used by preceeding plugiun
98 //     to calculate output frame number.  Provided so the client can get data
99 //     at a higher fidelity than provided by the EDL.
100 // start_position - start of frame in forward.  end of frame in reverse.
101 //     Relative to start of EDL.
102 // frame_rate - frame rate position is scaled to
103         int read_frame(VFrame *buffer,
104                 int channel,
105                 int64_t start_position,
106                 double frame_rate,
107                 int use_opengl /* = 0 */);
108
109
110 // User calls this to request an opengl routine to be run synchronously.
111         int run_opengl();
112
113 // Called by Playback3D to run opengl commands synchronously.
114 // Overridden by the user with the commands to run synchronously.
115         virtual int handle_opengl();
116
117 // Used by the opengl handlers to get the
118 // arguments to process_buffer.
119 // For realtime plugins, they're identical for input and output.
120         VFrame* get_input(int channel = 0);
121         VFrame* get_output(int channel = 0);
122
123 // For aggregation, this does case sensitive compares with the
124 // the stack in the frame object.
125 // Only possible for video because VFrame stores the effect stacks.
126         int next_effect_is(const char *title);
127         int prev_effect_is(const char *title);
128
129 // Called by user to allocate the temporary for the current process_buffer.
130 // It may be deleted after the process_buffer to conserve memory.
131         VFrame* new_temp(int w, int h, int color_model);
132 // Called by PluginServer after process_buffer to delete the temp if it's too
133 // large.
134         void age_temp();
135         VFrame* get_temp();
136
137 // Frame rate relative to EDL
138         double get_project_framerate();
139 // Frame rate requested
140         double get_framerate();
141 // Get list of system fonts
142         ArrayList<BC_FontEntry*> *get_fontlist();
143 // Find font entry
144         BC_FontEntry *find_fontentry(const char *displayname, int style,
145                 int mask, int preferred_style);
146 // Find font path where glyph for the character_code exists
147         int find_font_by_char(FT_ULong char_code, char *path_new, const FT_Face oldface);
148
149         int64_t local_to_edl(int64_t position);
150         int64_t edl_to_local(int64_t position);
151         int64_t get_startproject();
152         int64_t get_endproject();
153
154 // ======================== Non realtime buffer pointers =======================
155 // Channels of arrays of frames that the client uses.
156         VFrame ***video_in, ***video_out;
157
158 // point to the start of the buffers
159         ArrayList<VFrame***> input_ptr_master;
160         ArrayList<VFrame***> output_ptr_master;
161 // Pointers to the regions for a single render.
162 // Arrays are channels of arrays of frames.
163         VFrame ***input_ptr_render;
164         VFrame ***output_ptr_render;
165
166 // ======================== Realtime buffer pointers ===========================
167 // These are provided by the plugin server for the opengl handler.
168         VFrame **input;
169         VFrame **output;
170
171
172 // Frame rate of EDL
173         double project_frame_rate;
174 // Local parameters set by non realtime plugin about the file to be generated.
175 // Retrieved by server to set output file format.
176 // In realtime plugins, these are set before every process_buffer as the
177 // requested rates.
178         double frame_rate;
179         int project_color_model;
180 // Whether user wants floating point calculations.
181         int use_float;
182 // Whether user wants alpha calculations.
183         int use_alpha;
184 // Whether user wants pixel interpolation.
185         int use_interpolation;
186 // Aspect ratio
187         float aspect_w;
188         float aspect_h;
189
190 // Temp
191         VFrame *temp;
192 };
193
194
195
196 #endif