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:
@@ -60,13 +60,13 @@ using namespace olive;
|
||||
namespace
|
||||
{
|
||||
|
||||
QString DemoVideoPath()
|
||||
QString demo_video_path()
|
||||
{
|
||||
return QDir(QStringLiteral(OAK_TEST_SOURCE_DIR))
|
||||
.filePath(QStringLiteral("tests/demo.mp4"));
|
||||
}
|
||||
|
||||
QString WorkerBinaryPath()
|
||||
QString worker_binary_path()
|
||||
{
|
||||
// The test binary lives in cmake-build-debug/tests/gtest; the worker is in
|
||||
// cmake-build-debug/app.
|
||||
@@ -81,30 +81,30 @@ QString WorkerBinaryPath()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IsRenderBackendAvailable(const QString &backend)
|
||||
bool is_render_backend_available(const QString &backend)
|
||||
{
|
||||
#ifdef OAK_ENABLE_DYNAMIC_RENDER_BACKEND
|
||||
olive::DynamicRenderer renderer(backend);
|
||||
if (!renderer.Load()) {
|
||||
if (!renderer.load()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
OakRenderBackendInfo info = {};
|
||||
if (!renderer.GetBackendInfo(&info)) {
|
||||
if (!renderer.get_backend_info(&info)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (backend == QStringLiteral("vulkan") &&
|
||||
info.kind != OAK_RENDER_BACKEND_VULKAN) {
|
||||
info.kind != oak_render_backend_vulkan) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (backend == QStringLiteral("opengl") &&
|
||||
info.kind != OAK_RENDER_BACKEND_OPENGL) {
|
||||
info.kind != oak_render_backend_opengl) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return renderer.Init();
|
||||
return renderer.init();
|
||||
#else
|
||||
Q_UNUSED(backend)
|
||||
return false;
|
||||
@@ -113,7 +113,7 @@ bool IsRenderBackendAvailable(const QString &backend)
|
||||
|
||||
// Returns the number of non-zero bytes sampled from the frame buffer, or -1
|
||||
// when the frame is invalid.
|
||||
int CountNonZeroBytes(const FramePtr &frame)
|
||||
int count_non_zero_bytes(const FramePtr &frame)
|
||||
{
|
||||
if (!frame || !frame->is_allocated()) {
|
||||
return -1;
|
||||
@@ -141,17 +141,17 @@ protected:
|
||||
{
|
||||
// Mirror Core::Start()'s singleton initialization order (RenderManager
|
||||
// is created per-test instead, so that each backend gets a fresh one).
|
||||
NodeFactory::Initialize();
|
||||
ColorManager::SetUpDefaultConfig();
|
||||
TaskManager::CreateInstance();
|
||||
ConformManager::CreateInstance();
|
||||
ProxyManager::CreateInstance();
|
||||
FrameManager::CreateInstance();
|
||||
ProjectSerializer::Initialize();
|
||||
DiskManager::CreateInstance();
|
||||
NodeFactory::initialize();
|
||||
ColorManager::set_up_default_config();
|
||||
TaskManager::create_instance();
|
||||
ConformManager::create_instance();
|
||||
ProxyManager::create_instance();
|
||||
FrameManager::create_instance();
|
||||
ProjectSerializer::initialize();
|
||||
DiskManager::create_instance();
|
||||
|
||||
// Point the worker pool at the built worker binary.
|
||||
const QString worker = WorkerBinaryPath();
|
||||
const QString worker = worker_binary_path();
|
||||
if (QFileInfo::exists(worker)) {
|
||||
qputenv("OAK_RENDER_WORKER", QFile::encodeName(worker));
|
||||
}
|
||||
@@ -159,58 +159,58 @@ protected:
|
||||
|
||||
static void TearDownTestSuite()
|
||||
{
|
||||
DiskManager::DestroyInstance();
|
||||
ProjectSerializer::Destroy();
|
||||
FrameManager::DestroyInstance();
|
||||
ProxyManager::DestroyInstance();
|
||||
ConformManager::DestroyInstance();
|
||||
TaskManager::DestroyInstance();
|
||||
NodeFactory::Destroy();
|
||||
DiskManager::destroy_instance();
|
||||
ProjectSerializer::destroy();
|
||||
FrameManager::destroy_instance();
|
||||
ProxyManager::destroy_instance();
|
||||
ConformManager::destroy_instance();
|
||||
TaskManager::destroy_instance();
|
||||
NodeFactory::destroy();
|
||||
}
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
backend_ = GetParam();
|
||||
if (!IsRenderBackendAvailable(backend_)) {
|
||||
if (!is_render_backend_available(backend_)) {
|
||||
GTEST_SKIP() << "Render backend is not available: "
|
||||
<< backend_.toStdString();
|
||||
}
|
||||
|
||||
const QString worker = WorkerBinaryPath();
|
||||
const QString worker = worker_binary_path();
|
||||
if (!QFileInfo::exists(worker)) {
|
||||
GTEST_SKIP() << "worker binary not found at "
|
||||
<< worker.toStdString();
|
||||
}
|
||||
|
||||
demo_path_ = DemoVideoPath();
|
||||
demo_path_ = demo_video_path();
|
||||
ASSERT_TRUE(QFileInfo::exists(demo_path_));
|
||||
|
||||
Config::Current()[QStringLiteral("GraphicsBackend")] = backend_;
|
||||
Config::current()[QStringLiteral("GraphicsBackend")] = backend_;
|
||||
|
||||
project_ = std::make_unique<Project>();
|
||||
project_->Initialize();
|
||||
project_->initialize();
|
||||
|
||||
footage_ = new Footage(demo_path_);
|
||||
footage_->setParent(project_.get());
|
||||
ASSERT_TRUE(footage_->IsValid())
|
||||
ASSERT_TRUE(footage_->is_valid())
|
||||
<< "Footage failed to probe " << demo_path_.toStdString();
|
||||
// The bug requires the footage to provide both a video and an audio
|
||||
// stream, so that the video texture is not the last value in the
|
||||
// footage's table.
|
||||
ASSERT_GE(footage_->GetVideoStreamCount(), 1);
|
||||
ASSERT_GE(footage_->GetAudioStreamCount(), 1)
|
||||
ASSERT_GE(footage_->get_video_stream_count(), 1);
|
||||
ASSERT_GE(footage_->get_audio_stream_count(), 1)
|
||||
<< "Test footage must contain an audio stream";
|
||||
|
||||
RenderManager::CreateInstance();
|
||||
RenderManager::instance()->GetCacher()->SetProject(project_.get());
|
||||
RenderManager::create_instance();
|
||||
RenderManager::instance()->get_cacher()->set_project(project_.get());
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
// May be null when SetUp() skipped before creating the instance.
|
||||
if (RenderManager::instance()) {
|
||||
RenderManager::instance()->GetCacher()->SetProject(nullptr);
|
||||
RenderManager::DestroyInstance();
|
||||
RenderManager::instance()->get_cacher()->set_project(nullptr);
|
||||
RenderManager::destroy_instance();
|
||||
}
|
||||
project_.reset();
|
||||
}
|
||||
@@ -218,66 +218,66 @@ protected:
|
||||
// Builds sequence <- track <- clip <- (optional effect) <- footage and
|
||||
// returns the clip. When insert_effect is false the footage is connected
|
||||
// directly to the clip's buffer input, which is the black-screen case.
|
||||
ClipBlock *BuildVideoClipChain(bool insert_effect)
|
||||
ClipBlock *build_video_clip_chain(bool insert_effect)
|
||||
{
|
||||
sequence_ = new Sequence();
|
||||
sequence_->setParent(project_.get());
|
||||
sequence_->SetVideoParams(VideoParams(
|
||||
1920, 1080, rational(25),
|
||||
sequence_->set_video_params(VideoParams(
|
||||
1920, 1080, Rational(25),
|
||||
static_cast<PixelFormat::Format>(
|
||||
Config::Current()[QStringLiteral("OfflinePixelFormat")]
|
||||
Config::current()[QStringLiteral("OfflinePixelFormat")]
|
||||
.toInt()),
|
||||
VideoParams::kInternalChannelCount, rational(1),
|
||||
VideoParams::kInterlaceNone, 1));
|
||||
sequence_->SetAudioParams(olive::core::AudioParams(
|
||||
48000, olive::core::kChannelLayoutStereo,
|
||||
olive::core::SampleFormat::F32P));
|
||||
VideoParams::k_internal_channel_count, Rational(1),
|
||||
VideoParams::k_interlace_none, 1));
|
||||
sequence_->set_audio_params(olive::core::AudioParams(
|
||||
48000, olive::core::k_channel_layout_stereo,
|
||||
olive::core::SampleFormat::f32_p));
|
||||
|
||||
Track *track = new Track();
|
||||
track->setParent(project_.get());
|
||||
video_track_ = track;
|
||||
ClipBlock *clip = new ClipBlock();
|
||||
clip->setParent(project_.get());
|
||||
clip->set_length_and_media_out(footage_->GetLength());
|
||||
clip->set_length_and_media_out(footage_->get_length());
|
||||
|
||||
Node *buffer_source = footage_;
|
||||
if (insert_effect) {
|
||||
OpacityEffect *opacity = new OpacityEffect();
|
||||
opacity->setParent(project_.get());
|
||||
Node::ConnectEdge(footage_,
|
||||
NodeInput(opacity, OpacityEffect::kTextureInput));
|
||||
Node::connect_edge(footage_,
|
||||
NodeInput(opacity, OpacityEffect::k_texture_input));
|
||||
buffer_source = opacity;
|
||||
}
|
||||
Node::ConnectEdge(buffer_source,
|
||||
NodeInput(clip, ClipBlock::kBufferIn));
|
||||
Node::connect_edge(buffer_source,
|
||||
NodeInput(clip, ClipBlock::k_buffer_in));
|
||||
|
||||
track->AppendBlock(clip);
|
||||
track->append_block(clip);
|
||||
|
||||
// Wire the track into the sequence's video track list (this is what
|
||||
// assigns the track its type) and into the sequence's texture output.
|
||||
TrackList *track_list = sequence_->track_list(Track::kVideo);
|
||||
track_list->ArrayAppend();
|
||||
Node::ConnectEdge(
|
||||
track, track_list->track_input(track_list->ArraySize() - 1));
|
||||
Node::ConnectEdge(track,
|
||||
NodeInput(sequence_, ViewerOutput::kTextureInput));
|
||||
TrackList *track_list = sequence_->track_list(Track::k_video);
|
||||
track_list->array_append();
|
||||
Node::connect_edge(
|
||||
track, track_list->track_input(track_list->array_size() - 1));
|
||||
Node::connect_edge(track,
|
||||
NodeInput(sequence_, ViewerOutput::k_texture_input));
|
||||
|
||||
return clip;
|
||||
}
|
||||
|
||||
// Renders one frame through the application's preview path and returns the
|
||||
// resulting CPU frame (nullptr on failure/timeout).
|
||||
FramePtr RenderOneFrame(ViewerOutput *viewer, const rational &time)
|
||||
FramePtr render_one_frame(ViewerOutput *viewer, const Rational &time)
|
||||
{
|
||||
RenderTicketPtr ticket =
|
||||
RenderManager::instance()->GetCacher()->GetSingleFrame(viewer, time,
|
||||
RenderManager::instance()->get_cacher()->get_single_frame(viewer, time,
|
||||
false);
|
||||
if (!ticket) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::atomic<bool> finished{ false };
|
||||
QObject::connect(ticket.get(), &RenderTicket::Finished,
|
||||
QObject::connect(ticket.get(), &RenderTicket::finished,
|
||||
[&finished]() { finished = true; });
|
||||
|
||||
QElapsedTimer timer;
|
||||
@@ -287,11 +287,11 @@ protected:
|
||||
QThread::msleep(5);
|
||||
}
|
||||
|
||||
if (!finished.load() || !ticket->HasResult()) {
|
||||
if (!finished.load() || !ticket->has_result()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return ticket->Get().value<FramePtr>();
|
||||
return ticket->get().value<FramePtr>();
|
||||
}
|
||||
|
||||
QString backend_;
|
||||
@@ -307,14 +307,14 @@ protected:
|
||||
// (the last value in the footage's table) instead of its video texture.
|
||||
TEST_P(RenderClipBufferHintTest, DirectFootageToVideoClipNotBlack)
|
||||
{
|
||||
BuildVideoClipChain(false);
|
||||
build_video_clip_chain(false);
|
||||
|
||||
for (double t : { 0.0, 1.0 }) {
|
||||
FramePtr frame = RenderOneFrame(sequence_, rational::fromDouble(t));
|
||||
FramePtr frame = render_one_frame(sequence_, Rational::from_double(t));
|
||||
ASSERT_TRUE(frame != nullptr)
|
||||
<< "Direct footage->clip render produced no frame at t=" << t;
|
||||
ASSERT_TRUE(frame->is_allocated());
|
||||
EXPECT_GT(CountNonZeroBytes(frame), 0)
|
||||
EXPECT_GT(count_non_zero_bytes(frame), 0)
|
||||
<< "Direct footage->clip render is BLACK at t=" << t
|
||||
<< " (all sampled bytes are zero)";
|
||||
}
|
||||
@@ -324,15 +324,15 @@ TEST_P(RenderClipBufferHintTest, DirectFootageToVideoClipNotBlack)
|
||||
// because the effect's table contains only the passed-through texture.
|
||||
TEST_P(RenderClipBufferHintTest, IndirectFootageToVideoClipNotBlack)
|
||||
{
|
||||
BuildVideoClipChain(true);
|
||||
build_video_clip_chain(true);
|
||||
|
||||
for (double t : { 0.0, 1.0 }) {
|
||||
FramePtr frame = RenderOneFrame(sequence_, rational::fromDouble(t));
|
||||
FramePtr frame = render_one_frame(sequence_, Rational::from_double(t));
|
||||
ASSERT_TRUE(frame != nullptr)
|
||||
<< "Indirect footage->opacity->clip render produced no frame at t="
|
||||
<< t;
|
||||
ASSERT_TRUE(frame->is_allocated());
|
||||
EXPECT_GT(CountNonZeroBytes(frame), 0)
|
||||
EXPECT_GT(count_non_zero_bytes(frame), 0)
|
||||
<< "Indirect footage->opacity->clip render is BLACK at t=" << t
|
||||
<< " (all sampled bytes are zero)";
|
||||
}
|
||||
@@ -343,25 +343,25 @@ TEST_P(RenderClipBufferHintTest, IndirectFootageToVideoClipNotBlack)
|
||||
// source.
|
||||
TEST_P(RenderClipBufferHintTest, BufferHintFollowsTrackType)
|
||||
{
|
||||
ClipBlock *clip = BuildVideoClipChain(false);
|
||||
ClipBlock *clip = build_video_clip_chain(false);
|
||||
|
||||
Node::ValueHint video_hint =
|
||||
clip->GetValueHintForInput(ClipBlock::kBufferIn);
|
||||
clip->get_value_hint_for_input(ClipBlock::k_buffer_in);
|
||||
ASSERT_FALSE(video_hint.types().isEmpty());
|
||||
EXPECT_TRUE(video_hint.types().contains(NodeValue::kTexture));
|
||||
EXPECT_TRUE(video_hint.types().contains(NodeValue::k_texture));
|
||||
|
||||
// Move the clip onto an audio track: the hint must prefer samples.
|
||||
video_track_->RippleRemoveBlock(clip);
|
||||
video_track_->ripple_remove_block(clip);
|
||||
|
||||
Track *audio_track = new Track();
|
||||
audio_track->setParent(project_.get());
|
||||
audio_track->set_type(Track::kAudio);
|
||||
audio_track->AppendBlock(clip);
|
||||
audio_track->set_type(Track::k_audio);
|
||||
audio_track->append_block(clip);
|
||||
|
||||
Node::ValueHint audio_hint =
|
||||
clip->GetValueHintForInput(ClipBlock::kBufferIn);
|
||||
clip->get_value_hint_for_input(ClipBlock::k_buffer_in);
|
||||
ASSERT_FALSE(audio_hint.types().isEmpty());
|
||||
EXPECT_TRUE(audio_hint.types().contains(NodeValue::kSamples));
|
||||
EXPECT_TRUE(audio_hint.types().contains(NodeValue::k_samples));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(Backends, RenderClipBufferHintTest,
|
||||
|
||||
Reference in New Issue
Block a user