forked from jmerdich/aeo-light
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframe_view_gl.h
214 lines (181 loc) · 5.97 KB
/
frame_view_gl.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
//-----------------------------------------------------------------------------
// 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 FRAME_VIEW_GL_H
#define FRAME_VIEW_GL_H
#include "openglwindow.h"
#include <QtGui/QGuiApplication>
#include <QtGui/QMatrix4x4>
#include <QtGui/QOpenGLShaderProgram>
#include <QtGui/QScreen>
#include <QtCore/qmath.h>
//#include <QtOpenGL>
#include <QOpenGLFunctions_3_0>
#include <QOpenGLTexture>
#include <QSurfaceFormat>
#include <QContextMenuEvent>
#include "videoencoder.h"
typedef void (*FrameWindowCallbackFunction)(void *);
class Frame_Window : public OpenGLWindow
{
public:
Frame_Window(int width, int height);
~Frame_Window();
void initialize() Q_DECL_OVERRIDE;
void render() Q_DECL_OVERRIDE;
void CheckGLError(const char *fn, int line);
typedef struct {
int postion;
float value;
} overlap_match;
typedef struct {
GLuint video_output_fbo;
GLuint video_output_texture;
int width;
int height;
uint8_t * videobuffer;
} video_output;
void ParamUpdateCallback(FrameWindowCallbackFunction cb, void *userData);
//load frame from pointer
void load_frame_texture(FrameTexture *frame);
float GetAverage(GLfloat *, int ) ;
int GetMinLoc(GLfloat*, int ) ;
void GetBestMatchFromFloatArray(GLfloat*, int , int ,overlap_match &) ;
float GetMin(GLfloat* dArray, int iSize) ;
void PrepareRecording(int numsamples) ;
void ProcessRecording(int numsamples);
void DestroyRecording( );
float **GetRecording() const { return FileRealBuffer; }
void PrepareVideoOutput(FrameTexture *frame) ;
float GetMax(GLfloat* dArray, int iSize) ;
void read_frame_texture(FrameTexture *frame);
float *GetCalibrationMask();
void SetCalibrationMask(const float *mask);
void update_parameters();// update gpu variables and rerender
video_output vo;
// working data
float * *FileRealBuffer;
// view parameters
float WFMzoom; // waveform zoom amount
float calval;
float o_color;
float currstart;
float rendermode;
float lift,gamma,gain;
float threshold,blur;
float stereo;
bool thresh;
int input_w;
int input_h;
bool trackonly;
int bestloc;
int lowloc;
bool negative;
float overlap_target; //0=sound 1= picture 2 = both
bool desaturate;
bool is_preload;
bool is_calc;
bool is_calculating;
int samplesperframe;
int samplesperframe_file;
overlap_match bestmatch;
overlap_match currmatch;
overlap_match * match_array;
bool cal_enabled;
int cal_points;
bool is_caling;
std::vector <float> sound_prev;
std::vector <float> sound_curr;
int channels ;
float* audio_sample_buffer;
float* audio_compare_buffer;
GLfloat bounds[4]; // boundry of track area 4 elements x1,x2,y1,y2
GLfloat overlap[4]; // used to compute overlap and hold translation numbers: y1_start, y_size, translate_Y,window,Y;
float * height_avg;
float h_avg;
float * match_avf;
GLfloat pixbounds[2];
int match_inc;
int height_inc;
bool overlapshow;
bool is_rendering;
bool is_debug;
bool is_videooutput;
int overrideOverlap;
float fps;
unsigned long duration; // milliseconds
unsigned int bit_depth;
unsigned int sampling_rate;
bool clear_cal;
QTextStream *logger;
const char **currentOperation;
private:
void mouseEvent(QMouseEvent *mouse);
void mouseMoveEvent(QMouseEvent *m) Q_DECL_OVERRIDE { mouseEvent(m); };
void mousePressEvent(QMouseEvent *m) Q_DECL_OVERRIDE { mouseEvent(m); };
void mouseReleaseEvent(QMouseEvent *m) Q_DECL_OVERRIDE;
FrameWindowCallbackFunction paramUpdateCB;
void *paramUpdateUserData;
int samplepointer;
GLuint loadShader(GLenum type, const char *source);
void gen_tex_bufs(); //generation of textures and buffers
bool new_frame; //is a new frame from seq
void CopyFrameBuffer(GLuint fbo, int width, int height);
GLenum *audio_draw_buffers;
GLuint audio_pbo;
GLuint m_posAttr; //vertex buffer
GLuint m_texAttr;
GLuint m_matrixUniform; //sizing matrix currently unused
GLuint m_inputsize_loc;
GLuint m_rendermode_loc;
GLuint m_manipcontrol_loc; //thresh,threshold amount, blur variable
GLuint m_show_loc;
GLuint m_overlap_target_loc;
GLuint m_neg_loc;
GLuint m_overlap_loc;
GLuint stereo_loc;
GLuint pix_bounds_loc;
GLuint dminmax_loc;
GLuint m_colorcontrol_loc;//test uniform varaiable
GLuint m_bounds_loc; //location of bounds uniform
GLuint m_calcontrol_loc;
GLuint m_overlapshow_loc;
GLuint frame_texture; //image frame texture used as input
GLuint adj_frame_fbo; //render fbo writes to adj frame texture
GLuint adj_frame_texture; //render with pixel/image adjustments
GLuint prev_adj_frame_tex;
//audio frame buffer object: audio textures attached as draw buffers.
GLuint audio_fbo;
GLuint audio_file_fbo;
GLuint audio_RGB_texture; //render texture audio rgb for screen display
GLuint prev_audio_RGB_texture;
GLuint overlap_compare_audio_texture;
GLuint overlaps_audio_texture;
GLuint output_audio_texture;
GLuint audio_float_texture; //render texture audio floating point
GLuint audio_int_texture; //render texture audio integer tbd-16bit or 32bit?
GLuint cal_audio_texture;
QOpenGLShaderProgram *m_program; //gpu opengl executable
int m_frame;
QOpenGLFunctions_3_0 OGL_Fun;
};
#endif