style: unify identifier naming per updated conventions
Automated with clang-tidy readability-identifier-naming (config added to .clang-tidy) plus scripted passes, per the updated rules now documented in CONTRIBUTING.md: - types (class/struct/enum/alias/template params): PascalCase - functions, variables, members: snake_case (incl. rational -> Rational) - private/protected members: trailing underscore; static member variables likewise (instance_, available_themes_) - constants and enum values: snake_case (kLinear -> k_linear, F32P -> f32p); ALL_CAPS reserved for macros - macros: OAK_ prefix (OLIVE_ADD_TEST/OLIVE_ASSERT/OLIVE_CONFIG -> OAK_ADD_TEST/OAK_ASSERT/OAK_CONFIG, GL_PREAMBLE -> OAK_GL_PREAMBLE, include guards -> OAK_*) - file names: all lowercase (Current/Plugin/OliveHost/OliveClip/ OlivePluginInstance -> current/plugin/olivehost/oliveclip/ oliveplugininstance) - getters share the member name sans underscore, setters set_foo() - Qt and third-party (OpenFX) virtual overrides and framework callbacks keep their original names (exempt in .clang-tidy) Manual follow-ups required where automation could not reach: - string-based QMetaObject/SIGNAL/SLOT references updated to renamed methods (AddTask, CreatedFile, DeleteSpecificFile, moveSelectionUp, ...) - macro bodies referencing renamed methods (OLIVE_CONFIG, NODE_DEFAULT_DESTRUCTOR, MANAGEDDISPLAYWIDGET_*) - self-shadowing locals renamed where signals/methods became same-named (size_changed, worker_count, selected_items, import param, filters) - third_party OFX member/namespace usages restored (OFX::Host::*, _created, _clipPrefsDirty, createInstance, clearPersistentMessage) - STL protocol aliases restored (const_iterator) with .clang-tidy ignore rules; qHash overloads restored Full build and test suite pass: ctest 4/4, ~1960 gtest cases green.
This commit is contained in:
+162
-162
@@ -35,16 +35,16 @@ namespace olive
|
||||
|
||||
#define super Node
|
||||
|
||||
const double Track::kTrackHeightDefault = 3.0;
|
||||
const double Track::kTrackHeightMinimum = 1.5;
|
||||
const double Track::kTrackHeightInterval = 0.5;
|
||||
const double Track::k_track_height_default = 3.0;
|
||||
const double Track::k_track_height_minimum = 1.5;
|
||||
const double Track::k_track_height_interval = 0.5;
|
||||
|
||||
const QString Track::kBlockInput = QStringLiteral("block_in");
|
||||
const QString Track::kMutedInput = QStringLiteral("muted_in");
|
||||
const QString Track::kArrayMapInput = QStringLiteral("arraymap_in");
|
||||
const QString Track::k_block_input = QStringLiteral("block_in");
|
||||
const QString Track::k_muted_input = QStringLiteral("muted_in");
|
||||
const QString Track::k_array_map_input = QStringLiteral("arraymap_in");
|
||||
|
||||
Track::Track()
|
||||
: track_type_(Track::kNone)
|
||||
: track_type_(Track::k_none)
|
||||
, index_(-1)
|
||||
, locked_(false)
|
||||
, sequence_(nullptr)
|
||||
@@ -52,19 +52,19 @@ Track::Track()
|
||||
, arraymap_invalid_(false)
|
||||
, ignore_arraymap_set_(false)
|
||||
{
|
||||
AddInput(kBlockInput, NodeValue::kNone,
|
||||
InputFlags(kInputFlagArray | kInputFlagNotKeyframable |
|
||||
kInputFlagHidden | kInputFlagIgnoreInvalidations));
|
||||
add_input(k_block_input, NodeValue::k_none,
|
||||
InputFlags(k_input_flag_array | k_input_flag_not_keyframable |
|
||||
k_input_flag_hidden | k_input_flag_ignore_invalidations));
|
||||
|
||||
AddInput(kMutedInput, NodeValue::kBoolean, false,
|
||||
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
add_input(k_muted_input, NodeValue::k_boolean, false,
|
||||
InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable));
|
||||
|
||||
AddInput(kArrayMapInput, NodeValue::kBinary,
|
||||
InputFlags(kInputFlagStatic | kInputFlagHidden |
|
||||
kInputFlagIgnoreInvalidations));
|
||||
add_input(k_array_map_input, NodeValue::k_binary,
|
||||
InputFlags(k_input_flag_static | k_input_flag_hidden |
|
||||
k_input_flag_ignore_invalidations));
|
||||
|
||||
// Set default height
|
||||
track_height_ = kTrackHeightDefault;
|
||||
track_height_ = k_track_height_default;
|
||||
}
|
||||
|
||||
void Track::set_type(const Type &track_type)
|
||||
@@ -77,13 +77,13 @@ const Track::Type &Track::type() const
|
||||
return track_type_;
|
||||
}
|
||||
|
||||
QString Track::Name() const
|
||||
QString Track::name() const
|
||||
{
|
||||
if (track_type_ == Track::kVideo) {
|
||||
if (track_type_ == Track::k_video) {
|
||||
return tr("Video Track %1").arg(index_);
|
||||
} else if (track_type_ == Track::kAudio) {
|
||||
} else if (track_type_ == Track::k_audio) {
|
||||
return tr("Audio Track %1").arg(index_);
|
||||
} else if (track_type_ == Track::kSubtitle) {
|
||||
} else if (track_type_ == Track::k_subtitle) {
|
||||
return tr("Subtitle Track %1").arg(index_);
|
||||
}
|
||||
|
||||
@@ -95,28 +95,28 @@ QString Track::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.track");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> Track::Category() const
|
||||
QVector<Node::CategoryID> Track::category() const
|
||||
{
|
||||
return { kCategoryTimeline };
|
||||
return { k_category_timeline };
|
||||
}
|
||||
|
||||
QString Track::Description() const
|
||||
QString Track::description() const
|
||||
{
|
||||
return tr(
|
||||
"Node for representing and processing a single array of Blocks sorted by time. Also represents the end of "
|
||||
"a Sequence.");
|
||||
}
|
||||
|
||||
Node::ActiveElements Track::GetActiveElementsAtTime(const QString &input,
|
||||
Node::ActiveElements Track::get_active_elements_at_time(const QString &input,
|
||||
const TimeRange &r) const
|
||||
{
|
||||
if (input == kBlockInput) {
|
||||
if (IsMuted() || blocks_.empty() || r.in() >= track_length() ||
|
||||
if (input == k_block_input) {
|
||||
if (is_muted() || blocks_.empty() || r.in() >= track_length() ||
|
||||
r.out() <= 0) {
|
||||
return ActiveElements::kNoElements;
|
||||
return ActiveElements::k_no_elements;
|
||||
} else {
|
||||
int start = GetBlockIndexAtTime(r.in());
|
||||
int end = GetBlockIndexAtTime(r.out());
|
||||
int start = get_block_index_at_time(r.in());
|
||||
int end = get_block_index_at_time(r.out());
|
||||
|
||||
if (start == -1) {
|
||||
start = 0;
|
||||
@@ -134,42 +134,42 @@ Node::ActiveElements Track::GetActiveElementsAtTime(const QString &input,
|
||||
Block *b = blocks_.at(i);
|
||||
if (b->is_enabled() && (dynamic_cast<ClipBlock *>(b) ||
|
||||
dynamic_cast<TransitionBlock *>(b))) {
|
||||
a.add(GetArrayIndexFromCacheIndex(i));
|
||||
a.add(get_array_index_from_cache_index(i));
|
||||
}
|
||||
}
|
||||
|
||||
if (a.elements().empty()) {
|
||||
return ActiveElements::kNoElements;
|
||||
return ActiveElements::k_no_elements;
|
||||
} else {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return super::GetActiveElementsAtTime(input, r);
|
||||
return super::get_active_elements_at_time(input, r);
|
||||
}
|
||||
}
|
||||
|
||||
void Track::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
void Track::value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
if (this->type() == Track::kVideo) {
|
||||
if (this->type() == Track::k_video) {
|
||||
// Just pass straight through
|
||||
NodeValueArray a = value[kBlockInput].toArray();
|
||||
NodeValueArray a = value[k_block_input].to_array();
|
||||
if (!a.empty()) {
|
||||
table->Push(a.begin()->second);
|
||||
table->push(a.begin()->second);
|
||||
}
|
||||
} else if (this->type() == Track::kAudio) {
|
||||
} else if (this->type() == Track::k_audio) {
|
||||
// Audio
|
||||
ProcessAudioTrack(value, globals, table);
|
||||
process_audio_track(value, globals, table);
|
||||
}
|
||||
}
|
||||
|
||||
TimeRange Track::InputTimeAdjustment(const QString &input, int element,
|
||||
TimeRange Track::input_time_adjustment(const QString &input, int element,
|
||||
const TimeRange &input_time,
|
||||
bool clamp) const
|
||||
{
|
||||
if (input == kBlockInput && element >= 0) {
|
||||
int cache_index = GetCacheIndexFromArrayIndex(element);
|
||||
if (input == k_block_input && element >= 0) {
|
||||
int cache_index = get_cache_index_from_array_index(element);
|
||||
|
||||
if (cache_index > -1) {
|
||||
TimeRange r = input_time;
|
||||
@@ -180,45 +180,45 @@ TimeRange Track::InputTimeAdjustment(const QString &input, int element,
|
||||
std::min(r.out(), b->out()));
|
||||
}
|
||||
|
||||
return TransformRangeForBlock(b, r);
|
||||
return transform_range_for_block(b, r);
|
||||
}
|
||||
}
|
||||
|
||||
return Node::InputTimeAdjustment(input, element, input_time, clamp);
|
||||
return Node::input_time_adjustment(input, element, input_time, clamp);
|
||||
}
|
||||
|
||||
TimeRange Track::OutputTimeAdjustment(const QString &input, int element,
|
||||
TimeRange Track::output_time_adjustment(const QString &input, int element,
|
||||
const TimeRange &input_time) const
|
||||
{
|
||||
if (input == kBlockInput && element >= 0) {
|
||||
int cache_index = GetCacheIndexFromArrayIndex(element);
|
||||
if (input == k_block_input && element >= 0) {
|
||||
int cache_index = get_cache_index_from_array_index(element);
|
||||
|
||||
if (cache_index > -1) {
|
||||
return TransformRangeFromBlock(blocks_.at(cache_index), input_time);
|
||||
return transform_range_from_block(blocks_.at(cache_index), input_time);
|
||||
}
|
||||
}
|
||||
|
||||
return Node::OutputTimeAdjustment(input, element, input_time);
|
||||
return Node::output_time_adjustment(input, element, input_time);
|
||||
}
|
||||
|
||||
const double &Track::GetTrackHeight() const
|
||||
const double &Track::get_track_height() const
|
||||
{
|
||||
return track_height_;
|
||||
}
|
||||
|
||||
void Track::SetTrackHeight(const double &height)
|
||||
void Track::set_track_height(const double &height)
|
||||
{
|
||||
track_height_ = height;
|
||||
emit TrackHeightChanged(track_height_);
|
||||
emit track_height_changed(track_height_);
|
||||
}
|
||||
|
||||
bool Track::LoadCustom(QXmlStreamReader *reader, SerializedData *data)
|
||||
bool Track::load_custom(QXmlStreamReader *reader, SerializedData *data)
|
||||
{
|
||||
ignore_arraymap_set_ = true;
|
||||
|
||||
while (XMLReadNextStartElement(reader)) {
|
||||
while (xml_read_next_start_element(reader)) {
|
||||
if (reader->name() == QStringLiteral("height")) {
|
||||
this->SetTrackHeight(reader->readElementText().toDouble());
|
||||
this->set_track_height(reader->readElementText().toDouble());
|
||||
} else {
|
||||
reader->skipCurrentElement();
|
||||
}
|
||||
@@ -227,51 +227,51 @@ bool Track::LoadCustom(QXmlStreamReader *reader, SerializedData *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
void Track::SaveCustom(QXmlStreamWriter *writer) const
|
||||
void Track::save_custom(QXmlStreamWriter *writer) const
|
||||
{
|
||||
writer->writeTextElement(QStringLiteral("height"),
|
||||
QString::number(this->GetTrackHeight()));
|
||||
QString::number(this->get_track_height()));
|
||||
}
|
||||
|
||||
void Track::PostLoadEvent(SerializedData *data)
|
||||
{
|
||||
ignore_arraymap_set_ = false;
|
||||
RefreshBlockCacheFromArrayMap();
|
||||
refresh_block_cache_from_array_map();
|
||||
}
|
||||
|
||||
void Track::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
|
||||
if (input == kMutedInput) {
|
||||
emit MutedChanged(IsMuted());
|
||||
} else if (input == kArrayMapInput) {
|
||||
if (input == k_muted_input) {
|
||||
emit muted_changed(is_muted());
|
||||
} else if (input == k_array_map_input) {
|
||||
if (ignore_arraymap_ > 0) {
|
||||
ignore_arraymap_--;
|
||||
} else {
|
||||
RefreshBlockCacheFromArrayMap();
|
||||
refresh_block_cache_from_array_map();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Track::Retranslate()
|
||||
void Track::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kBlockInput, tr("Blocks"));
|
||||
SetInputName(kMutedInput, tr("Muted"));
|
||||
set_input_name(k_block_input, tr("Blocks"));
|
||||
set_input_name(k_muted_input, tr("Muted"));
|
||||
}
|
||||
|
||||
void Track::SetIndex(const int &index)
|
||||
void Track::set_index(const int &index)
|
||||
{
|
||||
int old = index_;
|
||||
|
||||
index_ = index;
|
||||
|
||||
emit IndexChanged(old, index_);
|
||||
emit index_changed(old, index_);
|
||||
}
|
||||
|
||||
Block *Track::BlockContainingTime(const rational &time) const
|
||||
Block *Track::block_containing_time(const Rational &time) const
|
||||
{
|
||||
foreach (Block *block, blocks_) {
|
||||
if (block->in() < time && block->out() > time) {
|
||||
@@ -284,7 +284,7 @@ Block *Track::BlockContainingTime(const rational &time) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Block *Track::NearestBlockBefore(const rational &time) const
|
||||
Block *Track::nearest_block_before(const Rational &time) const
|
||||
{
|
||||
foreach (Block *block, blocks_) {
|
||||
// Blocks are sorted by time, so the first Block who's out point is at/after this time is the correct Block
|
||||
@@ -300,7 +300,7 @@ Block *Track::NearestBlockBefore(const rational &time) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Block *Track::NearestBlockBeforeOrAt(const rational &time) const
|
||||
Block *Track::nearest_block_before_or_at(const Rational &time) const
|
||||
{
|
||||
foreach (Block *block, blocks_) {
|
||||
// Blocks are sorted by time, so the first Block who's out point is at/after this time is the correct Block
|
||||
@@ -312,7 +312,7 @@ Block *Track::NearestBlockBeforeOrAt(const rational &time) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Block *Track::NearestBlockAfterOrAt(const rational &time) const
|
||||
Block *Track::nearest_block_after_or_at(const Rational &time) const
|
||||
{
|
||||
foreach (Block *block, blocks_) {
|
||||
// Blocks are sorted by time, so the first Block after this time is the correct Block
|
||||
@@ -324,7 +324,7 @@ Block *Track::NearestBlockAfterOrAt(const rational &time) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Block *Track::NearestBlockAfter(const rational &time) const
|
||||
Block *Track::nearest_block_after(const Rational &time) const
|
||||
{
|
||||
foreach (Block *block, blocks_) {
|
||||
// Blocks are sorted by time, so the first Block after this time is the correct Block
|
||||
@@ -336,9 +336,9 @@ Block *Track::NearestBlockAfter(const rational &time) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Track::IsRangeFree(const TimeRange &range) const
|
||||
bool Track::is_range_free(const TimeRange &range) const
|
||||
{
|
||||
Block *b = NearestBlockBeforeOrAt(range.in());
|
||||
Block *b = nearest_block_before_or_at(range.in());
|
||||
if (!b) {
|
||||
// No block here, assume track is empty here
|
||||
return true;
|
||||
@@ -363,18 +363,18 @@ bool Track::IsRangeFree(const TimeRange &range) const
|
||||
return true;
|
||||
}
|
||||
|
||||
void Track::InvalidateCache(const TimeRange &range, const QString &from,
|
||||
void Track::invalidate_cache(const TimeRange &range, const QString &from,
|
||||
int element, InvalidateCacheOptions options)
|
||||
{
|
||||
TimeRange limited;
|
||||
|
||||
const Block *b;
|
||||
|
||||
if (from == kBlockInput && element >= 0 &&
|
||||
(b = dynamic_cast<const Block *>(GetConnectedOutput(from, element))) &&
|
||||
if (from == k_block_input && element >= 0 &&
|
||||
(b = dynamic_cast<const Block *>(get_connected_output(from, element))) &&
|
||||
!options.value(QStringLiteral("lengthevent")).toBool()) {
|
||||
// Limit the range signal to the corresponding block
|
||||
TimeRange transformed = TransformRangeFromBlock(b, range);
|
||||
TimeRange transformed = transform_range_from_block(b, range);
|
||||
|
||||
if (transformed.out() <= b->in() || transformed.in() >= b->out()) {
|
||||
return;
|
||||
@@ -390,44 +390,44 @@ void Track::InvalidateCache(const TimeRange &range, const QString &from,
|
||||
// to keep it
|
||||
options.remove(QStringLiteral("lengthevent"));
|
||||
|
||||
Node::InvalidateCache(limited, from, element, options);
|
||||
Node::invalidate_cache(limited, from, element, options);
|
||||
}
|
||||
|
||||
void Track::InsertBlockBefore(Block *block, Block *after)
|
||||
void Track::insert_block_before(Block *block, Block *after)
|
||||
{
|
||||
if (!after) {
|
||||
AppendBlock(block);
|
||||
append_block(block);
|
||||
} else {
|
||||
InsertBlockAtIndex(block, blocks_.indexOf(after));
|
||||
insert_block_at_index(block, blocks_.indexOf(after));
|
||||
}
|
||||
}
|
||||
|
||||
void Track::InsertBlockAfter(Block *block, Block *before)
|
||||
void Track::insert_block_after(Block *block, Block *before)
|
||||
{
|
||||
if (!before) {
|
||||
PrependBlock(block);
|
||||
prepend_block(block);
|
||||
} else {
|
||||
int before_index = blocks_.indexOf(before);
|
||||
|
||||
Q_ASSERT(before_index >= 0);
|
||||
|
||||
InsertBlockAtIndex(block, before_index + 1);
|
||||
insert_block_at_index(block, before_index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void Track::PrependBlock(Block *block)
|
||||
void Track::prepend_block(Block *block)
|
||||
{
|
||||
InsertBlockAtIndex(block, 0);
|
||||
insert_block_at_index(block, 0);
|
||||
}
|
||||
|
||||
void Track::InsertBlockAtIndex(Block *block, int index)
|
||||
void Track::insert_block_at_index(Block *block, int index)
|
||||
{
|
||||
// Set track
|
||||
Q_ASSERT(block->track() == nullptr);
|
||||
block->set_track(this);
|
||||
|
||||
// Update array
|
||||
int array_index = ConnectBlock(block);
|
||||
int array_index = connect_block(block);
|
||||
blocks_.insert(index, block);
|
||||
block_array_indexes_.insert(index, array_index);
|
||||
|
||||
@@ -439,28 +439,28 @@ void Track::InsertBlockAtIndex(Block *block, int index)
|
||||
Block::set_previous_next(block, next);
|
||||
|
||||
// Update in/out
|
||||
UpdateInOutFrom(index);
|
||||
update_in_out_from(index);
|
||||
|
||||
connect(block, &Block::LengthChanged, this, &Track::BlockLengthChanged);
|
||||
connect(block, &Block::length_changed, this, &Track::block_length_changed);
|
||||
|
||||
Node::InvalidateCache(TimeRange(block->in(), track_length()), kBlockInput);
|
||||
Node::invalidate_cache(TimeRange(block->in(), track_length()), k_block_input);
|
||||
|
||||
emit BlockAdded(block);
|
||||
emit block_added(block);
|
||||
|
||||
UpdateArrayMap();
|
||||
update_array_map();
|
||||
}
|
||||
|
||||
void Track::AppendBlock(Block *block)
|
||||
void Track::append_block(Block *block)
|
||||
{
|
||||
InsertBlockAtIndex(block, blocks_.size());
|
||||
insert_block_at_index(block, blocks_.size());
|
||||
}
|
||||
|
||||
void Track::RippleRemoveBlock(Block *block)
|
||||
void Track::ripple_remove_block(Block *block)
|
||||
{
|
||||
rational remove_in = block->in();
|
||||
rational remove_out = block->out();
|
||||
Rational remove_in = block->in();
|
||||
Rational remove_out = block->out();
|
||||
|
||||
emit BlockRemoved(block);
|
||||
emit block_removed(block);
|
||||
|
||||
// Set track
|
||||
Q_ASSERT(block->track() == this);
|
||||
@@ -475,9 +475,9 @@ void Track::RippleRemoveBlock(Block *block)
|
||||
blocks_.removeAt(index);
|
||||
block_array_indexes_.removeAt(index);
|
||||
|
||||
Node::DisconnectEdge(block, NodeInput(this, kBlockInput, array_index));
|
||||
Node::disconnect_edge(block, NodeInput(this, k_block_input, array_index));
|
||||
empty_inputs_.push_back(array_index);
|
||||
disconnect(block, &Block::LengthChanged, this, &Track::BlockLengthChanged);
|
||||
disconnect(block, &Block::length_changed, this, &Track::block_length_changed);
|
||||
|
||||
// Handle previous/next
|
||||
Block *previous = (index > 0) ? blocks_.at(index - 1) : nullptr;
|
||||
@@ -489,17 +489,17 @@ void Track::RippleRemoveBlock(Block *block)
|
||||
block->set_out(block->length());
|
||||
|
||||
// Update in/outs
|
||||
UpdateInOutFrom(index);
|
||||
update_in_out_from(index);
|
||||
|
||||
Node::InvalidateCache(
|
||||
TimeRange(remove_in, qMax(track_length(), remove_out)), kBlockInput);
|
||||
Node::invalidate_cache(
|
||||
TimeRange(remove_in, qMax(track_length(), remove_out)), k_block_input);
|
||||
|
||||
UpdateArrayMap();
|
||||
update_array_map();
|
||||
}
|
||||
|
||||
void Track::ReplaceBlock(Block *old, Block *replace)
|
||||
void Track::replace_block(Block *old, Block *replace)
|
||||
{
|
||||
emit BlockRemoved(old);
|
||||
emit block_removed(old);
|
||||
|
||||
// Set track
|
||||
Q_ASSERT(old->track() == this);
|
||||
@@ -510,13 +510,13 @@ void Track::ReplaceBlock(Block *old, Block *replace)
|
||||
|
||||
// Update array
|
||||
int cache_index = blocks_.indexOf(old);
|
||||
int index_of_old_block = GetArrayIndexFromCacheIndex(cache_index);
|
||||
int index_of_old_block = get_array_index_from_cache_index(cache_index);
|
||||
|
||||
DisconnectEdge(old, NodeInput(this, kBlockInput, index_of_old_block));
|
||||
ConnectEdge(replace, NodeInput(this, kBlockInput, index_of_old_block));
|
||||
disconnect_edge(old, NodeInput(this, k_block_input, index_of_old_block));
|
||||
connect_edge(replace, NodeInput(this, k_block_input, index_of_old_block));
|
||||
blocks_.replace(cache_index, replace);
|
||||
disconnect(old, &Block::LengthChanged, this, &Track::BlockLengthChanged);
|
||||
connect(replace, &Block::LengthChanged, this, &Track::BlockLengthChanged);
|
||||
disconnect(old, &Block::length_changed, this, &Track::block_length_changed);
|
||||
connect(replace, &Block::length_changed, this, &Track::block_length_changed);
|
||||
|
||||
// Handle previous/next
|
||||
replace->set_previous(old->previous());
|
||||
@@ -534,22 +534,22 @@ void Track::ReplaceBlock(Block *old, Block *replace)
|
||||
replace->set_in(replace->previous() ? replace->previous()->out() : 0);
|
||||
replace->set_out(replace->in() + replace->length());
|
||||
|
||||
Node::InvalidateCache(TimeRange(replace->in(), replace->out()),
|
||||
kBlockInput);
|
||||
Node::invalidate_cache(TimeRange(replace->in(), replace->out()),
|
||||
k_block_input);
|
||||
} else {
|
||||
// Update in/outs
|
||||
UpdateInOutFrom(cache_index);
|
||||
update_in_out_from(cache_index);
|
||||
|
||||
Node::InvalidateCache(TimeRange(replace->in(), track_length()),
|
||||
kBlockInput);
|
||||
Node::invalidate_cache(TimeRange(replace->in(), track_length()),
|
||||
k_block_input);
|
||||
}
|
||||
|
||||
emit BlockAdded(replace);
|
||||
emit block_added(replace);
|
||||
|
||||
UpdateArrayMap();
|
||||
update_array_map();
|
||||
}
|
||||
|
||||
rational Track::track_length() const
|
||||
Rational Track::track_length() const
|
||||
{
|
||||
if (blocks_.isEmpty()) {
|
||||
return 0;
|
||||
@@ -558,37 +558,37 @@ rational Track::track_length() const
|
||||
}
|
||||
}
|
||||
|
||||
bool Track::IsMuted() const
|
||||
bool Track::is_muted() const
|
||||
{
|
||||
return GetStandardValue(kMutedInput).toBool();
|
||||
return get_standard_value(k_muted_input).toBool();
|
||||
}
|
||||
|
||||
bool Track::IsLocked() const
|
||||
bool Track::is_locked() const
|
||||
{
|
||||
return locked_;
|
||||
}
|
||||
|
||||
void Track::SetMuted(bool e)
|
||||
void Track::set_muted(bool e)
|
||||
{
|
||||
SetStandardValue(kMutedInput, e);
|
||||
set_standard_value(k_muted_input, e);
|
||||
}
|
||||
|
||||
void Track::SetLocked(bool e)
|
||||
void Track::set_locked(bool e)
|
||||
{
|
||||
locked_ = e;
|
||||
}
|
||||
|
||||
void Track::InputConnectedEvent(const QString &input, int element, Node *node)
|
||||
{
|
||||
if (arraymap_invalid_ && input == kBlockInput && element >= 0) {
|
||||
RefreshBlockCacheFromArrayMap();
|
||||
if (arraymap_invalid_ && input == k_block_input && element >= 0) {
|
||||
refresh_block_cache_from_array_map();
|
||||
}
|
||||
}
|
||||
|
||||
void Track::UpdateInOutFrom(int index)
|
||||
void Track::update_in_out_from(int index)
|
||||
{
|
||||
// Find block just before this one to find the last out point
|
||||
rational last_out = (index == 0) ? 0 : blocks_.at(index - 1)->out();
|
||||
Rational last_out = (index == 0) ? 0 : blocks_.at(index - 1)->out();
|
||||
|
||||
// Iterate through all blocks updating their in/outs
|
||||
for (int i = index; i < blocks_.size(); i++) {
|
||||
@@ -601,28 +601,28 @@ void Track::UpdateInOutFrom(int index)
|
||||
b->set_out(last_out);
|
||||
}
|
||||
|
||||
emit BlocksRefreshed();
|
||||
emit blocks_refreshed();
|
||||
|
||||
// Update track length
|
||||
emit TrackLengthChanged();
|
||||
emit track_length_changed();
|
||||
}
|
||||
|
||||
int Track::GetArrayIndexFromBlock(Block *block) const
|
||||
int Track::get_array_index_from_block(Block *block) const
|
||||
{
|
||||
return block_array_indexes_.at(blocks_.indexOf(block));
|
||||
}
|
||||
|
||||
int Track::GetArrayIndexFromCacheIndex(int index) const
|
||||
int Track::get_array_index_from_cache_index(int index) const
|
||||
{
|
||||
return block_array_indexes_.at(index);
|
||||
}
|
||||
|
||||
int Track::GetCacheIndexFromArrayIndex(int index) const
|
||||
int Track::get_cache_index_from_array_index(int index) const
|
||||
{
|
||||
return block_array_indexes_.indexOf(index);
|
||||
}
|
||||
|
||||
int Track::GetBlockIndexAtTime(const rational &time) const
|
||||
int Track::get_block_index_at_time(const Rational &time) const
|
||||
{
|
||||
if (time < 0 || time >= track_length()) {
|
||||
return -1;
|
||||
@@ -647,7 +647,7 @@ int Track::GetBlockIndexAtTime(const rational &time) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Track::ProcessAudioTrack(const NodeValueRow &value,
|
||||
void Track::process_audio_track(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
@@ -658,10 +658,10 @@ void Track::ProcessAudioTrack(const NodeValueRow &value,
|
||||
block_range_buffer.silence();
|
||||
|
||||
// Loop through active blocks retrieving their audio
|
||||
NodeValueArray arr = value[kBlockInput].toArray();
|
||||
NodeValueArray arr = value[k_block_input].to_array();
|
||||
|
||||
for (auto it = arr.cbegin(); it != arr.cend(); it++) {
|
||||
Block *b = blocks_.at(GetCacheIndexFromArrayIndex(it->first));
|
||||
Block *b = blocks_.at(get_cache_index_from_array_index(it->first));
|
||||
|
||||
TimeRange range_for_block(qMax(b->in(), range.in()),
|
||||
qMin(b->out(), range.out()));
|
||||
@@ -673,7 +673,7 @@ void Track::ProcessAudioTrack(const NodeValueRow &value,
|
||||
globals.aparams().time_to_samples(range_for_block.length());
|
||||
|
||||
// Destination buffer
|
||||
SampleBuffer samples_from_this_block = it->second.toSamples();
|
||||
SampleBuffer samples_from_this_block = it->second.to_samples();
|
||||
|
||||
if (samples_from_this_block.is_allocated()) {
|
||||
// If this is a clip, we might have extra speed/reverse information
|
||||
@@ -688,7 +688,7 @@ void Track::ProcessAudioTrack(const NodeValueRow &value,
|
||||
if (clip_cast->maintain_audio_pitch()) {
|
||||
AudioProcessor processor;
|
||||
|
||||
if (processor.Open(
|
||||
if (processor.open(
|
||||
samples_from_this_block.audio_params(),
|
||||
samples_from_this_block.audio_params(),
|
||||
speed_value)) {
|
||||
@@ -700,7 +700,7 @@ void Track::ProcessAudioTrack(const NodeValueRow &value,
|
||||
// well on export (assuming audio is all generated at once on export), but
|
||||
// users may hear clicks and pops in the audio during preview due to this
|
||||
// approach.
|
||||
int r = processor.Convert(
|
||||
int r = processor.convert(
|
||||
samples_from_this_block.to_raw_ptrs().data(),
|
||||
samples_from_this_block.sample_count(),
|
||||
nullptr);
|
||||
@@ -709,9 +709,9 @@ void Track::ProcessAudioTrack(const NodeValueRow &value,
|
||||
qCritical()
|
||||
<< "Failed to change tempo of audio:" << r;
|
||||
} else {
|
||||
processor.Flush();
|
||||
processor.flush();
|
||||
|
||||
processor.Convert(nullptr, 0, &out);
|
||||
processor.convert(nullptr, 0, &out);
|
||||
|
||||
if (!out.empty()) {
|
||||
int nb_samples =
|
||||
@@ -762,37 +762,37 @@ void Track::ProcessAudioTrack(const NodeValueRow &value,
|
||||
}
|
||||
}
|
||||
|
||||
table->Push(NodeValue::kSamples, QVariant::fromValue(block_range_buffer),
|
||||
table->push(NodeValue::k_samples, QVariant::fromValue(block_range_buffer),
|
||||
this);
|
||||
}
|
||||
|
||||
int Track::ConnectBlock(Block *b)
|
||||
int Track::connect_block(Block *b)
|
||||
{
|
||||
if (!empty_inputs_.empty()) {
|
||||
int index = empty_inputs_.front();
|
||||
empty_inputs_.pop_front();
|
||||
|
||||
Node::ConnectEdge(b, NodeInput(this, kBlockInput, index));
|
||||
Node::connect_edge(b, NodeInput(this, k_block_input, index));
|
||||
|
||||
return index;
|
||||
} else {
|
||||
int old_sz = InputArraySize(kBlockInput);
|
||||
InputArrayAppend(kBlockInput);
|
||||
Node::ConnectEdge(b, NodeInput(this, kBlockInput, old_sz));
|
||||
int old_sz = input_array_size(k_block_input);
|
||||
input_array_append(k_block_input);
|
||||
Node::connect_edge(b, NodeInput(this, k_block_input, old_sz));
|
||||
return old_sz;
|
||||
}
|
||||
}
|
||||
|
||||
void Track::UpdateArrayMap()
|
||||
void Track::update_array_map()
|
||||
{
|
||||
ignore_arraymap_++;
|
||||
SetStandardValue(
|
||||
kArrayMapInput,
|
||||
set_standard_value(
|
||||
k_array_map_input,
|
||||
QByteArray(reinterpret_cast<const char *>(block_array_indexes_.data()),
|
||||
block_array_indexes_.size() * sizeof(uint32_t)));
|
||||
}
|
||||
|
||||
void Track::RefreshBlockCacheFromArrayMap()
|
||||
void Track::refresh_block_cache_from_array_map()
|
||||
{
|
||||
if (ignore_arraymap_set_) {
|
||||
return;
|
||||
@@ -806,10 +806,10 @@ void Track::RefreshBlockCacheFromArrayMap()
|
||||
b->set_next(nullptr);
|
||||
b->set_in(0);
|
||||
b->set_out(b->length());
|
||||
disconnect(b, &Block::LengthChanged, this, &Track::BlockLengthChanged);
|
||||
disconnect(b, &Block::length_changed, this, &Track::block_length_changed);
|
||||
}
|
||||
|
||||
QByteArray bytes = GetStandardValue(kArrayMapInput).toByteArray();
|
||||
QByteArray bytes = get_standard_value(k_array_map_input).toByteArray();
|
||||
block_array_indexes_.resize(bytes.size() / sizeof(uint32_t));
|
||||
memcpy(block_array_indexes_.data(), bytes.data(), bytes.size());
|
||||
blocks_.clear();
|
||||
@@ -820,13 +820,13 @@ void Track::RefreshBlockCacheFromArrayMap()
|
||||
|
||||
for (int i = 0; i < block_array_indexes_.size(); i++) {
|
||||
Block *b = static_cast<Block *>(
|
||||
GetConnectedOutput(kBlockInput, block_array_indexes_.at(i)));
|
||||
get_connected_output(k_block_input, block_array_indexes_.at(i)));
|
||||
|
||||
Block::set_previous_next(prev, b);
|
||||
|
||||
if (b) {
|
||||
b->set_track(this);
|
||||
connect(b, &Block::LengthChanged, this, &Track::BlockLengthChanged);
|
||||
connect(b, &Block::length_changed, this, &Track::block_length_changed);
|
||||
|
||||
blocks_.append(b);
|
||||
prev = b;
|
||||
@@ -841,15 +841,15 @@ void Track::RefreshBlockCacheFromArrayMap()
|
||||
prev->set_next(nullptr);
|
||||
}
|
||||
|
||||
UpdateInOutFrom(0);
|
||||
update_in_out_from(0);
|
||||
}
|
||||
|
||||
void Track::BlockLengthChanged()
|
||||
void Track::block_length_changed()
|
||||
{
|
||||
// Assumes sender is a Block
|
||||
Block *b = static_cast<Block *>(sender());
|
||||
|
||||
UpdateInOutFrom(blocks_.indexOf(b));
|
||||
update_in_out_from(blocks_.indexOf(b));
|
||||
}
|
||||
|
||||
uint qHash(const Track::Reference &r, uint seed)
|
||||
|
||||
+110
-110
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TRACK_H
|
||||
#define TRACK_H
|
||||
#ifndef OAK_TRACK_H
|
||||
#define OAK_TRACK_H
|
||||
|
||||
#include "node/block/block.h"
|
||||
|
||||
@@ -35,7 +35,7 @@ class Sequence;
|
||||
class Track : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Type { kNone = -1, kVideo, kAudio, kSubtitle, kCount };
|
||||
enum Type { k_none = -1, k_video, k_audio, k_subtitle, k_count };
|
||||
|
||||
Track();
|
||||
|
||||
@@ -44,27 +44,27 @@ public:
|
||||
const Track::Type &type() const;
|
||||
void set_type(const Track::Type &track_type);
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual ActiveElements
|
||||
GetActiveElementsAtTime(const QString &input,
|
||||
get_active_elements_at_time(const QString &input,
|
||||
const TimeRange &r) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual TimeRange InputTimeAdjustment(const QString &input, int element,
|
||||
virtual TimeRange input_time_adjustment(const QString &input, int element,
|
||||
const TimeRange &input_time,
|
||||
bool clamp) const override;
|
||||
|
||||
virtual TimeRange
|
||||
OutputTimeAdjustment(const QString &input, int element,
|
||||
output_time_adjustment(const QString &input, int element,
|
||||
const TimeRange &input_time) const override;
|
||||
|
||||
static rational TransformTimeForBlock(const Block *block,
|
||||
const rational &time)
|
||||
static Rational transform_time_for_block(const Block *block,
|
||||
const Rational &time)
|
||||
{
|
||||
if (time == RATIONAL_MAX || time == RATIONAL_MIN) {
|
||||
return time;
|
||||
@@ -73,15 +73,15 @@ public:
|
||||
return time - block->in();
|
||||
}
|
||||
|
||||
static TimeRange TransformRangeForBlock(const Block *block,
|
||||
static TimeRange transform_range_for_block(const Block *block,
|
||||
const TimeRange &range)
|
||||
{
|
||||
return TimeRange(TransformTimeForBlock(block, range.in()),
|
||||
TransformTimeForBlock(block, range.out()));
|
||||
return TimeRange(transform_time_for_block(block, range.in()),
|
||||
transform_time_for_block(block, range.out()));
|
||||
}
|
||||
|
||||
static rational TransformTimeFromBlock(const Block *block,
|
||||
const rational &time)
|
||||
static Rational transform_time_from_block(const Block *block,
|
||||
const Rational &time)
|
||||
{
|
||||
if (time == RATIONAL_MAX || time == RATIONAL_MIN) {
|
||||
return time;
|
||||
@@ -90,57 +90,57 @@ public:
|
||||
return time + block->in();
|
||||
}
|
||||
|
||||
static TimeRange TransformRangeFromBlock(const Block *block,
|
||||
static TimeRange transform_range_from_block(const Block *block,
|
||||
const TimeRange &range)
|
||||
{
|
||||
return TimeRange(TransformTimeFromBlock(block, range.in()),
|
||||
TransformTimeFromBlock(block, range.out()));
|
||||
return TimeRange(transform_time_from_block(block, range.in()),
|
||||
transform_time_from_block(block, range.out()));
|
||||
}
|
||||
|
||||
const double &GetTrackHeight() const;
|
||||
void SetTrackHeight(const double &height);
|
||||
const double &get_track_height() const;
|
||||
void set_track_height(const double &height);
|
||||
|
||||
int GetTrackHeightInPixels() const
|
||||
int get_track_height_in_pixels() const
|
||||
{
|
||||
return InternalHeightToPixelHeight(GetTrackHeight());
|
||||
return internal_height_to_pixel_height(get_track_height());
|
||||
}
|
||||
|
||||
void SetTrackHeightInPixels(int h)
|
||||
void set_track_height_in_pixels(int h)
|
||||
{
|
||||
SetTrackHeight(PixelHeightToInternalHeight(h));
|
||||
set_track_height(pixel_height_to_internal_height(h));
|
||||
}
|
||||
|
||||
virtual bool LoadCustom(QXmlStreamReader *reader,
|
||||
virtual bool load_custom(QXmlStreamReader *reader,
|
||||
SerializedData *data) override;
|
||||
virtual void SaveCustom(QXmlStreamWriter *writer) const override;
|
||||
virtual void save_custom(QXmlStreamWriter *writer) const override;
|
||||
virtual void PostLoadEvent(SerializedData *data) override;
|
||||
|
||||
static int InternalHeightToPixelHeight(double h)
|
||||
static int internal_height_to_pixel_height(double h)
|
||||
{
|
||||
return qRound(h * QFontMetrics(QFont()).height());
|
||||
}
|
||||
|
||||
static double PixelHeightToInternalHeight(int h)
|
||||
static double pixel_height_to_internal_height(int h)
|
||||
{
|
||||
return double(h) / double(QFontMetrics(QFont()).height());
|
||||
}
|
||||
|
||||
static int GetDefaultTrackHeightInPixels()
|
||||
static int get_default_track_height_in_pixels()
|
||||
{
|
||||
return InternalHeightToPixelHeight(kTrackHeightDefault);
|
||||
return internal_height_to_pixel_height(k_track_height_default);
|
||||
}
|
||||
|
||||
static int GetMinimumTrackHeightInPixels()
|
||||
static int get_minimum_track_height_in_pixels()
|
||||
{
|
||||
return InternalHeightToPixelHeight(kTrackHeightMinimum);
|
||||
return internal_height_to_pixel_height(k_track_height_minimum);
|
||||
}
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
class Reference {
|
||||
public:
|
||||
Reference()
|
||||
: type_(kNone)
|
||||
: type_(k_none)
|
||||
, index_(-1)
|
||||
{
|
||||
}
|
||||
@@ -180,9 +180,9 @@ public:
|
||||
return index_ < rhs.index_;
|
||||
}
|
||||
|
||||
QString ToString() const
|
||||
QString to_string() const
|
||||
{
|
||||
QString type_string = TypeToString(type_);
|
||||
QString type_string = type_to_string(type_);
|
||||
if (type_string.isEmpty()) {
|
||||
return QString();
|
||||
} else {
|
||||
@@ -192,17 +192,17 @@ public:
|
||||
}
|
||||
|
||||
/// For IDs that shouldn't change between localizations
|
||||
static QString TypeToString(Type type)
|
||||
static QString type_to_string(Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case kVideo:
|
||||
case k_video:
|
||||
return QStringLiteral("v");
|
||||
case kAudio:
|
||||
case k_audio:
|
||||
return QStringLiteral("a");
|
||||
case kSubtitle:
|
||||
case k_subtitle:
|
||||
return QStringLiteral("s");
|
||||
case kCount:
|
||||
case kNone:
|
||||
case k_count:
|
||||
case k_none:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -210,49 +210,49 @@ public:
|
||||
}
|
||||
|
||||
/// For human-facing strings
|
||||
static QString TypeToTranslatedString(Type type)
|
||||
static QString type_to_translated_string(Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case kVideo:
|
||||
case k_video:
|
||||
return tr("V");
|
||||
case kAudio:
|
||||
case k_audio:
|
||||
return tr("A");
|
||||
case kSubtitle:
|
||||
case k_subtitle:
|
||||
return tr("S");
|
||||
case kCount:
|
||||
case kNone:
|
||||
case k_count:
|
||||
case k_none:
|
||||
break;
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
static Type TypeFromString(const QString &s)
|
||||
static Type type_from_string(const QString &s)
|
||||
{
|
||||
if (s.size() >= 3) {
|
||||
if (s.at(1) == ':') {
|
||||
if (s.at(0) == 'v') {
|
||||
// Video stream
|
||||
return Track::kVideo;
|
||||
return Track::k_video;
|
||||
} else if (s.at(0) == 'a') {
|
||||
// Audio stream
|
||||
return Track::kAudio;
|
||||
return Track::k_audio;
|
||||
} else if (s.at(0) == 's') {
|
||||
// Subtitle stream
|
||||
return Track::kSubtitle;
|
||||
return Track::k_subtitle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Track::kNone;
|
||||
return Track::k_none;
|
||||
}
|
||||
|
||||
static Reference FromString(const QString &s)
|
||||
static Reference from_string(const QString &s)
|
||||
{
|
||||
Reference ref;
|
||||
Type parse_type = TypeFromString(s);
|
||||
Type parse_type = type_from_string(s);
|
||||
|
||||
if (parse_type != Track::kNone) {
|
||||
if (parse_type != Track::k_none) {
|
||||
bool ok;
|
||||
int parse_index = s.mid(2).toInt(&ok);
|
||||
|
||||
@@ -265,9 +265,9 @@ public:
|
||||
return ref;
|
||||
}
|
||||
|
||||
bool IsValid() const
|
||||
bool is_valid() const
|
||||
{
|
||||
return type_ > kNone && type_ < kCount && index_ >= 0;
|
||||
return type_ > k_none && type_ < k_count && index_ >= 0;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -276,17 +276,17 @@ public:
|
||||
int index_;
|
||||
};
|
||||
|
||||
Reference ToReference() const
|
||||
Reference to_reference() const
|
||||
{
|
||||
return Reference(type(), Index());
|
||||
return Reference(type(), index());
|
||||
}
|
||||
|
||||
const int &Index() const
|
||||
const int &index() const
|
||||
{
|
||||
return index_;
|
||||
}
|
||||
|
||||
void SetIndex(const int &index);
|
||||
void set_index(const int &index);
|
||||
|
||||
/**
|
||||
* @brief Returns the block that starts BEFORE (not AT) and ends AFTER (not AT) a time
|
||||
@@ -294,7 +294,7 @@ public:
|
||||
* 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 *block_containing_time(const Rational &time) const;
|
||||
|
||||
/**
|
||||
* @brief Returns the block that starts BEFORE a given time and ends either AFTER or AT that time
|
||||
@@ -302,7 +302,7 @@ public:
|
||||
* @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 *nearest_block_before(const Rational &time) const;
|
||||
|
||||
/**
|
||||
* @brief Returns the block that starts BEFORE or AT a given time.
|
||||
@@ -310,7 +310,7 @@ public:
|
||||
* @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 *nearest_block_before_or_at(const Rational &time) const;
|
||||
|
||||
/**
|
||||
* @brief Returns the block that starts either AT a given time or the soonest block AFTER
|
||||
@@ -318,7 +318,7 @@ public:
|
||||
* @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 *nearest_block_after_or_at(const Rational &time) const;
|
||||
|
||||
/**
|
||||
* @brief Returns the block that starts AFTER the given time (but never AT the given time)
|
||||
@@ -326,32 +326,32 @@ public:
|
||||
* @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 *nearest_block_after(const Rational &time) const;
|
||||
|
||||
/*
|
||||
* @brief Returns whether a time range is empty or only has a gap
|
||||
*/
|
||||
bool IsRangeFree(const TimeRange &range) const;
|
||||
bool is_range_free(const TimeRange &range) const;
|
||||
|
||||
const QVector<Block *> &Blocks() const
|
||||
const QVector<Block *> &blocks() const
|
||||
{
|
||||
return blocks_;
|
||||
}
|
||||
|
||||
virtual void InvalidateCache(const TimeRange &range, const QString &from,
|
||||
virtual void invalidate_cache(const TimeRange &range, const QString &from,
|
||||
int element,
|
||||
InvalidateCacheOptions options) override;
|
||||
|
||||
Block *VisibleBlockAtTime(const rational &t) const
|
||||
Block *visible_block_at_time(const Rational &t) const
|
||||
{
|
||||
int index = GetBlockIndexAtTime(t);
|
||||
int index = get_block_index_at_time(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 prepend_block(Block *block);
|
||||
|
||||
/**
|
||||
* @brief Inserts Block `block` at a specific index (0 is the start of the timeline)
|
||||
@@ -359,44 +359,44 @@ public:
|
||||
* 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 insert_block_at_index(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 insert_block_after(Block *block, Block *before);
|
||||
|
||||
/**
|
||||
* @brief Inserts Block before another Block
|
||||
*/
|
||||
void InsertBlockBefore(Block *block, Block *after);
|
||||
void insert_block_before(Block *block, Block *after);
|
||||
|
||||
/**
|
||||
* @brief Adds Block `block` at the very end of the Sequence after all other clips
|
||||
*/
|
||||
void AppendBlock(Block *block);
|
||||
void append_block(Block *block);
|
||||
|
||||
/**
|
||||
* @brief Removes a Block pushing all subsequent Blocks earlier to take up the space
|
||||
*/
|
||||
void RippleRemoveBlock(Block *block);
|
||||
void ripple_remove_block(Block *block);
|
||||
|
||||
/**
|
||||
* @brief Replaces Block `old` with Block `replace`
|
||||
*
|
||||
* Both blocks must have equal lengths.
|
||||
*/
|
||||
void ReplaceBlock(Block *old, Block *replace);
|
||||
void replace_block(Block *old, Block *replace);
|
||||
|
||||
rational track_length() const;
|
||||
Rational track_length() const;
|
||||
|
||||
bool IsMuted() const;
|
||||
bool is_muted() const;
|
||||
|
||||
bool IsLocked() const;
|
||||
bool is_locked() const;
|
||||
|
||||
int GetArrayIndexFromBlock(Block *block) const;
|
||||
int get_array_index_from_block(Block *block) const;
|
||||
|
||||
Sequence *sequence() const
|
||||
{
|
||||
@@ -408,54 +408,54 @@ public:
|
||||
sequence_ = sequence;
|
||||
}
|
||||
|
||||
static const double kTrackHeightDefault;
|
||||
static const double kTrackHeightMinimum;
|
||||
static const double kTrackHeightInterval;
|
||||
static const double k_track_height_default;
|
||||
static const double k_track_height_minimum;
|
||||
static const double k_track_height_interval;
|
||||
|
||||
static const QString kBlockInput;
|
||||
static const QString kMutedInput;
|
||||
static const QString kArrayMapInput;
|
||||
static const QString k_block_input;
|
||||
static const QString k_muted_input;
|
||||
static const QString k_array_map_input;
|
||||
|
||||
public slots:
|
||||
void SetMuted(bool e);
|
||||
void set_muted(bool e);
|
||||
|
||||
void SetLocked(bool e);
|
||||
void set_locked(bool e);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when a Block is added to this Track
|
||||
*/
|
||||
void BlockAdded(Block *block);
|
||||
void block_added(Block *block);
|
||||
|
||||
/**
|
||||
* @brief Signal emitted when a Block is removed from this Track
|
||||
*/
|
||||
void BlockRemoved(Block *block);
|
||||
void block_removed(Block *block);
|
||||
|
||||
/**
|
||||
* @brief Signal emitted when the length of the track has changed
|
||||
*/
|
||||
void TrackLengthChanged();
|
||||
void track_length_changed();
|
||||
|
||||
/**
|
||||
* @brief Signal emitted when the height of the track has changed
|
||||
*/
|
||||
void TrackHeightChanged(qreal virtual_height);
|
||||
void track_height_changed(qreal virtual_height);
|
||||
|
||||
/**
|
||||
* @brief Signal emitted when the muted setting changes
|
||||
*/
|
||||
void MutedChanged(bool e);
|
||||
void muted_changed(bool e);
|
||||
|
||||
/**
|
||||
* @brief Signal emitted when the index has changed
|
||||
*/
|
||||
void IndexChanged(int old, int now);
|
||||
void index_changed(int old, int now);
|
||||
|
||||
/**
|
||||
* @brief Emitted when a block changes length and all the subsequent blocks had to update
|
||||
*/
|
||||
void BlocksRefreshed();
|
||||
void blocks_refreshed();
|
||||
|
||||
protected:
|
||||
virtual void InputConnectedEvent(const QString &input, int element,
|
||||
@@ -464,21 +464,21 @@ protected:
|
||||
int element) override;
|
||||
|
||||
private:
|
||||
void UpdateInOutFrom(int index);
|
||||
void update_in_out_from(int index);
|
||||
|
||||
int GetArrayIndexFromCacheIndex(int index) const;
|
||||
int get_array_index_from_cache_index(int index) const;
|
||||
|
||||
int GetCacheIndexFromArrayIndex(int index) const;
|
||||
int get_cache_index_from_array_index(int index) const;
|
||||
|
||||
int GetBlockIndexAtTime(const rational &time) const;
|
||||
int get_block_index_at_time(const Rational &time) const;
|
||||
|
||||
void ProcessAudioTrack(const NodeValueRow &value,
|
||||
void process_audio_track(const NodeValueRow &value,
|
||||
const NodeGlobals &globals,
|
||||
NodeValueTable *table) const;
|
||||
|
||||
int ConnectBlock(Block *b);
|
||||
int connect_block(Block *b);
|
||||
|
||||
void UpdateArrayMap();
|
||||
void update_array_map();
|
||||
|
||||
TimeRangeList block_length_pending_invalidations_;
|
||||
|
||||
@@ -502,9 +502,9 @@ private:
|
||||
bool ignore_arraymap_set_;
|
||||
|
||||
private slots:
|
||||
void BlockLengthChanged();
|
||||
void block_length_changed();
|
||||
|
||||
void RefreshBlockCacheFromArrayMap();
|
||||
void refresh_block_cache_from_array_map();
|
||||
};
|
||||
|
||||
uint qHash(const Track::Reference &r, uint seed = 0);
|
||||
@@ -515,4 +515,4 @@ QDataStream &operator>>(QDataStream &in, Track::Reference &ref);
|
||||
|
||||
}
|
||||
|
||||
#endif // TRACK_H
|
||||
#endif // OAK_TRACK_H
|
||||
|
||||
@@ -39,7 +39,7 @@ TrackList::TrackList(Sequence *parent, const Track::Type &type,
|
||||
{
|
||||
}
|
||||
|
||||
Track *TrackList::GetTrackAt(int index) const
|
||||
Track *TrackList::get_track_at(int index) const
|
||||
{
|
||||
if (index >= 0 && index < track_cache_.size()) {
|
||||
return track_cache_.at(index);
|
||||
@@ -48,10 +48,10 @@ Track *TrackList::GetTrackAt(int index) const
|
||||
}
|
||||
}
|
||||
|
||||
void TrackList::TrackConnected(Node *node, int element)
|
||||
void TrackList::track_connected(Node *node, int element)
|
||||
{
|
||||
if (element == -1) {
|
||||
parent()->InvalidateAll(track_input(), element);
|
||||
parent()->invalidate_all(track_input(), element);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,9 +63,9 @@ void TrackList::TrackConnected(Node *node, int element)
|
||||
|
||||
// Determine where in the cache this block will be
|
||||
int cache_index = -1;
|
||||
for (int i = element + 1; i < ArraySize(); i++) {
|
||||
for (int i = element + 1; i < array_size(); i++) {
|
||||
// Find next track because this will be the index we insert at
|
||||
cache_index = GetCacheIndexFromArrayIndex(i);
|
||||
cache_index = get_cache_index_from_array_index(i);
|
||||
|
||||
if (cache_index >= 0) {
|
||||
break;
|
||||
@@ -81,33 +81,33 @@ void TrackList::TrackConnected(Node *node, int element)
|
||||
track_array_indexes_.insert(cache_index, element);
|
||||
|
||||
// Update track indexes in the list (including this track)
|
||||
UpdateTrackIndexesFrom(cache_index);
|
||||
update_track_indexes_from(cache_index);
|
||||
|
||||
connect(track, &Track::TrackLengthChanged, this,
|
||||
&TrackList::UpdateTotalLength);
|
||||
connect(track, &Track::track_length_changed, this,
|
||||
&TrackList::update_total_length);
|
||||
track_height_connections_.insert(
|
||||
track, connect(track, &Track::TrackHeightChanged, this, [this]() {
|
||||
track, connect(track, &Track::track_height_changed, this, [this]() {
|
||||
Track *t = static_cast<Track *>(sender());
|
||||
emit TrackHeightChanged(t, t->GetTrackHeightInPixels());
|
||||
emit track_height_changed(t, t->get_track_height_in_pixels());
|
||||
}));
|
||||
|
||||
track->set_type(type_);
|
||||
track->set_sequence(parent());
|
||||
|
||||
emit TrackListChanged();
|
||||
emit track_list_changed();
|
||||
|
||||
// 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);
|
||||
emit track_added(track);
|
||||
|
||||
UpdateTotalLength();
|
||||
update_total_length();
|
||||
}
|
||||
|
||||
void TrackList::TrackDisconnected(Node *node, int element)
|
||||
void TrackList::track_disconnected(Node *node, int element)
|
||||
{
|
||||
if (element == -1) {
|
||||
// User has replaced the entire array, we will invalidate everything
|
||||
parent()->InvalidateAll(track_input(), element);
|
||||
parent()->invalidate_all(track_input(), element);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -118,38 +118,38 @@ void TrackList::TrackDisconnected(Node *node, int element)
|
||||
}
|
||||
|
||||
// Traverse through Tracks uncaching and disconnecting them
|
||||
emit TrackRemoved(track);
|
||||
emit track_removed(track);
|
||||
|
||||
int cache_index = GetCacheIndexFromArrayIndex(element);
|
||||
int cache_index = get_cache_index_from_array_index(element);
|
||||
|
||||
// Remove track here
|
||||
track_cache_.removeAt(cache_index);
|
||||
track_array_indexes_.removeAt(cache_index);
|
||||
|
||||
// Update indices for all subsequent tracks
|
||||
UpdateTrackIndexesFrom(cache_index);
|
||||
update_track_indexes_from(cache_index);
|
||||
|
||||
track->SetIndex(-1);
|
||||
track->set_type(Track::kNone);
|
||||
track->set_index(-1);
|
||||
track->set_type(Track::k_none);
|
||||
track->set_sequence(nullptr);
|
||||
|
||||
disconnect(track, &Track::TrackLengthChanged, this,
|
||||
&TrackList::UpdateTotalLength);
|
||||
disconnect(track, &Track::track_length_changed, this,
|
||||
&TrackList::update_total_length);
|
||||
disconnect(track_height_connections_.take(track));
|
||||
|
||||
emit TrackListChanged();
|
||||
emit track_list_changed();
|
||||
|
||||
UpdateTotalLength();
|
||||
update_total_length();
|
||||
}
|
||||
|
||||
void TrackList::UpdateTrackIndexesFrom(int index)
|
||||
void TrackList::update_track_indexes_from(int index)
|
||||
{
|
||||
for (int i = index; i < track_cache_.size(); i++) {
|
||||
track_cache_.at(i)->SetIndex(i);
|
||||
track_cache_.at(i)->set_index(i);
|
||||
}
|
||||
}
|
||||
|
||||
Project *TrackList::GetParentGraph() const
|
||||
Project *TrackList::get_parent_graph() const
|
||||
{
|
||||
return parent()->parent();
|
||||
}
|
||||
@@ -169,22 +169,22 @@ Sequence *TrackList::parent() const
|
||||
return static_cast<Sequence *>(QObject::parent());
|
||||
}
|
||||
|
||||
int TrackList::ArraySize() const
|
||||
int TrackList::array_size() const
|
||||
{
|
||||
return parent()->InputArraySize(track_input());
|
||||
return parent()->input_array_size(track_input());
|
||||
}
|
||||
|
||||
void TrackList::ArrayAppend()
|
||||
void TrackList::array_append()
|
||||
{
|
||||
parent()->InputArrayAppend(track_input());
|
||||
parent()->input_array_append(track_input());
|
||||
}
|
||||
|
||||
void TrackList::ArrayRemoveLast()
|
||||
void TrackList::array_remove_last()
|
||||
{
|
||||
parent()->InputArrayRemoveLast(track_input());
|
||||
parent()->input_array_remove_last(track_input());
|
||||
}
|
||||
|
||||
void TrackList::UpdateTotalLength()
|
||||
void TrackList::update_total_length()
|
||||
{
|
||||
total_length_ = 0;
|
||||
|
||||
@@ -194,7 +194,7 @@ void TrackList::UpdateTotalLength()
|
||||
}
|
||||
}
|
||||
|
||||
emit LengthChanged(total_length_);
|
||||
emit length_changed(total_length_);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TRACKLIST_H
|
||||
#define TRACKLIST_H
|
||||
#ifndef OAK_TRACKLIST_H
|
||||
#define OAK_TRACKLIST_H
|
||||
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
@@ -44,41 +44,41 @@ public:
|
||||
return type_;
|
||||
}
|
||||
|
||||
const QVector<Track *> &GetTracks() const
|
||||
const QVector<Track *> &get_tracks() const
|
||||
{
|
||||
return track_cache_;
|
||||
}
|
||||
|
||||
Track *GetTrackAt(int index) const;
|
||||
Track *get_track_at(int index) const;
|
||||
|
||||
const rational &GetTotalLength() const
|
||||
const Rational &get_total_length() const
|
||||
{
|
||||
return total_length_;
|
||||
}
|
||||
|
||||
int GetTrackCount() const
|
||||
int get_track_count() const
|
||||
{
|
||||
return track_cache_.size();
|
||||
}
|
||||
|
||||
Project *GetParentGraph() const;
|
||||
Project *get_parent_graph() const;
|
||||
|
||||
const QString &track_input() const;
|
||||
NodeInput track_input(int element) const;
|
||||
|
||||
Sequence *parent() const;
|
||||
|
||||
int ArraySize() const;
|
||||
int array_size() const;
|
||||
|
||||
void ArrayAppend();
|
||||
void ArrayRemoveLast();
|
||||
void array_append();
|
||||
void array_remove_last();
|
||||
|
||||
int GetArrayIndexFromCacheIndex(int index) const
|
||||
int get_array_index_from_cache_index(int index) const
|
||||
{
|
||||
return track_array_indexes_.at(index);
|
||||
}
|
||||
|
||||
int GetCacheIndexFromArrayIndex(int index) const
|
||||
int get_cache_index_from_array_index(int index) const
|
||||
{
|
||||
return track_array_indexes_.indexOf(index);
|
||||
}
|
||||
@@ -87,26 +87,26 @@ public slots:
|
||||
/**
|
||||
* @brief Slot for when the track connection is added
|
||||
*/
|
||||
void TrackConnected(Node *node, int element);
|
||||
void track_connected(Node *node, int element);
|
||||
|
||||
/**
|
||||
* @brief Slot for when the track connection is removed
|
||||
*/
|
||||
void TrackDisconnected(Node *node, int element);
|
||||
void track_disconnected(Node *node, int element);
|
||||
|
||||
signals:
|
||||
void TrackListChanged();
|
||||
void track_list_changed();
|
||||
|
||||
void LengthChanged(const rational &length);
|
||||
void length_changed(const Rational &length);
|
||||
|
||||
void TrackAdded(Track *track);
|
||||
void track_added(Track *track);
|
||||
|
||||
void TrackRemoved(Track *track);
|
||||
void track_removed(Track *track);
|
||||
|
||||
void TrackHeightChanged(Track *track, int height);
|
||||
void track_height_changed(Track *track, int height);
|
||||
|
||||
private:
|
||||
void UpdateTrackIndexesFrom(int index);
|
||||
void update_track_indexes_from(int index);
|
||||
|
||||
/**
|
||||
* @brief A cache of connected Tracks
|
||||
@@ -121,7 +121,7 @@ private:
|
||||
|
||||
QString track_input_;
|
||||
|
||||
rational total_length_;
|
||||
Rational total_length_;
|
||||
|
||||
enum Track::Type type_;
|
||||
|
||||
@@ -129,9 +129,9 @@ 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 update_total_length();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TRACKLIST_H
|
||||
#endif // OAK_TRACKLIST_H
|
||||
|
||||
+221
-221
@@ -28,16 +28,16 @@
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString ViewerOutput::kVideoParamsInput =
|
||||
const QString ViewerOutput::k_video_params_input =
|
||||
QStringLiteral("video_param_in");
|
||||
const QString ViewerOutput::kAudioParamsInput =
|
||||
const QString ViewerOutput::k_audio_params_input =
|
||||
QStringLiteral("audio_param_in");
|
||||
const QString ViewerOutput::kSubtitleParamsInput =
|
||||
const QString ViewerOutput::k_subtitle_params_input =
|
||||
QStringLiteral("subtitle_param_in");
|
||||
const QString ViewerOutput::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString ViewerOutput::kSamplesInput = QStringLiteral("samples_in");
|
||||
const QString ViewerOutput::k_texture_input = QStringLiteral("tex_in");
|
||||
const QString ViewerOutput::k_samples_input = QStringLiteral("samples_in");
|
||||
|
||||
const SampleFormat ViewerOutput::kDefaultSampleFormat = SampleFormat::F32P;
|
||||
const SampleFormat ViewerOutput::k_default_sample_format = SampleFormat::f32_p;
|
||||
|
||||
#define super Node
|
||||
|
||||
@@ -50,38 +50,38 @@ ViewerOutput::ViewerOutput(bool create_buffer_inputs,
|
||||
, autocache_input_audio_(false)
|
||||
, waveform_requests_enabled_(false)
|
||||
{
|
||||
AddInput(kVideoParamsInput, NodeValue::kVideoParams,
|
||||
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable |
|
||||
kInputFlagArray | kInputFlagHidden));
|
||||
add_input(k_video_params_input, NodeValue::k_video_params,
|
||||
InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable |
|
||||
k_input_flag_array | k_input_flag_hidden));
|
||||
|
||||
AddInput(kAudioParamsInput, NodeValue::kAudioParams,
|
||||
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable |
|
||||
kInputFlagArray | kInputFlagHidden));
|
||||
add_input(k_audio_params_input, NodeValue::k_audio_params,
|
||||
InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable |
|
||||
k_input_flag_array | k_input_flag_hidden));
|
||||
|
||||
AddInput(kSubtitleParamsInput, NodeValue::kSubtitleParams,
|
||||
InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable |
|
||||
kInputFlagArray | kInputFlagHidden));
|
||||
add_input(k_subtitle_params_input, NodeValue::k_subtitle_params,
|
||||
InputFlags(k_input_flag_not_connectable | k_input_flag_not_keyframable |
|
||||
k_input_flag_array | k_input_flag_hidden));
|
||||
|
||||
if (create_buffer_inputs) {
|
||||
AddInput(kTextureInput, NodeValue::kTexture,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
AddInput(kSamplesInput, NodeValue::kSamples,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
add_input(k_texture_input, NodeValue::k_texture,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
add_input(k_samples_input, NodeValue::k_samples,
|
||||
InputFlags(k_input_flag_not_keyframable));
|
||||
}
|
||||
|
||||
if (create_default_streams) {
|
||||
AddStream(Track::kVideo, QVariant());
|
||||
AddStream(Track::kAudio, QVariant());
|
||||
add_stream(Track::k_video, QVariant());
|
||||
add_stream(Track::k_audio, QVariant());
|
||||
set_default_parameters();
|
||||
}
|
||||
|
||||
SetFlag(kDontShowInParamView);
|
||||
set_flag(k_dont_show_in_param_view);
|
||||
|
||||
workarea_ = new TimelineWorkArea(this);
|
||||
markers_ = new TimelineMarkerList(this);
|
||||
}
|
||||
|
||||
QString ViewerOutput::Name() const
|
||||
QString ViewerOutput::name() const
|
||||
{
|
||||
return tr("Viewer");
|
||||
}
|
||||
@@ -91,12 +91,12 @@ QString ViewerOutput::id() const
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.vieweroutput");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> ViewerOutput::Category() const
|
||||
QVector<Node::CategoryID> ViewerOutput::category() const
|
||||
{
|
||||
return { kCategoryOutput };
|
||||
return { k_category_output };
|
||||
}
|
||||
|
||||
QString ViewerOutput::Description() const
|
||||
QString ViewerOutput::description() const
|
||||
{
|
||||
return tr("Interface between a Viewer panel and the node system.");
|
||||
}
|
||||
@@ -104,52 +104,52 @@ QString ViewerOutput::Description() const
|
||||
QVariant ViewerOutput::data(const DataType &d) const
|
||||
{
|
||||
switch (d) {
|
||||
case DURATION: {
|
||||
rational using_timebase;
|
||||
case duration: {
|
||||
Rational using_timebase;
|
||||
Timecode::Display using_display =
|
||||
Core::instance()->GetTimecodeDisplay();
|
||||
Core::instance()->get_timecode_display();
|
||||
|
||||
// Get first enabled streams
|
||||
VideoParams video = GetFirstEnabledVideoStream();
|
||||
AudioParams audio = GetFirstEnabledAudioStream();
|
||||
SubtitleParams sub = GetFirstEnabledSubtitleStream();
|
||||
VideoParams video = get_first_enabled_video_stream();
|
||||
AudioParams audio = get_first_enabled_audio_stream();
|
||||
SubtitleParams sub = get_first_enabled_subtitle_stream();
|
||||
|
||||
if (video.is_valid() &&
|
||||
video.video_type() != VideoParams::kVideoTypeStill) {
|
||||
video.video_type() != VideoParams::k_video_type_still) {
|
||||
// Prioritize video
|
||||
using_timebase = video.frame_rate_as_time_base();
|
||||
} else if (audio.is_valid()) {
|
||||
// Use audio as a backup
|
||||
// If we're showing in a timecode, we prefer showing audio in seconds instead
|
||||
if (using_display == Timecode::kTimecodeDropFrame ||
|
||||
using_display == Timecode::kTimecodeNonDropFrame) {
|
||||
using_display = Timecode::kTimecodeSeconds;
|
||||
if (using_display == Timecode::k_timecode_drop_frame ||
|
||||
using_display == Timecode::k_timecode_non_drop_frame) {
|
||||
using_display = Timecode::k_timecode_seconds;
|
||||
}
|
||||
|
||||
using_timebase = audio.sample_rate_as_time_base();
|
||||
} else if (sub.is_valid()) {
|
||||
using_timebase =
|
||||
OLIVE_CONFIG("DefaultSequenceFrameRate").value<rational>();
|
||||
OAK_CONFIG("DefaultSequenceFrameRate").value<Rational>();
|
||||
}
|
||||
|
||||
if (!using_timebase.isNull()) {
|
||||
// Return time transformed to timecode
|
||||
return QString::fromStdString(Timecode::time_to_timecode(
|
||||
GetLength(), using_timebase, using_display));
|
||||
get_length(), using_timebase, using_display));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FREQUENCY_RATE: {
|
||||
case frequency_rate: {
|
||||
VideoParams video_stream;
|
||||
|
||||
if (HasEnabledVideoStreams() &&
|
||||
(video_stream = GetFirstEnabledVideoStream()).video_type() !=
|
||||
VideoParams::kVideoTypeStill) {
|
||||
if (has_enabled_video_streams() &&
|
||||
(video_stream = get_first_enabled_video_stream()).video_type() !=
|
||||
VideoParams::k_video_type_still) {
|
||||
// This is a video editor, prioritize video streams
|
||||
return tr("%1 FPS").arg(video_stream.frame_rate().toDouble());
|
||||
} else if (HasEnabledAudioStreams()) {
|
||||
return tr("%1 FPS").arg(video_stream.frame_rate().to_double());
|
||||
} else if (has_enabled_audio_streams()) {
|
||||
// No video streams, return audio
|
||||
AudioParams audio_stream = GetFirstEnabledAudioStream();
|
||||
AudioParams audio_stream = get_first_enabled_audio_stream();
|
||||
return tr("%1 Hz").arg(audio_stream.sample_rate());
|
||||
}
|
||||
break;
|
||||
@@ -161,27 +161,27 @@ QVariant ViewerOutput::data(const DataType &d) const
|
||||
return super::data(d);
|
||||
}
|
||||
|
||||
bool ViewerOutput::HasEnabledVideoStreams() const
|
||||
bool ViewerOutput::has_enabled_video_streams() const
|
||||
{
|
||||
return GetFirstEnabledVideoStream().is_valid();
|
||||
return get_first_enabled_video_stream().is_valid();
|
||||
}
|
||||
|
||||
bool ViewerOutput::HasEnabledAudioStreams() const
|
||||
bool ViewerOutput::has_enabled_audio_streams() const
|
||||
{
|
||||
return GetFirstEnabledAudioStream().is_valid();
|
||||
return get_first_enabled_audio_stream().is_valid();
|
||||
}
|
||||
|
||||
bool ViewerOutput::HasEnabledSubtitleStreams() const
|
||||
bool ViewerOutput::has_enabled_subtitle_streams() const
|
||||
{
|
||||
return GetFirstEnabledSubtitleStream().is_valid();
|
||||
return get_first_enabled_subtitle_stream().is_valid();
|
||||
}
|
||||
|
||||
VideoParams ViewerOutput::GetFirstEnabledVideoStream() const
|
||||
VideoParams ViewerOutput::get_first_enabled_video_stream() const
|
||||
{
|
||||
int sz = GetVideoStreamCount();
|
||||
int sz = get_video_stream_count();
|
||||
|
||||
for (int i = 0; i < sz; i++) {
|
||||
VideoParams vp = GetVideoParams(i);
|
||||
VideoParams vp = get_video_params(i);
|
||||
|
||||
if (vp.enabled()) {
|
||||
return vp;
|
||||
@@ -191,12 +191,12 @@ VideoParams ViewerOutput::GetFirstEnabledVideoStream() const
|
||||
return VideoParams();
|
||||
}
|
||||
|
||||
AudioParams ViewerOutput::GetFirstEnabledAudioStream() const
|
||||
AudioParams ViewerOutput::get_first_enabled_audio_stream() const
|
||||
{
|
||||
int sz = GetAudioStreamCount();
|
||||
int sz = get_audio_stream_count();
|
||||
|
||||
for (int i = 0; i < sz; i++) {
|
||||
AudioParams ap = GetAudioParams(i);
|
||||
AudioParams ap = get_audio_params(i);
|
||||
|
||||
if (ap.enabled()) {
|
||||
return ap;
|
||||
@@ -206,12 +206,12 @@ AudioParams ViewerOutput::GetFirstEnabledAudioStream() const
|
||||
return AudioParams();
|
||||
}
|
||||
|
||||
SubtitleParams ViewerOutput::GetFirstEnabledSubtitleStream() const
|
||||
SubtitleParams ViewerOutput::get_first_enabled_subtitle_stream() const
|
||||
{
|
||||
int sz = GetSubtitleStreamCount();
|
||||
int sz = get_subtitle_stream_count();
|
||||
|
||||
for (int i = 0; i < sz; i++) {
|
||||
SubtitleParams sp = GetSubtitleParams(i);
|
||||
SubtitleParams sp = get_subtitle_params(i);
|
||||
|
||||
if (sp.enabled()) {
|
||||
return sp;
|
||||
@@ -223,88 +223,88 @@ SubtitleParams ViewerOutput::GetFirstEnabledSubtitleStream() const
|
||||
|
||||
void ViewerOutput::set_default_parameters()
|
||||
{
|
||||
int width = OLIVE_CONFIG("DefaultSequenceWidth").toInt();
|
||||
int height = OLIVE_CONFIG("DefaultSequenceHeight").toInt();
|
||||
int width = OAK_CONFIG("DefaultSequenceWidth").toInt();
|
||||
int height = OAK_CONFIG("DefaultSequenceHeight").toInt();
|
||||
|
||||
SetVideoParams(VideoParams(
|
||||
set_video_params(VideoParams(
|
||||
width, height,
|
||||
OLIVE_CONFIG("DefaultSequenceFrameRate").value<rational>(),
|
||||
OAK_CONFIG("DefaultSequenceFrameRate").value<Rational>(),
|
||||
static_cast<PixelFormat::Format>(
|
||||
OLIVE_CONFIG("OfflinePixelFormat").toInt()),
|
||||
VideoParams::kInternalChannelCount,
|
||||
OLIVE_CONFIG("DefaultSequencePixelAspect").value<rational>(),
|
||||
OLIVE_CONFIG("DefaultSequenceInterlacing")
|
||||
OAK_CONFIG("OfflinePixelFormat").toInt()),
|
||||
VideoParams::k_internal_channel_count,
|
||||
OAK_CONFIG("DefaultSequencePixelAspect").value<Rational>(),
|
||||
OAK_CONFIG("DefaultSequenceInterlacing")
|
||||
.value<VideoParams::Interlacing>(),
|
||||
1));
|
||||
SetAudioParams(
|
||||
AudioParams(OLIVE_CONFIG("DefaultSequenceAudioFrequency").toInt(),
|
||||
OLIVE_CONFIG("DefaultSequenceAudioLayout").toULongLong(),
|
||||
kDefaultSampleFormat));
|
||||
set_audio_params(
|
||||
AudioParams(OAK_CONFIG("DefaultSequenceAudioFrequency").toInt(),
|
||||
OAK_CONFIG("DefaultSequenceAudioLayout").toULongLong(),
|
||||
k_default_sample_format));
|
||||
}
|
||||
|
||||
void ViewerOutput::InvalidateCache(const TimeRange &range, const QString &from,
|
||||
void ViewerOutput::invalidate_cache(const TimeRange &range, const QString &from,
|
||||
int element, InvalidateCacheOptions options)
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
|
||||
if (Node *connected = GetConnectedOutput(from, element)) {
|
||||
if (from == kTextureInput) {
|
||||
if (Node *connected = get_connected_output(from, element)) {
|
||||
if (from == k_texture_input) {
|
||||
//connected->thumbnail_cache()->Request(range.Intersected(max_range), PlaybackCache::kPreviewsOnly);
|
||||
if (autocache_input_video_) {
|
||||
TimeRange max_range = InputTimeAdjustment(
|
||||
from, element, TimeRange(0, GetVideoLength()), false);
|
||||
connected->video_frame_cache()->Request(
|
||||
this, range.Intersected(max_range));
|
||||
TimeRange max_range = input_time_adjustment(
|
||||
from, element, TimeRange(0, get_video_length()), false);
|
||||
connected->video_frame_cache()->request(
|
||||
this, range.intersected(max_range));
|
||||
}
|
||||
} else if (from == kSamplesInput) {
|
||||
TimeRange max_range = InputTimeAdjustment(
|
||||
from, element, TimeRange(0, GetAudioLength()), false);
|
||||
} else if (from == k_samples_input) {
|
||||
TimeRange max_range = input_time_adjustment(
|
||||
from, element, TimeRange(0, get_audio_length()), false);
|
||||
if (waveform_requests_enabled_) {
|
||||
connected->waveform_cache()->Request(
|
||||
this, range.Intersected(max_range));
|
||||
connected->waveform_cache()->request(
|
||||
this, range.intersected(max_range));
|
||||
}
|
||||
if (autocache_input_audio_) {
|
||||
connected->audio_playback_cache()->Request(
|
||||
this, range.Intersected(max_range));
|
||||
connected->audio_playback_cache()->request(
|
||||
this, range.intersected(max_range));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VerifyLength();
|
||||
verify_length();
|
||||
|
||||
super::InvalidateCache(range, from, element, options);
|
||||
super::invalidate_cache(range, from, element, options);
|
||||
}
|
||||
|
||||
QVector<Track::Reference> ViewerOutput::GetEnabledStreamsAsReferences() const
|
||||
QVector<Track::Reference> ViewerOutput::get_enabled_streams_as_references() const
|
||||
{
|
||||
QVector<Track::Reference> refs;
|
||||
|
||||
{
|
||||
int vp_sz = GetVideoStreamCount();
|
||||
int vp_sz = get_video_stream_count();
|
||||
|
||||
for (int i = 0; i < vp_sz; i++) {
|
||||
if (GetVideoParams(i).enabled()) {
|
||||
refs.append(Track::Reference(Track::kVideo, i));
|
||||
if (get_video_params(i).enabled()) {
|
||||
refs.append(Track::Reference(Track::k_video, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int ap_sz = GetAudioStreamCount();
|
||||
int ap_sz = get_audio_stream_count();
|
||||
|
||||
for (int i = 0; i < ap_sz; i++) {
|
||||
if (GetAudioParams(i).enabled()) {
|
||||
refs.append(Track::Reference(Track::kAudio, i));
|
||||
if (get_audio_params(i).enabled()) {
|
||||
refs.append(Track::Reference(Track::k_audio, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int sp_sz = GetSubtitleStreamCount();
|
||||
int sp_sz = get_subtitle_stream_count();
|
||||
|
||||
for (int i = 0; i < sp_sz; i++) {
|
||||
if (GetSubtitleParams(i).enabled()) {
|
||||
refs.append(Track::Reference(Track::kSubtitle, i));
|
||||
if (get_subtitle_params(i).enabled()) {
|
||||
refs.append(Track::Reference(Track::k_subtitle, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,54 +312,54 @@ QVector<Track::Reference> ViewerOutput::GetEnabledStreamsAsReferences() const
|
||||
return refs;
|
||||
}
|
||||
|
||||
void ViewerOutput::Retranslate()
|
||||
void ViewerOutput::retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::retranslate();
|
||||
|
||||
SetInputName(kVideoParamsInput, tr("Video Parameters"));
|
||||
SetInputName(kAudioParamsInput, tr("Audio Parameters"));
|
||||
SetInputName(kSubtitleParamsInput, tr("Subtitle Parameters"));
|
||||
set_input_name(k_video_params_input, tr("Video Parameters"));
|
||||
set_input_name(k_audio_params_input, tr("Audio Parameters"));
|
||||
set_input_name(k_subtitle_params_input, tr("Subtitle Parameters"));
|
||||
|
||||
if (HasInputWithID(kTextureInput)) {
|
||||
SetInputName(kTextureInput, tr("Texture"));
|
||||
if (has_input_with_id(k_texture_input)) {
|
||||
set_input_name(k_texture_input, tr("Texture"));
|
||||
}
|
||||
|
||||
if (HasInputWithID(kSamplesInput)) {
|
||||
SetInputName(kSamplesInput, tr("Samples"));
|
||||
if (has_input_with_id(k_samples_input)) {
|
||||
set_input_name(k_samples_input, tr("Samples"));
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerOutput::VerifyLength()
|
||||
void ViewerOutput::verify_length()
|
||||
{
|
||||
video_length_ = VerifyLengthInternal(Track::kVideo);
|
||||
video_length_ = verify_length_internal(Track::k_video);
|
||||
|
||||
audio_length_ = VerifyLengthInternal(Track::kAudio);
|
||||
audio_length_ = verify_length_internal(Track::k_audio);
|
||||
|
||||
rational subtitle_length = VerifyLengthInternal(Track::kSubtitle);
|
||||
Rational subtitle_length = verify_length_internal(Track::k_subtitle);
|
||||
|
||||
rational real_length =
|
||||
Rational real_length =
|
||||
qMax(subtitle_length, qMax(video_length_, audio_length_));
|
||||
|
||||
if (real_length != last_length_) {
|
||||
last_length_ = real_length;
|
||||
emit LengthChanged(last_length_);
|
||||
emit length_changed(last_length_);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerOutput::SetPlayhead(const rational &t)
|
||||
void ViewerOutput::set_playhead(const Rational &t)
|
||||
{
|
||||
playhead_ = t;
|
||||
emit PlayheadChanged(t);
|
||||
emit playhead_changed(t);
|
||||
}
|
||||
|
||||
void ViewerOutput::InputConnectedEvent(const QString &input, int element,
|
||||
Node *output)
|
||||
{
|
||||
if (input == kTextureInput) {
|
||||
emit TextureInputChanged();
|
||||
} else if (input == kSamplesInput) {
|
||||
connect(output->waveform_cache(), &AudioWaveformCache::Validated, this,
|
||||
&ViewerOutput::ConnectedWaveformChanged);
|
||||
if (input == k_texture_input) {
|
||||
emit texture_input_changed();
|
||||
} else if (input == k_samples_input) {
|
||||
connect(output->waveform_cache(), &AudioWaveformCache::validated, this,
|
||||
&ViewerOutput::connected_waveform_changed);
|
||||
}
|
||||
|
||||
super::InputConnectedEvent(input, element, output);
|
||||
@@ -368,111 +368,111 @@ void ViewerOutput::InputConnectedEvent(const QString &input, int element,
|
||||
void ViewerOutput::InputDisconnectedEvent(const QString &input, int element,
|
||||
Node *output)
|
||||
{
|
||||
if (input == kTextureInput) {
|
||||
emit TextureInputChanged();
|
||||
} else if (input == kSamplesInput) {
|
||||
disconnect(output->waveform_cache(), &AudioWaveformCache::Validated,
|
||||
this, &ViewerOutput::ConnectedWaveformChanged);
|
||||
if (input == k_texture_input) {
|
||||
emit texture_input_changed();
|
||||
} else if (input == k_samples_input) {
|
||||
disconnect(output->waveform_cache(), &AudioWaveformCache::validated,
|
||||
this, &ViewerOutput::connected_waveform_changed);
|
||||
}
|
||||
|
||||
super::InputDisconnectedEvent(input, element, output);
|
||||
}
|
||||
|
||||
rational ViewerOutput::VerifyLengthInternal(Track::Type type) const
|
||||
Rational ViewerOutput::verify_length_internal(Track::Type type) const
|
||||
{
|
||||
NodeTraverser traverser;
|
||||
|
||||
switch (type) {
|
||||
case Track::kVideo:
|
||||
if (IsInputConnected(kTextureInput)) {
|
||||
NodeValueTable t = traverser.GenerateTable(
|
||||
GetConnectedOutput(kTextureInput), TimeRange(0, 0));
|
||||
rational r = t.Get(NodeValue::kRational, QStringLiteral("length"))
|
||||
.toRational();
|
||||
case Track::k_video:
|
||||
if (is_input_connected(k_texture_input)) {
|
||||
NodeValueTable t = traverser.generate_table(
|
||||
get_connected_output(k_texture_input), TimeRange(0, 0));
|
||||
Rational r = t.get(NodeValue::k_rational, QStringLiteral("length"))
|
||||
.to_rational();
|
||||
if (!r.isNaN()) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Track::kAudio:
|
||||
if (IsInputConnected(kSamplesInput)) {
|
||||
NodeValueTable t = traverser.GenerateTable(
|
||||
GetConnectedOutput(kSamplesInput), TimeRange(0, 0));
|
||||
rational r = t.Get(NodeValue::kRational, QStringLiteral("length"))
|
||||
.toRational();
|
||||
case Track::k_audio:
|
||||
if (is_input_connected(k_samples_input)) {
|
||||
NodeValueTable t = traverser.generate_table(
|
||||
get_connected_output(k_samples_input), TimeRange(0, 0));
|
||||
Rational r = t.get(NodeValue::k_rational, QStringLiteral("length"))
|
||||
.to_rational();
|
||||
if (!r.isNaN()) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Track::kNone:
|
||||
case Track::kSubtitle:
|
||||
case Track::kCount:
|
||||
case Track::k_none:
|
||||
case Track::k_subtitle:
|
||||
case Track::k_count:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Node *ViewerOutput::GetConnectedTextureOutput()
|
||||
Node *ViewerOutput::get_connected_texture_output()
|
||||
{
|
||||
return GetConnectedOutput(kTextureInput);
|
||||
return get_connected_output(k_texture_input);
|
||||
}
|
||||
|
||||
Node::ValueHint ViewerOutput::GetConnectedTextureValueHint()
|
||||
Node::ValueHint ViewerOutput::get_connected_texture_value_hint()
|
||||
{
|
||||
return GetValueHintForInput(kTextureInput);
|
||||
return get_value_hint_for_input(k_texture_input);
|
||||
}
|
||||
|
||||
Node *ViewerOutput::GetConnectedSampleOutput()
|
||||
Node *ViewerOutput::get_connected_sample_output()
|
||||
{
|
||||
return GetConnectedOutput(kSamplesInput);
|
||||
return get_connected_output(k_samples_input);
|
||||
}
|
||||
|
||||
Node::ValueHint ViewerOutput::GetConnectedSampleValueHint()
|
||||
Node::ValueHint ViewerOutput::get_connected_sample_value_hint()
|
||||
{
|
||||
return GetValueHintForInput(kSamplesInput);
|
||||
return get_value_hint_for_input(k_samples_input);
|
||||
}
|
||||
|
||||
void ViewerOutput::SetWaveformEnabled(bool e)
|
||||
void ViewerOutput::set_waveform_enabled(bool e)
|
||||
{
|
||||
if ((waveform_requests_enabled_ = e)) {
|
||||
if (Node *connected = this->GetConnectedSampleOutput()) {
|
||||
TimeRange max_range = InputTimeAdjustment(
|
||||
kSamplesInput, -1, TimeRange(0, GetAudioLength()), false);
|
||||
if (Node *connected = this->get_connected_sample_output()) {
|
||||
TimeRange max_range = input_time_adjustment(
|
||||
k_samples_input, -1, TimeRange(0, get_audio_length()), false);
|
||||
TimeRangeList invalid =
|
||||
connected->waveform_cache()->GetInvalidatedRanges(max_range);
|
||||
connected->waveform_cache()->get_invalidated_ranges(max_range);
|
||||
for (const TimeRange &r : invalid) {
|
||||
connected->waveform_cache()->Request(this, r);
|
||||
connected->waveform_cache()->request(this, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerOutput::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
void ViewerOutput::value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
if (HasInputWithID(kTextureInput)) {
|
||||
NodeValue repush = value[kTextureInput];
|
||||
repush.set_tag(Track::Reference(Track::kVideo, 0).ToString());
|
||||
table->Push(repush);
|
||||
if (has_input_with_id(k_texture_input)) {
|
||||
NodeValue repush = value[k_texture_input];
|
||||
repush.set_tag(Track::Reference(Track::k_video, 0).to_string());
|
||||
table->push(repush);
|
||||
}
|
||||
if (HasInputWithID(kSamplesInput)) {
|
||||
NodeValue repush = value[kSamplesInput];
|
||||
repush.set_tag(Track::Reference(Track::kAudio, 0).ToString());
|
||||
table->Push(repush);
|
||||
if (has_input_with_id(k_samples_input)) {
|
||||
NodeValue repush = value[k_samples_input];
|
||||
repush.set_tag(Track::Reference(Track::k_audio, 0).to_string());
|
||||
table->push(repush);
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewerOutput::LoadCustom(QXmlStreamReader *reader, SerializedData *data)
|
||||
bool ViewerOutput::load_custom(QXmlStreamReader *reader, SerializedData *data)
|
||||
{
|
||||
while (XMLReadNextStartElement(reader)) {
|
||||
while (xml_read_next_start_element(reader)) {
|
||||
if (reader->name() == QStringLiteral("markers")) {
|
||||
if (!this->GetMarkers()->load(reader)) {
|
||||
if (!this->get_markers()->load(reader)) {
|
||||
return false;
|
||||
}
|
||||
} else if (reader->name() == QStringLiteral("workarea")) {
|
||||
if (!this->GetWorkArea()->load(reader)) {
|
||||
if (!this->get_work_area()->load(reader)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@@ -483,66 +483,66 @@ bool ViewerOutput::LoadCustom(QXmlStreamReader *reader, SerializedData *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewerOutput::SaveCustom(QXmlStreamWriter *writer) const
|
||||
void ViewerOutput::save_custom(QXmlStreamWriter *writer) const
|
||||
{
|
||||
writer->writeStartElement(QStringLiteral("workarea"));
|
||||
this->GetWorkArea()->save(writer);
|
||||
this->get_work_area()->save(writer);
|
||||
writer->writeEndElement(); // workarea
|
||||
|
||||
writer->writeStartElement(QStringLiteral("markers"));
|
||||
this->GetMarkers()->save(writer);
|
||||
this->get_markers()->save(writer);
|
||||
writer->writeEndElement(); // markers
|
||||
}
|
||||
|
||||
void ViewerOutput::InputValueChangedEvent(const QString &input, int element)
|
||||
{
|
||||
if (element == 0) {
|
||||
if (input == kVideoParamsInput) {
|
||||
VideoParams new_video_params = GetVideoParams();
|
||||
if (input == k_video_params_input) {
|
||||
VideoParams new_video_params = get_video_params();
|
||||
|
||||
bool size_changed =
|
||||
bool has_size_changed =
|
||||
cached_video_params_.width() != new_video_params.width() ||
|
||||
cached_video_params_.height() != new_video_params.height();
|
||||
bool frame_rate_changed = cached_video_params_.frame_rate() !=
|
||||
bool has_frame_rate_changed = cached_video_params_.frame_rate() !=
|
||||
new_video_params.frame_rate();
|
||||
bool pixel_aspect_changed =
|
||||
bool has_pixel_aspect_changed =
|
||||
cached_video_params_.pixel_aspect_ratio() !=
|
||||
new_video_params.pixel_aspect_ratio();
|
||||
bool interlacing_changed = cached_video_params_.interlacing() !=
|
||||
bool has_interlacing_changed = cached_video_params_.interlacing() !=
|
||||
new_video_params.interlacing();
|
||||
|
||||
if (size_changed) {
|
||||
emit SizeChanged(new_video_params.width(),
|
||||
if (has_size_changed) {
|
||||
emit size_changed(new_video_params.width(),
|
||||
new_video_params.height());
|
||||
}
|
||||
|
||||
if (pixel_aspect_changed) {
|
||||
emit PixelAspectChanged(new_video_params.pixel_aspect_ratio());
|
||||
if (has_pixel_aspect_changed) {
|
||||
emit pixel_aspect_changed(new_video_params.pixel_aspect_ratio());
|
||||
}
|
||||
|
||||
if (interlacing_changed) {
|
||||
emit InterlacingChanged(new_video_params.interlacing());
|
||||
if (has_interlacing_changed) {
|
||||
emit interlacing_changed(new_video_params.interlacing());
|
||||
}
|
||||
|
||||
if (frame_rate_changed) {
|
||||
emit FrameRateChanged(new_video_params.frame_rate());
|
||||
if (has_frame_rate_changed) {
|
||||
emit frame_rate_changed(new_video_params.frame_rate());
|
||||
}
|
||||
|
||||
emit VideoParamsChanged();
|
||||
emit video_params_changed();
|
||||
|
||||
cached_video_params_ = new_video_params;
|
||||
|
||||
} else if (input == kAudioParamsInput) {
|
||||
AudioParams new_audio_params = GetAudioParams();
|
||||
} else if (input == k_audio_params_input) {
|
||||
AudioParams new_audio_params = get_audio_params();
|
||||
|
||||
bool sample_rate_changed = new_audio_params.sample_rate() !=
|
||||
bool has_sample_rate_changed = new_audio_params.sample_rate() !=
|
||||
cached_audio_params_.sample_rate();
|
||||
|
||||
if (sample_rate_changed) {
|
||||
emit SampleRateChanged(new_audio_params.sample_rate());
|
||||
if (has_sample_rate_changed) {
|
||||
emit sample_rate_changed(new_audio_params.sample_rate());
|
||||
}
|
||||
|
||||
emit AudioParamsChanged();
|
||||
emit audio_params_changed();
|
||||
|
||||
cached_audio_params_ = new_audio_params;
|
||||
}
|
||||
@@ -555,16 +555,16 @@ void ViewerOutput::set_parameters_from_footage(
|
||||
const QVector<ViewerOutput *> footage)
|
||||
{
|
||||
foreach (ViewerOutput *f, footage) {
|
||||
QVector<VideoParams> video_streams = f->GetEnabledVideoStreams();
|
||||
QVector<AudioParams> audio_streams = f->GetEnabledAudioStreams();
|
||||
QVector<VideoParams> video_streams = f->get_enabled_video_streams();
|
||||
QVector<AudioParams> audio_streams = f->get_enabled_audio_streams();
|
||||
|
||||
for (int i = 0; i < video_streams.size(); i++) {
|
||||
const VideoParams &s = video_streams.at(i);
|
||||
|
||||
bool found_video_params = false;
|
||||
rational using_timebase;
|
||||
Rational using_timebase;
|
||||
|
||||
if (s.video_type() == VideoParams::kVideoTypeStill) {
|
||||
if (s.video_type() == VideoParams::k_video_type_still) {
|
||||
// If this is a still image, we'll use it's resolution but won't set
|
||||
// `found_video_params` in case something with a frame rate comes along which we'll
|
||||
// prioritize
|
||||
@@ -573,17 +573,17 @@ void ViewerOutput::set_parameters_from_footage(
|
||||
continue;
|
||||
}
|
||||
|
||||
using_timebase = GetVideoParams().time_base();
|
||||
using_timebase = get_video_params().time_base();
|
||||
} else {
|
||||
using_timebase = s.frame_rate_as_time_base();
|
||||
found_video_params = true;
|
||||
}
|
||||
|
||||
SetVideoParams(
|
||||
set_video_params(
|
||||
VideoParams(s.width(), s.height(), using_timebase,
|
||||
static_cast<PixelFormat::Format>(
|
||||
OLIVE_CONFIG("OfflinePixelFormat").toInt()),
|
||||
VideoParams::kInternalChannelCount,
|
||||
OAK_CONFIG("OfflinePixelFormat").toInt()),
|
||||
VideoParams::k_internal_channel_count,
|
||||
s.pixel_aspect_ratio(), s.interlacing(), 1));
|
||||
|
||||
if (found_video_params) {
|
||||
@@ -593,52 +593,52 @@ void ViewerOutput::set_parameters_from_footage(
|
||||
|
||||
if (!audio_streams.isEmpty()) {
|
||||
const AudioParams &s = audio_streams.first();
|
||||
SetAudioParams(AudioParams(s.sample_rate(), s.channel_layout(),
|
||||
kDefaultSampleFormat));
|
||||
set_audio_params(AudioParams(s.sample_rate(), s.channel_layout(),
|
||||
k_default_sample_format));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ViewerOutput::AddStream(Track::Type type, const QVariant &value)
|
||||
int ViewerOutput::add_stream(Track::Type type, const QVariant &value)
|
||||
{
|
||||
return SetStream(type, value, -1);
|
||||
return set_stream(type, value, -1);
|
||||
}
|
||||
|
||||
int ViewerOutput::SetStream(Track::Type type, const QVariant &value,
|
||||
int ViewerOutput::set_stream(Track::Type type, const QVariant &value,
|
||||
int index_in)
|
||||
{
|
||||
QString id;
|
||||
|
||||
if (type == Track::kVideo) {
|
||||
id = kVideoParamsInput;
|
||||
} else if (type == Track::kAudio) {
|
||||
id = kAudioParamsInput;
|
||||
} else if (type == Track::kSubtitle) {
|
||||
id = kSubtitleParamsInput;
|
||||
if (type == Track::k_video) {
|
||||
id = k_video_params_input;
|
||||
} else if (type == Track::k_audio) {
|
||||
id = k_audio_params_input;
|
||||
} else if (type == Track::k_subtitle) {
|
||||
id = k_subtitle_params_input;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Add another video/audio param to the array for this stream
|
||||
int index = (index_in == -1) ? InputArraySize(id) : index_in;
|
||||
int index = (index_in == -1) ? input_array_size(id) : index_in;
|
||||
|
||||
if (index >= InputArraySize(id)) {
|
||||
InputArrayResize(id, index + 1);
|
||||
if (index >= input_array_size(id)) {
|
||||
input_array_resize(id, index + 1);
|
||||
}
|
||||
|
||||
SetStandardValue(id, value, index);
|
||||
set_standard_value(id, value, index);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
QVector<VideoParams> ViewerOutput::GetEnabledVideoStreams() const
|
||||
QVector<VideoParams> ViewerOutput::get_enabled_video_streams() const
|
||||
{
|
||||
QVector<VideoParams> streams;
|
||||
|
||||
int vp_sz = GetVideoStreamCount();
|
||||
int vp_sz = get_video_stream_count();
|
||||
|
||||
for (int i = 0; i < vp_sz; i++) {
|
||||
VideoParams vp = GetVideoParams(i);
|
||||
VideoParams vp = get_video_params(i);
|
||||
|
||||
if (vp.enabled()) {
|
||||
streams.append(vp);
|
||||
@@ -648,14 +648,14 @@ QVector<VideoParams> ViewerOutput::GetEnabledVideoStreams() const
|
||||
return streams;
|
||||
}
|
||||
|
||||
QVector<AudioParams> ViewerOutput::GetEnabledAudioStreams() const
|
||||
QVector<AudioParams> ViewerOutput::get_enabled_audio_streams() const
|
||||
{
|
||||
QVector<AudioParams> streams;
|
||||
|
||||
int ap_sz = GetAudioStreamCount();
|
||||
int ap_sz = get_audio_stream_count();
|
||||
|
||||
for (int i = 0; i < ap_sz; i++) {
|
||||
AudioParams ap = GetAudioParams(i);
|
||||
AudioParams ap = get_audio_params(i);
|
||||
|
||||
if (ap.enabled()) {
|
||||
streams.append(ap);
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef VIEWER_H
|
||||
#define VIEWER_H
|
||||
#ifndef OAK_VIEWER_H
|
||||
#define OAK_VIEWER_H
|
||||
|
||||
#include "codec/encoder.h"
|
||||
#include "node/node.h"
|
||||
@@ -50,10 +50,10 @@ public:
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(ViewerOutput)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QVector<CategoryID> category() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
virtual QVariant data(const DataType &d) const override;
|
||||
|
||||
@@ -61,216 +61,216 @@ public:
|
||||
|
||||
void set_parameters_from_footage(const QVector<ViewerOutput *> footage);
|
||||
|
||||
virtual void InvalidateCache(const TimeRange &range, const QString &from,
|
||||
virtual void invalidate_cache(const TimeRange &range, const QString &from,
|
||||
int element,
|
||||
InvalidateCacheOptions options) override;
|
||||
|
||||
VideoParams GetVideoParams(int index = 0) const
|
||||
VideoParams get_video_params(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)
|
||||
if (index < input_array_size(k_video_params_input)) {
|
||||
return get_standard_value(k_video_params_input, index)
|
||||
.value<VideoParams>();
|
||||
} else {
|
||||
return VideoParams();
|
||||
}
|
||||
}
|
||||
|
||||
AudioParams GetAudioParams(int index = 0) const
|
||||
AudioParams get_audio_params(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)
|
||||
if (index < input_array_size(k_audio_params_input)) {
|
||||
return get_standard_value(k_audio_params_input, index)
|
||||
.value<AudioParams>();
|
||||
} else {
|
||||
return AudioParams();
|
||||
}
|
||||
}
|
||||
|
||||
SubtitleParams GetSubtitleParams(int index = 0) const
|
||||
SubtitleParams get_subtitle_params(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)
|
||||
if (index < input_array_size(k_subtitle_params_input)) {
|
||||
return get_standard_value(k_subtitle_params_input, index)
|
||||
.value<SubtitleParams>();
|
||||
} else {
|
||||
return SubtitleParams();
|
||||
}
|
||||
}
|
||||
|
||||
const rational &GetPlayhead()
|
||||
const Rational &get_playhead()
|
||||
{
|
||||
return playhead_;
|
||||
}
|
||||
|
||||
void SetVideoParams(const VideoParams &video, int index = 0)
|
||||
void set_video_params(const VideoParams &video, int index = 0)
|
||||
{
|
||||
SetStandardValue(kVideoParamsInput, QVariant::fromValue(video), index);
|
||||
set_standard_value(k_video_params_input, QVariant::fromValue(video), index);
|
||||
}
|
||||
|
||||
void SetAudioParams(const AudioParams &audio, int index = 0)
|
||||
void set_audio_params(const AudioParams &audio, int index = 0)
|
||||
{
|
||||
SetStandardValue(kAudioParamsInput, QVariant::fromValue(audio), index);
|
||||
set_standard_value(k_audio_params_input, QVariant::fromValue(audio), index);
|
||||
}
|
||||
|
||||
void SetSubtitleParams(const SubtitleParams &subs, int index = 0)
|
||||
void set_subtitle_params(const SubtitleParams &subs, int index = 0)
|
||||
{
|
||||
SetStandardValue(kSubtitleParamsInput, QVariant::fromValue(subs),
|
||||
set_standard_value(k_subtitle_params_input, QVariant::fromValue(subs),
|
||||
index);
|
||||
}
|
||||
|
||||
int GetVideoStreamCount() const
|
||||
int get_video_stream_count() const
|
||||
{
|
||||
return InputArraySize(kVideoParamsInput);
|
||||
return input_array_size(k_video_params_input);
|
||||
}
|
||||
|
||||
int GetAudioStreamCount() const
|
||||
int get_audio_stream_count() const
|
||||
{
|
||||
return InputArraySize(kAudioParamsInput);
|
||||
return input_array_size(k_audio_params_input);
|
||||
}
|
||||
|
||||
int GetSubtitleStreamCount() const
|
||||
int get_subtitle_stream_count() const
|
||||
{
|
||||
return InputArraySize(kSubtitleParamsInput);
|
||||
return input_array_size(k_subtitle_params_input);
|
||||
}
|
||||
|
||||
virtual int GetTotalStreamCount() const
|
||||
virtual int get_total_stream_count() const
|
||||
{
|
||||
return GetVideoStreamCount() + GetAudioStreamCount() +
|
||||
GetSubtitleStreamCount();
|
||||
return get_video_stream_count() + get_audio_stream_count() +
|
||||
get_subtitle_stream_count();
|
||||
}
|
||||
|
||||
const AudioWaveformCache *GetConnectedWaveform()
|
||||
const AudioWaveformCache *get_connected_waveform()
|
||||
{
|
||||
if (Node *n = GetConnectedSampleOutput()) {
|
||||
if (Node *n = get_connected_sample_output()) {
|
||||
return n->waveform_cache();
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool HasEnabledVideoStreams() const;
|
||||
bool HasEnabledAudioStreams() const;
|
||||
bool HasEnabledSubtitleStreams() const;
|
||||
bool has_enabled_video_streams() const;
|
||||
bool has_enabled_audio_streams() const;
|
||||
bool has_enabled_subtitle_streams() const;
|
||||
|
||||
VideoParams GetFirstEnabledVideoStream() const;
|
||||
AudioParams GetFirstEnabledAudioStream() const;
|
||||
SubtitleParams GetFirstEnabledSubtitleStream() const;
|
||||
VideoParams get_first_enabled_video_stream() const;
|
||||
AudioParams get_first_enabled_audio_stream() const;
|
||||
SubtitleParams get_first_enabled_subtitle_stream() const;
|
||||
|
||||
const rational &GetLength() const
|
||||
const Rational &get_length() const
|
||||
{
|
||||
return last_length_;
|
||||
}
|
||||
const rational &GetVideoLength() const
|
||||
const Rational &get_video_length() const
|
||||
{
|
||||
return video_length_;
|
||||
}
|
||||
const rational &GetAudioLength() const
|
||||
const Rational &get_audio_length() const
|
||||
{
|
||||
return audio_length_;
|
||||
}
|
||||
|
||||
TimelineWorkArea *GetWorkArea() const
|
||||
TimelineWorkArea *get_work_area() const
|
||||
{
|
||||
return workarea_;
|
||||
}
|
||||
TimelineMarkerList *GetMarkers() const
|
||||
TimelineMarkerList *get_markers() const
|
||||
{
|
||||
return markers_;
|
||||
}
|
||||
|
||||
virtual TimeRange GetVideoCacheRange() const override
|
||||
virtual TimeRange get_video_cache_range() const override
|
||||
{
|
||||
return TimeRange(0, GetVideoLength());
|
||||
return TimeRange(0, get_video_length());
|
||||
}
|
||||
|
||||
virtual TimeRange GetAudioCacheRange() const override
|
||||
virtual TimeRange get_audio_cache_range() const override
|
||||
{
|
||||
return TimeRange(0, GetAudioLength());
|
||||
return TimeRange(0, get_audio_length());
|
||||
}
|
||||
|
||||
QVector<Track::Reference> GetEnabledStreamsAsReferences() const;
|
||||
QVector<Track::Reference> get_enabled_streams_as_references() const;
|
||||
|
||||
QVector<VideoParams> GetEnabledVideoStreams() const;
|
||||
QVector<VideoParams> get_enabled_video_streams() const;
|
||||
|
||||
QVector<AudioParams> GetEnabledAudioStreams() const;
|
||||
QVector<AudioParams> get_enabled_audio_streams() const;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void retranslate() override;
|
||||
|
||||
virtual Node *GetConnectedTextureOutput();
|
||||
virtual Node *get_connected_texture_output();
|
||||
|
||||
virtual ValueHint GetConnectedTextureValueHint();
|
||||
virtual ValueHint get_connected_texture_value_hint();
|
||||
|
||||
virtual Node *GetConnectedSampleOutput();
|
||||
virtual Node *get_connected_sample_output();
|
||||
|
||||
virtual ValueHint GetConnectedSampleValueHint();
|
||||
virtual ValueHint get_connected_sample_value_hint();
|
||||
|
||||
void SetWaveformEnabled(bool e);
|
||||
void set_waveform_enabled(bool e);
|
||||
|
||||
bool IsVideoAutoCacheEnabled() const
|
||||
bool is_video_auto_cache_enabled() const
|
||||
{
|
||||
qDebug() << "sequence ac is a stub";
|
||||
return false;
|
||||
}
|
||||
void SetVideoAutoCacheEnabled(bool e)
|
||||
void set_video_auto_cache_enabled(bool e)
|
||||
{
|
||||
qDebug() << "sequence ac is a stub";
|
||||
}
|
||||
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
virtual void value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
const EncodingParams &GetLastUsedEncodingParams() const
|
||||
const EncodingParams &get_last_used_encoding_params() const
|
||||
{
|
||||
return last_used_encoding_params_;
|
||||
}
|
||||
void SetLastUsedEncodingParams(const EncodingParams &p)
|
||||
void set_last_used_encoding_params(const EncodingParams &p)
|
||||
{
|
||||
last_used_encoding_params_ = p;
|
||||
}
|
||||
|
||||
virtual bool LoadCustom(QXmlStreamReader *reader,
|
||||
virtual bool load_custom(QXmlStreamReader *reader,
|
||||
SerializedData *data) override;
|
||||
virtual void SaveCustom(QXmlStreamWriter *writer) const override;
|
||||
virtual void save_custom(QXmlStreamWriter *writer) const override;
|
||||
|
||||
static const QString kVideoParamsInput;
|
||||
static const QString kAudioParamsInput;
|
||||
static const QString kSubtitleParamsInput;
|
||||
static const QString k_video_params_input;
|
||||
static const QString k_audio_params_input;
|
||||
static const QString k_subtitle_params_input;
|
||||
|
||||
static const QString kTextureInput;
|
||||
static const QString kSamplesInput;
|
||||
static const QString k_texture_input;
|
||||
static const QString k_samples_input;
|
||||
|
||||
static const SampleFormat kDefaultSampleFormat;
|
||||
static const SampleFormat k_default_sample_format;
|
||||
|
||||
signals:
|
||||
void FrameRateChanged(const rational &);
|
||||
void frame_rate_changed(const Rational &);
|
||||
|
||||
void LengthChanged(const rational &length);
|
||||
void length_changed(const Rational &length);
|
||||
|
||||
void SizeChanged(int width, int height);
|
||||
void size_changed(int width, int height);
|
||||
|
||||
void PixelAspectChanged(const rational &pixel_aspect);
|
||||
void pixel_aspect_changed(const Rational &pixel_aspect);
|
||||
|
||||
void InterlacingChanged(VideoParams::Interlacing mode);
|
||||
void interlacing_changed(VideoParams::Interlacing mode);
|
||||
|
||||
void VideoParamsChanged();
|
||||
void AudioParamsChanged();
|
||||
void video_params_changed();
|
||||
void audio_params_changed();
|
||||
|
||||
void TextureInputChanged();
|
||||
void texture_input_changed();
|
||||
|
||||
void SampleRateChanged(int sr);
|
||||
void sample_rate_changed(int sr);
|
||||
|
||||
void ConnectedWaveformChanged();
|
||||
void connected_waveform_changed();
|
||||
|
||||
void PlayheadChanged(const rational &t);
|
||||
void playhead_changed(const Rational &t);
|
||||
|
||||
public slots:
|
||||
void VerifyLength();
|
||||
void verify_length();
|
||||
|
||||
void SetPlayhead(const rational &t);
|
||||
void set_playhead(const Rational &t);
|
||||
|
||||
protected:
|
||||
virtual void InputConnectedEvent(const QString &input, int element,
|
||||
@@ -279,18 +279,18 @@ protected:
|
||||
virtual void InputDisconnectedEvent(const QString &input, int element,
|
||||
Node *output) override;
|
||||
|
||||
virtual rational VerifyLengthInternal(Track::Type type) const;
|
||||
virtual Rational verify_length_internal(Track::Type type) const;
|
||||
|
||||
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 add_stream(Track::Type type, const QVariant &value);
|
||||
int set_stream(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_;
|
||||
|
||||
@@ -306,9 +306,9 @@ private:
|
||||
|
||||
bool waveform_requests_enabled_;
|
||||
|
||||
rational playhead_;
|
||||
Rational playhead_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // VIEWER_H
|
||||
#endif // OAK_VIEWER_H
|
||||
|
||||
Reference in New Issue
Block a user