3 #include "overlayframe.h"
10 PluginClient* new_plugin(PluginServer *server)
12 return new FlashMain(server);
19 FlashMain::FlashMain(PluginServer *server)
20 : PluginVClient(server)
24 FlashMain::~FlashMain()
28 char* FlashMain::plugin_title() { return N_("Flash"); }
29 int FlashMain::is_video() { return 1; }
30 int FlashMain::is_transition() { return 1; }
31 int FlashMain::uses_gui() { return 0; }
33 NEW_PICON_MACRO(FlashMain)
36 #define FLASH(type, temp_type, components, max, chroma_offset) \
38 float round_factor = (sizeof(type) < 4) ? 0.5 : 0; \
39 temp_type foreground = (temp_type)(fraction * max + round_factor); \
40 temp_type chroma_foreground = foreground; \
41 if(chroma_offset) chroma_foreground = foreground * chroma_offset / max; \
42 temp_type transparency = max - foreground; \
44 for(int i = 0; i < h; i++) \
46 type *in_row = (type*)incoming->get_rows()[i]; \
47 type *out_row = (type*)outgoing->get_rows()[i]; \
50 for(int j = 0; j < w; j++) \
52 *out_row = foreground + transparency * *out_row / max; \
54 *out_row = chroma_foreground + transparency * *out_row / max; \
56 *out_row = chroma_foreground + transparency * *out_row / max; \
60 *out_row = foreground + transparency * *out_row / max; \
67 for(int j = 0; j < w; j++) \
69 *out_row = foreground + transparency * *in_row / max; \
72 *out_row = chroma_foreground + transparency * *in_row / max; \
75 *out_row = chroma_foreground + transparency * *in_row / max; \
80 *out_row = foreground + transparency * *in_row / max; \
89 int FlashMain::process_realtime(VFrame *incoming, VFrame *outgoing)
91 int half = PluginClient::get_total_len() / 2;
92 int position = half - labs(PluginClient::get_source_position() - half);
93 float fraction = (float)position / half;
94 int is_before = PluginClient::get_source_position() < half;
95 int w = incoming->get_w();
96 int h = incoming->get_h();
98 switch(incoming->get_color_model())
101 FLASH(unsigned char, int, 3, 0xff, 0x0);
104 FLASH(float, float, 3, 1.0, 0x0);
107 FLASH(unsigned char, int, 4, 0xff, 0x0);
110 FLASH(float, float, 4, 1.0, 0x0);
113 FLASH(unsigned char, int, 3, 0xff, 0x80);
116 FLASH(unsigned char, int, 4, 0xff, 0x80);
119 FLASH(uint16_t, int, 3, 0xffff, 0x0);
121 case BC_RGBA16161616:
122 FLASH(uint16_t, int, 4, 0xffff, 0x0);
125 FLASH(uint16_t, int, 3, 0xffff, 0x8000);
127 case BC_YUVA16161616:
128 FLASH(uint16_t, int, 4, 0xffff, 0x8000);