1 #if defined(__i386__) || defined(__x86_64__)
2 #if defined (__linux__)
9 #include "bcwindowbase.inc"
12 #include "../db/tdb.h"
17 #include <semaphore.h>
22 void write_pbm(uint8_t *tp, int w, int h, const char *fmt, ...);
23 void write_pgm(uint8_t *tp, int w, int h, const char *fmt, ...);
24 void pbm_diff(uint8_t *ap, uint8_t *bp, int w, int h, const char *fmt, ...);
28 int rx, ry, rw, rh, iw, ih;
29 int ix0, ix1, iy0, iy1, rsh;
30 double xf0, xf1, yf0, yf1, pw;
32 uint8_t *row(int y) { return idat + (iw<<rsh) * (y>>rsh); }
34 inline double scalex(uint8_t *rp, double v, double yw) {
36 double vv = xf0 * *rp++;
37 int iv = 0; while( ++x < ix1 ) iv += *rp++;
42 inline double scalexy() {
45 if( (yw = pw * yf0) > 0 ) v = scalex(row(y), v, yw);
46 while( ++y < iy1 ) v = scalex(row(y), v, pw);
47 if( (yw = pw * yf1) > 0 ) v = scalex(row(y), v, yw);
51 Scale(uint8_t *idata, int type, int iw, int ih, int rx, int ry, int rw, int rh) {
53 this->idat = idata + ry*iw + rx;
54 this->iw = iw; this->ih = ih;
55 this->rx = rx; this->ry = ry;
56 this->rw = rw; this->rh = rh;
58 void scale(uint8_t *odata, int ow, int oh, int sx, int sy, int sw, int sh);
63 DEL_START, // always the first mark
64 DEL_MARK, // boundary between cur/next media deletion
65 DEL_SKIP, // skip media in current deletion region
66 DEL_OOPS, // ignore previous mark
70 // dele: n. A sign indicating that something is to be removed from <media>
72 class Dele : public ListItem<Dele>
78 Dele(double t, int a) : time(t), action(a) {}
82 class Deletions: public List<Dele>
84 int save(FileXML &xml);
85 int load(FileXML &xml);
88 char filepath[BCTEXTLEN];
89 const char *file_path() { return filepath; }
90 bool empty() { return !first; }
92 int write_dels(const char *filename);
93 static Deletions *read_dels(const char *filename);
95 Deletions(int pid, const char *fn);
100 class Clip : public ListItem<Clip> {
103 int votes, index, groups, cycle, muted;
104 double start, end, best;
106 Clip(int clip_id, double start, double end, int index);
110 class Clips : public List<Clip> {
112 int pid, count, cycle;
114 Clip *locate(int id, double start, double end);
115 int get_clip(int idx, int &id, double &start, double &end);
116 virtual Clip *new_clip(int clip_id, double start, double end, int index);
117 int check(int clip_id, double start, double end, int group, double err);
118 int save(FileXML &xml);
119 int load(FileXML &xml);
124 class Snip : public Clip {
126 ArrayList<double> weights;
127 ArrayList<double> positions;
129 Snip(int clip_id, double start, double end, int index);
133 class Snips : public Clips {
135 Clip *new_clip(int clip_id, double start, double end, int index);
146 uint8_t frm[SFRM_SZ];
147 double position, error_limit;
148 int lid, nid, distance, group_mask;
149 double fmean, fsd, fcx, fcy, fmoment;
150 int64_t lerr, pixlmt;
151 Db::pgRef clip_id_loc;
153 int get_key(Clips *clips, Db::rKey &prev_rkey, Db::rKey &next_rkey);
154 int64_t key_compare(Clips *clips, Db::ObjectLoc &loc);
155 static double mean(uint8_t *dat, int n, int stride=1);
156 static double variance(uint8_t *dat, double mn, int n, int stride=1);
157 static double std_dev(uint8_t *dat, double mn, int n, int stride=1) {
158 return sqrt(variance(dat, mn, n, stride));
160 static double centroid(uint8_t *dat, int n, int stride=1);
161 static void centroid(uint8_t *dat, int w, int h, double &xx, double &yy);
162 static void deviation(uint8_t *a, uint8_t *b, int sz, int margin,
163 double &dev, int &ofs, int stride=1);
164 static int64_t cmpr(uint8_t *ap, uint8_t *bp, int sz);
165 static int64_t diff(uint8_t *a, uint8_t *b, int w, int h, int dx, int dy, int bias);
166 static void fit(int *dat, int n, double &a, double &b);
167 static void eq(uint8_t *sp, uint8_t *dp, int len);
168 static void eq(uint8_t *p, int len) { eq(p, p, len); }
171 int openDb(int rw=0);
172 int resetDb(int rw=0);
176 int attachDb(int rw=0);
181 static void hist_eq(uint8_t *dp, int len);
182 static void scale(uint8_t *idata,int iw,int ih,int rx,int ry,int rw,int rh,
183 uint8_t *odata,int ow,int oh,int sx,int sy,int sw,int sh);
184 int new_clip_set(const char *title, const char *asset_path, double position,
185 double framerate, int frames, int prefix_size, int suffix_size,
186 int64_t creation_time, int64_t system_time);
187 int new_clip_view(int clip_id, int64_t access_time);
188 int access_clip(int clip_id, int64_t access_time=0);
189 int del_clip_set(int clip_id);
190 int new_frame(int clip_id, uint8_t *dat, int no, int group, double offset);
191 int get_timeline_by_frame_id(int fid);
192 int get_timelines(int frame_id);
193 int next_timelines();
194 int get_sequences(int clip_id, int seq_no=0);
195 int next_sequences();
196 int get_image(int id, uint8_t *dat, int &w, int &h);
197 int get_frame_key(uint8_t *dat, int &fid,
198 Clips *clips=0, double pos=0, int mask=~0);
199 int get_media_key(uint8_t *key, int &fid, int dist, double errlmt,
200 Clips *clips=0, double pos=0, int mask=~0);
201 int add_timelines(Clips *clips, int fid, double err);
202 // clip_set accessors
205 int clips_first_id();
207 const char *clip_title();
208 const char *clip_path();
209 double clip_position();
210 double clip_framerate();
211 double clip_average_weight();
212 void clip_average_weight(double avg_wt);
213 double clip_length();
215 int clip_prefix_size();
216 int clip_suffix_size();
218 double *clip_weights();
219 int64_t clip_creation_time();
220 int64_t clip_system_time();
222 // timeline accessors
223 int timeline_id(int id);
225 int timeline_clip_id();
226 int timeline_sequence_no();
227 int timeline_frame_id();
228 int timeline_group();
229 double timeline_offset();
231 // clip_views accessors
232 int views_id(int id);
234 int views_clip_id(int id);
236 int64_t views_access_time();
237 int views_access_count();