00001 #ifndef PLAYBACK3D_H
00002 #define PLAYBACK3D_H
00003
00004 #include "arraylist.h"
00005 #include "bcpixmap.inc"
00006 #include "bcsynchronous.h"
00007 #include "bcwindowbase.inc"
00008 #include "canvas.inc"
00009 #include "condition.inc"
00010 #include "maskauto.inc"
00011 #include "maskautos.inc"
00012 #include "mutex.inc"
00013 #include "mwindow.inc"
00014 #include "pluginclient.inc"
00015 #include "thread.h"
00016 #include "vframe.inc"
00017
00018
00019
00020
00021
00022
00023 #define YUV_TO_RGB_FRAG(PIXEL) \
00024 PIXEL ".gb -= vec2(0.5, 0.5);\n" \
00025 PIXEL ".rgb = mat3(\n" \
00026 " 1, 1, 1, \n" \
00027 " 0, -0.34414, 1.77200, \n" \
00028 " 1.40200, -0.71414, 0) * " PIXEL ".rgb;\n"
00029
00030 #define RGB_TO_YUV_FRAG(PIXEL) \
00031 PIXEL ".rgb = mat3(\n" \
00032 " 0.29900, -0.16874, 0.50000, \n" \
00033 " 0.58700, -0.33126, -0.41869, \n" \
00034 " 0.11400, 0.50000, -0.08131) * " PIXEL ".rgb;\n" \
00035 PIXEL ".gb += vec2(0.5, 0.5);\n"
00036
00037 #define RGB_TO_HSV_FRAG(PIXEL) \
00038 "{\n" \
00039 "float r, g, b;\n" \
00040 "float h, s, v;\n" \
00041 "float min, max, delta;\n" \
00042 "float f, p, q, t;\n" \
00043 "r = " PIXEL ".r;\n" \
00044 "g = " PIXEL ".g;\n" \
00045 "b = " PIXEL ".b;\n" \
00046 "min = ((r < g) ? r : g) < b ? ((r < g) ? r : g) : b;\n" \
00047 "max = ((r > g) ? r : g) > b ? ((r > g) ? r : g) : b;\n" \
00048 "v = max;\n" \
00049 "delta = max - min;\n" \
00050 "if(max != 0.0 && delta != 0.0)\n" \
00051 "{\n" \
00052 " s = delta / max;\n" \
00053 " if(r == max)\n" \
00054 " h = (g - b) / delta;\n" \
00055 " else \n" \
00056 " if(g == max)\n" \
00057 " h = 2.0 + (b - r) / delta;\n" \
00058 " else\n" \
00059 " h = 4.0 + (r - g) / delta;\n" \
00060 "\n" \
00061 " h *= 60.0;\n" \
00062 " if(h < 0.0)\n" \
00063 " h += 360.0;\n" \
00064 "}\n" \
00065 "else\n" \
00066 "{\n" \
00067 " s = 0.0;\n" \
00068 " h = -1.0;\n" \
00069 "}\n" \
00070 "" PIXEL ".r = h;\n" \
00071 "" PIXEL ".g = s;\n" \
00072 "" PIXEL ".b = v;\n" \
00073 "}\n"
00074
00075 #define HSV_TO_RGB_FRAG(PIXEL) \
00076 "{\n" \
00077 "int i;\n" \
00078 "float r, g, b;\n" \
00079 "float h, s, v;\n" \
00080 "float min, max, delta;\n" \
00081 "float f, p, q, t;\n" \
00082 "h = " PIXEL ".r;\n" \
00083 "s = " PIXEL ".g;\n" \
00084 "v = " PIXEL ".b;\n" \
00085 "if(s == 0.0) \n" \
00086 "{\n" \
00087 " r = g = b = v;\n" \
00088 "}\n" \
00089 "else\n" \
00090 "{\n" \
00091 " h /= 60.0;\n" \
00092 " i = int(h);\n" \
00093 " f = h - float(i);\n" \
00094 " p = v * (1.0 - s);\n" \
00095 " q = v * (1.0 - s * f);\n" \
00096 " t = v * (1.0 - s * (1.0 - f));\n" \
00097 "\n" \
00098 " if(i == 0)\n" \
00099 " {\n" \
00100 " r = v;\n" \
00101 " g = t;\n" \
00102 " b = p;\n" \
00103 " }\n" \
00104 " else\n" \
00105 " if(i == 1)\n" \
00106 " {\n" \
00107 " r = q;\n" \
00108 " g = v;\n" \
00109 " b = p;\n" \
00110 " }\n" \
00111 " else\n" \
00112 " if(i == 2)\n" \
00113 " {\n" \
00114 " r = p;\n" \
00115 " g = v;\n" \
00116 " b = t;\n" \
00117 " }\n" \
00118 " else\n" \
00119 " if(i == 3)\n" \
00120 " {\n" \
00121 " r = p;\n" \
00122 " g = q;\n" \
00123 " b = v;\n" \
00124 " }\n" \
00125 " else\n" \
00126 " if(i == 4)\n" \
00127 " {\n" \
00128 " r = t;\n" \
00129 " g = p;\n" \
00130 " b = v;\n" \
00131 " }\n" \
00132 " else\n" \
00133 " if(i == 5)\n" \
00134 " {\n" \
00135 " r = v;\n" \
00136 " g = p;\n" \
00137 " b = q;\n" \
00138 " }\n" \
00139 "}\n" \
00140 "" PIXEL ".r = r;\n" \
00141 "" PIXEL ".g = g;\n" \
00142 "" PIXEL ".b = b;\n" \
00143 "}\n"
00144
00145
00146
00147 class Playback3DCommand : public BC_SynchronousCommand
00148 {
00149 public:
00150 Playback3DCommand();
00151 void copy_from(BC_SynchronousCommand *command);
00152
00153
00154 enum
00155 {
00156
00157 WRITE_BUFFER = LAST_COMMAND,
00158 CLEAR_OUTPUT,
00159 OVERLAY,
00160 DO_FADE,
00161 DO_MASK,
00162 PLUGIN,
00163 CLEAR_INPUT,
00164 DO_CAMERA,
00165 COPY_FROM
00166 };
00167
00168 Canvas *canvas;
00169 int is_cleared;
00170
00171
00172 float in_x1;
00173 float in_y1;
00174 float in_x2;
00175 float in_y2;
00176 float out_x1;
00177 float out_y1;
00178 float out_x2;
00179 float out_y2;
00180
00181 float alpha;
00182 int mode;
00183 int interpolation_type;
00184 VFrame *input;
00185 int want_texture;
00186
00187 int64_t start_position_project;
00188 MaskAutos *keyframe_set;
00189 MaskAuto *keyframe;
00190 MaskAuto *default_auto;
00191 PluginClient *plugin_client;
00192 };
00193
00194
00195 class Playback3D : public BC_Synchronous
00196 {
00197 public:
00198 Playback3D(MWindow *mwindow);
00199 ~Playback3D();
00200
00201 BC_SynchronousCommand* new_command();
00202 void handle_command(BC_SynchronousCommand *command);
00203
00204
00205 void write_buffer(Canvas *canvas,
00206 VFrame *frame,
00207 float in_x1,
00208 float in_y1,
00209 float in_x2,
00210 float in_y2,
00211 float out_x1,
00212 float out_y1,
00213 float out_x2,
00214 float out_y2,
00215 int is_cleared);
00216
00217
00218
00219 void copy_from(Canvas *canvas,
00220 VFrame *dst,
00221 VFrame *src,
00222 int want_texture = 0);
00223
00224
00225
00226 void clear_output(Canvas *canvas, VFrame *output);
00227
00228 void do_fade(Canvas *canvas, VFrame *frame, float fade);
00229
00230 void do_mask(Canvas *canvas,
00231 VFrame *output,
00232 int64_t start_position_project,
00233 MaskAutos *keyframe_set,
00234 MaskAuto *keyframe,
00235 MaskAuto *default_auto);
00236
00237
00238
00239 void overlay(Canvas *canvas,
00240 VFrame *input,
00241 float in_x1,
00242 float in_y1,
00243 float in_x2,
00244 float in_y2,
00245 float out_x1,
00246 float out_y1,
00247 float out_x2,
00248 float out_y2,
00249 float alpha,
00250 int mode,
00251 int interpolation_type,
00252
00253 VFrame *output = 0);
00254
00255
00256 int run_plugin(Canvas *canvas, PluginClient *client);
00257
00258 void clear_input(Canvas *canvas, VFrame *frame);
00259 void do_camera(Canvas *canvas,
00260 VFrame *output,
00261 VFrame *input,
00262 float in_x1,
00263 float in_y1,
00264 float in_x2,
00265 float in_y2,
00266 float out_x1,
00267 float out_y1,
00268 float out_x2,
00269 float out_y2);
00270
00271 private:
00272
00273 void init_frame(Playback3DCommand *command);
00274 void write_buffer_sync(Playback3DCommand *command);
00275 void draw_output(Playback3DCommand *command);
00276 void clear_output_sync(Playback3DCommand *command);
00277 void clear_input_sync(Playback3DCommand *command);
00278 void overlay_sync(Playback3DCommand *command);
00279
00280 void enable_overlay_texture(Playback3DCommand *command);
00281 void do_fade_sync(Playback3DCommand *command);
00282 void do_mask_sync(Playback3DCommand *command);
00283 void run_plugin_sync(Playback3DCommand *command);
00284 void do_camera_sync(Playback3DCommand *command);
00285
00286 void copy_from_sync(Playback3DCommand *command);
00287
00288
00289 void print_error(unsigned int object, int is_program);
00290
00291
00292 MWindow *mwindow;
00293
00294 BC_Texture *temp_texture;
00295
00296
00297 int canvas_w;
00298 int canvas_h;
00299 };
00300
00301
00302
00303
00304 #endif