Files
oak-editor/app/node/output/track/tracklist.cpp
T
Mike-Solar 2aa921b215 fix: bug-fix sweep across node, audio, render, plugin subsystems
Node core:
- MathNode/TrigonometryNode combo strings realigned with Operation enums
- mathbase scalar/vector operand pick no longer uses bitwise type checks
- NodeSetPositionAndDependenciesRecursively moves dependencies again
- RemoveAllKeyframes undo actually restores keyframes
- NodeGroup GetInputName null-deref guard, passthrough ids use input id
- NodeValueTable::Has is an exact type match; tag fallback only for
  empty tags; kStrCombo/kPushButton get data type names
- delete_all_keyframes no longer loops forever on unparented keyframes;
  keyframe-load failures propagate; rational interpolation falls back to
  double; OpacityEffect no longer leaks its internal MathNode

Audio/footage:
- AudioVisualWaveform: GetSummaryFromTime underflow OOB read, TrimIn
  prepend length bookkeeping, OverwriteSums source channel indexing
- PanNode inserts the pan value into the sample job (keyframed pan
  works); OutputParamsChanged is emitted on device change; PortAudio
  device indices are validated before Pa_GetDeviceInfo
- Footage: AdjustTimeByLoopMode no longer hangs/UBs on degenerate
  lengths, GetStreamIndex bounds-checked, CheckFootage clears stale
  state on missing files, failed probes are not cached,
  FootageDescription::Load requires its own root element

Render/track:
- ViewerOutput pushes the tagged samples value; TrackList disconnects
  the track-height lambda; GetTrackFromReference validity check
- RenderManager dummy backend: null-initialized threads, guarded
  decoder-cache/timer paths; Renderer::Destroy releases color cache
  shaders/textures; unknown dynamic backends no longer alias to oakgl
- SharedMemoryRegion POSIX attach validates segment size; ReadMessage
  skips blank lines instead of failing; GC counter clamped;
  IsRenderingCustomRange implemented; TimeOffsetNode gets a true
  inverse OutputTimeAdjustment; zero-speed clips return the held frame

Plugin/nodes:
- OliveClip: stored default region of definition is honored, on-demand
  images are cached; OliveHost sets host identity properties and logs
  instead of showing modal dialogs offscreen; Plugin.h dead decls gone
- DespillNode guards graph-less use with Rec.709 fallback; description
  typos fixed (despill, swirl); mosaic applies when only one axis
  matches; Windows-only Project filename separator test fixed
2026-07-17 08:26:48 +08:00

201 lines
4.5 KiB
C++

/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
Modifications Copyright (C) 2025 mikesolar
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "tracklist.h"
#include "node/factory.h"
#include "node/math/math/math.h"
#include "node/math/merge/merge.h"
#include "node/output/viewer/viewer.h"
#include "node/project/sequence/sequence.h"
namespace olive
{
TrackList::TrackList(Sequence *parent, const Track::Type &type,
const QString &track_input)
: QObject(parent)
, track_input_(track_input)
, total_length_(0)
, type_(type)
{
}
Track *TrackList::GetTrackAt(int index) const
{
if (index >= 0 && index < track_cache_.size()) {
return track_cache_.at(index);
} else {
return nullptr;
}
}
void TrackList::TrackConnected(Node *node, int element)
{
if (element == -1) {
parent()->InvalidateAll(track_input(), element);
return;
}
Track *track = dynamic_cast<Track *>(node);
if (!track) {
return;
}
// Determine where in the cache this block will be
int cache_index = -1;
for (int i = element + 1; i < ArraySize(); i++) {
// Find next track because this will be the index we insert at
cache_index = GetCacheIndexFromArrayIndex(i);
if (cache_index >= 0) {
break;
}
}
// If there was no next, this will be inserted at the end
if (cache_index == -1) {
cache_index = track_cache_.size();
}
track_cache_.insert(cache_index, track);
track_array_indexes_.insert(cache_index, element);
// Update track indexes in the list (including this track)
UpdateTrackIndexesFrom(cache_index);
connect(track, &Track::TrackLengthChanged, this,
&TrackList::UpdateTotalLength);
track_height_connections_.insert(
track, connect(track, &Track::TrackHeightChanged, this, [this]() {
Track *t = static_cast<Track *>(sender());
emit TrackHeightChanged(t, t->GetTrackHeightInPixels());
}));
track->set_type(type_);
track->set_sequence(parent());
emit TrackListChanged();
// This function must be called after the track is added to track_cache_, since it uses track_cache_ to determine
// the track's index
emit TrackAdded(track);
UpdateTotalLength();
}
void TrackList::TrackDisconnected(Node *node, int element)
{
if (element == -1) {
// User has replaced the entire array, we will invalidate everything
parent()->InvalidateAll(track_input(), element);
return;
}
Track *track = dynamic_cast<Track *>(node);
if (!track) {
return;
}
// Traverse through Tracks uncaching and disconnecting them
emit TrackRemoved(track);
int cache_index = GetCacheIndexFromArrayIndex(element);
// Remove track here
track_cache_.removeAt(cache_index);
track_array_indexes_.removeAt(cache_index);
// Update indices for all subsequent tracks
UpdateTrackIndexesFrom(cache_index);
track->SetIndex(-1);
track->set_type(Track::kNone);
track->set_sequence(nullptr);
disconnect(track, &Track::TrackLengthChanged, this,
&TrackList::UpdateTotalLength);
disconnect(track_height_connections_.take(track));
emit TrackListChanged();
UpdateTotalLength();
}
void TrackList::UpdateTrackIndexesFrom(int index)
{
for (int i = index; i < track_cache_.size(); i++) {
track_cache_.at(i)->SetIndex(i);
}
}
Project *TrackList::GetParentGraph() const
{
return parent()->parent();
}
const QString &TrackList::track_input() const
{
return track_input_;
}
NodeInput TrackList::track_input(int element) const
{
return NodeInput(parent(), track_input(), element);
}
Sequence *TrackList::parent() const
{
return static_cast<Sequence *>(QObject::parent());
}
int TrackList::ArraySize() const
{
return parent()->InputArraySize(track_input());
}
void TrackList::ArrayAppend()
{
parent()->InputArrayAppend(track_input());
}
void TrackList::ArrayRemoveLast()
{
parent()->InputArrayRemoveLast(track_input());
}
void TrackList::UpdateTotalLength()
{
total_length_ = 0;
foreach (Track *track, track_cache_) {
if (track) {
total_length_ = qMax(total_length_, track->track_length());
}
}
emit LengthChanged(total_length_);
}
}