5 #include "edlsession.h"
7 #include "pluginserver.h"
8 #include "renderengine.h"
9 #include "transportque.h"
10 #include "vattachmentpoint.h"
11 #include "vdevicex11.h"
12 #include "videodevice.h"
15 VAttachmentPoint::VAttachmentPoint(RenderEngine *renderengine, Plugin *plugin)
16 : AttachmentPoint(renderengine, plugin, TRACK_VIDEO)
21 VAttachmentPoint::~VAttachmentPoint()
23 delete_buffer_vector();
26 void VAttachmentPoint::delete_buffer_vector()
28 if(!this) printf("VAttachmentPoint::delete_buffer_vector NULL\n");
31 for(int i = 0; i < virtual_plugins.total; i++)
32 delete buffer_vector[i];
33 delete [] buffer_vector;
38 void VAttachmentPoint::new_buffer_vector(int width, int height, int colormodel)
40 if(!this) printf("VAttachmentPoint::new_buffer_vector NULL\n");
42 (width != buffer_vector[0]->get_w() ||
43 height != buffer_vector[0]->get_h() ||
44 colormodel != buffer_vector[0]->get_color_model()))
46 delete_buffer_vector();
51 buffer_vector = new VFrame*[virtual_plugins.total];
52 for(int i = 0; i < virtual_plugins.total; i++)
54 buffer_vector[i] = new VFrame(0,
63 int VAttachmentPoint::get_buffer_size()
68 void VAttachmentPoint::render(VFrame *output,
70 int64_t start_position,
75 if(!this) printf("VAttachmentPoint::render NULL\n");
76 if(!plugin_server || !plugin->on) return;
79 printf(" VAttachmentPoint::render \"%s\" multi=%d opengl=%d\n",
81 plugin_server->multichannel,
84 if(plugin_server->multichannel)
86 // Test against previous parameters for reuse of previous data
88 this->start_position == start_position &&
89 EQUIV(this->frame_rate, frame_rate))
91 // Need to copy PBuffer if OpenGL, regardless of use_opengl
92 if(buffer_vector[buffer_number]->get_opengl_state() == VFrame::RAM)
94 output->copy_from(buffer_vector[buffer_number]);
95 output->set_opengl_state(VFrame::RAM);
98 if(renderengine && renderengine->video)
100 // Need to copy PBuffer to texture
101 // printf("VAttachmentPoint::render temp=%p output=%p\n",
102 // buffer_vector[buffer_number],
104 VDeviceX11 *x11_device = (VDeviceX11*)renderengine->video->get_output_base();
105 x11_device->copy_frame(output, buffer_vector[buffer_number]);
111 this->start_position = start_position;
112 this->frame_rate = frame_rate;
114 // Allocate buffer vector for subsequent render calls
115 new_buffer_vector(output->get_w(),
117 output->get_color_model());
119 // Create temporary vector with output argument substituted in
120 VFrame **output_temp = new VFrame*[virtual_plugins.total];
121 for(int i = 0; i < virtual_plugins.total; i++)
123 if(i == buffer_number)
124 output_temp[i] = output;
126 output_temp[i] = buffer_vector[i];
130 //printf("VAttachmentPoint::render 1 %d\n", buffer_number);
132 plugin_servers.values[0]->set_use_opengl(use_opengl,
133 renderengine->video);
134 plugin_servers.values[0]->process_buffer(output_temp,
137 (int64_t)Units::round(plugin->length *
139 renderengine->edl->session->frame_rate),
140 renderengine->command->get_direction());
141 //printf("VAttachmentPoint::render 2\n");
143 delete [] output_temp;
144 //printf("VAttachmentPoint::render 3\n");
147 // process single track
149 VFrame *output_temp[1];
150 output_temp[0] = output;
152 plugin_servers.values[buffer_number]->set_use_opengl(use_opengl,
153 renderengine->video);
154 plugin_servers.values[buffer_number]->process_buffer(output_temp,
157 (int64_t)Units::round(plugin->length *
159 renderengine->edl->session->frame_rate),
160 renderengine->command->get_direction());