Debian Codegraph @

src/dvbcut.h

raw
1 /* dvbcut
2 Copyright (c) 2005 Sven Over <[email protected]>
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 /* $Id$ */
20
21 #ifndef _DVBCUT_DVBCUT_H
22 #define _DVBCUT_DVBCUT_H
23
24 #if !defined(DVBCUT_VERSION)
25 #define DVBCUT_VERSION "git"
26 #endif
27
28 #ifndef VERSION_STRING
29 #define VERSION_STRING "dvbcut-" DVBCUT_VERSION
30 #endif
31
32 #include <string>
33 #include <vector>
34 #include <list>
35 #include "mpgfile.h"
36 #include "ui_dvbcutbase.h"
37 #include "pts.h"
38 #include "eventlistitem.h"
39
40 class QProcess;
41 class imageprovider;
42
43 class dvbcut: public QMainWindow
44 {
45 Q_OBJECT
46
47 public:
48 static bool cache_friendly;
49
50 struct quick_picture_lookup_s
51 {
52 int startpicture;
53 pts_t startpts;
54 int stoppicture;
55 pts_t stoppts;
56 int outpicture;
57 pts_t outpts;
58
59 quick_picture_lookup_s(int _startpicture, pts_t _startpts, int _stoppicture, pts_t _stoppts, int _outpicture, pts_t _outpts) :
60 startpicture(_startpicture), startpts(_startpts), stoppicture(_stoppicture), stoppts(_stoppts), outpicture(_outpicture), outpts(_outpts)
61 {
62 }
63
64 struct cmp_picture
65 {
66 bool operator()(int lhs, const quick_picture_lookup_s &rhs) const
67 {
68 return lhs<rhs.startpicture;
69 }
70 };
71 struct cmp_outpicture
72 {
73 bool operator()(int lhs, const quick_picture_lookup_s &rhs) const
74 {
75 return lhs<rhs.outpicture;
76 }
77 };
78 };
79 typedef std::vector<quick_picture_lookup_s> quick_picture_lookup_t;
80
81 protected:
82 quick_picture_lookup_t quick_picture_lookup;
83 std::list<pts_t> chapterlist;
84
85 QMenu *audiotrackpopup,*recentfilespopup,*editconvertpopup;
86 QAction* audiotrackmenu;
87 inbuffer buf;
88 mpgfile *mpg;
89 int pictures;
90 int curpic;
91 double alpha;
92 pts_t firstpts;
93 int timeperframe;
94 bool showimage;
95 bool fine;
96 bool jogsliding;
97 int jogmiddlepic;
98 std::string prjfilen,idxfilen,expfilen;
99 QString picfilen;
100 std::list<std::string> mpgfilen;
101 QProcess *mplayer_process;
102 bool mplayer_success;
103 QString mplayer_out;
104 pts_t mplayer_curpts;
105 imageprovider *imgp;
106 int busy;
107 double viewscalefactor;
108 int currentaudiotrack;
109 bool nogui;
110 int exportformat;
111 bool start_bof;
112 bool stop_eof;
113 Ui::dvbcutbase* ui;
114
115 protected:
116 // QPixmap getpixmap(int picture, bool allgop=false);
117 void exportvideo(const char *fmt);
118 void addtorecentfiles(const std::list<std::string> &filenames, const std::string &idxfilename=std::string());
119 void setviewscalefactor(double factor);
120
121 // special event handling (mouse wheel)
122 bool eventFilter(QObject *watched, QEvent *e);
123
124 void update_time_display();
125 void update_quick_picture_lookup_table();
126
127 // QMessagebox interface
128 int question(const QString & caption, const QString & text);
129 int critical(const QString & caption, const QString & text);
130 int critical(const QString & caption, const std::string & text);
131
132 // filename handling
133 void make_canonical(std::string &filename);
134 void make_canonical(std::list<std::string> &filenames);
135
136 // generic event item adder
137 void addEventListItem(int pic, EventListItem::eventtype type);
138
139 // save given (or current) picture (or select the best from a given number of samples inside a range)
140 void snapshotSave(std::vector<int> piclist, int range=0, int samples=1);
141 int chooseBestPicture(int startpic, int range, int smaples);
142
143 void gotoFrame(int frameno);
144 int getPreviousStopEvent(int picture);
145
146 protected slots:
147 virtual void helpAboutAction_activated();
148 virtual void helpContentAction_activated();
149
150 public:
151 ~dvbcut();
152 dvbcut();
153 void open(std::list<std::string> filenames=std::list<std::string>(),
154 std::string idxfilename=std::string(), std::string expfilename=std::string());
155 void setbusy(bool b=true);
156 void batchmode(bool b=true) { nogui = b; }
157 void exportoptions(int format=0, bool bof=true, bool eof=true) { exportformat = format; start_bof=bof; stop_eof=eof; }
158 // static dvbcut *New(std::string filename=std::string(), std::string idxfilename=std::string());
159 void addStartStopItems(std::vector<int>, int option=0);
160 int getTimePerFrame() { return timeperframe>0 && timeperframe<5000 ? timeperframe : 3003; };
161
162 enum editconvertpop_actions {
163 act_start_stop = 0,
164 act_stop_start,
165 act_4_3,
166 act_16_9
167 };
168
169 public slots:
170 virtual void fileNew();
171 virtual void fileOpen();
172 virtual void fileSaveAs();
173 virtual void fileSave();
174 virtual void snapshotSave();
175 virtual void chapterSnapshotsSave();
176 virtual void fileExport();
177 virtual void fileClose();
178 virtual void editBookmark();
179 virtual void editChapter();
180 virtual void editStop();
181 virtual void editStart();
182 virtual void editAutoChapters();
183 virtual void editSuggest();
184 virtual void editImport();
185 virtual void editConvert(QAction* a);
186 virtual void editConvert(editconvertpop_actions options);
187 virtual void abouttoshoweditconvert();
188 virtual void viewDifference();
189 virtual void searchDuplicate();
190 virtual void viewUnscaled();
191 virtual void viewNormal();
192 virtual void zoomIn();
193 virtual void zoomOut();
194 virtual void viewFullSize();
195 virtual void viewHalfSize();
196 virtual void viewQuarterSize();
197 virtual void viewCustomSize();
198 virtual void playAudio2();
199 virtual void playAudio1();
200 virtual void playStop();
201 virtual void playPlay();
202 virtual void jogsliderreleased();
203 virtual void jogslidervalue(int);
204 virtual void linslidervalue(int);
205 virtual void doubleclickedeventlist(QListWidgetItem *lbi);
206 virtual void eventlistcontextmenu(const QPoint &);
207 virtual void mplayer_exited();
208 virtual void mplayer_readstdout();
209 virtual void clickedgo();
210 virtual void clickedgo2();
211 virtual void updateimagedisplay();
212 virtual void audiotrackchosen(QAction* a);
213 virtual void loadrecentfile(QAction* a);
214 virtual void abouttoshowrecentfiles();
215 virtual void wheelEvent(QWheelEvent* event);
216 };
217
218 #endif