cache: add audio option

This commit is contained in:
itsmattkc
2021-09-23 00:47:21 -07:00
parent 0b205ece9c
commit 4fd7298cc3
4 changed files with 61 additions and 5 deletions
+12 -1
View File
@@ -31,7 +31,8 @@ const QString ViewerOutput::kVideoParamsInput = QStringLiteral("video_param_in")
const QString ViewerOutput::kAudioParamsInput = QStringLiteral("audio_param_in"); const QString ViewerOutput::kAudioParamsInput = QStringLiteral("audio_param_in");
const QString ViewerOutput::kTextureInput = QStringLiteral("tex_in"); const QString ViewerOutput::kTextureInput = QStringLiteral("tex_in");
const QString ViewerOutput::kSamplesInput = QStringLiteral("samples_in"); const QString ViewerOutput::kSamplesInput = QStringLiteral("samples_in");
const QString ViewerOutput::kVideoAutoCacheInput = QStringLiteral("autocache_in"); const QString ViewerOutput::kVideoAutoCacheInput = QStringLiteral("video_autocache_in");
const QString ViewerOutput::kAudioAutoCacheInput = QStringLiteral("audio_autocache_in");
const uint64_t ViewerOutput::kVideoParamEditMask = VideoParamEdit::kWidthHeight | VideoParamEdit::kInterlacing | VideoParamEdit::kFrameRate | VideoParamEdit::kPixelAspect; const uint64_t ViewerOutput::kVideoParamEditMask = VideoParamEdit::kWidthHeight | VideoParamEdit::kInterlacing | VideoParamEdit::kFrameRate | VideoParamEdit::kPixelAspect;
@@ -58,6 +59,10 @@ ViewerOutput::ViewerOutput(bool create_buffer_inputs, bool create_default_stream
AddInput(kVideoAutoCacheInput, NodeValue::kBoolean, true, InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable)); AddInput(kVideoAutoCacheInput, NodeValue::kBoolean, true, InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
IgnoreHashingFrom(kVideoAutoCacheInput); IgnoreHashingFrom(kVideoAutoCacheInput);
IgnoreInvalidationsFrom(kVideoAutoCacheInput); IgnoreInvalidationsFrom(kVideoAutoCacheInput);
AddInput(kAudioAutoCacheInput, NodeValue::kBoolean, true, InputFlags(kInputFlagNotKeyframable | kInputFlagNotConnectable));
IgnoreHashingFrom(kAudioAutoCacheInput);
IgnoreInvalidationsFrom(kAudioAutoCacheInput);
} }
if (create_default_streams) { if (create_default_streams) {
@@ -297,6 +302,10 @@ void ViewerOutput::Retranslate()
if (HasInputWithID(kVideoAutoCacheInput)) { if (HasInputWithID(kVideoAutoCacheInput)) {
SetInputName(kVideoAutoCacheInput, tr("Auto-Cache Video")); SetInputName(kVideoAutoCacheInput, tr("Auto-Cache Video"));
} }
if (HasInputWithID(kAudioAutoCacheInput)) {
SetInputName(kAudioAutoCacheInput, tr("Auto-Cache Audio"));
}
} }
void ViewerOutput::VerifyLength() void ViewerOutput::VerifyLength()
@@ -389,6 +398,8 @@ void ViewerOutput::InputValueChangedEvent(const QString &input, int element)
{ {
if (input == kVideoAutoCacheInput) { if (input == kVideoAutoCacheInput) {
emit VideoAutoCacheChanged(GetVideoAutoCacheEnabled()); emit VideoAutoCacheChanged(GetVideoAutoCacheEnabled());
} else if (input == kAudioAutoCacheInput) {
emit AudioAutoCacheChanged(GetAudioAutoCacheEnabled());
} else if (element == 0) { } else if (element == 0) {
if (input == kVideoParamsInput) { if (input == kVideoParamsInput) {
+18
View File
@@ -175,6 +175,22 @@ public:
} }
} }
bool GetAudioAutoCacheEnabled() const
{
if (HasInputWithID(kAudioAutoCacheInput)) {
return GetStandardValue(kAudioAutoCacheInput).toBool();
} else {
return false;
}
}
void SetAudioAutoCacheEnabled(bool e)
{
if (HasInputWithID(kAudioAutoCacheInput)) {
return SetStandardValue(kAudioAutoCacheInput, e);
}
}
static const QString kVideoParamsInput; static const QString kVideoParamsInput;
static const QString kAudioParamsInput; static const QString kAudioParamsInput;
@@ -182,6 +198,7 @@ public:
static const QString kSamplesInput; static const QString kSamplesInput;
static const QString kVideoAutoCacheInput; static const QString kVideoAutoCacheInput;
static const QString kAudioAutoCacheInput;
static const uint64_t kVideoParamEditMask; static const uint64_t kVideoParamEditMask;
@@ -197,6 +214,7 @@ signals:
void InterlacingChanged(VideoParams::Interlacing mode); void InterlacingChanged(VideoParams::Interlacing mode);
void VideoAutoCacheChanged(bool e); void VideoAutoCacheChanged(bool e);
void AudioAutoCacheChanged(bool e);
void VideoParamsChanged(); void VideoParamsChanged();
void AudioParamsChanged(); void AudioParamsChanged();
+29 -4
View File
@@ -116,12 +116,14 @@ void PreviewAutoCacher::AudioInvalidated(const TimeRange &range)
// cancelled, so some areas may end up unrendered forever // cancelled, so some areas may end up unrendered forever
// ClearAudioQueue(); // ClearAudioQueue();
audio_job_tracker_.insert(range, graph_changed_time_); if (viewer_node_->GetAudioAutoCacheEnabled()) {
audio_job_tracker_.insert(range, graph_changed_time_);
// Start jobs to re-render the audio at this range, split into 2 second chunks // Start jobs to re-render the audio at this range, split into 2 second chunks
invalidated_audio_.insert(range); invalidated_audio_.insert(range);
TryRender(); TryRender();
}
} }
void PreviewAutoCacher::HashesProcessed() void PreviewAutoCacher::HashesProcessed()
@@ -698,6 +700,19 @@ void PreviewAutoCacher::VideoAutoCacheEnableChanged(bool e)
{ {
if (e) { if (e) {
RequeueFrames(); RequeueFrames();
} else {
CancelVideoTasks();
queued_frame_iterator_.reset();
}
}
void PreviewAutoCacher::AudioAutoCacheEnableChanged(bool e)
{
if (e) {
AudioInvalidatedList(viewer_node_->audio_playback_cache()->GetInvalidatedRanges(viewer_node_->GetAudioLength()));
} else {
CancelAudioTasks();
audio_iterator_.clear();
} }
} }
@@ -791,6 +806,11 @@ void PreviewAutoCacher::SetViewerNode(ViewerOutput *viewer_node)
this, this,
&PreviewAutoCacher::VideoAutoCacheEnableChanged); &PreviewAutoCacher::VideoAutoCacheEnableChanged);
disconnect(viewer_node_,
&ViewerOutput::AudioAutoCacheChanged,
this,
&PreviewAutoCacher::AudioAutoCacheEnableChanged);
disconnect(viewer_node_->video_frame_cache(), disconnect(viewer_node_->video_frame_cache(),
&PlaybackCache::Invalidated, &PlaybackCache::Invalidated,
this, this,
@@ -846,6 +866,11 @@ void PreviewAutoCacher::SetViewerNode(ViewerOutput *viewer_node)
this, this,
&PreviewAutoCacher::VideoAutoCacheEnableChanged); &PreviewAutoCacher::VideoAutoCacheEnableChanged);
connect(viewer_node_,
&ViewerOutput::AudioAutoCacheChanged,
this,
&PreviewAutoCacher::AudioAutoCacheEnableChanged);
connect(viewer_node_->video_frame_cache(), connect(viewer_node_->video_frame_cache(),
&PlaybackCache::Invalidated, &PlaybackCache::Invalidated,
this, this,
+2
View File
@@ -220,6 +220,8 @@ private slots:
void VideoAutoCacheEnableChanged(bool e); void VideoAutoCacheEnableChanged(bool e);
void AudioAutoCacheEnableChanged(bool e);
}; };
} }