fixed linking bug
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
const char* version = "Olive (May 2018 | Pre-Alpha)";
|
||||
float scale = 1.0f;
|
||||
bool vsync = true;
|
||||
bool hwaccel = false;
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
}
|
||||
|
||||
Media::Media() {}
|
||||
Media::Media() : ready(false) {}
|
||||
|
||||
Media::~Media() {
|
||||
for (int i=0;i<video_tracks.size();i++) {
|
||||
|
||||
@@ -34,6 +34,7 @@ struct Media
|
||||
QVector<MediaStream*> video_tracks;
|
||||
QVector<MediaStream*> audio_tracks;
|
||||
int save_id;
|
||||
bool ready;
|
||||
long get_length_in_frames(float frame_rate);
|
||||
MediaStream* get_stream_from_file_index(int index);
|
||||
};
|
||||
|
||||
+10
-9
@@ -115,7 +115,11 @@ QTreeWidgetItem* Project::import_file(QString file) {
|
||||
char* filename = new char[ba.size()+1];
|
||||
strcpy(filename, ba.data());
|
||||
|
||||
QTreeWidgetItem* item = NULL;
|
||||
QTreeWidgetItem* item = new_item();
|
||||
Media* m = new Media();
|
||||
m->url = file;
|
||||
m->name = file.mid(file.lastIndexOf('/')+1);
|
||||
item->setText(0, m->name);
|
||||
|
||||
AVFormatContext* pFormatCtx = NULL;
|
||||
int errCode = avformat_open_input(&pFormatCtx, filename, NULL, NULL);
|
||||
@@ -132,10 +136,6 @@ QTreeWidgetItem* Project::import_file(QString file) {
|
||||
} else {
|
||||
av_dump_format(pFormatCtx, 0, filename, 0);
|
||||
|
||||
Media* m = new Media();
|
||||
m->url = file;
|
||||
m->name = file.mid(file.lastIndexOf('/')+1);
|
||||
|
||||
// detect video/audio streams in file
|
||||
for (int i=0;i<(int)pFormatCtx->nb_streams;i++) {
|
||||
// Find the decoder for the video stream
|
||||
@@ -159,17 +159,14 @@ QTreeWidgetItem* Project::import_file(QString file) {
|
||||
}
|
||||
m->length = pFormatCtx->duration;
|
||||
|
||||
item = new_item();
|
||||
if (m->video_tracks.size() == 0) {
|
||||
item->setIcon(0, QIcon(":/icons/audiosource.png"));
|
||||
} else {
|
||||
item->setIcon(0, QIcon(":/icons/videosource.png"));
|
||||
}
|
||||
item->setText(0, m->name);
|
||||
item->setText(1, QString::number(m->length));
|
||||
set_media_of_tree(item, m);
|
||||
|
||||
project_changed = true;
|
||||
m->ready = true;
|
||||
|
||||
// generate waveform/thumbnail in another thread
|
||||
PreviewGenerator* pg = new PreviewGenerator();
|
||||
@@ -180,6 +177,10 @@ QTreeWidgetItem* Project::import_file(QString file) {
|
||||
}
|
||||
}
|
||||
|
||||
set_media_of_tree(item, m);
|
||||
|
||||
project_changed = true;
|
||||
|
||||
delete [] filename;
|
||||
return item;
|
||||
}
|
||||
|
||||
+19
-3
@@ -846,9 +846,25 @@ void Timeline::toggle_links() {
|
||||
LinkCommand* command = new LinkCommand();
|
||||
for (int i=0;i<sequence->clip_count();i++) {
|
||||
Clip* c = sequence->get_clip(i);
|
||||
command->clips.append(c);
|
||||
if (c->linked.size() > 0) {
|
||||
command->link = false; // prioritize unlinking
|
||||
if (c != NULL && is_clip_selected(c, true)) {
|
||||
command->clips.append(c);
|
||||
if (c->linked.size() > 0) {
|
||||
command->link = false; // prioritize unlinking
|
||||
|
||||
for (int j=0;j<c->linked.size();j++) { // add links to the command
|
||||
bool found = false;
|
||||
Clip* link = sequence->get_clip(c->linked.at(j));
|
||||
for (int k=0;k<command->clips.size();k++) {
|
||||
if (command->clips.at(k) == link) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
command->clips.append(link);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (command->clips.size() > 0) {
|
||||
|
||||
+23
-21
@@ -64,27 +64,29 @@ void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) {
|
||||
QTreeWidgetItem* item = items.at(i);
|
||||
if (panel_project->get_type_from_tree(item) == MEDIA_TYPE_FOOTAGE) {
|
||||
Media* m = panel_project->get_media_from_tree(item);
|
||||
Ghost g;
|
||||
g.clip = -1;
|
||||
g.media = m;
|
||||
g.old_clip_in = g.clip_in = 0;
|
||||
g.in = entry_point;
|
||||
if (m->video_tracks.size() > 0 && m->video_tracks[0]->infinite_length && m->audio_tracks.size() == 0) {
|
||||
g.out = g.in + 100;
|
||||
} else {
|
||||
g.out = entry_point + m->get_length_in_frames(sequence->frame_rate);
|
||||
}
|
||||
entry_point = g.out;
|
||||
g.trimming = false;
|
||||
for (int j=0;j<m->audio_tracks.size();j++) {
|
||||
g.track = j;
|
||||
g.media_stream = m->audio_tracks.at(j);
|
||||
panel_timeline->ghosts.append(g);
|
||||
}
|
||||
for (int j=0;j<m->video_tracks.size();j++) {
|
||||
g.track = -1-j;
|
||||
g.media_stream = m->video_tracks.at(j);
|
||||
panel_timeline->ghosts.append(g);
|
||||
if (m->ready) {
|
||||
Ghost g;
|
||||
g.clip = -1;
|
||||
g.media = m;
|
||||
g.old_clip_in = g.clip_in = 0;
|
||||
g.in = entry_point;
|
||||
if (m->video_tracks.size() > 0 && m->video_tracks[0]->infinite_length && m->audio_tracks.size() == 0) {
|
||||
g.out = g.in + 100;
|
||||
} else {
|
||||
g.out = entry_point + m->get_length_in_frames(sequence->frame_rate);
|
||||
}
|
||||
entry_point = g.out;
|
||||
g.trimming = false;
|
||||
for (int j=0;j<m->audio_tracks.size();j++) {
|
||||
g.track = j;
|
||||
g.media_stream = m->audio_tracks.at(j);
|
||||
panel_timeline->ghosts.append(g);
|
||||
}
|
||||
for (int j=0;j<m->video_tracks.size();j++) {
|
||||
g.track = -1-j;
|
||||
g.media_stream = m->video_tracks.at(j);
|
||||
panel_timeline->ghosts.append(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ void ViewerWidget::paintGL() {
|
||||
|
||||
// if clip starts within one second and/or hasn't finished yet
|
||||
if (c != NULL) {
|
||||
if (is_clip_active(c, panel_timeline->playhead)) {
|
||||
if (c->media->ready && is_clip_active(c, panel_timeline->playhead)) {
|
||||
// if thread is already working, we don't want to touch this,
|
||||
// but we also don't want to hang the UI thread
|
||||
if (!c->open) {
|
||||
|
||||
Reference in New Issue
Block a user