00001 #include "flash.h"
00002 #include "edl.inc"
00003 #include "overlayframe.h"
00004 #include "language.h"
00005 #include "picon_png.h"
00006 #include "vframe.h"
00007 #include <stdint.h>
00008
00009
00010 PluginClient* new_plugin(PluginServer *server)
00011 {
00012 return new FlashMain(server);
00013 }
00014
00015
00016
00017
00018
00019 FlashMain::FlashMain(PluginServer *server)
00020 : PluginVClient(server)
00021 {
00022 }
00023
00024 FlashMain::~FlashMain()
00025 {
00026 }
00027
00028 char* FlashMain::plugin_title() { return N_("Flash"); }
00029 int FlashMain::is_video() { return 1; }
00030 int FlashMain::is_transition() { return 1; }
00031 int FlashMain::uses_gui() { return 0; }
00032
00033 NEW_PICON_MACRO(FlashMain)
00034
00035
00036 #define FLASH(type, temp_type, components, max, chroma_offset) \
00037 { \
00038 float round_factor = (sizeof(type) < 4) ? 0.5 : 0; \
00039 temp_type foreground = (temp_type)(fraction * max + round_factor); \
00040 temp_type chroma_foreground = foreground; \
00041 if(chroma_offset) chroma_foreground = foreground * chroma_offset / max; \
00042 temp_type transparency = max - foreground; \
00043 \
00044 for(int i = 0; i < h; i++) \
00045 { \
00046 type *in_row = (type*)incoming->get_rows()[i]; \
00047 type *out_row = (type*)outgoing->get_rows()[i]; \
00048 if(is_before) \
00049 { \
00050 for(int j = 0; j < w; j++) \
00051 { \
00052 *out_row = foreground + transparency * *out_row / max; \
00053 out_row++; \
00054 *out_row = chroma_foreground + transparency * *out_row / max; \
00055 out_row++; \
00056 *out_row = chroma_foreground + transparency * *out_row / max; \
00057 out_row++; \
00058 if(components == 4) \
00059 { \
00060 *out_row = foreground + transparency * *out_row / max; \
00061 out_row++; \
00062 } \
00063 } \
00064 } \
00065 else \
00066 { \
00067 for(int j = 0; j < w; j++) \
00068 { \
00069 *out_row = foreground + transparency * *in_row / max; \
00070 out_row++; \
00071 in_row++; \
00072 *out_row = chroma_foreground + transparency * *in_row / max; \
00073 out_row++; \
00074 in_row++; \
00075 *out_row = chroma_foreground + transparency * *in_row / max; \
00076 out_row++; \
00077 in_row++; \
00078 if(components == 4) \
00079 { \
00080 *out_row = foreground + transparency * *in_row / max; \
00081 out_row++; \
00082 in_row++; \
00083 } \
00084 } \
00085 } \
00086 } \
00087 }
00088
00089 int FlashMain::process_realtime(VFrame *incoming, VFrame *outgoing)
00090 {
00091 int half = PluginClient::get_total_len() / 2;
00092 int position = half - labs(PluginClient::get_source_position() - half);
00093 float fraction = (float)position / half;
00094 int is_before = PluginClient::get_source_position() < half;
00095 int w = incoming->get_w();
00096 int h = incoming->get_h();
00097
00098 switch(incoming->get_color_model())
00099 {
00100 case BC_RGB888:
00101 FLASH(unsigned char, int, 3, 0xff, 0x0);
00102 break;
00103 case BC_RGB_FLOAT:
00104 FLASH(float, float, 3, 1.0, 0x0);
00105 break;
00106 case BC_RGBA8888:
00107 FLASH(unsigned char, int, 4, 0xff, 0x0);
00108 break;
00109 case BC_RGBA_FLOAT:
00110 FLASH(float, float, 4, 1.0, 0x0);
00111 break;
00112 case BC_YUV888:
00113 FLASH(unsigned char, int, 3, 0xff, 0x80);
00114 break;
00115 case BC_YUVA8888:
00116 FLASH(unsigned char, int, 4, 0xff, 0x80);
00117 break;
00118 case BC_RGB161616:
00119 FLASH(uint16_t, int, 3, 0xffff, 0x0);
00120 break;
00121 case BC_RGBA16161616:
00122 FLASH(uint16_t, int, 4, 0xffff, 0x0);
00123 break;
00124 case BC_YUV161616:
00125 FLASH(uint16_t, int, 3, 0xffff, 0x8000);
00126 break;
00127 case BC_YUVA16161616:
00128 FLASH(uint16_t, int, 4, 0xffff, 0x8000);
00129 break;
00130 }
00131
00132 return 0;
00133 }