Andrew mod to ignore opus extras + title plugin X11 RGBA-FLOAT fix
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / titler / titler.C
index fcab44010e74a05c69aca8a16735e441a726c5ad..7655b5a3c8a15b01ea36c1d1a584538919e55985 100644 (file)
@@ -76,7 +76,7 @@ REGISTER_PLUGIN(TitleMain)
 #else
 #define DEFAULT_ENCODING "ISO8859-1"
 #endif
-#define DEFAULT_TIMECODEFORMAT TIME_HMS
+#define DEFAULT_TIMECODEFORMAT TIME_HMSF
 
 static inline int kw_strcmp(const char *ap, const char *bp) {
        return !strcmp(ap, bp) ? 0 : strcmp(ap,_(bp));
@@ -88,10 +88,10 @@ TitleConfig::TitleConfig()
        strcpy(encoding, DEFAULT_ENCODING);
        style = FONT_ALIAS;
        size = 48;
-       color = BLACK;
+       color = WHITE;
        alpha = 0xff;
        outline_size = 0.;
-       outline_color = WHITE;
+       outline_color = RED;
        outline_alpha = 0xff;
        color_stroke = 0xff0000;
        stroke_width = 0.0;
@@ -594,7 +594,6 @@ void TitleUnit::draw_frame(int mode, VFrame *dst, VFrame *src, int x, int y)
        int color = chr->color, max = 0xff;
        int alpha = chr->alpha * chr->fade;
        int ofs = BC_CModels::is_yuv(dst->get_color_model()) ? 0x80 : 0x00;
-
        switch( mode ) {
        case DRAW_ALPHA: {
                while( y_inp < inp_h && y_out < out_h ) {
@@ -1213,7 +1212,7 @@ Indexable *TitleMain::open_background(const char *filename)
        nested_edl->create_objects();
        nested_edl->set_path(filename);
        nested_edl->load_xml(&xml_file, LOAD_ALL);
-       TransportCommand command;
+       TransportCommand command(server->preferences);
        //command.command = audio_tracks ? NORMAL_FWD : CURRENT_FRAME;
        command.command = CURRENT_FRAME;
        command.get_edl()->copy_all(nested_edl);
@@ -2155,7 +2154,6 @@ int TitleMain::draw_underline(VFrame *mask, int alpha)
 
 void TitleMain::draw_overlay()
 {
-//printf("TitleMain::draw_overlay 1\n");
         fade = 1;
         if( !EQUIV(config.fade_in, 0) ) {
                int64_t plugin_start = get_startproject();
@@ -2275,12 +2273,19 @@ TitleTranslateUnit::TitleTranslateUnit(TitleMain *plugin, TitleTranslate *server
                        type in_r = (cp00[0]*a00 + cp01[0]*a01 + cp10[0]*a10 + cp11[0]*a11)*s + r; \
                        type in_g = (cp00[1]*a00 + cp01[1]*a01 + cp10[1]*a10 + cp11[1]*a11)*s + r; \
                        type in_b = (cp00[2]*a00 + cp01[2]*a01 + cp10[2]*a10 + cp11[2]*a11)*s + r; \
-                       type a = in_a*plugin->fade, b = max - a, px; \
-                       /*if( comps == 4 ) { b = (b * op[3]) / max; }*/ \
-                       px = *op;  *op++ = (a*in_r + b*px) / max; \
-                       px = *op;  *op++ = (a*(in_g-ofs) + b*(px-ofs)) / max + ofs; \
-                       px = *op;  *op++ = (a*(in_b-ofs) + b*(px-ofs)) / max + ofs; \
-                       if( comps == 4 ) { b = *op;  *op++ = a + b - a*b / max; } \
+                       type a = in_a*plugin->fade, px; \
+                       type b ; \
+                       double total_alpha, double_b; \
+                       if ( comps == 4 ) { b = *(op+3); } \
+                       else b = max - a; \
+                       double_b = (1.0 * b * (max - a)/(max*1.0)); \
+                       total_alpha = a + double_b; \
+                       if (total_alpha > 0.00000001) { \
+                               px = *op;  *op++ = (a*in_r + double_b*px) / total_alpha; \
+                               px = *op;  *op++ = (a*(in_g-ofs) + double_b*(px-ofs)) / total_alpha + ofs; \
+                               px = *op;  *op++ = (a*(in_b-ofs) + double_b*(px-ofs)) / total_alpha + ofs; \
+                               if( comps == 4 ) { b = *op;  *op++ = a + b - a*b / max; } \
+                       } \
                } \
        } \
 }