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