sequence: made divider a sequence parameter rather than a viewer parameter
Doing this makes the preview resolution an explicit project setting rather than a temporary UI setting. This will allow more consistency when caching.
This commit is contained in:
@@ -50,7 +50,7 @@ AudioMonitor::~AudioMonitor()
|
||||
Stop();
|
||||
}
|
||||
|
||||
void AudioMonitor::SetParams(const AudioRenderingParams ¶ms)
|
||||
void AudioMonitor::SetParams(const AudioParams ¶ms)
|
||||
{
|
||||
params_ = params;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
virtual ~AudioMonitor() override;
|
||||
|
||||
public slots:
|
||||
void SetParams(const AudioRenderingParams& params);
|
||||
void SetParams(const AudioParams& params);
|
||||
|
||||
void OutputDeviceSet(const QString& filename, qint64 offset, int playback_speed);
|
||||
|
||||
@@ -64,7 +64,7 @@ private:
|
||||
|
||||
QVector<double> GetAverages() const;
|
||||
|
||||
AudioRenderingParams params_;
|
||||
AudioParams params_;
|
||||
|
||||
QFile file_;
|
||||
qint64 last_time_;
|
||||
|
||||
@@ -62,7 +62,7 @@ void AudioWaveformView::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QWidget::paintEvent(event);
|
||||
|
||||
const AudioRenderingParams& params = playback_->GetParameters();
|
||||
const AudioParams& params = playback_->GetParameters();
|
||||
|
||||
if (!playback_
|
||||
|| playback_->GetCacheFilename().isEmpty()
|
||||
|
||||
@@ -84,21 +84,28 @@ void FootageViewerWidget::SetFootage(Footage *footage)
|
||||
|
||||
if (video_stream) {
|
||||
video_node_->SetFootage(video_stream);
|
||||
viewer_node_->set_video_params(VideoParams(video_stream->width(), video_stream->height(), video_stream->frame_rate().flipped()));
|
||||
viewer_node_->set_video_params(VideoParams(video_stream->width(),
|
||||
video_stream->height(),
|
||||
video_stream->frame_rate().flipped(),
|
||||
static_cast<PixelFormat::Format>(Config::Current()["DefaultSequencePreviewFormat"].toInt()),
|
||||
Config::Current()["DefaultSequencePreviewDivider"].toInt()));
|
||||
NodeParam::ConnectEdge(video_node_->output(), viewer_node_->texture_input());
|
||||
} else {
|
||||
viewer_node_->set_video_params(VideoParams(Config::Current()["DefaultSequenceWidth"].toInt(),
|
||||
Config::Current()["DefaultSequenceHeight"].toInt(),
|
||||
Config::Current()["DefaultSequenceFrameRate"].value<rational>()));
|
||||
Config::Current()["DefaultSequenceHeight"].toInt(),
|
||||
Config::Current()["DefaultSequenceFrameRate"].value<rational>(),
|
||||
static_cast<PixelFormat::Format>(Config::Current()["DefaultSequencePreviewFormat"].toInt()),
|
||||
Config::Current()["DefaultSequencePreviewDivider"].toInt()));
|
||||
}
|
||||
|
||||
if (audio_stream) {
|
||||
audio_node_->SetFootage(audio_stream);
|
||||
viewer_node_->set_audio_params(AudioParams(audio_stream->sample_rate(), audio_stream->channel_layout()));
|
||||
viewer_node_->set_audio_params(AudioParams(audio_stream->sample_rate(), audio_stream->channel_layout(), SampleFormat::kInternalFormat));
|
||||
NodeParam::ConnectEdge(audio_node_->output(), viewer_node_->samples_input());
|
||||
} else {
|
||||
viewer_node_->set_audio_params(AudioParams(Config::Current()["DefaultSequenceAudioFrequency"].toInt(),
|
||||
Config::Current()["DefaultSequenceAudioLayout"].toULongLong()));
|
||||
Config::Current()["DefaultSequenceAudioLayout"].toULongLong(),
|
||||
SampleFormat::kInternalFormat));
|
||||
}
|
||||
|
||||
ConnectViewerNode(viewer_node_, footage_->project()->color_manager());
|
||||
|
||||
@@ -54,7 +54,6 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
|
||||
playback_speed_(0),
|
||||
frame_cache_job_time_(0),
|
||||
color_menu_enabled_(true),
|
||||
divider_(Config::Current()["DefaultViewerDivider"].toInt()),
|
||||
override_color_manager_(nullptr),
|
||||
time_changed_from_timer_(false),
|
||||
prequeuing_(false),
|
||||
@@ -112,6 +111,7 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
|
||||
// Start background renderer
|
||||
renderer_ = new OpenGLBackend(this);
|
||||
renderer_->SetUpdateWithGraph(true);
|
||||
renderer_->SetRenderMode(RenderMode::kOffline);
|
||||
|
||||
// Setup cache wait timer (waits a few seconds of inactivity before caching)
|
||||
cache_wait_timer_.setInterval(100);
|
||||
@@ -186,8 +186,7 @@ void ViewerWidget::ConnectNodeInternal(ViewerOutput *n)
|
||||
|
||||
ruler()->SetPlaybackCache(n->video_frame_cache());
|
||||
|
||||
n->audio_playback_cache()->SetParameters(AudioRenderingParams(n->audio_params(),
|
||||
SampleFormat::kInternalFormat));
|
||||
n->audio_playback_cache()->SetParameters(n->audio_params());
|
||||
|
||||
SizeChangedSlot(n->video_params().width(), n->video_params().height());
|
||||
last_length_ = rational();
|
||||
@@ -208,8 +207,6 @@ void ViewerWidget::ConnectNodeInternal(ViewerOutput *n)
|
||||
window->display_widget()->ConnectColorManager(using_manager);
|
||||
}
|
||||
|
||||
divider_ = CalculateDivider();
|
||||
|
||||
UpdateRendererParameters();
|
||||
|
||||
UpdateStack();
|
||||
@@ -409,7 +406,7 @@ FramePtr DecodeCachedImage(const QString &fn, const rational& time)
|
||||
|
||||
frame = Frame::Create();
|
||||
frame->set_timestamp(time);
|
||||
frame->set_video_params(VideoRenderingParams(input->spec().width,
|
||||
frame->set_video_params(VideoParams(input->spec().width,
|
||||
input->spec().height,
|
||||
image_format));
|
||||
|
||||
@@ -558,7 +555,7 @@ void ViewerWidget::PushScrubbedAudio()
|
||||
QFile audio_src(audio_fn);
|
||||
|
||||
if (audio_src.open(QFile::ReadOnly)) {
|
||||
const AudioRenderingParams& params = GetConnectedNode()->audio_playback_cache()->GetParameters();
|
||||
const AudioParams& params = GetConnectedNode()->audio_playback_cache()->GetParameters();
|
||||
|
||||
// FIXME: Hardcoded scrubbing interval (20ms)
|
||||
int size_of_sample = params.time_to_bytes(rational(20, 1000));
|
||||
@@ -574,6 +571,7 @@ void ViewerWidget::PushScrubbedAudio()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
int ViewerWidget::CalculateDivider()
|
||||
{
|
||||
if (GetConnectedNode() && Config::Current()["AutoSelectDivider"].toBool()) {
|
||||
@@ -585,6 +583,7 @@ int ViewerWidget::CalculateDivider()
|
||||
|
||||
return divider_;
|
||||
}
|
||||
*/
|
||||
|
||||
void ViewerWidget::UpdateMinimumScale()
|
||||
{
|
||||
@@ -703,20 +702,6 @@ void ViewerWidget::FinishPlayPreprocess()
|
||||
PlaybackTimerUpdate();
|
||||
}
|
||||
|
||||
VideoRenderingParams ViewerWidget::GenerateVideoParams() const
|
||||
{
|
||||
return VideoRenderingParams(GetConnectedNode()->video_params(),
|
||||
GetCurrentPixelFormat(),
|
||||
RenderMode::kOffline,
|
||||
divider_);
|
||||
}
|
||||
|
||||
AudioRenderingParams ViewerWidget::GenerateAudioParams() const
|
||||
{
|
||||
return AudioRenderingParams(GetConnectedNode()->audio_params(),
|
||||
SampleFormat::kInternalFormat);
|
||||
}
|
||||
|
||||
int ViewerWidget::DeterminePlaybackQueueSize()
|
||||
{
|
||||
int64_t end_ts;
|
||||
@@ -914,8 +899,8 @@ void ViewerWidget::StartBackgroundCaching()
|
||||
|
||||
} else {
|
||||
cache_background_task_ = new CacheTask(GetConnectedNode(),
|
||||
GenerateVideoParams(),
|
||||
GenerateAudioParams(),
|
||||
GetConnectedNode()->video_params(),
|
||||
GetConnectedNode()->audio_params(),
|
||||
false);
|
||||
|
||||
our_cache_background_task_ = cache_background_task_;
|
||||
@@ -943,8 +928,8 @@ void ViewerWidget::UpdateRendererParameters()
|
||||
|
||||
StartBackgroundCaching();
|
||||
|
||||
renderer_->SetVideoParams(GenerateVideoParams());
|
||||
renderer_->SetAudioParams(GenerateAudioParams());
|
||||
renderer_->SetVideoParams(GetConnectedNode()->video_params());
|
||||
renderer_->SetAudioParams(GetConnectedNode()->audio_params());
|
||||
|
||||
display_widget_->SetVideoParams(GetConnectedNode()->video_params());
|
||||
}
|
||||
@@ -975,26 +960,6 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos)
|
||||
menu.addSeparator();
|
||||
}
|
||||
|
||||
{
|
||||
// Playback resolution
|
||||
Menu* playback_resolution_menu = new Menu(tr("Resolution"), &menu);
|
||||
menu.addMenu(playback_resolution_menu);
|
||||
|
||||
playback_resolution_menu->addAction(tr("Full"))->setData(1);
|
||||
int dividers[] = {2, 4, 8, 16};
|
||||
for (int i=0;i<4;i++) {
|
||||
playback_resolution_menu->addAction(tr("1/%1").arg(dividers[i]))->setData(dividers[i]);
|
||||
}
|
||||
connect(playback_resolution_menu, &QMenu::triggered, this, &ViewerWidget::SetDividerFromMenu);
|
||||
|
||||
foreach (QAction* a, playback_resolution_menu->actions()) {
|
||||
a->setCheckable(true);
|
||||
if (a->data() == divider_) {
|
||||
a->setChecked(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// Viewer Zoom Level
|
||||
Menu* zoom_menu = new Menu(tr("Zoom"), &menu);
|
||||
@@ -1252,20 +1217,6 @@ void ViewerWidget::LengthChangedSlot(const rational &length)
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerWidget::SetDividerFromMenu(QAction *action)
|
||||
{
|
||||
int divider = action->data().toInt();
|
||||
|
||||
if (divider <= 0) {
|
||||
qWarning() << "Tried to set invalid divider:" << divider;
|
||||
return;
|
||||
}
|
||||
|
||||
divider_ = divider;
|
||||
|
||||
UpdateRendererParameters();
|
||||
}
|
||||
|
||||
void ViewerWidget::SetZoomFromMenu(QAction *action)
|
||||
{
|
||||
sizer_->SetZoom(action->data().toInt());
|
||||
|
||||
@@ -197,9 +197,6 @@ private:
|
||||
|
||||
void FinishPlayPreprocess();
|
||||
|
||||
VideoRenderingParams GenerateVideoParams() const;
|
||||
AudioRenderingParams GenerateAudioParams() const;
|
||||
|
||||
int DeterminePlaybackQueueSize();
|
||||
|
||||
void PopOldestFrameFromPlaybackQueue();
|
||||
@@ -216,8 +213,6 @@ private:
|
||||
|
||||
bool color_menu_enabled_;
|
||||
|
||||
int divider_;
|
||||
|
||||
ColorManager* override_color_manager_;
|
||||
|
||||
bool time_changed_from_timer_;
|
||||
@@ -269,8 +264,6 @@ private slots:
|
||||
|
||||
void ShowContextMenu(const QPoint& pos);
|
||||
|
||||
void SetDividerFromMenu(QAction* action);
|
||||
|
||||
void SetZoomFromMenu(QAction* action);
|
||||
|
||||
void ViewerInvalidatedVideoRange(const OLIVE_NAMESPACE::TimeRange &range);
|
||||
|
||||
Reference in New Issue
Block a user