+1
-14
@@ -326,7 +326,6 @@ void cache_clip_worker(Clip* clip, long playhead, bool write_A, bool write_B, bo
|
||||
}
|
||||
|
||||
void close_clip_worker(Clip* clip) {
|
||||
cc_lock.lock();
|
||||
// closes ffmpeg file handle and frees any memory used for caching
|
||||
if (clip->stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
sws_freeContext(clip->sws_ctx);
|
||||
@@ -345,19 +344,7 @@ void close_clip_worker(Clip* clip) {
|
||||
delete [] clip->cache_A.frames;
|
||||
if (!clip->media_stream->infinite_length) delete [] clip->cache_B.frames;
|
||||
|
||||
av_frame_free(&clip->frame);
|
||||
|
||||
// remove clip from current_clips
|
||||
bool found = false;
|
||||
for (int i=0;i<current_clips.count();i++) {
|
||||
if (current_clips[i] == clip) {
|
||||
current_clips.removeAt(i);
|
||||
found = true;
|
||||
i = current_clips.count();
|
||||
}
|
||||
}
|
||||
cc_lock.unlock();
|
||||
if (!found) qDebug() << "[WARNING] Could not remove clip from current clips";
|
||||
av_frame_free(&clip->frame);
|
||||
|
||||
clip->reset();
|
||||
|
||||
|
||||
@@ -22,47 +22,8 @@ extern "C" {
|
||||
#include <QDebug>
|
||||
#include <QOpenGLPixelTransferOptions>
|
||||
|
||||
QList<Clip*> current_clips;
|
||||
bool texture_failed = false;
|
||||
|
||||
QMutex cc_lock;
|
||||
|
||||
void handle_media(Sequence* sequence, long playhead, bool multithreaded) {
|
||||
for (int i=0;i<sequence->clip_count();i++) {
|
||||
Clip* c = sequence->get_clip(i);
|
||||
|
||||
// if clip starts within one second and/or hasn't finished yet
|
||||
if (c != NULL) {
|
||||
if (is_clip_active(c, 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) {
|
||||
if (c->open_lock.tryLock()) {
|
||||
open_clip(c, multithreaded);
|
||||
|
||||
// add to current_clips, (insertion) sorted by track so composite them in order
|
||||
cc_lock.lock();
|
||||
bool found = false;
|
||||
for (int j=0;j<current_clips.size();j++) {
|
||||
if (current_clips[j]->track < c->track) {
|
||||
current_clips.insert(current_clips.begin()+j, c);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
current_clips.push_back(c);
|
||||
}
|
||||
cc_lock.unlock();
|
||||
}
|
||||
}
|
||||
} else if (c->open) {
|
||||
close_clip(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void open_clip(Clip* clip, bool multithreaded) {
|
||||
clip->multithreaded = multithreaded;
|
||||
if (multithreaded) {
|
||||
|
||||
@@ -9,9 +9,6 @@ struct ClipCache;
|
||||
struct Sequence;
|
||||
struct AVFrame;
|
||||
|
||||
extern QList<Clip*> current_clips;
|
||||
extern QMutex cc_lock;
|
||||
|
||||
extern bool texture_failed;
|
||||
|
||||
void open_clip(Clip* clip, bool multithreaded);
|
||||
|
||||
Reference in New Issue
Block a user