4 #include "commonrender.h"
7 #include "edlsession.h"
10 #include "floatautos.h"
11 #include "overlayframe.h"
13 #include "preferences.h"
14 #include "renderengine.h"
15 #include "sharedlocation.h"
16 #include "transition.h"
17 #include "transportque.h"
19 #include "vattachmentpoint.h"
27 VModule::VModule(RenderEngine *renderengine,
28 CommonRender *commonrender,
29 PluginArray *plugin_array,
31 : Module(renderengine, commonrender, plugin_array, track)
33 data_type = TRACK_VIDEO;
34 input_temp = transition_temp = 0;
46 delete transition_temp;
48 if(overlayer) delete overlayer;
52 AttachmentPoint* VModule::new_attachment(Plugin *plugin)
54 return new VAttachmentPoint(renderengine, plugin);
57 int VModule::get_buffer_size()
62 CICache* VModule::get_cache()
65 return renderengine->get_vcache();
70 int VModule::import_frame(VFrame *output,
72 int64_t input_position,
75 int64_t corrected_position;
77 // Translation of edit
88 corrected_position = input_position;
89 if(direction == PLAY_REVERSE) corrected_position--;
91 // Load frame into output
95 File *source = get_cache()->check_out(current_edit->asset);
99 source->set_video_position(corrected_position -
100 current_edit->startproject +
101 current_edit->startsource,
102 get_edl()->session->frame_rate);
103 source->set_layer(current_edit->channel);
105 ((VTrack*)track)->calculate_input_transfer(current_edit->asset,
119 // file -> temp -> output
120 if( !EQUIV(in_x1, 0) ||
122 !EQUIV(in_w1, track->track_w) ||
123 !EQUIV(in_h1, track->track_h) ||
126 !EQUIV(out_w1, track->track_w) ||
127 !EQUIV(out_h1, track->track_h) ||
128 !EQUIV(in_w1, current_edit->asset->width) ||
129 !EQUIV(in_h1, current_edit->asset->height))
133 (input_temp->get_w() != current_edit->asset->width ||
134 input_temp->get_h() != current_edit->asset->height))
146 //printf("VModule::import_frame 4\n");
147 input_temp = new VFrame(0,
148 current_edit->asset->width,
149 current_edit->asset->height,
150 get_edl()->session->color_model,
153 //printf("VModule::import_frame 5\n");
156 result = source->read_frame(input_temp);
159 overlayer = new OverlayFrame(renderengine->preferences->processors);
161 // printf("VModule::import_frame 1 %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f\n",
172 // for(int j = 0; j < output->get_w() * 3 * 5; j++)
173 // output->get_rows()[0][j] = 255;
175 output->clear_frame();
178 // get_cache()->check_in(current_edit->asset);
181 // TRANSFER_REPLACE is the fastest transfer mode but it has the disadvantage
182 // of producing green borders in floating point translation of YUV
183 int mode = TRANSFER_REPLACE;
184 if(get_edl()->session->interpolation_type != NEAREST_NEIGHBOR &&
185 cmodel_is_yuv(output->get_color_model()))
186 mode = TRANSFER_NORMAL;
188 overlayer->overlay(output,
200 get_edl()->session->interpolation_type);
206 //printf("VModule::import_frame 6\n");
207 result = source->read_frame(output);
209 //printf("VModule::import_frame 6\n");
211 get_cache()->check_in(current_edit->asset);
215 output->clear_frame();
222 output->clear_frame();
224 //printf("VModule::import_frame 7\n");
231 int VModule::render(VFrame *output,
232 int64_t input_position,
237 if(use_nudge) input_position += track->nudge;
239 update_transition(input_position, direction);
241 VEdit* current_edit = (VEdit*)track->edits->editof(input_position,
244 VEdit* previous_edit = 0;
248 output->clear_frame();
253 // Process transition
256 // Load incoming frame
259 transition_temp = new VFrame(0,
262 get_edl()->session->color_model,
266 result = import_frame(transition_temp,
272 // Load transition buffer
273 previous_edit = (VEdit*)current_edit->previous;
275 result |= import_frame(output,
280 // Execute plugin with transition_temp and output here
281 int64_t corrected_position = input_position;
282 if(direction == PLAY_REVERSE)
283 corrected_position--;
285 transition_server->process_realtime(&transition_temp,
287 (direction == PLAY_FORWARD) ?
288 (input_position - current_edit->startproject) :
289 (input_position - current_edit->startproject - 1),
294 // Load output buffer
295 result = import_frame(output,
310 void VModule::create_objects()
312 Module::create_objects();