4 #include "overlayframe.h"
10 PluginClient* new_plugin(PluginServer *server)
12 return new DissolveMain(server);
19 DissolveMain::DissolveMain(PluginServer *server)
20 : PluginVClient(server)
25 DissolveMain::~DissolveMain()
30 char* DissolveMain::plugin_title() { return N_("Dissolve"); }
31 int DissolveMain::is_video() { return 1; }
32 int DissolveMain::is_transition() { return 1; }
33 int DissolveMain::uses_gui() { return 0; }
35 NEW_PICON_MACRO(DissolveMain)
38 int DissolveMain::process_realtime(VFrame *incoming, VFrame *outgoing)
40 fade = (float)PluginClient::get_source_position() /
41 PluginClient::get_total_len();
51 if(!overlayer) overlayer = new OverlayFrame(get_project_smp() + 1);
54 // There is a problem when dissolving from a big picture to a small picture.
55 // In order to make it dissolve correctly, we have to manually decrese alpha of big picture.
56 switch (outgoing->get_color_model())
61 uint8_t** data_rows = (uint8_t **)outgoing->get_rows();
62 int w = outgoing->get_w();
63 int h = outgoing->get_h();
64 for(int i = 0; i < h; i++)
66 uint8_t* alpha_chan = data_rows[i] + 3;
67 for(int j = 0; j < w; j++)
69 *alpha_chan = (uint8_t) (*alpha_chan * (1-fade));
77 uint16_t** data_rows = (uint16_t **)outgoing->get_rows();
78 int w = outgoing->get_w();
79 int h = outgoing->get_h();
80 for(int i = 0; i < h; i++)
82 uint16_t* alpha_chan = data_rows[i] + 3; // 3 since this is uint16_t
83 for(int j = 0; j < w; j++)
85 *alpha_chan = (uint16_t)(*alpha_chan * (1-fade));
93 float** data_rows = (float **)outgoing->get_rows();
94 int w = outgoing->get_w();
95 int h = outgoing->get_h();
96 for(int i = 0; i < h; i++)
98 float* alpha_chan = data_rows[i] + 3; // 3 since this is floats
99 for(int j = 0; j < w; j++)
101 *alpha_chan = *alpha_chan * (1-fade);
102 alpha_chan += sizeof(float);
112 overlayer->overlay(outgoing,
129 int DissolveMain::handle_opengl()
133 // Read images from RAM
134 get_input()->to_texture();
135 get_output()->to_texture();
137 // Create output pbuffer
138 get_output()->enable_opengl();
140 VFrame::init_screen(get_output()->get_w(), get_output()->get_h());
142 // Enable output texture
143 get_output()->bind_texture(0);
144 // Draw output texture
146 glColor4f(1, 1, 1, 1);
147 get_output()->draw_texture();
149 // Draw input texture
150 get_input()->bind_texture(0);
152 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
153 glColor4f(1, 1, 1, fade);
154 get_input()->draw_texture();
158 get_output()->set_opengl_state(VFrame::SCREEN);