Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions encoder_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct EncoderInfo {
uint8_t qp[3]{};
std::map<int, std::string> presets{};
int defaultPreset{};
const char* customParamsKey{};
};

}
4 changes: 4 additions & 0 deletions ffmpeg_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ void FFmpegEncoder::ApplyOptions(AVCodecContext* ctx, UISettingsController& sett
av_opt_set(ctx->priv_data, "preset", preset->second.c_str(), 0);
}
}

if (encoderInfo.customParamsKey != nullptr && !settings.GetCustomParams().empty()) {
av_opt_set(ctx->priv_data, encoderInfo.customParamsKey, settings.GetCustomParams().c_str(), 0);
}
}

StatusCode FFmpegEncoder::DoProcess(HostBufferRef* p_pBuff) {
Expand Down
1 change: 1 addition & 0 deletions svt_av1_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const EncoderInfo SvtAv1Encoder::encoderInfo = {
{12, "12"},
},
.defaultPreset = 8,
.customParamsKey = "svtav1-params",
};

SvtAv1Encoder::SvtAv1Encoder() { FFmpegEncoder::encoderInfo = encoderInfo; }
Expand Down
17 changes: 17 additions & 0 deletions uisettings_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ void UISettingsController::Load(IPropertyProvider* values) {
values->GetINT32(qpId.c_str(), qp);
values->GetINT32(bitrateId.c_str(), bitRate);
values->GetINT32(presetId.c_str(), preset);

std::string customParamsStr;
if (values->GetString(customParamsId.c_str(), customParamsStr)) {
customParams = customParamsStr;
}
}

StatusCode UISettingsController::Render(HostListRef* settingsList) const {
Expand Down Expand Up @@ -59,6 +64,7 @@ void UISettingsController::InitDefaults() {
qpId = prefix + "qp";
bitrateId = prefix + "bitrate";
presetId = prefix + "preset";
customParamsId = prefix + "custom_params";
}

void UISettingsController::SetFirstSupportedQualityMode() {
Expand Down Expand Up @@ -91,6 +97,15 @@ StatusCode UISettingsController::RenderQuality(HostListRef* settingsList) const
}
}

if (encoderInfo.customParamsKey != nullptr) {
HostUIConfigEntryRef item(customParamsId);
item.MakeTextBox("Encoder Params", customParams, "");
if (!item.IsSuccess() || !settingsList->Append(&item)) {
g_Log(logLevelError, "FFmpeg Plugin :: Failed to populate custom params UI entry");
return errFail;
}
}

{
HostUIConfigEntryRef item(qualityModeId);

Expand Down Expand Up @@ -163,3 +178,5 @@ int32_t UISettingsController::GetQP() const { return std::max<int>(0, qp); }
int32_t UISettingsController::GetBitRate() const { return bitRate * 1000; }

int32_t UISettingsController::GetPreset() const { return preset; }

const std::string& UISettingsController::GetCustomParams() const { return customParams; }
3 changes: 3 additions & 0 deletions uisettings_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class UISettingsController final {
int32_t GetQP() const;
int32_t GetBitRate() const;
int32_t GetPreset() const;
const std::string& GetCustomParams() const;

private:
HostCodecConfigCommon commonProps;
Expand All @@ -37,11 +38,13 @@ class UISettingsController final {
int32_t qp{};
int32_t bitRate{};
int32_t preset{};
std::string customParams;

std::string qualityModeId;
std::string qpId;
std::string bitrateId;
std::string presetId;
std::string customParamsId;
};

}
1 change: 1 addition & 0 deletions x264_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const EncoderInfo X264Encoder::encoderInfo = {
{8, "veryslow"},
},
.defaultPreset = 5,
.customParamsKey = "x264-params",
};

X264Encoder::X264Encoder() { FFmpegEncoder::encoderInfo = encoderInfo; }
Expand Down
1 change: 1 addition & 0 deletions x265_encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const EncoderInfo X265Encoder::encoderInfo = {
{8, "veryslow"},
},
.defaultPreset = 5,
.customParamsKey = "x265-params",
};

X265Encoder::X265Encoder() { FFmpegEncoder::encoderInfo = encoderInfo; }
Expand Down