1 #ifndef _COMMERCIALS_H_
2 #define _COMMERCIALS_H_
6 #include "bcprogress.h"
8 #include "commercials.inc"
9 #include "condition.inc"
16 #include "mwindow.inc"
20 #include "filexml.inc"
23 class Commercials : public Garbage
29 int64_t frame_start, frame_total;
31 ArrayList<double> weights;
32 ArrayList<double> offsets;
33 ArrayList<Clips*> tracks;
36 ScanStatus *scan_status;
37 int update_cut_info(int trk, double position);
38 int update_caption(int trk, int edt, const char *path);
39 int update_status(int clip, double start, double end);
41 int new_clip(const char *title, int frames, double framerate);
42 Clips *find_clips(int pid);
43 int put_weight(VFrame *frame, int no);
44 int put_frame(VFrame *frame, int no, int group, double offset);
45 int skim_weights(int track, double position, double iframerate, int iframes);
46 double abs_err(Snip *snip, double *ap, int j, int len, double iframerate);
47 double abs_err(double *ap, int len, double iframerate);
48 int skim_weight(int track);
49 static int skim_weight(void *vp, int track);
60 int transaction() { return mdb->transaction(); }
61 int attachDb(int rw=0);
64 int put_clip(File *file, int track, double position, double length);
65 int get_frame(File *file, int pid, double position,
66 uint8_t *tp, int mw, int mh, int ww, int hh);
67 static double frame_weight(uint8_t *tdat, int rowsz, int width, int height);
68 int skim_frame(Snips *snips, uint8_t *dat, double position);
69 int verify_snip(Snip *snip, double weight, double position);
70 int mute_audio(Clip *clip);
72 int test_clip(int clip_id, int track, double position, double &pos);
73 int verify_clip(int clip_id, int track, double position, double &pos);
74 int write_ads(const char *filename);
75 int read_ads(const char *filename);
77 int verify_edit(Track *track, Edit *edit, double start, double end);
78 Edit * cut_edit(Track *track, Edit *edit, int64_t clip_start, int64_t clip_end);
79 int scan_audio(int vstream, double start, double end);
82 int scan_asset(Asset *asset, Track *vtrack, Edit *edit);
83 int scan_clips(Track *vtrack, Edit *edit);
84 int get_image(int id, uint8_t *dat, int &w, int &h);
85 int get_clip_seq_no(int clip_id, int &seq_no, double &offset, int &frame_id);
86 MediaDb *media_db() { return mdb; }
88 Commercials(MWindow *mwindow);
92 class ScanStatusBar : public BC_ProgressBar
96 int update(int64_t position) {
97 if( --tick >= 0 ) return 0;
99 return BC_ProgressBar::update(position);
101 int update_length(int64_t length) {
102 tick = limit = length / 100;
103 return BC_ProgressBar::update_length(length);
105 ScanStatusBar(int x, int y, int w, int64_t length, int do_text = 1) :
106 BC_ProgressBar(x, y, w, length, do_text) {
107 tick = limit = length / 100;
112 class ScanStatusGUI : public BC_Window
114 ScanStatus *sswindow;
117 ScanStatusBar **bars;
118 friend class ScanStatus;
120 ScanStatusGUI(ScanStatus *sswindow, int x, int y, int nlines, int nbars);
123 void create_objects(const char *text);
126 class ScanStatus : public Thread
132 Commercials *commercials;
135 ScanStatus(Commercials *commercials, int x, int y,
136 int nlines, int nbars, int &status, const char *text);
139 int update_length(int i, int64_t length);
140 int update_position(int i, int64_t position);
141 int update_text(int i, const char *text);
145 class SdbPacket : public ListItem<SdbPacket>
148 enum sdb_packet_type { sdb_none, sdb_skim_frame, } type;
149 SkimDbThread *thread;
151 virtual void run() = 0;
153 SdbPacket(sdb_packet_type ty, SkimDbThread *tp) : type(ty), thread(tp) {}
157 class SdbPacketQueue : public List<SdbPacket>, public Mutex
160 SdbPacket *get_packet();
161 void put_packet(SdbPacket *p);
164 class SdbSkimFrame : public SdbPacket
170 uint8_t dat[SFRM_SZ];
172 void load(int pid,int64_t framenum,double framerate,
173 uint8_t *idata,int mw,int mh,int iw,int ih);
176 SdbSkimFrame(SkimDbThread *t) : SdbPacket(sdb_skim_frame, t) {}
181 class SkimDbThread : public Thread
183 SdbPacketQueue active_packets;
184 Condition *input_lock;
185 friend class SdbSkimFrame;
188 SdbPacketQueue skim_frames;
189 Commercials *commercials;
192 void start(Commercials *commercials);
195 void put_packet(SdbPacket *p);
196 int skim(int pid,int64_t framenum,double framerate,
197 uint8_t *idata,int mw,int mh,int iw,int ih);