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_bicubic(float* &coef_table,
68 void tabulate_blinear(int* &table_int1,
71 float* &table_antifrac,
78 void process_package(LoadPackage *package);
80 OverlayFrame *overlay;
84 class ScaleEngine : public LoadServer
87 ScaleEngine(OverlayFrame *overlay, int cpus);
91 LoadClient* new_client();
92 LoadPackage* new_package();
94 OverlayFrame *overlay;
95 // Global parameters for scaling units
104 int interpolation_type;
113 class TranslateEngine;
115 class TranslatePackage : public LoadPackage
120 int out_row1, out_row2;
124 class TranslateUnit : public LoadClient
127 TranslateUnit(TranslateEngine *server, OverlayFrame *overlay);
130 void process_package(LoadPackage *package);
131 void translation_array(transfer_table* &table,
140 void translate(VFrame *output,
155 OverlayFrame *overlay;
156 TranslateEngine *engine;
159 class TranslateEngine : public LoadServer
162 TranslateEngine(OverlayFrame *overlay, int cpus);
165 void init_packages();
166 LoadClient* new_client();
167 LoadPackage* new_package();
169 OverlayFrame *overlay;
170 // Global parameters for translate units
171 VFrame *translate_output;
172 VFrame *translate_input;
173 float translate_in_x1;
174 float translate_in_y1;
175 float translate_in_x2;
176 float translate_in_y2;
177 float translate_out_x1;
178 float translate_out_y1;
179 float translate_out_x2;
180 float translate_out_y2;
181 float translate_alpha;
193 class ScaleTranslateEngine;
195 class ScaleTranslatePackage : public LoadPackage
198 ScaleTranslatePackage();
200 int out_row1, out_row2;
204 class ScaleTranslateUnit : public LoadClient
207 ScaleTranslateUnit(ScaleTranslateEngine *server, OverlayFrame *overlay);
208 ~ScaleTranslateUnit();
210 void process_package(LoadPackage *package);
211 void scale_array(int* &table,
218 OverlayFrame *overlay;
219 ScaleTranslateEngine *scale_translate;
222 class ScaleTranslateEngine : public LoadServer
225 ScaleTranslateEngine(OverlayFrame *overlay, int cpus);
226 ~ScaleTranslateEngine();
228 void init_packages();
229 LoadClient* new_client();
230 LoadPackage* new_package();
232 OverlayFrame *overlay;
266 class BlendPackage : public LoadPackage
271 int out_row1, out_row2;
275 class BlendUnit : public LoadClient
278 BlendUnit(BlendEngine *server, OverlayFrame *overlay);
281 void process_package(LoadPackage *package);
282 void translation_array(transfer_table* &table,
291 void translate(VFrame *output,
306 OverlayFrame *overlay;
307 BlendEngine *blend_engine;
310 class BlendEngine : public LoadServer
313 BlendEngine(OverlayFrame *overlay, int cpus);
316 void init_packages();
317 LoadClient* new_client();
318 LoadPackage* new_package();
320 OverlayFrame *overlay;
345 OverlayFrame(int cpus = 1);
346 virtual ~OverlayFrame();
348 // Alpha is from 0 - 1
349 int overlay(VFrame *output,
361 int interpolation_type);
363 int overlay(VFrame *output, unsigned char *input,
364 float in_x1, float in_y1, float in_x2, float in_y2,
365 float out_x1, float out_y1, float out_x2, float out_y2,
366 int alpha, int in_w, int in_h);
367 int use_alpha, use_float, mode, interpolate;
370 BlendEngine *blend_engine;
371 ScaleEngine *scale_engine;
372 TranslateEngine *translate_engine;
373 ScaleTranslateEngine *scaletranslate_engine;