00001 #ifndef TITLE_H
00002 #define TITLE_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 class TitleMain;
00028 class TitleEngine;
00029 class GlyphEngine;
00030 class TitleTranslate;
00031
00032 #include "bchash.h"
00033 #include "loadbalance.h"
00034 #include "mutex.h"
00035 #include "overlayframe.h"
00036 #include "pluginvclient.h"
00037 #include "titlewindow.h"
00038
00039 #include <ft2build.h>
00040 #include FT_FREETYPE_H
00041 #include <sys/types.h>
00042
00043
00044 #define FONT_ITALIC 0x1
00045 #define FONT_BOLD 0x2
00046 #define FONT_OUTLINE 0x4
00047
00048
00049 #define TOTAL_PATHS 5
00050 #define NO_MOTION 0x0
00051 #define BOTTOM_TO_TOP 0x1
00052 #define TOP_TO_BOTTOM 0x2
00053 #define RIGHT_TO_LEFT 0x3
00054 #define LEFT_TO_RIGHT 0x4
00055
00056
00057 #define JUSTIFY_LEFT 0x0
00058 #define JUSTIFY_CENTER 0x1
00059 #define JUSTIFY_RIGHT 0x2
00060
00061
00062 #define JUSTIFY_TOP 0x0
00063 #define JUSTIFY_MID 0x1
00064 #define JUSTIFY_BOTTOM 0x2
00065
00066
00067 class TitleConfig
00068 {
00069 public:
00070 TitleConfig();
00071
00072
00073 int equivalent(TitleConfig &that);
00074 void copy_from(TitleConfig &that);
00075 void interpolate(TitleConfig &prev,
00076 TitleConfig &next,
00077 int64_t prev_frame,
00078 int64_t next_frame,
00079 int64_t current_frame);
00080
00081
00082
00083 char font[BCTEXTLEN];
00084 int64_t style;
00085 int size;
00086 int color;
00087 int color_stroke;
00088
00089 int motion_strategy;
00090
00091 int loop;
00092
00093 float pixels_per_second;
00094 int hjustification;
00095 int vjustification;
00096
00097 double fade_in, fade_out;
00098
00099 float x, y;
00100
00101 int dropshadow;
00102
00103 int64_t prev_keyframe_position;
00104 int64_t next_keyframe_position;
00105
00106 int timecode;
00107
00108
00109 char text[BCTEXTLEN];
00110
00111 char encoding[BCTEXTLEN];
00112
00113 char timecodeformat[BCTEXTLEN];
00114
00115 double stroke_width;
00116 };
00117
00118 class FontEntry
00119 {
00120 public:
00121 FontEntry();
00122 ~FontEntry();
00123
00124 void dump();
00125
00126 char *path;
00127 char *foundary;
00128 char *family;
00129 char *weight;
00130 char *slant;
00131 char *swidth;
00132 char *adstyle;
00133 int pixelsize;
00134 int pointsize;
00135 int xres;
00136 int yres;
00137 char *spacing;
00138 int avg_width;
00139 char *registry;
00140 char *encoding;
00141 char *fixed_title;
00142 int fixed_style;
00143 };
00144
00145 class TitleGlyph
00146 {
00147 public:
00148 TitleGlyph();
00149 ~TitleGlyph();
00150
00151 int c;
00152
00153 FT_ULong char_code;
00154 int width, height, pitch, advance_w, left, top, freetype_index;
00155 VFrame *data;
00156 VFrame *data_stroke;
00157 };
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 class GlyphPackage : public LoadPackage
00168 {
00169 public:
00170 GlyphPackage();
00171 TitleGlyph *glyph;
00172 };
00173
00174
00175 class GlyphUnit : public LoadClient
00176 {
00177 public:
00178 GlyphUnit(TitleMain *plugin, GlyphEngine *server);
00179 ~GlyphUnit();
00180 void process_package(LoadPackage *package);
00181
00182 TitleMain *plugin;
00183 FontEntry *current_font;
00184 FT_Library freetype_library;
00185 FT_Face freetype_face;
00186 };
00187
00188 class GlyphEngine : public LoadServer
00189 {
00190 public:
00191 GlyphEngine(TitleMain *plugin, int cpus);
00192 void init_packages();
00193 LoadClient* new_client();
00194 LoadPackage* new_package();
00195 TitleMain *plugin;
00196 };
00197
00198
00199
00200
00201
00202
00203
00204
00205 class TitlePackage : public LoadPackage
00206 {
00207 public:
00208 TitlePackage();
00209 int x, y, c;
00210 };
00211
00212
00213 class TitleUnit : public LoadClient
00214 {
00215 public:
00216 TitleUnit(TitleMain *plugin, TitleEngine *server);
00217 void process_package(LoadPackage *package);
00218 void draw_glyph(VFrame *output, TitleGlyph *glyph, int x, int y);
00219 TitleMain *plugin;
00220 };
00221
00222 class TitleEngine : public LoadServer
00223 {
00224 public:
00225 TitleEngine(TitleMain *plugin, int cpus);
00226 void init_packages();
00227 LoadClient* new_client();
00228 LoadPackage* new_package();
00229 TitleMain *plugin;
00230 };
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244 class TitleTranslatePackage : public LoadPackage
00245 {
00246 public:
00247 TitleTranslatePackage();
00248 int y1, y2;
00249 };
00250
00251
00252 class TitleTranslateUnit : public LoadClient
00253 {
00254 public:
00255 TitleTranslateUnit(TitleMain *plugin, TitleTranslate *server);
00256 void process_package(LoadPackage *package);
00257 TitleMain *plugin;
00258 };
00259
00260 class TitleTranslate : public LoadServer
00261 {
00262 public:
00263 TitleTranslate(TitleMain *plugin, int cpus);
00264 ~TitleTranslate();
00265 void init_packages();
00266 LoadClient* new_client();
00267 LoadPackage* new_package();
00268 TitleMain *plugin;
00269 transfer_table_f *y_table;
00270 transfer_table_f *x_table;
00271 int output_w;
00272 int output_h;
00273
00274 int out_x1_int;
00275 int out_x2_int;
00276 int out_y1_int;
00277 int out_y2_int;
00278
00279 int out_x1;
00280 int out_x2;
00281 int out_y1;
00282 int out_y2;
00283 };
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299 typedef struct
00300 {
00301 int x, y, w;
00302 } title_char_position_t;
00303
00304
00305
00306 class TitleMain : public PluginVClient
00307 {
00308 public:
00309 TitleMain(PluginServer *server);
00310 ~TitleMain();
00311
00312
00313 int process_realtime(VFrame *input_ptr, VFrame *output_ptr);
00314 int is_realtime();
00315 int is_synthesis();
00316 char* plugin_title();
00317 int show_gui();
00318 void raise_window();
00319 void update_gui();
00320 int set_string();
00321 int load_configuration();
00322 void save_data(KeyFrame *keyframe);
00323 void read_data(KeyFrame *keyframe);
00324 int load_defaults();
00325 int save_defaults();
00326 VFrame* new_picon();
00327
00328
00329
00330 void build_fonts();
00331 void draw_glyphs();
00332 int draw_mask();
00333 void overlay_mask();
00334 FontEntry* get_font_entry(char *title,
00335 int style,
00336 int size);
00337 FontEntry* get_font();
00338 int get_char_advance(int current, int next);
00339 int get_char_height();
00340 void get_total_extents();
00341 void clear_glyphs();
00342 int load_freetype_face(FT_Library &freetype_library,
00343 FT_Face &freetype_face,
00344 char *path);
00345
00346
00347
00348
00349
00350 static char* motion_to_text(int motion);
00351 static int text_to_motion(char *text);
00352
00353 TitleThread *thread;
00354
00355 TitleConfig config;
00356
00357 int window_w, window_h;
00358
00359 static ArrayList<FontEntry*> *fonts;
00360
00361 BC_Hash *defaults;
00362 ArrayList<TitleGlyph*> glyphs;
00363 Mutex glyph_lock;
00364
00365
00366 VFrame *text_mask;
00367 VFrame *text_mask_stroke;
00368 GlyphEngine *glyph_engine;
00369 TitleEngine *title_engine;
00370 TitleTranslate *translate;
00371
00372
00373 FT_Library freetype_library;
00374 FT_Face freetype_face;
00375
00376
00377
00378
00379 int visible_row1;
00380 int visible_row2;
00381 int visible_char1;
00382 int visible_char2;
00383
00384 float text_y1;
00385 float text_y2;
00386 float text_x1;
00387 float text_x2;
00388
00389 float mask_y1;
00390 float mask_y2;
00391
00392
00393 int alpha;
00394
00395
00396 int ascent;
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407 int text_len;
00408 int text_rows;
00409 int text_w;
00410 int text_h;
00411
00412 title_char_position_t *char_positions;
00413
00414 int *rows_bottom;
00415 VFrame *input, *output;
00416
00417 int need_reconfigure;
00418 };
00419
00420
00421 #endif