Merge branch 'master' into typos

This commit is contained in:
itsmattkc
2020-03-19 12:16:09 +11:00
committed by GitHub
126 changed files with 2951 additions and 934 deletions
+18 -17
View File
@@ -20,7 +20,7 @@
#include "folder.h"
#include "common/xmlreadloop.h"
#include "common/xmlutils.h"
#include "project/item/footage/footage.h"
#include "project/item/sequence/sequence.h"
#include "ui/icons/icons.h"
@@ -46,37 +46,38 @@ QIcon Folder::icon()
void Folder::Load(QXmlStreamReader *reader, QHash<quintptr, StreamPtr> &footage_ptrs, QList<NodeParam::FootageConnection>& footage_connections, const QAtomicInt *cancelled)
{
qDebug() << "Hello?";
XMLAttributeLoop(reader, attr) {
if (cancelled && *cancelled) {
return;
}
if (attr.name() == "name") {
if (attr.name() == QStringLiteral("name")) {
set_name(attr.value().toString());
}
}
XMLReadLoop(reader, "folder") {
while (XMLReadNextStartElement(reader)) {
if (cancelled && *cancelled) {
return;
}
if (reader->isStartElement()) {
ItemPtr child;
ItemPtr child;
if (reader->name() == "folder") {
child = std::make_shared<Folder>();
} else if (reader->name() == "footage") {
child = std::make_shared<Footage>();
} else if (reader->name() == "sequence") {
child = std::make_shared<Sequence>();
} else {
continue;
}
add_child(child);
child->Load(reader, footage_ptrs, footage_connections, cancelled);
if (reader->name() == QStringLiteral("folder")) {
child = std::make_shared<Folder>();
} else if (reader->name() == QStringLiteral("footage")) {
child = std::make_shared<Footage>();
} else if (reader->name() == QStringLiteral("sequence")) {
child = std::make_shared<Sequence>();
} else {
reader->skipCurrentElement();
continue;
}
add_child(child);
child->Load(reader, footage_ptrs, footage_connections, cancelled);
}
}
+27 -27
View File
@@ -23,9 +23,9 @@
#include <QCoreApplication>
#include "codec/decoder.h"
#include "common/timecodefunctions.h"
#include "common/xmlreadloop.h"
#include "common/xmlutils.h"
#include "config/config.h"
#include "core.h"
#include "ui/icons/icons.h"
Footage::Footage()
@@ -43,45 +43,45 @@ void Footage::Load(QXmlStreamReader *reader, QHash<quintptr, StreamPtr>& footage
QXmlStreamAttributes attributes = reader->attributes();
foreach (const QXmlStreamAttribute& attr, attributes) {
if (attr.name() == "name") {
if (attr.name() == QStringLiteral("name")) {
set_name(attr.value().toString());
} else if (attr.name() == "filename") {
} else if (attr.name() == QStringLiteral("filename")) {
set_filename(attr.value().toString());
}
}
Decoder::ProbeMedia(this, cancelled);
XMLReadLoop(reader, "footage") {
while (XMLReadNextStartElement(reader)) {
if (cancelled && *cancelled) {
return;
}
if (reader->isStartElement()) {
if (reader->name() == "stream") {
int stream_index = -1;
quintptr stream_ptr = 0;
if (reader->name() == QStringLiteral("stream")) {
int stream_index = -1;
quintptr stream_ptr = 0;
XMLAttributeLoop(reader, attr) {
if (cancelled && *cancelled) {
return;
}
if (attr.name() == "index") {
stream_index = attr.value().toInt();
} else if (attr.name() == "ptr") {
stream_ptr = attr.value().toULongLong();
}
XMLAttributeLoop(reader, attr) {
if (cancelled && *cancelled) {
return;
}
if (stream_index > -1 && stream_ptr > 0) {
footage_ptrs.insert(stream_ptr, stream(stream_index));
stream(stream_index)->Load(reader);
} else {
qWarning() << "Invalid stream found in project file";
if (attr.name() == QStringLiteral("index")) {
stream_index = attr.value().toInt();
} else if (attr.name() == QStringLiteral("ptr")) {
stream_ptr = attr.value().toULongLong();
}
}
if (stream_index > -1 && stream_ptr > 0) {
footage_ptrs.insert(stream_ptr, stream(stream_index));
stream(stream_index)->Load(reader);
} else {
qWarning() << "Invalid stream found in project file";
}
} else {
reader->skipCurrentElement();
}
}
}
@@ -232,12 +232,12 @@ QString Footage::duration()
return Timecode::timestamp_to_timecode(duration,
frame_rate_timebase,
Timecode::CurrentDisplay());
Core::instance()->GetTimecodeDisplay());
} else if (streams_.first()->type() == Stream::kAudio) {
AudioStreamPtr audio_stream = std::static_pointer_cast<AudioStream>(streams_.first());
// If we're showing in a timecode, we prefer showing audio in seconds instead
Timecode::Display display = Timecode::CurrentDisplay();
Timecode::Display display = Core::instance()->GetTimecodeDisplay();
if (display == Timecode::kTimecodeDropFrame
|| display == Timecode::kTimecodeNonDropFrame) {
display = Timecode::kTimecodeSeconds;
+2 -1
View File
@@ -30,6 +30,7 @@
#include "project/item/footage/audiostream.h"
#include "project/item/footage/imagestream.h"
#include "project/item/footage/videostream.h"
#include "timeline/timelinepoints.h"
/**
* @brief A reference to an external media file with metadata in a project structure
@@ -38,7 +39,7 @@
* Footage objects store a list of Stream objects which store the majority of video/audio metadata. These streams
* are identical to the stream data in the files.
*/
class Footage : public Item
class Footage : public Item, public TimelinePoints
{
public:
enum Status {
+13 -10
View File
@@ -20,7 +20,7 @@
#include "imagestream.h"
#include "common/xmlreadloop.h"
#include "common/xmlutils.h"
#include "footage.h"
#include "project/project.h"
#include "render/colormanager.h"
@@ -43,10 +43,11 @@ void ImageStream::FootageSetEvent(Footage *f)
void ImageStream::LoadCustomParameters(QXmlStreamReader *reader)
{
XMLReadLoop(reader, "stream") {
if (reader->isStartElement() && reader->name() == "colorspace") {
reader->readNext();
set_colorspace(reader->text().toString());
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("colorspace")) {
set_colorspace(reader->readElementText());
} else {
reader->skipCurrentElement();
}
}
}
@@ -91,11 +92,13 @@ bool ImageStream::premultiplied_alpha() const
void ImageStream::set_premultiplied_alpha(bool e)
{
premultiplied_alpha_ = e;
emit ParametersChanged();
}
const QString &ImageStream::colorspace() const
const QString &ImageStream::colorspace(bool default_if_empty) const
{
if (colorspace_.isEmpty()) {
if (colorspace_.isEmpty() && default_if_empty) {
return footage()->project()->default_input_colorspace();
} else {
return colorspace_;
@@ -106,7 +109,7 @@ void ImageStream::set_colorspace(const QString &color)
{
colorspace_ = color;
emit ColorSpaceChanged();
emit ParametersChanged();
}
void ImageStream::ColorConfigChanged()
@@ -123,13 +126,13 @@ void ImageStream::ColorConfigChanged()
}
// Either way, the color calculation has likely changed so we signal here
emit ColorSpaceChanged();
emit ParametersChanged();
}
void ImageStream::DefaultColorSpaceChanged()
{
// If no colorspace is set, this stream uses the default color space and it's just changed
if (colorspace_.isEmpty()) {
emit ColorSpaceChanged();
emit ParametersChanged();
}
}
+1 -4
View File
@@ -43,12 +43,9 @@ public:
bool premultiplied_alpha() const;
void set_premultiplied_alpha(bool e);
const QString& colorspace() const;
const QString& colorspace(bool default_if_empty = true) const;
void set_colorspace(const QString& color);
signals:
void ColorSpaceChanged();
protected:
virtual void FootageSetEvent(Footage*) override;
+8 -5
View File
@@ -107,6 +107,8 @@ const int64_t &Stream::duration() const
void Stream::set_duration(const int64_t &duration)
{
duration_ = duration;
emit ParametersChanged();
}
bool Stream::enabled() const
@@ -135,10 +137,10 @@ QIcon Stream::IconFromType(const Stream::Type &type)
return QIcon();
}
StreamID Stream::ToID() const
/*StreamID Stream::ToID() const
{
return StreamID(footage_->filename(), index_);
}
}*/
QMutex* Stream::index_process_lock()
{
@@ -149,16 +151,17 @@ void Stream::FootageSetEvent(Footage*)
{
}
void Stream::LoadCustomParameters(QXmlStreamReader*)
void Stream::LoadCustomParameters(QXmlStreamReader* reader)
{
reader->skipCurrentElement();
}
void Stream::SaveCustomParameters(QXmlStreamWriter*) const
{
}
StreamID::StreamID(const QString &filename, const int &stream_index) :
/*StreamID::StreamID(const QString &filename, const int &stream_index) :
filename_(filename),
stream_index_(stream_index)
{
}
}*/
+5 -3
View File
@@ -31,7 +31,7 @@
class Footage;
class StreamID {
/*class StreamID {
public:
StreamID(const QString& filename, const int& stream_index);
@@ -40,7 +40,7 @@ private:
int stream_index_;
};
};*/
/**
* @brief A base class for keeping metadata about a media stream.
@@ -101,7 +101,7 @@ public:
static QIcon IconFromType(const Type& type);
StreamID ToID() const;
//StreamID ToID() const;
QMutex* index_process_lock();
@@ -115,6 +115,8 @@ protected:
signals:
void IndexChanged();
void ParametersChanged();
private:
Footage* footage_;
+13 -1
View File
@@ -27,7 +27,8 @@
const int64_t VideoStream::kEndTimestamp = AV_NOPTS_VALUE;
VideoStream::VideoStream() :
start_time_(0)
start_time_(0),
is_image_sequence_(false)
{
set_type(kVideo);
}
@@ -57,6 +58,17 @@ const int64_t &VideoStream::start_time() const
void VideoStream::set_start_time(const int64_t &start_time)
{
start_time_ = start_time;
emit ParametersChanged();
}
bool VideoStream::is_image_sequence() const
{
return is_image_sequence_;
}
void VideoStream::set_image_sequence(bool e)
{
is_image_sequence_ = e;
}
int64_t VideoStream::get_closest_timestamp_in_frame_index(const rational &time)
+6
View File
@@ -25,6 +25,7 @@
class VideoStream : public ImageStream
{
Q_OBJECT
public:
VideoStream();
@@ -43,6 +44,9 @@ public:
const int64_t& start_time() const;
void set_start_time(const int64_t& start_time);
bool is_image_sequence() const;
void set_image_sequence(bool e);
int64_t get_closest_timestamp_in_frame_index(const rational& time);
int64_t get_closest_timestamp_in_frame_index(int64_t timestamp);
void clear_frame_index();
@@ -62,6 +66,8 @@ private:
QMutex index_access_lock_;
bool is_image_sequence_;
};
using VideoStreamPtr = std::shared_ptr<VideoStream>;
+28 -3
View File
@@ -76,11 +76,19 @@ const QList<ItemPtr> &Item::children() const
return children_;
}
ItemPtr Item::shared_ptr_from_raw(Item *item)
ItemPtr Item::shared_ptr_from_raw(Item *item, bool traverse)
{
for (int i=0;i<children_.size();i++) {
if (children_.at(i).get() == item) {
return children_.at(i);
ItemPtr c = children_.at(i);
if (c.get() == item) {
return c;
} else if (traverse && c->CanHaveChildren()) {
ItemPtr grandchild = shared_ptr_from_raw(item);
if (grandchild) {
return grandchild;
}
}
}
@@ -147,6 +155,23 @@ void Item::set_project(Project *project)
project_ = project;
}
QList<ItemPtr> Item::get_children_of_type(Type type, bool recursive) const
{
QList<ItemPtr> list;
foreach (ItemPtr item, children_) {
if (item->type() == type) {
list.append(item);
}
if (recursive && item->CanHaveChildren()) {
list.append(item->get_children_of_type(type, recursive));
}
}
return list;
}
bool Item::CanHaveChildren() const
{
return false;
+3 -1
View File
@@ -77,7 +77,7 @@ public:
Item* child(int i) const;
const QList<ItemPtr>& children() const;
ItemPtr shared_ptr_from_raw(Item* item);
ItemPtr shared_ptr_from_raw(Item* item, bool traverse = false);
const QString& name() const;
void set_name(const QString& n);
@@ -97,6 +97,8 @@ public:
Project* project() const;
void set_project(Project* project);
QList<ItemPtr> get_children_of_type(Type type, bool recursive) const;
virtual bool CanHaveChildren() const;
bool ChildExistsWithName(const QString& name);
+50 -79
View File
@@ -25,7 +25,7 @@
#include "config/config.h"
#include "common/channellayout.h"
#include "common/timecodefunctions.h"
#include "common/xmlreadloop.h"
#include "common/xmlutils.h"
#include "node/factory.h"
#include "panel/panelmanager.h"
#include "panel/node/node.h"
@@ -59,97 +59,68 @@ void Sequence::Load(QXmlStreamReader *reader, QHash<quintptr, StreamPtr> &, QLis
QHash<quintptr, NodeOutput*> output_ptrs;
QList<NodeParam::SerializedConnection> desired_connections;
XMLReadLoop(reader, "sequence") {
while (XMLReadNextStartElement(reader)) {
if (cancelled && *cancelled) {
return;
}
if (reader->isStartElement()) {
if (reader->name() == "video") {
int video_width, video_height;
rational video_timebase;
if (reader->name() == QStringLiteral("video")) {
int video_width, video_height;
rational video_timebase;
XMLReadLoop(reader, "video") {
if (cancelled && *cancelled) {
return;
}
if (reader->isStartElement()) {
if (reader->name() == "width") {
reader->readNext();
video_width = reader->text().toInt();
} else if (reader->name() == "height") {
reader->readNext();
video_height = reader->text().toInt();
} else if (reader->name() == "timebase") {
reader->readNext();
video_timebase = rational::fromString(reader->text().toString());
}
}
while (XMLReadNextStartElement(reader)) {
if (cancelled && *cancelled) {
return;
}
set_video_params(VideoParams(video_width, video_height, video_timebase));
} else if (reader->name() == "audio") {
int rate;
uint64_t layout;
XMLReadLoop(reader, "audio") {
if (reader->isStartElement()) {
if (reader->name() == "rate") {
reader->readNext();
rate = reader->text().toInt();
} else if (reader->name() == "layout") {
reader->readNext();
layout = reader->text().toULongLong();
}
}
}
set_audio_params(AudioParams(rate, layout));
} else if (reader->name() == "node" || reader->name() == "viewer") {
Node* node;
if (reader->name() == "node") {
QString node_id;
XMLAttributeLoop(reader, attr) {
if (attr.name() == "id") {
node_id = attr.value().toString();
// Currently the only thing we need
break;
}
}
if (node_id.isEmpty()) {
qDebug() << "Found node with no ID";
continue;
}
node = NodeFactory::CreateFromID(node_id);
if (!node) {
qDebug() << "Failed to load" << node_id << "- no node with that ID is installed";
continue;
}
if (reader->name() == QStringLiteral("width")) {
video_width = reader->readElementText().toInt();
} else if (reader->name() == QStringLiteral("height")) {
video_height = reader->readElementText().toInt();
} else if (reader->name() == QStringLiteral("timebase")) {
video_timebase = rational::fromString(reader->readElementText());
} else {
node = viewer_output_;
}
if (node) {
node->Load(reader, output_ptrs, desired_connections, footage_connections, cancelled, reader->name().toString());
AddNode(node);
reader->skipCurrentElement();
}
}
set_video_params(VideoParams(video_width, video_height, video_timebase));
} else if (reader->name() == QStringLiteral("audio")) {
int rate;
uint64_t layout;
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("rate")) {
rate = reader->readElementText().toInt();
} else if (reader->name() == QStringLiteral("layout")) {
layout = reader->readElementText().toULongLong();
} else {
reader->skipCurrentElement();
}
}
set_audio_params(AudioParams(rate, layout));
} else if (reader->name() == QStringLiteral("node") || reader->name() == QStringLiteral("viewer")) {
Node* node;
if (reader->name() == QStringLiteral("node")) {
node = XMLLoadNode(reader);
} else {
node = viewer_output_;
}
if (node) {
node->Load(reader, output_ptrs, desired_connections, footage_connections, cancelled);
AddNode(node);
}
} else {
reader->skipCurrentElement();
}
}
// Make connections
foreach (const NodeParam::SerializedConnection& con, desired_connections) {
NodeParam::ConnectEdge(output_ptrs.value(con.output),
con.input);
}
XMLConnectNodes(output_ptrs, desired_connections);
// Ensure this and all children are in the main thread
// (FIXME: Weird place for this? This should probably be in ProjectLoadManager somehow)
@@ -228,7 +199,7 @@ QString Sequence::duration()
int64_t timestamp = Timecode::time_to_timestamp(timeline_length, video_params().time_base());
return Timecode::timestamp_to_timecode(timestamp, video_params().time_base(), Timecode::CurrentDisplay());
return Timecode::timestamp_to_timecode(timestamp, video_params().time_base(), Core::instance()->GetTimecodeDisplay());
}
QString Sequence::rate()
+2 -1
View File
@@ -27,6 +27,7 @@
#include "render/videoparams.h"
#include "project/item/footage/stream.h"
#include "project/item/item.h"
#include "timeline/timelinepoints.h"
class Sequence;
using SequencePtr = std::shared_ptr<Sequence>;
@@ -34,7 +35,7 @@ using SequencePtr = std::shared_ptr<Sequence>;
/**
* @brief The main timeline object, an graph of edited clips that forms a complete edit
*/
class Sequence : public Item, public NodeGraph
class Sequence : public Item, public NodeGraph, public TimelinePoints
{
public:
Sequence();
+25 -17
View File
@@ -23,7 +23,7 @@
#include <QDir>
#include <QFileInfo>
#include "common/xmlreadloop.h"
#include "common/xmlutils.h"
#include "core.h"
#include "dialog/progress/progress.h"
#include "window/mainwindow/mainwindow.h"
@@ -35,29 +35,32 @@ Project::Project()
void Project::Load(QXmlStreamReader *reader, const QAtomicInt* cancelled)
{
qDebug() << "Hello?";
QHash<quintptr, StreamPtr> footage_ptrs;
QList<NodeInput::FootageConnection> footage_connections;
XMLReadLoop(reader, "project") {
if (reader->isStartElement()) {
if (reader->name() == "folder") {
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("folder")) {
// Assume this folder is our root
root_.Load(reader, footage_ptrs, footage_connections, cancelled);
// Assume this folder is our root
root_.Load(reader, footage_ptrs, footage_connections, cancelled);
} else if (reader->name() == "colormanagement") {
} else if (reader->name() == QStringLiteral("colormanagement")) {
// Read color management info
XMLReadLoop(reader, "colormanagement") {
if (reader->name() == "config") {
reader->readNext();
set_ocio_config(reader->text().toString());
} else if (reader->name() == "default") {
reader->readNext();
set_default_input_colorspace(reader->text().toString());
}
// Read color management info
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("config")) {
set_ocio_config(reader->readElementText());
} else if (reader->name() == QStringLiteral("default")) {
set_default_input_colorspace(reader->readElementText());
} else {
reader->skipCurrentElement();
}
}
} else {
reader->skipCurrentElement();
}
}
@@ -97,7 +100,7 @@ QString Project::name() const
if (filename_.isEmpty()) {
return tr("(untitled)");
} else {
return QFileInfo(filename_).baseName();
return QFileInfo(filename_).completeBaseName();
}
}
@@ -137,3 +140,8 @@ ColorManager *Project::color_manager()
{
return &color_manager_;
}
QList<ItemPtr> Project::get_items_of_type(Item::Type type) const
{
return root_.get_children_of_type(type, true);
}
+2
View File
@@ -63,6 +63,8 @@ public:
ColorManager* color_manager();
QList<ItemPtr> get_items_of_type(Item::Type type) const;
signals:
void NameChanged();
+21 -15
View File
@@ -4,6 +4,8 @@
#include <QFile>
#include <QXmlStreamReader>
#include "common/xmlutils.h"
ProjectLoadManager::ProjectLoadManager(const QString &filename) :
filename_(filename)
{
@@ -17,28 +19,32 @@ void ProjectLoadManager::Action()
if (project_file.open(QFile::ReadOnly | QFile::Text)) {
QXmlStreamReader reader(&project_file);
while (!reader.atEnd()) {
reader.readNext();
qDebug() << "Hello?";
if (reader.isStartElement()) {
if (reader.name() == "version") {
reader.readNext();
while (XMLReadNextStartElement(&reader)) {
if (reader.name() == QStringLiteral("olive")) {
while(XMLReadNextStartElement(&reader)) {
if (reader.name() == QStringLiteral("version")) {
qDebug() << "Project version:" << reader.readElementText();
} else if (reader.name() == QStringLiteral("project")) {
ProjectPtr project = std::make_shared<Project>();
qDebug() << "Project version:" << reader.text();
} else if (reader.name() == "project") {
ProjectPtr project = std::make_shared<Project>();
project->set_filename(filename_);
project->set_filename(filename_);
project->Load(&reader, &IsCancelled());
project->Load(&reader, &IsCancelled());
// Ensure project is in main thread
moveToThread(qApp->thread());
// Ensure project is in main thread
moveToThread(qApp->thread());
if (!IsCancelled()) {
emit ProjectLoaded(project);
if (!IsCancelled()) {
emit ProjectLoaded(project);
}
} else {
reader.skipCurrentElement();
}
}
} else {
reader.skipCurrentElement();
}
}