rework keyframe hide popup, keyframe auto render, textbox set_selection wide text
[goodguy/history.git] / cinelerra-5.1 / cinelerra / overlayframe.h.floattable
1 #ifndef OVERLAYFRAME_H
2 #define OVERLAYFRAME_H
3
4 #include "loadbalance.h"
5 #include "overlayframe.inc"
6 #include "vframe.inc"
7
8
9 // Issues encoutered with overlay
10
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.
14
15 // Single step vs. two step process.
16
17 // A single step process would require performing blend with the output
18 // of BILINEAR or BICUBIC and trimming the output to fractional pixels.
19 // This is easy.  
20
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.
25
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.
28
29 // The translation engine focuses purely on trimming input pixels and
30 // blending with the output
31
32 // Translation
33
34 typedef struct
35 {
36         int in_x1;
37         float in_fraction1;
38         int in_x2;       // Might be same as in_x1 for boundary
39         float in_fraction2;
40         float output_fraction;
41 } transfer_table;
42
43
44 class ScaleEngine;
45
46 class ScalePackage : public LoadPackage
47 {
48 public:
49         ScalePackage();
50
51         int out_row1, out_row2;
52 };
53
54 class ScaleUnit : public LoadClient
55 {
56 public:
57         ScaleUnit(ScaleEngine *server, OverlayFrame *overlay);
58         ~ScaleUnit();
59         
60         float cubic_bspline(float x);
61         void tabulate_bspline(float* &table, 
62                 float scale,
63                 int pixels,
64                 float coefficient);
65         void tabulate_blinear(int* &table_int,
66                 float* &table_frac,
67                 float* &table_antifrac,
68                 float scale,
69                 int pixel1,
70                 int pixel2,
71                 int total_pixels);
72
73         void process_package(LoadPackage *package);
74         
75         OverlayFrame *overlay;
76         ScaleEngine *engine;
77 };
78
79 class ScaleEngine : public LoadServer
80 {
81 public:
82         ScaleEngine(OverlayFrame *overlay, int cpus);
83         ~ScaleEngine();
84         
85         void init_packages();
86         LoadClient* new_client();
87         LoadPackage* new_package();
88         
89         OverlayFrame *overlay;
90 // Global parameters for scaling units
91         VFrame *scale_output;
92         VFrame *scale_input;
93         float w_scale;
94         float h_scale;
95         int in_x1_int;
96         int in_y1_int;
97         int out_w_int;
98         int out_h_int;
99         int interpolation_type;
100 };
101
102
103
104
105
106
107
108 class TranslateEngine;
109
110 class TranslatePackage : public LoadPackage
111 {
112 public:
113         TranslatePackage();
114
115         int out_row1, out_row2;
116 };
117
118
119 class TranslateUnit : public LoadClient
120 {
121 public:
122         TranslateUnit(TranslateEngine *server, OverlayFrame *overlay);
123         ~TranslateUnit();
124
125         void process_package(LoadPackage *package);
126         void translation_array(transfer_table* &table, 
127                 float out_x1, 
128                 float out_x2,
129                 float in_x1,
130                 float in_x2,
131                 int in_total, 
132                 int out_total, 
133                 int &out_x1_int,
134                 int &out_x2_int);
135         void translate(VFrame *output, 
136                         VFrame *input, 
137                         float in_x1,
138                         float in_y1,
139                         float in_x2,
140                         float in_y2,
141                         float out_x1,
142                         float out_y1,
143                         float out_x2,
144                         float out_y2,
145                         float alpha,
146                         int mode,
147                         int row1,
148                         int row2);
149
150         OverlayFrame *overlay;
151         TranslateEngine *engine;
152 };
153
154 class TranslateEngine : public LoadServer
155 {
156 public:
157         TranslateEngine(OverlayFrame *overlay, int cpus);
158         ~TranslateEngine();
159         
160         void init_packages();
161         LoadClient* new_client();
162         LoadPackage* new_package();
163         
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;
177         int translate_mode;
178 };
179
180
181
182
183
184
185
186
187
188 class ScaleTranslateEngine;
189
190 class ScaleTranslatePackage : public LoadPackage
191 {
192 public:
193         ScaleTranslatePackage();
194
195         int out_row1, out_row2;
196 };
197
198
199 class ScaleTranslateUnit : public LoadClient
200 {
201 public:
202         ScaleTranslateUnit(ScaleTranslateEngine *server, OverlayFrame *overlay);
203         ~ScaleTranslateUnit();
204
205         void process_package(LoadPackage *package);
206         void scale_array(int* &table, 
207                 int out_x1, 
208                 int out_x2,
209                 int in_x1,
210                 int in_x2,
211                 int is_x);
212         
213         OverlayFrame *overlay;
214         ScaleTranslateEngine *scale_translate;
215 };
216
217 class ScaleTranslateEngine : public LoadServer
218 {
219 public:
220         ScaleTranslateEngine(OverlayFrame *overlay, int cpus);
221         ~ScaleTranslateEngine();
222         
223         void init_packages();
224         LoadClient* new_client();
225         LoadPackage* new_package();
226         
227         OverlayFrame *overlay;
228         
229         
230 // Arguments
231         VFrame *output;
232         VFrame *input;
233         int in_x1;
234         int in_y1;
235         int in_x2;
236         int in_y2;
237         int out_x1;
238         int out_y1;
239         int out_x2;
240         int out_y2;
241         float alpha;
242         int mode;
243 };
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259 class BlendEngine;
260
261 class BlendPackage : public LoadPackage
262 {
263 public:
264         BlendPackage();
265
266         int out_row1, out_row2;
267 };
268
269
270 class BlendUnit : public LoadClient
271 {
272 public:
273         BlendUnit(BlendEngine *server, OverlayFrame *overlay);
274         ~BlendUnit();
275
276         void process_package(LoadPackage *package);
277         void translation_array(transfer_table* &table, 
278                 float out_x1, 
279                 float out_x2,
280                 float in_x1,
281                 float in_x2,
282                 int in_total, 
283                 int out_total, 
284                 int &out_x1_int,
285                 int &out_x2_int);
286         void translate(VFrame *output, 
287                         VFrame *input, 
288                         float in_x1,
289                         float in_y1,
290                         float in_x2,
291                         float in_y2,
292                         float out_x1,
293                         float out_y1,
294                         float out_x2,
295                         float out_y2,
296                         float alpha,
297                         int mode,
298                         int row1,
299                         int row2);
300
301         OverlayFrame *overlay;
302         BlendEngine *blend_engine;
303 };
304
305 class BlendEngine : public LoadServer
306 {
307 public:
308         BlendEngine(OverlayFrame *overlay, int cpus);
309         ~BlendEngine();
310         
311         void init_packages();
312         LoadClient* new_client();
313         LoadPackage* new_package();
314         
315         OverlayFrame *overlay;
316         
317         
318 // Arguments
319         VFrame *output;
320         VFrame *input;
321         float alpha;
322         int mode;
323 };
324
325
326
327
328
329
330
331
332
333
334
335
336
337 class OverlayFrame
338 {
339 public:
340         OverlayFrame(int cpus = 1);
341         virtual ~OverlayFrame();
342
343 // Alpha is from 0 - 1
344         int overlay(VFrame *output, 
345                 VFrame *input, 
346                 float in_x1, 
347                 float in_y1, 
348                 float in_x2, 
349                 float in_y2, 
350                 float out_x1, 
351                 float out_y1, 
352                 float out_x2, 
353                 float out_y2, 
354                 float alpha, 
355                 int mode,
356                 int interpolation_type);
357
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;
363         int color_model;
364
365         BlendEngine *blend_engine;
366         ScaleEngine *scale_engine;
367         TranslateEngine *translate_engine;
368         ScaleTranslateEngine *scaletranslate_engine;
369
370
371         VFrame *temp_frame;
372         int cpus;
373
374 };
375
376 #endif