many changes, mostly to export
This commit is contained in:
+52
-55
@@ -109,16 +109,17 @@ void TimelineWidget::dropEvent(QDropEvent* event) {
|
||||
|
||||
if (c.track < 0) {
|
||||
// add default video effects
|
||||
c.effects.append(new TransformEffect(&c));
|
||||
c.effects.append(create_effect(VIDEO_TRANSFORM_EFFECT, &c));
|
||||
} else {
|
||||
// add default audio effects
|
||||
c.effects.append(new VolumeEffect(&c));
|
||||
c.effects.append(new PanEffect(&c));
|
||||
c.effects.append(create_effect(AUDIO_VOLUME_EFFECT, &c));
|
||||
c.effects.append(create_effect(AUDIO_PAN_EFFECT, &c));
|
||||
}
|
||||
}
|
||||
|
||||
panel_timeline->ghosts.clear();
|
||||
panel_timeline->importing = false;
|
||||
panel_timeline->snapped = false;
|
||||
|
||||
panel_timeline->redraw_all_clips();
|
||||
}
|
||||
@@ -303,13 +304,46 @@ void TimelineWidget::init_ghosts() {
|
||||
}
|
||||
}
|
||||
|
||||
bool subvalidate_snapping(Ghost& g, long* frame_diff, long snap_point) {
|
||||
int snap_range = 15;
|
||||
long in_validator = g.old_in + *frame_diff - snap_point;
|
||||
long out_validator = g.old_out + *frame_diff - snap_point;
|
||||
|
||||
if (in_validator > -snap_range && in_validator < snap_range) {
|
||||
*frame_diff -= in_validator;
|
||||
panel_timeline->snap_point = snap_point;
|
||||
panel_timeline->snapped = true;
|
||||
return true;
|
||||
} else if (out_validator > -snap_range && out_validator < snap_range) {
|
||||
*frame_diff -= out_validator;
|
||||
panel_timeline->snap_point = snap_point;
|
||||
panel_timeline->snapped = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void validate_snapping(Ghost& g, long* frame_diff) {
|
||||
long validator;
|
||||
panel_timeline->snapped = false;
|
||||
if (panel_timeline->snapping) {
|
||||
if (!subvalidate_snapping(g, frame_diff, panel_timeline->playhead)) {
|
||||
for (int j=0;j<panel_timeline->sequence->clip_count();j++) {
|
||||
Clip& c = panel_timeline->sequence->get_clip(j);
|
||||
if (!subvalidate_snapping(g, frame_diff, c.timeline_in)) {
|
||||
subvalidate_snapping(g, frame_diff, c.timeline_out);
|
||||
}
|
||||
if (panel_timeline->snapped) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineWidget::update_ghosts(QPoint& mouse_pos) {
|
||||
int mouse_track = getTrackFromScreenPoint(mouse_pos.y());
|
||||
long frame_diff = getFrameFromScreenPoint(mouse_pos.x(), false) - panel_timeline->drag_frame_start;
|
||||
int track_diff = mouse_track - panel_timeline->drag_track_start;
|
||||
|
||||
int snap_range = 15;
|
||||
|
||||
long validator;
|
||||
if (panel_timeline->trim_target > -1) {
|
||||
// trim ops
|
||||
@@ -378,6 +412,8 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
validate_snapping(g, &frame_diff);
|
||||
}
|
||||
|
||||
// resize ghosts
|
||||
@@ -422,46 +458,7 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) {
|
||||
}
|
||||
}
|
||||
|
||||
// shitty hacky code but works wonders
|
||||
panel_timeline->snapped = false;
|
||||
if (panel_timeline->snapping) {
|
||||
for (int j=0;j<panel_timeline->sequence->clip_count();j++) {
|
||||
Clip& c = panel_timeline->sequence->get_clip(j);
|
||||
|
||||
panel_timeline->snapped = false;
|
||||
for (int k=0;k<4;k++) {
|
||||
switch (k) {
|
||||
case 0:
|
||||
// snap in to timeline_in
|
||||
validator = g.old_in + frame_diff - c.timeline_in;
|
||||
panel_timeline->snap_point = c.timeline_in;
|
||||
break;
|
||||
case 1:
|
||||
// snap in to timeline out
|
||||
validator = g.old_in + frame_diff - c.timeline_out;
|
||||
panel_timeline->snap_point = c.timeline_out;
|
||||
break;
|
||||
case 2:
|
||||
// snap out to timeline_in
|
||||
validator = g.old_out + frame_diff - c.timeline_in;
|
||||
panel_timeline->snap_point = c.timeline_in;
|
||||
break;
|
||||
case 3:
|
||||
// snap out to timeline_out
|
||||
validator = g.old_out + frame_diff - c.timeline_out;
|
||||
panel_timeline->snap_point = c.timeline_out;
|
||||
break;
|
||||
}
|
||||
|
||||
if (validator > -snap_range && validator < snap_range) {
|
||||
frame_diff -= validator;
|
||||
panel_timeline->snapped = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (panel_timeline->snapped) break;
|
||||
}
|
||||
}
|
||||
validate_snapping(g, &frame_diff);
|
||||
}
|
||||
|
||||
// move ghosts
|
||||
@@ -756,6 +753,15 @@ void TimelineWidget::paintEvent(QPaintEvent*) {
|
||||
}
|
||||
}
|
||||
|
||||
// Draw playhead
|
||||
p.setPen(Qt::red);
|
||||
int playhead_x = getScreenPointFromFrame(panel_timeline->playhead);
|
||||
p.drawLine(playhead_x, rect().top(), playhead_x, rect().bottom());
|
||||
|
||||
p.setPen(QColor(0, 0, 0, 64));
|
||||
int edge_y = (bottom_align) ? rect().height()-1 : 0;
|
||||
p.drawLine(0, edge_y, rect().width(), edge_y);
|
||||
|
||||
// draw snap point
|
||||
if (panel_timeline->snapping && panel_timeline->snapped) {
|
||||
p.setPen(Qt::white);
|
||||
@@ -774,16 +780,7 @@ void TimelineWidget::paintEvent(QPaintEvent*) {
|
||||
p.setPen(Qt::gray);
|
||||
p.drawLine(cursor_x, cursor_y, cursor_x, cursor_y + track_height);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw playhead
|
||||
p.setPen(Qt::red);
|
||||
int playhead_x = getScreenPointFromFrame(panel_timeline->playhead);
|
||||
p.drawLine(playhead_x, rect().top(), playhead_x, rect().bottom());
|
||||
|
||||
p.setPen(QColor(0, 0, 0, 64));
|
||||
int edge_y = (bottom_align) ? rect().height()-1 : 0;
|
||||
p.drawLine(0, edge_y, rect().width(), edge_y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+21
-15
@@ -18,6 +18,10 @@ extern "C" {
|
||||
ViewerWidget::ViewerWidget(QWidget *parent) : QOpenGLWidget(parent)
|
||||
{
|
||||
multithreaded = true;
|
||||
enable_paint = true;
|
||||
force_audio = false;
|
||||
|
||||
audio_bytes_written = 0;
|
||||
|
||||
QSurfaceFormat format;
|
||||
format.setDepthBufferSize(24);
|
||||
@@ -46,7 +50,9 @@ void ViewerWidget::initializeGL() {
|
||||
//{
|
||||
//}
|
||||
|
||||
int audio_bytes_written = 0;
|
||||
void ViewerWidget::paintEvent(QPaintEvent *e) {
|
||||
if (enable_paint) QOpenGLWidget::paintEvent(e);
|
||||
}
|
||||
|
||||
void ViewerWidget::paintGL()
|
||||
{
|
||||
@@ -59,14 +65,19 @@ void ViewerWidget::paintGL()
|
||||
handle_media(panel_viewer->sequence, playhead, multithreaded);
|
||||
texture_failed = false;
|
||||
|
||||
bool render_audio = (panel_timeline->playing);
|
||||
bool render_audio = (panel_timeline->playing || force_audio);
|
||||
|
||||
if (render_audio && switch_audio_cache) {
|
||||
reading_audio_cache_A = !reading_audio_cache_A;
|
||||
audio_bytes_written = 0;
|
||||
clear_cache(!reading_audio_cache_A, reading_audio_cache_A);
|
||||
// switch_cache
|
||||
if (render_audio && audio_bytes_written == audio_cache_size) {
|
||||
switch_audio_cache = true;
|
||||
|
||||
reading_audio_cache_A = !reading_audio_cache_A;
|
||||
audio_bytes_written = 0;
|
||||
clear_cache(!reading_audio_cache_A, reading_audio_cache_A);
|
||||
}
|
||||
|
||||
qDebug() << audio_bytes_written << "/" << audio_cache_size;
|
||||
|
||||
cc_lock.lock();
|
||||
for (int i=0;i<current_clips.size();i++) {
|
||||
Clip* c = current_clips.at(i);
|
||||
@@ -92,7 +103,7 @@ void ViewerWidget::paintGL()
|
||||
|
||||
// perform all transform effects
|
||||
for (unsigned int j=0;j<c->effects.size();j++) {
|
||||
c->effects.at(j)->process_gl(&anchor_x, &anchor_y);
|
||||
c->effects.at(j)->process_gl(&anchor_x, &anchor_y);
|
||||
}
|
||||
|
||||
int anchor_right = c->media_stream->video_width - anchor_x;
|
||||
@@ -118,7 +129,7 @@ void ViewerWidget::paintGL()
|
||||
render_audio &&
|
||||
!c->reached_end &&
|
||||
(switch_audio_cache || c->reset_audio)) {
|
||||
// TODO doesn't new clips appearing in the timeline (they'll ALWAYS end up in the other cache with a 1/8 sec delay)
|
||||
// TODO doesn't affect new clips appearing in the timeline (they'll ALWAYS end up in the other cache with a 1/8 sec delay)
|
||||
|
||||
// cache audio
|
||||
if (c->lock.tryLock()) {
|
||||
@@ -136,13 +147,8 @@ void ViewerWidget::paintGL()
|
||||
if (audio_cache_A != NULL && audio_bytes_written < audio_cache_size) {
|
||||
// send cached/buffered audio to QIODevice/QAudioOutput
|
||||
uint8_t* cache = reading_audio_cache_A ? audio_cache_A : audio_cache_B;
|
||||
audio_bytes_written += audio_io_device->write((const char*) cache+audio_bytes_written, audio_cache_size-audio_bytes_written);
|
||||
}
|
||||
|
||||
if (audio_bytes_written == audio_cache_size) {
|
||||
// switch_cache
|
||||
switch_audio_cache = true;
|
||||
}
|
||||
if (panel_timeline->playing) audio_bytes_written += audio_io_device->write((const char*) cache+audio_bytes_written, audio_cache_size-audio_bytes_written);
|
||||
}
|
||||
}
|
||||
|
||||
cc_lock.unlock();
|
||||
|
||||
+5
-1
@@ -18,7 +18,11 @@ public:
|
||||
// void resizeGL(int w, int h);
|
||||
void paintGL();
|
||||
|
||||
bool multithreaded;
|
||||
bool multithreaded;
|
||||
bool force_audio;
|
||||
bool enable_paint;
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
private:
|
||||
QTimer retry_timer;
|
||||
private slots:
|
||||
|
||||
Reference in New Issue
Block a user