r854: Merge 2.1:
[cinelerra_cv/ct.git] / cinelerra / pluginvclient.h
blob1ffb4b39d385f499a28b3d9497ac755a63635b3b
1 #ifndef PLUGINVCLIENT_H
2 #define PLUGINVCLIENT_H
5 #include "maxbuffers.h"
6 #include "pluginclient.h"
7 #include "vframe.inc"
9 // Maximum dimensions for a temporary frame a plugin should retain between
10 // process_buffer calls. This allows memory conservation.
11 #define PLUGIN_MAX_W 2000
12 #define PLUGIN_MAX_H 1000
16 class PluginVClient : public PluginClient
18 public:
19 PluginVClient(PluginServer *server);
20 virtual ~PluginVClient();
22 int get_render_ptrs();
23 int init_realtime_parameters();
24 int delete_nonrealtime_parameters();
25 int is_video();
26 // Replaced by pull method
28 * void plugin_process_realtime(VFrame **input,
29 * VFrame **output,
30 * int64_t current_position,
31 * int64_t total_len);
33 // Multichannel buffer process for backwards compatibility
34 virtual int process_realtime(VFrame **input,
35 VFrame **output);
36 // Single channel buffer process for backwards compatibility and transitions
37 virtual int process_realtime(VFrame *input,
38 VFrame *output);
40 // Process buffer using pull method. By default this loads the input into *frame
41 // and calls process_realtime with input and output pointing to frame.
42 // start_position - requested position relative to frame rate. Relative
43 // to start of EDL. End of buffer if reverse.
44 // sample_rate - scale of start_position.
45 // These should return 1 if error or 0 if success.
46 virtual int process_buffer(VFrame **frame,
47 int64_t start_position,
48 double frame_rate);
49 virtual int process_buffer(VFrame *frame,
50 int64_t start_position,
51 double frame_rate);
54 // Called by plugin server to render the GUI with rendered data.
55 void plugin_render_gui(void *data);
56 virtual void render_gui(void *data) { };
57 // Called by client to cause GUI to be rendered with data.
58 void send_render_gui(void *data);
59 virtual int process_loop(VFrame **buffers) { return 1; };
60 virtual int process_loop(VFrame *buffer) { return 1; };
61 int plugin_process_loop(VFrame **buffers, int64_t &write_length);
63 int plugin_start_loop(int64_t start,
64 int64_t end,
65 int64_t buffer_size,
66 int total_buffers);
67 int plugin_get_parameters();
69 // Called by non-realtime client to read frame for processing.
70 // buffer - output frame
71 // channel - channel of the plugin input for a multichannel plugin
72 // start_position - start of frame in forward. end of frame in reverse.
73 // Relative to start of EDL.
74 int read_frame(VFrame *buffer,
75 int channel,
76 int64_t start_position);
77 int read_frame(VFrame *buffer,
78 int64_t start_position);
80 // Called by realtime plugin to read frame from previous entity
81 // framerate - framerate start_position is relative to. Used by preceeding plugiun
82 // to calculate output frame number. Provided so the client can get data
83 // at a higher fidelity than provided by the EDL.
84 // start_position - start of frame in forward. end of frame in reverse.
85 // Relative to start of EDL.
86 // frame_rate - frame rate position is scaled to
87 int read_frame(VFrame *buffer,
88 int channel,
89 int64_t start_position,
90 double frame_rate,
91 int use_opengl = 0);
93 // Called by Playback3D to run opengl commands synchronously.
94 // Overridden by the user with the commands to run synchronously.
95 virtual int handle_opengl();
98 // Called by user to allocate the temporary for the current process_buffer.
99 // It may be deleted after the process_buffer to conserve memory.
100 VFrame* new_temp(int w, int h, int color_model);
101 // Called by PluginServer after process_buffer to delete the temp if it's too
102 // large.
103 void age_temp();
105 // Frame rate relative to EDL
106 double get_project_framerate();
107 // Frame rate requested
108 double get_framerate();
110 int64_t local_to_edl(int64_t position);
111 int64_t edl_to_local(int64_t position);
113 // ======================== Non realtime buffer pointers =======================
114 // Channels of arrays of frames that the client uses.
115 VFrame ***video_in, ***video_out;
117 // point to the start of the buffers
118 ArrayList<VFrame***> input_ptr_master;
119 ArrayList<VFrame***> output_ptr_master;
120 // Pointers to the regions for a single render.
121 // Arrays are channels of arrays of frames.
122 VFrame ***input_ptr_render;
123 VFrame ***output_ptr_render;
125 // ======================== Realtime buffer pointers ===========================
126 // These are provided by the plugin server for the opengl handler.
127 VFrame **input;
128 VFrame **output;
131 // Frame rate of EDL
132 double project_frame_rate;
133 // Local parameters set by non realtime plugin about the file to be generated.
134 // Retrieved by server to set output file format.
135 // In realtime plugins, these are set before every process_buffer as the
136 // requested rates.
137 double frame_rate;
138 int project_color_model;
139 // Whether user wants floating point calculations.
140 int use_float;
141 // Whether user wants alpha calculations.
142 int use_alpha;
143 // Whether user wants pixel interpolation.
144 int use_interpolation;
145 // Aspect ratio
146 float aspect_w;
147 float aspect_h;
149 // Tempo
150 VFrame *temp;
155 #endif