Skip to content

Commit 189520e

Browse files
committed
Implement QP 0 lossless x264 encoding
1 parent 5626e6a commit 189520e

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

app/dialog/export/codec/h264section.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ H264Section::H264Section(int default_crf, QWidget *parent) :
7474

7575
// These items must correspond to the CompressionMethod enum
7676
compression_box->addItem(tr("Constant Rate Factor"));
77+
compression_box->addItem(tr("Lossless"));
7778
compression_box->addItem(tr("Target Bit Rate"));
7879
compression_box->addItem(tr("Target File Size"));
7980

@@ -87,6 +88,9 @@ H264Section::H264Section(int default_crf, QWidget *parent) :
8788
crf_section_ = new H264CRFSection(default_crf);
8889
compression_method_stack_->addWidget(crf_section_);
8990

91+
lossless_section_ = new H264LosslessSection();
92+
compression_method_stack_->addWidget(lossless_section_);
93+
9094
bitrate_section_ = new H264BitRateSection();
9195
compression_method_stack_->addWidget(bitrate_section_);
9296

@@ -114,6 +118,10 @@ void H264Section::AddOpts(EncodingParams *params)
114118
// Simply set CRF value
115119
params->set_video_option(QStringLiteral("crf"), QString::number(crf_section_->GetValue()));
116120

121+
} else if (method == kLossless) {
122+
123+
params->set_video_option(QStringLiteral("qp"), QString::number(0));
124+
117125
} else {
118126

119127
int64_t target_rate, max_rate, min_rate;
@@ -237,6 +245,17 @@ H264BitRateSection::H264BitRateSection(QWidget *parent) :
237245
max_rate_->SetValue(32.0);
238246
}
239247

248+
H264LosslessSection::H264LosslessSection(QWidget *parent) :
249+
QWidget(parent)
250+
{
251+
QGridLayout* layout = new QGridLayout(this);
252+
layout->setMargin(0);
253+
254+
int row = 0;
255+
256+
layout->addWidget(new QLabel(tr("For true lossless, verify the pixel format before exporting")), row, 0);
257+
}
258+
240259
int64_t H264BitRateSection::GetTargetBitRate() const
241260
{
242261
return qRound64(target_rate_->GetValue() * 1000000.0);

app/dialog/export/codec/h264section.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ class H264CRFSection : public QWidget
5050

5151
};
5252

53+
class H264LosslessSection : public QWidget
54+
{
55+
Q_OBJECT
56+
public:
57+
H264LosslessSection(QWidget* parent = nullptr);
58+
};
59+
5360
class H264BitRateSection : public QWidget
5461
{
5562
Q_OBJECT
@@ -98,6 +105,7 @@ class H264Section : public CodecSection
98105
public:
99106
enum CompressionMethod {
100107
kConstantRateFactor,
108+
kLossless,
101109
kTargetBitRate,
102110
kTargetFileSize
103111
};
@@ -114,6 +122,8 @@ class H264Section : public CodecSection
114122

115123
H264CRFSection* crf_section_;
116124

125+
H264LosslessSection* lossless_section_;
126+
117127
H264BitRateSection* bitrate_section_;
118128

119129
H264FileSizeSection* filesize_section_;

0 commit comments

Comments
 (0)