4 #include "loadbalance.h"
5 #include "overlayframe.inc"
9 // Issues encoutered with overlay
11 // Floating point vs. int. On alpha the floating point interpolation is about
12 // 2x faster than integer interpolation. Integer interpolation uses 32
13 // siginificant bits while floating point uses 24, however.
15 // Single step vs. two step process.
17 // A single step process would require performing blend with the output
18 // of BILINEAR or BICUBIC and trimming the output to fractional pixels.
21 // However reading the input for
22 // BILINEAR and BICUBIC would require trimming the input to fractional
23 // pixels often repeatedly since the interpolation reads the same pixels more
24 // than once. This is hard.
26 // In the two step process one step worries purely about scaling, ignoring
27 // trimming at the input and output so redundant trimming is not done here.
29 // The translation engine focuses purely on trimming input pixels and
30 // blending with the output
38 int in_x2; // Might be same as in_x1 for boundary
40 float output_fraction;
46 class ScalePackage : public LoadPackage
51 int out_row1, out_row2;
54 class ScaleUnit : public LoadClient
57 ScaleUnit(ScaleEngine *server, OverlayFrame *overlay);
60 float cubic_bspline(float x);
61 void tabulate_bspline(float* &table,
65 void tabulate_blinear(int* &table_int,
67 float* &table_antifrac,
73 void process_package(LoadPackage *package);
75 OverlayFrame *overlay;
79 class ScaleEngine : public LoadServer
82 ScaleEngine(OverlayFrame *overlay, int cpus);
86 LoadClient* new_client();
87 LoadPackage* new_package();
89 OverlayFrame *overlay;
90 // Global parameters for scaling units
99 int interpolation_type;
108 class TranslateEngine;
110 class TranslatePackage : public LoadPackage
115 int out_row1, out_row2;
119 class TranslateUnit : public LoadClient
122 TranslateUnit(TranslateEngine *server, OverlayFrame *overlay);
125 void process_package(LoadPackage *package);
126 void translation_array(transfer_table* &table,
135 void translate(VFrame *output,
150 OverlayFrame *overlay;
151 TranslateEngine *engine;
154 class TranslateEngine : public LoadServer
157 TranslateEngine(OverlayFrame *overlay, int cpus);
160 void init_packages();
161 LoadClient* new_client();
162 LoadPackage* new_package();
164 OverlayFrame *overlay;
165 // Global parameters for translate units
166 VFrame *translate_output;
167 VFrame *translate_input;
168 float translate_in_x1;
169 float translate_in_y1;
170 float translate_in_x2;
171 float translate_in_y2;
172 float translate_out_x1;
173 float translate_out_y1;
174 float translate_out_x2;
175 float translate_out_y2;
176 float translate_alpha;
188 class ScaleTranslateEngine;
190 class ScaleTranslatePackage : public LoadPackage
193 ScaleTranslatePackage();
195 int out_row1, out_row2;
199 class ScaleTranslateUnit : public LoadClient
202 ScaleTranslateUnit(ScaleTranslateEngine *server, OverlayFrame *overlay);
203 ~ScaleTranslateUnit();
205 void process_package(LoadPackage *package);
206 void scale_array(int* &table,
213 OverlayFrame *overlay;
214 ScaleTranslateEngine *scale_translate;
217 class ScaleTranslateEngine : public LoadServer
220 ScaleTranslateEngine(OverlayFrame *overlay, int cpus);
221 ~ScaleTranslateEngine();
223 void init_packages();
224 LoadClient* new_client();
225 LoadPackage* new_package();
227 OverlayFrame *overlay;
261 class BlendPackage : public LoadPackage
266 int out_row1, out_row2;
270 class BlendUnit : public LoadClient
273 BlendUnit(BlendEngine *server, OverlayFrame *overlay);
276 void process_package(LoadPackage *package);
277 void translation_array(transfer_table* &table,
286 void translate(VFrame *output,
301 OverlayFrame *overlay;
302 BlendEngine *blend_engine;
305 class BlendEngine : public LoadServer
308 BlendEngine(OverlayFrame *overlay, int cpus);
311 void init_packages();
312 LoadClient* new_client();
313 LoadPackage* new_package();
315 OverlayFrame *overlay;
340 OverlayFrame(int cpus = 1);
341 virtual ~OverlayFrame();
343 // Alpha is from 0 - 1
344 int overlay(VFrame *output,
356 int interpolation_type);
358 int overlay(VFrame *output, unsigned char *input,
359 float in_x1, float in_y1, float in_x2, float in_y2,
360 float out_x1, float out_y1, float out_x2, float out_y2,
361 int alpha, int in_w, int in_h);
362 int use_alpha, use_float, mode, interpolate;
365 BlendEngine *blend_engine;
366 ScaleEngine *scale_engine;
367 TranslateEngine *translate_engine;
368 ScaleTranslateEngine *scaletranslate_engine;