4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #include "bcsignals.h"
24 #include "edlsession.h"
25 #include "pluginserver.h"
26 #include "pluginvclient.h"
31 PluginVClient::PluginVClient(PluginServer *server)
32 : PluginClient(server)
41 project_frame_rate = server->edl->session->frame_rate;
42 frame_rate = project_frame_rate;
46 project_frame_rate = 1.0;
47 frame_rate = project_frame_rate;
51 PluginVClient::~PluginVClient()
56 int PluginVClient::is_video()
61 VFrame* PluginVClient::new_temp(int w, int h, int color_model)
64 (temp->get_w() != w ||
66 temp->get_color_model() != color_model))
74 temp = new VFrame(w, h, color_model, 0);
80 void PluginVClient::age_temp()
83 temp->get_w() > PLUGIN_MAX_W &&
84 temp->get_h() > PLUGIN_MAX_H)
91 VFrame* PluginVClient::get_temp()
96 // Run before every realtime buffer is to be rendered.
97 int PluginVClient::get_render_ptrs()
99 int i, double_buffer, fragment_position;
101 for(i = 0; i < total_in_buffers; i++)
103 double_buffer = double_buffer_in_render.values[i];
104 fragment_position = offset_in_render.values[i];
105 input_ptr_render[i] = &input_ptr_master.values[i][double_buffer][fragment_position];
108 for(i = 0; i < total_out_buffers; i++)
110 double_buffer = double_buffer_out_render.values[i];
111 fragment_position = offset_out_render.values[i];
112 output_ptr_render[i] = &output_ptr_master.values[i][double_buffer][fragment_position];
117 // Run after the non realtime plugin is run.
118 int PluginVClient::delete_nonrealtime_parameters()
122 for(i = 0; i < total_in_buffers; i++)
124 for(j = 0; j < in_buffer_size; j++)
126 delete video_in[i][j];
130 for(i = 0; i < total_out_buffers; i++)
132 for(j = 0; j < out_buffer_size; j++)
134 delete video_out[i][j];
143 int PluginVClient::init_realtime_parameters()
145 project_frame_rate = server->edl->session->frame_rate;
146 project_color_model = server->edl->session->color_model;
147 aspect_w = server->edl->session->aspect_w;
148 aspect_h = server->edl->session->aspect_h;
152 int PluginVClient::process_realtime(VFrame **input,
158 int PluginVClient::process_realtime(VFrame *input,
164 int PluginVClient::process_buffer(VFrame **frame,
165 int64_t start_position,
169 for(int i = 0; i < PluginClient::total_in_buffers; i++)
170 read_frame(frame[i], i, start_position, frame_rate, 0);
171 if(is_multichannel())
172 process_realtime(frame, frame);
176 int PluginVClient::process_buffer(VFrame *frame,
177 int64_t start_position,
180 read_frame(frame, 0, start_position, frame_rate, 0);
181 process_realtime(frame, frame);
186 int PluginVClient::plugin_start_loop(int64_t start,
191 frame_rate = get_project_framerate();
192 return PluginClient::plugin_start_loop(start,
198 int PluginVClient::plugin_get_parameters()
200 frame_rate = get_project_framerate();
201 return PluginClient::plugin_get_parameters();
204 int64_t PluginVClient::local_to_edl(int64_t position)
206 if(position < 0) return position;
207 return (int64_t)Units::round(position *
208 get_project_framerate() /
213 int64_t PluginVClient::edl_to_local(int64_t position)
215 if(position < 0) return position;
216 return (int64_t)Units::round(position *
218 get_project_framerate());
221 int PluginVClient::plugin_process_loop(VFrame **buffers, int64_t &write_length)
225 if(is_multichannel())
226 result = process_loop(buffers);
228 result = process_loop(buffers[0]);
237 int PluginVClient::run_opengl()
239 server->run_opengl(this);
243 int PluginVClient::handle_opengl()
248 VFrame* PluginVClient::get_input(int channel)
250 return input[channel];
253 VFrame* PluginVClient::get_output(int channel)
255 return output[channel];
258 int PluginVClient::next_effect_is(const char *title)
260 return !strcmp(title, output[0]->get_next_effect());
263 int PluginVClient::prev_effect_is(const char *title)
265 return !strcmp(title, output[0]->get_prev_effect());
270 int PluginVClient::read_frame(VFrame *buffer,
272 int64_t start_position)
274 return server->read_frame(buffer,
279 int PluginVClient::read_frame(VFrame *buffer,
280 int64_t start_position)
282 return server->read_frame(buffer,
287 int PluginVClient::read_frame(VFrame *buffer,
289 int64_t start_position,
293 return server->read_frame(buffer,
301 double PluginVClient::get_project_framerate()
303 return project_frame_rate;
306 double PluginVClient::get_framerate()
311 ArrayList<BC_FontEntry*> *PluginVClient::get_fontlist()
313 return BC_Resources::fontlist;
316 BC_FontEntry *PluginVClient::find_fontentry(const char *displayname, int style,
317 int mask, int preferred_style)
319 return BC_Resources::find_fontentry(displayname, style, mask, preferred_style);
322 int PluginVClient::find_font_by_char(FT_ULong char_code, char *path_new, const FT_Face oldface)
324 return BC_Resources::find_font_by_char(char_code, path_new, oldface);