change: change code style to Linux style except indent.

This commit is contained in:
Mike Solar
2025-08-03 03:09:40 +08:00
parent 65ab76edc8
commit 74f73ab3be
789 changed files with 77113 additions and 68888 deletions
+70 -64
View File
@@ -28,105 +28,111 @@
#include "common/qtutils.h"
#include "widget/slider/integerslider.h"
namespace olive {
namespace olive
{
AV1Section::AV1Section(QWidget *parent) :
AV1Section(AV1CRFSection::kDefaultAV1CRF, parent)
AV1Section::AV1Section(QWidget *parent)
: AV1Section(AV1CRFSection::kDefaultAV1CRF, parent)
{
}
AV1Section::AV1Section(int default_crf, QWidget *parent) :
CodecSection(parent)
AV1Section::AV1Section(int default_crf, QWidget *parent)
: CodecSection(parent)
{
QGridLayout* layout = new QGridLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
QGridLayout *layout = new QGridLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
int row = 0;
layout->addWidget(new QLabel(tr("Preset:")), row, 0);
int row = 0;
layout->addWidget(new QLabel(tr("Preset:")), row, 0);
preset_combobox_ = new QComboBox();
preset_combobox_->setToolTip(tr("This parameter governs the efficiency/encode-time trade-off.\n"
"Lower presets will result in an output with better quality for a given file size, but will take longer to encode.\n"
"Higher presets can result in a very fast encode, but will make some compromises on visual quality for a given crf value."));
preset_combobox_ = new QComboBox();
preset_combobox_->setToolTip(tr(
"This parameter governs the efficiency/encode-time trade-off.\n"
"Lower presets will result in an output with better quality for a given file size, but will take longer to encode.\n"
"Higher presets can result in a very fast encode, but will make some compromises on visual quality for a given crf value."));
for (int i = 0; i <= 13; i++)
preset_combobox_->addItem(QString::number(i));
for (int i = 0; i <= 13; i++)
preset_combobox_->addItem(QString::number(i));
preset_combobox_->setCurrentIndex(8);
preset_combobox_->setCurrentIndex(8);
layout->addWidget(preset_combobox_, row, 1);
layout->addWidget(preset_combobox_, row, 1);
row++;
row++;
layout->addWidget(new QLabel(tr("Compression Method:")), row, 0);
layout->addWidget(new QLabel(tr("Compression Method:")), row, 0);
QComboBox* compression_box = new QComboBox();
compression_box->setToolTip(tr("This parameter governs the quality/size trade-off.\n"
"Higher CRF values will result in a final output that takes less space, but begins to lose detail.\n"
"Lower CRF values retain more detail at the cost of larger file sizes.\n"
"The possible range of CRF in SVT-AV1 is 1-63."));
QComboBox *compression_box = new QComboBox();
compression_box->setToolTip(tr(
"This parameter governs the quality/size trade-off.\n"
"Higher CRF values will result in a final output that takes less space, but begins to lose detail.\n"
"Lower CRF values retain more detail at the cost of larger file sizes.\n"
"The possible range of CRF in SVT-AV1 is 1-63."));
// These items must correspond to the CompressionMethod enum
compression_box->addItem(tr("Constant Rate Factor"));
// These items must correspond to the CompressionMethod enum
compression_box->addItem(tr("Constant Rate Factor"));
layout->addWidget(compression_box, row, 1);
layout->addWidget(compression_box, row, 1);
row++;
row++;
compression_method_stack_ = new QStackedWidget();
layout->addWidget(compression_method_stack_, row, 0, 1, 2);
compression_method_stack_ = new QStackedWidget();
layout->addWidget(compression_method_stack_, row, 0, 1, 2);
crf_section_ = new AV1CRFSection(default_crf);
compression_method_stack_->addWidget(crf_section_);
crf_section_ = new AV1CRFSection(default_crf);
compression_method_stack_->addWidget(crf_section_);
connect(compression_box,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
compression_method_stack_,
&QStackedWidget::setCurrentIndex);
connect(
compression_box,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
compression_method_stack_, &QStackedWidget::setCurrentIndex);
}
void AV1Section::AddOpts(EncodingParams *params)
{
CompressionMethod method = static_cast<CompressionMethod>(
compression_method_stack_->currentIndex());
CompressionMethod method = static_cast<CompressionMethod>(compression_method_stack_->currentIndex());
if (method == kConstantRateFactor) {
// Set Quantizer value
params->set_video_option(QStringLiteral("qp"),
QString::number(crf_section_->GetValue()));
}
if (method == kConstantRateFactor) {
// Set Quantizer value
params->set_video_option(QStringLiteral("qp"), QString::number(crf_section_->GetValue()));
}
params->set_video_option(QStringLiteral("preset"), QString::number(preset_combobox_->currentIndex()));
params->set_video_option(QStringLiteral("preset"),
QString::number(preset_combobox_->currentIndex()));
}
AV1CRFSection::AV1CRFSection(int default_crf, QWidget *parent) :
QWidget(parent)
AV1CRFSection::AV1CRFSection(int default_crf, QWidget *parent)
: QWidget(parent)
{
QHBoxLayout* layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
crf_slider_ = new QSlider(Qt::Horizontal);
crf_slider_->setMinimum(kMinimumCRF);
crf_slider_->setMaximum(kMaximumCRF);
crf_slider_->setValue(default_crf);
layout->addWidget(crf_slider_);
crf_slider_ = new QSlider(Qt::Horizontal);
crf_slider_->setMinimum(kMinimumCRF);
crf_slider_->setMaximum(kMaximumCRF);
crf_slider_->setValue(default_crf);
layout->addWidget(crf_slider_);
IntegerSlider* crf_input = new IntegerSlider();
crf_input->setMaximumWidth(QtUtils::QFontMetricsWidth(crf_input->fontMetrics(), QStringLiteral("HHHH")));
crf_input->SetMinimum(kMinimumCRF);
crf_input->SetMaximum(kMaximumCRF);
crf_input->SetValue(default_crf);
crf_input->SetDefaultValue(default_crf);
layout->addWidget(crf_input);
IntegerSlider *crf_input = new IntegerSlider();
crf_input->setMaximumWidth(QtUtils::QFontMetricsWidth(
crf_input->fontMetrics(), QStringLiteral("HHHH")));
crf_input->SetMinimum(kMinimumCRF);
crf_input->SetMaximum(kMaximumCRF);
crf_input->SetValue(default_crf);
crf_input->SetDefaultValue(default_crf);
layout->addWidget(crf_input);
connect(crf_slider_, &QSlider::valueChanged, crf_input, &IntegerSlider::SetValue);
connect(crf_input, &IntegerSlider::ValueChanged, crf_slider_, &QSlider::setValue);
connect(crf_slider_, &QSlider::valueChanged, crf_input,
&IntegerSlider::SetValue);
connect(crf_input, &IntegerSlider::ValueChanged, crf_slider_,
&QSlider::setValue);
}
int AV1CRFSection::GetValue() const
{
return crf_slider_->value();
return crf_slider_->value();
}
}
+21 -23
View File
@@ -28,45 +28,43 @@
#include "codecsection.h"
#include "widget/slider/floatslider.h"
namespace olive {
class AV1CRFSection : public QWidget
namespace olive
{
Q_OBJECT
class AV1CRFSection : public QWidget {
Q_OBJECT
public:
AV1CRFSection(int default_crf, QWidget* parent = nullptr);
AV1CRFSection(int default_crf, QWidget *parent = nullptr);
int GetValue() const;
int GetValue() const;
static const int kDefaultAV1CRF = 30;
static const int kDefaultAV1CRF = 30;
private:
static const int kMinimumCRF = 0;
static const int kMaximumCRF = 63;
QSlider* crf_slider_;
static const int kMinimumCRF = 0;
static const int kMaximumCRF = 63;
QSlider *crf_slider_;
};
class AV1Section : public CodecSection
{
Q_OBJECT
class AV1Section : public CodecSection {
Q_OBJECT
public:
enum CompressionMethod {
kConstantRateFactor,
};
enum CompressionMethod {
kConstantRateFactor,
};
AV1Section(QWidget* parent = nullptr);
AV1Section(int default_crf, QWidget* parent);
AV1Section(QWidget *parent = nullptr);
AV1Section(int default_crf, QWidget *parent);
virtual void AddOpts(EncodingParams* params) override;
virtual void AddOpts(EncodingParams *params) override;
private:
QStackedWidget* compression_method_stack_;
QStackedWidget *compression_method_stack_;
AV1CRFSection* crf_section_;
AV1CRFSection *crf_section_;
QComboBox *preset_combobox_;
QComboBox *preset_combobox_;
};
}
+32 -28
View File
@@ -23,22 +23,23 @@
#include <QGridLayout>
#include <QLabel>
namespace olive {
CineformSection::CineformSection(QWidget *parent) :
CodecSection(parent)
namespace olive
{
QGridLayout *layout = new QGridLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
CineformSection::CineformSection(QWidget *parent)
: CodecSection(parent)
{
QGridLayout *layout = new QGridLayout(this);
int row = 0;
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(new QLabel(tr("Quality:")), row, 0);
int row = 0;
quality_combobox_ = new QComboBox();
layout->addWidget(new QLabel(tr("Quality:")), row, 0);
/* Correspond to the following indexes for FFmpeg
quality_combobox_ = new QComboBox();
/* Correspond to the following indexes for FFmpeg
*
* -quality <int> E..V....... set quality (from 0 to 12) (default film3+)
* film3+ 0 E..V.......
@@ -57,34 +58,37 @@ CineformSection::CineformSection(QWidget *parent) :
*
*/
quality_combobox_->addItem(tr("Film Scan 3+"));
quality_combobox_->addItem(tr("Film Scan 3"));
quality_combobox_->addItem(tr("Film Scan 2+"));
quality_combobox_->addItem(tr("Film Scan 2"));
quality_combobox_->addItem(tr("Film Scan 1.5"));
quality_combobox_->addItem(tr("Film Scan 1+"));
quality_combobox_->addItem(tr("Film Scan 1"));
quality_combobox_->addItem(tr("High+"));
quality_combobox_->addItem(tr("High"));
quality_combobox_->addItem(tr("Medium+"));
quality_combobox_->addItem(tr("Medium"));
quality_combobox_->addItem(tr("Low+"));
quality_combobox_->addItem(tr("Low"));
quality_combobox_->addItem(tr("Film Scan 3+"));
quality_combobox_->addItem(tr("Film Scan 3"));
quality_combobox_->addItem(tr("Film Scan 2+"));
quality_combobox_->addItem(tr("Film Scan 2"));
quality_combobox_->addItem(tr("Film Scan 1.5"));
quality_combobox_->addItem(tr("Film Scan 1+"));
quality_combobox_->addItem(tr("Film Scan 1"));
quality_combobox_->addItem(tr("High+"));
quality_combobox_->addItem(tr("High"));
quality_combobox_->addItem(tr("Medium+"));
quality_combobox_->addItem(tr("Medium"));
quality_combobox_->addItem(tr("Low+"));
quality_combobox_->addItem(tr("Low"));
// Default to "medium"
quality_combobox_->setCurrentIndex(10);
// Default to "medium"
quality_combobox_->setCurrentIndex(10);
layout->addWidget(quality_combobox_, row, 1);
layout->addWidget(quality_combobox_, row, 1);
}
void CineformSection::AddOpts(EncodingParams *params)
{
params->set_video_option(QStringLiteral("quality"), QString::number(quality_combobox_->currentIndex()));
params->set_video_option(
QStringLiteral("quality"),
QString::number(quality_combobox_->currentIndex()));
}
void CineformSection::SetOpts(const EncodingParams *p)
{
quality_combobox_->setCurrentIndex(p->video_option(QStringLiteral("quality")).toInt());
quality_combobox_->setCurrentIndex(
p->video_option(QStringLiteral("quality")).toInt());
}
}
+8 -9
View File
@@ -25,21 +25,20 @@
#include "codecsection.h"
namespace olive {
class CineformSection : public CodecSection
namespace olive
{
Q_OBJECT
class CineformSection : public CodecSection {
Q_OBJECT
public:
CineformSection(QWidget *parent = nullptr);
CineformSection(QWidget *parent = nullptr);
virtual void AddOpts(EncodingParams* params) override;
virtual void AddOpts(EncodingParams *params) override;
virtual void SetOpts(const EncodingParams *p) override;
virtual void SetOpts(const EncodingParams *p) override;
private:
QComboBox *quality_combobox_;
QComboBox *quality_combobox_;
};
}
+4 -3
View File
@@ -20,10 +20,11 @@
#include "codecsection.h"
namespace olive {
namespace olive
{
CodecSection::CodecSection(QWidget *parent) :
QWidget(parent)
CodecSection::CodecSection(QWidget *parent)
: QWidget(parent)
{
}
+13 -8
View File
@@ -25,18 +25,23 @@
#include "codec/encoder.h"
namespace olive {
class CodecSection : public QWidget
namespace olive
{
Q_OBJECT
class CodecSection : public QWidget {
Q_OBJECT
public:
CodecSection(QWidget* parent = nullptr);
CodecSection(QWidget *parent = nullptr);
virtual void AddOpts(EncodingParams* params){Q_UNUSED(params)}
virtual void SetOpts(const EncodingParams *p){Q_UNUSED(p)}
virtual void AddOpts(EncodingParams *params)
{
Q_UNUSED(params)
}
virtual void SetOpts(const EncodingParams *p)
{
Q_UNUSED(p)
}
};
}
+17 -14
View File
@@ -20,34 +20,37 @@
#include "codecstack.h"
namespace olive {
namespace olive
{
#define super QStackedWidget
CodecStack::CodecStack(QWidget *parent)
: super{parent}
: super{ parent }
{
connect(this, &CodecStack::currentChanged, this, &CodecStack::OnChange);
connect(this, &CodecStack::currentChanged, this, &CodecStack::OnChange);
}
void CodecStack::addWidget(QWidget *widget)
{
super::addWidget(widget);
super::addWidget(widget);
OnChange(currentIndex());
OnChange(currentIndex());
}
void CodecStack::OnChange(int index)
{
for (int i=0; i<count(); i++) {
if (i == index) {
widget(i)->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
} else {
widget(i)->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
}
widget(i)->adjustSize();
}
adjustSize();
for (int i = 0; i < count(); i++) {
if (i == index) {
widget(i)->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Expanding);
} else {
widget(i)->setSizePolicy(QSizePolicy::Ignored,
QSizePolicy::Ignored);
}
widget(i)->adjustSize();
}
adjustSize();
}
}
+8 -9
View File
@@ -23,21 +23,20 @@
#include <QStackedWidget>
namespace olive {
class CodecStack : public QStackedWidget
namespace olive
{
Q_OBJECT
public:
explicit CodecStack(QWidget *parent = nullptr);
void addWidget(QWidget *widget);
class CodecStack : public QStackedWidget {
Q_OBJECT
public:
explicit CodecStack(QWidget *parent = nullptr);
void addWidget(QWidget *widget);
signals:
private slots:
void OnChange(int index);
void OnChange(int index);
};
}
+174 -164
View File
@@ -28,274 +28,284 @@
#include "common/qtutils.h"
#include "widget/slider/integerslider.h"
namespace olive {
namespace olive
{
H264Section::H264Section(QWidget *parent) :
H264Section(H264CRFSection::kDefaultH264CRF, parent)
H264Section::H264Section(QWidget *parent)
: H264Section(H264CRFSection::kDefaultH264CRF, parent)
{
}
H264Section::H264Section(int default_crf, QWidget *parent) :
CodecSection(parent)
H264Section::H264Section(int default_crf, QWidget *parent)
: CodecSection(parent)
{
QGridLayout* layout = new QGridLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
QGridLayout *layout = new QGridLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
int row = 0;
layout->addWidget(new QLabel(tr("Encode Speed:")), row, 0);
int row = 0;
layout->addWidget(new QLabel(tr("Encode Speed:")), row, 0);
preset_combobox_ = new QComboBox();
preset_combobox_->setToolTip(tr(
"This setting allows you to tweak the ratio of export speed to compression quality. \n\n"
"If using Constant Rate Factor, slower speeds will result in smaller file sizes for the same quality. \n\n"
"If using Target Bit Rate or Target File Size, slower speeds will result in higher quality for the same bitrate/filesize. \n\n"
"This setting is equivalent to the `preset` setting in libx264."));
preset_combobox_ = new QComboBox();
preset_combobox_->setToolTip(tr("This setting allows you to tweak the ratio of export speed to compression quality. \n\n"
"If using Constant Rate Factor, slower speeds will result in smaller file sizes for the same quality. \n\n"
"If using Target Bit Rate or Target File Size, slower speeds will result in higher quality for the same bitrate/filesize. \n\n"
"This setting is equivalent to the `preset` setting in libx264."));
preset_combobox_->addItem(tr("Ultra Fast"));
preset_combobox_->addItem(tr("Super Fast"));
preset_combobox_->addItem(tr("Very Fast"));
preset_combobox_->addItem(tr("Faster"));
preset_combobox_->addItem(tr("Fast"));
preset_combobox_->addItem(tr("Medium"));
preset_combobox_->addItem(tr("Slow"));
preset_combobox_->addItem(tr("Slower"));
preset_combobox_->addItem(tr("Very Slow"));
preset_combobox_->addItem(tr("Ultra Fast"));
preset_combobox_->addItem(tr("Super Fast"));
preset_combobox_->addItem(tr("Very Fast"));
preset_combobox_->addItem(tr("Faster"));
preset_combobox_->addItem(tr("Fast"));
preset_combobox_->addItem(tr("Medium"));
preset_combobox_->addItem(tr("Slow"));
preset_combobox_->addItem(tr("Slower"));
preset_combobox_->addItem(tr("Very Slow"));
//Default to "medium"
preset_combobox_->setCurrentIndex(5);
//Default to "medium"
preset_combobox_->setCurrentIndex(5);
layout->addWidget(preset_combobox_, row, 1);
layout->addWidget(preset_combobox_, row, 1);
row++;
row++;
layout->addWidget(new QLabel(tr("Compression Method:")), row, 0);
layout->addWidget(new QLabel(tr("Compression Method:")), row, 0);
QComboBox *compression_box = new QComboBox();
QComboBox* compression_box = new QComboBox();
// These items must correspond to the CompressionMethod enum
compression_box->addItem(tr("Constant Rate Factor"));
compression_box->addItem(tr("Target Bit Rate"));
compression_box->addItem(tr("Target File Size"));
// These items must correspond to the CompressionMethod enum
compression_box->addItem(tr("Constant Rate Factor"));
compression_box->addItem(tr("Target Bit Rate"));
compression_box->addItem(tr("Target File Size"));
layout->addWidget(compression_box, row, 1);
layout->addWidget(compression_box, row, 1);
row++;
row++;
compression_method_stack_ = new QStackedWidget();
layout->addWidget(compression_method_stack_, row, 0, 1, 2);
compression_method_stack_ = new QStackedWidget();
layout->addWidget(compression_method_stack_, row, 0, 1, 2);
crf_section_ = new H264CRFSection(default_crf);
compression_method_stack_->addWidget(crf_section_);
crf_section_ = new H264CRFSection(default_crf);
compression_method_stack_->addWidget(crf_section_);
bitrate_section_ = new H264BitRateSection();
compression_method_stack_->addWidget(bitrate_section_);
bitrate_section_ = new H264BitRateSection();
compression_method_stack_->addWidget(bitrate_section_);
filesize_section_ = new H264FileSizeSection();
compression_method_stack_->addWidget(filesize_section_);
filesize_section_ = new H264FileSizeSection();
compression_method_stack_->addWidget(filesize_section_);
connect(compression_box,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
compression_method_stack_,
&QStackedWidget::setCurrentIndex);
connect(
compression_box,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
compression_method_stack_, &QStackedWidget::setCurrentIndex);
}
void H264Section::AddOpts(EncodingParams *params)
{
// FIXME: Implement two-pass
// FIXME: Implement two-pass
CompressionMethod method = static_cast<CompressionMethod>(compression_method_stack_->currentIndex());
CompressionMethod method = static_cast<CompressionMethod>(
compression_method_stack_->currentIndex());
// This option is not used by the encoder (nor is anything with the ove_ prefix), it's to help us
// identify which option was chosen when params are restored
params->set_video_option(QStringLiteral("ove_compressionmethod"), QString::number(method));
// This option is not used by the encoder (nor is anything with the ove_ prefix), it's to help us
// identify which option was chosen when params are restored
params->set_video_option(QStringLiteral("ove_compressionmethod"),
QString::number(method));
if (method == kConstantRateFactor) {
if (method == kConstantRateFactor) {
// Simply set CRF value
params->set_video_option(QStringLiteral("crf"),
QString::number(crf_section_->GetValue()));
// Simply set CRF value
params->set_video_option(QStringLiteral("crf"), QString::number(crf_section_->GetValue()));
} else {
int64_t target_rate, max_rate, min_rate;
} else {
if (method == kTargetBitRate) {
// Use user-supplied values for the bit rate
target_rate = bitrate_section_->GetTargetBitRate();
min_rate = 0;
max_rate = bitrate_section_->GetMaximumBitRate();
} else {
// Calculate the bit rate from the file size divided by the sequence length in seconds (bits per second)
int64_t target_fs = filesize_section_->GetFileSize();
target_rate = qRound64(static_cast<double>(target_fs) /
params->GetExportLength().toDouble());
min_rate = target_rate;
max_rate = target_rate;
int64_t target_rate, max_rate, min_rate;
params->set_video_option(QStringLiteral("ove_targetfilesize"),
QString::number(target_fs));
}
if (method == kTargetBitRate) {
// Use user-supplied values for the bit rate
target_rate = bitrate_section_->GetTargetBitRate();
min_rate = 0;
max_rate = bitrate_section_->GetMaximumBitRate();
} else {
// Calculate the bit rate from the file size divided by the sequence length in seconds (bits per second)
int64_t target_fs = filesize_section_->GetFileSize();
target_rate = qRound64(static_cast<double>(target_fs) / params->GetExportLength().toDouble());
min_rate = target_rate;
max_rate = target_rate;
// Disable CRF encoding
params->set_video_option(QStringLiteral("crf"), QStringLiteral("-1"));
params->set_video_option(QStringLiteral("ove_targetfilesize"), QString::number(target_fs));
}
params->set_video_bit_rate(target_rate);
params->set_video_min_bit_rate(min_rate);
params->set_video_max_bit_rate(max_rate);
params->set_video_buffer_size(2000000);
}
// Disable CRF encoding
params->set_video_option(QStringLiteral("crf"), QStringLiteral("-1"));
params->set_video_bit_rate(target_rate);
params->set_video_min_bit_rate(min_rate);
params->set_video_max_bit_rate(max_rate);
params->set_video_buffer_size(2000000);
}
params->set_video_option(QStringLiteral("preset"), QString::number(preset_combobox_->currentIndex()));
params->set_video_option(QStringLiteral("preset"),
QString::number(preset_combobox_->currentIndex()));
}
void H264Section::SetOpts(const EncodingParams *p)
{
CompressionMethod method = static_cast<CompressionMethod>(p->video_option(QStringLiteral("ove_compressionmethod")).toInt());
CompressionMethod method = static_cast<CompressionMethod>(
p->video_option(QStringLiteral("ove_compressionmethod")).toInt());
compression_method_stack_->setCurrentIndex(method);
compression_method_stack_->setCurrentIndex(method);
if (method == kConstantRateFactor) {
crf_section_->SetValue(p->video_option(QStringLiteral("crf")).toInt());
} else {
int64_t target_rate = p->video_bit_rate();
int64_t max_rate = p->video_max_bit_rate();
if (method == kConstantRateFactor) {
crf_section_->SetValue(p->video_option(QStringLiteral("crf")).toInt());
} else {
int64_t target_rate = p->video_bit_rate();
int64_t max_rate = p->video_max_bit_rate();
if (method == kTargetBitRate) {
// Use user-supplied values for the bit rate
bitrate_section_->SetTargetBitRate(target_rate);
bitrate_section_->SetMaximumBitRate(max_rate);
} else {
// Calculate the bit rate from the file size divided by the sequence length in seconds (bits per second)
filesize_section_->SetFileSize(p->video_option(QStringLiteral("ove_targetfilesize")).toLongLong());
}
}
if (method == kTargetBitRate) {
// Use user-supplied values for the bit rate
bitrate_section_->SetTargetBitRate(target_rate);
bitrate_section_->SetMaximumBitRate(max_rate);
} else {
// Calculate the bit rate from the file size divided by the sequence length in seconds (bits per second)
filesize_section_->SetFileSize(
p->video_option(QStringLiteral("ove_targetfilesize"))
.toLongLong());
}
}
}
H264CRFSection::H264CRFSection(int default_crf, QWidget *parent) :
QWidget(parent)
H264CRFSection::H264CRFSection(int default_crf, QWidget *parent)
: QWidget(parent)
{
QHBoxLayout* layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
crf_slider_ = new QSlider(Qt::Horizontal);
crf_slider_->setMinimum(kMinimumCRF);
crf_slider_->setMaximum(kMaximumCRF);
crf_slider_->setValue(default_crf);
layout->addWidget(crf_slider_);
crf_slider_ = new QSlider(Qt::Horizontal);
crf_slider_->setMinimum(kMinimumCRF);
crf_slider_->setMaximum(kMaximumCRF);
crf_slider_->setValue(default_crf);
layout->addWidget(crf_slider_);
IntegerSlider* crf_input = new IntegerSlider();
crf_input->setMaximumWidth(QtUtils::QFontMetricsWidth(crf_input->fontMetrics(), QStringLiteral("HHHH")));
crf_input->SetMinimum(kMinimumCRF);
crf_input->SetMaximum(kMaximumCRF);
crf_input->SetValue(default_crf);
crf_input->SetDefaultValue(default_crf);
layout->addWidget(crf_input);
IntegerSlider *crf_input = new IntegerSlider();
crf_input->setMaximumWidth(QtUtils::QFontMetricsWidth(
crf_input->fontMetrics(), QStringLiteral("HHHH")));
crf_input->SetMinimum(kMinimumCRF);
crf_input->SetMaximum(kMaximumCRF);
crf_input->SetValue(default_crf);
crf_input->SetDefaultValue(default_crf);
layout->addWidget(crf_input);
connect(crf_slider_, &QSlider::valueChanged, crf_input, &IntegerSlider::SetValue);
connect(crf_input, &IntegerSlider::ValueChanged, crf_slider_, &QSlider::setValue);
connect(crf_slider_, &QSlider::valueChanged, crf_input,
&IntegerSlider::SetValue);
connect(crf_input, &IntegerSlider::ValueChanged, crf_slider_,
&QSlider::setValue);
}
int H264CRFSection::GetValue() const
{
return crf_slider_->value();
return crf_slider_->value();
}
void H264CRFSection::SetValue(int c)
{
crf_slider_->setValue(c);
crf_slider_->setValue(c);
}
H264BitRateSection::H264BitRateSection(QWidget *parent) :
QWidget(parent)
H264BitRateSection::H264BitRateSection(QWidget *parent)
: QWidget(parent)
{
QGridLayout* layout = new QGridLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
QGridLayout *layout = new QGridLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
int row = 0;
int row = 0;
layout->addWidget(new QLabel(tr("Target Bit Rate (Mbps):")), row, 0);
layout->addWidget(new QLabel(tr("Target Bit Rate (Mbps):")), row, 0);
target_rate_ = new FloatSlider();
target_rate_->SetMinimum(0);
layout->addWidget(target_rate_, row, 1);
target_rate_ = new FloatSlider();
target_rate_->SetMinimum(0);
layout->addWidget(target_rate_, row, 1);
row++;
row++;
layout->addWidget(new QLabel(tr("Maximum Bit Rate (Mbps):")), row, 0);
layout->addWidget(new QLabel(tr("Maximum Bit Rate (Mbps):")), row, 0);
max_rate_ = new FloatSlider();
max_rate_->SetMinimum(0);
layout->addWidget(max_rate_, row, 1);
max_rate_ = new FloatSlider();
max_rate_->SetMinimum(0);
layout->addWidget(max_rate_, row, 1);
row++;
row++;
layout->addWidget(new QLabel(tr("Two-Pass")), row, 0);
layout->addWidget(new QLabel(tr("Two-Pass")), row, 0);
QCheckBox* two_pass_box = new QCheckBox();
layout->addWidget(two_pass_box, row, 1);
QCheckBox *two_pass_box = new QCheckBox();
layout->addWidget(two_pass_box, row, 1);
// Bit rate defaults
target_rate_->SetValue(16.0);
max_rate_->SetValue(32.0);
// Bit rate defaults
target_rate_->SetValue(16.0);
max_rate_->SetValue(32.0);
}
int64_t H264BitRateSection::GetTargetBitRate() const
{
return qRound64(target_rate_->GetValue() * 1000000.0);
return qRound64(target_rate_->GetValue() * 1000000.0);
}
void H264BitRateSection::SetTargetBitRate(int64_t b)
{
target_rate_->SetValue(double(b) * 0.000001);
target_rate_->SetValue(double(b) * 0.000001);
}
int64_t H264BitRateSection::GetMaximumBitRate() const
{
return qRound64(max_rate_->GetValue() * 1000000.0);
return qRound64(max_rate_->GetValue() * 1000000.0);
}
void H264BitRateSection::SetMaximumBitRate(int64_t b)
{
max_rate_->SetValue(double(b) * 0.000001);
max_rate_->SetValue(double(b) * 0.000001);
}
H264FileSizeSection::H264FileSizeSection(QWidget *parent) :
QWidget(parent)
H264FileSizeSection::H264FileSizeSection(QWidget *parent)
: QWidget(parent)
{
QGridLayout* layout = new QGridLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
QGridLayout *layout = new QGridLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
int row = 0;
int row = 0;
layout->addWidget(new QLabel(tr("Target File Size (MB):")), row, 0);
layout->addWidget(new QLabel(tr("Target File Size (MB):")), row, 0);
file_size_ = new FloatSlider();
file_size_->SetMinimum(0);
layout->addWidget(file_size_, row, 1);
file_size_ = new FloatSlider();
file_size_->SetMinimum(0);
layout->addWidget(file_size_, row, 1);
row++;
row++;
layout->addWidget(new QLabel(tr("Two-Pass")), row, 0);
layout->addWidget(new QLabel(tr("Two-Pass")), row, 0);
QCheckBox* two_pass_box = new QCheckBox();
layout->addWidget(two_pass_box, row, 1);
QCheckBox *two_pass_box = new QCheckBox();
layout->addWidget(two_pass_box, row, 1);
// File size defaults
file_size_->SetValue(700.0);
// File size defaults
file_size_->SetValue(700.0);
}
int64_t H264FileSizeSection::GetFileSize() const
{
// Convert megabytes to BITS
return qRound64(file_size_->GetValue() * 1024.0 * 1024.0 * 8.0);
// Convert megabytes to BITS
return qRound64(file_size_->GetValue() * 1024.0 * 1024.0 * 8.0);
}
void H264FileSizeSection::SetFileSize(int64_t f)
{
// Convert bits back to megabytes
file_size_->SetValue(double(f) / 8.0 / 1024.0 / 1024.0);
// Convert bits back to megabytes
file_size_->SetValue(double(f) / 8.0 / 1024.0 / 1024.0);
}
H265Section::H265Section(QWidget *parent) :
H264Section(H264CRFSection::kDefaultH265CRF, parent)
H265Section::H265Section(QWidget *parent)
: H264Section(H264CRFSection::kDefaultH265CRF, parent)
{
}
+49 -56
View File
@@ -28,104 +28,97 @@
#include "codecsection.h"
#include "widget/slider/floatslider.h"
namespace olive {
class H264CRFSection : public QWidget
namespace olive
{
Q_OBJECT
class H264CRFSection : public QWidget {
Q_OBJECT
public:
H264CRFSection(int default_crf, QWidget* parent = nullptr);
H264CRFSection(int default_crf, QWidget *parent = nullptr);
int GetValue() const;
void SetValue(int c);
int GetValue() const;
void SetValue(int c);
static const int kDefaultH264CRF = 18;
static const int kDefaultH265CRF = 23;
static const int kDefaultH264CRF = 18;
static const int kDefaultH265CRF = 23;
private:
static const int kMinimumCRF = 0;
static const int kMaximumCRF = 51;
QSlider* crf_slider_;
static const int kMinimumCRF = 0;
static const int kMaximumCRF = 51;
QSlider *crf_slider_;
};
class H264BitRateSection : public QWidget
{
Q_OBJECT
class H264BitRateSection : public QWidget {
Q_OBJECT
public:
H264BitRateSection(QWidget* parent = nullptr);
H264BitRateSection(QWidget *parent = nullptr);
/**
/**
* @brief Get user-selected target bit rate (returns in BITS)
*/
int64_t GetTargetBitRate() const;
void SetTargetBitRate(int64_t b);
int64_t GetTargetBitRate() const;
void SetTargetBitRate(int64_t b);
/**
/**
* @brief Get user-selected maximum bit rate (returns in BITS)
*/
int64_t GetMaximumBitRate() const;
void SetMaximumBitRate(int64_t b);
int64_t GetMaximumBitRate() const;
void SetMaximumBitRate(int64_t b);
private:
FloatSlider* target_rate_;
FloatSlider* max_rate_;
FloatSlider *target_rate_;
FloatSlider *max_rate_;
};
class H264FileSizeSection : public QWidget
{
Q_OBJECT
class H264FileSizeSection : public QWidget {
Q_OBJECT
public:
H264FileSizeSection(QWidget* parent = nullptr);
H264FileSizeSection(QWidget *parent = nullptr);
/**
/**
* @brief Returns file size in BITS
*/
int64_t GetFileSize() const;
void SetFileSize(int64_t f);
int64_t GetFileSize() const;
void SetFileSize(int64_t f);
private:
FloatSlider* file_size_;
FloatSlider *file_size_;
};
class H264Section : public CodecSection
{
Q_OBJECT
class H264Section : public CodecSection {
Q_OBJECT
public:
enum CompressionMethod {
kConstantRateFactor,
kTargetBitRate,
kTargetFileSize
};
enum CompressionMethod {
kConstantRateFactor,
kTargetBitRate,
kTargetFileSize
};
H264Section(QWidget* parent = nullptr);
H264Section(int default_crf, QWidget* parent);
H264Section(QWidget *parent = nullptr);
H264Section(int default_crf, QWidget *parent);
virtual void AddOpts(EncodingParams* params) override;
virtual void AddOpts(EncodingParams *params) override;
virtual void SetOpts(const EncodingParams *p) override;
virtual void SetOpts(const EncodingParams *p) override;
private:
QStackedWidget* compression_method_stack_;
QStackedWidget *compression_method_stack_;
H264CRFSection* crf_section_;
H264CRFSection *crf_section_;
H264BitRateSection* bitrate_section_;
H264BitRateSection *bitrate_section_;
H264FileSizeSection* filesize_section_;
H264FileSizeSection *filesize_section_;
QComboBox *preset_combobox_;
QComboBox *preset_combobox_;
};
class H265Section : public H264Section
{
Q_OBJECT
class H265Section : public H264Section {
Q_OBJECT
public:
H265Section(QWidget* parent = nullptr);
H265Section(QWidget *parent = nullptr);
};
}
+23 -20
View File
@@ -23,37 +23,40 @@
#include <QGridLayout>
#include <QLabel>
namespace olive {
ImageSection::ImageSection(QWidget* parent) :
CodecSection(parent)
namespace olive
{
QGridLayout* layout = new QGridLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
int row = 0;
ImageSection::ImageSection(QWidget *parent)
: CodecSection(parent)
{
QGridLayout *layout = new QGridLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(new QLabel(tr("Image Sequence:")), row, 0);
int row = 0;
image_sequence_checkbox_ = new QCheckBox();
connect(image_sequence_checkbox_, &QCheckBox::toggled, this, &ImageSection::ImageSequenceCheckBoxToggled);
layout->addWidget(image_sequence_checkbox_, row, 1);
layout->addWidget(new QLabel(tr("Image Sequence:")), row, 0);
row++;
image_sequence_checkbox_ = new QCheckBox();
connect(image_sequence_checkbox_, &QCheckBox::toggled, this,
&ImageSection::ImageSequenceCheckBoxToggled);
layout->addWidget(image_sequence_checkbox_, row, 1);
layout->addWidget(new QLabel(tr("Frame to Export:")), row, 0);
row++;
frame_slider_ = new RationalSlider();
frame_slider_->SetMinimum(0);
frame_slider_->SetValue(0);
frame_slider_->SetDisplayType(RationalSlider::kTime);
connect(frame_slider_, &RationalSlider::ValueChanged, this, &ImageSection::TimeChanged);
layout->addWidget(frame_slider_, row, 1);
layout->addWidget(new QLabel(tr("Frame to Export:")), row, 0);
frame_slider_ = new RationalSlider();
frame_slider_->SetMinimum(0);
frame_slider_->SetValue(0);
frame_slider_->SetDisplayType(RationalSlider::kTime);
connect(frame_slider_, &RationalSlider::ValueChanged, this,
&ImageSection::TimeChanged);
layout->addWidget(frame_slider_, row, 1);
}
void ImageSection::ImageSequenceCheckBoxToggled(bool e)
{
frame_slider_->setEnabled(!e);
frame_slider_->setEnabled(!e);
}
}
+29 -30
View File
@@ -26,50 +26,49 @@
#include "codecsection.h"
#include "widget/slider/rationalslider.h"
namespace olive {
class ImageSection : public CodecSection
namespace olive
{
Q_OBJECT
class ImageSection : public CodecSection {
Q_OBJECT
public:
ImageSection(QWidget* parent = nullptr);
ImageSection(QWidget *parent = nullptr);
bool IsImageSequenceChecked() const
{
return image_sequence_checkbox_->isChecked();
}
bool IsImageSequenceChecked() const
{
return image_sequence_checkbox_->isChecked();
}
void SetImageSequenceChecked(bool e)
{
image_sequence_checkbox_->setChecked(e);
}
void SetImageSequenceChecked(bool e)
{
image_sequence_checkbox_->setChecked(e);
}
void SetTimebase(const rational& r)
{
frame_slider_->SetTimebase(r);
}
void SetTimebase(const rational &r)
{
frame_slider_->SetTimebase(r);
}
rational GetTime() const
{
return frame_slider_->GetValue();
}
rational GetTime() const
{
return frame_slider_->GetValue();
}
void SetTime(const rational &t)
{
frame_slider_->SetValue(t);
}
void SetTime(const rational &t)
{
frame_slider_->SetValue(t);
}
signals:
void TimeChanged(const rational &t);
void TimeChanged(const rational &t);
private:
QCheckBox* image_sequence_checkbox_;
QCheckBox *image_sequence_checkbox_;
RationalSlider* frame_slider_;
RationalSlider *frame_slider_;
private slots:
void ImageSequenceCheckBoxToggled(bool e);
void ImageSequenceCheckBoxToggled(bool e);
};
}