Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

pluginvclient.C

Go to the documentation of this file.
00001 #include "edl.h"
00002 #include "edlsession.h"
00003 #include "pluginserver.h"
00004 #include "pluginvclient.h"
00005 #include "vframe.h"
00006 
00007 #include <string.h>
00008 
00009 PluginVClient::PluginVClient(PluginServer *server)
00010  : PluginClient(server)
00011 {
00012         video_in = 0;
00013         video_out = 0;
00014         temp = 0;
00015         if(server &&
00016                 server->edl &&
00017                 server->edl->session)
00018         {
00019                 project_frame_rate = server->edl->session->frame_rate;
00020                 frame_rate = project_frame_rate;
00021         }
00022         else
00023         {
00024                 project_frame_rate = 1.0;
00025                 frame_rate = project_frame_rate;
00026         }
00027 }
00028 
00029 PluginVClient::~PluginVClient()
00030 {
00031         if(temp) delete temp;
00032 }
00033 
00034 int PluginVClient::is_video()
00035 {
00036         return 1;
00037 }
00038 
00039 VFrame* PluginVClient::new_temp(int w, int h, int color_model)
00040 {
00041         if(temp && 
00042                 (temp->get_w() != w ||
00043                 temp->get_h() != h ||
00044                 temp->get_color_model() != color_model))
00045         {
00046                 delete temp;
00047                 temp = 0;
00048         }
00049 
00050         if(!temp)
00051         {
00052                 temp = new VFrame(0, w, h, color_model);
00053         }
00054 
00055         return temp;
00056 }
00057 
00058 void PluginVClient::age_temp()
00059 {
00060         if(temp &&
00061                 temp->get_w() > PLUGIN_MAX_W &&
00062                 temp->get_h() > PLUGIN_MAX_H)
00063         {
00064                 delete temp;
00065                 temp = 0;
00066         }
00067 }
00068 
00069 // Run before every realtime buffer is to be rendered.
00070 int PluginVClient::get_render_ptrs()
00071 {
00072         int i, j, double_buffer, fragment_position;
00073 
00074         for(i = 0; i < total_in_buffers; i++)
00075         {
00076                 double_buffer = double_buffer_in_render.values[i];
00077                 fragment_position = offset_in_render.values[i];
00078                 input_ptr_render[i] = &input_ptr_master.values[i][double_buffer][fragment_position];
00079         }
00080 
00081         for(i = 0; i < total_out_buffers; i++)
00082         {
00083                 double_buffer = double_buffer_out_render.values[i];
00084                 fragment_position = offset_out_render.values[i];
00085                 output_ptr_render[i] = &output_ptr_master.values[i][double_buffer][fragment_position];
00086         }
00087         return 0;
00088 }
00089 
00090 // Run after the non realtime plugin is run.
00091 int PluginVClient::delete_nonrealtime_parameters()
00092 {
00093         int i, j;
00094 
00095         for(i = 0; i < total_in_buffers; i++)
00096         {
00097                 for(j = 0; j < in_buffer_size; j++)
00098                 {
00099                         delete video_in[i][j];
00100                 }
00101         }
00102 
00103         for(i = 0; i < total_out_buffers; i++)
00104         {
00105                 for(j = 0; j < out_buffer_size; j++)
00106                 {
00107                         delete video_out[i][j];
00108                 }
00109         }
00110         video_in = 0;
00111         video_out = 0;
00112 
00113         return 0;
00114 }
00115 
00116 int PluginVClient::init_realtime_parameters()
00117 {
00118         project_frame_rate = server->edl->session->frame_rate;
00119         project_color_model = server->edl->session->color_model;
00120         aspect_w = server->edl->session->aspect_w;
00121         aspect_h = server->edl->session->aspect_h;
00122         return 0;
00123 }
00124 
00125 int PluginVClient::process_realtime(VFrame **input, 
00126         VFrame **output)
00127 {
00128         return 0; 
00129 }
00130 
00131 int PluginVClient::process_realtime(VFrame *input, 
00132         VFrame *output) 
00133 {
00134         return 0; 
00135 }
00136 
00137 int PluginVClient::process_buffer(VFrame **frame,
00138         int64_t start_position,
00139         double frame_rate)
00140 {
00141         for(int i = 0; i < PluginClient::total_in_buffers; i++)
00142                 read_frame(frame[i], i, start_position, frame_rate);
00143         if(is_multichannel())
00144                 process_realtime(frame, frame);
00145         return 0;
00146 }
00147 
00148 int PluginVClient::process_buffer(VFrame *frame,
00149         int64_t start_position,
00150         double frame_rate)
00151 {
00152         read_frame(frame, 0, start_position, frame_rate);
00153         process_realtime(frame, frame);
00154         return 0;
00155 }
00156 
00157 
00158 // Replaced by pull method
00159 // void PluginVClient::plugin_process_realtime(VFrame **input, 
00160 //              VFrame **output, 
00161 //              int64_t current_position,
00162 //              int64_t total_len)
00163 // {
00164 //      this->source_position = current_position;
00165 //      this->total_len = total_len;
00166 // 
00167 //      if(is_multichannel())
00168 //              process_realtime(input, output);
00169 //      else
00170 //              process_realtime(input[0], output[0]);
00171 // }
00172 
00173 void PluginVClient::plugin_render_gui(void *data)
00174 {
00175         render_gui(data);
00176 }
00177 
00178 void PluginVClient::send_render_gui(void *data)
00179 {
00180         server->send_render_gui(data);
00181 }
00182 
00183 int PluginVClient::plugin_start_loop(int64_t start, 
00184         int64_t end, 
00185         int64_t buffer_size, 
00186         int total_buffers)
00187 {
00188         frame_rate = get_project_framerate();
00189         return PluginClient::plugin_start_loop(start, 
00190                 end, 
00191                 buffer_size, 
00192                 total_buffers);
00193 }
00194 
00195 int PluginVClient::plugin_get_parameters()
00196 {
00197         frame_rate = get_project_framerate();
00198         return PluginClient::plugin_get_parameters();
00199 }
00200 
00201 int64_t PluginVClient::local_to_edl(int64_t position)
00202 {
00203         if(position < 0) return position;
00204         return (int64_t)Units::round(position * 
00205                 get_project_framerate() /
00206                 frame_rate);
00207         return 0;
00208 }
00209 
00210 int64_t PluginVClient::edl_to_local(int64_t position)
00211 {
00212         if(position < 0) return position;
00213         return (int64_t)Units::round(position * 
00214                 frame_rate /
00215                 get_project_framerate());
00216 }
00217 
00218 int PluginVClient::plugin_process_loop(VFrame **buffers, int64_t &write_length)
00219 {
00220         int result = 0;
00221 
00222         if(is_multichannel())
00223                 result = process_loop(buffers);
00224         else
00225                 result = process_loop(buffers[0]);
00226 
00227 
00228         write_length = 1;
00229 
00230         return result;
00231 }
00232 
00233 
00234 int PluginVClient::read_frame(VFrame *buffer, 
00235         int channel, 
00236         int64_t start_position)
00237 {
00238         return server->read_frame(buffer, 
00239                 channel, 
00240                 start_position);
00241 }
00242 
00243 int PluginVClient::read_frame(VFrame *buffer, 
00244         int64_t start_position)
00245 {
00246         return server->read_frame(buffer, 
00247                 0, 
00248                 start_position);
00249 }
00250 
00251 int PluginVClient::read_frame(VFrame *buffer, 
00252                 int channel, 
00253                 int64_t start_position,
00254                 double frame_rate)
00255 {
00256         return server->read_frame(buffer,
00257                 channel,
00258                 start_position,
00259                 frame_rate);
00260 }
00261 
00262 
00263 double PluginVClient::get_project_framerate()
00264 {
00265         return project_frame_rate;
00266 }
00267 
00268 double PluginVClient::get_framerate()
00269 {
00270         return frame_rate;
00271 }
00272 

Generated on Sun Jan 8 13:38:59 2006 for Cinelerra-svn by  doxygen 1.4.4