change: change code style to Linux style except indent.

This commit is contained in:
Mike Solar
2025-08-03 03:09:40 +08:00
parent 65ab76edc8
commit 74f73ab3be
789 changed files with 77113 additions and 68888 deletions
File diff suppressed because it is too large Load Diff
+309 -297
View File
@@ -23,478 +23,490 @@
#include "node/block/block.h"
namespace olive {
namespace olive
{
class Sequence;
/**
* @brief A time traversal Node for sorting through one channel/track of Blocks
*/
class Track : public Node
{
Q_OBJECT
class Track : public Node {
Q_OBJECT
public:
enum Type {
kNone = -1,
kVideo,
kAudio,
kSubtitle,
kCount
};
enum Type { kNone = -1, kVideo, kAudio, kSubtitle, kCount };
Track();
Track();
NODE_DEFAULT_FUNCTIONS(Track)
NODE_DEFAULT_FUNCTIONS(Track)
const Track::Type& type() const;
void set_type(const Track::Type& track_type);
const Track::Type &type() const;
void set_type(const Track::Type &track_type);
virtual QString Name() const override;
virtual QString id() const override;
virtual QVector<CategoryID> Category() const override;
virtual QString Description() const override;
virtual QString Name() const override;
virtual QString id() const override;
virtual QVector<CategoryID> Category() const override;
virtual QString Description() const override;
virtual ActiveElements GetActiveElementsAtTime(const QString &input, const TimeRange &r) const override;
virtual void Value(const NodeValueRow& value, const NodeGlobals &globals, NodeValueTable *table) const override;
virtual ActiveElements
GetActiveElementsAtTime(const QString &input,
const TimeRange &r) const override;
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
NodeValueTable *table) const override;
virtual TimeRange InputTimeAdjustment(const QString& input, int element, const TimeRange& input_time, bool clamp) const override;
virtual TimeRange InputTimeAdjustment(const QString &input, int element,
const TimeRange &input_time,
bool clamp) const override;
virtual TimeRange OutputTimeAdjustment(const QString& input, int element, const TimeRange& input_time) const override;
virtual TimeRange
OutputTimeAdjustment(const QString &input, int element,
const TimeRange &input_time) const override;
static rational TransformTimeForBlock(const Block* block, const rational& time)
{
if (time == RATIONAL_MAX || time == RATIONAL_MIN) {
return time;
}
static rational TransformTimeForBlock(const Block *block,
const rational &time)
{
if (time == RATIONAL_MAX || time == RATIONAL_MIN) {
return time;
}
return time - block->in();
}
return time - block->in();
}
static TimeRange TransformRangeForBlock(const Block* block, const TimeRange& range)
{
return TimeRange(TransformTimeForBlock(block, range.in()), TransformTimeForBlock(block, range.out()));
}
static TimeRange TransformRangeForBlock(const Block *block,
const TimeRange &range)
{
return TimeRange(TransformTimeForBlock(block, range.in()),
TransformTimeForBlock(block, range.out()));
}
static rational TransformTimeFromBlock(const Block* block, const rational& time)
{
if (time == RATIONAL_MAX || time == RATIONAL_MIN) {
return time;
}
static rational TransformTimeFromBlock(const Block *block,
const rational &time)
{
if (time == RATIONAL_MAX || time == RATIONAL_MIN) {
return time;
}
return time + block->in();
}
return time + block->in();
}
static TimeRange TransformRangeFromBlock(const Block* block, const TimeRange& range)
{
return TimeRange(TransformTimeFromBlock(block, range.in()), TransformTimeFromBlock(block, range.out()));
}
static TimeRange TransformRangeFromBlock(const Block *block,
const TimeRange &range)
{
return TimeRange(TransformTimeFromBlock(block, range.in()),
TransformTimeFromBlock(block, range.out()));
}
const double& GetTrackHeight() const;
void SetTrackHeight(const double& height);
const double &GetTrackHeight() const;
void SetTrackHeight(const double &height);
int GetTrackHeightInPixels() const
{
return InternalHeightToPixelHeight(GetTrackHeight());
}
int GetTrackHeightInPixels() const
{
return InternalHeightToPixelHeight(GetTrackHeight());
}
void SetTrackHeightInPixels(int h)
{
SetTrackHeight(PixelHeightToInternalHeight(h));
}
void SetTrackHeightInPixels(int h)
{
SetTrackHeight(PixelHeightToInternalHeight(h));
}
virtual bool LoadCustom(QXmlStreamReader *reader, SerializedData *data) override;
virtual void SaveCustom(QXmlStreamWriter *writer) const override;
virtual void PostLoadEvent(SerializedData *data) override;
virtual bool LoadCustom(QXmlStreamReader *reader,
SerializedData *data) override;
virtual void SaveCustom(QXmlStreamWriter *writer) const override;
virtual void PostLoadEvent(SerializedData *data) override;
static int InternalHeightToPixelHeight(double h)
{
return qRound(h * QFontMetrics(QFont()).height());
}
static int InternalHeightToPixelHeight(double h)
{
return qRound(h * QFontMetrics(QFont()).height());
}
static double PixelHeightToInternalHeight(int h)
{
return double(h) / double(QFontMetrics(QFont()).height());
}
static double PixelHeightToInternalHeight(int h)
{
return double(h) / double(QFontMetrics(QFont()).height());
}
static int GetDefaultTrackHeightInPixels()
{
return InternalHeightToPixelHeight(kTrackHeightDefault);
}
static int GetDefaultTrackHeightInPixels()
{
return InternalHeightToPixelHeight(kTrackHeightDefault);
}
static int GetMinimumTrackHeightInPixels()
{
return InternalHeightToPixelHeight(kTrackHeightMinimum);
}
static int GetMinimumTrackHeightInPixels()
{
return InternalHeightToPixelHeight(kTrackHeightMinimum);
}
virtual void Retranslate() override;
virtual void Retranslate() override;
class Reference
{
public:
Reference() :
type_(kNone),
index_(-1)
{
}
class Reference {
public:
Reference()
: type_(kNone)
, index_(-1)
{
}
Reference(const Track::Type& type, const int& index) :
type_(type),
index_(index)
{
}
Reference(const Track::Type &type, const int &index)
: type_(type)
, index_(index)
{
}
const Track::Type& type() const
{
return type_;
}
const Track::Type &type() const
{
return type_;
}
const int& index() const
{
return index_;
}
const int &index() const
{
return index_;
}
bool operator==(const Reference& ref) const
{
return type_ == ref.type_ && index_ == ref.index_;
}
bool operator==(const Reference &ref) const
{
return type_ == ref.type_ && index_ == ref.index_;
}
bool operator!=(const Reference& ref) const
{
return !(*this == ref);
}
bool operator!=(const Reference &ref) const
{
return !(*this == ref);
}
bool operator<(const Track::Reference& rhs) const
{
if (type_ != rhs.type_) {
return type_ < rhs.type_;
}
bool operator<(const Track::Reference &rhs) const
{
if (type_ != rhs.type_) {
return type_ < rhs.type_;
}
return index_ < rhs.index_;
}
return index_ < rhs.index_;
}
QString ToString() const
{
QString type_string = TypeToString(type_);
if (type_string.isEmpty()) {
return QString();
} else {
return QStringLiteral("%1:%2").arg(type_string, QString::number(index_));
}
}
QString ToString() const
{
QString type_string = TypeToString(type_);
if (type_string.isEmpty()) {
return QString();
} else {
return QStringLiteral("%1:%2").arg(type_string,
QString::number(index_));
}
}
/// For IDs that shouldn't change between localizations
static QString TypeToString(Type type)
{
switch (type) {
case kVideo:
return QStringLiteral("v");
case kAudio:
return QStringLiteral("a");
case kSubtitle:
return QStringLiteral("s");
case kCount:
case kNone:
break;
}
/// For IDs that shouldn't change between localizations
static QString TypeToString(Type type)
{
switch (type) {
case kVideo:
return QStringLiteral("v");
case kAudio:
return QStringLiteral("a");
case kSubtitle:
return QStringLiteral("s");
case kCount:
case kNone:
break;
}
return QString();
}
return QString();
}
/// For human-facing strings
static QString TypeToTranslatedString(Type type)
{
switch (type) {
case kVideo:
return tr("V");
case kAudio:
return tr("A");
case kSubtitle:
return tr("S");
case kCount:
case kNone:
break;
}
/// For human-facing strings
static QString TypeToTranslatedString(Type type)
{
switch (type) {
case kVideo:
return tr("V");
case kAudio:
return tr("A");
case kSubtitle:
return tr("S");
case kCount:
case kNone:
break;
}
return QString();
}
return QString();
}
static Type TypeFromString(const QString& s)
{
if (s.size() >= 3) {
if (s.at(1) == ':') {
if (s.at(0) == 'v') {
// Video stream
return Track::kVideo;
} else if (s.at(0) == 'a') {
// Audio stream
return Track::kAudio;
} else if (s.at(0) == 's') {
// Subtitle stream
return Track::kSubtitle;
}
}
}
static Type TypeFromString(const QString &s)
{
if (s.size() >= 3) {
if (s.at(1) == ':') {
if (s.at(0) == 'v') {
// Video stream
return Track::kVideo;
} else if (s.at(0) == 'a') {
// Audio stream
return Track::kAudio;
} else if (s.at(0) == 's') {
// Subtitle stream
return Track::kSubtitle;
}
}
}
return Track::kNone;
}
return Track::kNone;
}
static Reference FromString(const QString& s)
{
Reference ref;
Type parse_type = TypeFromString(s);
static Reference FromString(const QString &s)
{
Reference ref;
Type parse_type = TypeFromString(s);
if (parse_type != Track::kNone) {
bool ok;
int parse_index = s.mid(2).toInt(&ok);
if (parse_type != Track::kNone) {
bool ok;
int parse_index = s.mid(2).toInt(&ok);
if (ok) {
ref.type_ = parse_type;
ref.index_ = parse_index;
}
}
if (ok) {
ref.type_ = parse_type;
ref.index_ = parse_index;
}
}
return ref;
}
return ref;
}
bool IsValid() const
{
return type_ > kNone && type_ < kCount && index_ >= 0;
}
bool IsValid() const
{
return type_ > kNone && type_ < kCount && index_ >= 0;
}
private:
Track::Type type_;
private:
Track::Type type_;
int index_;
int index_;
};
};
Reference ToReference() const
{
return Reference(type(), Index());
}
Reference ToReference() const
{
return Reference(type(), Index());
}
const int &Index() const
{
return index_;
}
const int& Index() const
{
return index_;
}
void SetIndex(const int &index);
void SetIndex(const int& index);
/**
/**
* @brief Returns the block that starts BEFORE (not AT) and ends AFTER (not AT) a time
*
* Catches the first block that matches `block.in < time && block.out > time` or nullptr if any
* block starts/ends precisely at that time or the time exceeds the track length.
*/
Block* BlockContainingTime(const rational& time) const;
Block *BlockContainingTime(const rational &time) const;
/**
/**
* @brief Returns the block that starts BEFORE a given time and ends either AFTER or AT that time
*
* @return Catches the first block that matches `block.out >= time` or nullptr if this time
* exceeds the track length.
*/
Block* NearestBlockBefore(const rational& time) const;
Block *NearestBlockBefore(const rational &time) const;
/**
/**
* @brief Returns the block that starts BEFORE or AT a given time.
*
* @return Catches the first block that matches `block.out > time` or nullptr if this time
* exceeds the track length.
*/
Block* NearestBlockBeforeOrAt(const rational& time) const;
Block *NearestBlockBeforeOrAt(const rational &time) const;
/**
/**
* @brief Returns the block that starts either AT a given time or the soonest block AFTER
*
* @return Catches the first block that matches `block.in >= time` or nullptr if this time
* exceeds the track length.
*/
Block* NearestBlockAfterOrAt(const rational& time) const;
Block *NearestBlockAfterOrAt(const rational &time) const;
/**
/**
* @brief Returns the block that starts AFTER the given time (but never AT the given time)
*
* @return Catches the first block that matches `block.in > time` or nullptr if this time
* exceeds the track length.
*/
Block* NearestBlockAfter(const rational& time) const;
Block *NearestBlockAfter(const rational &time) const;
/*
/*
* @brief Returns whether a time range is empty or only has a gap
*/
bool IsRangeFree(const TimeRange &range) const;
bool IsRangeFree(const TimeRange &range) const;
const QVector<Block *> &Blocks() const
{
return blocks_;
}
const QVector<Block *> &Blocks() const
{
return blocks_;
}
virtual void InvalidateCache(const TimeRange& range, const QString& from, int element, InvalidateCacheOptions options) override;
virtual void InvalidateCache(const TimeRange &range, const QString &from,
int element,
InvalidateCacheOptions options) override;
Block *VisibleBlockAtTime(const rational &t) const
{
int index = GetBlockIndexAtTime(t);
return (index == -1) ? nullptr : blocks_.at(index);
}
Block *VisibleBlockAtTime(const rational &t) const
{
int index = GetBlockIndexAtTime(t);
return (index == -1) ? nullptr : blocks_.at(index);
}
/**
/**
* @brief Adds Block `block` at the very beginning of the Sequence before all other clips
*/
void PrependBlock(Block* block);
void PrependBlock(Block *block);
/**
/**
* @brief Inserts Block `block` at a specific index (0 is the start of the timeline)
*
* If the index == 0, this function does the same as PrependBlock(). If the index >= the current number of blocks,
* this function is the same as AppendBlock().
*/
void InsertBlockAtIndex(Block* block, int index);
void InsertBlockAtIndex(Block *block, int index);
/**
/**
* @brief Inserts Block after another Block
*
* Equivalent to calling InsertBlockBetweenBlocks(block, before, before->next())
*/
void InsertBlockAfter(Block* block, Block* before);
void InsertBlockAfter(Block *block, Block *before);
/**
/**
* @brief Inserts Block before another Block
*/
void InsertBlockBefore(Block* block, Block* after);
void InsertBlockBefore(Block *block, Block *after);
/**
/**
* @brief Adds Block `block` at the very end of the Sequence after all other clips
*/
void AppendBlock(Block* block);
void AppendBlock(Block *block);
/**
/**
* @brief Removes a Block pushing all subsequent Blocks earlier to take up the space
*/
void RippleRemoveBlock(Block* block);
void RippleRemoveBlock(Block *block);
/**
/**
* @brief Replaces Block `old` with Block `replace`
*
* Both blocks must have equal lengths.
*/
void ReplaceBlock(Block* old, Block* replace);
void ReplaceBlock(Block *old, Block *replace);
rational track_length() const;
rational track_length() const;
bool IsMuted() const;
bool IsMuted() const;
bool IsLocked() const;
bool IsLocked() const;
int GetArrayIndexFromBlock(Block* block) const;
int GetArrayIndexFromBlock(Block *block) const;
Sequence *sequence() const
{
return sequence_;
}
Sequence *sequence() const
{
return sequence_;
}
void set_sequence(Sequence *sequence)
{
sequence_ = sequence;
}
void set_sequence(Sequence *sequence)
{
sequence_ = sequence;
}
static const double kTrackHeightDefault;
static const double kTrackHeightMinimum;
static const double kTrackHeightInterval;
static const double kTrackHeightDefault;
static const double kTrackHeightMinimum;
static const double kTrackHeightInterval;
static const QString kBlockInput;
static const QString kMutedInput;
static const QString kArrayMapInput;
static const QString kBlockInput;
static const QString kMutedInput;
static const QString kArrayMapInput;
public slots:
void SetMuted(bool e);
void SetMuted(bool e);
void SetLocked(bool e);
void SetLocked(bool e);
signals:
/**
/**
* @brief Signal emitted when a Block is added to this Track
*/
void BlockAdded(Block* block);
void BlockAdded(Block *block);
/**
/**
* @brief Signal emitted when a Block is removed from this Track
*/
void BlockRemoved(Block* block);
void BlockRemoved(Block *block);
/**
/**
* @brief Signal emitted when the length of the track has changed
*/
void TrackLengthChanged();
void TrackLengthChanged();
/**
/**
* @brief Signal emitted when the height of the track has changed
*/
void TrackHeightChanged(qreal virtual_height);
void TrackHeightChanged(qreal virtual_height);
/**
/**
* @brief Signal emitted when the muted setting changes
*/
void MutedChanged(bool e);
void MutedChanged(bool e);
/**
/**
* @brief Signal emitted when the index has changed
*/
void IndexChanged(int old, int now);
void IndexChanged(int old, int now);
/**
/**
* @brief Emitted when a block changes length and all the subsequent blocks had to update
*/
void BlocksRefreshed();
void BlocksRefreshed();
protected:
virtual void InputConnectedEvent(const QString& input, int element, Node *node) override;
virtual void InputValueChangedEvent(const QString& input, int element) override;
virtual void InputConnectedEvent(const QString &input, int element,
Node *node) override;
virtual void InputValueChangedEvent(const QString &input,
int element) override;
private:
void UpdateInOutFrom(int index);
void UpdateInOutFrom(int index);
int GetArrayIndexFromCacheIndex(int index) const;
int GetArrayIndexFromCacheIndex(int index) const;
int GetCacheIndexFromArrayIndex(int index) const;
int GetCacheIndexFromArrayIndex(int index) const;
int GetBlockIndexAtTime(const rational &time) const;
int GetBlockIndexAtTime(const rational &time) const;
void ProcessAudioTrack(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const;
void ProcessAudioTrack(const NodeValueRow &value,
const NodeGlobals &globals,
NodeValueTable *table) const;
int ConnectBlock(Block *b);
int ConnectBlock(Block *b);
void UpdateArrayMap();
void UpdateArrayMap();
TimeRangeList block_length_pending_invalidations_;
TimeRangeList block_length_pending_invalidations_;
QVector<Block*> blocks_;
QVector<uint32_t> block_array_indexes_;
QVector<Block *> blocks_;
QVector<uint32_t> block_array_indexes_;
std::list<int> empty_inputs_;
std::list<int> empty_inputs_;
Track::Type track_type_;
Track::Type track_type_;
double track_height_;
double track_height_;
int index_;
int index_;
bool locked_;
bool locked_;
Sequence *sequence_;
Sequence *sequence_;
int ignore_arraymap_;
bool arraymap_invalid_;
bool ignore_arraymap_set_;
int ignore_arraymap_;
bool arraymap_invalid_;
bool ignore_arraymap_set_;
private slots:
void BlockLengthChanged();
void RefreshBlockCacheFromArrayMap();
void BlockLengthChanged();
void RefreshBlockCacheFromArrayMap();
};
uint qHash(const Track::Reference& r, uint seed = 0);
uint qHash(const Track::Reference &r, uint seed = 0);
QDataStream &operator<<(QDataStream &out, const Track::Reference &ref);
+93 -89
View File
@@ -26,168 +26,172 @@
#include "node/output/viewer/viewer.h"
#include "node/project/sequence/sequence.h"
namespace olive {
namespace olive
{
TrackList::TrackList(Sequence *parent, const Track::Type &type, const QString &track_input) :
QObject(parent),
track_input_(track_input),
total_length_(0),
type_(type)
TrackList::TrackList(Sequence *parent, const Track::Type &type,
const QString &track_input)
: QObject(parent)
, track_input_(track_input)
, total_length_(0)
, type_(type)
{
}
Track *TrackList::GetTrackAt(int index) const
{
if (index >= 0 && index < track_cache_.size()) {
return track_cache_.at(index);
} else {
return nullptr;
}
if (index >= 0 && index < track_cache_.size()) {
return track_cache_.at(index);
} else {
return nullptr;
}
}
void TrackList::TrackConnected(Node *node, int element)
{
if (element == -1) {
parent()->InvalidateAll(track_input(), element);
return;
}
if (element == -1) {
parent()->InvalidateAll(track_input(), element);
return;
}
Track* track = dynamic_cast<Track*>(node);
Track *track = dynamic_cast<Track *>(node);
if (!track) {
return;
}
if (!track) {
return;
}
// Determine where in the cache this block will be
int cache_index = -1;
for (int i=element+1; i<ArraySize(); i++) {
// Find next track because this will be the index we insert at
cache_index = GetCacheIndexFromArrayIndex(i);
// Determine where in the cache this block will be
int cache_index = -1;
for (int i = element + 1; i < ArraySize(); i++) {
// Find next track because this will be the index we insert at
cache_index = GetCacheIndexFromArrayIndex(i);
if (cache_index >= 0) {
break;
}
}
if (cache_index >= 0) {
break;
}
}
// If there was no next, this will be inserted at the end
if (cache_index == -1) {
cache_index = track_cache_.size();
}
// If there was no next, this will be inserted at the end
if (cache_index == -1) {
cache_index = track_cache_.size();
}
track_cache_.insert(cache_index, track);
track_array_indexes_.insert(cache_index, element);
track_cache_.insert(cache_index, track);
track_array_indexes_.insert(cache_index, element);
// Update track indexes in the list (including this track)
UpdateTrackIndexesFrom(cache_index);
// Update track indexes in the list (including this track)
UpdateTrackIndexesFrom(cache_index);
connect(track, &Track::TrackLengthChanged, this, &TrackList::UpdateTotalLength);
connect(track, &Track::TrackHeightChanged, this, [this](){
Track *t = static_cast<Track*>(sender());
emit TrackHeightChanged(t, t->GetTrackHeightInPixels());
});
connect(track, &Track::TrackLengthChanged, this,
&TrackList::UpdateTotalLength);
connect(track, &Track::TrackHeightChanged, this, [this]() {
Track *t = static_cast<Track *>(sender());
emit TrackHeightChanged(t, t->GetTrackHeightInPixels());
});
track->set_type(type_);
track->set_sequence(parent());
track->set_type(type_);
track->set_sequence(parent());
emit TrackListChanged();
emit TrackListChanged();
// This function must be called after the track is added to track_cache_, since it uses track_cache_ to determine
// the track's index
emit TrackAdded(track);
// This function must be called after the track is added to track_cache_, since it uses track_cache_ to determine
// the track's index
emit TrackAdded(track);
UpdateTotalLength();
UpdateTotalLength();
}
void TrackList::TrackDisconnected(Node *node, int element)
{
if (element == -1) {
// User has replaced the entire array, we will invalidate everything
parent()->InvalidateAll(track_input(), element);
return;
}
if (element == -1) {
// User has replaced the entire array, we will invalidate everything
parent()->InvalidateAll(track_input(), element);
return;
}
Track* track = dynamic_cast<Track*>(node);
Track *track = dynamic_cast<Track *>(node);
if (!track) {
return;
}
if (!track) {
return;
}
// Traverse through Tracks uncaching and disconnecting them
emit TrackRemoved(track);
// Traverse through Tracks uncaching and disconnecting them
emit TrackRemoved(track);
int cache_index = GetCacheIndexFromArrayIndex(element);
int cache_index = GetCacheIndexFromArrayIndex(element);
// Remove track here
track_cache_.removeAt(cache_index);
track_array_indexes_.removeAt(cache_index);
// Remove track here
track_cache_.removeAt(cache_index);
track_array_indexes_.removeAt(cache_index);
// Update indices for all subsequent tracks
UpdateTrackIndexesFrom(cache_index);
// Update indices for all subsequent tracks
UpdateTrackIndexesFrom(cache_index);
track->SetIndex(-1);
track->set_type(Track::kNone);
track->set_sequence(nullptr);
track->SetIndex(-1);
track->set_type(Track::kNone);
track->set_sequence(nullptr);
disconnect(track, &Track::TrackLengthChanged, this, &TrackList::UpdateTotalLength);
disconnect(track, &Track::TrackLengthChanged, this,
&TrackList::UpdateTotalLength);
emit TrackListChanged();
emit TrackListChanged();
UpdateTotalLength();
UpdateTotalLength();
}
void TrackList::UpdateTrackIndexesFrom(int index)
{
for (int i=index; i<track_cache_.size(); i++) {
track_cache_.at(i)->SetIndex(i);
}
for (int i = index; i < track_cache_.size(); i++) {
track_cache_.at(i)->SetIndex(i);
}
}
Project *TrackList::GetParentGraph() const
{
return parent()->parent();
return parent()->parent();
}
const QString& TrackList::track_input() const
const QString &TrackList::track_input() const
{
return track_input_;
return track_input_;
}
NodeInput TrackList::track_input(int element) const
{
return NodeInput(parent(), track_input(), element);
return NodeInput(parent(), track_input(), element);
}
Sequence *TrackList::parent() const
{
return static_cast<Sequence*>(QObject::parent());
return static_cast<Sequence *>(QObject::parent());
}
int TrackList::ArraySize() const
{
return parent()->InputArraySize(track_input());
return parent()->InputArraySize(track_input());
}
void TrackList::ArrayAppend()
{
parent()->InputArrayAppend(track_input());
parent()->InputArrayAppend(track_input());
}
void TrackList::ArrayRemoveLast()
{
parent()->InputArrayRemoveLast(track_input());
parent()->InputArrayRemoveLast(track_input());
}
void TrackList::UpdateTotalLength()
{
total_length_ = 0;
total_length_ = 0;
foreach (Track* track, track_cache_) {
if (track) {
total_length_ = qMax(total_length_, track->track_length());
}
}
foreach (Track *track, track_cache_) {
if (track) {
total_length_ = qMax(total_length_, track->track_length());
}
}
emit LengthChanged(total_length_);
emit LengthChanged(total_length_);
}
}
+56 -56
View File
@@ -26,103 +26,103 @@
#include "node/output/track/track.h"
#include "timeline/timelinecommon.h"
namespace olive {
namespace olive
{
class Sequence;
class TrackList : public QObject
{
Q_OBJECT
class TrackList : public QObject {
Q_OBJECT
public:
TrackList(Sequence *parent, const Track::Type& type, const QString& track_input);
TrackList(Sequence *parent, const Track::Type &type,
const QString &track_input);
const Track::Type& type() const
{
return type_;
}
const Track::Type &type() const
{
return type_;
}
const QVector<Track*>& GetTracks() const
{
return track_cache_;
}
const QVector<Track *> &GetTracks() const
{
return track_cache_;
}
Track* GetTrackAt(int index) const;
Track *GetTrackAt(int index) const;
const rational& GetTotalLength() const
{
return total_length_;
}
const rational &GetTotalLength() const
{
return total_length_;
}
int GetTrackCount() const
{
return track_cache_.size();
}
int GetTrackCount() const
{
return track_cache_.size();
}
Project* GetParentGraph() const;
Project *GetParentGraph() const;
const QString &track_input() const;
NodeInput track_input(int element) const;
const QString &track_input() const;
NodeInput track_input(int element) const;
Sequence* parent() const;
Sequence *parent() const;
int ArraySize() const;
int ArraySize() const;
void ArrayAppend();
void ArrayRemoveLast();
void ArrayAppend();
void ArrayRemoveLast();
int GetArrayIndexFromCacheIndex(int index) const
{
return track_array_indexes_.at(index);
}
int GetArrayIndexFromCacheIndex(int index) const
{
return track_array_indexes_.at(index);
}
int GetCacheIndexFromArrayIndex(int index) const
{
return track_array_indexes_.indexOf(index);
}
int GetCacheIndexFromArrayIndex(int index) const
{
return track_array_indexes_.indexOf(index);
}
public slots:
/**
/**
* @brief Slot for when the track connection is added
*/
void TrackConnected(Node* node, int element);
void TrackConnected(Node *node, int element);
/**
/**
* @brief Slot for when the track connection is removed
*/
void TrackDisconnected(Node* node, int element);
void TrackDisconnected(Node *node, int element);
signals:
void TrackListChanged();
void TrackListChanged();
void LengthChanged(const rational &length);
void LengthChanged(const rational &length);
void TrackAdded(Track* track);
void TrackAdded(Track *track);
void TrackRemoved(Track* track);
void TrackRemoved(Track *track);
void TrackHeightChanged(Track *track, int height);
void TrackHeightChanged(Track *track, int height);
private:
void UpdateTrackIndexesFrom(int index);
void UpdateTrackIndexesFrom(int index);
/**
/**
* @brief A cache of connected Tracks
*/
QVector<Track*> track_cache_;
QVector<int> track_array_indexes_;
QVector<Track *> track_cache_;
QVector<int> track_array_indexes_;
QString track_input_;
QString track_input_;
rational total_length_;
rational total_length_;
enum Track::Type type_;
enum Track::Type type_;
private slots:
/**
/**
* @brief Slot for when any of the track's length changes so we can update the length of the tracklist
*/
void UpdateTotalLength();
void UpdateTotalLength();
};
}
File diff suppressed because it is too large Load Diff
+197 -154
View File
@@ -31,7 +31,8 @@
#include "timeline/timelinemarker.h"
#include "timeline/timelineworkarea.h"
namespace olive {
namespace olive
{
class Footage;
@@ -40,229 +41,271 @@ class Footage;
*
* Receives update/time change signals from ViewerPanels and responds by sending them a texture of that frame
*/
class ViewerOutput : public Node
{
Q_OBJECT
class ViewerOutput : public Node {
Q_OBJECT
public:
ViewerOutput(bool create_buffer_inputs = true, bool create_default_streams = true);
ViewerOutput(bool create_buffer_inputs = true,
bool create_default_streams = true);
NODE_DEFAULT_FUNCTIONS(ViewerOutput)
NODE_DEFAULT_FUNCTIONS(ViewerOutput)
virtual QString Name() const override;
virtual QString id() const override;
virtual QVector<CategoryID> Category() const override;
virtual QString Description() const override;
virtual QString Name() const override;
virtual QString id() const override;
virtual QVector<CategoryID> Category() const override;
virtual QString Description() const override;
virtual QVariant data(const DataType &d) const override;
virtual QVariant data(const DataType &d) const override;
void set_default_parameters();
void set_default_parameters();
void set_parameters_from_footage(const QVector<ViewerOutput *> footage);
void set_parameters_from_footage(const QVector<ViewerOutput *> footage);
virtual void InvalidateCache(const TimeRange& range, const QString& from, int element, InvalidateCacheOptions options) override;
virtual void InvalidateCache(const TimeRange &range, const QString &from,
int element,
InvalidateCacheOptions options) override;
VideoParams GetVideoParams(int index = 0) const
{
// This check isn't strictly necessary (GetStandardValue will return a null VideoParams anyway),
// but it does suppress a warning message that we don't need
if (index < InputArraySize(kVideoParamsInput)) {
return GetStandardValue(kVideoParamsInput, index).value<VideoParams>();
} else {
return VideoParams();
}
}
VideoParams GetVideoParams(int index = 0) const
{
// This check isn't strictly necessary (GetStandardValue will return a null VideoParams anyway),
// but it does suppress a warning message that we don't need
if (index < InputArraySize(kVideoParamsInput)) {
return GetStandardValue(kVideoParamsInput, index)
.value<VideoParams>();
} else {
return VideoParams();
}
}
AudioParams GetAudioParams(int index = 0) const
{
// This check isn't strictly necessary (GetStandardValue will return a null VideoParams anyway),
// but it does suppress a warning message that we don't need
if (index < InputArraySize(kAudioParamsInput)) {
return GetStandardValue(kAudioParamsInput, index).value<AudioParams>();
} else {
return AudioParams();
}
}
AudioParams GetAudioParams(int index = 0) const
{
// This check isn't strictly necessary (GetStandardValue will return a null VideoParams anyway),
// but it does suppress a warning message that we don't need
if (index < InputArraySize(kAudioParamsInput)) {
return GetStandardValue(kAudioParamsInput, index)
.value<AudioParams>();
} else {
return AudioParams();
}
}
SubtitleParams GetSubtitleParams(int index = 0) const
{
// This check isn't strictly necessary (GetStandardValue will return a null VideoParams anyway),
// but it does suppress a warning message that we don't need
if (index < InputArraySize(kSubtitleParamsInput)) {
return GetStandardValue(kSubtitleParamsInput, index).value<SubtitleParams>();
} else {
return SubtitleParams();
}
}
SubtitleParams GetSubtitleParams(int index = 0) const
{
// This check isn't strictly necessary (GetStandardValue will return a null VideoParams anyway),
// but it does suppress a warning message that we don't need
if (index < InputArraySize(kSubtitleParamsInput)) {
return GetStandardValue(kSubtitleParamsInput, index)
.value<SubtitleParams>();
} else {
return SubtitleParams();
}
}
const rational &GetPlayhead() { return playhead_; }
const rational &GetPlayhead()
{
return playhead_;
}
void SetVideoParams(const VideoParams &video, int index = 0)
{
SetStandardValue(kVideoParamsInput, QVariant::fromValue(video), index);
}
void SetVideoParams(const VideoParams &video, int index = 0)
{
SetStandardValue(kVideoParamsInput, QVariant::fromValue(video), index);
}
void SetAudioParams(const AudioParams &audio, int index = 0)
{
SetStandardValue(kAudioParamsInput, QVariant::fromValue(audio), index);
}
void SetAudioParams(const AudioParams &audio, int index = 0)
{
SetStandardValue(kAudioParamsInput, QVariant::fromValue(audio), index);
}
void SetSubtitleParams(const SubtitleParams &subs, int index = 0)
{
SetStandardValue(kSubtitleParamsInput, QVariant::fromValue(subs), index);
}
void SetSubtitleParams(const SubtitleParams &subs, int index = 0)
{
SetStandardValue(kSubtitleParamsInput, QVariant::fromValue(subs),
index);
}
int GetVideoStreamCount() const
{
return InputArraySize(kVideoParamsInput);
}
int GetVideoStreamCount() const
{
return InputArraySize(kVideoParamsInput);
}
int GetAudioStreamCount() const
{
return InputArraySize(kAudioParamsInput);
}
int GetAudioStreamCount() const
{
return InputArraySize(kAudioParamsInput);
}
int GetSubtitleStreamCount() const
{
return InputArraySize(kSubtitleParamsInput);
}
int GetSubtitleStreamCount() const
{
return InputArraySize(kSubtitleParamsInput);
}
virtual int GetTotalStreamCount() const
{
return GetVideoStreamCount() + GetAudioStreamCount() + GetSubtitleStreamCount();
}
virtual int GetTotalStreamCount() const
{
return GetVideoStreamCount() + GetAudioStreamCount() +
GetSubtitleStreamCount();
}
const AudioWaveformCache *GetConnectedWaveform()
{
if (Node *n = GetConnectedSampleOutput()) {
return n->waveform_cache();
} else {
return nullptr;
}
}
const AudioWaveformCache *GetConnectedWaveform()
{
if (Node *n = GetConnectedSampleOutput()) {
return n->waveform_cache();
} else {
return nullptr;
}
}
bool HasEnabledVideoStreams() const;
bool HasEnabledAudioStreams() const;
bool HasEnabledSubtitleStreams() const;
bool HasEnabledVideoStreams() const;
bool HasEnabledAudioStreams() const;
bool HasEnabledSubtitleStreams() const;
VideoParams GetFirstEnabledVideoStream() const;
AudioParams GetFirstEnabledAudioStream() const;
SubtitleParams GetFirstEnabledSubtitleStream() const;
VideoParams GetFirstEnabledVideoStream() const;
AudioParams GetFirstEnabledAudioStream() const;
SubtitleParams GetFirstEnabledSubtitleStream() const;
const rational &GetLength() const { return last_length_; }
const rational &GetVideoLength() const { return video_length_; }
const rational &GetAudioLength() const { return audio_length_; }
const rational &GetLength() const
{
return last_length_;
}
const rational &GetVideoLength() const
{
return video_length_;
}
const rational &GetAudioLength() const
{
return audio_length_;
}
TimelineWorkArea *GetWorkArea() const { return workarea_; }
TimelineMarkerList *GetMarkers() const { return markers_; }
TimelineWorkArea *GetWorkArea() const
{
return workarea_;
}
TimelineMarkerList *GetMarkers() const
{
return markers_;
}
virtual TimeRange GetVideoCacheRange() const override
{
return TimeRange(0, GetVideoLength());
}
virtual TimeRange GetVideoCacheRange() const override
{
return TimeRange(0, GetVideoLength());
}
virtual TimeRange GetAudioCacheRange() const override
{
return TimeRange(0, GetAudioLength());
}
virtual TimeRange GetAudioCacheRange() const override
{
return TimeRange(0, GetAudioLength());
}
QVector<Track::Reference> GetEnabledStreamsAsReferences() const;
QVector<Track::Reference> GetEnabledStreamsAsReferences() const;
QVector<VideoParams> GetEnabledVideoStreams() const;
QVector<VideoParams> GetEnabledVideoStreams() const;
QVector<AudioParams> GetEnabledAudioStreams() const;
QVector<AudioParams> GetEnabledAudioStreams() const;
virtual void Retranslate() override;
virtual void Retranslate() override;
virtual Node *GetConnectedTextureOutput();
virtual Node *GetConnectedTextureOutput();
virtual ValueHint GetConnectedTextureValueHint();
virtual ValueHint GetConnectedTextureValueHint();
virtual Node *GetConnectedSampleOutput();
virtual Node *GetConnectedSampleOutput();
virtual ValueHint GetConnectedSampleValueHint();
virtual ValueHint GetConnectedSampleValueHint();
void SetWaveformEnabled(bool e);
void SetWaveformEnabled(bool e);
bool IsVideoAutoCacheEnabled() const { qDebug() << "sequence ac is a stub"; return false; }
void SetVideoAutoCacheEnabled(bool e) { qDebug() << "sequence ac is a stub"; }
bool IsVideoAutoCacheEnabled() const
{
qDebug() << "sequence ac is a stub";
return false;
}
void SetVideoAutoCacheEnabled(bool e)
{
qDebug() << "sequence ac is a stub";
}
virtual void Value(const NodeValueRow& value, const NodeGlobals &globals, NodeValueTable *table) const override;
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
NodeValueTable *table) const override;
const EncodingParams &GetLastUsedEncodingParams() const { return last_used_encoding_params_; }
void SetLastUsedEncodingParams(const EncodingParams &p) { last_used_encoding_params_ = p; }
const EncodingParams &GetLastUsedEncodingParams() const
{
return last_used_encoding_params_;
}
void SetLastUsedEncodingParams(const EncodingParams &p)
{
last_used_encoding_params_ = p;
}
virtual bool LoadCustom(QXmlStreamReader *reader, SerializedData *data) override;
virtual void SaveCustom(QXmlStreamWriter *writer) const override;
virtual bool LoadCustom(QXmlStreamReader *reader,
SerializedData *data) override;
virtual void SaveCustom(QXmlStreamWriter *writer) const override;
static const QString kVideoParamsInput;
static const QString kAudioParamsInput;
static const QString kSubtitleParamsInput;
static const QString kVideoParamsInput;
static const QString kAudioParamsInput;
static const QString kSubtitleParamsInput;
static const QString kTextureInput;
static const QString kSamplesInput;
static const QString kTextureInput;
static const QString kSamplesInput;
static const SampleFormat kDefaultSampleFormat;
static const SampleFormat kDefaultSampleFormat;
signals:
void FrameRateChanged(const rational&);
void FrameRateChanged(const rational &);
void LengthChanged(const rational& length);
void LengthChanged(const rational &length);
void SizeChanged(int width, int height);
void SizeChanged(int width, int height);
void PixelAspectChanged(const rational& pixel_aspect);
void PixelAspectChanged(const rational &pixel_aspect);
void InterlacingChanged(VideoParams::Interlacing mode);
void InterlacingChanged(VideoParams::Interlacing mode);
void VideoParamsChanged();
void AudioParamsChanged();
void VideoParamsChanged();
void AudioParamsChanged();
void TextureInputChanged();
void TextureInputChanged();
void SampleRateChanged(int sr);
void SampleRateChanged(int sr);
void ConnectedWaveformChanged();
void ConnectedWaveformChanged();
void PlayheadChanged(const rational &t);
void PlayheadChanged(const rational &t);
public slots:
void VerifyLength();
void VerifyLength();
void SetPlayhead(const rational &t);
void SetPlayhead(const rational &t);
protected:
virtual void InputConnectedEvent(const QString &input, int element, Node *output) override;
virtual void InputConnectedEvent(const QString &input, int element,
Node *output) override;
virtual void InputDisconnectedEvent(const QString &input, int element, Node *output) override;
virtual void InputDisconnectedEvent(const QString &input, int element,
Node *output) override;
virtual rational VerifyLengthInternal(Track::Type type) const;
virtual rational VerifyLengthInternal(Track::Type type) const;
virtual void InputValueChangedEvent(const QString& input, int element) override;
virtual void InputValueChangedEvent(const QString &input,
int element) override;
int AddStream(Track::Type type, const QVariant &value);
int SetStream(Track::Type type, const QVariant &value, int index);
int AddStream(Track::Type type, const QVariant &value);
int SetStream(Track::Type type, const QVariant &value, int index);
private:
rational last_length_;
rational video_length_;
rational audio_length_;
rational last_length_;
rational video_length_;
rational audio_length_;
VideoParams cached_video_params_;
VideoParams cached_video_params_;
AudioParams cached_audio_params_;
AudioParams cached_audio_params_;
TimelineWorkArea *workarea_;
TimelineMarkerList *markers_;
TimelineWorkArea *workarea_;
TimelineMarkerList *markers_;
bool autocache_input_video_;
bool autocache_input_audio_;
bool autocache_input_video_;
bool autocache_input_audio_;
EncodingParams last_used_encoding_params_;
EncodingParams last_used_encoding_params_;
bool waveform_requests_enabled_;
rational playhead_;
bool waveform_requests_enabled_;
rational playhead_;
};
}