5 #include "bcpixmap.inc"
6 #include "bcsynchronous.h"
7 #include "bcwindowbase.inc"
9 #include "condition.inc"
10 #include "maskauto.inc"
11 #include "maskautos.inc"
13 #include "mwindow.inc"
14 #include "pluginclient.inc"
22 // Macros for useful fragment shaders
23 #define YUV_TO_RGB_FRAG(PIXEL) \
24 PIXEL ".gb -= vec2(0.5, 0.5);\n" \
25 PIXEL ".rgb = mat3(\n" \
27 " 0, -0.34414, 1.77200, \n" \
28 " 1.40200, -0.71414, 0) * " PIXEL ".rgb;\n"
30 #define RGB_TO_YUV_FRAG(PIXEL) \
31 PIXEL ".rgb = mat3(\n" \
32 " 0.29900, -0.16874, 0.50000, \n" \
33 " 0.58700, -0.33126, -0.41869, \n" \
34 " 0.11400, 0.50000, -0.08131) * " PIXEL ".rgb;\n" \
35 PIXEL ".gb += vec2(0.5, 0.5);\n"
37 #define RGB_TO_HSV_FRAG(PIXEL) \
41 "float min, max, delta;\n" \
42 "float f, p, q, t;\n" \
43 "r = " PIXEL ".r;\n" \
44 "g = " PIXEL ".g;\n" \
45 "b = " PIXEL ".b;\n" \
46 "min = ((r < g) ? r : g) < b ? ((r < g) ? r : g) : b;\n" \
47 "max = ((r > g) ? r : g) > b ? ((r > g) ? r : g) : b;\n" \
49 "delta = max - min;\n" \
50 "if(max != 0.0 && delta != 0.0)\n" \
52 " s = delta / max;\n" \
54 " h = (g - b) / delta;\n" \
57 " h = 2.0 + (b - r) / delta;\n" \
59 " h = 4.0 + (r - g) / delta;\n" \
70 "" PIXEL ".r = h;\n" \
71 "" PIXEL ".g = s;\n" \
72 "" PIXEL ".b = v;\n" \
75 #define HSV_TO_RGB_FRAG(PIXEL) \
80 "float min, max, delta;\n" \
81 "float f, p, q, t;\n" \
82 "h = " PIXEL ".r;\n" \
83 "s = " PIXEL ".g;\n" \
84 "v = " PIXEL ".b;\n" \
93 " f = h - float(i);\n" \
94 " p = v * (1.0 - s);\n" \
95 " q = v * (1.0 - s * f);\n" \
96 " t = v * (1.0 - s * (1.0 - f));\n" \
140 "" PIXEL ".r = r;\n" \
141 "" PIXEL ".g = g;\n" \
142 "" PIXEL ".b = b;\n" \
147 class Playback3DCommand
: public BC_SynchronousCommand
151 void copy_from(BC_SynchronousCommand
*command
);
157 WRITE_BUFFER
= LAST_COMMAND
,
171 // Parameters for overlay command
183 int interpolation_type
;
187 int64_t start_position_project
;
188 MaskAutos
*keyframe_set
;
190 MaskAuto
*default_auto
;
191 PluginClient
*plugin_client
;
195 class Playback3D
: public BC_Synchronous
198 Playback3D(MWindow
*mwindow
);
201 BC_SynchronousCommand
* new_command();
202 void handle_command(BC_SynchronousCommand
*command
);
204 // Called by VDeviceX11::write_buffer during video playback
205 void write_buffer(Canvas
*canvas
,
217 // Reads from pbuffer to either RAM or texture and updates the dst state
218 // want_texture - causes read into texture if 1
219 void copy_from(Canvas
*canvas
,
222 int want_texture
= 0);
224 // Clear framebuffer before composing virtual console
225 // output - passed when rendering refresh frame. If 0, the canvas is cleared.
226 void clear_output(Canvas
*canvas
, VFrame
*output
);
228 void do_fade(Canvas
*canvas
, VFrame
*fade
, float fade
);
230 void do_mask(Canvas
*canvas
,
232 int64_t start_position_project
,
233 MaskAutos
*keyframe_set
,
235 MaskAuto
*default_auto
);
238 // Overlay a virtual node on the framebuffer
239 void overlay(Canvas
*canvas
,
249 float alpha
, // 0 - 1
251 int interpolation_type
,
252 // supplied if rendering single frame to PBuffer.
256 int run_plugin(Canvas
*canvas
, PluginClient
*client
);
258 void clear_input(Canvas
*canvas
, VFrame
*frame
);
259 void do_camera(Canvas
*canvas
,
272 // Called by write_buffer and clear_frame to initialize OpenGL flags
273 void init_frame(Playback3DCommand
*command
);
274 void write_buffer_sync(Playback3DCommand
*command
);
275 void draw_output(Playback3DCommand
*command
);
276 void clear_output_sync(Playback3DCommand
*command
);
277 void clear_input_sync(Playback3DCommand
*command
);
278 void overlay_sync(Playback3DCommand
*command
);
279 // Read frame buffer back into texture for overlay operation
280 void enable_overlay_texture(Playback3DCommand
*command
);
281 void do_fade_sync(Playback3DCommand
*command
);
282 void do_mask_sync(Playback3DCommand
*command
);
283 void run_plugin_sync(Playback3DCommand
*command
);
284 void do_camera_sync(Playback3DCommand
*command
);
285 // void draw_refresh_sync(Playback3DCommand *command);
286 void copy_from_sync(Playback3DCommand
*command
);
288 // Print errors from shader compilation
289 void print_error(unsigned int object
, int is_program
);
291 // This quits the program when it's 1.
293 // Temporaries for render to texture
294 BC_Texture
*temp_texture
;
295 // This is set by clear_output and used in compositing directly
296 // to the output framebuffer.