Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

overlayframe.h

Go to the documentation of this file.
00001 #ifndef OVERLAYFRAME_H
00002 #define OVERLAYFRAME_H
00003 
00004 #include "loadbalance.h"
00005 #include "overlayframe.inc"
00006 #include "vframe.inc"
00007 
00008 
00009 // Issues encoutered with overlay
00010 
00011 // Floating point vs. int.  On both alpha and Intel 
00012 // the floating point interpolation is over
00013 // 2x faster than integer interpolation.  Pipelined CPUs probably don't benefit
00014 // at all in long sequences of integer calculations.  Integer interpolation uses 32 
00015 // siginificant bits while floating point uses 24, however.
00016 
00017 // Single step vs. two step process.
00018 
00019 // A single step process would require performing blend with the output
00020 // of BILINEAR or BICUBIC and trimming the output to fractional pixels.
00021 // This is easy.  
00022 
00023 // However reading the input for
00024 // BILINEAR and BICUBIC would require trimming the input to fractional
00025 // pixels often repeatedly since the interpolation reads the same pixels more
00026 // than once.  This is hard.
00027 
00028 // In the two step process one step worries purely about scaling, ignoring 
00029 // trimming at the input and output so redundant trimming is not done here.
00030 
00031 // The translation engine focuses purely on trimming input pixels and
00032 // blending with the output.
00033 
00034 // Another advantage to the two step process is further optimization can be achieved
00035 // by leaving out translation or scaling.
00036 
00037 // Translation
00038 
00039 typedef struct
00040 {
00041         int in_x1;
00042         int in_fraction1;
00043         int in_x2;       // Might be same as in_x1 for boundary
00044         int in_fraction2;
00045         int output_fraction;
00046 } transfer_table_i;
00047 
00048 typedef struct
00049 {
00050         int in_x1;
00051         float in_fraction1;
00052         int in_x2;       // Might be same as in_x1 for boundary
00053         float in_fraction2;
00054         float output_fraction;
00055 } transfer_table_f;
00056 
00057 typedef struct
00058 {
00059         int input_pixel1;
00060         int input_pixel2;
00061         float input_fraction1;
00062         float input_fraction2;
00063         float input_fraction3;
00064         float total_fraction;
00065 } bilinear_table_t;
00066 
00067 class ScaleEngine;
00068 
00069 class ScalePackage : public LoadPackage
00070 {
00071 public:
00072         ScalePackage();
00073 
00074         int out_row1, out_row2;
00075 };
00076 
00077 class ScaleUnit : public LoadClient
00078 {
00079 public:
00080         ScaleUnit(ScaleEngine *server, OverlayFrame *overlay);
00081         ~ScaleUnit();
00082         
00083         float cubic_bspline(float x);
00084 
00085         void tabulate_bcubic_f(float* &coef_table, 
00086                 int* &coord_table,
00087                 float scale,
00088                 int start, 
00089                 int pixels,
00090                 int total_pixels,
00091                 float coefficient);
00092         void tabulate_blinear_f(int* &table_int1,
00093                 int* &table_int2,
00094                 float* &table_frac,
00095                 float* &table_antifrac,
00096                 float scale,
00097                 int pixel1,
00098                 int pixel2,
00099                 int start,
00100                 int total_pixels);
00101 
00102         void tabulate_bcubic_i(int* &coef_table, 
00103                 int* &coord_table,
00104                 float scale,
00105                 int start, 
00106                 int pixels,
00107                 int total_pixels,
00108                 float coefficient);
00109         void tabulate_blinear_i(int* &table_int1,
00110                 int* &table_int2,
00111                 int* &table_frac,
00112                 int* &table_antifrac,
00113                 float scale,
00114                 int pixel1,
00115                 int pixel2,
00116                 int start,
00117                 int total_pixels);
00118         void tabulate_reduction(bilinear_table_t* &table,
00119                 float scale,
00120                 int pixel1,
00121                 int out_total,
00122                 int in_total);
00123         void tabulate_enlarge(bilinear_table_t* &table,
00124                 float scale,
00125                 int pixel1,
00126                 int out_total,
00127                 int in_total);
00128         void dump_bilinear(bilinear_table_t *table, int total);
00129 
00130         void process_package(LoadPackage *package);
00131         
00132         OverlayFrame *overlay;
00133         ScaleEngine *engine;
00134 };
00135 
00136 class ScaleEngine : public LoadServer
00137 {
00138 public:
00139         ScaleEngine(OverlayFrame *overlay, int cpus);
00140         ~ScaleEngine();
00141         
00142         void init_packages();
00143         LoadClient* new_client();
00144         LoadPackage* new_package();
00145         
00146         OverlayFrame *overlay;
00147 // Global parameters for scaling units
00148         VFrame *scale_output;
00149         VFrame *scale_input;
00150         float w_scale;
00151         float h_scale;
00152         int in_x1_int;
00153         int in_y1_int;
00154         int out_w_int;
00155         int out_h_int;
00156         int interpolation_type;
00157 };
00158 
00159 
00160 
00161 
00162 
00163 
00164 
00165 class TranslateEngine;
00166 
00167 class TranslatePackage : public LoadPackage
00168 {
00169 public:
00170         TranslatePackage();
00171 
00172         int out_row1, out_row2;
00173 };
00174 
00175 
00176 class TranslateUnit : public LoadClient
00177 {
00178 public:
00179         TranslateUnit(TranslateEngine *server, OverlayFrame *overlay);
00180         ~TranslateUnit();
00181 
00182         void process_package(LoadPackage *package);
00183         static void translation_array_f(transfer_table_f* &table, 
00184                 float out_x1, 
00185                 float out_x2,
00186                 float in_x1,
00187                 float in_x2,
00188                 int in_total, 
00189                 int out_total, 
00190                 int &out_x1_int,
00191                 int &out_x2_int);
00192         void translation_array_i(transfer_table_i* &table, 
00193                 float out_x1, 
00194                 float out_x2,
00195                 float in_x1,
00196                 float in_x2,
00197                 int in_total, 
00198                 int out_total, 
00199                 int &out_x1_int,
00200                 int &out_x2_int);
00201         void translate(VFrame *output, 
00202                         VFrame *input, 
00203                         float in_x1,
00204                         float in_y1,
00205                         float in_x2,
00206                         float in_y2,
00207                         float out_x1,
00208                         float out_y1,
00209                         float out_x2,
00210                         float out_y2,
00211                         float alpha,
00212                         int mode,
00213                         int row1,
00214                         int row2);
00215 
00216         OverlayFrame *overlay;
00217         TranslateEngine *engine;
00218 };
00219 
00220 class TranslateEngine : public LoadServer
00221 {
00222 public:
00223         TranslateEngine(OverlayFrame *overlay, int cpus);
00224         ~TranslateEngine();
00225         
00226         void init_packages();
00227         LoadClient* new_client();
00228         LoadPackage* new_package();
00229         
00230         OverlayFrame *overlay;
00231 // Global parameters for translate units
00232         VFrame *translate_output;
00233         VFrame *translate_input;
00234         float translate_in_x1;
00235         float translate_in_y1;
00236         float translate_in_x2;
00237         float translate_in_y2;
00238         float translate_out_x1;
00239         float translate_out_y1;
00240         float translate_out_x2;
00241         float translate_out_y2;
00242         float translate_alpha;
00243         int translate_mode;
00244 };
00245 
00246 
00247 
00248 
00249 
00250 
00251 
00252 
00253 
00254 class ScaleTranslateEngine;
00255 
00256 class ScaleTranslatePackage : public LoadPackage
00257 {
00258 public:
00259         ScaleTranslatePackage();
00260 
00261         int out_row1, out_row2;
00262 };
00263 
00264 
00265 class ScaleTranslateUnit : public LoadClient
00266 {
00267 public:
00268         ScaleTranslateUnit(ScaleTranslateEngine *server, OverlayFrame *overlay);
00269         ~ScaleTranslateUnit();
00270 
00271         void process_package(LoadPackage *package);
00272         void scale_array(int* &table, 
00273                 int out_x1, 
00274                 int out_x2,
00275                 int in_x1,
00276                 int in_x2,
00277                 int is_x);
00278         
00279         OverlayFrame *overlay;
00280         ScaleTranslateEngine *scale_translate;
00281 };
00282 
00283 class ScaleTranslateEngine : public LoadServer
00284 {
00285 public:
00286         ScaleTranslateEngine(OverlayFrame *overlay, int cpus);
00287         ~ScaleTranslateEngine();
00288         
00289         void init_packages();
00290         LoadClient* new_client();
00291         LoadPackage* new_package();
00292         
00293         OverlayFrame *overlay;
00294         
00295         
00296 // Arguments
00297         VFrame *output;
00298         VFrame *input;
00299         int in_x1;
00300         int in_y1;
00301         int in_x2;
00302         int in_y2;
00303         int out_x1;
00304         int out_y1;
00305         int out_x2;
00306         int out_y2;
00307         float alpha;
00308         int mode;
00309 };
00310 
00311 
00312 
00313 
00314 
00315 
00316 
00317 
00318 
00319 
00320 
00321 
00322 
00323 
00324 
00325 class BlendEngine;
00326 
00327 class BlendPackage : public LoadPackage
00328 {
00329 public:
00330         BlendPackage();
00331 
00332         int out_row1, out_row2;
00333 };
00334 
00335 
00336 class BlendUnit : public LoadClient
00337 {
00338 public:
00339         BlendUnit(BlendEngine *server, OverlayFrame *overlay);
00340         ~BlendUnit();
00341 
00342         void process_package(LoadPackage *package);
00343         void translation_array_f(transfer_table_f* &table, 
00344                 float out_x1, 
00345                 float out_x2,
00346                 float in_x1,
00347                 float in_x2,
00348                 int in_total, 
00349                 int out_total, 
00350                 int &out_x1_int,
00351                 int &out_x2_int);
00352         void translate(VFrame *output, 
00353                         VFrame *input, 
00354                         float in_x1,
00355                         float in_y1,
00356                         float in_x2,
00357                         float in_y2,
00358                         float out_x1,
00359                         float out_y1,
00360                         float out_x2,
00361                         float out_y2,
00362                         float alpha,
00363                         int mode,
00364                         int row1,
00365                         int row2);
00366 
00367         OverlayFrame *overlay;
00368         BlendEngine *blend_engine;
00369 };
00370 
00371 class BlendEngine : public LoadServer
00372 {
00373 public:
00374         BlendEngine(OverlayFrame *overlay, int cpus);
00375         ~BlendEngine();
00376         
00377         void init_packages();
00378         LoadClient* new_client();
00379         LoadPackage* new_package();
00380         
00381         OverlayFrame *overlay;
00382         
00383         
00384 // Arguments
00385         VFrame *output;
00386         VFrame *input;
00387         float alpha;
00388         int mode;
00389 };
00390 
00391 
00392 
00393 
00394 
00395 
00396 
00397 
00398 
00399 
00400 
00401 
00402 
00403 class OverlayFrame
00404 {
00405 public:
00406         OverlayFrame(int cpus = 1);
00407         virtual ~OverlayFrame();
00408 
00409 // Alpha is from 0 - 1
00410         int overlay(VFrame *output, 
00411                 VFrame *input, 
00412                 float in_x1, 
00413                 float in_y1, 
00414                 float in_x2, 
00415                 float in_y2, 
00416                 float out_x1, 
00417                 float out_y1, 
00418                 float out_x2, 
00419                 float out_y2, 
00420                 float alpha,        // 0 - 1
00421                 int mode,
00422                 int interpolation_type);
00423         int use_alpha, use_float, mode, interpolate;
00424         int color_model;
00425 
00426         BlendEngine *blend_engine;
00427         ScaleEngine *scale_engine;
00428         TranslateEngine *translate_engine;
00429         ScaleTranslateEngine *scaletranslate_engine;
00430 
00431 
00432         VFrame *temp_frame;
00433         int cpus;
00434 
00435 };
00436 
00437 #endif

Generated on Sun Jan 8 13:38:57 2006 for Cinelerra-svn by  doxygen 1.4.4