app: migrate all engine access to the C ABI facade (nm U _ZN5olive = 0)

Every app module now reaches liboakengine exclusively through
oakengine_* C calls, EngineEventBridge subscriptions and app-side
handle headers (cliphandle/keyframehandle/nodevaluehandle/oakvaluehelper).
Direct C++ command construction, engine signal connect()s, and engine
type usage in MOC-visible signatures are gone: 557 -> 0 undefined
olive:: symbols in oak-editor.
This commit is contained in:
2026-07-26 22:43:21 +08:00
parent f95590e924
commit 0aa5879f35
256 changed files with 12357 additions and 4044 deletions
+7 -5
View File
@@ -89,19 +89,21 @@ AV1Section::AV1Section(int default_crf, QWidget *parent)
compression_method_stack_, &QStackedWidget::setCurrentIndex);
}
void AV1Section::add_opts(EncodingParams *params)
void AV1Section::add_opts(OakEngineEncodingParams *params)
{
CompressionMethod method = static_cast<CompressionMethod>(
compression_method_stack_->currentIndex());
if (method == k_constant_rate_factor) {
// Set Quantizer value
params->set_video_option(QStringLiteral("qp"),
QString::number(crf_section_->get_value()));
oakengine_encoding_params_set_video_option(
params, "qp",
QByteArray::number(crf_section_->get_value()).constData());
}
params->set_video_option(QStringLiteral("preset"),
QString::number(preset_combobox_->currentIndex()));
oakengine_encoding_params_set_video_option(
params, "preset",
QByteArray::number(preset_combobox_->currentIndex()).constData());
}
AV1CRFSection::AV1CRFSection(int default_crf, QWidget *parent)
+1 -1
View File
@@ -58,7 +58,7 @@ public:
AV1Section(QWidget *parent = nullptr);
AV1Section(int default_crf, QWidget *parent);
virtual void add_opts(EncodingParams *params) override;
virtual void add_opts(OakEngineEncodingParams *params) override;
private:
QStackedWidget *compression_method_stack_;
+11 -7
View File
@@ -79,17 +79,21 @@ CineformSection::CineformSection(QWidget *parent)
layout->addWidget(quality_combobox_, row, 1);
}
void CineformSection::add_opts(EncodingParams *params)
void CineformSection::add_opts(OakEngineEncodingParams *params)
{
params->set_video_option(
QStringLiteral("quality"),
QString::number(quality_combobox_->currentIndex()));
oakengine_encoding_params_set_video_option(
params, "quality",
QByteArray::number(quality_combobox_->currentIndex()).constData());
}
void CineformSection::set_opts(const EncodingParams *p)
void CineformSection::set_opts(const OakEngineEncodingParams *p)
{
quality_combobox_->setCurrentIndex(
p->video_option(QStringLiteral("quality")).toInt());
char buf[64];
const int ret = oakengine_encoding_params_video_option(
p, "quality", buf, static_cast<int>(sizeof(buf)));
if (ret > 0) {
quality_combobox_->setCurrentIndex(QString::fromUtf8(buf).toInt());
}
}
}
+2 -2
View File
@@ -34,9 +34,9 @@ class CineformSection : public CodecSection {
public:
CineformSection(QWidget *parent = nullptr);
virtual void add_opts(EncodingParams *params) override;
virtual void add_opts(OakEngineEncodingParams *params) override;
virtual void set_opts(const EncodingParams *p) override;
virtual void set_opts(const OakEngineEncodingParams *p) override;
private:
QComboBox *quality_combobox_;
+3 -3
View File
@@ -24,7 +24,7 @@
#include <QWidget>
#include "codec/encoder.h"
#include "oakengine/encoding.h"
namespace olive
{
@@ -34,12 +34,12 @@ class CodecSection : public QWidget {
public:
CodecSection(QWidget *parent = nullptr);
virtual void add_opts(EncodingParams *params)
virtual void add_opts(OakEngineEncodingParams *params)
{
Q_UNUSED(params)
}
virtual void set_opts(const EncodingParams *p)
virtual void set_opts(const OakEngineEncodingParams *p)
{
Q_UNUSED(p)
}
+48 -25
View File
@@ -101,7 +101,7 @@ H264Section::H264Section(int default_crf, QWidget *parent)
compression_method_stack_, &QStackedWidget::setCurrentIndex);
}
void H264Section::add_opts(EncodingParams *params)
void H264Section::add_opts(OakEngineEncodingParams *params)
{
// FIXME: Implement two-pass
@@ -110,13 +110,15 @@ void H264Section::add_opts(EncodingParams *params)
// 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));
oakengine_encoding_params_set_video_option(
params, "ove_compressionmethod",
QByteArray::number(method).constData());
if (method == k_constant_rate_factor) {
// Simply set CRF value
params->set_video_option(QStringLiteral("crf"),
QString::number(crf_section_->get_value()));
oakengine_encoding_params_set_video_option(
params, "crf",
QByteArray::number(crf_section_->get_value()).constData());
} else {
int64_t target_rate, max_rate, min_rate;
@@ -129,40 +131,58 @@ void H264Section::add_opts(EncodingParams *params)
} 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_->get_file_size();
target_rate = qRound64(static_cast<double>(target_fs) /
params->get_export_length().to_double());
int export_len_num = 0, export_len_den = 1;
oakengine_encoding_params_get_export_length(
params, &export_len_num, &export_len_den);
const double export_len_sec =
(export_len_den > 0)
? static_cast<double>(export_len_num)
/ static_cast<double>(export_len_den)
: 1.0;
target_rate = qRound64(static_cast<double>(target_fs) / export_len_sec);
min_rate = target_rate;
max_rate = target_rate;
params->set_video_option(QStringLiteral("ove_targetfilesize"),
QString::number(target_fs));
oakengine_encoding_params_set_video_option(
params, "ove_targetfilesize",
QByteArray::number(target_fs).constData());
}
// Disable CRF encoding
params->set_video_option(QStringLiteral("crf"), QStringLiteral("-1"));
oakengine_encoding_params_set_video_option(params, "crf", "-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);
oakengine_encoding_params_set_video_bit_rate(params, target_rate);
oakengine_encoding_params_set_video_min_bit_rate(params, min_rate);
oakengine_encoding_params_set_video_max_bit_rate(params, max_rate);
oakengine_encoding_params_set_video_buffer_size(params, 2000000);
}
params->set_video_option(QStringLiteral("preset"),
QString::number(preset_combobox_->currentIndex()));
oakengine_encoding_params_set_video_option(
params, "preset",
QByteArray::number(preset_combobox_->currentIndex()).constData());
}
void H264Section::set_opts(const EncodingParams *p)
void H264Section::set_opts(const OakEngineEncodingParams *p)
{
CompressionMethod method = static_cast<CompressionMethod>(
p->video_option(QStringLiteral("ove_compressionmethod")).toInt());
char buf[64];
CompressionMethod method = k_constant_rate_factor;
if (oakengine_encoding_params_video_option(
p, "ove_compressionmethod", buf,
static_cast<int>(sizeof(buf))) > 0) {
method = static_cast<CompressionMethod>(QString::fromUtf8(buf).toInt());
}
compression_method_stack_->setCurrentIndex(method);
if (method == k_constant_rate_factor) {
crf_section_->set_value(p->video_option(QStringLiteral("crf")).toInt());
if (oakengine_encoding_params_video_option(
p, "crf", buf, static_cast<int>(sizeof(buf))) > 0) {
crf_section_->set_value(QString::fromUtf8(buf).toInt());
}
} else {
int64_t target_rate = p->video_bit_rate();
int64_t max_rate = p->video_max_bit_rate();
int64_t target_rate = oakengine_encoding_params_video_bit_rate(p);
int64_t max_rate = oakengine_encoding_params_video_max_bit_rate(p);
if (method == k_target_bit_rate) {
// Use user-supplied values for the bit rate
@@ -170,9 +190,12 @@ void H264Section::set_opts(const EncodingParams *p)
bitrate_section_->set_maximum_bit_rate(max_rate);
} else {
// Calculate the bit rate from the file size divided by the sequence length in seconds (bits per second)
filesize_section_->set_file_size(
p->video_option(QStringLiteral("ove_targetfilesize"))
.toLongLong());
if (oakengine_encoding_params_video_option(
p, "ove_targetfilesize", buf,
static_cast<int>(sizeof(buf))) > 0) {
filesize_section_->set_file_size(
QString::fromUtf8(buf).toLongLong());
}
}
}
}
+2 -2
View File
@@ -100,9 +100,9 @@ public:
H264Section(QWidget *parent = nullptr);
H264Section(int default_crf, QWidget *parent);
virtual void add_opts(EncodingParams *params) override;
virtual void add_opts(OakEngineEncodingParams *params) override;
virtual void set_opts(const EncodingParams *p) override;
virtual void set_opts(const OakEngineEncodingParams *p) override;
private:
QStackedWidget *compression_method_stack_;
+358 -252
View File
@@ -33,16 +33,24 @@
#include "common/digit.h"
#include "common/qtutils.h"
#include "codec/ffmpeg/ffmpegencoder.h"
#include "codec/exportcodec.h"
#include "codec/exportformat.h"
#include "dialog/msgbox.h"
#include "dialog/task/task.h"
#include "exportsavepresetdialog.h"
#include "node/project.h"
#include "node/project/sequence/sequence.h"
#include "oakengine/events.h"
#include "widget/manageddisplay/colorprocessorhandle.h"
#include "widget/viewer/vieweroutpututils.h"
#include "oakengine/exporter.h"
#include "task/taskmanager.h"
#include "oakengine/project.h"
#include "oakengine/task.h"
#include "oakengine/encoding.h"
#include "oakengine/viewer.h"
#include "ui/icons/icons.h"
#include "widget/timeruler/timeruler.h"
#include "common/configwrapper.h"
namespace olive
{
@@ -54,159 +62,126 @@ namespace
// pix_fmt string (e.g. "yuv420p") to its index in the codec's supported
// list; 0 (the codec's preferred format) when absent.
int pix_fmt_index(ExportCodec::Codec codec, const QString &pix_fmt)
int pix_fmt_index(int codec, const QString &pix_fmt)
{
if (pix_fmt.isEmpty()) {
return 0;
}
FFmpegEncoder probe{ EncodingParams() };
const int index = probe.get_pixel_formats_for_codec(codec).indexOf(pix_fmt);
return index >= 0 ? index : 0;
return oakengine_encoding_pix_fmt_index(codec, pix_fmt.toUtf8().constData());
}
// EncodingParams (assembled by the dialog) -> facade POD. One-to-one with
// OakEngineEncodingParams (assembled by the dialog) -> facade POD. One-to-one with
// oak_export_options_ex; see oakengine/exporter.h for the field docs.
oak_export_options_ex params_to_ex(const EncodingParams &p)
oak_export_options_ex params_to_ex(const OakEngineEncodingParams *p)
{
oak_export_options_ex o = {};
const VideoParams &vp = p.video_params();
const Rational tb = vp.frame_rate().flipped();
int64_t vbrate = 0, abrate = 0;
int asample_rate = 0;
uint64_t ach_layout = 0;
int asample_fmt = 0;
int vthreads = 0;
int scaling = 0;
int is_img_seq = 0;
if (p.has_custom_range()) {
oak_video_params vp = {};
oakengine_encoding_params_get_video_params(p, &vp);
vbrate = oakengine_encoding_params_video_bit_rate(p);
abrate = oakengine_encoding_params_audio_bit_rate(p);
vthreads = oakengine_encoding_params_video_threads(p);
scaling = oakengine_encoding_params_video_scaling_method(p);
is_img_seq = oakengine_encoding_params_video_is_image_sequence(p);
if (oakengine_encoding_params_has_custom_range(p)) {
o.range_mode = OAKENGINE_EXPORT_RANGE_CUSTOM;
o.range_in_ts = Timecode::time_to_timestamp(p.custom_range().in(), tb);
int64_t r_in_num = 0, r_in_den = 1, r_out_num = 0, r_out_den = 1;
oakengine_encoding_params_get_custom_range(
p, &r_in_num, &r_in_den, &r_out_num, &r_out_den);
o.range_in_ts =
Timecode::time_to_timestamp(
Rational(r_in_num, r_in_den),
Rational(vp.time_base_num, vp.time_base_den));
o.range_out_ts =
Timecode::time_to_timestamp(p.custom_range().out(), tb);
Timecode::time_to_timestamp(
Rational(r_out_num, r_out_den),
Rational(vp.time_base_num, vp.time_base_den));
} else {
o.range_mode = OAKENGINE_EXPORT_RANGE_ENTIRE;
}
o.format = int(p.format());
o.video_enabled = p.video_enabled() ? 1 : 0;
o.video_codec = int(p.video_codec());
o.audio_enabled = p.audio_enabled() ? 1 : 0;
o.audio_codec = int(p.audio_codec());
o.subtitles_enabled = p.subtitles_enabled() ? 1 : 0;
o.subtitles_sidecar = p.subtitles_are_sidecar() ? 1 : 0;
o.format = oakengine_encoding_params_format(p);
o.video_enabled = oakengine_encoding_params_video_enabled(p) ? 1 : 0;
o.video_codec = oakengine_encoding_params_video_codec(p);
o.audio_enabled = oakengine_encoding_params_audio_enabled(p) ? 1 : 0;
o.audio_codec = oakengine_encoding_params_audio_codec(p);
o.subtitles_enabled = oakengine_encoding_params_subtitles_enabled(p) ? 1 : 0;
o.subtitles_sidecar = oakengine_encoding_params_subtitles_are_sidecar(p) ? 1 : 0;
o.subtitles_format =
p.subtitles_are_sidecar() ? int(p.subtitle_sidecar_fmt()) : 0;
o.subtitles_codec = p.subtitles_enabled() ? int(p.subtitles_codec()) : 0;
oakengine_encoding_params_subtitles_are_sidecar(p)
? oakengine_encoding_params_subtitles_sidecar_format(p)
: 0;
o.subtitles_codec = oakengine_encoding_params_subtitles_enabled(p)
? oakengine_encoding_params_subtitles_codec(p)
: 0;
o.video_bit_rate = p.video_bit_rate();
o.audio_bit_rate = p.audio_bit_rate();
o.video_pix_fmt = pix_fmt_index(p.video_codec(), p.video_pix_fmt());
o.video_bit_rate = vbrate;
o.audio_bit_rate = abrate;
o.audio_sample_rate = p.audio_params().sample_rate();
o.audio_channel_layout = p.audio_params().channel_layout();
o.audio_sample_format = int(p.audio_params().format());
const QString ct = p.color_transform().output();
if (ct.isEmpty()) {
o.color_transform = OAKENGINE_EXPORT_COLOR_REFERENCE;
} else if (ct == QStringLiteral("sRGB OETF")) {
o.color_transform = OAKENGINE_EXPORT_COLOR_SRGB_OETF;
} else if (ct == QStringLiteral("Rec.709 OETF")) {
o.color_transform = OAKENGINE_EXPORT_COLOR_REC709_OETF;
} else if (ct == QStringLiteral("BT.1886 EOTF")) {
o.color_transform = OAKENGINE_EXPORT_COLOR_BT1886_EOTF;
char pix_fmt_buf[64];
if (oakengine_encoding_params_video_pix_fmt(
p, pix_fmt_buf, static_cast<int>(sizeof(pix_fmt_buf))) > 0) {
o.video_pix_fmt = oakengine_encoding_pix_fmt_index(
o.video_codec, pix_fmt_buf);
} else {
o.color_transform = OAKENGINE_EXPORT_COLOR_CUSTOM;
const QByteArray utf = ct.toUtf8();
snprintf(o.color_transform_name, sizeof(o.color_transform_name),
"%s", utf.constData());
o.video_pix_fmt = 0;
}
o.video_width = vp.width();
o.video_height = vp.height();
o.frame_rate_num = vp.frame_rate().numerator();
o.frame_rate_den = vp.frame_rate().denominator();
o.pixel_aspect_num = vp.pixel_aspect_ratio().numerator();
o.pixel_aspect_den = vp.pixel_aspect_ratio().denominator();
o.interlacing = int(vp.interlacing());
o.pixel_format = int(vp.format());
o.scaling_method = int(p.video_scaling_method());
o.color_range = int(vp.color_range());
o.video_threads = p.video_threads();
o.is_image_sequence = p.video_is_image_sequence() ? 1 : 0;
if (oakengine_encoding_params_get_audio_params(
p, &asample_rate, &ach_layout, &asample_fmt) == OAKENGINE_OK) {
o.audio_sample_rate = asample_rate;
o.audio_channel_layout = ach_layout;
o.audio_sample_format = asample_fmt;
}
char ct_buf[128];
const int ct_ret = oakengine_encoding_params_color_transform_output(
p, ct_buf, static_cast<int>(sizeof(ct_buf)));
if (ct_ret <= 0 || ct_buf[0] == '\0') {
o.color_transform = OAKENGINE_EXPORT_COLOR_REFERENCE;
} else {
const QString ct = QString::fromUtf8(ct_buf);
if (ct == QStringLiteral("sRGB OETF")) {
o.color_transform = OAKENGINE_EXPORT_COLOR_SRGB_OETF;
} else if (ct == QStringLiteral("Rec.709 OETF")) {
o.color_transform = OAKENGINE_EXPORT_COLOR_REC709_OETF;
} else if (ct == QStringLiteral("BT.1886 EOTF")) {
o.color_transform = OAKENGINE_EXPORT_COLOR_BT1886_EOTF;
} else {
o.color_transform = OAKENGINE_EXPORT_COLOR_CUSTOM;
snprintf(o.color_transform_name, sizeof(o.color_transform_name),
"%s", ct_buf);
}
}
o.video_width = vp.width;
o.video_height = vp.height;
o.frame_rate_num = vp.time_base_den; // time_base is frame duration, so rate = den/num
o.frame_rate_den = vp.time_base_num;
o.pixel_aspect_num = vp.pixel_aspect_num;
o.pixel_aspect_den = vp.pixel_aspect_den;
o.interlacing = vp.interlacing;
o.pixel_format = vp.format;
o.scaling_method = scaling;
o.color_range = vp.color_range;
o.video_threads = vthreads;
o.is_image_sequence = is_img_seq;
return o;
}
} // namespace
/**
* @brief ExportTask replacement driven by the liboakengine C ABI facade
*
* Same Task contract as the engine's ExportTask (progress via
* progress_changed, cancel via CancelEvent), but the actual
* render+encode goes through oakengine_export_render_ex(): the facade
* owns the ExportTask instance, its event-loop drive and the conform
* prewarm. Cancellation is forwarded to the facade
* (oakengine_export_cancel()), which reports OAKENGINE_E_CANCELLED back.
*/
class FacadeExportTask : public Task {
public:
FacadeExportTask(ViewerOutput *viewer_node, const EncodingParams &params)
: sequence_(reinterpret_cast<OakEngineSequence *>(viewer_node))
, params_(params)
{
set_title(tr("Exporting \"%1\"").arg(viewer_node->get_label()));
}
protected:
virtual bool run() override
{
oak_export_options_ex o = params_to_ex(params_);
// Pass the codec section's encoder-specific options through.
for (auto it = params_.video_opts().cbegin();
it != params_.video_opts().cend(); ++it) {
oakengine_export_set_video_option(it.key().toUtf8().constData(),
it.value().toUtf8().constData());
}
oakengine_export_set_progress_callback(
&FacadeExportTask::forward_progress, this);
const int rc = oakengine_export_render_ex(
sequence_, params_.filename().toUtf8().constData(), &o);
oakengine_export_set_progress_callback(nullptr, nullptr);
oakengine_export_set_video_option("", nullptr);
if (rc == OAKENGINE_E_CANCELLED) {
// Mirror the engine task's cancelled state for TaskDialog.
cancel();
return false;
}
if (rc != OAKENGINE_OK) {
char err[1024];
err[0] = '\0';
oakengine_export_last_error(err, sizeof(err));
set_error(err[0] ? QString::fromUtf8(err) :
QStringLiteral("Export failed"));
return false;
}
return true;
}
virtual void CancelEvent() override
{
oakengine_export_cancel();
}
private:
static void forward_progress(double fraction, void *userdata)
{
static_cast<FacadeExportTask *>(userdata)->emit_progress(fraction);
}
void emit_progress(double fraction)
{
emit progress_changed(fraction);
}
OakEngineSequence *sequence_;
EncodingParams params_;
};
ExportDialog::ExportDialog(ViewerOutput *viewer_node, bool stills_only_mode,
QWidget *parent)
: super(parent)
@@ -312,16 +287,32 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, bool stills_only_mode,
preferences_tabs_ = new QTabWidget();
color_manager_ = viewer_node_->project()->color_manager();
color_manager_ = oak_color_manager(viewer_node_->project()->color_manager());
video_tab_ = new ExportVideoTab(color_manager_);
add_preferences_tab(video_tab_, tr("Video"));
// Set video tab time and make connections
connect(viewer_node, &ViewerOutput::playhead_changed, video_tab_,
&ExportVideoTab::set_time);
connect(video_tab_, &ExportVideoTab::time_changed, viewer_node,
&ViewerOutput::set_playhead);
video_tab_->set_time(viewer_node->get_playhead());
viewer_sub_ = oakengine_event_subscribe(
reinterpret_cast<OakEngineNode *>(viewer_node),
OAKENGINE_EVENT_VIEWER_PLAYHEAD_CHANGED,
[](const oakengine_event *event, void *userdata) {
auto *dlg = static_cast<ExportDialog *>(userdata);
auto *tab = dlg->video_tab_;
tab->set_time(Rational(event->a, event->b));
},
this);
connect(video_tab_, &ExportVideoTab::time_changed, this,
[viewer_node](const Rational &time) {
oakengine_viewer_set_playhead(
reinterpret_cast<OakEngineNode *>(viewer_node),
time.numerator(), time.denominator());
});
{
int64_t pn, pd;
oakengine_viewer_get_playhead(
reinterpret_cast<OakEngineNode *>(viewer_node), &pn, &pd);
video_tab_->set_time(Rational(pn, pd));
}
audio_tab_ = new ExportAudioTab();
add_preferences_tab(audio_tab_, tr("Audio"));
@@ -394,11 +385,11 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, bool stills_only_mode,
set_default_filename();
// Set defaults
previously_selected_format_ = ExportFormat::k_format_mpe_g4_video;
previously_selected_format_ = OAKENGINE_ENCODING_FORMAT_MPEG4_VIDEO;
connect(format_combobox_, &ExportFormatComboBox::format_changed, this,
&ExportDialog::format_changed);
VideoParams vp = viewer_node_->get_video_params();
VideoParams vp = viewer_output_video_params(viewer_node_);
video_aspect_ratio_ =
static_cast<double>(vp.width()) / static_cast<double>(vp.height());
@@ -430,7 +421,8 @@ ExportDialog::ExportDialog(ViewerOutput *viewer_node, bool stills_only_mode,
// If the viewer already has cached params, use them
if (!stills_only_mode_ &&
viewer_node_->get_last_used_encoding_params().is_valid()) {
oakengine_encoding_params_get_last_used(
reinterpret_cast<OakEngineSequence *>(viewer_node_)) != nullptr) {
// This will automatically set the param data
QtUtils::set_combo_box_data(preset_combobox_, k_preset_last_used);
} else {
@@ -477,8 +469,9 @@ void ExportDialog::start_export()
// Validate if the entered filename contains the correct extension (the extension is necessary
// for both FFmpeg and OIIO to determine the output format)
QString necessary_ext = QStringLiteral(".%1").arg(
ExportFormat::get_extension(format_combobox_->get_format()));
char ext_buf[64];
int ext_len = oakengine_encoding_format_extension(format_combobox_->get_format(), ext_buf, sizeof(ext_buf));
QString necessary_ext = QStringLiteral(".%1").arg(QString::fromUtf8(ext_buf, ext_len));
QString proposed_filename = filename_edit_->text().trimmed();
// If it doesn't, see if the user wants to append it automatically. If not, we don't abort the export.
@@ -513,7 +506,7 @@ void ExportDialog::start_export()
// Validate if this is an image sequence and if the filename contains enough digits
if (video_tab_->is_image_sequence_set()) {
// Ensure filename contains digits
if (!Encoder::filename_contains_digit_placeholder(proposed_filename)) {
if (!oakengine_encoding_filename_contains_digit_placeholder(proposed_filename.toUtf8().constData())) {
msg_box(
this, QMessageBox::Critical, tr("Invalid filename"),
tr("Export is set to an image sequence, but the filename does not have a section for digits "
@@ -524,7 +517,7 @@ void ExportDialog::start_export()
int64_t frame_count = get_export_length_in_timebase_units();
int64_t needed_digit_count = get_digit_count(frame_count);
int current_digit_count =
Encoder::get_image_sequence_placeholder_digit_count(proposed_filename);
oakengine_encoding_image_sequence_digit_count(proposed_filename.toUtf8().constData());
if (current_digit_count < needed_digit_count) {
msg_box(
this, QMessageBox::Critical, tr("Invalid filename"),
@@ -549,8 +542,8 @@ void ExportDialog::start_export()
// Validate video resolution
if (video_enabled_->isChecked() &&
(video_tab_->get_selected_codec() == ExportCodec::k_codec_h264 ||
video_tab_->get_selected_codec() == ExportCodec::k_codec_h265) &&
(video_tab_->get_selected_codec() == OAKENGINE_ENCODING_CODEC_H264 ||
video_tab_->get_selected_codec() == OAKENGINE_ENCODING_CODEC_H265) &&
(video_tab_->width_slider()->get_value() % 2 != 0 ||
video_tab_->height_slider()->get_value() % 2 != 0)) {
msg_box(this, QMessageBox::Critical, tr("Invalid Parameters"),
@@ -558,12 +551,13 @@ void ExportDialog::start_export()
return;
}
FacadeExportTask *task =
new FacadeExportTask(viewer_node_, generate_params());
OakEngineTask *task = oakengine_task_create_export(
reinterpret_cast<OakEngineSequence *>(viewer_node_),
generate_params());
if (export_bkg_box_->isChecked()) {
// Send to TaskManager to export in background
TaskManager::instance()->add_task(task);
oakengine_task_manager_add(task);
this->accept();
} else {
// Use modal dialog box
@@ -578,7 +572,7 @@ void ExportDialog::export_finished()
{
TaskDialog *td = static_cast<TaskDialog *>(sender());
if (td->get_task()->is_cancelled()) {
if (oakengine_task_is_cancelled(td->get_task())) {
// If this task was cancelled, we stay open so the user can potentially queue another export
} else {
// Accept this dialog and close
@@ -600,11 +594,14 @@ void ExportDialog::image_sequence_check_box_changed(bool e)
QString suffix = current_fileinfo.suffix();
if (e) {
if (!Encoder::filename_contains_digit_placeholder(basename)) {
if (!oakengine_encoding_filename_contains_digit_placeholder(basename.toUtf8().constData())) {
basename.append(QStringLiteral("_[#####]"));
}
} else {
basename = Encoder::filename_remove_digit_placeholder(basename);
char buf[1024];
oakengine_encoding_filename_remove_digit_placeholder(
basename.toUtf8().constData(), buf, sizeof(buf));
basename = QString::fromUtf8(buf);
}
// Set filename
@@ -636,7 +633,14 @@ void ExportDialog::preset_combo_box_changed()
if (preset_number == k_preset_default) {
set_defaults();
} else if (preset_number == k_preset_last_used) {
set_params(viewer_node_->get_last_used_encoding_params());
OakEngineEncodingParams *last =
oakengine_encoding_params_get_last_used(
reinterpret_cast<OakEngineSequence *>(viewer_node_));
if (last) {
set_params(last);
} else {
set_defaults();
}
} else {
set_params(presets_.at(preset_number));
}
@@ -653,12 +657,17 @@ void ExportDialog::add_preferences_tab(QWidget *inner_widget,
void ExportDialog::browse_filename()
{
ExportFormat::Format f = format_combobox_->get_format();
int f = format_combobox_->get_format();
char name_buf[256];
char ext_buf[64];
oakengine_encoding_format_name(f, name_buf, sizeof(name_buf));
oakengine_encoding_format_extension(f, ext_buf, sizeof(ext_buf));
QString browsed_fn = QFileDialog::getSaveFileName(
this, "", filename_edit_->text().trimmed(),
QStringLiteral("%1 (*.%2)")
.arg(ExportFormat::get_name(f), ExportFormat::get_extension(f)),
.arg(QString::fromUtf8(name_buf), QString::fromUtf8(ext_buf)),
nullptr,
// We don't confirm overwrite here because we do it later
@@ -669,12 +678,14 @@ void ExportDialog::browse_filename()
}
}
void ExportDialog::format_changed(ExportFormat::Format current_format)
void ExportDialog::format_changed(int current_format)
{
QString current_filename = filename_edit_->text().trimmed();
QString previously_selected_ext =
ExportFormat::get_extension(previously_selected_format_);
QString currently_selected_ext = ExportFormat::get_extension(current_format);
char ext_buf[64];
oakengine_encoding_format_extension(previously_selected_format_, ext_buf, sizeof(ext_buf));
QString previously_selected_ext = QString::fromUtf8(ext_buf);
oakengine_encoding_format_extension(current_format, ext_buf, sizeof(ext_buf));
QString currently_selected_ext = QString::fromUtf8(ext_buf);
// If the previous extension was added, remove it
if (current_filename.endsWith(previously_selected_ext,
@@ -742,25 +753,45 @@ void ExportDialog::load_presets()
preset_combobox_->addItem(tr("Default"), k_preset_default);
if (viewer_node_->get_last_used_encoding_params().is_valid()) {
if (oakengine_encoding_params_get_last_used(
reinterpret_cast<OakEngineSequence *>(viewer_node_)) != nullptr) {
preset_combobox_->addItem(tr("Last Used"), k_preset_last_used);
}
preset_combobox_->insertSeparator(preset_combobox_->count());
QStringList l = EncodingParams::get_list_of_presets();
QStringList l;
{
const int n = oakengine_encoding_preset_count();
for (int i = 0; i < n; i++) {
char name_buf[256];
if (oakengine_encoding_preset_name(
i, name_buf, static_cast<int>(sizeof(name_buf))) > 0) {
l.append(QString::fromUtf8(name_buf));
}
}
}
presets_.reserve(l.size());
for (const QString &preset : l) {
EncodingParams p;
OakEngineEncodingParams *p = oakengine_encoding_params_create();
QFile f(EncodingParams::get_preset_path().filePath(preset));
if (f.open(QFile::ReadOnly)) {
if (p.load(&f)) {
preset_combobox_->addItem(preset, int(presets_.size()));
presets_.push_back(p);
}
f.close();
char preset_path_buf[1024];
preset_path_buf[0] = '\0';
oakengine_encoding_preset_path(
preset_path_buf, static_cast<int>(sizeof(preset_path_buf)));
const QByteArray preset_path_utf =
QDir(QString::fromUtf8(preset_path_buf))
.filePath(preset)
.toUtf8();
const int rc = oakengine_encoding_params_load_file(
p, preset_path_utf.constData());
if (rc == OAKENGINE_OK) {
preset_combobox_->addItem(preset, int(presets_.size()));
presets_.push_back(p);
} else {
oakengine_encoding_params_destroy(p);
}
}
@@ -771,13 +802,17 @@ void ExportDialog::set_default_filename()
{
Project *p = viewer_node_->project();
char fn_buf[512];
oakengine_project_filename(
reinterpret_cast<OakEngineProject *>(p),
fn_buf, sizeof(fn_buf));
QDir doc_location;
if (p->filename().isEmpty()) {
if (fn_buf[0] == '\0') {
doc_location.setPath(QStandardPaths::writableLocation(
QStandardPaths::DocumentsLocation));
} else {
doc_location = QFileInfo(p->filename()).dir();
doc_location = QFileInfo(fn_buf).dir();
}
QString file_location = doc_location.filePath(viewer_node_->get_label());
@@ -801,14 +836,14 @@ bool ExportDialog::sequence_has_subtitles() const
void ExportDialog::set_defaults()
{
if (!stills_only_mode_) {
format_combobox_->set_format(ExportFormat::k_format_mpe_g4_video);
format_combobox_->set_format(OAKENGINE_ENCODING_FORMAT_MPEG4_VIDEO);
} else {
format_combobox_->set_format(ExportFormat::k_format_png);
format_combobox_->set_format(OAKENGINE_ENCODING_FORMAT_PNG);
}
format_changed(format_combobox_->get_format());
VideoParams vp = viewer_node_->get_video_params();
AudioParams ap = viewer_node_->get_audio_params();
VideoParams vp = viewer_output_video_params(viewer_node_);
AudioParams ap = viewer_output_audio_params(viewer_node_);
video_tab_->width_slider()->set_value(vp.width());
video_tab_->width_slider()->SetDefaultValue(vp.width());
@@ -826,151 +861,217 @@ void ExportDialog::set_defaults()
audio_tab_->channel_layout_combobox()->set_channel_layout(
ap.channel_layout());
subtitles_enabled_->setChecked(sequence_has_subtitles());
subtitle_tab_->set_sidecar_format(ExportFormat::k_format_srt);
subtitle_tab_->set_sidecar_format(OAKENGINE_ENCODING_FORMAT_SRT);
}
EncodingParams ExportDialog::generate_params() const
OakEngineEncodingParams *ExportDialog::generate_params() const
{
VideoParams video_render_params(
static_cast<int>(video_tab_->width_slider()->get_value()),
static_cast<int>(video_tab_->height_slider()->get_value()),
get_selected_timebase(),
video_tab_->pixel_format_field()->get_pixel_format(),
VideoParams::k_internal_channel_count,
video_tab_->pixel_aspect_combobox()->get_pixel_aspect_ratio(),
video_tab_->interlaced_combobox()->get_interlace_mode(), 1);
OakEngineEncodingParams *params = oakengine_encoding_params_create();
AudioParams audio_render_params(
audio_tab_->sample_rate_combobox()->get_sample_rate(),
audio_tab_->channel_layout_combobox()->get_channel_layout(),
audio_tab_->sample_format_combobox()->get_sample_format());
oakengine_encoding_params_set_format(
params, format_combobox_->get_format());
oakengine_encoding_params_set_filename(
params, filename_edit_->text().trimmed().toUtf8().constData());
EncodingParams params;
params.set_format(format_combobox_->get_format());
params.set_filename(filename_edit_->text().trimmed());
params.set_export_length(viewer_node_->get_length());
const Rational export_len = viewer_node_->get_length();
oakengine_encoding_params_set_export_length(
params, export_len.numerator(), export_len.denominator());
if (ExportCodec::is_codec_a_still_image(video_tab_->get_selected_codec()) &&
if (oakengine_encoding_codec_is_still_image(video_tab_->get_selected_codec()) &&
!video_tab_->is_image_sequence_set()) {
// Exporting as image without exporting image sequence, only export one frame
Rational export_time = video_tab_->get_still_image_time();
params.set_custom_range(
TimeRange(export_time, export_time + get_selected_timebase()));
const Rational tb = get_selected_timebase();
oakengine_encoding_params_set_custom_range(
params, export_time.numerator(), export_time.denominator(),
(export_time + tb).numerator(),
(export_time + tb).denominator());
} else if (range_combobox_->currentIndex() == k_range_in_to_out) {
// Assume if this combobox is enabled, workarea is enabled - a check that we make in this dialog's constructor
params.set_custom_range(viewer_node_->get_work_area()->range());
const TimeRange &r = viewer_node_->get_work_area()->range();
oakengine_encoding_params_set_custom_range(
params, r.in().numerator(), r.in().denominator(),
r.out().numerator(), r.out().denominator());
}
if (video_tab_->scaling_method_combobox()->isEnabled()) {
params.set_video_scaling_method(
static_cast<EncodingParams::VideoScalingMethod>(
video_tab_->scaling_method_combobox()->currentData().toInt()));
oakengine_encoding_params_set_video_scaling_method(
params,
video_tab_->scaling_method_combobox()->currentData().toInt());
}
if (video_enabled_->isChecked()) {
ExportCodec::Codec video_codec = video_tab_->get_selected_codec();
const int video_codec = video_tab_->get_selected_codec();
video_render_params.set_color_range(video_tab_->color_range());
// Build video params from the tab
const int vw = static_cast<int>(video_tab_->width_slider()->get_value());
const int vh = static_cast<int>(video_tab_->height_slider()->get_value());
const Rational tb = get_selected_timebase();
const int pix_fmt = video_tab_->pixel_format_field()->get_pixel_format();
const int ch_count = oakengine_video_params_internal_channel_count();
const Rational par = video_tab_->pixel_aspect_combobox()->get_pixel_aspect_ratio();
const int interlace = video_tab_->interlaced_combobox()->get_interlace_mode();
params.enable_video(video_render_params, video_codec);
oak_video_params vp = {};
vp.width = vw;
vp.height = vh;
vp.time_base_num = tb.numerator();
vp.time_base_den = tb.denominator();
vp.format = pix_fmt;
vp.pixel_aspect_num = par.numerator();
vp.pixel_aspect_den = par.denominator();
vp.interlacing = interlace;
vp.color_range = video_tab_->color_range();
params.set_video_threads(video_tab_->threads());
oakengine_encoding_params_enable_video(params, &vp, video_codec);
oakengine_encoding_params_set_video_threads(
params, video_tab_->threads());
if (video_tab_->isVisible()) {
video_tab_->get_codec_section()->add_opts(&params);
video_tab_->get_codec_section()->add_opts(params);
}
params.set_color_transform(video_tab_->current_ocio_color_space());
{
const QString ct = video_tab_->current_ocio_color_space();
oakengine_encoding_params_set_color_transform(
params, ct.isEmpty() ? nullptr : ct.toUtf8().constData());
}
params.set_video_pix_fmt(video_tab_->pix_fmt());
{
const QString pix_fmt_name = video_tab_->pix_fmt();
oakengine_encoding_params_set_video_pix_fmt(
params,
pix_fmt_name.isEmpty() ? nullptr
: pix_fmt_name.toUtf8().constData());
}
params.set_video_is_image_sequence(video_tab_->is_image_sequence_set());
oakengine_encoding_params_set_video_is_image_sequence(
params, video_tab_->is_image_sequence_set() ? 1 : 0);
}
if (audio_enabled_->isChecked()) {
ExportCodec::Codec audio_codec = audio_tab_->get_codec();
params.enable_audio(audio_render_params, audio_codec);
const int audio_codec = audio_tab_->get_codec();
const int sample_rate = audio_tab_->sample_rate_combobox()->get_sample_rate();
const uint64_t ch_layout = audio_tab_->channel_layout_combobox()->get_channel_layout();
const int sample_fmt = audio_tab_->sample_format_combobox()->get_sample_format();
params.set_audio_bit_rate(audio_tab_->bit_rate_slider()->get_value() *
1000);
oakengine_encoding_params_enable_audio(
params, sample_rate, ch_layout, sample_fmt, audio_codec);
oakengine_encoding_params_set_audio_bit_rate(
params,
audio_tab_->bit_rate_slider()->get_value() * 1000);
}
if (subtitles_enabled_->isEnabled() && subtitles_enabled_->isChecked()) {
if (!subtitle_tab_->get_sidecar_enabled()) {
// Export subtitles embedded in container
params.enable_subtitles(subtitle_tab_->get_subtitle_codec());
oakengine_encoding_params_enable_subtitles(
params, subtitle_tab_->get_subtitle_codec());
} else {
// Export subtitles to a sidecar file
params.enable_sidecar_subtitles(subtitle_tab_->get_sidecar_format(),
subtitle_tab_->get_subtitle_codec());
oakengine_encoding_params_enable_sidecar_subtitles(
params, subtitle_tab_->get_sidecar_format(),
subtitle_tab_->get_subtitle_codec());
}
}
return params;
}
void ExportDialog::set_params(const EncodingParams &e)
void ExportDialog::set_params(const OakEngineEncodingParams *e)
{
format_combobox_->set_format(e.format());
format_combobox_->set_format(oakengine_encoding_params_format(e));
format_changed(format_combobox_->get_format());
if (e.has_custom_range() && viewer_node_->get_work_area()->enabled()) {
if (oakengine_encoding_params_has_custom_range(e) &&
viewer_node_->get_work_area()->enabled()) {
range_combobox_->setCurrentIndex(k_range_in_to_out);
}
QtUtils::set_combo_box_data(video_tab_->scaling_method_combobox(),
e.video_scaling_method());
oakengine_encoding_params_video_scaling_method(e));
video_enabled_->setChecked(e.video_enabled());
if (e.video_enabled()) {
video_tab_->width_slider()->set_value(e.video_params().width());
video_tab_->height_slider()->set_value(e.video_params().height());
set_selected_timebase(e.video_params().time_base());
const int video_enabled = oakengine_encoding_params_video_enabled(e);
video_enabled_->setChecked(video_enabled);
if (video_enabled) {
oak_video_params vp = {};
oakengine_encoding_params_get_video_params(e, &vp);
video_tab_->width_slider()->set_value(vp.width);
video_tab_->height_slider()->set_value(vp.height);
set_selected_timebase(Rational(vp.time_base_num, vp.time_base_den));
video_tab_->pixel_format_field()->set_pixel_format(
e.video_params().format());
static_cast<olive::core::PixelFormat::Format>(vp.format));
video_tab_->pixel_aspect_combobox()->set_pixel_aspect_ratio(
e.video_params().pixel_aspect_ratio());
video_tab_->interlaced_combobox()->set_interlace_mode(
e.video_params().interlacing());
Rational(vp.pixel_aspect_num, vp.pixel_aspect_den));
video_tab_->interlaced_combobox()->set_interlace_mode(vp.interlacing);
video_tab_->set_selected_codec(e.video_codec());
video_tab_->set_selected_codec(oakengine_encoding_params_video_codec(e));
video_tab_->set_color_range(e.video_params().color_range());
video_tab_->set_color_range(vp.color_range);
video_tab_->set_threads(e.video_threads());
video_tab_->set_threads(oakengine_encoding_params_video_threads(e));
if (video_tab_->isVisible()) {
video_tab_->get_codec_section()->set_opts(&e);
video_tab_->get_codec_section()->set_opts(e);
}
video_tab_->set_ocio_color_space(e.color_transform().output());
{
char ct_buf[128];
if (oakengine_encoding_params_color_transform_output(
e, ct_buf, static_cast<int>(sizeof(ct_buf))) > 0) {
video_tab_->set_ocio_color_space(QString::fromUtf8(ct_buf));
} else {
video_tab_->set_ocio_color_space(QString());
}
}
video_tab_->set_pix_fmt(e.video_pix_fmt());
{
char pix_fmt_buf[64];
if (oakengine_encoding_params_video_pix_fmt(
e, pix_fmt_buf, static_cast<int>(sizeof(pix_fmt_buf))) > 0) {
video_tab_->set_pix_fmt(QString::fromUtf8(pix_fmt_buf));
} else {
video_tab_->set_pix_fmt(QString());
}
}
video_tab_->set_image_sequence(e.video_is_image_sequence());
video_tab_->set_image_sequence(
oakengine_encoding_params_video_is_image_sequence(e));
}
audio_enabled_->setChecked(e.audio_enabled());
if (e.audio_enabled()) {
audio_tab_->sample_rate_combobox()->set_sample_rate(
e.audio_params().sample_rate());
audio_tab_->channel_layout_combobox()->set_channel_layout(
e.audio_params().channel_layout());
const int audio_enabled = oakengine_encoding_params_audio_enabled(e);
audio_enabled_->setChecked(audio_enabled);
if (audio_enabled) {
int asample_rate = 0;
uint64_t ach_layout = 0;
int asample_fmt = 0;
oakengine_encoding_params_get_audio_params(
e, &asample_rate, &ach_layout, &asample_fmt);
audio_tab_->sample_rate_combobox()->set_sample_rate(asample_rate);
audio_tab_->channel_layout_combobox()->set_channel_layout(ach_layout);
audio_tab_->sample_format_combobox()->set_sample_format(
e.audio_params().format());
static_cast<olive::core::SampleFormat::Format>(asample_fmt));
audio_tab_->set_codec(e.audio_codec());
audio_tab_->set_codec(oakengine_encoding_params_audio_codec(e));
audio_tab_->bit_rate_slider()->set_value(e.audio_bit_rate() / 1000);
audio_tab_->bit_rate_slider()->set_value(
oakengine_encoding_params_audio_bit_rate(e) / 1000);
}
if (subtitles_enabled_->isEnabled()) {
subtitles_enabled_->setChecked(e.subtitles_enabled());
subtitle_tab_->set_sidecar_enabled(e.subtitles_are_sidecar());
if (e.subtitles_enabled()) {
subtitle_tab_->set_subtitle_codec(e.subtitles_codec());
if (e.subtitles_are_sidecar()) {
subtitle_tab_->set_sidecar_format(e.subtitle_sidecar_fmt());
const int subs_enabled = oakengine_encoding_params_subtitles_enabled(e);
subtitles_enabled_->setChecked(subs_enabled);
subtitle_tab_->set_sidecar_enabled(
oakengine_encoding_params_subtitles_are_sidecar(e));
if (subs_enabled) {
subtitle_tab_->set_subtitle_codec(
oakengine_encoding_params_subtitles_codec(e));
if (oakengine_encoding_params_subtitles_are_sidecar(e)) {
subtitle_tab_->set_sidecar_format(
oakengine_encoding_params_subtitles_sidecar_format(e));
}
}
}
@@ -997,7 +1098,10 @@ void ExportDialog::done(int r)
preview_viewer_->connect_viewer_node(nullptr);
if (!stills_only_mode_) {
viewer_node_->set_last_used_encoding_params(generate_params());
OakEngineEncodingParams *p = generate_params();
oakengine_encoding_params_set_last_used(
reinterpret_cast<OakEngineSequence *>(viewer_node_), p);
oakengine_encoding_params_destroy(p);
}
super::done(r);
@@ -1024,14 +1128,16 @@ void ExportDialog::update_viewer_dimensions()
static_cast<int>(video_tab_->width_slider()->get_value()),
static_cast<int>(video_tab_->height_slider()->get_value()));
VideoParams vp = viewer_node_->get_video_params();
VideoParams vp = viewer_output_video_params(viewer_node_);
QMatrix4x4 transform = EncodingParams::generate_matrix(
static_cast<EncodingParams::VideoScalingMethod>(
video_tab_->scaling_method_combobox()->currentData().toInt()),
float mat16[16];
oakengine_encoding_generate_matrix(
video_tab_->scaling_method_combobox()->currentData().toInt(),
vp.width(), vp.height(),
static_cast<int>(video_tab_->width_slider()->get_value()),
static_cast<int>(video_tab_->height_slider()->get_value()));
static_cast<int>(video_tab_->height_slider()->get_value()),
mat16);
QMatrix4x4 transform(mat16);
preview_viewer_->set_matrix(transform);
}
+10 -8
View File
@@ -24,17 +24,17 @@
#include <QComboBox>
#include <QDialog>
#include <cstdint>
#include <QDialogButtonBox>
#include <QLineEdit>
#include <QProgressBar>
#include "codec/encoder.h"
#include "codec/exportcodec.h"
#include "codec/exportformat.h"
#include "dialog/export/exportformatcombobox.h"
#include "exportaudiotab.h"
#include "exportsubtitlestab.h"
#include "exportvideotab.h"
#include "oakengine/encoding.h"
#include "widget/nodeparamview/nodeparamviewwidgetbridge.h"
#include "widget/viewer/viewer.h"
@@ -54,8 +54,8 @@ public:
Rational get_selected_timebase() const;
void set_selected_timebase(const Rational &r);
EncodingParams generate_params() const;
void set_params(const EncodingParams &e);
OakEngineEncodingParams *generate_params() const;
void set_params(const OakEngineEncodingParams *e);
virtual bool eventFilter(QObject *o, QEvent *e) override;
@@ -77,7 +77,9 @@ private:
ViewerOutput *viewer_node_;
ExportFormat::Format previously_selected_format_;
int64_t viewer_sub_ = 0;
int previously_selected_format_;
Rational get_export_length() const;
int64_t get_export_length_in_timebase_units() const;
@@ -93,7 +95,7 @@ private:
QComboBox *preset_combobox_;
QComboBox *range_combobox_;
std::vector<EncodingParams> presets_;
std::vector<OakEngineEncodingParams *> presets_;
QCheckBox *video_enabled_;
QCheckBox *audio_enabled_;
@@ -109,7 +111,7 @@ private:
double video_aspect_ratio_;
ColorManager *color_manager_;
OakEngineColorManager *color_manager_;
QWidget *preferences_area_;
QCheckBox *export_bkg_box_;
@@ -122,7 +124,7 @@ private:
private slots:
void browse_filename();
void format_changed(ExportFormat::Format current_format);
void format_changed(int current_format);
void resolution_changed();
@@ -54,13 +54,13 @@ public:
pixel_format_combobox_->setCurrentText(s);
}
VideoParams::ColorRange yuv_range() const
int yuv_range() const
{
return static_cast<VideoParams::ColorRange>(
return static_cast<int>(
yuv_color_range_combobox_->currentIndex());
}
void set_yuv_range(VideoParams::ColorRange i)
void set_yuv_range(int i)
{
yuv_color_range_combobox_->setCurrentIndex(i);
}
+21 -8
View File
@@ -24,6 +24,9 @@
#include <QGridLayout>
#include <QLabel>
#include <olive/core/core.h>
#include "oakengine/encoding.h"
namespace olive
{
@@ -87,14 +90,17 @@ ExportAudioTab::ExportAudioTab(QWidget *parent)
outer_layout->addStretch();
}
int ExportAudioTab::set_format(ExportFormat::Format format)
int ExportAudioTab::set_format(int format)
{
QList<ExportCodec::Codec> acodecs = ExportFormat::get_audio_codecs(format);
setEnabled(!acodecs.isEmpty());
const int acodec_count = oakengine_encoding_format_audio_codec_count(format);
setEnabled(acodec_count > 0);
codec_combobox_->blockSignals(true);
codec_combobox_->clear();
foreach (ExportCodec::Codec acodec, acodecs) {
codec_combobox_->addItem(ExportCodec::get_codec_name(acodec), acodec);
for (int i = 0; i < acodec_count; i++) {
int codec = oakengine_encoding_format_audio_codec_at(format, i);
char buf[256];
oakengine_encoding_codec_name(codec, buf, sizeof(buf));
codec_combobox_->addItem(QString::fromUtf8(buf), codec);
}
codec_combobox_->blockSignals(false);
fmt_ = format;
@@ -102,18 +108,25 @@ int ExportAudioTab::set_format(ExportFormat::Format format)
update_sample_formats();
update_bit_rate_enabled();
return acodecs.size();
return acodec_count;
}
void ExportAudioTab::update_sample_formats()
{
auto fmts = ExportFormat::get_sample_formats_for_codec(fmt_, get_codec());
// Use oakengine to get sample format values and build the vector
const int count = oakengine_encoding_sample_format_count(fmt_, get_codec());
std::vector<olive::core::SampleFormat> fmts;
fmts.reserve(count);
for (int i = 0; i < count; i++) {
int val = oakengine_encoding_sample_format_at(fmt_, get_codec(), i);
fmts.push_back(olive::core::SampleFormat(static_cast<olive::core::SampleFormat::Format>(val)));
}
sample_format_combobox_->set_available_formats(fmts);
}
void ExportAudioTab::update_bit_rate_enabled()
{
bool uses_bitrate = !ExportCodec::is_codec_lossless(get_codec());
bool uses_bitrate = !oakengine_encoding_codec_is_lossless(get_codec());
bit_rate_slider_->setEnabled(uses_bitrate);
if (!uses_bitrate) {
+5 -7
View File
@@ -26,7 +26,6 @@
#include <QWidget>
#include "common/define.h"
#include "codec/exportformat.h"
#include "widget/slider/integerslider.h"
#include "widget/standardcombos/standardcombos.h"
@@ -38,13 +37,12 @@ class ExportAudioTab : public QWidget {
public:
ExportAudioTab(QWidget *parent = nullptr);
ExportCodec::Codec get_codec() const
int get_codec() const
{
return static_cast<ExportCodec::Codec>(
codec_combobox_->currentData().toInt());
return codec_combobox_->currentData().toInt();
}
void set_codec(ExportCodec::Codec c)
void set_codec(int c)
{
for (int i = 0; i < codec_combobox_->count(); i++) {
if (codec_combobox_->itemData(i) == c) {
@@ -75,10 +73,10 @@ public:
}
public slots:
int set_format(ExportFormat::Format format);
int set_format(int format);
private:
ExportFormat::Format fmt_;
int fmt_;
QComboBox *codec_combobox_;
SampleRateComboBox *sample_rate_combobox_;
ChannelLayoutComboBox *channel_layout_combobox_;
+23 -16
View File
@@ -24,6 +24,7 @@
#include <QHBoxLayout>
#include <QLabel>
#include "oakengine/encoding.h"
#include "ui/icons/icons.h"
namespace olive
@@ -32,6 +33,10 @@ namespace olive
ExportFormatComboBox::ExportFormatComboBox(Mode mode, QWidget *parent)
: QComboBox(parent)
{
// The invalid placeholder format is the format count itself
// (ExportFormat::k_format_count), not -1.
current_ = oakengine_encoding_format_count();
custom_menu_ = new Menu(this);
// Populate combobox formats
@@ -69,43 +74,45 @@ void ExportFormatComboBox::showPopup()
custom_menu_->exec(mapToGlobal(QPoint(0, 0)));
}
void ExportFormatComboBox::set_format(ExportFormat::Format fmt)
void ExportFormatComboBox::set_format(int fmt)
{
current_ = fmt;
clear();
addItem(ExportFormat::get_name(current_));
char buf[256];
oakengine_encoding_format_name(fmt, buf, sizeof(buf));
addItem(QString::fromUtf8(buf));
}
void ExportFormatComboBox::handle_index_change(QAction *a)
{
ExportFormat::Format f =
static_cast<ExportFormat::Format>(a->data().toInt());
int f = a->data().toInt();
set_format(f);
emit format_changed(f);
}
void ExportFormatComboBox::populate_type(Track::Type type)
{
for (int i = 0; i < ExportFormat::k_format_count; i++) {
ExportFormat::Format f = static_cast<ExportFormat::Format>(i);
const int fmt_count = oakengine_encoding_format_count();
for (int i = 0; i < fmt_count; i++) {
int f = i;
char buf[256];
if (type == Track::k_video &&
!ExportFormat::get_video_codecs(f).isEmpty()) {
bool has_video = oakengine_encoding_format_video_codec_count(f) > 0;
bool has_audio = oakengine_encoding_format_audio_codec_count(f) > 0;
bool has_sub = oakengine_encoding_format_subtitle_codec_count(f) > 0;
if (type == Track::k_video && has_video) {
// Do nothing
} else if (type == Track::k_audio &&
ExportFormat::get_video_codecs(f).isEmpty() &&
!ExportFormat::get_audio_codecs(f).isEmpty()) {
} else if (type == Track::k_audio && !has_video && has_audio) {
// Do nothing
} else if (type == Track::k_subtitle &&
ExportFormat::get_video_codecs(f).isEmpty() &&
ExportFormat::get_audio_codecs(f).isEmpty() &&
!ExportFormat::get_subtitle_codecs(f).isEmpty()) {
} else if (type == Track::k_subtitle && !has_video && !has_audio && has_sub) {
// Do nothing
} else {
continue;
}
QString format_name = ExportFormat::get_name(f);
oakengine_encoding_format_name(f, buf, sizeof(buf));
QString format_name = QString::fromUtf8(buf);
QAction *a = custom_menu_->addAction(format_name);
a->setData(i);
+4 -5
View File
@@ -25,7 +25,6 @@
#include <QComboBox>
#include <QWidgetAction>
#include "codec/exportformat.h"
#include "node/output/track/track.h"
#include "widget/menu/menu.h"
@@ -48,7 +47,7 @@ public:
{
}
ExportFormat::Format get_format() const
int get_format() const
{
return current_;
}
@@ -56,10 +55,10 @@ public:
void showPopup();
signals:
void format_changed(ExportFormat::Format fmt);
void format_changed(int fmt);
public slots:
void set_format(ExportFormat::Format fmt);
void set_format(int fmt);
private slots:
void handle_index_change(QAction *a);
@@ -71,7 +70,7 @@ private:
Menu *custom_menu_;
ExportFormat::Format current_ = ExportFormat::k_format_count;
int current_ = -1; // was ExportFormat::k_format_count
};
}
+27 -11
View File
@@ -22,6 +22,7 @@
#include "exportsavepresetdialog.h"
#include <QDialogButtonBox>
#include <QDir>
#include <QLabel>
#include <QMessageBox>
#include <QVBoxLayout>
@@ -29,7 +30,7 @@
namespace olive
{
ExportSavePresetDialog::ExportSavePresetDialog(const EncodingParams &p,
ExportSavePresetDialog::ExportSavePresetDialog(const OakEngineEncodingParams *p,
QWidget *parent)
: QDialog(parent)
, params_(p)
@@ -39,7 +40,17 @@ ExportSavePresetDialog::ExportSavePresetDialog(const EncodingParams &p,
name_edit_ = new QLineEdit();
// Populate existing list
QStringList l = EncodingParams::get_list_of_presets();
QStringList l;
{
const int n = oakengine_encoding_preset_count();
for (int i = 0; i < n; i++) {
char name_buf[256];
if (oakengine_encoding_preset_name(
i, name_buf, static_cast<int>(sizeof(name_buf))) > 0) {
l.append(QString::fromUtf8(name_buf));
}
}
}
if (!l.empty()) {
auto list_widget = new QListWidget();
for (const QString &f : l) {
@@ -78,13 +89,17 @@ void ExportSavePresetDialog::accept()
return;
}
QDir d(EncodingParams::get_preset_path());
char preset_path_buf[1024];
preset_path_buf[0] = '\0';
oakengine_encoding_preset_path(
preset_path_buf, static_cast<int>(sizeof(preset_path_buf)));
QDir d(QString::fromUtf8(preset_path_buf));
if (!d.exists()) {
d.mkpath(QStringLiteral("."));
}
QFile f(d.filePath(name_edit_->text()));
if (f.exists()) {
if (d.exists(name_edit_->text())) {
if (QMessageBox::question(
this, tr("Overwrite Preset"),
tr("A preset with the name \"%1\" already exists. Do you wish to overwrite it?")
@@ -94,17 +109,18 @@ void ExportSavePresetDialog::accept()
}
}
if (!f.open(QFile::WriteOnly)) {
const QByteArray full_path =
d.filePath(name_edit_->text()).toUtf8();
const int rc = oakengine_encoding_params_save_file(
params_, full_path.constData());
if (rc != OAKENGINE_OK) {
QMessageBox::critical(
this, tr("Write Error"),
tr("Failed to open file \"%1\" for writing.").arg(f.fileName()));
tr("Failed to save preset to \"%1\".").arg(
QString::fromUtf8(full_path)));
return;
}
params_.save(&f);
f.close();
QDialog::accept();
}
+3 -3
View File
@@ -26,7 +26,7 @@
#include <QLineEdit>
#include <QListWidget>
#include "codec/encoder.h"
#include "oakengine/encoding.h"
namespace olive
{
@@ -34,7 +34,7 @@ namespace olive
class ExportSavePresetDialog : public QDialog {
Q_OBJECT
public:
ExportSavePresetDialog(const EncodingParams &p, QWidget *parent = nullptr);
ExportSavePresetDialog(const OakEngineEncodingParams *p, QWidget *parent = nullptr);
QString get_selected_preset_name() const
{
@@ -47,7 +47,7 @@ public slots:
private:
QLineEdit *name_edit_;
EncodingParams params_;
const OakEngineEncodingParams *params_;
};
}
+18 -31
View File
@@ -1,25 +1,9 @@
/*
* Oak Video Editor - Non-Linear Video Editor
* Copyright (C) 2025 Olive CE 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 "exportsubtitlestab.h"
#include <QGridLayout>
#include "oakengine/encoding.h"
namespace olive
{
@@ -62,32 +46,35 @@ ExportSubtitlesTab::ExportSubtitlesTab(QWidget *parent)
&QWidget::setVisible);
}
int ExportSubtitlesTab::set_format(ExportFormat::Format format)
int ExportSubtitlesTab::set_format(int format)
{
auto vcodecs = ExportFormat::get_video_codecs(format);
auto acodecs = ExportFormat::get_audio_codecs(format);
const bool has_video = oakengine_encoding_format_video_codec_count(format) > 0;
const bool has_audio = oakengine_encoding_format_audio_codec_count(format) > 0;
int scodec_count = oakengine_encoding_format_subtitle_codec_count(format);
auto scodecs = ExportFormat::get_subtitle_codecs(format);
if (!scodecs.empty() && vcodecs.empty() && acodecs.empty()) {
if (scodec_count > 0 && !has_video && !has_audio) {
// If format supports ONLY scodecs, default this to off and disable it
sidecar_checkbox_->setChecked(false);
sidecar_checkbox_->setEnabled(false);
} else {
// If format does not support scodecs, default this to checked and disable it
sidecar_checkbox_->setChecked(scodecs.empty());
sidecar_checkbox_->setEnabled(!scodecs.empty());
sidecar_checkbox_->setChecked(scodec_count == 0);
sidecar_checkbox_->setEnabled(scodec_count > 0);
}
scodecs =
ExportFormat::get_subtitle_codecs(sidecar_format_combobox_->get_format());
// Refresh for sidecar format
int sidecar_fmt = sidecar_format_combobox_->get_format();
scodec_count = oakengine_encoding_format_subtitle_codec_count(sidecar_fmt);
codec_combobox_->clear();
foreach (ExportCodec::Codec scodec, scodecs) {
codec_combobox_->addItem(ExportCodec::get_codec_name(scodec), scodec);
for (int i = 0; i < scodec_count; i++) {
int scodec = oakengine_encoding_format_subtitle_codec_at(sidecar_fmt, i);
char buf[256];
oakengine_encoding_codec_name(scodec, buf, sizeof(buf));
codec_combobox_->addItem(QString::fromUtf8(buf), scodec);
}
return scodecs.size();
return scodec_count;
}
}
+6 -8
View File
@@ -26,7 +26,6 @@
#include <QComboBox>
#include <QLabel>
#include "codec/exportformat.h"
#include "common/qtutils.h"
#include "dialog/export/exportformatcombobox.h"
@@ -47,24 +46,23 @@ public:
sidecar_checkbox_->setChecked(e);
}
ExportFormat::Format get_sidecar_format() const
int get_sidecar_format() const
{
return sidecar_format_combobox_->get_format();
}
void set_sidecar_format(ExportFormat::Format f)
void set_sidecar_format(int f)
{
sidecar_format_combobox_->set_format(f);
}
int set_format(ExportFormat::Format format);
int set_format(int format);
ExportCodec::Codec get_subtitle_codec()
int get_subtitle_codec()
{
return static_cast<ExportCodec::Codec>(
codec_combobox_->currentData().toInt());
return codec_combobox_->currentData().toInt();
}
void set_subtitle_codec(ExportCodec::Codec c)
void set_subtitle_codec(int c)
{
QtUtils::set_combo_box_data(codec_combobox_, c);
}
+37 -23
View File
@@ -29,15 +29,16 @@
#include "exportadvancedvideodialog.h"
#include "node/color/colormanager/colormanager.h"
#include "oakengine/encoding.h"
namespace olive
{
ExportVideoTab::ExportVideoTab(ColorManager *color_manager, QWidget *parent)
ExportVideoTab::ExportVideoTab(OakEngineColorManager *color_manager, QWidget *parent)
: QWidget(parent)
, color_manager_(color_manager)
, threads_(0)
, color_range_(VideoParams::k_color_range_default)
, color_range_(0) // k_color_range_default
{
QVBoxLayout *outer_layout = new QVBoxLayout(this);
@@ -50,17 +51,20 @@ ExportVideoTab::ExportVideoTab(ColorManager *color_manager, QWidget *parent)
outer_layout->addStretch();
}
int ExportVideoTab::set_format(ExportFormat::Format format)
int ExportVideoTab::set_format(int format)
{
format_ = format;
QList<ExportCodec::Codec> vcodecs = ExportFormat::get_video_codecs(format);
setEnabled(!vcodecs.isEmpty());
const int vcodec_count = oakengine_encoding_format_video_codec_count(format);
setEnabled(vcodec_count > 0);
codec_combobox()->clear();
foreach (ExportCodec::Codec vcodec, vcodecs) {
codec_combobox()->addItem(ExportCodec::get_codec_name(vcodec), vcodec);
for (int i = 0; i < vcodec_count; i++) {
int vcodec = oakengine_encoding_format_video_codec_at(format, i);
char buf[256];
oakengine_encoding_codec_name(vcodec, buf, sizeof(buf));
codec_combobox()->addItem(QString::fromUtf8(buf), vcodec);
}
return vcodecs.size();
return vcodec_count;
}
bool ExportVideoTab::is_image_sequence_set() const
@@ -116,9 +120,9 @@ QWidget *ExportVideoTab::setup_resolution_section()
scaling_method_combobox_ = new QComboBox();
scaling_method_combobox_->setEnabled(false);
scaling_method_combobox_->addItem(tr("Fit"), EncodingParams::k_fit);
scaling_method_combobox_->addItem(tr("Stretch"), EncodingParams::k_stretch);
scaling_method_combobox_->addItem(tr("Crop"), EncodingParams::k_crop);
scaling_method_combobox_->addItem(tr("Fit"), OAKENGINE_ENCODING_SCALING_FIT);
scaling_method_combobox_->addItem(tr("Stretch"), OAKENGINE_ENCODING_SCALING_STRETCH);
scaling_method_combobox_->addItem(tr("Crop"), OAKENGINE_ENCODING_SCALING_CROP);
layout->addWidget(scaling_method_combobox_, row, 1);
// Automatically enable/disable the scaling method depending on maintain aspect ratio
@@ -223,9 +227,14 @@ void ExportVideoTab::maintain_aspect_ratio_changed(bool val)
void ExportVideoTab::open_advanced_dialog()
{
// Find export formats compatible with this encoder
QStringList pixel_formats =
ExportFormat::get_pixel_formats_for_codec(format_, get_selected_codec());
// Find pixel formats compatible with this encoder
QStringList pixel_formats;
const int pix_count = oakengine_encoding_pix_fmt_count(format_, get_selected_codec());
for (int i = 0; i < pix_count; i++) {
char buf[64];
oakengine_encoding_pix_fmt_at(format_, get_selected_codec(), i, buf, sizeof(buf));
pixel_formats.append(QString::fromUtf8(buf));
}
ExportAdvancedVideoDialog d(pixel_formats, this);
@@ -256,30 +265,35 @@ void ExportVideoTab::update_frame_rate(Rational r)
void ExportVideoTab::video_codec_changed()
{
ExportCodec::Codec codec = get_selected_codec();
int codec = get_selected_codec();
switch (codec) {
case ExportCodec::k_codec_h264:
case ExportCodec::k_codec_h264rgb:
case OAKENGINE_ENCODING_CODEC_H264:
case OAKENGINE_ENCODING_CODEC_H264RGB:
set_codec_section(h264_section_);
break;
case ExportCodec::k_codec_h265:
case OAKENGINE_ENCODING_CODEC_H265:
set_codec_section(h265_section_);
break;
case ExportCodec::k_codec_a_v1:
case OAKENGINE_ENCODING_CODEC_AV1:
set_codec_section(av1_section_);
break;
case ExportCodec::k_codec_cineform:
case OAKENGINE_ENCODING_CODEC_CINEFORM:
set_codec_section(cineform_section_);
break;
default:
set_codec_section(
ExportCodec::is_codec_a_still_image(codec) ? image_section_ : nullptr);
oakengine_encoding_codec_is_still_image(codec) ? image_section_ : nullptr);
}
// Set default pixel format
QStringList pix_fmts =
ExportFormat::get_pixel_formats_for_codec(format_, codec);
QStringList pix_fmts;
const int pix_count = oakengine_encoding_pix_fmt_count(format_, codec);
for (int i = 0; i < pix_count; i++) {
char buf[64];
oakengine_encoding_pix_fmt_at(format_, codec, i, buf, sizeof(buf));
pix_fmts.append(QString::fromUtf8(buf));
}
if (!pix_fmts.isEmpty()) {
pix_fmt_ = pix_fmts.first();
} else {
+12 -12
View File
@@ -32,8 +32,9 @@
#include "dialog/export/codec/codecstack.h"
#include "dialog/export/codec/h264section.h"
#include "dialog/export/codec/imagesection.h"
#include "node/color/colormanager/colormanager.h"
#include "oakengine/color.h"
#include "widget/colorwheel/colorspacechooser.h"
#include "widget/manageddisplay/colorprocessorhandle.h"
#include "widget/slider/integerslider.h"
#include "widget/standardcombos/standardcombos.h"
@@ -43,9 +44,9 @@ namespace olive
class ExportVideoTab : public QWidget {
Q_OBJECT
public:
ExportVideoTab(ColorManager *color_manager, QWidget *parent = nullptr);
ExportVideoTab(OakEngineColorManager *color_manager, QWidget *parent = nullptr);
int set_format(ExportFormat::Format format);
int set_format(int format);
bool is_image_sequence_set() const;
void set_image_sequence(bool e) const;
@@ -55,13 +56,12 @@ public:
return image_section_->get_time();
}
ExportCodec::Codec get_selected_codec() const
int get_selected_codec() const
{
return static_cast<ExportCodec::Codec>(
codec_combobox()->currentData().toInt());
return codec_combobox()->currentData().toInt();
}
void set_selected_codec(ExportCodec::Codec c)
void set_selected_codec(int c)
{
QtUtils::set_combo_box_data(codec_combobox(), c);
}
@@ -161,11 +161,11 @@ public:
pix_fmt_ = s;
}
VideoParams::ColorRange color_range() const
int color_range() const
{
return color_range_;
}
void set_color_range(VideoParams::ColorRange c)
void set_color_range(int c)
{
color_range_ = c;
}
@@ -204,7 +204,7 @@ private:
IntegerSlider *width_slider_;
IntegerSlider *height_slider_;
ColorManager *color_manager_;
OakEngineColorManager *color_manager_;
InterlacedComboBox *interlaced_combobox_;
PixelAspectRatioComboBox *pixel_aspect_combobox_;
@@ -213,9 +213,9 @@ private:
int threads_;
QString pix_fmt_;
VideoParams::ColorRange color_range_;
int color_range_;
ExportFormat::Format format_;
int format_;
private slots:
void maintain_aspect_ratio_changed(bool val);