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:
2026-07-19 16:10:54 +08:00
parent cb1718a103
commit bb40b4923e
1014 changed files with 44257 additions and 44220 deletions
+252 -252
View File
@@ -31,7 +31,7 @@ public:
NODE_DEFAULT_FUNCTIONS(ConstantValueNode)
virtual QString Name() const override
virtual QString name() const override
{
return QStringLiteral("Test Constant");
}
@@ -41,24 +41,24 @@ public:
return QStringLiteral("org.oak.test.constant");
}
virtual QVector<CategoryID> Category() const override
virtual QVector<CategoryID> category() const override
{
return { kCategoryGenerator };
return { k_category_generator };
}
void SetOutput(const olive::NodeValue &value)
void set_output(const olive::NodeValue &value)
{
output_ = value;
}
virtual void Value(const olive::NodeValueRow &value,
virtual void value(const olive::NodeValueRow &value,
const olive::NodeGlobals &globals,
olive::NodeValueTable *table) const override
{
Q_UNUSED(value)
Q_UNUSED(globals)
table->Push(output_);
table->push(output_);
}
private:
@@ -69,20 +69,20 @@ private:
// non-static (job) paths of the audio nodes can be verified end to end.
class SampleResolvingTraverser : public olive::NodeTraverser {
public:
void Resolve(olive::NodeValue &value)
void resolve(olive::NodeValue &value)
{
ResolveJobs(value);
resolve_jobs(value);
}
protected:
virtual olive::core::SampleBuffer
CreateSampleBuffer(const olive::core::AudioParams &params,
create_sample_buffer(const olive::core::AudioParams &params,
int sample_count) override
{
return olive::core::SampleBuffer(params, size_t(sample_count));
}
virtual void ProcessSamples(olive::core::SampleBuffer &destination,
virtual void process_samples(olive::core::SampleBuffer &destination,
const olive::Node *node,
const olive::TimeRange &range,
const olive::SampleJob &job) override
@@ -90,66 +90,66 @@ protected:
Q_UNUSED(range)
for (size_t i = 0; i < destination.sample_count(); i++) {
node->ProcessSamples(job.GetValues(), job.samples(), destination,
node->process_samples(job.get_values(), job.samples(), destination,
int(i));
}
}
};
template <typename T> T *AddNode(olive::Project *project)
template <typename T> T *add_node(olive::Project *project)
{
T *node = new T();
node->setParent(project);
return node;
}
ConstantValueNode *AddConstant(olive::Project *project,
ConstantValueNode *add_constant(olive::Project *project,
const olive::NodeValue &value)
{
auto *node = new ConstantValueNode();
node->setParent(project);
node->SetOutput(value);
node->set_output(value);
return node;
}
olive::NodeKeyframe *AddKey(olive::Node *node, const QString &input,
const olive::core::rational &time,
olive::NodeKeyframe *add_key(olive::Node *node, const QString &input,
const olive::core::Rational &time,
const QVariant &value)
{
auto *key = new olive::NodeKeyframe(
time, value, olive::NodeKeyframe::kLinear, 0, -1, input);
time, value, olive::NodeKeyframe::k_linear, 0, -1, input);
key->setParent(node);
return key;
}
// A fresh traverser per call: NodeTraverser caches tables per node+range, so
// reusing one would return stale results after the node's parameters change.
olive::NodeValueTable GenerateTableAt(const olive::Node *node,
const olive::core::rational &time)
olive::NodeValueTable generate_table_at(const olive::Node *node,
const olive::core::Rational &time)
{
olive::NodeTraverser traverser;
return traverser.GenerateTable(
node, olive::TimeRange(time, time + olive::core::rational(1, 30)));
return traverser.generate_table(
node, olive::TimeRange(time, time + olive::core::Rational(1, 30)));
}
olive::core::AudioParams StereoParams()
olive::core::AudioParams stereo_params()
{
return olive::core::AudioParams(48000, olive::core::kChannelLayoutStereo,
olive::core::SampleFormat::F32P);
return olive::core::AudioParams(48000, olive::core::k_channel_layout_stereo,
olive::core::SampleFormat::f32_p);
}
olive::core::AudioParams MonoParams()
olive::core::AudioParams mono_params()
{
return olive::core::AudioParams(48000, olive::core::kChannelLayoutMono,
olive::core::SampleFormat::F32P);
return olive::core::AudioParams(48000, olive::core::k_channel_layout_mono,
olive::core::SampleFormat::f32_p);
}
// Creates a stereo buffer with the given per-channel samples. Both channels
// must have the same number of samples.
olive::core::SampleBuffer MakeStereoBuffer(const std::vector<float> &channel0,
olive::core::SampleBuffer make_stereo_buffer(const std::vector<float> &channel0,
const std::vector<float> &channel1)
{
olive::core::SampleBuffer buffer(StereoParams(), channel0.size());
olive::core::SampleBuffer buffer(stereo_params(), channel0.size());
for (size_t i = 0; i < channel0.size(); i++) {
buffer.data(0)[i] = channel0[i];
}
@@ -159,30 +159,30 @@ olive::core::SampleBuffer MakeStereoBuffer(const std::vector<float> &channel0,
return buffer;
}
olive::core::SampleBuffer MakeMonoBuffer(const std::vector<float> &samples)
olive::core::SampleBuffer make_mono_buffer(const std::vector<float> &samples)
{
olive::core::SampleBuffer buffer(MonoParams(), samples.size());
olive::core::SampleBuffer buffer(mono_params(), samples.size());
for (size_t i = 0; i < samples.size(); i++) {
buffer.data(0)[i] = samples[i];
}
return buffer;
}
olive::NodeValue SampleValue(const olive::core::SampleBuffer &buffer)
olive::NodeValue sample_value(const olive::core::SampleBuffer &buffer)
{
return olive::NodeValue(olive::NodeValue::kSamples,
return olive::NodeValue(olive::NodeValue::k_samples,
QVariant::fromValue(buffer));
}
// Connects a stereo buffer {1,2,3,4}/{5,6,7,8} to the node's samples input.
ConstantValueNode *ConnectTestSamples(olive::Project *project,
ConstantValueNode *connect_test_samples(olive::Project *project,
olive::Node *node,
const QString &samples_input)
{
ConstantValueNode *samples = AddConstant(
project, SampleValue(MakeStereoBuffer({ 1.0f, 2.0f, 3.0f, 4.0f },
ConstantValueNode *samples = add_constant(
project, sample_value(make_stereo_buffer({ 1.0f, 2.0f, 3.0f, 4.0f },
{ 5.0f, 6.0f, 7.0f, 8.0f })));
olive::Node::ConnectEdge(samples, olive::NodeInput(node, samples_input));
olive::Node::connect_edge(samples, olive::NodeInput(node, samples_input));
return samples;
}
@@ -192,69 +192,69 @@ TEST(PanNode, Metadata)
{
olive::PanNode pan;
EXPECT_EQ(pan.Name(), QStringLiteral("Pan"));
EXPECT_EQ(pan.name(), QStringLiteral("Pan"));
EXPECT_EQ(pan.id(), QStringLiteral("org.olivevideoeditor.Olive.pan"));
EXPECT_FALSE(pan.Description().isEmpty());
EXPECT_TRUE(pan.Category().contains(olive::Node::kCategoryFilter));
EXPECT_FALSE(pan.description().isEmpty());
EXPECT_TRUE(pan.category().contains(olive::Node::k_category_filter));
// Registered as an audio effect with the samples input as effect input
EXPECT_TRUE(pan.GetFlags() & olive::Node::kAudioEffect);
EXPECT_EQ(pan.GetEffectInputID(), olive::PanNode::kSamplesInput);
EXPECT_TRUE(pan.get_flags() & olive::Node::k_audio_effect);
EXPECT_EQ(pan.get_effect_input_id(), olive::PanNode::k_samples_input);
}
TEST(PanNode, InputDefaults)
{
olive::PanNode pan;
EXPECT_EQ(pan.GetInputDataType(olive::PanNode::kSamplesInput),
olive::NodeValue::kSamples);
EXPECT_FALSE(pan.IsInputKeyframable(olive::PanNode::kSamplesInput));
EXPECT_TRUE(pan.IsInputConnectable(olive::PanNode::kSamplesInput));
EXPECT_EQ(pan.get_input_data_type(olive::PanNode::k_samples_input),
olive::NodeValue::k_samples);
EXPECT_FALSE(pan.is_input_keyframable(olive::PanNode::k_samples_input));
EXPECT_TRUE(pan.is_input_connectable(olive::PanNode::k_samples_input));
EXPECT_EQ(pan.GetInputDataType(olive::PanNode::kPanningInput),
olive::NodeValue::kFloat);
EXPECT_TRUE(pan.IsInputKeyframable(olive::PanNode::kPanningInput));
EXPECT_EQ(pan.get_input_data_type(olive::PanNode::k_panning_input),
olive::NodeValue::k_float);
EXPECT_TRUE(pan.is_input_keyframable(olive::PanNode::k_panning_input));
EXPECT_DOUBLE_EQ(
pan.GetStandardValue(olive::PanNode::kPanningInput).toDouble(), 0.0);
EXPECT_DOUBLE_EQ(pan.GetInputProperty(olive::PanNode::kPanningInput,
pan.get_standard_value(olive::PanNode::k_panning_input).toDouble(), 0.0);
EXPECT_DOUBLE_EQ(pan.get_input_property(olive::PanNode::k_panning_input,
QStringLiteral("min"))
.toDouble(),
-1.0);
EXPECT_DOUBLE_EQ(pan.GetInputProperty(olive::PanNode::kPanningInput,
EXPECT_DOUBLE_EQ(pan.get_input_property(olive::PanNode::k_panning_input,
QStringLiteral("max"))
.toDouble(),
1.0);
EXPECT_EQ(int(pan.GetInputProperty(olive::PanNode::kPanningInput,
EXPECT_EQ(int(pan.get_input_property(olive::PanNode::k_panning_input,
QStringLiteral("view"))
.toInt()),
int(olive::FloatSlider::kPercentage));
int(olive::FloatSlider::k_percentage));
}
TEST(PanNode, RetranslateSetsInputNames)
{
olive::PanNode pan;
pan.Retranslate();
pan.retranslate();
EXPECT_EQ(pan.GetInputName(olive::PanNode::kSamplesInput),
EXPECT_EQ(pan.get_input_name(olive::PanNode::k_samples_input),
QStringLiteral("Samples"));
EXPECT_EQ(pan.GetInputName(olive::PanNode::kPanningInput),
EXPECT_EQ(pan.get_input_name(olive::PanNode::k_panning_input),
QStringLiteral("Pan"));
}
TEST(PanNode, StaticCenterPanLeavesSamplesUnchanged)
{
olive::ColorManager::SetUpDefaultConfig();
olive::ColorManager::set_up_default_config();
olive::Project project;
project.Initialize();
project.initialize();
olive::PanNode *pan = AddNode<olive::PanNode>(&project);
ConnectTestSamples(&project, pan, olive::PanNode::kSamplesInput);
olive::PanNode *pan = add_node<olive::PanNode>(&project);
connect_test_samples(&project, pan, olive::PanNode::k_samples_input);
// Pan 0 is a no-op, but the (unmodified) buffer is still pushed
const olive::NodeValueTable table = GenerateTableAt(pan, olive::core::rational(0));
const olive::NodeValueTable table = generate_table_at(pan, olive::core::Rational(0));
const olive::core::SampleBuffer out =
table.Get(olive::NodeValue::kSamples).toSamples();
table.get(olive::NodeValue::k_samples).to_samples();
ASSERT_TRUE(out.is_allocated());
ASSERT_EQ(out.sample_count(), 4u);
for (int i = 0; i < 4; i++) {
@@ -265,17 +265,17 @@ TEST(PanNode, StaticCenterPanLeavesSamplesUnchanged)
TEST(PanNode, StaticRightPanAttenuatesLeftChannel)
{
olive::ColorManager::SetUpDefaultConfig();
olive::ColorManager::set_up_default_config();
olive::Project project;
project.Initialize();
project.initialize();
olive::PanNode *pan = AddNode<olive::PanNode>(&project);
pan->SetStandardValue(olive::PanNode::kPanningInput, 0.5);
ConnectTestSamples(&project, pan, olive::PanNode::kSamplesInput);
olive::PanNode *pan = add_node<olive::PanNode>(&project);
pan->set_standard_value(olive::PanNode::k_panning_input, 0.5);
connect_test_samples(&project, pan, olive::PanNode::k_samples_input);
const olive::NodeValueTable table = GenerateTableAt(pan, olive::core::rational(0));
const olive::NodeValueTable table = generate_table_at(pan, olive::core::Rational(0));
const olive::core::SampleBuffer out =
table.Get(olive::NodeValue::kSamples).toSamples();
table.get(olive::NodeValue::k_samples).to_samples();
ASSERT_TRUE(out.is_allocated());
for (int i = 0; i < 4; i++) {
EXPECT_FLOAT_EQ(out.data(0)[i], float(i + 1) * 0.5f);
@@ -285,17 +285,17 @@ TEST(PanNode, StaticRightPanAttenuatesLeftChannel)
TEST(PanNode, StaticLeftPanAttenuatesRightChannel)
{
olive::ColorManager::SetUpDefaultConfig();
olive::ColorManager::set_up_default_config();
olive::Project project;
project.Initialize();
project.initialize();
olive::PanNode *pan = AddNode<olive::PanNode>(&project);
pan->SetStandardValue(olive::PanNode::kPanningInput, -0.5);
ConnectTestSamples(&project, pan, olive::PanNode::kSamplesInput);
olive::PanNode *pan = add_node<olive::PanNode>(&project);
pan->set_standard_value(olive::PanNode::k_panning_input, -0.5);
connect_test_samples(&project, pan, olive::PanNode::k_samples_input);
const olive::NodeValueTable table = GenerateTableAt(pan, olive::core::rational(0));
const olive::NodeValueTable table = generate_table_at(pan, olive::core::Rational(0));
const olive::core::SampleBuffer out =
table.Get(olive::NodeValue::kSamples).toSamples();
table.get(olive::NodeValue::k_samples).to_samples();
ASSERT_TRUE(out.is_allocated());
for (int i = 0; i < 4; i++) {
EXPECT_FLOAT_EQ(out.data(0)[i], float(i + 1));
@@ -305,17 +305,17 @@ TEST(PanNode, StaticLeftPanAttenuatesRightChannel)
TEST(PanNode, StaticFullRightPanSilencesLeftChannel)
{
olive::ColorManager::SetUpDefaultConfig();
olive::ColorManager::set_up_default_config();
olive::Project project;
project.Initialize();
project.initialize();
olive::PanNode *pan = AddNode<olive::PanNode>(&project);
pan->SetStandardValue(olive::PanNode::kPanningInput, 1.0);
ConnectTestSamples(&project, pan, olive::PanNode::kSamplesInput);
olive::PanNode *pan = add_node<olive::PanNode>(&project);
pan->set_standard_value(olive::PanNode::k_panning_input, 1.0);
connect_test_samples(&project, pan, olive::PanNode::k_samples_input);
const olive::NodeValueTable table = GenerateTableAt(pan, olive::core::rational(0));
const olive::NodeValueTable table = generate_table_at(pan, olive::core::Rational(0));
const olive::core::SampleBuffer out =
table.Get(olive::NodeValue::kSamples).toSamples();
table.get(olive::NodeValue::k_samples).to_samples();
ASSERT_TRUE(out.is_allocated());
for (int i = 0; i < 4; i++) {
EXPECT_FLOAT_EQ(out.data(0)[i], 0.0f);
@@ -325,22 +325,22 @@ TEST(PanNode, StaticFullRightPanSilencesLeftChannel)
TEST(PanNode, NonStereoSamplesPassThroughUnchanged)
{
olive::ColorManager::SetUpDefaultConfig();
olive::ColorManager::set_up_default_config();
olive::Project project;
project.Initialize();
project.initialize();
olive::PanNode *pan = AddNode<olive::PanNode>(&project);
pan->SetStandardValue(olive::PanNode::kPanningInput, 0.5);
olive::PanNode *pan = add_node<olive::PanNode>(&project);
pan->set_standard_value(olive::PanNode::k_panning_input, 0.5);
ConstantValueNode *samples = AddConstant(
&project, SampleValue(MakeMonoBuffer({ 1.0f, -2.0f, 3.0f })));
olive::Node::ConnectEdge(
samples, olive::NodeInput(pan, olive::PanNode::kSamplesInput));
ConstantValueNode *samples = add_constant(
&project, sample_value(make_mono_buffer({ 1.0f, -2.0f, 3.0f })));
olive::Node::connect_edge(
samples, olive::NodeInput(pan, olive::PanNode::k_samples_input));
// Pan only supports stereo: a mono buffer is pushed through untouched
const olive::NodeValueTable table = GenerateTableAt(pan, olive::core::rational(0));
const olive::NodeValueTable table = generate_table_at(pan, olive::core::Rational(0));
const olive::core::SampleBuffer out =
table.Get(olive::NodeValue::kSamples).toSamples();
table.get(olive::NodeValue::k_samples).to_samples();
ASSERT_TRUE(out.is_allocated());
ASSERT_EQ(out.audio_params().channel_count(), 1);
ASSERT_EQ(out.sample_count(), 3u);
@@ -351,50 +351,50 @@ TEST(PanNode, NonStereoSamplesPassThroughUnchanged)
TEST(PanNode, NoSamplesInputProducesNoOutput)
{
olive::ColorManager::SetUpDefaultConfig();
olive::ColorManager::set_up_default_config();
olive::Project project;
project.Initialize();
project.initialize();
olive::PanNode *pan = AddNode<olive::PanNode>(&project);
pan->SetStandardValue(olive::PanNode::kPanningInput, 0.5);
olive::PanNode *pan = add_node<olive::PanNode>(&project);
pan->set_standard_value(olive::PanNode::k_panning_input, 0.5);
// Without an allocated buffer on the samples input, Value() pushes nothing
const olive::NodeValueTable table = GenerateTableAt(pan, olive::core::rational(0));
EXPECT_EQ(table.Get(olive::NodeValue::kSamples).type(),
olive::NodeValue::kNone);
const olive::NodeValueTable table = generate_table_at(pan, olive::core::Rational(0));
EXPECT_EQ(table.get(olive::NodeValue::k_samples).type(),
olive::NodeValue::k_none);
}
TEST(PanNode, KeyframedPanProducesSampleJobWithPanValue)
{
olive::ColorManager::SetUpDefaultConfig();
olive::ColorManager::set_up_default_config();
olive::Project project;
project.Initialize();
project.initialize();
olive::PanNode *pan = AddNode<olive::PanNode>(&project);
ConnectTestSamples(&project, pan, olive::PanNode::kSamplesInput);
olive::PanNode *pan = add_node<olive::PanNode>(&project);
connect_test_samples(&project, pan, olive::PanNode::k_samples_input);
// A non-static (keyframed) pan makes Value() push a SampleJob instead of
// processing the buffer immediately
pan->SetInputIsKeyframing(olive::PanNode::kPanningInput, true);
AddKey(pan, olive::PanNode::kPanningInput, olive::core::rational(0), 1.0);
pan->set_input_is_keyframing(olive::PanNode::k_panning_input, true);
add_key(pan, olive::PanNode::k_panning_input, olive::core::Rational(0), 1.0);
const olive::NodeValueTable table = GenerateTableAt(pan, olive::core::rational(0));
olive::NodeValue result = table.Get(olive::NodeValue::kSamples);
ASSERT_EQ(result.type(), olive::NodeValue::kSamples);
const olive::NodeValueTable table = generate_table_at(pan, olive::core::Rational(0));
olive::NodeValue result = table.get(olive::NodeValue::k_samples);
ASSERT_EQ(result.type(), olive::NodeValue::k_samples);
ASSERT_TRUE(result.canConvert<olive::SampleJob>());
// Like VolumeNode, PanNode::Value() inserts the panning value into the
// SampleJob so ProcessSamples() sees the keyframed pan
const olive::SampleJob job = result.value<olive::SampleJob>();
ASSERT_TRUE(job.GetValues().contains(olive::PanNode::kPanningInput));
EXPECT_DOUBLE_EQ(job.GetValues().value(olive::PanNode::kPanningInput).toDouble(),
ASSERT_TRUE(job.get_values().contains(olive::PanNode::k_panning_input));
EXPECT_DOUBLE_EQ(job.get_values().value(olive::PanNode::k_panning_input).to_double(),
1.0);
SampleResolvingTraverser resolver;
resolver.Resolve(result);
resolver.resolve(result);
// Pan 1.0 (full right) silences the left channel and leaves the right
const olive::core::SampleBuffer out = result.toSamples();
const olive::core::SampleBuffer out = result.to_samples();
ASSERT_TRUE(out.is_allocated());
ASSERT_EQ(out.sample_count(), 4u);
for (int i = 0; i < 4; i++) {
@@ -408,18 +408,18 @@ TEST(PanNode, ProcessSamplesAppliesPanPerSample)
olive::PanNode pan;
olive::NodeValueRow row;
row.insert(olive::PanNode::kPanningInput,
olive::NodeValue(olive::NodeValue::kFloat, 0.5));
row.insert(olive::PanNode::k_panning_input,
olive::NodeValue(olive::NodeValue::k_float, 0.5));
olive::core::SampleBuffer input(StereoParams(), 2);
olive::core::SampleBuffer output(StereoParams(), 2);
olive::core::SampleBuffer input(stereo_params(), 2);
olive::core::SampleBuffer output(stereo_params(), 2);
input.data(0)[0] = 1.5f;
input.data(0)[1] = -2.0f;
input.data(1)[0] = 0.25f;
input.data(1)[1] = 8.0f;
pan.ProcessSamples(row, input, output, 0);
pan.ProcessSamples(row, input, output, 1);
pan.process_samples(row, input, output, 0);
pan.process_samples(row, input, output, 1);
// Panning right attenuates the left channel only
EXPECT_FLOAT_EQ(output.data(0)[0], 0.75f);
@@ -428,9 +428,9 @@ TEST(PanNode, ProcessSamplesAppliesPanPerSample)
EXPECT_FLOAT_EQ(output.data(1)[1], 8.0f);
// Panning left attenuates the right channel only
row.insert(olive::PanNode::kPanningInput,
olive::NodeValue(olive::NodeValue::kFloat, -0.25));
pan.ProcessSamples(row, input, output, 0);
row.insert(olive::PanNode::k_panning_input,
olive::NodeValue(olive::NodeValue::k_float, -0.25));
pan.process_samples(row, input, output, 0);
EXPECT_FLOAT_EQ(output.data(0)[0], 1.5f);
EXPECT_FLOAT_EQ(output.data(1)[0], 0.1875f);
@@ -443,12 +443,12 @@ TEST(PanNode, ProcessSamplesWithoutPanValueCopiesInput)
// No panning value in the row: samples are copied unchanged
olive::NodeValueRow row;
olive::core::SampleBuffer input(StereoParams(), 1);
olive::core::SampleBuffer output(StereoParams(), 1);
olive::core::SampleBuffer input(stereo_params(), 1);
olive::core::SampleBuffer output(stereo_params(), 1);
input.data(0)[0] = 3.0f;
input.data(1)[0] = -4.0f;
pan.ProcessSamples(row, input, output, 0);
pan.process_samples(row, input, output, 0);
EXPECT_FLOAT_EQ(output.data(0)[0], 3.0f);
EXPECT_FLOAT_EQ(output.data(1)[0], -4.0f);
@@ -458,65 +458,65 @@ TEST(VolumeNode, Metadata)
{
olive::VolumeNode volume;
EXPECT_EQ(volume.Name(), QStringLiteral("Volume"));
EXPECT_EQ(volume.name(), QStringLiteral("Volume"));
EXPECT_EQ(volume.id(),
QStringLiteral("org.olivevideoeditor.Olive.volume"));
EXPECT_FALSE(volume.Description().isEmpty());
EXPECT_TRUE(volume.Category().contains(olive::Node::kCategoryFilter));
EXPECT_FALSE(volume.description().isEmpty());
EXPECT_TRUE(volume.category().contains(olive::Node::k_category_filter));
EXPECT_TRUE(volume.GetFlags() & olive::Node::kAudioEffect);
EXPECT_EQ(volume.GetEffectInputID(), olive::VolumeNode::kSamplesInput);
EXPECT_TRUE(volume.get_flags() & olive::Node::k_audio_effect);
EXPECT_EQ(volume.get_effect_input_id(), olive::VolumeNode::k_samples_input);
}
TEST(VolumeNode, InputDefaults)
{
olive::VolumeNode volume;
EXPECT_EQ(volume.GetInputDataType(olive::VolumeNode::kSamplesInput),
olive::NodeValue::kSamples);
EXPECT_FALSE(volume.IsInputKeyframable(olive::VolumeNode::kSamplesInput));
EXPECT_EQ(volume.get_input_data_type(olive::VolumeNode::k_samples_input),
olive::NodeValue::k_samples);
EXPECT_FALSE(volume.is_input_keyframable(olive::VolumeNode::k_samples_input));
EXPECT_EQ(volume.GetInputDataType(olive::VolumeNode::kVolumeInput),
olive::NodeValue::kFloat);
EXPECT_TRUE(volume.IsInputKeyframable(olive::VolumeNode::kVolumeInput));
EXPECT_EQ(volume.get_input_data_type(olive::VolumeNode::k_volume_input),
olive::NodeValue::k_float);
EXPECT_TRUE(volume.is_input_keyframable(olive::VolumeNode::k_volume_input));
EXPECT_DOUBLE_EQ(
volume.GetStandardValue(olive::VolumeNode::kVolumeInput).toDouble(),
volume.get_standard_value(olive::VolumeNode::k_volume_input).toDouble(),
1.0);
EXPECT_DOUBLE_EQ(volume.GetInputProperty(olive::VolumeNode::kVolumeInput,
EXPECT_DOUBLE_EQ(volume.get_input_property(olive::VolumeNode::k_volume_input,
QStringLiteral("min"))
.toDouble(),
0.0);
EXPECT_EQ(int(volume.GetInputProperty(olive::VolumeNode::kVolumeInput,
EXPECT_EQ(int(volume.get_input_property(olive::VolumeNode::k_volume_input,
QStringLiteral("view"))
.toInt()),
int(olive::FloatSlider::kDecibel));
int(olive::FloatSlider::k_decibel));
}
TEST(VolumeNode, RetranslateSetsInputNames)
{
olive::VolumeNode volume;
volume.Retranslate();
volume.retranslate();
EXPECT_EQ(volume.GetInputName(olive::VolumeNode::kSamplesInput),
EXPECT_EQ(volume.get_input_name(olive::VolumeNode::k_samples_input),
QStringLiteral("Samples"));
EXPECT_EQ(volume.GetInputName(olive::VolumeNode::kVolumeInput),
EXPECT_EQ(volume.get_input_name(olive::VolumeNode::k_volume_input),
QStringLiteral("Volume"));
}
TEST(VolumeNode, StaticVolumeScalesSamples)
{
olive::ColorManager::SetUpDefaultConfig();
olive::ColorManager::set_up_default_config();
olive::Project project;
project.Initialize();
project.initialize();
olive::VolumeNode *volume = AddNode<olive::VolumeNode>(&project);
volume->SetStandardValue(olive::VolumeNode::kVolumeInput, 2.0);
ConnectTestSamples(&project, volume, olive::VolumeNode::kSamplesInput);
olive::VolumeNode *volume = add_node<olive::VolumeNode>(&project);
volume->set_standard_value(olive::VolumeNode::k_volume_input, 2.0);
connect_test_samples(&project, volume, olive::VolumeNode::k_samples_input);
const olive::NodeValueTable table = GenerateTableAt(volume, olive::core::rational(0));
const olive::NodeValueTable table = generate_table_at(volume, olive::core::Rational(0));
const olive::core::SampleBuffer out =
table.Get(olive::NodeValue::kSamples).toSamples();
table.get(olive::NodeValue::k_samples).to_samples();
ASSERT_TRUE(out.is_allocated());
ASSERT_EQ(out.sample_count(), 4u);
for (int i = 0; i < 4; i++) {
@@ -527,18 +527,18 @@ TEST(VolumeNode, StaticVolumeScalesSamples)
TEST(VolumeNode, StaticUnityVolumeLeavesSamplesUnchanged)
{
olive::ColorManager::SetUpDefaultConfig();
olive::ColorManager::set_up_default_config();
olive::Project project;
project.Initialize();
project.initialize();
olive::VolumeNode *volume = AddNode<olive::VolumeNode>(&project);
volume->SetStandardValue(olive::VolumeNode::kVolumeInput, 1.0);
ConnectTestSamples(&project, volume, olive::VolumeNode::kSamplesInput);
olive::VolumeNode *volume = add_node<olive::VolumeNode>(&project);
volume->set_standard_value(olive::VolumeNode::k_volume_input, 1.0);
connect_test_samples(&project, volume, olive::VolumeNode::k_samples_input);
// Volume 1 is a no-op, but the (unmodified) buffer is still pushed
const olive::NodeValueTable table = GenerateTableAt(volume, olive::core::rational(0));
const olive::NodeValueTable table = generate_table_at(volume, olive::core::Rational(0));
const olive::core::SampleBuffer out =
table.Get(olive::NodeValue::kSamples).toSamples();
table.get(olive::NodeValue::k_samples).to_samples();
ASSERT_TRUE(out.is_allocated());
for (int i = 0; i < 4; i++) {
EXPECT_FLOAT_EQ(out.data(0)[i], float(i + 1));
@@ -548,17 +548,17 @@ TEST(VolumeNode, StaticUnityVolumeLeavesSamplesUnchanged)
TEST(VolumeNode, StaticZeroVolumeSilencesSamples)
{
olive::ColorManager::SetUpDefaultConfig();
olive::ColorManager::set_up_default_config();
olive::Project project;
project.Initialize();
project.initialize();
olive::VolumeNode *volume = AddNode<olive::VolumeNode>(&project);
volume->SetStandardValue(olive::VolumeNode::kVolumeInput, 0.0);
ConnectTestSamples(&project, volume, olive::VolumeNode::kSamplesInput);
olive::VolumeNode *volume = add_node<olive::VolumeNode>(&project);
volume->set_standard_value(olive::VolumeNode::k_volume_input, 0.0);
connect_test_samples(&project, volume, olive::VolumeNode::k_samples_input);
const olive::NodeValueTable table = GenerateTableAt(volume, olive::core::rational(0));
const olive::NodeValueTable table = generate_table_at(volume, olive::core::Rational(0));
const olive::core::SampleBuffer out =
table.Get(olive::NodeValue::kSamples).toSamples();
table.get(olive::NodeValue::k_samples).to_samples();
ASSERT_TRUE(out.is_allocated());
for (int i = 0; i < 4; i++) {
EXPECT_FLOAT_EQ(out.data(0)[i], 0.0f);
@@ -568,36 +568,36 @@ TEST(VolumeNode, StaticZeroVolumeSilencesSamples)
TEST(VolumeNode, KeyframedVolumeProducesSampleJobWithInterpolatedValue)
{
olive::ColorManager::SetUpDefaultConfig();
olive::ColorManager::set_up_default_config();
olive::Project project;
project.Initialize();
project.initialize();
olive::VolumeNode *volume = AddNode<olive::VolumeNode>(&project);
ConnectTestSamples(&project, volume, olive::VolumeNode::kSamplesInput);
olive::VolumeNode *volume = add_node<olive::VolumeNode>(&project);
connect_test_samples(&project, volume, olive::VolumeNode::k_samples_input);
// A non-static (keyframed) volume makes Value() push a SampleJob carrying
// the volume value instead of processing the buffer immediately
volume->SetInputIsKeyframing(olive::VolumeNode::kVolumeInput, true);
AddKey(volume, olive::VolumeNode::kVolumeInput, olive::core::rational(0),
volume->set_input_is_keyframing(olive::VolumeNode::k_volume_input, true);
add_key(volume, olive::VolumeNode::k_volume_input, olive::core::Rational(0),
1.0);
AddKey(volume, olive::VolumeNode::kVolumeInput, olive::core::rational(1),
add_key(volume, olive::VolumeNode::k_volume_input, olive::core::Rational(1),
3.0);
// At t=0.5 the linear ramp 1.0 -> 3.0 interpolates to 2.0
const olive::NodeValueTable table = GenerateTableAt(volume, olive::core::rational(1, 2));
olive::NodeValue result = table.Get(olive::NodeValue::kSamples);
ASSERT_EQ(result.type(), olive::NodeValue::kSamples);
const olive::NodeValueTable table = generate_table_at(volume, olive::core::Rational(1, 2));
olive::NodeValue result = table.get(olive::NodeValue::k_samples);
ASSERT_EQ(result.type(), olive::NodeValue::k_samples);
ASSERT_TRUE(result.canConvert<olive::SampleJob>());
const olive::SampleJob job = result.value<olive::SampleJob>();
ASSERT_TRUE(job.GetValues().contains(olive::VolumeNode::kVolumeInput));
EXPECT_DOUBLE_EQ(job.Get(olive::VolumeNode::kVolumeInput).toDouble(), 2.0);
ASSERT_TRUE(job.get_values().contains(olive::VolumeNode::k_volume_input));
EXPECT_DOUBLE_EQ(job.get(olive::VolumeNode::k_volume_input).to_double(), 2.0);
// Resolve the job on the CPU and verify the scaled samples
SampleResolvingTraverser resolver;
resolver.Resolve(result);
resolver.resolve(result);
const olive::core::SampleBuffer out = result.toSamples();
const olive::core::SampleBuffer out = result.to_samples();
ASSERT_TRUE(out.is_allocated());
ASSERT_EQ(out.sample_count(), 4u);
for (int i = 0; i < 4; i++) {
@@ -611,18 +611,18 @@ TEST(VolumeNode, ProcessSamplesMultipliesPerSample)
olive::VolumeNode volume;
olive::NodeValueRow row;
row.insert(olive::VolumeNode::kVolumeInput,
olive::NodeValue(olive::NodeValue::kFloat, 2.0));
row.insert(olive::VolumeNode::k_volume_input,
olive::NodeValue(olive::NodeValue::k_float, 2.0));
olive::core::SampleBuffer input(StereoParams(), 2);
olive::core::SampleBuffer output(StereoParams(), 2);
olive::core::SampleBuffer input(stereo_params(), 2);
olive::core::SampleBuffer output(stereo_params(), 2);
input.data(0)[0] = 1.5f;
input.data(0)[1] = -2.0f;
input.data(1)[0] = 0.25f;
input.data(1)[1] = 8.0f;
volume.ProcessSamples(row, input, output, 0);
volume.ProcessSamples(row, input, output, 1);
volume.process_samples(row, input, output, 0);
volume.process_samples(row, input, output, 1);
EXPECT_FLOAT_EQ(output.data(0)[0], 3.0f);
EXPECT_FLOAT_EQ(output.data(0)[1], -4.0f);
@@ -638,13 +638,13 @@ TEST(VolumeNode, ProcessSamplesWithoutVolumeLeavesOutputUntouched)
// must not be written
olive::NodeValueRow row;
olive::core::SampleBuffer input(StereoParams(), 1);
olive::core::SampleBuffer output(StereoParams(), 1);
olive::core::SampleBuffer input(stereo_params(), 1);
olive::core::SampleBuffer output(stereo_params(), 1);
input.data(0)[0] = 10.0f;
output.data(0)[0] = 123.0f;
output.data(1)[0] = 45.0f;
volume.ProcessSamples(row, input, output, 0);
volume.process_samples(row, input, output, 0);
EXPECT_FLOAT_EQ(output.data(0)[0], 123.0f);
EXPECT_FLOAT_EQ(output.data(1)[0], 45.0f);
@@ -654,72 +654,72 @@ TEST(TimeInput, Metadata)
{
olive::TimeInput time;
EXPECT_EQ(time.Name(), QStringLiteral("Time"));
EXPECT_EQ(time.name(), QStringLiteral("Time"));
EXPECT_EQ(time.id(), QStringLiteral("org.olivevideoeditor.Olive.time"));
EXPECT_FALSE(time.Description().isEmpty());
EXPECT_TRUE(time.Category().contains(olive::Node::kCategoryTime));
EXPECT_FALSE(time.description().isEmpty());
EXPECT_TRUE(time.category().contains(olive::Node::k_category_time));
}
TEST(TimeInput, ValuePushesCurrentTimeInSeconds)
{
olive::ColorManager::SetUpDefaultConfig();
olive::ColorManager::set_up_default_config();
olive::Project project;
project.Initialize();
project.initialize();
olive::TimeInput *time = AddNode<olive::TimeInput>(&project);
olive::TimeInput *time = add_node<olive::TimeInput>(&project);
olive::NodeValueTable table = GenerateTableAt(time, olive::core::rational(0));
olive::NodeValue result = table.Get(olive::NodeValue::kFloat);
ASSERT_EQ(result.type(), olive::NodeValue::kFloat);
EXPECT_DOUBLE_EQ(result.toDouble(), 0.0);
olive::NodeValueTable table = generate_table_at(time, olive::core::Rational(0));
olive::NodeValue result = table.get(olive::NodeValue::k_float);
ASSERT_EQ(result.type(), olive::NodeValue::k_float);
EXPECT_DOUBLE_EQ(result.to_double(), 0.0);
table = GenerateTableAt(time, olive::core::rational(5, 2));
result = table.Get(olive::NodeValue::kFloat);
ASSERT_EQ(result.type(), olive::NodeValue::kFloat);
EXPECT_DOUBLE_EQ(result.toDouble(), 2.5);
table = generate_table_at(time, olive::core::Rational(5, 2));
result = table.get(olive::NodeValue::k_float);
ASSERT_EQ(result.type(), olive::NodeValue::k_float);
EXPECT_DOUBLE_EQ(result.to_double(), 2.5);
}
TEST(ValueNode, Metadata)
{
olive::ValueNode value;
EXPECT_EQ(value.Name(), QStringLiteral("Value"));
EXPECT_EQ(value.name(), QStringLiteral("Value"));
EXPECT_EQ(value.id(), QStringLiteral("org.olivevideoeditor.Olive.value"));
EXPECT_FALSE(value.Description().isEmpty());
EXPECT_TRUE(value.Category().contains(olive::Node::kCategoryGenerator));
EXPECT_FALSE(value.description().isEmpty());
EXPECT_TRUE(value.category().contains(olive::Node::k_category_generator));
}
TEST(ValueNode, InputDefaults)
{
olive::ValueNode value;
EXPECT_EQ(value.GetInputDataType(olive::ValueNode::kTypeInput),
olive::NodeValue::kCombo);
EXPECT_FALSE(value.IsInputConnectable(olive::ValueNode::kTypeInput));
EXPECT_FALSE(value.IsInputKeyframable(olive::ValueNode::kTypeInput));
EXPECT_EQ(value.GetStandardValue(olive::ValueNode::kTypeInput).toInt(), 0);
EXPECT_EQ(value.get_input_data_type(olive::ValueNode::k_type_input),
olive::NodeValue::k_combo);
EXPECT_FALSE(value.is_input_connectable(olive::ValueNode::k_type_input));
EXPECT_FALSE(value.is_input_keyframable(olive::ValueNode::k_type_input));
EXPECT_EQ(value.get_standard_value(olive::ValueNode::k_type_input).toInt(), 0);
// The value input starts out as a float (the first supported type)
EXPECT_EQ(value.GetInputDataType(olive::ValueNode::kValueInput),
olive::NodeValue::kFloat);
EXPECT_FALSE(value.IsInputConnectable(olive::ValueNode::kValueInput));
EXPECT_TRUE(value.IsInputKeyframable(olive::ValueNode::kValueInput));
EXPECT_EQ(value.get_input_data_type(olive::ValueNode::k_value_input),
olive::NodeValue::k_float);
EXPECT_FALSE(value.is_input_connectable(olive::ValueNode::k_value_input));
EXPECT_TRUE(value.is_input_keyframable(olive::ValueNode::k_value_input));
}
TEST(ValueNode, RetranslateSetsInputNamesAndTypeCombo)
{
olive::ValueNode value;
value.Retranslate();
value.retranslate();
EXPECT_EQ(value.GetInputName(olive::ValueNode::kTypeInput),
EXPECT_EQ(value.get_input_name(olive::ValueNode::k_type_input),
QStringLiteral("Type"));
EXPECT_EQ(value.GetInputName(olive::ValueNode::kValueInput),
EXPECT_EQ(value.get_input_name(olive::ValueNode::k_value_input),
QStringLiteral("Value"));
// The type combo lists the pretty name of every supported type, in order
const QStringList types =
value.GetInputProperty(olive::ValueNode::kTypeInput,
value.get_input_property(olive::ValueNode::k_type_input,
QStringLiteral("combo_str"))
.toStringList();
ASSERT_EQ(types.size(), 11);
@@ -740,62 +740,62 @@ TEST(ValueNode, ChangingTypeSwitchesValueInputDataType)
{
olive::ValueNode value;
EXPECT_EQ(value.GetInputDataType(olive::ValueNode::kValueInput),
olive::NodeValue::kFloat);
EXPECT_EQ(value.get_input_data_type(olive::ValueNode::k_value_input),
olive::NodeValue::k_float);
value.SetStandardValue(olive::ValueNode::kTypeInput, 1);
EXPECT_EQ(value.GetInputDataType(olive::ValueNode::kValueInput),
olive::NodeValue::kInt);
value.set_standard_value(olive::ValueNode::k_type_input, 1);
EXPECT_EQ(value.get_input_data_type(olive::ValueNode::k_value_input),
olive::NodeValue::k_int);
value.SetStandardValue(olive::ValueNode::kTypeInput, 3);
EXPECT_EQ(value.GetInputDataType(olive::ValueNode::kValueInput),
olive::NodeValue::kVec2);
value.set_standard_value(olive::ValueNode::k_type_input, 3);
EXPECT_EQ(value.get_input_data_type(olive::ValueNode::k_value_input),
olive::NodeValue::k_vec2);
value.SetStandardValue(olive::ValueNode::kTypeInput, 6);
EXPECT_EQ(value.GetInputDataType(olive::ValueNode::kValueInput),
olive::NodeValue::kColor);
value.set_standard_value(olive::ValueNode::k_type_input, 6);
EXPECT_EQ(value.get_input_data_type(olive::ValueNode::k_value_input),
olive::NodeValue::k_color);
value.SetStandardValue(olive::ValueNode::kTypeInput, 10);
EXPECT_EQ(value.GetInputDataType(olive::ValueNode::kValueInput),
olive::NodeValue::kBoolean);
value.set_standard_value(olive::ValueNode::k_type_input, 10);
EXPECT_EQ(value.get_input_data_type(olive::ValueNode::k_value_input),
olive::NodeValue::k_boolean);
value.SetStandardValue(olive::ValueNode::kTypeInput, 0);
EXPECT_EQ(value.GetInputDataType(olive::ValueNode::kValueInput),
olive::NodeValue::kFloat);
value.set_standard_value(olive::ValueNode::k_type_input, 0);
EXPECT_EQ(value.get_input_data_type(olive::ValueNode::k_value_input),
olive::NodeValue::k_float);
}
TEST(ValueNode, ValuePassesThroughFloat)
{
olive::ColorManager::SetUpDefaultConfig();
olive::ColorManager::set_up_default_config();
olive::Project project;
project.Initialize();
project.initialize();
olive::ValueNode *value = AddNode<olive::ValueNode>(&project);
value->SetStandardValue(olive::ValueNode::kValueInput, 3.5);
olive::ValueNode *value = add_node<olive::ValueNode>(&project);
value->set_standard_value(olive::ValueNode::k_value_input, 3.5);
const olive::NodeValueTable table = GenerateTableAt(value, olive::core::rational(0));
const olive::NodeValue result = table.Get(olive::NodeValue::kFloat);
ASSERT_EQ(result.type(), olive::NodeValue::kFloat);
EXPECT_DOUBLE_EQ(result.toDouble(), 3.5);
const olive::NodeValueTable table = generate_table_at(value, olive::core::Rational(0));
const olive::NodeValue result = table.get(olive::NodeValue::k_float);
ASSERT_EQ(result.type(), olive::NodeValue::k_float);
EXPECT_DOUBLE_EQ(result.to_double(), 3.5);
}
TEST(ValueNode, ValuePassesThroughVectorAfterTypeSwitch)
{
olive::ColorManager::SetUpDefaultConfig();
olive::ColorManager::set_up_default_config();
olive::Project project;
project.Initialize();
project.initialize();
olive::ValueNode *value = AddNode<olive::ValueNode>(&project);
olive::ValueNode *value = add_node<olive::ValueNode>(&project);
// Switch the value input to kVec3 (index 4) and set a vector value
value->SetStandardValue(olive::ValueNode::kTypeInput, 4);
value->SetStandardValue(olive::ValueNode::kValueInput,
value->set_standard_value(olive::ValueNode::k_type_input, 4);
value->set_standard_value(olive::ValueNode::k_value_input,
QVector3D(1.0f, 2.0f, 3.0f));
const olive::NodeValueTable table = GenerateTableAt(value, olive::core::rational(0));
const olive::NodeValue result = table.Get(olive::NodeValue::kVec3);
ASSERT_EQ(result.type(), olive::NodeValue::kVec3);
const QVector3D vec = result.toVec3();
const olive::NodeValueTable table = generate_table_at(value, olive::core::Rational(0));
const olive::NodeValue result = table.get(olive::NodeValue::k_vec3);
ASSERT_EQ(result.type(), olive::NodeValue::k_vec3);
const QVector3D vec = result.to_vec3();
EXPECT_FLOAT_EQ(vec.x(), 1.0f);
EXPECT_FLOAT_EQ(vec.y(), 2.0f);
EXPECT_FLOAT_EQ(vec.z(), 3.0f);