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.inc"
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 void draw_line_clamped(int x1, int y1, int x2, int y2, int w, int h, int hoffset);
00043 void do_feather(VFrame *output,
00044 VFrame *input,
00045 float feather,
00046 int start_out,
00047 int end_out);
00048 int do_feather_2(VFrame *output,
00049 VFrame *input,
00050 float feather,
00051 int start_out,
00052 int end_out);
00053 void blur_strip(float *val_p,
00054 float *val_m,
00055 float *dst,
00056 float *src,
00057 int size,
00058 int max);
00059
00060 float n_p[5], n_m[5];
00061 float d_p[5], d_m[5];
00062 float bd_p[5], bd_m[5];
00063 MaskEngine *engine;
00064 short **row_spans;
00065 short row_spans_h;
00066 };
00067
00068
00069 class MaskEngine : public LoadServer
00070 {
00071 public:
00072 MaskEngine(int cpus);
00073 ~MaskEngine();
00074
00075 void do_mask(VFrame *output,
00076 int64_t start_position,
00077 double frame_rate,
00078 double project_frame_rate,
00079 MaskAutos *keyframe_set,
00080 int direction);
00081 int points_equivalent(ArrayList<MaskPoint*> *new_points,
00082 ArrayList<MaskPoint*> *points);
00083
00084 void delete_packages();
00085 void init_packages();
00086 LoadClient* new_client();
00087 LoadPackage* new_package();
00088
00089 VFrame *output;
00090
00091 VFrame *mask;
00092
00093 VFrame *temp_mask;
00094 ArrayList<ArrayList<MaskPoint*>*> point_sets;
00095 int mode;
00096 float feather;
00097 float realfeather;
00098 int recalculate;
00099 int value;
00100 pthread_mutex_t stage1_finished_mutex;
00101 pthread_cond_t stage1_finished_cond;
00102 int stage1_finished_count;
00103 Mutex protect_data;
00104 int first_nonempty_rowspan;
00105 int last_nonempty_rowspan;
00106 };
00107
00108
00109
00110 #endif