4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "bcsignals.h"
26 #include "edlsession.h"
29 #include "pluginserver.h"
30 #include "preferences.h"
31 #include "recordablevtracks.h"
32 #include "mainsession.h"
35 #include "vpluginarray.h"
39 #define RING_BUFFERS 2
43 VPluginArray::VPluginArray()
44 : PluginArray(TRACK_VIDEO)
49 VPluginArray::~VPluginArray()
51 file->stop_video_thread();
52 for(int i = 0; i < total_tracks(); i++)
59 void VPluginArray::get_recordable_tracks()
61 tracks = new RecordableVTracks(edl->tracks);
64 int64_t VPluginArray::get_bufsize()
69 void VPluginArray::create_buffers()
71 file->start_video_thread(buffer_size,
72 edl->session->color_model,
75 // if(!plugin_server->realtime) realtime_buffers = file->get_video_buffer();
78 void VPluginArray::get_buffers()
80 if(!realtime_buffers) realtime_buffers = file->get_video_buffer();
83 void VPluginArray::create_modules()
85 modules = new Module*[total_tracks()];
86 for(int i = 0; i < total_tracks(); i++)
88 modules[i] = new VModule(0, 0, this, tracks->values[i]);
89 modules[i]->cache = cache;
90 modules[i]->edl = edl;
91 modules[i]->create_objects();
92 modules[i]->render_init();
97 void VPluginArray::process_realtime(int module,
98 int64_t input_position,
101 int ibfr = module % file->asset->layers;
102 values[module]->process_buffer(realtime_buffers[ibfr],
104 edl->session->frame_rate,
109 int VPluginArray::process_loop(int module, int64_t &write_length)
111 if(!realtime_buffers) realtime_buffers = file->get_video_buffer();
113 // Convert from array of frames to array of tracks
114 // VFrame **temp_buffer;
115 // temp_buffer = new VFrame*[total_tracks()];
116 // for(int i = 0; i < total_tracks(); i++)
118 // temp_buffer[i] = realtime_buffers[i][0];
121 int ibfr = module % file->asset->layers;
122 int result = values[module]->process_loop(realtime_buffers[ibfr], write_length);
123 // delete [] temp_buffer;
127 int VPluginArray::write_buffers(int64_t len)
129 int result = file->write_video_buffer(len);
130 realtime_buffers = 0;
132 // if(!plugin_server->realtime && !done && !result) realtime_buffers = file->get_video_buffer();
137 int VPluginArray::total_tracks()
139 return tracks->total;
142 Track* VPluginArray::track_number(int number)
144 return (Track*)tracks->values[number];