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

vattachmentpoint.C

Go to the documentation of this file.
00001 #include "bcsignals.h"
00002 #include "clip.h"
00003 #include "datatype.h"
00004 #include "edl.h"
00005 #include "edlsession.h"
00006 #include "plugin.h"
00007 #include "pluginserver.h"
00008 #include "renderengine.h"
00009 #include "transportque.h"
00010 #include "vattachmentpoint.h"
00011 #include "vframe.h"
00012 
00013 VAttachmentPoint::VAttachmentPoint(RenderEngine *renderengine, Plugin *plugin)
00014 : AttachmentPoint(renderengine, plugin, TRACK_VIDEO)
00015 {
00016         buffer_vector = 0;
00017 }
00018 
00019 VAttachmentPoint::~VAttachmentPoint()
00020 {
00021         delete_buffer_vector();
00022 }
00023 
00024 void VAttachmentPoint::delete_buffer_vector()
00025 {
00026         if(!this) printf("VAttachmentPoint::delete_buffer_vector NULL\n");
00027         if(buffer_vector)
00028         {
00029                 for(int i = 0; i < virtual_plugins.total; i++)
00030                         delete buffer_vector[i];
00031                 delete [] buffer_vector;
00032         }
00033         buffer_vector = 0;
00034 }
00035 
00036 void VAttachmentPoint::new_buffer_vector(int width, int height, int colormodel)
00037 {
00038         if(!this) printf("VAttachmentPoint::new_buffer_vector NULL\n");
00039         if(buffer_vector &&
00040                 (width != buffer_vector[0]->get_w() ||
00041                 height != buffer_vector[0]->get_h() ||
00042                 colormodel != buffer_vector[0]->get_color_model()))
00043         {
00044                 delete_buffer_vector();
00045         }
00046 
00047         if(!buffer_vector)
00048         {
00049                 buffer_vector = new VFrame*[virtual_plugins.total];
00050                 for(int i = 0; i < virtual_plugins.total; i++)
00051                 {
00052                         buffer_vector[i] = new VFrame(0,
00053                                 width,
00054                                 height,
00055                                 colormodel,
00056                                 -1);
00057                 }
00058         }
00059 }
00060 
00061 int VAttachmentPoint::get_buffer_size()
00062 {
00063         return 1;
00064 }
00065 
00066 void VAttachmentPoint::render(VFrame *output, 
00067         int buffer_number,
00068         int64_t start_position,
00069         double frame_rate,
00070         int debug_render)
00071 {
00072         if(!this) printf("VAttachmentPoint::render NULL\n");
00073         if(!plugin_server || !plugin->on) return;
00074 
00075         if(debug_render)
00076                 printf("    VAttachmentPoint::render %s %d\n", 
00077                         plugin_server->title,
00078                         plugin_server->multichannel);
00079 
00080         if(plugin_server->multichannel)
00081         {
00082 // Test against previous parameters for reuse of previous data
00083                 if(is_processed &&
00084                         this->start_position == start_position &&
00085                         EQUIV(this->frame_rate, frame_rate))
00086                 {
00087                         output->copy_from(buffer_vector[buffer_number]);
00088                         return;
00089                 }
00090 
00091                 is_processed = 1;
00092                 this->start_position = start_position;
00093                 this->frame_rate = frame_rate;
00094 
00095 // Allocate buffer vector
00096                 new_buffer_vector(output->get_w(), 
00097                         output->get_h(), 
00098                         output->get_color_model());
00099 
00100 // Create temporary vector with output argument substituted in
00101                 VFrame **output_temp = new VFrame*[virtual_plugins.total];
00102                 for(int i = 0; i < virtual_plugins.total; i++)
00103                 {
00104                         if(i == buffer_number)
00105                                 output_temp[i] = output;
00106                         else
00107                                 output_temp[i] = buffer_vector[i];
00108                 }
00109 
00110 // Process plugin
00111 //printf("VAttachmentPoint::render 1 %d\n", buffer_number);
00112                 plugin_servers.values[0]->process_buffer(output_temp,
00113                         start_position,
00114                         frame_rate,
00115                         (int64_t)Units::round(plugin->length * 
00116                                 frame_rate / 
00117                                 renderengine->edl->session->frame_rate),
00118                         renderengine->command->get_direction());
00119 //printf("VAttachmentPoint::render 2\n");
00120 
00121                 delete [] output_temp;
00122 //printf("VAttachmentPoint::render 3\n");
00123         }
00124         else
00125 // process single track
00126         {
00127                 VFrame *output_temp[1];
00128                 output_temp[0] = output;
00129                 plugin_servers.values[buffer_number]->process_buffer(output_temp,
00130                         start_position,
00131                         frame_rate,
00132                         (int64_t)Units::round(plugin->length * 
00133                                 frame_rate / 
00134                                 renderengine->edl->session->frame_rate),
00135                         renderengine->command->get_direction());
00136         }
00137 }
00138 
00139 

Generated on Sun Jan 8 13:39:01 2006 for Cinelerra-svn by  doxygen 1.4.4