-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmainwindow.h
345 lines (286 loc) · 9.84 KB
/
mainwindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
//-----------------------------------------------------------------------------
// This file is part of AEO-Light
//
// Copyright (c) 2016 University of South Carolina
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// AEO-Light is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Funding for AEO-Light development was provided through a grant from the
// National Endowment for the Humanities
//-----------------------------------------------------------------------------
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QSound>
#include <QDate>
#include <QProgressDialog>
#include <vector>
#include <queue>
#include "frame_view_gl.h"
#include "readframedpx.h"
#include "project.h"
#include "metadata.h"
#include "videoencoder.h"
#define USE_MUX_HACK
// #define SAVE_CALIBRATION_MASK_IN_PROJECT
namespace Ui {
class MainWindow;
}
#define FPS_NTSC 0
#define FPS_24 1
#define FPS_25 2
#define FPS_FILM FPS_24
#define FPS_PAL FPS_25
#define EXTRACT_TIMER 0x01
#define EXTRACT_LOG 0x02
#define EXTRACT_NOTIFY 0x04
class ExtractedSound
{
public:
uint32_t frameIn;
uint32_t frameOut;
uint16_t bounds[2]; // left, right pixel columns
uint16_t pixBounds[2]; // left, right pixel columns
uint16_t framePitch[2]; // top, bottom pixel rows
uint16_t gamma; // [0,500]
uint16_t gain; // [0,500]
uint16_t sCurve; // [0,600]
uint8_t overlap; // as a percentage of height [0,100]
int8_t lift; // [-100,100]
int8_t blur; // [-100,100]
uint8_t fpsType;
bool useBounds;
bool usePixBounds;
bool useSCurve;
bool makeNegative;
bool makeGray;
QSound *sound;
int err;
ExtractedSound();
~ExtractedSound();
void Play() const;
bool operator ==(const ExtractedSound &ref) const;
operator bool() const { return (err==0); };
};
class ExtractTask
{
public:
ExtractedSound params;
QString source;
SourceFormat srcFormat;
QString output;
MetaData meta;
};
#ifdef USE_MUX_HACK
//----------------------------------------------------------------------------
//---------------------- MUX.C -----------------------------------------------
//----------------------------------------------------------------------------
// a wrapper around a single output AVStream
class OutputStream {
public:
int requestedWidth;
int requestedHeight;
int requestedSamplingRate;
int requestedSamplesPerFrame;
int requestedTimeBase;
AVStream *st;
/* pts of the next frame that will be generated */
int64_t next_pts;
int samples_count;
AVFrame *frame;
AVFrame *tmp_frame;
float t, tincr, tincr2;
struct SwsContext *sws_ctx;
struct SwrContext *swr_ctx;
};
#endif
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
void Render_Frame();
Project scan;
std::vector< ExtractedSound > samplesPlayed;
std::vector< ExtractTask > extractQueue;
int adminWidth;
void GUI_Params_Update();
static void GUI_Params_Update_Static(void *userData)
{ static_cast<MainWindow *>(userData)->GUI_Params_Update(); }
ExtractedSound ExtractionParamsFromGUI();
void ExtractionParametersToGUI(const ExtractedSound ¶ms);
void PlaySample(int index);
private slots:
void LicenseAgreement();
bool WriteAudioToFile(const char *fn, const char *videoFn,
long firstFrame, long numFrames);
void DeleteTempSoundFile(void);
void on_changeButton_clicked();
void on_sourceButton_clicked();
bool saveproject(QString);
bool saveproject(QTextStream &stream);
void SaveDefaultsSoundtrack();
void SaveDefaultsImage();
void SaveDefaultsAudio();
void LoadDefaults();
bool LoadProjectSource(QString fn);
bool LoadProjectSettings(QString fn);
bool OpenProject(QString fn);
void OpenStartingProject();
bool NewSource(QString fn, SourceFormat ft=SOURCE_UNKNOWN);
bool Load_Frame_Texture(int);
void GPU_Params_Update(bool renderyes);
void UpdateQueueWidgets(void);
QString Compute_Timecode_String(int position);
uint64_t ComputeTimeReference(int position, int samplingRate);
void on_leftSpinBox_valueChanged(int arg1);
void on_rightSpinBox_valueChanged(int arg1);
void on_MainWindow_destroyed();
void on_leftSlider_sliderMoved(int position);
void on_rightSlider_sliderMoved(int position);
void on_playSlider_sliderMoved(int position);
void on_markinButton_clicked();
void on_markoutButton_clicked();
void on_gammaSlider_valueChanged(int value);
void on_liftSlider_valueChanged(int value);
void on_gainSlider_valueChanged(int value);
void on_lift_resetButton_clicked();
void on_gamma_resetButton_clicked();
void on_gain_resetButton_clicked();
void on_thresh_resetButton_clicked();
void on_blur_resetButton_clicked();
void on_thresholdSlider_valueChanged(int value);
void on_blurSlider_valueChanged(int value);
void on_negBox_clicked();
void on_threshBox_clicked();
void on_desatBox_clicked();
void on_overlapSlider_valueChanged(int value);
void on_framepitchstartSlider_valueChanged(int value);
void on_frame_numberSpinBox_valueChanged(int arg1);
void on_extractGLButton_clicked();
bool extractGL(QString filename, bool doTimer);
bool extractGL(bool doTimer) { return extractGL(QString(), doTimer); }
ExtractedSound Extract(QString filename, QString videoFilename,
long firstFrame, long numFrames, uint8_t flags=0);
#ifdef USE_SERIAL
void on_extractSerialButton_clicked();
void extractSerial(bool doTimer);
#endif // USE_SERIAL
void on_HeightCalculateBtn_clicked();
void on_FramePitchendSlider_valueChanged(int value);
void on_CalBtn_clicked();
void on_CalEnableCB_clicked();
void on_actionAcknowledgements_triggered();
void on_actionAbout_triggered();
void on_saveprojectButton_clicked();
void on_loadprojectButton_clicked();
void on_FramePitchendSlider_sliderMoved(int position);
void on_leftPixSlider_valueChanged(int value);
void on_rightPixSlider_valueChanged(int value);
void on_smoothingMethodComboBox_2_currentIndexChanged(int index);
void on_leftPixSlider_sliderMoved(int position);
void on_rightPixSlider_sliderMoved(int position);
void on_leftPixSpinBox_valueChanged(int arg1);
void on_rightPixSpinBox_valueChanged(int arg1);
void on_monostereo_PD_currentIndexChanged(int index);
void on_OverlapSoundtrackCheckBox_stateChanged(int arg1);
void on_OverlapPixCheckBox_stateChanged(int arg1);
void on_actionShow_Soundtrack_Only_triggered();
void on_actionWaveform_Zoom_triggered();
void on_actionShow_Overlap_triggered();
void on_frameInSpinBox_valueChanged(int arg1);
void on_cancelButton_clicked();
void on_waveformZoomCheckBox_clicked(bool checked);
void on_showOverlapCheckBox_clicked(bool checked);
void on_showSoundtrackOnlyCheckBox_clicked(bool checked);
void on_actionOpen_Source_triggered();
void on_actionLoad_Settings_triggered();
void on_actionSave_Settings_triggered();
void on_actionQuit_triggered();
void on_frame_numberSpinBox_editingFinished();
void on_frameOutSpinBox_valueChanged(int arg1);
void on_playSampleButton_clicked();
void on_playSample1Button_clicked();
void on_playSample2Button_clicked();
void on_playSample3Button_clicked();
void on_playSample4Button_clicked();
void on_loadSample1Button_clicked();
void on_loadSample2Button_clicked();
void on_loadSample3Button_clicked();
void on_loadSample4Button_clicked();
void on_enqueueButton_clicked();
void on_queueDelete1Button_clicked();
void on_queueDelete2Button_clicked();
void on_queueDelete3Button_clicked();
void on_queueDelete4Button_clicked();
void on_queueDelete5Button_clicked();
void on_loadSettingsButton_clicked();
void on_queueExtractButton_clicked();
void on_soundtrackDefaultsButton_clicked();
void on_imageDefaultsButton_clicked();
void on_extractDefaultsButton_clicked();
void on_actionPreferences_triggered();
void on_actionReport_or_track_an_issue_triggered();
void on_OverlapPixCheckBox_clicked(bool checked);
private:
QString startingProjectFilename;
Ui::MainWindow *ui;
Frame_Window * frame_window = NULL;
QTextStream log;
bool paramCopyLock;
bool requestCancel;
QString prevProjectDir;
QString prevExportDir;
MetaData *currentMeta;
FrameTexture *currentFrameTexture;
FrameTexture *outputFrameTexture;
bool isVideoMuxingRisky;
public:
void SetStartingProject(QString fn) { startingProjectFilename = fn; };
int MaxFrequency() const;
ExtractedSound ExtractionParameters();
QString Version();
QTextStream &Log();
void LogSettings();
void LogClose()
{ if(log.device() && log.device()->isOpen()) log.device()->close(); }
#ifdef USE_MUX_HACK
private:
long encStartFrame;
long encNumFrames;
long encCurFrame;
long encVideoSkip; // discard scanned video frames from start
long encAudioSkip; // discard extracted audio frame snippets from start
long encVideoPad; // add synthetic (black) video frames at start
long encAudioPad; // add synthetic (silent) audio frame snippets at start
long encVideoBufSize;
AVFrame *encRGBFrame;
AVFrame *encS16Frame;
std::queue< uint8_t* > encVideoQueue;
int64_t encAudioLen; // total number of samples rendered so far
int64_t encAudioNextPts;
bool EnqueueNextFrame();
uint8_t *GetVideoFromQueue();
AVFrame *GetAudioFromQueue();
AVFrame *get_audio_frame(OutputStream *ost);
int write_audio_frame(AVFormatContext *oc, OutputStream *ost);
AVFrame *get_video_frame(OutputStream *ost);
int write_video_frame(AVFormatContext *oc, OutputStream *ost);
int MuxMain(const char *fn_arg, long firstFrame, long numFrames,
long vidFrameOffset, QProgressDialog &progress);
#endif
};
#endif // MAINWINDOW_H