thumbnail/waveform generation

This commit is contained in:
itsmattkc
2018-06-15 20:17:05 -07:00
parent f8ce6c08f8
commit dc8d4728fc
29 changed files with 849 additions and 479 deletions
+54 -54
View File
@@ -35,13 +35,13 @@ void ViewerWidget::retry() {
}
void ViewerWidget::initializeGL() {
initializeOpenGLFunctions();
initializeOpenGLFunctions();
glClearColor(0, 0, 0, 1);
glMatrixMode(GL_PROJECTION);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearColor(0, 0, 0, 1);
glMatrixMode(GL_PROJECTION);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
//void ViewerWidget::resizeGL(int w, int h)
@@ -54,63 +54,63 @@ void ViewerWidget::paintEvent(QPaintEvent *e) {
void ViewerWidget::paintGL()
{
if (multithreaded) retry_timer.stop();
if (multithreaded) retry_timer.stop();
glClear(GL_COLOR_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT);
long playhead = panel_timeline->playhead;
long playhead = panel_timeline->playhead;
handle_media(sequence, playhead, multithreaded);
texture_failed = false;
texture_failed = false;
bool render_audio = (panel_timeline->playing || force_audio);
cc_lock.lock();
cc_lock.lock();
for (int i=0;i<current_clips.size();i++) {
Clip* c = current_clips.at(i);
for (int i=0;i<current_clips.size();i++) {
Clip* c = current_clips.at(i);
if (!c->open) {
qDebug() << "[WARNING] Tried to display clip" << i << "but it's closed";
texture_failed = true;
} else if (is_clip_active(c, playhead)) {
if (c->stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
// start preparing cache
get_clip_frame(c, playhead);
if (!c->open) {
qDebug() << "[WARNING] Tried to display clip" << i << "but it's closed";
texture_failed = true;
} else if (is_clip_active(c, playhead)) {
if (c->stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
// start preparing cache
get_clip_frame(c, playhead);
if (c->texture == NULL) {
qDebug() << "[WARNING] Texture hasn't been created yet";
texture_failed = true;
} else if (playhead >= c->timeline_in) {
glLoadIdentity();
int half_width = c->sequence->width/2;
int half_height = c->sequence->height/2;
glOrtho(-half_width, half_width, half_height,- half_height, -1, 1);
if (c->texture == NULL) {
qDebug() << "[WARNING] Texture hasn't been created yet";
texture_failed = true;
} else if (playhead >= c->timeline_in) {
glLoadIdentity();
int half_width = c->sequence->width/2;
int half_height = c->sequence->height/2;
glOrtho(-half_width, half_width, half_height,- half_height, -1, 1);
int anchor_x = c->media_stream->video_width/2;
int anchor_y = c->media_stream->video_height/2;
// perform all transform effects
// perform all transform effects
for (int j=0;j<c->effects.size();j++) {
c->effects.at(j)->process_gl(&anchor_x, &anchor_y);
}
}
int anchor_right = c->media_stream->video_width - anchor_x;
int anchor_bottom = c->media_stream->video_height - anchor_y;
int anchor_right = c->media_stream->video_width - anchor_x;
int anchor_bottom = c->media_stream->video_height - anchor_y;
c->texture->bind();
c->texture->bind();
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex2f(-anchor_x, -anchor_y);
glTexCoord2f(1.0, 0.0);
glVertex2f(anchor_right, -anchor_y);
glTexCoord2f(1.0, 1.0);
glVertex2f(anchor_right, anchor_bottom);
glTexCoord2f(0.0, 1.0);
glVertex2f(-anchor_x, anchor_bottom);
glEnd();
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex2f(-anchor_x, -anchor_y);
glTexCoord2f(1.0, 0.0);
glVertex2f(anchor_right, -anchor_y);
glTexCoord2f(1.0, 1.0);
glVertex2f(anchor_right, anchor_bottom);
glTexCoord2f(0.0, 1.0);
glVertex2f(-anchor_x, anchor_bottom);
glEnd();
c->texture->release();
c->texture->release();
}
} else if (render_audio &&
c->stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
@@ -119,8 +119,8 @@ void ViewerWidget::paintGL()
// clip is not caching, start caching audio
c->lock.unlock();
cache_clip(c, playhead, false, false, c->reset_audio);
}
}
}
}
}
if (panel_timeline->playing) {
@@ -137,13 +137,13 @@ void ViewerWidget::paintGL()
}
}
cc_lock.unlock();
cc_lock.unlock();
if (texture_failed) {
if (multithreaded) {
retry_timer.start();
} else {
paintGL();
}
}
if (texture_failed) {
if (multithreaded) {
retry_timer.start();
} else {
paintGL();
}
}
}