00001
00002
00003
00004
00005
00006 #include "clip.h"
00007 #include "colormodels.h"
00008 #include "filexml.h"
00009 #include "filesystem.h"
00010 #include "transportque.inc"
00011 #include "ft2build.h"
00012 #include FT_GLYPH_H
00013 #include FT_BBOX_H
00014 #include FT_OUTLINE_H
00015 #include FT_STROKER_H
00016
00017 #include "language.h"
00018 #include "mwindow.inc"
00019 #include "picon_png.h"
00020 #include "plugincolors.h"
00021 #include "title.h"
00022 #include "titlewindow.h"
00023 #include "transportque.inc"
00024
00025
00026 #include <errno.h>
00027 #include <stdint.h>
00028 #include <stdio.h>
00029 #include <string.h>
00030 #include <endian.h>
00031 #include <byteswap.h>
00032 #include <iconv.h>
00033 #include <sys/stat.h>
00034
00035 #define ZERO (1.0 / 64.0)
00036
00037 #define FONT_SEARCHPATH "fonts"
00038
00039
00040
00041 REGISTER_PLUGIN(TitleMain)
00042
00043
00044 TitleConfig::TitleConfig()
00045 {
00046 style = 0;
00047 color = BLACK;
00048 color_stroke = 0xff0000;
00049 size = 24;
00050 motion_strategy = NO_MOTION;
00051 loop = 0;
00052 hjustification = JUSTIFY_CENTER;
00053 vjustification = JUSTIFY_MID;
00054 fade_in = 0.0;
00055 fade_out = 0.0;
00056 x = 0.0;
00057 y = 0.0;
00058 dropshadow = 10;
00059 sprintf(font, "fixed");
00060 sprintf(text, _("hello world"));
00061 #define DEFAULT_ENCODING "ISO8859-1"
00062 sprintf(encoding, DEFAULT_ENCODING);
00063 #define DEFAULT_TIMECODEFORMAT "h:mm:ss:ff"
00064 sprintf(timecodeformat, DEFAULT_TIMECODEFORMAT);
00065 pixels_per_second = 1.0;
00066 timecode = 0;
00067 stroke_width = 1.0;
00068 }
00069
00070
00071 int TitleConfig::equivalent(TitleConfig &that)
00072 {
00073 return dropshadow == that.dropshadow &&
00074 style == that.style &&
00075 size == that.size &&
00076 color == that.color &&
00077 color_stroke == that.color_stroke &&
00078 stroke_width == that.stroke_width &&
00079 timecode == that.timecode &&
00080 !strcasecmp(timecodeformat, that.timecodeformat) &&
00081 hjustification == that.hjustification &&
00082 vjustification == that.vjustification &&
00083 EQUIV(pixels_per_second, that.pixels_per_second) &&
00084 !strcasecmp(font, that.font) &&
00085 !strcasecmp(encoding, that.encoding) &&
00086 !strcmp(text, that.text);
00087 }
00088
00089 void TitleConfig::copy_from(TitleConfig &that)
00090 {
00091 strcpy(font, that.font);
00092 style = that.style;
00093 size = that.size;
00094 color = that.color;
00095 color_stroke = that.color_stroke;
00096 stroke_width = that.stroke_width;
00097 pixels_per_second = that.pixels_per_second;
00098 motion_strategy = that.motion_strategy;
00099 loop = that.loop;
00100 hjustification = that.hjustification;
00101 vjustification = that.vjustification;
00102 fade_in = that.fade_in;
00103 fade_out = that.fade_out;
00104 x = that.x;
00105 y = that.y;
00106 dropshadow = that.dropshadow;
00107 timecode = that.timecode;
00108 strcpy(timecodeformat, that.timecodeformat);
00109 strcpy(text, that.text);
00110 strcpy(encoding, that.encoding);
00111 }
00112
00113 void TitleConfig::interpolate(TitleConfig &prev,
00114 TitleConfig &next,
00115 int64_t prev_frame,
00116 int64_t next_frame,
00117 int64_t current_frame)
00118 {
00119 strcpy(font, prev.font);
00120 strcpy(encoding, prev.encoding);
00121 style = prev.style;
00122 size = prev.size;
00123 color = prev.color;
00124 color_stroke = prev.color_stroke;
00125 stroke_width = prev.stroke_width;
00126 motion_strategy = prev.motion_strategy;
00127 loop = prev.loop;
00128 hjustification = prev.hjustification;
00129 vjustification = prev.vjustification;
00130 fade_in = prev.fade_in;
00131 fade_out = prev.fade_out;
00132 pixels_per_second = prev.pixels_per_second;
00133 strcpy(text, prev.text);
00134
00135 double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame);
00136 double prev_scale = (double)(next_frame - current_frame) / (next_frame - prev_frame);
00137
00138
00139
00140
00141 this->x = prev.x;
00142 this->y = prev.y;
00143 timecode = prev.timecode;
00144 strcpy(timecodeformat, prev.timecodeformat);
00145
00146 this->dropshadow = prev.dropshadow;
00147 }
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 FontEntry::FontEntry()
00166 {
00167 path = 0;
00168 foundary = 0;
00169 family = 0;
00170 weight = 0;
00171 slant = 0;
00172 swidth = 0;
00173 adstyle = 0;
00174 spacing = 0;
00175 registry = 0;
00176 encoding = 0;
00177 fixed_title = 0;
00178 fixed_style = 0;
00179 }
00180
00181 FontEntry::~FontEntry()
00182 {
00183 if(path) delete [] path;
00184 if(foundary) delete [] foundary;
00185 if(family) delete [] family;
00186 if(weight) delete [] weight;
00187 if(slant) delete [] slant;
00188 if(swidth) delete [] swidth;
00189 if(adstyle) delete [] adstyle;
00190 if(spacing) delete [] spacing;
00191 if(registry) delete [] registry;
00192 if(encoding) delete [] encoding;
00193 if(fixed_title) delete [] fixed_title;
00194 }
00195
00196 void FontEntry::dump()
00197 {
00198 printf("%s: %s %s %s %s %s %s %d %d %d %d %s %d %s %s\n",
00199 path,
00200 foundary,
00201 family,
00202 weight,
00203 slant,
00204 swidth,
00205 adstyle,
00206 pixelsize,
00207 pointsize,
00208 xres,
00209 yres,
00210 spacing,
00211 avg_width,
00212 registry,
00213 encoding);
00214 }
00215
00216 TitleGlyph::TitleGlyph()
00217 {
00218 char_code = 0;
00219 c=0;
00220 data = 0;
00221 data_stroke = 0;
00222 }
00223
00224
00225 TitleGlyph::~TitleGlyph()
00226 {
00227
00228 if(data) delete data;
00229 if(data_stroke) delete data_stroke;
00230 }
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242 GlyphPackage::GlyphPackage() : LoadPackage()
00243 {
00244 }
00245
00246 GlyphUnit::GlyphUnit(TitleMain *plugin, GlyphEngine *server)
00247 : LoadClient(server)
00248 {
00249 this->plugin = plugin;
00250 current_font = 0;
00251 freetype_library = 0;
00252 freetype_face = 0;
00253 }
00254
00255 GlyphUnit::~GlyphUnit()
00256 {
00257 if(freetype_library) FT_Done_FreeType(freetype_library);
00258 }
00259
00260 void GlyphUnit::process_package(LoadPackage *package)
00261 {
00262 GlyphPackage *pkg = (GlyphPackage*)package;
00263 TitleGlyph *glyph = pkg->glyph;
00264 int result = 0;
00265
00266 if(!freetype_library)
00267 {
00268 current_font = plugin->get_font();
00269
00270 if(plugin->load_freetype_face(freetype_library,
00271 freetype_face,
00272 current_font->path))
00273 {
00274 printf(_("GlyphUnit::process_package FT_New_Face failed.\n"));
00275 result = 1;
00276 }
00277 else
00278 {
00279 FT_Set_Pixel_Sizes(freetype_face, plugin->config.size, 0);
00280 }
00281 }
00282
00283 if(!result)
00284 {
00285 int gindex = FT_Get_Char_Index(freetype_face, glyph->char_code);
00286
00287
00288
00289 if (gindex == 0)
00290 {
00291
00292 if (glyph->char_code != 10)
00293 printf(_("GlyphUnit::process_package FT_Load_Char failed - char: %i.\n"),
00294 glyph->char_code);
00295
00296 glyph->width = 8;
00297 glyph->height = 8;
00298 glyph->pitch = 8;
00299 glyph->left = 9;
00300 glyph->top = 9;
00301 glyph->freetype_index = 0;
00302 glyph->advance_w = 8;
00303 glyph->data = new VFrame(0,
00304 8,
00305 8,
00306 BC_A8,
00307 8);
00308 glyph->data->clear_frame();
00309 glyph->data_stroke = 0;
00310
00311
00312
00313
00314 if (plugin->config.stroke_width >= ZERO &&
00315 (plugin->config.style & FONT_OUTLINE))
00316 {
00317 glyph->data_stroke = new VFrame(0,
00318 8,
00319 8,
00320 BC_A8,
00321 8);
00322 glyph->data_stroke->clear_frame();
00323 }
00324
00325
00326
00327 }
00328 else
00329
00330 if (plugin->config.stroke_width < ZERO ||
00331 !(plugin->config.style & FONT_OUTLINE))
00332 {
00333 FT_Glyph glyph_image;
00334 FT_BBox bbox;
00335 FT_Bitmap bm;
00336 FT_Load_Glyph(freetype_face, gindex, FT_LOAD_DEFAULT);
00337 FT_Get_Glyph(freetype_face->glyph, &glyph_image);
00338 FT_Outline_Get_BBox(&((FT_OutlineGlyph) glyph_image)->outline, &bbox);
00339
00340
00341
00342 FT_Outline_Translate(&((FT_OutlineGlyph) glyph_image)->outline,
00343 - bbox.xMin,
00344 - bbox.yMin);
00345 glyph->width = bm.width = ((bbox.xMax - bbox.xMin + 63) >> 6);
00346 glyph->height = bm.rows = ((bbox.yMax - bbox.yMin + 63) >> 6);
00347 glyph->pitch = bm.pitch = bm.width;
00348 bm.pixel_mode = FT_PIXEL_MODE_GRAY;
00349 bm.num_grays = 256;
00350 glyph->left = (bbox.xMin + 31) >> 6;
00351 if (glyph->left < 0) glyph->left = 0;
00352 glyph->top = (bbox.yMax + 31) >> 6;
00353 glyph->freetype_index = gindex;
00354 glyph->advance_w = ((freetype_face->glyph->advance.x + 31) >> 6);
00355
00356
00357
00358 glyph->data = new VFrame(0,
00359 glyph->width,
00360 glyph->height,
00361 BC_A8,
00362 glyph->pitch);
00363 glyph->data->clear_frame();
00364 bm.buffer = glyph->data->get_data();
00365 FT_Outline_Get_Bitmap( freetype_library,
00366 &((FT_OutlineGlyph) glyph_image)->outline,
00367 &bm);
00368 FT_Done_Glyph(glyph_image);
00369 }
00370 else
00371
00372 {
00373 FT_Glyph glyph_image;
00374 int no_outline = 0;
00375 FT_Stroker stroker;
00376 FT_Outline outline;
00377 FT_Bitmap bm;
00378 FT_BBox bbox;
00379 FT_UInt npoints, ncontours;
00380
00381 typedef struct FT_LibraryRec_
00382 {
00383 FT_Memory memory;
00384 } FT_LibraryRec;
00385
00386 FT_Load_Glyph(freetype_face, gindex, FT_LOAD_DEFAULT);
00387 FT_Get_Glyph(freetype_face->glyph, &glyph_image);
00388
00389
00390 FT_Outline_Get_BBox(&((FT_OutlineGlyph) glyph_image)->outline, &bbox);
00391 if (bbox.xMin == 0 && bbox.xMax == 0 && bbox.yMin ==0 && bbox.yMax == 0)
00392 {
00393 FT_Done_Glyph(glyph_image);
00394 glyph->data = new VFrame(0, 0, BC_A8,0);
00395 glyph->data_stroke = new VFrame(0, 0, BC_A8,0);;
00396 glyph->width=0;
00397 glyph->height=0;
00398 glyph->top=0;
00399 glyph->left=0;
00400 glyph->advance_w =((int)(freetype_face->glyph->advance.x +
00401 plugin->config.stroke_width * 64)) >> 6;
00402 return;
00403 }
00404 #if FREETYPE_MAJOR > 2 || (FREETYPE_MAJOR == 2 && FREETYPE_MINOR >= 2)
00405 FT_Stroker_New(freetype_library, &stroker);
00406 #else
00407 FT_Stroker_New(((FT_LibraryRec *)freetype_library)->memory, &stroker);
00408 #endif
00409 FT_Stroker_Set(stroker, (int)(plugin->config.stroke_width * 64), FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
00410 FT_Stroker_ParseOutline(stroker, &((FT_OutlineGlyph) glyph_image)->outline,1);
00411 FT_Stroker_GetCounts(stroker,&npoints, &ncontours);
00412 if (npoints ==0 && ncontours == 0)
00413 {
00414
00415 FT_Stroker_Done(stroker);
00416 FT_Done_Glyph(glyph_image);
00417 glyph->data = new VFrame(0, 0, BC_A8,0);
00418 glyph->data_stroke = new VFrame(0, 0, BC_A8,0);;
00419 glyph->width=0;
00420 glyph->height=0;
00421 glyph->top=0;
00422 glyph->left=0;
00423 glyph->advance_w =((int)(freetype_face->glyph->advance.x +
00424 plugin->config.stroke_width * 64)) >> 6;
00425 return;
00426 };
00427
00428 FT_Outline_New(freetype_library, npoints, ncontours, &outline);
00429 outline.n_points=0;
00430 outline.n_contours=0;
00431 FT_Stroker_Export (stroker, &outline);
00432 FT_Outline_Get_BBox(&outline, &bbox);
00433
00434 FT_Outline_Translate(&outline,
00435 - bbox.xMin,
00436 - bbox.yMin);
00437
00438 FT_Outline_Translate(&((FT_OutlineGlyph) glyph_image)->outline,
00439 - bbox.xMin,
00440 - bbox.yMin + (int)(plugin->config.stroke_width*32));
00441
00442
00443
00444
00445 glyph->width = bm.width = ((bbox.xMax - bbox.xMin) >> 6)+1;
00446 glyph->height = bm.rows = ((bbox.yMax - bbox.yMin) >> 6) +1;
00447 glyph->pitch = bm.pitch = bm.width;
00448 bm.pixel_mode = FT_PIXEL_MODE_GRAY;
00449 bm.num_grays = 256;
00450 glyph->left = (bbox.xMin + 31) >> 6;
00451 if (glyph->left < 0) glyph->left = 0;
00452 glyph->top = (bbox.yMax + 31) >> 6;
00453 glyph->freetype_index = gindex;
00454 int real_advance = ((int)ceil((float)freetype_face->glyph->advance.x +
00455 plugin->config.stroke_width * 64) >> 6);
00456 glyph->advance_w = glyph->width + glyph->left;
00457 if (real_advance > glyph->advance_w)
00458 glyph->advance_w = real_advance;
00459
00460
00461
00462
00463
00464 glyph->data = new VFrame(0,
00465 glyph->width,
00466 glyph->height,
00467 BC_A8,
00468 glyph->pitch);
00469 glyph->data_stroke = new VFrame(0,
00470 glyph->width,
00471 glyph->height,
00472 BC_A8,
00473 glyph->pitch);
00474 glyph->data->clear_frame();
00475 glyph->data_stroke->clear_frame();
00476
00477 bm.buffer=glyph->data->get_data();
00478 FT_Outline_Get_Bitmap( freetype_library,
00479 &((FT_OutlineGlyph) glyph_image)->outline,
00480 &bm);
00481 bm.buffer=glyph->data_stroke->get_data();
00482 FT_Outline_Get_Bitmap( freetype_library,
00483 &outline,
00484 &bm);
00485 FT_Outline_Done(freetype_library,&outline);
00486 FT_Stroker_Done(stroker);
00487 FT_Done_Glyph(glyph_image);
00488
00489
00490 }
00491 }
00492 }
00493
00494 GlyphEngine::GlyphEngine(TitleMain *plugin, int cpus)
00495 : LoadServer(cpus, cpus)
00496 {
00497 this->plugin = plugin;
00498 }
00499 void GlyphEngine::init_packages()
00500 {
00501 int current_package = 0;
00502 for(int i = 0; i < plugin->glyphs.total; i++)
00503 {
00504 if(!plugin->glyphs.values[i]->data)
00505 {
00506 GlyphPackage *pkg = (GlyphPackage*)get_package(current_package++);
00507 pkg->glyph = plugin->glyphs.values[i];
00508 }
00509 }
00510 }
00511 LoadClient* GlyphEngine::new_client()
00512 {
00513 return new GlyphUnit(plugin, this);
00514 }
00515 LoadPackage* GlyphEngine::new_package()
00516 {
00517 return new GlyphPackage;
00518 }
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533 TitlePackage::TitlePackage()
00534 : LoadPackage()
00535 {
00536 }
00537
00538
00539 TitleUnit::TitleUnit(TitleMain *plugin, TitleEngine *server)
00540 : LoadClient(server)
00541 {
00542 this->plugin = plugin;
00543 }
00544
00545 void TitleUnit::draw_glyph(VFrame *output, TitleGlyph *glyph, int x, int y)
00546 {
00547 int glyph_w = glyph->data->get_w();
00548 int glyph_h = glyph->data->get_h();
00549 int output_w = output->get_w();
00550 int output_h = output->get_h();
00551 unsigned char **in_rows = glyph->data->get_rows();
00552 unsigned char **out_rows = output->get_rows();
00553
00554
00555 for(int in_y = 0; in_y < glyph_h; in_y++)
00556 {
00557
00558 int y_out = y + plugin->get_char_height() + in_y - glyph->top;
00559
00560
00561 if(y_out >= 0 && y_out < output_h)
00562 {
00563 unsigned char *out_row = out_rows[y_out];
00564 unsigned char *in_row = in_rows[in_y];
00565 for(int in_x = 0; in_x < glyph_w; in_x++)
00566 {
00567 int x_out = x + glyph->left + in_x;
00568 if(x_out >= 0 && x_out < output_w)
00569 {
00570 if(in_row[in_x] > 0)
00571 out_row[x_out] = in_row[in_x];
00572
00573 }
00574 }
00575 }
00576 }
00577 }
00578
00579
00580 void TitleUnit::process_package(LoadPackage *package)
00581 {
00582 TitlePackage *pkg = (TitlePackage*)package;
00583
00584 if(pkg->c != 0xa)
00585 {
00586 for(int i = 0; i < plugin->glyphs.total; i++)
00587 {
00588 TitleGlyph *glyph = plugin->glyphs.values[i];
00589 if(glyph->c == pkg->c)
00590 {
00591 draw_glyph(plugin->text_mask, glyph, pkg->x, pkg->y);
00592 if(plugin->config.stroke_width >= ZERO &&
00593 (plugin->config.style & FONT_OUTLINE))
00594 {
00595 VFrame *tmp = glyph->data;
00596 glyph->data = glyph->data_stroke;
00597 draw_glyph(plugin->text_mask_stroke, glyph, pkg->x, pkg->y);
00598 glyph->data = tmp;
00599 }
00600 break;
00601 }
00602 }
00603 }
00604 }
00605
00606 TitleEngine::TitleEngine(TitleMain *plugin, int cpus)
00607 : LoadServer(cpus, cpus)
00608 {
00609 this->plugin = plugin;
00610 }
00611
00612 void TitleEngine::init_packages()
00613 {
00614
00615 int visible_y1 = plugin->visible_row1 * plugin->get_char_height();
00616
00617 int current_package = 0;
00618 for(int i = plugin->visible_char1; i < plugin->visible_char2; i++)
00619 {
00620 title_char_position_t *char_position = plugin->char_positions + i;
00621 TitlePackage *pkg = (TitlePackage*)get_package(current_package);
00622
00623 pkg->x = char_position->x;
00624
00625 pkg->y = char_position->y - visible_y1;
00626
00627 pkg->c = plugin->config.text[i];
00628
00629 current_package++;
00630 }
00631 }
00632
00633 LoadClient* TitleEngine::new_client()
00634 {
00635 return new TitleUnit(plugin, this);
00636 }
00637
00638 LoadPackage* TitleEngine::new_package()
00639 {
00640 return new TitlePackage;
00641 }
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653 TitleTranslatePackage::TitleTranslatePackage()
00654 : LoadPackage()
00655 {
00656 }
00657
00658
00659 TitleTranslateUnit::TitleTranslateUnit(TitleMain *plugin, TitleTranslate *server)
00660 : LoadClient(server)
00661 {
00662 this->plugin = plugin;
00663 }
00664
00665
00666
00667 #define TRANSLATE(type, max, components, r, g, b) \
00668 { \
00669 unsigned char **in_rows = plugin->text_mask->get_rows(); \
00670 type **out_rows = (type**)plugin->output->get_rows(); \
00671 \
00672 for(int i = pkg->y1; i < pkg->y2; i++) \
00673 { \
00674 if(i + server->out_y1_int >= 0 && \
00675 i + server->out_y1_int < server->output_h) \
00676 { \
00677 int in_y1, in_y2; \
00678 float y_fraction1, y_fraction2; \
00679 float y_output_fraction; \
00680 in_y1 = server->y_table[i].in_x1; \
00681 in_y2 = server->y_table[i].in_x2; \
00682 y_fraction1 = server->y_table[i].in_fraction1; \
00683 y_fraction2 = server->y_table[i].in_fraction2; \
00684 y_output_fraction = server->y_table[i].output_fraction; \
00685 unsigned char *in_row1 = in_rows[in_y1]; \
00686 unsigned char *in_row2 = in_rows[in_y2]; \
00687 type *out_row = out_rows[i + server->out_y1_int]; \
00688 \
00689 for(int j = server->out_x1_int; j < server->out_x2_int; j++) \
00690 { \
00691 if(j >= 0 && j < server->output_w) \
00692 { \
00693 int in_x1; \
00694 int in_x2; \
00695 float x_fraction1; \
00696 float x_fraction2; \
00697 float x_output_fraction; \
00698 in_x1 = \
00699 server->x_table[j - server->out_x1_int].in_x1; \
00700 in_x2 = \
00701 server->x_table[j - server->out_x1_int].in_x2; \
00702 x_fraction1 = \
00703 server->x_table[j - server->out_x1_int].in_fraction1; \
00704 x_fraction2 = \
00705 server->x_table[j - server->out_x1_int].in_fraction2; \
00706 x_output_fraction = \
00707 server->x_table[j - server->out_x1_int].output_fraction; \
00708 \
00709 float fraction1 = x_fraction1 * y_fraction1; \
00710 float fraction2 = x_fraction2 * y_fraction1; \
00711 float fraction3 = x_fraction1 * y_fraction2; \
00712 float fraction4 = x_fraction2 * y_fraction2; \
00713 int input = (int)(in_row1[in_x1] * fraction1 + \
00714 in_row1[in_x2] * fraction2 + \
00715 in_row2[in_x1] * fraction3 + \
00716 in_row2[in_x2] * fraction4 + 0.5); \
00717 input *= plugin->alpha; \
00718 \
00719 input >>= 8; \
00720 \
00721 int anti_input = 0xff - input; \
00722 if(components == 4) \
00723 { \
00724 out_row[j * components + 0] = \
00725 (r * input + out_row[j * components + 0] * anti_input) / 0xff; \
00726 out_row[j * components + 1] = \
00727 (g * input + out_row[j * components + 1] * anti_input) / 0xff; \
00728 out_row[j * components + 2] = \
00729 (b * input + out_row[j * components + 2] * anti_input) / 0xff; \
00730 if(max == 0xffff) \
00731 out_row[j * components + 3] = \
00732 MAX((input << 8) | input, out_row[j * components + 3]); \
00733 else \
00734 out_row[j * components + 3] = \
00735 MAX(input, out_row[j * components + 3]); \
00736 } \
00737 else \
00738 { \
00739 out_row[j * components + 0] = \
00740 (r * input + out_row[j * components + 0] * anti_input) / 0xff; \
00741 out_row[j * components + 1] = \
00742 (g * input + out_row[j * components + 1] * anti_input) / 0xff; \
00743 out_row[j * components + 2] = \
00744 (b * input + out_row[j * components + 2] * anti_input) / 0xff; \
00745 } \
00746 } \
00747 } \
00748 } \
00749 } \
00750 }
00751
00752
00753 #define TRANSLATEA(type, max, components, r, g, b) \
00754 { \
00755 unsigned char **in_rows = plugin->text_mask->get_rows(); \
00756 type **out_rows = (type**)plugin->output->get_rows(); \
00757 \
00758 for(int i = pkg->y1; i < pkg->y2; i++) \
00759 { \
00760 if(i + server->out_y1_int >= 0 && \
00761 i + server->out_y1_int < server->output_h) \
00762 { \
00763 unsigned char *in_row = in_rows[i]; \
00764 type *out_row = out_rows[i + server->out_y1_int]; \
00765 \
00766 for(int j = server->out_x1; j < server->out_x2_int; j++) \
00767 { \
00768 if(j >= 0 && \
00769 j < server->output_w) \
00770 { \
00771 int input = (int)(in_row[j - server->out_x1]); \
00772 \
00773 input *= plugin->alpha; \
00774 \
00775 input >>= 8; \
00776 \
00777 int anti_input = 0xff - input; \
00778 if(components == 4) \
00779 { \
00780 out_row[j * components + 0] = \
00781 (r * input + out_row[j * components + 0] * anti_input) / 0xff; \
00782 out_row[j * components + 1] = \
00783 (g * input + out_row[j * components + 1] * anti_input) / 0xff; \
00784 out_row[j * components + 2] = \
00785 (b * input + out_row[j * components + 2] * anti_input) / 0xff; \
00786 if(max == 0xffff) \
00787 out_row[j * components + 3] = \
00788 MAX((input << 8) | input, out_row[j * components + 3]); \
00789 else \
00790 out_row[j * components + 3] = \
00791 MAX(input, out_row[j * components + 3]); \
00792 } \
00793 else \
00794 { \
00795 out_row[j * components + 0] = \
00796 (r * input + out_row[j * components + 0] * anti_input) / 0xff; \
00797 out_row[j * components + 1] = \
00798 (g * input + out_row[j * components + 1] * anti_input) / 0xff; \
00799 out_row[j * components + 2] = \
00800 (b * input + out_row[j * components + 2] * anti_input) / 0xff; \
00801 } \
00802 } \
00803 } \
00804 } \
00805 } \
00806 }
00807
00808 static YUV yuv;
00809
00810 void TitleTranslateUnit::process_package(LoadPackage *package)
00811 {
00812 TitleTranslatePackage *pkg = (TitleTranslatePackage*)package;
00813 TitleTranslate *server = (TitleTranslate*)this->server;
00814 int r_in, g_in, b_in;
00815
00816
00817
00818 r_in = (plugin->config.color & 0xff0000) >> 16;
00819 g_in = (plugin->config.color & 0xff00) >> 8;
00820 b_in = plugin->config.color & 0xff;
00821 switch(plugin->output->get_color_model())
00822 {
00823 case BC_RGB888:
00824 {
00825 TRANSLATE(unsigned char, 0xff, 3, r_in, g_in, b_in);
00826 break;
00827 }
00828 case BC_RGB_FLOAT:
00829 {
00830 float r, g, b;
00831 r = (float)r_in / 0xff;
00832 g = (float)g_in / 0xff;
00833 b = (float)b_in / 0xff;
00834 TRANSLATE(float, 0xff, 3, r, g, b);
00835 break;
00836 }
00837 case BC_YUV888:
00838 {
00839 unsigned char y, u, v;
00840 yuv.rgb_to_yuv_8(r_in, g_in, b_in, y, u, v);
00841 TRANSLATE(unsigned char, 0xff, 3, y, u, v);
00842 break;
00843 }
00844 case BC_RGB161616:
00845 {
00846 uint16_t r, g, b;
00847 r = (r_in << 8) | r_in;
00848 g = (g_in << 8) | g_in;
00849 b = (b_in << 8) | b_in;
00850 TRANSLATE(uint16_t, 0xffff, 3, r, g, b);
00851 break;
00852 }
00853 case BC_YUV161616:
00854 {
00855 uint16_t y, u, v;
00856 yuv.rgb_to_yuv_16(
00857 (r_in << 8) | r_in,
00858 (g_in << 8) | g_in,
00859 (b_in << 8) | b_in,
00860 y,
00861 u,
00862 v);
00863 TRANSLATE(uint16_t, 0xffff, 3, y, u, v);
00864 break;
00865 }
00866 case BC_RGBA_FLOAT:
00867 {
00868 float r, g, b;
00869 r = (float)r_in / 0xff;
00870 g = (float)g_in / 0xff;
00871 b = (float)b_in / 0xff;
00872 TRANSLATE(float, 0xff, 4, r, g, b);
00873 break;
00874 }
00875 case BC_RGBA8888:
00876 {
00877 TRANSLATE(unsigned char, 0xff, 4, r_in, g_in, b_in);
00878 break;
00879 }
00880 case BC_YUVA8888:
00881 {
00882 unsigned char y, u, v;
00883 yuv.rgb_to_yuv_8(r_in, g_in, b_in, y, u, v);
00884 TRANSLATE(unsigned char, 0xff, 4, y, u, v);
00885 break;
00886 }
00887 case BC_RGBA16161616:
00888 {
00889 uint16_t r, g, b;
00890 r = (r_in << 8) | r_in;
00891 g = (g_in << 8) | g_in;
00892 b = (b_in << 8) | b_in;
00893 TRANSLATE(uint16_t, 0xffff, 4, r, g, b);
00894 break;
00895 }
00896 case BC_YUVA16161616:
00897 {
00898 uint16_t y, u, v;
00899 yuv.rgb_to_yuv_16(
00900 (r_in << 8) | r_in,
00901 (g_in << 8) | g_in,
00902 (b_in << 8) | b_in,
00903 y,
00904 u,
00905 v);
00906 TRANSLATE(uint16_t, 0xffff, 4, y, u, v);
00907 break;
00908 }
00909 }
00910
00911
00912 }
00913
00914
00915
00916
00917 TitleTranslate::TitleTranslate(TitleMain *plugin, int cpus)
00918 : LoadServer(1, 1)
00919 {
00920 this->plugin = plugin;
00921 x_table = y_table = 0;
00922 }
00923
00924 TitleTranslate::~TitleTranslate()
00925 {
00926 if(x_table) delete [] x_table;
00927 if(y_table) delete [] y_table;
00928 }
00929
00930 void TitleTranslate::init_packages()
00931 {
00932
00933
00934 if(x_table) delete [] x_table;
00935 if(y_table) delete [] y_table;
00936
00937
00938 output_w = plugin->output->get_w();
00939 output_h = plugin->output->get_h();
00940
00941
00942
00943 TranslateUnit::translation_array_f(x_table,
00944 plugin->text_x1,
00945 plugin->text_x1 + plugin->text_w,
00946 0,
00947 plugin->text_w,
00948 plugin->text_w,
00949 output_w,
00950 out_x1_int,
00951 out_x2_int);
00952
00953
00954 TranslateUnit::translation_array_f(y_table,
00955 plugin->mask_y1,
00956 plugin->mask_y1 + plugin->text_mask->get_h(),
00957 0,
00958 plugin->text_mask->get_h(),
00959 plugin->text_mask->get_h(),
00960 output_h,
00961 out_y1_int,
00962 out_y2_int);
00963
00964
00965
00966
00967 out_y1 = out_y1_int;
00968 out_y2 = out_y2_int;
00969 out_x1 = out_x1_int;
00970 out_x2 = out_x2_int;
00971 int increment = (out_y2 - out_y1) / get_total_packages() + 1;
00972
00973
00974
00975 for(int i = 0; i < get_total_packages(); i++)
00976 {
00977 TitleTranslatePackage *pkg = (TitleTranslatePackage*)get_package(i);
00978 pkg->y1 = i * increment;
00979 pkg->y2 = i * increment + increment;
00980 if(pkg->y1 > out_y2 - out_y1)
00981 pkg->y1 = out_y2 - out_y1;
00982 if(pkg->y2 > out_y2 - out_y1)
00983 pkg->y2 = out_y2 - out_y1;
00984 }
00985
00986 }
00987
00988 LoadClient* TitleTranslate::new_client()
00989 {
00990 return new TitleTranslateUnit(plugin, this);
00991 }
00992
00993 LoadPackage* TitleTranslate::new_package()
00994 {
00995 return new TitleTranslatePackage;
00996 }
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012 ArrayList<FontEntry*>* TitleMain::fonts = 0;
01013
01014
01015
01016 TitleMain::TitleMain(PluginServer *server)
01017 : PluginVClient(server)
01018 {
01019 PLUGIN_CONSTRUCTOR_MACRO
01020
01021
01022 build_fonts();
01023 text_mask = 0;
01024 text_mask_stroke = 0;
01025 glyph_engine = 0;
01026 title_engine = 0;
01027 freetype_library = 0;
01028 freetype_face = 0;
01029 char_positions = 0;
01030 rows_bottom = 0;
01031 translate = 0;
01032 need_reconfigure = 1;
01033 }
01034
01035 TitleMain::~TitleMain()
01036 {
01037 PLUGIN_DESTRUCTOR_MACRO
01038 if(text_mask) delete text_mask;
01039 if(text_mask_stroke) delete text_mask_stroke;
01040 if(char_positions) delete [] char_positions;
01041 if(rows_bottom) delete [] rows_bottom;
01042 clear_glyphs();
01043 if(glyph_engine) delete glyph_engine;
01044 if(title_engine) delete title_engine;
01045 if(freetype_library) FT_Done_FreeType(freetype_library);
01046 if(translate) delete translate;
01047 }
01048
01049 char* TitleMain::plugin_title() { return N_("Title"); }
01050 int TitleMain::is_realtime() { return 1; }
01051 int TitleMain::is_synthesis() { return 1; }
01052
01053 VFrame* TitleMain::new_picon()
01054 {
01055 return new VFrame(picon_png);
01056 }
01057
01058
01059 void TitleMain::build_fonts()
01060 {
01061 if(!fonts)
01062 {
01063 fonts = new ArrayList<FontEntry*>;
01064
01065 char search_path[BCTEXTLEN];
01066 strcpy(search_path, PluginClient::get_path());
01067 char *ptr = strrchr(search_path, '/');
01068 strcpy(ptr + 1, FONT_SEARCHPATH);
01069 char command_line[BCTEXTLEN];
01070
01071 sprintf(command_line,
01072 "find %s -name 'fonts.dir' -print -exec cat {} \\;",
01073 search_path);
01074
01075
01076 FILE *in = popen(command_line, "r");
01077
01078
01079 char current_dir[BCTEXTLEN];
01080 FT_Library freetype_library = 0;
01081 FT_Face freetype_face = 0;
01082
01083
01084 current_dir[0] = 0;
01085
01086 while(!feof(in))
01087 {
01088 char string[BCTEXTLEN], string2[BCTEXTLEN];
01089 fgets(string, BCTEXTLEN, in);
01090 if(!strlen(string)) break;
01091
01092 char *in_ptr = string;
01093 char *out_ptr;
01094
01095
01096
01097 if(string[0] == '/')
01098 {
01099 out_ptr = current_dir;
01100 while(*in_ptr != 0 && *in_ptr != 0xa)
01101 *out_ptr++ = *in_ptr++;
01102 out_ptr--;
01103 while(*out_ptr != '/')
01104 *out_ptr-- = 0;
01105 }
01106 else
01107 {
01108
01109
01110
01111 FontEntry *entry = new FontEntry;
01112 int result = 0;
01113
01114
01115 out_ptr = string2;
01116 while(*in_ptr != 0 && *in_ptr != ' ' && *in_ptr != 0xa)
01117 {
01118 *out_ptr++ = *in_ptr++;
01119 }
01120 *out_ptr = 0;
01121 if(string2[0] == '/')
01122 {
01123 entry->path = new char[strlen(string2) + 1];
01124 sprintf(entry->path, "%s", string2);
01125 }
01126 else
01127 {
01128 entry->path = new char[strlen(current_dir) + strlen(string2) + 1];
01129 sprintf(entry->path, "%s%s", current_dir, string2);
01130 }
01131
01132
01133
01134 struct stat test_stat;
01135 if(stat(entry->path, &test_stat))
01136 {
01137 result = 1;
01138 }
01139
01140
01141
01142 while(*in_ptr != 0 && *in_ptr != 0xa && (*in_ptr == ' ' || *in_ptr == '-'))
01143 in_ptr++;
01144
01145 out_ptr = string2;
01146 while(*in_ptr != 0 && *in_ptr != ' ' && *in_ptr != 0xa && *in_ptr != '-')
01147 {
01148 *out_ptr++ = *in_ptr++;
01149 }
01150 *out_ptr = 0;
01151 entry->foundary = new char[strlen(string2) + 1];
01152 strcpy(entry->foundary, string2);
01153 if(*in_ptr == '-') in_ptr++;
01154
01155
01156
01157 out_ptr = string2;
01158 while(*in_ptr != 0 && *in_ptr != 0xa && *in_ptr != '-')
01159 {
01160 *out_ptr++ = *in_ptr++;
01161 }
01162 *out_ptr = 0;
01163 entry->family = new char[strlen(string2) + 1];
01164 strcpy(entry->family, string2);
01165 if(*in_ptr == '-') in_ptr++;
01166
01167
01168 out_ptr = string2;
01169 while(*in_ptr != 0 && *in_ptr != 0xa && *in_ptr != '-')
01170 {
01171 *out_ptr++ = *in_ptr++;
01172 }
01173 *out_ptr = 0;
01174 entry->weight = new char[strlen(string2) + 1];
01175 strcpy(entry->weight, string2);
01176 if(*in_ptr == '-') in_ptr++;
01177
01178
01179 out_ptr = string2;
01180 while(*in_ptr != 0 && *in_ptr != 0xa && *in_ptr != '-')
01181 {
01182 *out_ptr++ = *in_ptr++;
01183 }
01184 *out_ptr = 0;
01185 entry->slant = new char[strlen(string2) + 1];
01186 strcpy(entry->slant, string2);
01187 if(*in_ptr == '-') in_ptr++;
01188
01189
01190 out_ptr = string2;
01191 while(*in_ptr != 0 && *in_ptr != 0xa && *in_ptr != '-')
01192 {
01193 *out_ptr++ = *in_ptr++;
01194 }
01195 *out_ptr = 0;
01196 entry->swidth = new char[strlen(string2) + 1];
01197 strcpy(entry->swidth, string2);
01198 if(*in_ptr == '-') in_ptr++;
01199
01200
01201 out_ptr = string2;
01202 while(*in_ptr != 0 && *in_ptr != 0xa && *in_ptr != '-')
01203 {
01204 *out_ptr++ = *in_ptr++;
01205 }
01206 *out_ptr = 0;
01207 entry->adstyle = new char[strlen(string2) + 1];
01208 strcpy(entry->adstyle, string2);
01209 if(*in_ptr == '-') in_ptr++;
01210
01211
01212 out_ptr = string2;
01213 while(*in_ptr != 0 && *in_ptr != 0xa && *in_ptr != '-')
01214 {
01215 *out_ptr++ = *in_ptr++;
01216 }
01217 *out_ptr = 0;
01218 entry->pixelsize = atol(string2);
01219 if(*in_ptr == '-') in_ptr++;
01220
01221
01222 out_ptr = string2;
01223 while(*in_ptr != 0 && *in_ptr != 0xa && *in_ptr != '-')
01224 {
01225 *out_ptr++ = *in_ptr++;
01226 }
01227 *out_ptr = 0;
01228 entry->pointsize = atol(string2);
01229 if(*in_ptr == '-') in_ptr++;
01230
01231
01232 out_ptr = string2;
01233 while(*in_ptr != 0 && *in_ptr != 0xa && *in_ptr != '-')
01234 {
01235 *out_ptr++ = *in_ptr++;
01236 }
01237 *out_ptr = 0;
01238 entry->xres = atol(string2);
01239 if(*in_ptr == '-') in_ptr++;
01240
01241
01242 out_ptr = string2;
01243 while(*in_ptr != 0 && *in_ptr != 0xa && *in_ptr != '-')
01244 {
01245 *out_ptr++ = *in_ptr++;
01246 }
01247 *out_ptr = 0;
01248 entry->yres = atol(string2);
01249 if(*in_ptr == '-') in_ptr++;
01250
01251
01252 out_ptr = string2;
01253 while(*in_ptr != 0 && *in_ptr != 0xa && *in_ptr != '-')
01254 {
01255 *out_ptr++ = *in_ptr++;
01256 }
01257 *out_ptr = 0;
01258 entry->spacing = new char[strlen(string2) + 1];
01259 strcpy(entry->spacing, string2);
01260 if(*in_ptr == '-') in_ptr++;
01261
01262
01263 out_ptr = string2;
01264 while(*in_ptr != 0 && *in_ptr != 0xa && *in_ptr != '-')
01265 {
01266 *out_ptr++ = *in_ptr++;
01267 }
01268 *out_ptr = 0;
01269 entry->avg_width = atol(string2);
01270 if(*in_ptr == '-') in_ptr++;
01271
01272
01273 out_ptr = string2;
01274 while(*in_ptr != 0 && *in_ptr != 0xa && *in_ptr != '-')
01275 {
01276 *out_ptr++ = *in_ptr++;
01277 }
01278 *out_ptr = 0;
01279 entry->registry = new char[strlen(string2) + 1];
01280 strcpy(entry->registry, string2);
01281 if(*in_ptr == '-') in_ptr++;
01282
01283
01284 out_ptr = string2;
01285 while(*in_ptr != 0 && *in_ptr != 0xa)
01286 {
01287 *out_ptr++ = *in_ptr++;
01288 }
01289 *out_ptr = 0;
01290 entry->encoding = new char[strlen(string2) + 1];
01291 strcpy(entry->encoding, string2);
01292
01293
01294
01295
01296 if(strlen(entry->foundary) && !result)
01297 {
01298
01299
01300
01301
01302
01303
01304 if(entry->family[0])
01305 {
01306
01307 sprintf(string, "%s (%s)", entry->family, entry->foundary);
01308 entry->fixed_title = new char[strlen(string) + 1];
01309 strcpy(entry->fixed_title, string);
01310
01311 if(!strcasecmp(entry->weight, "demibold") ||
01312 !strcasecmp(entry->weight, "bold"))
01313 entry->fixed_style |= FONT_BOLD;
01314 if(!strcasecmp(entry->slant, "i") ||
01315 !strcasecmp(entry->slant, "o"))
01316 entry->fixed_style |= FONT_ITALIC;
01317 fonts->append(entry);
01318
01319
01320
01321 }
01322 else
01323 {
01324
01325
01326
01327 delete entry;
01328 }
01329 }
01330 else
01331 {
01332 delete entry;
01333 }
01334 }
01335 }
01336 pclose(in);
01337
01338 if(freetype_library) FT_Done_FreeType(freetype_library);
01339 }
01340
01341
01342
01343
01344
01345
01346 }
01347
01348 int TitleMain::load_freetype_face(FT_Library &freetype_library,
01349 FT_Face &freetype_face,
01350 char *path)
01351 {
01352
01353 if(!freetype_library) FT_Init_FreeType(&freetype_library);
01354 if(freetype_face) FT_Done_Face(freetype_face);
01355 freetype_face = 0;
01356
01357
01358
01359 if(FT_New_Face(freetype_library,
01360 path,
01361 0,
01362 &freetype_face))
01363 {
01364 fprintf(stderr, _("TitleMain::load_freetype_face %s failed.\n"));
01365 FT_Done_FreeType(freetype_library);
01366 freetype_face = 0;
01367 freetype_library = 0;
01368 return 1;
01369 } else
01370 {
01371 return 0;
01372 }
01373
01374
01375 }
01376
01377 FontEntry* TitleMain::get_font_entry(char *title,
01378 int style,
01379 int size)
01380 {
01381
01382 FontEntry *result = 0;
01383 int got_title = 0;
01384
01385 for(int i = 0; i < fonts->total; i++)
01386 {
01387 FontEntry *entry = fonts->values[i];
01388
01389 if(!result) result = entry;
01390
01391 if(!strcmp(title, entry->fixed_title))
01392 {
01393 if(!got_title) result = entry;
01394 got_title = 1;
01395
01396
01397 if(entry->fixed_style == style)
01398 result = entry;
01399
01400 if(entry->fixed_style == style && entry->pointsize == size)
01401 result = entry;
01402
01403 }
01404 }
01405
01406 return result;
01407 }
01408
01409
01410 FontEntry* TitleMain::get_font()
01411 {
01412 return get_font_entry(config.font,
01413 config.style,
01414 config.size);
01415 }
01416
01417
01418
01419
01420
01421
01422 int TitleMain::get_char_height()
01423 {
01424
01425 int result = config.size;
01426 if((config.style & FONT_OUTLINE)) result += (int)ceil(config.stroke_width * 2);
01427 return result;
01428 }
01429
01430 int TitleMain::get_char_advance(int current, int next)
01431 {
01432 FT_Vector kerning;
01433 int result = 0;
01434 TitleGlyph *current_glyph = 0;
01435 TitleGlyph *next_glyph = 0;
01436
01437 if(current == 0xa) return 0;
01438
01439 for(int i = 0; i < glyphs.total; i++)
01440 {
01441 if(glyphs.values[i]->c == current)
01442 {
01443 current_glyph = glyphs.values[i];
01444 break;
01445 }
01446 }
01447
01448 for(int i = 0; i < glyphs.total; i++)
01449 {
01450 if(glyphs.values[i]->c == next)
01451 {
01452 next_glyph = glyphs.values[i];
01453 break;
01454 }
01455 }
01456
01457 if(current_glyph)
01458 result = current_glyph->advance_w;
01459
01460
01461 if(next_glyph)
01462 FT_Get_Kerning(freetype_face,
01463 current_glyph->freetype_index,
01464 next_glyph->freetype_index,
01465 ft_kerning_default,
01466 &kerning);
01467 else
01468 kerning.x = 0;
01469
01470
01471 return result + (kerning.x >> 6);
01472 }
01473
01474
01475 void TitleMain::draw_glyphs()
01476 {
01477
01478 int text_len = strlen(config.text);
01479 int total_packages = 0;
01480 iconv_t cd;
01481 cd = iconv_open ("UCS-4", config.encoding);
01482 if (cd == (iconv_t) -1)
01483 {
01484
01485 fprintf (stderr, _("Iconv conversion from %s to Unicode UCS-4 not available\n"),config.encoding);
01486 };
01487
01488 for(int i = 0; i < text_len; i++)
01489 {
01490 FT_ULong char_code;
01491 int c = config.text[i];
01492 int exists = 0;
01493
01494 if (cd != (iconv_t) -1)
01495 {
01496
01497 size_t inbytes,outbytes;
01498 char inbuf;
01499 char *inp = (char*)&inbuf, *outp = (char *)&char_code;
01500
01501 inbuf = (char)c;
01502 inbytes = 1;
01503 outbytes = 4;
01504
01505 iconv (cd, &inp, &inbytes, &outp, &outbytes);
01506 #if __BYTE_ORDER == __LITTLE_ENDIAN
01507 char_code = bswap_32(char_code);
01508 #endif
01509
01510 } else {
01511 char_code = c;
01512 }
01513
01514 for(int j = 0; j < glyphs.total; j++)
01515 {
01516 if(glyphs.values[j]->char_code == char_code)
01517 {
01518 exists = 1;
01519 break;
01520 }
01521 }
01522
01523 if(!exists)
01524 {
01525 total_packages++;
01526
01527 TitleGlyph *glyph = new TitleGlyph;
01528
01529 glyphs.append(glyph);
01530 glyph->c = c;
01531 glyph->char_code = char_code;
01532 }
01533 }
01534 iconv_close(cd);
01535
01536 if(!glyph_engine)
01537 glyph_engine = new GlyphEngine(this, PluginClient::smp + 1);
01538
01539 glyph_engine->set_package_count(total_packages);
01540
01541 glyph_engine->process_packages();
01542
01543 }
01544
01545 void TitleMain::get_total_extents()
01546 {
01547
01548 int current_w = 0;
01549 int row_start = 0;
01550 text_len = strlen(config.text);
01551 if(!char_positions) char_positions = new title_char_position_t[text_len];
01552 text_rows = 0;
01553 text_w = 0;
01554 ascent = 0;
01555
01556 for(int i = 0; i < glyphs.total; i++)
01557 if(glyphs.values[i]->top > ascent) ascent = glyphs.values[i]->top;
01558
01559
01560
01561 for(int i = 0; i < text_len; i++)
01562 {
01563 if(config.text[i] == 0xa || i == text_len - 1)
01564 {
01565 text_rows++;
01566 }
01567 }
01568 if (!rows_bottom) rows_bottom = new int[text_rows+1];
01569 text_rows = 0;
01570 rows_bottom[0] = 0;
01571
01572 for(int i = 0; i < text_len; i++)
01573 {
01574 char_positions[i].x = current_w;
01575 char_positions[i].y = text_rows * get_char_height();
01576 char_positions[i].w = get_char_advance(config.text[i], config.text[i + 1]);
01577 TitleGlyph *current_glyph = 0;
01578 for(int j = 0; j < glyphs.total; j++)
01579 {
01580 if(glyphs.values[j]->c == config.text[i])
01581 {
01582 current_glyph = glyphs.values[j];
01583 break;
01584 }
01585 }
01586 int current_bottom = current_glyph->top - current_glyph->height;
01587 if (current_bottom < rows_bottom[text_rows])
01588 rows_bottom[text_rows] = current_bottom ;
01589
01590
01591
01592
01593
01594
01595 current_w += char_positions[i].w;
01596
01597 if(config.text[i] == 0xa || i == text_len - 1)
01598 {
01599 text_rows++;
01600 rows_bottom[text_rows] = 0;
01601 if(current_w > text_w) text_w = current_w;
01602 current_w = 0;
01603 }
01604 }
01605 text_w += config.dropshadow;
01606 text_h = text_rows * get_char_height();
01607 text_h += config.dropshadow;
01608
01609
01610
01611 row_start = 0;
01612 for(int i = 0; i < text_len; i++)
01613 {
01614 if(config.text[i] == 0xa || i == text_len - 1)
01615 {
01616 for(int j = row_start; j <= i; j++)
01617 {
01618 switch(config.hjustification)
01619 {
01620 case JUSTIFY_LEFT:
01621 break;
01622
01623 case JUSTIFY_MID:
01624 char_positions[j].x += (text_w -
01625 char_positions[i].x -
01626 char_positions[i].w) /
01627 2;
01628 break;
01629
01630 case JUSTIFY_RIGHT:
01631 char_positions[j].x += (text_w -
01632 char_positions[i].x -
01633 char_positions[i].w);
01634 break;
01635 }
01636 }
01637 row_start = i + 1;
01638 }
01639 }
01640
01641
01642
01643 }
01644
01645 int TitleMain::draw_mask()
01646 {
01647 int old_visible_row1 = visible_row1;
01648 int old_visible_row2 = visible_row2;
01649
01650
01651
01652 if(config.motion_strategy == BOTTOM_TO_TOP)
01653 {
01654
01655
01656
01657
01658
01659 float magnitude = config.pixels_per_second *
01660 (get_source_position() - config.prev_keyframe_position) /
01661 PluginVClient::project_frame_rate;
01662 if(config.loop)
01663 {
01664 int loop_size = text_h + input->get_h();
01665 magnitude -= (int)(magnitude / loop_size) * loop_size;
01666 }
01667 text_y1 = config.y + input->get_h() - magnitude;
01668 }
01669 else
01670 if(config.motion_strategy == TOP_TO_BOTTOM)
01671 {
01672 float magnitude = config.pixels_per_second *
01673 (get_source_position() - config.prev_keyframe_position) /
01674 PluginVClient::project_frame_rate;
01675 if(config.loop)
01676 {
01677 int loop_size = text_h + input->get_h();
01678 magnitude -= (int)(magnitude / loop_size) * loop_size;
01679 }
01680 text_y1 = config.y + magnitude;
01681 text_y1 -= text_h;
01682 }
01683 else
01684 if(config.vjustification == JUSTIFY_TOP)
01685 {
01686 text_y1 = config.y;
01687 }
01688 else
01689 if(config.vjustification == JUSTIFY_MID)
01690 {
01691 text_y1 = config.y + input->get_h() / 2 - text_h / 2;
01692 }
01693 else
01694 if(config.vjustification == JUSTIFY_BOTTOM)
01695 {
01696 text_y1 = config.y + input->get_h() - text_h;
01697 }
01698
01699 text_y2 = text_y1 + text_h + 0.5;
01700
01701
01702 if(config.motion_strategy == RIGHT_TO_LEFT)
01703 {
01704 float magnitude = config.pixels_per_second *
01705 (get_source_position() - config.prev_keyframe_position) /
01706 PluginVClient::project_frame_rate;
01707 if(config.loop)
01708 {
01709 int loop_size = text_w + input->get_w();
01710 magnitude -= (int)(magnitude / loop_size) * loop_size;
01711 }
01712 text_x1 = config.x + (float)input->get_w() - magnitude;
01713 }
01714 else
01715 if(config.motion_strategy == LEFT_TO_RIGHT)
01716 {
01717 float magnitude = config.pixels_per_second *
01718 (get_source_position() - config.prev_keyframe_position) /
01719 PluginVClient::project_frame_rate;
01720 if(config.loop)
01721 {
01722 int loop_size = text_w + input->get_w();
01723 magnitude -= (int)(magnitude / loop_size) * loop_size;
01724 }
01725 text_x1 = config.x + -(float)text_w + magnitude;
01726 }
01727 else
01728 if(config.hjustification == JUSTIFY_LEFT)
01729 {
01730 text_x1 = config.x;
01731 }
01732 else
01733 if(config.hjustification == JUSTIFY_MID)
01734 {
01735 text_x1 = config.x + input->get_w() / 2 - text_w / 2;
01736 }
01737 else
01738 if(config.hjustification == JUSTIFY_RIGHT)
01739 {
01740 text_x1 = config.x + input->get_w() - text_w;
01741 }
01742
01743
01744
01745
01746
01747
01748 visible_row1 = (int)(-text_y1 / get_char_height());
01749 if(visible_row1 < 0) visible_row1 = 0;
01750
01751 visible_row2 = (int)((float)text_rows - (text_y2 - input->get_h()) / get_char_height() + 1);
01752 if(visible_row2 > text_rows) visible_row2 = text_rows;
01753
01754
01755 if(visible_row2 <= visible_row1) return 1;
01756
01757
01758 mask_y1 = text_y1 + visible_row1 * get_char_height();
01759 mask_y2 = text_y1 + visible_row2 * get_char_height();
01760 text_x1 += config.x;
01761
01762
01763
01764 visible_char1 = visible_char2 = 0;
01765 int got_char1 = 0;
01766 for(int i = 0; i < text_len; i++)
01767 {
01768 title_char_position_t *char_position = char_positions + i;
01769 int char_row = char_position->y / get_char_height();
01770 if(char_row >= visible_row1 &&
01771 char_row < visible_row2)
01772
01773 {
01774 if(!got_char1)
01775 {
01776 visible_char1 = i;
01777 got_char1 = 1;
01778 }
01779 visible_char2 = i;
01780 }
01781 }
01782 visible_char2++;
01783
01784
01785
01786 int visible_rows = visible_row2 - visible_row1;
01787 int need_redraw = 0;
01788 if(text_mask &&
01789 (text_mask->get_w() != text_w ||
01790 text_mask->get_h() != visible_rows * get_char_height() - rows_bottom[visible_row2 - 1]))
01791 {
01792 delete text_mask;
01793 delete text_mask_stroke;
01794 text_mask = 0;
01795 text_mask_stroke = 0;
01796 }
01797
01798 if(!text_mask)
01799 {
01800 text_mask = new VFrame(0,
01801 text_w,
01802 visible_rows * get_char_height() - rows_bottom[visible_row2-1],
01803 BC_A8);
01804 text_mask_stroke = new VFrame(0,
01805 text_w,
01806 visible_rows * get_char_height() - rows_bottom[visible_row2-1],
01807 BC_A8);
01808
01809 need_redraw = 1;
01810 }
01811
01812
01813
01814
01815
01816
01817 if(old_visible_row1 != visible_row1 ||
01818 old_visible_row2 != visible_row2 ||
01819 need_redraw)
01820 {
01821
01822 text_mask->clear_frame();
01823 text_mask_stroke->clear_frame();
01824
01825
01826
01827 if(!title_engine)
01828 title_engine = new TitleEngine(this, PluginClient::smp + 1);
01829
01830
01831 title_engine->set_package_count(visible_char2 - visible_char1);
01832
01833 title_engine->process_packages();
01834
01835 }
01836
01837 return 0;
01838 }
01839
01840
01841 void TitleMain::overlay_mask()
01842 {
01843
01844
01845 alpha = 0x100;
01846 if(!EQUIV(config.fade_in, 0))
01847 {
01848 int fade_len = lroundf(config.fade_in * PluginVClient::project_frame_rate);
01849 int fade_position = get_source_position() - config.prev_keyframe_position;
01850
01851
01852 if(fade_position >= 0 && fade_position < fade_len)
01853 {
01854 alpha = lroundf(256.0f * fade_position / fade_len);
01855 }
01856 }
01857
01858
01859 if(!EQUIV(config.fade_out, 0))
01860 {
01861 int fade_len = lroundf(config.fade_out * PluginVClient::project_frame_rate);
01862 int fade_position = config.next_keyframe_position - get_source_position();
01863
01864
01865 if(fade_position >= 0 && fade_position < fade_len)
01866 {
01867 alpha = lroundf(256.0f * fade_position / fade_len);
01868 }
01869 }
01870
01871
01872 if(config.dropshadow)
01873 {
01874 text_x1 += config.dropshadow;
01875 text_x2 += config.dropshadow;
01876 mask_y1 += config.dropshadow;
01877 mask_y2 += config.dropshadow;
01878 if(text_x1 < input->get_w() && text_x1 + text_w > 0 &&
01879 mask_y1 < input->get_h() && mask_y2 > 0)
01880 {
01881 if(!translate) translate = new TitleTranslate(this, PluginClient::smp + 1);
01882
01883 int temp_color = config.color;
01884 config.color = 0x0;
01885 translate->process_packages();
01886 config.color = temp_color;
01887 }
01888 text_x1 -= config.dropshadow;
01889 text_x2 -= config.dropshadow;
01890 mask_y1 -= config.dropshadow;
01891 mask_y2 -= config.dropshadow;
01892 }
01893
01894
01895 if(text_x1 < input->get_w() && text_x1 + text_w > 0 &&
01896 mask_y1 < input->get_h() && mask_y2 > 0)
01897 {
01898 if(!translate) translate = new TitleTranslate(this, PluginClient::smp + 1);
01899 translate->process_packages();
01900 if (config.stroke_width >= ZERO &&
01901 (config.style & FONT_OUTLINE))
01902 {
01903 int temp_color = config.color;
01904 VFrame *tmp_text_mask = this->text_mask;
01905 config.color = config.color_stroke;
01906 this->text_mask = this->text_mask_stroke;
01907
01908 translate->process_packages();
01909 config.color = temp_color;
01910 this->text_mask = tmp_text_mask;
01911 }
01912 }
01913
01914 }
01915
01916 void TitleMain::clear_glyphs()
01917 {
01918
01919 glyphs.remove_all_objects();
01920 }
01921
01922 char* TitleMain::motion_to_text(int motion)
01923 {
01924 switch(motion)
01925 {
01926 case NO_MOTION: return _("No motion"); break;
01927 case BOTTOM_TO_TOP: return _("Bottom to top"); break;
01928 case TOP_TO_BOTTOM: return _("Top to bottom"); break;
01929 case RIGHT_TO_LEFT: return _("Right to left"); break;
01930 case LEFT_TO_RIGHT: return _("Left to right"); break;
01931 }
01932 }
01933
01934 int TitleMain::text_to_motion(char *text)
01935 {
01936 for(int i = 0; i < TOTAL_PATHS; i++)
01937 {
01938 if(!strcasecmp(motion_to_text(i), text)) return i;
01939 }
01940 return 0;
01941 }
01942
01943
01944
01945
01946
01947
01948
01949 int TitleMain::process_realtime(VFrame *input_ptr, VFrame *output_ptr)
01950 {
01951 int result = 0;
01952 input = input_ptr;
01953 output = output_ptr;
01954
01955 need_reconfigure |= load_configuration();
01956
01957
01958
01959
01960 if(config.timecode)
01961 {
01962 int64_t rendered_frame = get_source_position();
01963 if (get_direction() == PLAY_REVERSE)
01964 rendered_frame -= 1;
01965
01966 int tcf = Units::timeformat_totype(config.timecodeformat);
01967 if (tcf < 0) {
01968 tcf = TIME_HMSF;
01969 strcpy(config.timecodeformat, DEFAULT_TIMECODEFORMAT);
01970 }
01971 Units::totext(config.text,
01972 (double)rendered_frame / PluginVClient::project_frame_rate,
01973 tcf,
01974 0,
01975 PluginVClient::project_frame_rate,
01976 0);
01977 need_reconfigure = 1;
01978 }
01979
01980
01981 if(config.size <= 0 || config.size >= 2048) config.size = 72;
01982 if(config.stroke_width < 0 ||
01983 config.stroke_width >= 512) config.stroke_width = 0.0;
01984 if(!strlen(config.text)) return 0;
01985 if(!strlen(config.encoding)) strcpy(config.encoding, DEFAULT_ENCODING);
01986
01987
01988
01989
01990 if(need_reconfigure)
01991 {
01992
01993 if(text_mask) delete text_mask;
01994 if(text_mask_stroke) delete text_mask_stroke;
01995 text_mask = 0;
01996 text_mask_stroke = 0;
01997
01998 if(freetype_face) FT_Done_Face(freetype_face);
01999 freetype_face = 0;
02000
02001 if(glyph_engine) delete glyph_engine;
02002 glyph_engine = 0;
02003
02004 if(char_positions) delete [] char_positions;
02005 char_positions = 0;
02006 if(rows_bottom) delete [] rows_bottom;
02007 rows_bottom = 0;
02008
02009 clear_glyphs();
02010
02011 visible_row1 = 0;
02012 visible_row2 = 0;
02013 ascent = 0;
02014
02015 if(!freetype_library)
02016 FT_Init_FreeType(&freetype_library);
02017
02018
02019 if(!freetype_face)
02020 {
02021 FontEntry *font = get_font();
02022
02023 if(load_freetype_face(freetype_library,
02024 freetype_face,
02025 font->path))
02026 {
02027 printf("TitleMain::process_realtime %s: FT_New_Face failed.\n",
02028 font->fixed_title);
02029 result = 1;
02030 }
02031
02032
02033 if(!result) FT_Set_Pixel_Sizes(freetype_face, config.size, 0);
02034
02035 }
02036
02037
02038
02039 if(!result)
02040 {
02041 draw_glyphs();
02042
02043 get_total_extents();
02044
02045 need_reconfigure = 0;
02046 }
02047 }
02048
02049 if(!result)
02050 {
02051
02052
02053 result = draw_mask();
02054 }
02055
02056
02057
02058
02059 if(!result)
02060 {
02061 overlay_mask();
02062 }
02063
02064
02065 return 0;
02066 }
02067
02068 int TitleMain::show_gui()
02069 {
02070 load_configuration();
02071 thread = new TitleThread(this);
02072 thread->start();
02073 return 0;
02074 }
02075
02076 int TitleMain::set_string()
02077 {
02078 if(thread) thread->window->set_title(gui_string);
02079 return 0;
02080 }
02081
02082 void TitleMain::raise_window()
02083 {
02084 if(thread)
02085 {
02086 thread->window->raise_window();
02087 thread->window->flush();
02088 }
02089 }
02090
02091 void TitleMain::update_gui()
02092 {
02093 if(thread)
02094 {
02095 int reconfigure = load_configuration();
02096 if(reconfigure)
02097 {
02098 thread->window->lock_window();
02099 thread->window->update();
02100 thread->window->unlock_window();
02101 thread->window->color_thread->update_gui(config.color, 0);
02102 }
02103 }
02104 }
02105
02106
02107 int TitleMain::load_defaults()
02108 {
02109 char directory[1024], text_path[1024];
02110
02111 sprintf(directory, "%stitle.rc", BCASTDIR);
02112
02113
02114 defaults = new BC_Hash(directory);
02115 defaults->load();
02116
02117 defaults->get("FONT", config.font);
02118 defaults->get("ENCODING", config.encoding);
02119 config.style = defaults->get("STYLE", (int64_t)config.style);
02120 config.size = defaults->get("SIZE", config.size);
02121 config.color = defaults->get("COLOR", config.color);
02122 config.color_stroke = defaults->get("COLOR_STROKE", config.color_stroke);
02123 config.stroke_width = defaults->get("STROKE_WIDTH", config.stroke_width);
02124 config.motion_strategy = defaults->get("MOTION_STRATEGY", config.motion_strategy);
02125 config.loop = defaults->get("LOOP", config.loop);
02126 config.pixels_per_second = defaults->get("PIXELS_PER_SECOND", config.pixels_per_second);
02127 config.hjustification = defaults->get("HJUSTIFICATION", config.hjustification);
02128 config.vjustification = defaults->get("VJUSTIFICATION", config.vjustification);
02129 config.fade_in = defaults->get("FADE_IN", config.fade_in);
02130 config.fade_out = defaults->get("FADE_OUT", config.fade_out);
02131 config.x = defaults->get("TITLE_X", config.x);
02132 config.y = defaults->get("TITLE_Y", config.y);
02133 config.dropshadow = defaults->get("DROPSHADOW", config.dropshadow);
02134 config.timecode = defaults->get("TIMECODE", config.timecode);
02135 defaults->get("TIMECODEFORMAT", config.timecodeformat);
02136 window_w = defaults->get("WINDOW_W", 660);
02137 window_h = defaults->get("WINDOW_H", 480);
02138
02139
02140 FileSystem fs;
02141 sprintf(text_path, "%stitle_text.rc", BCASTDIR);
02142 fs.complete_path(text_path);
02143 FILE *fd = fopen(text_path, "rb");
02144 if(fd)
02145 {
02146 fseek(fd, 0, SEEK_END);
02147 int64_t len = ftell(fd);
02148 fseek(fd, 0, SEEK_SET);
02149 fread(config.text, len, 1, fd);
02150 config.text[len] = 0;
02151
02152 fclose(fd);
02153 }
02154 else
02155 config.text[0] = 0;
02156 return 0;
02157 }
02158
02159 int TitleMain::save_defaults()
02160 {
02161 char text_path[1024];
02162
02163 defaults->update("FONT", config.font);
02164 defaults->update("ENCODING", config.encoding);
02165 defaults->update("STYLE", (int64_t)config.style);
02166 defaults->update("SIZE", config.size);
02167 defaults->update("COLOR", config.color);
02168 defaults->update("COLOR_STROKE", config.color_stroke);
02169 defaults->update("STROKE_WIDTH", config.stroke_width);
02170 defaults->update("MOTION_STRATEGY", config.motion_strategy);
02171 defaults->update("LOOP", config.loop);
02172 defaults->update("PIXELS_PER_SECOND", config.pixels_per_second);
02173 defaults->update("HJUSTIFICATION", config.hjustification);
02174 defaults->update("VJUSTIFICATION", config.vjustification);
02175 defaults->update("FADE_IN", config.fade_in);
02176 defaults->update("FADE_OUT", config.fade_out);
02177 defaults->update("TITLE_X", config.x);
02178 defaults->update("TITLE_Y", config.y);
02179 defaults->update("DROPSHADOW", config.dropshadow);
02180 defaults->update("TIMECODE", config.timecode);
02181 defaults->update("TIMECODEFORMAT", config.timecodeformat);
02182 defaults->update("WINDOW_W", window_w);
02183 defaults->update("WINDOW_H", window_h);
02184 defaults->save();
02185
02186
02187 FileSystem fs;
02188 sprintf(text_path, "%stitle_text.rc", BCASTDIR);
02189 fs.complete_path(text_path);
02190 FILE *fd = fopen(text_path, "wb");
02191 if(fd)
02192 {
02193 fwrite(config.text, strlen(config.text), 1, fd);
02194 fclose(fd);
02195 }
02196
02197
02198 return 0;
02199 }
02200
02201
02202
02203
02204 int TitleMain::load_configuration()
02205 {
02206 KeyFrame *prev_keyframe, *next_keyframe;
02207 prev_keyframe = get_prev_keyframe(get_source_position());
02208 next_keyframe = get_next_keyframe(get_source_position());
02209
02210
02211
02212
02213
02214 TitleConfig old_config, prev_config, next_config;
02215 old_config.copy_from(config);
02216 read_data(prev_keyframe);
02217 prev_config.copy_from(config);
02218 read_data(next_keyframe);
02219 next_config.copy_from(config);
02220
02221 config.prev_keyframe_position = prev_keyframe->position;
02222 config.next_keyframe_position = next_keyframe->position;
02223
02224
02225 if(config.next_keyframe_position == config.prev_keyframe_position)
02226 config.next_keyframe_position = get_source_start() + get_total_len();
02227 if (config.prev_keyframe_position == 0)
02228 config.prev_keyframe_position = get_source_start();
02229
02230
02231
02232
02233
02234
02235 config.interpolate(prev_config,
02236 next_config,
02237 (next_keyframe->position == prev_keyframe->position) ?
02238 get_source_position() :
02239 prev_keyframe->position,
02240 (next_keyframe->position == prev_keyframe->position) ?
02241 get_source_position() + 1 :
02242 next_keyframe->position,
02243 get_source_position());
02244
02245 if(!config.equivalent(old_config))
02246 return 1;
02247 else
02248 return 0;
02249 }
02250
02251
02252
02253
02254
02255
02256
02257
02258
02259
02260
02261
02262 void TitleMain::save_data(KeyFrame *keyframe)
02263 {
02264 FileXML output;
02265
02266
02267 output.set_shared_string(keyframe->data, MESSAGESIZE);
02268 output.tag.set_title("TITLE");
02269 output.tag.set_property("FONT", config.font);
02270 output.tag.set_property("ENCODING", config.encoding);
02271 output.tag.set_property("STYLE", (int64_t)config.style);
02272 output.tag.set_property("SIZE", config.size);
02273 output.tag.set_property("COLOR", config.color);
02274 output.tag.set_property("COLOR_STROKE", config.color_stroke);
02275 output.tag.set_property("STROKE_WIDTH", config.stroke_width);
02276 output.tag.set_property("MOTION_STRATEGY", config.motion_strategy);
02277 output.tag.set_property("LOOP", config.loop);
02278 output.tag.set_property("PIXELS_PER_SECOND", config.pixels_per_second);
02279 output.tag.set_property("HJUSTIFICATION", config.hjustification);
02280 output.tag.set_property("VJUSTIFICATION", config.vjustification);
02281 output.tag.set_property("FADE_IN", config.fade_in);
02282 output.tag.set_property("FADE_OUT", config.fade_out);
02283 output.tag.set_property("TITLE_X", config.x);
02284 output.tag.set_property("TITLE_Y", config.y);
02285 output.tag.set_property("DROPSHADOW", config.dropshadow);
02286 output.tag.set_property("TIMECODE", config.timecode);
02287 output.tag.set_property("TIMECODEFORMAT", config.timecodeformat);
02288 output.append_tag();
02289 output.append_newline();
02290
02291 output.encode_text(config.text);
02292
02293 output.tag.set_title("/TITLE");
02294 output.append_tag();
02295 output.append_newline();
02296 output.terminate_string();
02297
02298
02299 }
02300
02301 void TitleMain::read_data(KeyFrame *keyframe)
02302 {
02303 FileXML input;
02304
02305 input.set_shared_string(keyframe->data, strlen(keyframe->data));
02306
02307 int result = 0;
02308 int new_interlace = 0;
02309 int new_horizontal = 0;
02310 int new_luminance = 0;
02311
02312 config.prev_keyframe_position = keyframe->position;
02313 while(!result)
02314 {
02315 result = input.read_tag();
02316
02317 if(!result)
02318 {
02319 if(input.tag.title_is("TITLE"))
02320 {
02321 input.tag.get_property("FONT", config.font);
02322 input.tag.get_property("ENCODING", config.encoding);
02323 config.style = input.tag.get_property("STYLE", (int64_t)config.style);
02324 config.size = input.tag.get_property("SIZE", config.size);
02325 config.color = input.tag.get_property("COLOR", config.color);
02326 config.color_stroke = input.tag.get_property("COLOR_STROKE", config.color_stroke);
02327 config.stroke_width = input.tag.get_property("STROKE_WIDTH", config.stroke_width);
02328 config.motion_strategy = input.tag.get_property("MOTION_STRATEGY", config.motion_strategy);
02329 config.loop = input.tag.get_property("LOOP", config.loop);
02330 config.pixels_per_second = input.tag.get_property("PIXELS_PER_SECOND", config.pixels_per_second);
02331 config.hjustification = input.tag.get_property("HJUSTIFICATION", config.hjustification);
02332 config.vjustification = input.tag.get_property("VJUSTIFICATION", config.vjustification);
02333 config.fade_in = input.tag.get_property("FADE_IN", config.fade_in);
02334 config.fade_out = input.tag.get_property("FADE_OUT", config.fade_out);
02335 config.x = input.tag.get_property("TITLE_X", config.x);
02336 config.y = input.tag.get_property("TITLE_Y", config.y);
02337 config.dropshadow = input.tag.get_property("DROPSHADOW", config.dropshadow);
02338 config.timecode = input.tag.get_property("TIMECODE", config.timecode);
02339 input.tag.get_property("TIMECODEFORMAT", config.timecodeformat);
02340 strcpy(config.text, input.read_text());
02341
02342
02343 }
02344 else
02345 if(input.tag.title_is("/TITLE"))
02346 {
02347 result = 1;
02348 }
02349 }
02350 }
02351 }
02352
02353
02354
02355
02356
02357