1 #if defined(__i386__) || defined(__x86_64__)
2 #if defined (__linux__)
3 #ifndef _COMMERCIALS_H_
4 #define _COMMERCIALS_H_
8 #include "bcprogress.h"
10 #include "commercials.inc"
11 #include "condition.inc"
18 #include "mwindow.inc"
22 #include "filexml.inc"
25 class Commercials : public Garbage
31 int64_t frame_start, frame_total;
33 ArrayList<double> weights;
34 ArrayList<double> offsets;
35 ArrayList<Clips*> tracks;
38 ScanStatus *scan_status;
39 int update_cut_info(int trk, double position);
40 int update_caption(int trk, int edt, const char *path);
41 int update_status(int clip, double start, double end);
43 int new_clip(const char *title, int frames, double framerate);
44 Clips *find_clips(int pid);
45 int put_weight(VFrame *frame, int no);
46 int put_frame(VFrame *frame, int no, int group, double offset);
47 int skim_weights(int track, double position, double iframerate, int iframes);
48 double abs_err(Snip *snip, double *ap, int j, int len, double iframerate);
49 double abs_err(double *ap, int len, double iframerate);
50 int skim_weight(int track);
51 static int skim_weight(void *vp, int track);
62 int transaction() { return mdb->transaction(); }
63 int attachDb(int rw=0);
66 int put_clip(File *file, int track, double position, double length);
67 int get_frame(File *file, int pid, double position,
68 uint8_t *tp, int mw, int mh, int ww, int hh);
69 static double frame_weight(uint8_t *tdat, int rowsz, int width, int height);
70 int skim_frame(Snips *snips, uint8_t *dat, double position);
71 int verify_snip(Snip *snip, double weight, double position);
72 int mute_audio(Clip *clip);
74 int test_clip(int clip_id, int track, double position, double &pos);
75 int verify_clip(int clip_id, int track, double position, double &pos);
76 int write_ads(const char *filename);
77 int read_ads(const char *filename);
79 int verify_edit(Track *track, Edit *edit, double start, double end);
80 Edit * cut_edit(Track *track, Edit *edit, int64_t clip_start, int64_t clip_end);
81 int scan_audio(int vstream, double start, double end);
84 int scan_asset(Asset *asset, Track *vtrack, Edit *edit);
85 int scan_clips(Track *vtrack, Edit *edit);
86 int get_image(int id, uint8_t *dat, int &w, int &h);
87 int get_clip_seq_no(int clip_id, int &seq_no, double &offset, int &frame_id);
88 MediaDb *media_db() { return mdb; }
90 Commercials(MWindow *mwindow);
94 class ScanStatusBar : public BC_ProgressBar
98 int update(int64_t position) {
99 if( --tick >= 0 ) return 0;
101 return BC_ProgressBar::update(position);
103 int update_length(int64_t length) {
104 tick = limit = length / 100;
105 return BC_ProgressBar::update_length(length);
107 ScanStatusBar(int x, int y, int w, int64_t length, int do_text = 1) :
108 BC_ProgressBar(x, y, w, length, do_text) {
109 tick = limit = length / 100;
114 class ScanStatusGUI : public BC_Window
116 ScanStatus *sswindow;
119 ScanStatusBar **bars;
120 friend class ScanStatus;
122 ScanStatusGUI(ScanStatus *sswindow, int x, int y, int nlines, int nbars);
125 void create_objects(const char *text);
128 class ScanStatus : public Thread
134 Commercials *commercials;
137 ScanStatus(Commercials *commercials, int x, int y,
138 int nlines, int nbars, int &status, const char *text);
141 int update_length(int i, int64_t length);
142 int update_position(int i, int64_t position);
143 int update_text(int i, const char *text);
147 class SdbPacket : public ListItem<SdbPacket>
150 enum sdb_packet_type { sdb_none, sdb_skim_frame, } type;
151 SkimDbThread *thread;
153 virtual void run() = 0;
155 SdbPacket(sdb_packet_type ty, SkimDbThread *tp) : type(ty), thread(tp) {}
159 class SdbPacketQueue : public List<SdbPacket>, public Mutex
162 SdbPacket *get_packet();
163 void put_packet(SdbPacket *p);
166 class SdbSkimFrame : public SdbPacket
172 uint8_t dat[SFRM_SZ];
174 void load(int pid,int64_t framenum,double framerate,
175 uint8_t *idata,int mw,int mh,int iw,int ih);
178 SdbSkimFrame(SkimDbThread *t) : SdbPacket(sdb_skim_frame, t) {}
183 class SkimDbThread : public Thread
185 SdbPacketQueue active_packets;
186 Condition *input_lock;
187 friend class SdbSkimFrame;
190 SdbPacketQueue skim_frames;
191 Commercials *commercials;
194 void start(Commercials *commercials);
197 void put_packet(SdbPacket *p);
198 int skim(int pid,int64_t framenum,double framerate,
199 uint8_t *idata,int mw,int mh,int iw,int ih);