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:
+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);
|
||||
|
||||
Reference in New Issue
Block a user