1 #include "automation.h"
4 #include "edlsession.h"
5 #include "fadeengine.h"
7 #include "floatautos.h"
10 #include "maskengine.h"
13 #include "overlayframe.h"
15 #include "preferences.h"
16 #include "renderengine.h"
17 #include "transition.h"
18 #include "transportque.h"
19 #include "vattachmentpoint.h"
21 #include "virtualvconsole.h"
22 #include "virtualvnode.h"
29 VirtualVNode::VirtualVNode(RenderEngine *renderengine,
30 VirtualConsole *vconsole,
34 VirtualNode *parent_module,
41 : VirtualNode(renderengine,
52 this->buffer_in = buffer_in;
53 this->buffer_out = buffer_out;
54 //printf("VirtualVNode::VirtualVNode 1\n");
55 overlayer = new OverlayFrame(renderengine->edl->session->smp + 1);
56 fader = new FadeEngine(renderengine->edl->session->smp + 1);
57 masker = new MaskEngine(renderengine->edl->session->smp + 1);
60 VirtualVNode::~VirtualVNode()
62 //printf("VirtualVNode::~VirtualVNode 1\n");
63 if(!shared_output) delete buffer_out;
64 if(!shared_input) delete buffer_in;
70 VirtualNode* VirtualVNode::create_module(Plugin *real_plugin,
74 return new VirtualVNode(renderengine,
80 data_in_input ? buffer_in : buffer_out,
82 data_in_input ? input_is_master : output_is_master,
89 VirtualNode* VirtualVNode::create_plugin(Plugin *real_plugin)
91 return new VirtualVNode(renderengine,
97 data_in_input ? buffer_in : buffer_out,
99 data_in_input ? input_is_master : output_is_master,
106 void VirtualVNode::new_output_buffer()
108 printf("VirtualVNode::new_input_buffer 1 %p\n", track);
109 buffer_out = new VFrame(0,
112 renderengine->edl->session->color_model,
116 void VirtualVNode::new_input_buffer()
118 printf("VirtualVNode::new_input_buffer 1 %p\n", track);
119 buffer_in = new VFrame(0,
122 renderengine->edl->session->color_model,
126 VFrame* VirtualVNode::get_module_input()
140 VFrame* VirtualVNode::get_module_output()
147 int VirtualVNode::render(VFrame **video_out, int64_t input_position)
149 //printf("VirtualVNode::render 1\n");
152 //printf("VirtualVNode::render 2\n");
153 render_as_module(video_out, input_position);
158 //printf("VirtualVNode::render 3\n");
159 render_as_plugin(input_position);
161 //printf("VirtualVNode::render 4\n");
165 void VirtualVNode::render_as_plugin(int64_t input_position)
169 !real_plugin->on) return;
171 ((VAttachmentPoint*)attachment)->render(buffer_in,
177 int VirtualVNode::render_as_module(VFrame **video_out, int64_t input_position)
179 this->reverse = reverse;
180 VFrame *buffer_in = get_module_input();
181 VFrame *buffer_out = get_module_output();
183 //printf("VirtualVNode::render_as_module 1 %d\n", buffer_out->get_color_model());
184 render_fade(buffer_in,
187 track->automation->fade_autos);
189 //printf("VirtualVNode::render_as_module 2\n");
191 // video is definitely in output buffer now
194 masker->do_mask(buffer_out,
195 track->automation->mask_autos,
197 renderengine->command->get_direction());
207 // overlay on the final output
210 int64_t mute_fragment = 1;
211 int64_t mute_position = 0;
213 //printf("VirtualVNode::render_as_module 3\n");
215 get_mute_fragment(input_position,
218 (Autos*)((VTrack*)track)->automation->mute_autos);
220 //printf("VirtualVNode::render_as_module 4 %d\n", mute_constant);
223 // Fragment is playable
224 render_projector(buffer_out,
229 //printf("VirtualVNode::render_as_module 5\n");
233 int VirtualVNode::render_fade(VFrame *input, // start of input fragment
234 VFrame *output, // start of output fragment
235 int64_t input_position, // start of input fragment in project if forward / end of input fragment if reverse
238 double slope, intercept;
239 int64_t slope_len = 1;
240 int direction = renderengine->command->get_direction();
241 FloatAuto *previous = 0;
244 intercept = ((FloatAutos*)autos)->get_value(input_position,
250 //printf("VirtualVNode::render_fade %d %f\n", input_position, intercept);
251 CLAMP(intercept, 0, 100);
254 // Can't use overlay here because overlayer blends the frame with itself.
255 // The fade engine can compensate for lack of alpha channels by reducing the
257 if(!EQUIV(intercept / 100, 1))
259 fader->do_fade(output, input, intercept / 100);
263 if(output->get_rows()[0] != input->get_rows()[0])
265 output->copy_from(input);
272 // Start of input fragment in project if forward. End of input fragment if reverse.
273 int VirtualVNode::render_projector(VFrame *input,
275 int64_t input_position)
277 float in_x1, in_y1, in_x2, in_y2;
278 float out_x1, out_y1, out_x2, out_y2;
279 float float_input_position = input_position;
281 for(int i = 0; i < MAX_CHANNELS; i++)
285 ((VTrack*)track)->calculate_output_transfer(i,
286 (int64_t)float_input_position,
287 renderengine->command->get_direction(),
302 //for(int j = 0; j < input->get_w() * 3 * 5; j++)
303 // input->get_rows()[0][j] = 255;
305 if(out_x2 > out_x1 &&
310 int direction = renderengine->command->get_direction();
311 IntAuto *mode_keyframe = 0;
313 (IntAuto*)track->automation->mode_autos->get_prev_auto(
316 (Auto*)mode_keyframe);
318 int mode = mode_keyframe->value;
320 // Fade is performed in render_fade so as to allow this module
321 // to be chained in another module, thus only 4 component colormodels
322 // can do dissolves, although a blend equation is still required for 3 component
323 // colormodels since fractional translation requires blending.
325 // If this is the only playable video track and the mode_keyframe is "normal"
326 // the mode keyframe may be overridden with "replace". Replace is faster.
327 if(mode == TRANSFER_NORMAL &&
328 vconsole->total_tracks == 1)
329 mode = TRANSFER_REPLACE;
332 overlayer->overlay(output[i],
344 renderengine->edl->session->interpolation_type);
346 // for(int j = 0; j < output[i]->get_w() * 3 * 5; j++)
347 // output[i]->get_rows()[0][j] = 255;
353 int VirtualVNode::transfer_from(VFrame *frame_out,
366 printf("VirtualVNode::transfer_from Depreciated\n", mode, alpha);
367 // overlayer->overlay(frame_out,
379 // renderengine->edl->session->interpolation_type);