From: Good Guy Date: Fri, 19 Jun 2015 02:59:52 +0000 (-0600) Subject: nix startup on theme fail, fixes for font init and titler color model X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=commitdiff_plain;h=aec726a82269214e444c42aafabdf84974e8c3b7 nix startup on theme fail, fixes for font init and titler color model --- diff --git a/cinelerra-5.0/cinelerra/mwindow.C b/cinelerra-5.0/cinelerra/mwindow.C index 7ad079b3..40a8b471 100644 --- a/cinelerra-5.0/cinelerra/mwindow.C +++ b/cinelerra-5.0/cinelerra/mwindow.C @@ -671,27 +671,44 @@ void MWindow::init_theme() if(!strcasecmp(preferences->theme, "Blond")) strcpy(preferences->theme, DEFAULT_THEME); - for(int i = 0; i < plugindb->total; i++) - { - if(plugindb->values[i]->theme && - !strcasecmp(preferences->theme, plugindb->values[i]->title)) - { - PluginServer plugin = *plugindb->values[i]; - plugin.open_plugin(0, preferences, 0, 0); - theme = plugin.new_theme(); - theme->mwindow = this; - strcpy(theme->path, plugin.path); - plugin.close_plugin(); - break; + PluginServer *theme_plugin = 0; + for(int i = 0; i < plugindb->total && !theme_plugin; i++) { + if( plugindb->values[i]->theme && + !strcasecmp(preferences->theme, plugindb->values[i]->title) ) + theme_plugin = plugindb->values[i]; + } + + if( !theme_plugin ) + fprintf(stderr, _("MWindow::init_theme: prefered theme %s not found.\n"), + preferences->theme); + + if( !theme_plugin && strcasecmp(preferences->theme, DEFAULT_THEME) ) { + fprintf(stderr, _("MWindow::init_theme: trying default theme %s\n"), + DEFAULT_THEME); + for(int i = 0; i < plugindb->total && !theme_plugin; i++) { + if( plugindb->values[i]->theme && + !strcasecmp(DEFAULT_THEME, plugindb->values[i]->title) ) + theme_plugin = plugindb->values[i]; } } - if(!theme) - { - fprintf(stderr, _("MWindow::init_theme: theme %s not found.\n"), preferences->theme); + if(!theme_plugin) { + fprintf(stderr, _("MWindow::init_theme: theme_plugin not found.\n")); exit(1); } + PluginServer plugin = *theme_plugin; + if( plugin.open_plugin(0, preferences, 0, 0) ) { + fprintf(stderr, _("MWindow::init_theme: unable to load theme %s\n"), + theme_plugin->title); + exit(1); + } + + theme = plugin.new_theme(); + theme->mwindow = this; + strcpy(theme->path, plugin.path); + plugin.close_plugin(); + // Load default images & settings theme->Theme::initialize(); // Load user images & settings @@ -1593,7 +1610,6 @@ void MWindow::create_objects(int want_gui, if(debug) PRINT_TRACE // show_splash(); - init_error(); if(debug) PRINT_TRACE init_defaults(defaults, config_path); init_preferences(); @@ -1603,6 +1619,7 @@ void MWindow::create_objects(int want_gui, if(debug) PRINT_TRACE init_theme(); if(debug) PRINT_TRACE + init_error(); char string[BCTEXTLEN]; strcpy(string, preferences->plugin_dir); diff --git a/cinelerra-5.0/guicast/bcresources.C b/cinelerra-5.0/guicast/bcresources.C index c93732ab..9c0da519 100644 --- a/cinelerra-5.0/guicast/bcresources.C +++ b/cinelerra-5.0/guicast/bcresources.C @@ -1013,7 +1013,8 @@ int BC_Resources::init_fontconfig(const char *search_path) FcChar8 *family, *file, *foundry, *style, *format; int slant, spacing, width, weight; int force_style = 0; - int limit_to_trutype = 0; // if you want limit search to TrueType put 1 +// if you want limit search to TrueType put 1 + int limit_to_trutype = 1; FcConfig *config; int i; char tmpstring[BCTEXTLEN]; @@ -1051,7 +1052,7 @@ int BC_Resources::init_fontconfig(const char *search_path) force_style = 0; FcPatternGetString(font, FC_FONTFORMAT, 0, &format); //on this point you can limit font search - if(!limit_to_trutype || !strcmp((char *)format, "TrueType")) + if(limit_to_trutype && strcmp((char *)format, "TrueType")) continue; sprintf(tmpstring, "%s", format); diff --git a/cinelerra-5.0/plugins/titler/title.C b/cinelerra-5.0/plugins/titler/title.C index 4cc97451..47e01036 100644 --- a/cinelerra-5.0/plugins/titler/title.C +++ b/cinelerra-5.0/plugins/titler/title.C @@ -568,8 +568,8 @@ void TitleUnit::draw_glyph(VFrame *output, VFrame *data, TitleGlyph *glyph, int int r, g, b, a; plugin->get_color_components(&r, &g, &b, &a, 0); - int outline = plugin->config.outline_size; - if(outline) a = 0xff; + //int outline = plugin->config.outline_size; + //if(outline) a = 0xff; while( y_in < glyph_h && y_out < output_h ) { unsigned char *in_row = in_rows[y_in]; @@ -725,8 +725,6 @@ void TitleOutlineUnit::process_package(LoadPackage *package) TitleOutlinePackage *pkg = (TitleOutlinePackage*)package; int r, g, b, outline_a; plugin->get_color_components(&r, &g, &b, &outline_a, 1); - int title_r, title_g, title_b, title_a; - plugin->get_color_components(&title_r, &title_g, &title_b, &title_a, 0); unsigned char **outline_rows = plugin->outline_mask->get_rows(); unsigned char **text_rows = plugin->text_mask->get_rows(); int mask_w1 = plugin->text_mask->get_w()-1; @@ -761,6 +759,7 @@ void TitleOutlineUnit::process_package(LoadPackage *package) } else { // Overlay text mask on top of outline mask + int ofs = BC_CModels::is_yuv(plugin->output->get_color_model()) ? 0x80 : 0; for(int y = pkg->y1; y < pkg->y2; y++) { unsigned char *outline_row = outline_rows[y]; unsigned char *text_row = text_rows[y]; @@ -770,9 +769,9 @@ void TitleOutlineUnit::process_package(LoadPackage *package) int out_a = out[3], in_a = inp[3]; int transparency = in_a * (0xff - out_a) / 0xff; out[0] = (out[0] * out_a + inp[0] * transparency) / 0xff; - out[1] = (out[1] * out_a + inp[1] * transparency) / 0xff; - out[2] = (out[2] * out_a + inp[2] * transparency) / 0xff; - out[3] = out_a + transparency; + out[1] = ((out[1]-ofs) * out_a + (inp[1]-ofs) * transparency) / 0xff + ofs; + out[2] = ((out[2]-ofs) * out_a + (inp[2]-ofs) * transparency) / 0xff + ofs; + out[3] = in_a + out_a - in_a*out_a / 0xff; } } } @@ -848,7 +847,7 @@ void TitleTranslate::run_packages() -#define TRANSLATE(type, max, components) \ +#define TRANSLATE(type, max, components, ofs) \ { \ unsigned char **in_rows = plugin->text_mask->get_rows(); \ type **out_rows = (type**)plugin->output->get_rows(); \ @@ -885,10 +884,10 @@ void TitleTranslate::run_packages() x_fraction2 = \ server->x_table[j - server->out_x1_int].in_fraction2; \ \ - float fraction1 = x_fraction1 * y_fraction1; \ - float fraction2 = x_fraction2 * y_fraction1; \ - float fraction3 = x_fraction1 * y_fraction2; \ - float fraction4 = x_fraction2 * y_fraction2; \ + float fraction1 = x_fraction1 * y_fraction1 / (256.f-max); \ + float fraction2 = x_fraction2 * y_fraction1 / (256.f-max); \ + float fraction3 = x_fraction1 * y_fraction2 / (256.f-max); \ + float fraction4 = x_fraction2 * y_fraction2 / (256.f-max); \ type input_r = (type)(in_row1[in_x1 * 4 + 0] * fraction1 + \ in_row1[in_x2 * 4 + 0] * fraction2 + \ in_row2[in_x1 * 4 + 0] * fraction3 + \ @@ -916,9 +915,9 @@ void TitleTranslate::run_packages() out_row[j * components + 0] = \ (input_r * input_a + out_row[j * components + 0] * transparency) / max; \ out_row[j * components + 1] = \ - (input_g * input_a + out_row[j * components + 1] * transparency) / max; \ + ((input_g-ofs) * input_a + (out_row[j * components + 1]-ofs) * transparency) / max + ofs; \ out_row[j * components + 2] = \ - (input_b * input_a + out_row[j * components + 2] * transparency) / max; \ + ((input_b-ofs) * input_a + (out_row[j * components + 2]-ofs) * transparency) / max + ofs; \ out_row[j * components + 3] = \ MAX(input_a, out_row[j * components + 3]); \ } \ @@ -928,9 +927,9 @@ void TitleTranslate::run_packages() out_row[j * components + 0] = \ (input_r * input_a + out_row[j * components + 0] * transparency) / max; \ out_row[j * components + 1] = \ - (input_g * input_a + out_row[j * components + 1] * transparency) / max; \ + ((input_g-ofs) * input_a + (out_row[j * components + 1]-ofs) * transparency) / max + ofs; \ out_row[j * components + 2] = \ - (input_b * input_a + out_row[j * components + 2] * transparency) / max; \ + ((input_b-ofs) * input_a + (out_row[j * components + 2]-ofs) * transparency) / max + ofs; \ } \ } \ } \ @@ -999,12 +998,12 @@ void TitleTranslateUnit::process_package(LoadPackage *package) TitleTranslate *server = (TitleTranslate*)this->server; switch(plugin->output->get_color_model()) { - case BC_RGB888: TRANSLATE(unsigned char, 0xff, 3); break; - case BC_RGB_FLOAT: TRANSLATE(float, 1.0, 3); break; - case BC_YUV888: TRANSLATE(unsigned char, 0xff, 3); break; - case BC_RGBA_FLOAT: TRANSLATE(float, 1.0, 4); break; - case BC_RGBA8888: TRANSLATE(unsigned char, 0xff, 4); break; - case BC_YUVA8888: TRANSLATE(unsigned char, 0xff, 4); break; + case BC_RGB888: TRANSLATE(unsigned char, 0xff, 3, 0); break; + case BC_RGB_FLOAT: TRANSLATE(float, 1.0, 3, 0); break; + case BC_YUV888: TRANSLATE(unsigned char, 0xff, 3, 0x80); break; + case BC_RGBA_FLOAT: TRANSLATE(float, 1.0, 4, 0); break; + case BC_RGBA8888: TRANSLATE(unsigned char, 0xff, 4, 0); break; + case BC_YUVA8888: TRANSLATE(unsigned char, 0xff, 4, 0x80); break; } //printf("TitleTranslateUnit::process_package 5\n"); } @@ -1887,35 +1886,22 @@ void TitleMain::overlay_mask() void TitleMain::get_color_components(int *r, int *g, int *b, int *a, int is_outline) { - int r_in, g_in, b_in, a_in; + int color = is_outline ? config.outline_color : config.color; + unsigned char r_in = color >> 16; + unsigned char g_in = color >> 8; + unsigned char b_in = color; + *a = is_outline ? config.outline_alpha : config.alpha; - if(is_outline) - { - r_in = (config.outline_color & 0xff0000) >> 16; - g_in = (config.outline_color & 0xff00) >> 8; - b_in = config.outline_color & 0xff; - a_in = config.outline_alpha; - } - else - { - r_in = (config.color & 0xff0000) >> 16; - g_in = (config.color & 0xff00) >> 8; - b_in = config.color & 0xff; - a_in = config.alpha; - } - *r = r_in; - *g = g_in; - *b = b_in; - *a = a_in; - - switch(output->get_color_model()) - { + switch(output->get_color_model()) { case BC_YUV888: yuv.rgb_to_yuv_8(r_in, g_in, b_in, *r, *g, *b); break; case BC_YUVA8888: yuv.rgb_to_yuv_8(r_in, g_in, b_in, *r, *g, *b); break; + default: + *r = r_in; *g = g_in; *b = b_in; + break; } }