footage: support multi-layered images

Fixes #982
This commit is contained in:
itsmattkc
2022-05-04 09:27:34 -07:00
parent a3c52cafaa
commit 5f13a83009
9 changed files with 132 additions and 26 deletions
@@ -318,7 +318,7 @@ void TransformDistortNode::GizmoDragMove(double x, double y, const Qt::KeyboardM
}
}
QMatrix4x4 TransformDistortNode::AdjustMatrixByResolutions(const QMatrix4x4 &mat, const QVector2D &sequence_res, const QVector2D &texture_res, AutoScaleType autoscale_type)
QMatrix4x4 TransformDistortNode::AdjustMatrixByResolutions(const QMatrix4x4 &mat, const QVector2D &sequence_res, const QVector2D &texture_res, const QVector2D &offset, AutoScaleType autoscale_type)
{
// First, create an identity matrix
QMatrix4x4 adjusted_matrix;
@@ -326,6 +326,9 @@ QMatrix4x4 TransformDistortNode::AdjustMatrixByResolutions(const QMatrix4x4 &mat
// Scale it to a square based on the sequence's resolution
adjusted_matrix.scale(2.0 / sequence_res.x(), 2.0 / sequence_res.y(), 1.0);
// Apply offset if applicable
adjusted_matrix.translate(offset);
// Adjust by the matrix we generated earlier
adjusted_matrix *= mat;
@@ -378,6 +381,7 @@ void TransformDistortNode::UpdateGizmoPositions(const NodeValueRow &row, const N
// GizmoTraverser just returns the sizes of the textures and no other data
VideoParams tex_params = tex->params();
QVector2D tex_sz(tex_params.square_pixel_width(), tex_params.height());
QVector2D tex_offset = tex_params.offset();
// Retrieve autoscale value
AutoScaleType autoscale = static_cast<AutoScaleType>(row[kAutoscaleInput].data().toInt());
@@ -388,6 +392,7 @@ void TransformDistortNode::UpdateGizmoPositions(const NodeValueRow &row, const N
rectangle_matrix *= AdjustMatrixByResolutions(GenerateMatrix(row, false, false, false, false),
sequence_res,
tex_sz,
tex_offset,
autoscale);
// Create rect and transform it
@@ -407,6 +412,7 @@ void TransformDistortNode::UpdateGizmoPositions(const NodeValueRow &row, const N
anchor_matrix *= AdjustMatrixByResolutions(GenerateMatrix(row, false, true, false, false),
sequence_res,
tex_sz,
tex_offset,
autoscale);
anchor_gizmo_->SetPoint(anchor_matrix.toTransform().map(QPointF(0, 0)) + sequence_half_res_pt);
@@ -422,7 +428,7 @@ void TransformDistortNode::UpdateGizmoPositions(const NodeValueRow &row, const N
// Use offsets to make the appearance of values that start in the top left, even though we
// really anchor around the center
SetInputProperty(kPositionInput, QStringLiteral("offset"), sequence_half_res);
SetInputProperty(kPositionInput, QStringLiteral("offset"), sequence_half_res + tex_offset);
SetInputProperty(kAnchorInput, QStringLiteral("offset"), tex_sz * 0.5);
}
@@ -440,6 +446,7 @@ QMatrix4x4 TransformDistortNode::GenerateAutoScaledMatrix(const QMatrix4x4& gene
return AdjustMatrixByResolutions(generated_matrix,
sequence_res,
texture_res,
texture_params.offset(),
autoscale);
}
@@ -82,6 +82,7 @@ public:
static QMatrix4x4 AdjustMatrixByResolutions(const QMatrix4x4& mat,
const QVector2D& sequence_res,
const QVector2D& texture_res,
const QVector2D& offset,
AutoScaleType autoscale_type = kAutoScaleNone);
virtual void UpdateGizmoPositions(const NodeValueRow &row, const NodeGlobals &globals) override;
+1
View File
@@ -363,6 +363,7 @@ void MathNodeBase::ValueInternal(Operation operation, Pairing pairing, const QSt
QMatrix4x4 adjusted_matrix = TransformDistortNode::AdjustMatrixByResolutions(number_val.data().value<QMatrix4x4>(),
sequence_res,
texture->params().offset(),
texture_res);
if (operation != kOpMultiply || adjusted_matrix.isIdentity()) {
+8 -1
View File
@@ -475,7 +475,9 @@ void ViewerOutput::set_parameters_from_footage(const QVector<ViewerOutput *> foo
QVector<VideoParams> video_streams = f->GetEnabledVideoStreams();
QVector<AudioParams> audio_streams = f->GetEnabledAudioStreams();
foreach (const VideoParams& s, video_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;
@@ -483,6 +485,11 @@ void ViewerOutput::set_parameters_from_footage(const QVector<ViewerOutput *> foo
// 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
if (i > 0) {
// Ignore still images past stream 0
continue;
}
using_timebase = GetVideoParams().time_base();
} else {
using_timebase = s.frame_rate_as_time_base();