1 #if defined(__i386__) || defined(__x86_64__)
2 #ifndef _COMMERCIALS_H_
3 #define _COMMERCIALS_H_
7 #include "bcprogress.h"
9 #include "commercials.inc"
10 #include "condition.inc"
17 #include "mwindow.inc"
21 #include "filexml.inc"
24 class Commercials : public Garbage
30 int64_t frame_start, frame_total;
32 ArrayList<double> weights;
33 ArrayList<double> offsets;
34 ArrayList<Clips*> tracks;
37 ScanStatus *scan_status;
38 int update_cut_info(int trk, double position);
39 int update_caption(int trk, int edt, const char *path);
40 int update_status(int clip, double start, double end);
42 int new_clip(const char *title, int frames, double framerate);
43 Clips *find_clips(int pid);
44 int put_weight(VFrame *frame, int no);
45 int put_frame(VFrame *frame, int no, int group, double offset);
46 int skim_weights(int track, double position, double iframerate, int iframes);
47 double abs_err(Snip *snip, double *ap, int j, int len, double iframerate);
48 double abs_err(double *ap, int len, double iframerate);
49 int skim_weight(int track);
50 static int skim_weight(void *vp, int track);
61 int transaction() { return mdb->transaction(); }
62 int attachDb(int rw=0);
65 int put_clip(File *file, int track, double position, double length);
66 int get_frame(File *file, int pid, double position,
67 uint8_t *tp, int mw, int mh, int ww, int hh);
68 static double frame_weight(uint8_t *tdat, int rowsz, int width, int height);
69 int skim_frame(Snips *snips, uint8_t *dat, double position);
70 int verify_snip(Snip *snip, double weight, double position);
71 int mute_audio(Clip *clip);
73 int test_clip(int clip_id, int track, double position, double &pos);
74 int verify_clip(int clip_id, int track, double position, double &pos);
75 int write_ads(const char *filename);
76 int read_ads(const char *filename);
78 int verify_edit(Track *track, Edit *edit, double start, double end);
79 Edit * cut_edit(Track *track, Edit *edit, int64_t clip_start, int64_t clip_end);
80 int scan_audio(int vstream, double start, double end);
83 int scan_asset(Asset *asset, Track *vtrack, Edit *edit);
84 int scan_clips(Track *vtrack, Edit *edit);
85 int get_image(int id, uint8_t *dat, int &w, int &h);
86 int get_clip_seq_no(int clip_id, int &seq_no, double &offset, int &frame_id);
87 MediaDb *media_db() { return mdb; }
89 Commercials(MWindow *mwindow);
93 class ScanStatusBar : public BC_ProgressBar
97 int update(int64_t position) {
98 if( --tick >= 0 ) return 0;
100 return BC_ProgressBar::update(position);
102 int update_length(int64_t length) {
103 tick = limit = length / 100;
104 return BC_ProgressBar::update_length(length);
106 ScanStatusBar(int x, int y, int w, int64_t length, int do_text = 1) :
107 BC_ProgressBar(x, y, w, length, do_text) {
108 tick = limit = length / 100;
113 class ScanStatusGUI : public BC_Window
115 ScanStatus *sswindow;
118 ScanStatusBar **bars;
119 friend class ScanStatus;
121 ScanStatusGUI(ScanStatus *sswindow, int x, int y, int nlines, int nbars);
124 void create_objects(const char *text);
127 class ScanStatus : public Thread
133 Commercials *commercials;
136 ScanStatus(Commercials *commercials, int x, int y,
137 int nlines, int nbars, int &status, const char *text);
140 int update_length(int i, int64_t length);
141 int update_position(int i, int64_t position);
142 int update_text(int i, const char *text);
146 class SdbPacket : public ListItem<SdbPacket>
149 enum sdb_packet_type { sdb_none, sdb_skim_frame, } type;
150 SkimDbThread *thread;
152 virtual void run() = 0;
154 SdbPacket(sdb_packet_type ty, SkimDbThread *tp) : type(ty), thread(tp) {}
158 class SdbPacketQueue : public List<SdbPacket>, public Mutex
161 SdbPacket *get_packet();
162 void put_packet(SdbPacket *p);
165 class SdbSkimFrame : public SdbPacket
171 uint8_t dat[SFRM_SZ];
173 void load(int pid,int64_t framenum,double framerate,
174 uint8_t *idata,int mw,int mh,int iw,int ih);
177 SdbSkimFrame(SkimDbThread *t) : SdbPacket(sdb_skim_frame, t) {}
182 class SkimDbThread : public Thread
184 SdbPacketQueue active_packets;
185 Condition *input_lock;
186 friend class SdbSkimFrame;
189 SdbPacketQueue skim_frames;
190 Commercials *commercials;
193 void start(Commercials *commercials);
196 void put_packet(SdbPacket *p);
197 int skim(int pid,int64_t framenum,double framerate,
198 uint8_t *idata,int mw,int mh,int iw,int ih);