fixed several memory leaks and image sequences not matching when loading
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@ extern "C" {
|
||||
|
||||
#include "project/clip.h"
|
||||
|
||||
Media::Media() : ready(false), preview_gen(NULL), invalid(false) {
|
||||
Media::Media() : ready(false), preview_gen(NULL), invalid(false), in(0), out(0) {
|
||||
ready_lock.lock();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ struct Media {
|
||||
Media();
|
||||
~Media();
|
||||
|
||||
QString url;
|
||||
QString url;
|
||||
QString name;
|
||||
int64_t length;
|
||||
QVector<MediaStream*> video_tracks;
|
||||
|
||||
+5
-1
@@ -602,7 +602,7 @@ void Project::process_file_list(bool recursive, QStringList& files, QTreeWidgetI
|
||||
}
|
||||
|
||||
m->using_inout = false;
|
||||
m->url = file;
|
||||
m->url = file;
|
||||
m->name = get_file_name_from_path(files.at(i));
|
||||
|
||||
// generate waveform/thumbnail in another thread
|
||||
@@ -1004,6 +1004,10 @@ bool Project::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
|
||||
} else if (QFileInfo::exists(internal_proj_dir_test)) { // if path is relative to the last directory the project was saved in
|
||||
m->url = internal_proj_dir_test;
|
||||
dout << "[INFO] Matched" << attr.value().toString() << "relative to project's internal directory";
|
||||
} else if (m->url.contains('%')) {
|
||||
// hack for image sequences (qt won't be able to find the URL with %, but ffmpeg may)
|
||||
m->url = proj_dir_test;
|
||||
dout << "[INFO] Guess image sequence" << attr.value().toString() << "path to project's current directory";
|
||||
} else {
|
||||
dout << "[INFO] Failed to match" << attr.value().toString() << "to file";
|
||||
}
|
||||
|
||||
+10
-7
@@ -665,22 +665,22 @@ void open_clip_worker(Clip* clip) {
|
||||
clip->max_queue_size = (ms->infinite_length) ? 1 : qCeil(ms->video_frame_rate*0.5);
|
||||
if (ms->video_interlacing != VIDEO_PROGRESSIVE) clip->max_queue_size *= 2;
|
||||
|
||||
AVDictionary* opts = NULL;
|
||||
clip->opts = NULL;
|
||||
|
||||
// optimized decoding settings
|
||||
if (clip->stream->codecpar->codec_id != AV_CODEC_ID_PNG &&
|
||||
if (clip->stream->codecpar->codec_id != AV_CODEC_ID_PNG &&
|
||||
clip->stream->codecpar->codec_id != AV_CODEC_ID_APNG &&
|
||||
clip->stream->codecpar->codec_id != AV_CODEC_ID_TIFF &&
|
||||
clip->stream->codecpar->codec_id != AV_CODEC_ID_PSD) {
|
||||
av_dict_set(&opts, "threads", "auto", 0);
|
||||
av_dict_set(&clip->opts, "threads", "auto", 0);
|
||||
}
|
||||
if (clip->stream->codecpar->codec_id == AV_CODEC_ID_H264) {
|
||||
av_dict_set(&opts, "tune", "fastdecode", 0);
|
||||
av_dict_set(&opts, "tune", "zerolatency", 0);
|
||||
}
|
||||
av_dict_set(&clip->opts, "tune", "fastdecode", 0);
|
||||
av_dict_set(&clip->opts, "tune", "zerolatency", 0);
|
||||
}
|
||||
|
||||
// Open codec
|
||||
if (avcodec_open2(clip->codecCtx, clip->codec, &opts) < 0) {
|
||||
if (avcodec_open2(clip->codecCtx, clip->codec, &clip->opts) < 0) {
|
||||
dout << "[ERROR] Could not open codec";
|
||||
}
|
||||
|
||||
@@ -888,6 +888,9 @@ void close_clip_worker(Clip* clip) {
|
||||
|
||||
avcodec_close(clip->codecCtx);
|
||||
avcodec_free_context(&clip->codecCtx);
|
||||
|
||||
av_dict_free(&clip->opts);
|
||||
|
||||
avformat_close_input(&clip->formatCtx);
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -35,7 +35,8 @@ Clip::Clip(Sequence* s) :
|
||||
use_existing_frame(false),
|
||||
filter_graph(NULL),
|
||||
fbo(NULL),
|
||||
texture(NULL)
|
||||
texture(NULL),
|
||||
opts(NULL)
|
||||
{
|
||||
pkt = av_packet_alloc();
|
||||
reset();
|
||||
@@ -88,6 +89,7 @@ void Clip::reset() {
|
||||
codec = NULL;
|
||||
codecCtx = NULL;
|
||||
texture = NULL;
|
||||
last_invalid_ts = -1;
|
||||
}
|
||||
|
||||
void Clip::reset_audio() {
|
||||
|
||||
@@ -27,6 +27,7 @@ struct SwsContext;
|
||||
struct SwrContext;
|
||||
struct AVFilterGraph;
|
||||
struct AVFilterContext;
|
||||
struct AVDictionary;
|
||||
class QOpenGLTexture;
|
||||
|
||||
struct Clip
|
||||
@@ -87,6 +88,7 @@ struct Clip
|
||||
AVCodecContext* codecCtx;
|
||||
AVPacket* pkt;
|
||||
AVFrame* frame;
|
||||
AVDictionary* opts;
|
||||
long calculated_length;
|
||||
|
||||
// temporary variables
|
||||
|
||||
@@ -431,9 +431,14 @@ Effect::~Effect() {
|
||||
close();
|
||||
}
|
||||
|
||||
delete container;
|
||||
|
||||
for (int i=0;i<rows.size();i++) {
|
||||
delete rows.at(i);
|
||||
}
|
||||
for (int i=0;i<gizmos.size();i++) {
|
||||
delete gizmos.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
void Effect::copy_field_keyframes(Effect* e) {
|
||||
|
||||
@@ -30,7 +30,7 @@ EffectRow::EffectRow(Effect *parent, bool save, QGridLayout *uilayout, const QSt
|
||||
QSize button_size(20, 20);
|
||||
QSize icon_size(12, 12);
|
||||
|
||||
QHBoxLayout* key_controls = new QHBoxLayout();
|
||||
key_controls = new QHBoxLayout();
|
||||
key_controls->setSpacing(0);
|
||||
key_controls->setMargin(0);
|
||||
key_controls->addStretch();
|
||||
|
||||
@@ -11,6 +11,7 @@ class QLabel;
|
||||
class KeyframeDelete;
|
||||
class QPushButton;
|
||||
class ComboAction;
|
||||
class QHBoxLayout;
|
||||
|
||||
class EffectRow : public QObject {
|
||||
Q_OBJECT
|
||||
@@ -45,6 +46,7 @@ private:
|
||||
int ui_row;
|
||||
QVector<EffectField*> fields;
|
||||
|
||||
QHBoxLayout* key_controls;
|
||||
QPushButton* keyframe_enable;
|
||||
QPushButton* left_key_nav;
|
||||
QPushButton* key_addremove;
|
||||
|
||||
@@ -22,7 +22,7 @@ CollapsibleWidget::CollapsibleWidget(QWidget* parent) : QWidget(parent) {
|
||||
title_bar = new CollapsibleWidgetHeader();
|
||||
title_bar->setFocusPolicy(Qt::ClickFocus);
|
||||
title_bar->setAutoFillBackground(true);
|
||||
QHBoxLayout* title_bar_layout = new QHBoxLayout();
|
||||
title_bar_layout = new QHBoxLayout();
|
||||
title_bar_layout->setMargin(5);
|
||||
title_bar->setLayout(title_bar_layout);
|
||||
enabled_check = new CheckboxEx();
|
||||
|
||||
@@ -41,6 +41,7 @@ private:
|
||||
QVBoxLayout* layout;
|
||||
QPushButton* collapse_button;
|
||||
QFrame* line;
|
||||
QHBoxLayout* title_bar_layout;
|
||||
|
||||
signals:
|
||||
void deselect_others(QWidget*);
|
||||
|
||||
+3
-3
@@ -19,10 +19,10 @@ LabelSlider::LabelSlider(QWidget* parent) : QLabel(parent) {
|
||||
setStyleSheet("QLabel{color:#ffc000;text-decoration:underline;}QLabel:disabled{color:#808080;}");
|
||||
setCursor(Qt::SizeHorCursor);
|
||||
internal_value = -1;
|
||||
set = false;
|
||||
display_type = LABELSLIDER_NORMAL;
|
||||
|
||||
set_default_value(0);
|
||||
set_value(0, false);
|
||||
set = false;
|
||||
display_type = LABELSLIDER_NORMAL;
|
||||
}
|
||||
|
||||
void LabelSlider::set_frame_rate(double d) {
|
||||
|
||||
Reference in New Issue
Block a user