renderer: fixed bug that would render frames even after hash matching

Also enables the -Wshadow GCC warning to warn against the code bug that
caused this issue (and has caused other issues like it in the past).
This commit is contained in:
itsmattkc
2020-06-19 20:25:05 +10:00
parent b2a3cede2c
commit 65ccac1dfe
11 changed files with 48 additions and 44 deletions
+1
View File
@@ -107,6 +107,7 @@ else()
-Wall
-Wextra
-Wno-unused-parameter
-Wshadow
)
endif()
+8 -6
View File
@@ -81,13 +81,15 @@ QString NodeInput::name()
void NodeInput::Load(QXmlStreamReader *reader, XMLNodeData &xml_node_data, const QAtomicInt *cancelled)
{
XMLAttributeLoop(reader, attr) {
if (cancelled && *cancelled) {
return;
}
{
XMLAttributeLoop(reader, attr) {
if (cancelled && *cancelled) {
return;
}
if (attr.name() == QStringLiteral("keyframing")) {
set_is_keyframing(attr.value() == QStringLiteral("1"));
if (attr.name() == QStringLiteral("keyframing")) {
set_is_keyframing(attr.value() == QStringLiteral("1"));
}
}
}
+3 -3
View File
@@ -151,9 +151,9 @@ void TrackList::RemoveTrack()
void TrackList::TrackConnected(NodeEdgePtr edge)
{
int track_index = track_input_->IndexOfSubParameter(edge->input());
int input_index = track_input_->IndexOfSubParameter(edge->input());
Q_ASSERT(track_index >= 0);
Q_ASSERT(input_index >= 0);
Node* connected_node = edge->output()->parentNode();
@@ -163,7 +163,7 @@ void TrackList::TrackConnected(NodeEdgePtr edge)
{
// Find "real" index
TrackOutput* next = nullptr;
for (int i=track_index+1; i<track_input_->GetSize(); i++) {
for (int i=input_index+1; i<track_input_->GetSize(); i++) {
Node* that_track = track_input_->At(i)->get_connected_node();
if (that_track && that_track->IsTrack()) {
+12 -12
View File
@@ -276,21 +276,21 @@ QVariant OpenGLProxy::RunNodeAccelerated(const Node *node,
shader->bind();
NodeValueMap::const_iterator i;
for (i=job.GetValues().constBegin(); i!=job.GetValues().constEnd(); i++) {
NodeValueMap::const_iterator it;
for (it=job.GetValues().constBegin(); it!=job.GetValues().constEnd(); it++) {
// See if the shader has takes this parameter as an input
int variable_location = shader->uniformLocation(i.key()->id());
int variable_location = shader->uniformLocation(it.key()->id());
if (variable_location == -1) {
continue;
}
// This variable is used in the shader, let's set it
const QVariant& value = i.value().data();
const QVariant& value = it.value().data();
const NodeParam::DataType& data_type = (i.value().type() != NodeParam::kNone)
? i.value().type()
: i.key()->data_type();
const NodeParam::DataType& data_type = (it.value().type() != NodeParam::kNone)
? it.value().type()
: it.key()->data_type();
switch (data_type) {
case NodeInput::kInt:
@@ -300,7 +300,7 @@ QVariant OpenGLProxy::RunNodeAccelerated(const Node *node,
shader->setUniformValue(variable_location, value.toFloat());
break;
case NodeInput::kVec2:
if (i.key()->IsArray()) {
if (it.key()->IsArray()) {
QVector<NodeValue> nv = value.value< QVector<NodeValue> >();
QVector<QVector2D> a(nv.size());
@@ -310,7 +310,7 @@ QVariant OpenGLProxy::RunNodeAccelerated(const Node *node,
shader->setUniformValueArray(variable_location, a.constData(), a.size());
int count_location = shader->uniformLocation(QStringLiteral("%1_count").arg(i.key()->id()));
int count_location = shader->uniformLocation(QStringLiteral("%1_count").arg(it.key()->id()));
if (count_location > -1) {
shader->setUniformValue(count_location, a.size());
}
@@ -354,7 +354,7 @@ QVariant OpenGLProxy::RunNodeAccelerated(const Node *node,
shader->setUniformValue(variable_location, textures_to_bind.size());
// If this texture binding is the iterative input, set it here
if (i.key() == job.GetIterativeInput()) {
if (it.key() == job.GetIterativeInput()) {
iterative_input = textures_to_bind.size();
}
@@ -362,7 +362,7 @@ QVariant OpenGLProxy::RunNodeAccelerated(const Node *node,
textures_to_bind.append(tex_id);
// Set enable flag if shader wants it
int enable_param_location = shader->uniformLocation(QStringLiteral("%1_enabled").arg(i.key()->id()));
int enable_param_location = shader->uniformLocation(QStringLiteral("%1_enabled").arg(it.key()->id()));
if (enable_param_location > -1) {
shader->setUniformValue(enable_param_location,
tex_id > 0);
@@ -370,7 +370,7 @@ QVariant OpenGLProxy::RunNodeAccelerated(const Node *node,
if (tex_id > 0) {
// Set texture resolution if shader wants it
int res_param_location = shader->uniformLocation(QStringLiteral("%1_resolution").arg(i.key()->id()));
int res_param_location = shader->uniformLocation(QStringLiteral("%1_resolution").arg(it.key()->id()));
if (res_param_location > -1) {
shader->setUniformValue(res_param_location,
static_cast<GLfloat>(texture->texture()->width() * texture->texture()->divider()),
+3 -3
View File
@@ -115,13 +115,13 @@ void RenderBackend::ClearVideoQueue()
QFuture<QVector<QByteArray> > RenderBackend::Hash(const QVector<rational> &times)
{
return QtConcurrent::run(&pool_, [this](const QVector<rational> &times){
QVector<QByteArray> hashes(times.size());
return QtConcurrent::run(&pool_, [this](const QVector<rational> &t){
QVector<QByteArray> hashes(t.size());
for (int i=0;i<hashes.size();i++) {
hashes[i] = HashNode(copied_viewer_node_->texture_input()->get_connected_node(),
video_params_,
times.at(i));
t.at(i));
}
return hashes;
+11 -10
View File
@@ -93,12 +93,10 @@ void RenderTask::Render(const TimeRangeList& video_range,
if (!video_range.isEmpty()) {
QList<QByteArray> existing_hashes;
foreach (const TimeRange& r, video_range) {
total_length += r.length().toDouble();
}
times = viewer_->video_frame_cache()->GetFrameListFromTimeRange(video_range);
total_length += video_frame_sz * times.size();
QFuture<QVector<QByteArray> > hash_future = backend_.Hash(times);
hashes = hash_future.result();
@@ -125,7 +123,7 @@ void RenderTask::Render(const TimeRangeList& video_range,
|| !download_futures.empty()
|| !audio_lookup_table.empty())) {
if (!frame_queue.empty()) {
if (!IsCancelled() && !frame_queue.empty()) {
// Pop another frame off the frame queue
const HashTimePair& p = frame_queue.front();
@@ -138,11 +136,14 @@ void RenderTask::Render(const TimeRangeList& video_range,
bool hash_exists = false;
if (use_disk_cache) {
bool hash_exists = (std::find(existing_hashes.begin(), existing_hashes.end(), p.hash) != existing_hashes.end());
// Check if this hash is in our "existing hashes" list
hash_exists = (std::find(existing_hashes.begin(), existing_hashes.end(), p.hash) != existing_hashes.end());
// If not, check if it's in the filesystem
if (!hash_exists) {
hash_exists = QFileInfo::exists(viewer_->video_frame_cache()->CachePathName(p.hash));
// If so, add it to the list so we don't have to check the filesystem again later
if (hash_exists) {
existing_hashes.push_back(p.hash);
}
@@ -167,7 +168,7 @@ void RenderTask::Render(const TimeRangeList& video_range,
frame_queue.pop_front();
}
if (!audio_queue.empty()) {
if (!IsCancelled() && !audio_queue.empty()) {
audio_lookup_table.push_back({audio_queue.front(), backend_.RenderAudio(audio_queue.front())});
audio_queue.pop_front();
}
@@ -194,9 +195,9 @@ void RenderTask::Render(const TimeRangeList& video_range,
// Place it in the cache
std::list<rational> times_with_hash;
for (int k=0;k<hashes.size();k++) {
if (hashes.at(k) == j->hash) {
times_with_hash.push_back(times.at(k));
for (int hash_index=0;hash_index<hashes.size();hash_index++) {
if (hashes.at(hash_index) == j->hash) {
times_with_hash.push_back(times.at(hash_index));
}
}
+2 -2
View File
@@ -90,11 +90,11 @@ void AudioMonitor::Stop()
}
}
void AudioMonitor::OutputPushed(const QByteArray &data)
void AudioMonitor::OutputPushed(const QByteArray &d)
{
QVector<double> v(params_.channel_count(), 0);
BytesToSampleSummary(data, v);
BytesToSampleSummary(d, v);
PushValue(v);
+1 -1
View File
@@ -45,7 +45,7 @@ public slots:
void Stop();
void OutputPushed(const QByteArray& data);
void OutputPushed(const QByteArray& d);
protected:
//virtual void paintEvent(QPaintEvent* event) override;
+3 -3
View File
@@ -50,13 +50,13 @@ Menu::Menu(const QString &s, QWidget *parent) :
Init();
}
QAction *Menu::AddActionWithData(const QString &text, const QVariant &data, const QVariant &compare)
QAction *Menu::AddActionWithData(const QString &text, const QVariant &d, const QVariant &compare)
{
QAction* a = addAction(text);
a->setData(data);
a->setData(d);
a->setCheckable(true);
a->setChecked(data == compare);
a->setChecked(d == compare);
return a;
}
+1 -1
View File
@@ -132,7 +132,7 @@ public:
}
QAction* AddActionWithData(const QString& text,
const QVariant& data,
const QVariant& d,
const QVariant& compare);
QAction *InsertAlphabetically(const QString& s);
+3 -3
View File
@@ -1584,9 +1584,9 @@ bool TimelineWidget::SnapPoint(QList<rational> start_times, rational* movement,
// Find all points at this movement
QList<rational> snap_times;
foreach (const SnapData& data, potential_snaps) {
if (data.movement == *movement) {
snap_times.append(data.time);
foreach (const SnapData& d, potential_snaps) {
if (d.movement == *movement) {
snap_times.append(d.time);
}
}