00001 #ifndef MASKENGINE_H
00002 #define MASKENGINE_H
00003
00004
00005 #include "condition.inc"
00006 #include "loadbalance.h"
00007 #include "maskautos.inc"
00008 #include "maskauto.inc"
00009 #include "mutex.h"
00010 #include "vframe.inc"
00011
00012
00013 #define OVERSAMPLE 8
00014 #define NUM_SPANS 4
00015
00016 class MaskEngine;
00017
00018
00019 enum
00020 {
00021 RECALCULATE_PART,
00022 APPLY_PART
00023 };
00024
00025
00026 class MaskPackage : public LoadPackage
00027 {
00028 public:
00029 MaskPackage();
00030 ~MaskPackage();
00031
00032 int row1, row2;
00033 };
00034
00035 class MaskUnit : public LoadClient
00036 {
00037 public:
00038 MaskUnit(MaskEngine *engine);
00039 ~MaskUnit();
00040
00041 void process_package(LoadPackage *package);
00042 private:
00043 void draw_line_clamped(int x1, int y1, int x2, int y2, int w, int h, int hoffset);
00044 void do_feather(VFrame *output,
00045 VFrame *input,
00046 float feather,
00047 int start_out,
00048 int end_out);
00049 int do_feather_2(VFrame *output,
00050 VFrame *input,
00051 float feather,
00052 int start_out,
00053 int end_out);
00054 template<class T>
00055 void blur_strip(float *val_p,
00056 float *val_m,
00057 float *dst,
00058 float *src,
00059 int size,
00060 T max);
00061
00062 float n_p[5], n_m[5];
00063 float d_p[5], d_m[5];
00064 float bd_p[5], bd_m[5];
00065 MaskEngine *engine;
00066 short **row_spans;
00067 short row_spans_h;
00068 };
00069
00070
00071 class MaskEngine : public LoadServer
00072 {
00073 public:
00074 MaskEngine(int cpus);
00075 ~MaskEngine();
00076
00077
00078 void do_mask(VFrame *output,
00079 int64_t start_position,
00080 double frame_rate,
00081 double project_frame_rate,
00082 MaskAutos *keyframe_set,
00083 int direction,
00084 int before_plugins);
00085 int points_equivalent(ArrayList<MaskPoint*> *new_points,
00086 ArrayList<MaskPoint*> *points);
00087
00088 void delete_packages();
00089 void init_packages();
00090 LoadClient* new_client();
00091 LoadPackage* new_package();
00092
00093 VFrame *output;
00094
00095 VFrame *mask;
00096
00097 VFrame *temp_mask;
00098 ArrayList<ArrayList<MaskPoint*>*> point_sets;
00099 int mode;
00100 float feather;
00101 float realfeather;
00102 int recalculate;
00103 int value;
00104 pthread_mutex_t stage1_finished_mutex;
00105 pthread_cond_t stage1_finished_cond;
00106 int stage1_finished_count;
00107 Mutex protect_data;
00108 int first_nonempty_rowspan;
00109 int last_nonempty_rowspan;
00110 };
00111
00112
00113
00114 #endif