4 #include "commonrender.h"
7 #include "edlsession.h"
10 #include "floatautos.h"
11 #include "overlayframe.h"
13 #include "renderengine.h"
14 #include "sharedlocation.h"
15 #include "transition.h"
16 #include "transportque.h"
18 #include "vattachmentpoint.h"
26 VModule::VModule(RenderEngine *renderengine,
27 CommonRender *commonrender,
28 PluginArray *plugin_array,
30 : Module(renderengine, commonrender, plugin_array, track)
32 data_type = TRACK_VIDEO;
33 input_temp = transition_temp = 0;
45 delete transition_temp;
47 if(overlayer) delete overlayer;
51 AttachmentPoint* VModule::new_attachment(Plugin *plugin)
53 return new VAttachmentPoint(renderengine, plugin);
56 int VModule::get_buffer_size()
61 CICache* VModule::get_cache()
64 return renderengine->get_vcache();
69 int VModule::import_frame(VFrame *output,
71 int64_t input_position,
74 int64_t corrected_position = input_position;
75 if(direction == PLAY_REVERSE) corrected_position--;
76 // Translation of edit
87 //printf("VModule::import_frame 1 %p\n", current_edit);
88 // Load frame into output
92 //printf("VModule::import_frame 1\n");
93 File *source = get_cache()->check_out(current_edit->asset);
97 //printf("VModule::import_frame 1\n");
98 source->set_video_position(corrected_position -
99 current_edit->startproject +
100 current_edit->startsource,
101 get_edl()->session->frame_rate);
102 source->set_layer(current_edit->channel);
103 //printf("VModule::import_frame 2\n");
105 ((VTrack*)track)->calculate_input_transfer(current_edit->asset,
116 // printf("VModule::import_frame 1 %0.2f %0.2f %0.2f %0.2f -> %0.2f %0.2f %0.2f %0.2f\n",
128 // file -> temp -> output
129 if( !EQUIV(in_x1, 0) ||
131 !EQUIV(in_w1, track->track_w) ||
132 !EQUIV(in_h1, track->track_h) ||
135 !EQUIV(out_w1, track->track_w) ||
136 !EQUIV(out_h1, track->track_h) ||
137 !EQUIV(in_w1, current_edit->asset->width) ||
138 !EQUIV(in_h1, current_edit->asset->height))
141 //printf("VModule::import_frame 3\n");
143 (input_temp->get_w() != current_edit->asset->width ||
144 input_temp->get_h() != current_edit->asset->height))
146 //printf("VModule::import_frame 3\n");
157 //printf("VModule::import_frame 4\n");
158 input_temp = new VFrame(0,
159 current_edit->asset->width,
160 current_edit->asset->height,
161 get_edl()->session->color_model,
164 //printf("VModule::import_frame 5\n");
167 result = source->read_frame(input_temp);
170 overlayer = new OverlayFrame(get_edl()->session->smp + 1);
172 // printf("VModule::import_frame 1 %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f\n",
183 // for(int j = 0; j < output->get_w() * 3 * 5; j++)
184 // output->get_rows()[0][j] = 255;
186 output->clear_frame();
189 // get_cache()->check_in(current_edit->asset);
192 // TRANSFER_REPLACE is the fastest transfer mode but it has the disadvantage
193 // of producing green borders in floating point translation of YUV
194 int mode = TRANSFER_REPLACE;
195 if(get_edl()->session->interpolation_type != NEAREST_NEIGHBOR &&
196 cmodel_is_yuv(output->get_color_model()))
197 mode = TRANSFER_NORMAL;
199 overlayer->overlay(output,
211 get_edl()->session->interpolation_type);
217 //printf("VModule::import_frame 6\n");
218 result = source->read_frame(output);
220 //printf("VModule::import_frame 6\n");
222 get_cache()->check_in(current_edit->asset);
226 output->clear_frame();
233 output->clear_frame();
235 //printf("VModule::import_frame 7\n");
242 int VModule::render(VFrame *output,
243 int64_t input_position,
248 //printf("VModule::render 1 %d\n", input_position);
249 update_transition(input_position, direction);
251 VEdit* current_edit = (VEdit*)track->edits->editof(input_position,
253 VEdit* previous_edit = 0;
254 //printf("VModule::render 2\n");
258 output->clear_frame();
262 //printf("VModule::render 3\n");
264 //printf("VModule::render 3 %p\n", transition);
265 // Process transition
268 // Load incoming frame
271 transition_temp = new VFrame(0,
274 get_edl()->session->color_model,
278 result = import_frame(transition_temp,
284 // Load transition buffer
285 //printf("VModule::render 2\n");
286 previous_edit = (VEdit*)current_edit->previous;
288 //printf("VModule::render 3\n");
289 result |= import_frame(output,
294 // Execute plugin with transition_temp and output here
295 //printf("VModule::render 4 %d - %d %d\n", input_position, current_edit->startproject, transition->length);
296 transition_server->process_realtime(&transition_temp,
298 (direction == PLAY_FORWARD) ?
299 (input_position - current_edit->startproject) :
300 (input_position - current_edit->startproject - 1),
305 // Load output buffer
306 result = import_frame(output,
312 //printf("VModule::render 5\n");
321 void VModule::create_objects()
323 Module::create_objects();