4 #include "loadbalance.h"
5 #include "overlayframe.inc"
9 // Issues encoutered with overlay
11 // Floating point vs. int. On both alpha and Intel
12 // the floating point interpolation is over
13 // 2x faster than integer interpolation. Pipelined CPUs probably don't benefit
14 // at all in long sequences of integer calculations. Integer interpolation uses 32
15 // siginificant bits while floating point uses 24, however.
17 // Single step vs. two step process.
19 // A single step process would require performing blend with the output
20 // of BILINEAR or BICUBIC and trimming the output to fractional pixels.
23 // However reading the input for
24 // BILINEAR and BICUBIC would require trimming the input to fractional
25 // pixels often repeatedly since the interpolation reads the same pixels more
26 // than once. This is hard.
28 // In the two step process one step worries purely about scaling, ignoring
29 // trimming at the input and output so redundant trimming is not done here.
31 // The translation engine focuses purely on trimming input pixels and
32 // blending with the output.
34 // Another advantage to the two step process is further optimization can be achieved
35 // by leaving out translation or scaling.
43 int in_x2
; // Might be same as in_x1 for boundary
52 int in_x2
; // Might be same as in_x1 for boundary
54 float output_fraction
;
61 float input_fraction1
;
62 float input_fraction2
;
63 float input_fraction3
;
69 class ScalePackage
: public LoadPackage
74 int out_row1
, out_row2
;
77 class ScaleUnit
: public LoadClient
80 ScaleUnit(ScaleEngine
*server
, OverlayFrame
*overlay
);
83 float cubic_bspline(float x
);
85 void tabulate_bcubic_f(float* &coef_table
,
92 void tabulate_blinear_f(int* &table_int1
,
95 float* &table_antifrac
,
102 void tabulate_bcubic_i(int* &coef_table
,
109 void tabulate_blinear_i(int* &table_int1
,
112 int* &table_antifrac
,
118 void tabulate_reduction(bilinear_table_t
* &table
,
123 void tabulate_enlarge(bilinear_table_t
* &table
,
128 void dump_bilinear(bilinear_table_t
*table
, int total
);
130 void process_package(LoadPackage
*package
);
132 OverlayFrame
*overlay
;
136 class ScaleEngine
: public LoadServer
139 ScaleEngine(OverlayFrame
*overlay
, int cpus
);
142 void init_packages();
143 LoadClient
* new_client();
144 LoadPackage
* new_package();
146 OverlayFrame
*overlay
;
147 // Global parameters for scaling units
148 VFrame
*scale_output
;
156 int interpolation_type
;
165 class TranslateEngine
;
167 class TranslatePackage
: public LoadPackage
172 int out_row1
, out_row2
;
176 class TranslateUnit
: public LoadClient
179 TranslateUnit(TranslateEngine
*server
, OverlayFrame
*overlay
);
182 void process_package(LoadPackage
*package
);
183 static void translation_array_f(transfer_table_f
* &table
,
192 void translation_array_i(transfer_table_i
* &table
,
201 void translate(VFrame
*output
,
216 OverlayFrame
*overlay
;
217 TranslateEngine
*engine
;
220 class TranslateEngine
: public LoadServer
223 TranslateEngine(OverlayFrame
*overlay
, int cpus
);
226 void init_packages();
227 LoadClient
* new_client();
228 LoadPackage
* new_package();
230 OverlayFrame
*overlay
;
231 // Global parameters for translate units
232 VFrame
*translate_output
;
233 VFrame
*translate_input
;
234 float translate_in_x1
;
235 float translate_in_y1
;
236 float translate_in_x2
;
237 float translate_in_y2
;
238 float translate_out_x1
;
239 float translate_out_y1
;
240 float translate_out_x2
;
241 float translate_out_y2
;
242 float translate_alpha
;
254 class ScaleTranslateEngine
;
256 class ScaleTranslatePackage
: public LoadPackage
259 ScaleTranslatePackage();
261 int out_row1
, out_row2
;
265 class ScaleTranslateUnit
: public LoadClient
268 ScaleTranslateUnit(ScaleTranslateEngine
*server
, OverlayFrame
*overlay
);
269 ~ScaleTranslateUnit();
271 void process_package(LoadPackage
*package
);
272 void scale_array_f(int* &table
,
278 OverlayFrame
*overlay
;
279 ScaleTranslateEngine
*scale_translate
;
282 class ScaleTranslateEngine
: public LoadServer
285 ScaleTranslateEngine(OverlayFrame
*overlay
, int cpus
);
286 ~ScaleTranslateEngine();
288 void init_packages();
289 LoadClient
* new_client();
290 LoadPackage
* new_package();
292 OverlayFrame
*overlay
;
326 class BlendPackage
: public LoadPackage
331 int out_row1
, out_row2
;
335 class BlendUnit
: public LoadClient
338 BlendUnit(BlendEngine
*server
, OverlayFrame
*overlay
);
341 void process_package(LoadPackage
*package
);
342 void translation_array_f(transfer_table_f
* &table
,
351 void translate(VFrame
*output
,
366 OverlayFrame
*overlay
;
367 BlendEngine
*blend_engine
;
370 class BlendEngine
: public LoadServer
373 BlendEngine(OverlayFrame
*overlay
, int cpus
);
376 void init_packages();
377 LoadClient
* new_client();
378 LoadPackage
* new_package();
380 OverlayFrame
*overlay
;
405 OverlayFrame(int cpus
= 1);
406 virtual ~OverlayFrame();
408 // Alpha is from 0 - 1
409 int overlay(VFrame
*output
,
419 float alpha
, // 0 - 1
421 int interpolation_type
);
422 int use_alpha
, use_float
, mode
, interpolate
;
425 BlendEngine
*blend_engine
;
426 ScaleEngine
*scale_engine
;
427 TranslateEngine
*translate_engine
;
428 ScaleTranslateEngine
*scaletranslate_engine
;
440 // c-file-style: "linux"