exportdialog: allow restoring parameters

This commit is contained in:
itsmattkc
2022-08-10 11:49:21 -07:00
parent a2b400a1dc
commit 409f24be39
22 changed files with 331 additions and 222 deletions
-2
View File
@@ -18,7 +18,5 @@ set(OLIVE_SOURCES
${OLIVE_SOURCES}
task/export/export.h
task/export/export.cpp
task/export/exportparams.h
task/export/exportparams.cpp
PARENT_SCOPE
)
+8 -8
View File
@@ -27,7 +27,7 @@ namespace olive {
ExportTask::ExportTask(ViewerOutput *viewer_node,
ColorManager* color_manager,
const ExportParams& params) :
const EncodingParams& params) :
color_manager_(color_manager),
params_(params)
{
@@ -60,7 +60,7 @@ bool ExportTask::Run()
// If we're exporting to a sidecar subtitle file, disable the subtitles in the main encoder
bool subtitles_enabled = params_.subtitles_enabled();
ExportParams sidecar_params = params_;
EncodingParams sidecar_params = params_;
if (subtitles_enabled && params_.subtitles_are_sidecar()) {
params_.DisableSubtitles();
}
@@ -126,12 +126,12 @@ bool ExportTask::Run()
|| video_params().height() != params_.video_params().height()) {
video_force_size = QSize(params_.video_params().width(), params_.video_params().height());
if (params_.video_scaling_method() != ExportParams::kStretch) {
video_force_matrix = ExportParams::GenerateMatrix(params_.video_scaling_method(),
video_params().width(),
video_params().height(),
params_.video_params().width(),
params_.video_params().height());
if (params_.video_scaling_method() != EncodingParams::kStretch) {
video_force_matrix = EncodingParams::GenerateMatrix(params_.video_scaling_method(),
video_params().width(),
video_params().height(),
params_.video_params().width(),
params_.video_params().height());
}
} else {
// Disables forcing size in the renderer
+3 -3
View File
@@ -21,7 +21,7 @@
#ifndef EXPORTTASK_H
#define EXPORTTASK_H
#include "exportparams.h"
#include "codec/encoder.h"
#include "node/output/viewer/viewer.h"
#include "render/colorprocessor.h"
#include "task/render/render.h"
@@ -33,7 +33,7 @@ class ExportTask : public RenderTask
{
Q_OBJECT
public:
ExportTask(ViewerOutput *viewer_node, ColorManager *color_manager, const ExportParams &params);
ExportTask(ViewerOutput *viewer_node, ColorManager *color_manager, const EncodingParams &params);
protected:
virtual bool Run() override;
@@ -58,7 +58,7 @@ private:
ColorManager* color_manager_;
ExportParams params_;
EncodingParams params_;
std::shared_ptr<Encoder> encoder_;
-103
View File
@@ -1,103 +0,0 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "exportparams.h"
namespace olive {
ExportParams::ExportParams() :
video_scaling_method_(kStretch),
has_custom_range_(false)
{
}
bool ExportParams::has_custom_range() const
{
return has_custom_range_;
}
const TimeRange &ExportParams::custom_range() const
{
return custom_range_;
}
void ExportParams::set_custom_range(const TimeRange &custom_range)
{
has_custom_range_ = true;
custom_range_ = custom_range;
}
const ExportParams::VideoScalingMethod &ExportParams::video_scaling_method() const
{
return video_scaling_method_;
}
void ExportParams::set_video_scaling_method(const ExportParams::VideoScalingMethod &video_scaling_method)
{
video_scaling_method_ = video_scaling_method;
}
QMatrix4x4 ExportParams::GenerateMatrix(ExportParams::VideoScalingMethod method,
int source_width, int source_height,
int dest_width, int dest_height)
{
QMatrix4x4 preview_matrix;
if (method == ExportParams::kStretch) {
return preview_matrix;
}
float export_ar = static_cast<float>(dest_width) / static_cast<float>(dest_height);
float source_ar = static_cast<float>(source_width) / static_cast<float>(source_height);
if (qFuzzyCompare(export_ar, source_ar)) {
return preview_matrix;
}
if ((export_ar > source_ar) == (method == ExportParams::kFit)) {
preview_matrix.scale(source_ar / export_ar, 1.0F);
} else {
preview_matrix.scale(1.0F, export_ar / source_ar);
}
return preview_matrix;
}
void ExportParams::Save(QXmlStreamWriter *writer) const
{
writer->writeStartElement(QStringLiteral("export"));
writer->writeTextElement(QStringLiteral("vscale"), QString::number(video_scaling_method_));
writer->writeTextElement(QStringLiteral("range"), QString::number(has_custom_range_));
writer->writeTextElement(QStringLiteral("customrangein"), custom_range_.in().toString());
writer->writeTextElement(QStringLiteral("customrangeout"), custom_range_.out().toString());
// FIXME: Change this when color chains are implemented
writer->writeTextElement(QStringLiteral("color"), color_transform().output());
EncodingParams::Save(writer);
writer->writeEndElement(); // export
}
}
-65
View File
@@ -1,65 +0,0 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef EXPORTPARAMS_H
#define EXPORTPARAMS_H
#include <QMatrix4x4>
#include "codec/encoder.h"
#include "node/output/viewer/viewer.h"
#include "render/colortransform.h"
namespace olive {
class ExportParams : public EncodingParams {
public:
enum VideoScalingMethod {
kFit,
kStretch,
kCrop
};
ExportParams();
bool has_custom_range() const;
const TimeRange& custom_range() const;
void set_custom_range(const TimeRange& custom_range);
const VideoScalingMethod& video_scaling_method() const;
void set_video_scaling_method(const VideoScalingMethod& video_scaling_method);
static QMatrix4x4 GenerateMatrix(ExportParams::VideoScalingMethod method,
int source_width, int source_height,
int dest_width, int dest_height);
virtual void Save(QXmlStreamWriter* writer) const override;
private:
VideoScalingMethod video_scaling_method_;
bool has_custom_range_;
TimeRange custom_range_;
};
}
#endif // EXPORTPARAMS_H