1 #if defined(__i386__) || defined(__x86_64__)
8 #include "bcwindowbase.inc"
11 #include "../db/tdb.h"
16 #include <semaphore.h>
21 void write_pbm(uint8_t *tp, int w, int h, const char *fmt, ...);
22 void write_pgm(uint8_t *tp, int w, int h, const char *fmt, ...);
23 void pbm_diff(uint8_t *ap, uint8_t *bp, int w, int h, const char *fmt, ...);
27 int rx, ry, rw, rh, iw, ih;
28 int ix0, ix1, iy0, iy1, rsh;
29 double xf0, xf1, yf0, yf1, pw;
31 uint8_t *row(int y) { return idat + (iw<<rsh) * (y>>rsh); }
33 inline double scalex(uint8_t *rp, double v, double yw) {
35 double vv = xf0 * *rp++;
36 int iv = 0; while( ++x < ix1 ) iv += *rp++;
41 inline double scalexy() {
44 if( (yw = pw * yf0) > 0 ) v = scalex(row(y), v, yw);
45 while( ++y < iy1 ) v = scalex(row(y), v, pw);
46 if( (yw = pw * yf1) > 0 ) v = scalex(row(y), v, yw);
50 Scale(uint8_t *idata, int type, int iw, int ih, int rx, int ry, int rw, int rh) {
52 this->idat = idata + ry*iw + rx;
53 this->iw = iw; this->ih = ih;
54 this->rx = rx; this->ry = ry;
55 this->rw = rw; this->rh = rh;
57 void scale(uint8_t *odata, int ow, int oh, int sx, int sy, int sw, int sh);
62 DEL_START, // always the first mark
63 DEL_MARK, // boundary between cur/next media deletion
64 DEL_SKIP, // skip media in current deletion region
65 DEL_OOPS, // ignore previous mark
69 // dele: n. A sign indicating that something is to be removed from <media>
71 class Dele : public ListItem<Dele>
77 Dele(double t, int a) : time(t), action(a) {}
81 class Deletions: public List<Dele>
83 int save(FileXML &xml);
84 int load(FileXML &xml);
87 char filepath[BCTEXTLEN];
88 const char *file_path() { return filepath; }
89 bool empty() { return !first; }
91 int write_dels(const char *filename);
92 static Deletions *read_dels(const char *filename);
94 Deletions(int pid, const char *fn);
99 class Clip : public ListItem<Clip> {
102 int votes, index, groups, cycle, muted;
103 double start, end, best;
105 Clip(int clip_id, double start, double end, int index);
109 class Clips : public List<Clip> {
111 int pid, count, cycle;
113 Clip *locate(int id, double start, double end);
114 int get_clip(int idx, int &id, double &start, double &end);
115 virtual Clip *new_clip(int clip_id, double start, double end, int index);
116 int check(int clip_id, double start, double end, int group, double err);
117 int save(FileXML &xml);
118 int load(FileXML &xml);
123 class Snip : public Clip {
125 ArrayList<double> weights;
126 ArrayList<double> positions;
128 Snip(int clip_id, double start, double end, int index);
132 class Snips : public Clips {
134 Clip *new_clip(int clip_id, double start, double end, int index);
145 uint8_t frm[SFRM_SZ];
146 double position, error_limit;
147 int lid, nid, distance, group_mask;
148 double fmean, fsd, fcx, fcy, fmoment;
149 int64_t lerr, pixlmt;
150 Db::pgRef clip_id_loc;
152 int get_key(Clips *clips, Db::rKey &prev_rkey, Db::rKey &next_rkey);
153 int64_t key_compare(Clips *clips, Db::ObjectLoc &loc);
154 static double mean(uint8_t *dat, int n, int stride=1);
155 static double variance(uint8_t *dat, double mn, int n, int stride=1);
156 static double std_dev(uint8_t *dat, double mn, int n, int stride=1) {
157 return sqrt(variance(dat, mn, n, stride));
159 static double centroid(uint8_t *dat, int n, int stride=1);
160 static void centroid(uint8_t *dat, int w, int h, double &xx, double &yy);
161 static void deviation(uint8_t *a, uint8_t *b, int sz, int margin,
162 double &dev, int &ofs, int stride=1);
163 static int64_t cmpr(uint8_t *ap, uint8_t *bp, int sz);
164 static int64_t diff(uint8_t *a, uint8_t *b, int w, int h, int dx, int dy, int bias);
165 static void fit(int *dat, int n, double &a, double &b);
166 static void eq(uint8_t *sp, uint8_t *dp, int len);
167 static void eq(uint8_t *p, int len) { eq(p, p, len); }
170 int openDb(int rw=0);
171 int resetDb(int rw=0);
175 int attachDb(int rw=0);
180 static void hist_eq(uint8_t *dp, int len);
181 static void scale(uint8_t *idata,int iw,int ih,int rx,int ry,int rw,int rh,
182 uint8_t *odata,int ow,int oh,int sx,int sy,int sw,int sh);
183 int new_clip_set(const char *title, const char *asset_path, double position,
184 double framerate, int frames, int prefix_size, int suffix_size,
185 int64_t creation_time, int64_t system_time);
186 int new_clip_view(int clip_id, int64_t access_time);
187 int access_clip(int clip_id, int64_t access_time=0);
188 int del_clip_set(int clip_id);
189 int new_frame(int clip_id, uint8_t *dat, int no, int group, double offset);
190 int get_timeline_by_frame_id(int fid);
191 int get_timelines(int frame_id);
192 int next_timelines();
193 int get_sequences(int clip_id, int seq_no=0);
194 int next_sequences();
195 int get_image(int id, uint8_t *dat, int &w, int &h);
196 int get_frame_key(uint8_t *dat, int &fid,
197 Clips *clips=0, double pos=0, int mask=~0);
198 int get_media_key(uint8_t *key, int &fid, int dist, double errlmt,
199 Clips *clips=0, double pos=0, int mask=~0);
200 int add_timelines(Clips *clips, int fid, double err);
201 // clip_set accessors
204 int clips_first_id();
206 const char *clip_title();
207 const char *clip_path();
208 double clip_position();
209 double clip_framerate();
210 double clip_average_weight();
211 void clip_average_weight(double avg_wt);
212 double clip_length();
214 int clip_prefix_size();
215 int clip_suffix_size();
217 double *clip_weights();
218 int64_t clip_creation_time();
219 int64_t clip_system_time();
221 // timeline accessors
222 int timeline_id(int id);
224 int timeline_clip_id();
225 int timeline_sequence_no();
226 int timeline_frame_id();
227 int timeline_group();
228 double timeline_offset();
230 // clip_views accessors
231 int views_id(int id);
233 int views_clip_id(int id);
235 int64_t views_access_time();
236 int views_access_count();